How to detect if file is a directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • César Leonardo Blum Silveira

    #1

    How to detect if file is a directory

    Hello all, I'm new to this list.

    How can I detect if a file is a directory or not?

    Thanks

    César
  • Tim Jarman

    #2
    Re: How to detect if file is a directory

    César Leonardo Blum Silveira wrote:
    [color=blue]
    > Hello all, I'm new to this list.
    >
    > How can I detect if a file is a directory or not?
    >
    > Thanks
    >
    > César[/color]

    The os module contains many helpful tools for working with files,
    directories, links and so forth. Check out the docs and marvel. The
    following snippet answers your specific question:

    <code>
    import os.path

    if os.path.isdir("/some/path/here"):
    print "It's a directory!"
    </code>
    --
    Website: www DOT jarmania FULLSTOP com

    Comment

    • César Leonardo Blum Silveira

      #3
      Re: How to detect if file is a directory

      Thanks :-)

      On Apr 9, 2005 3:55 PM, Tim Jarman <tmj@spamlessja rmania.com> wrote:[color=blue]
      > César Leonardo Blum Silveira wrote:
      > [color=green]
      > > Hello all, I'm new to this list.
      > >
      > > How can I detect if a file is a directory or not?
      > >
      > > Thanks
      > >
      > > César[/color]
      >
      > The os module contains many helpful tools for working with files,
      > directories, links and so forth. Check out the docs and marvel. The
      > following snippet answers your specific question:
      >
      > <code>
      > import os.path
      >
      > if os.path.isdir("/some/path/here"):
      > print "It's a directory!"
      > </code>
      > --
      > Website: www DOT jarmania FULLSTOP com
      > --
      > http://mail.python.org/mailman/listinfo/python-list
      >[/color]

      Comment

      Working...