NEWbie asks "is Python a good tool for automated file/folder generation?"

Mark McEahern marklists at mceahern.com
Fri Jun 14 12:50:45 EDT 2002


> I've never used Python, and I'm wondering if you, collectively, think
> that Python is a good language to do this.

Sure.  I'd recommend starting with simple things:

Fire up Python and do this:

>>> import os
>>> path = "c:\type your path here"
>>> print os.listdir(path)

listdir returns a list of the contents of path.  You can use os.path.isdir()
to distinguish files from directories.

Also, note that strings are objects with methods that you can use to do
string manipulation:

>>> s = "foobar"
>>> dir(s)

dir(object) tells you the the attributes of the object.  This encourages
interactive exploration of Python, which is one of the things I think makes
Python eminently easy to (re)learn.  ;-)

I'd recommend reading any one of the fine Python tutorials:

  http://www.python.org/doc/Newbies.html

If you have questions, you can always post them here or:

  http://www.python.org/psa/MailingLists.html#tutor

Cheers,

// mark

p.s.  If you want people to cc you, you can make it easier by using that
email address when sending messages.

-






More information about the Python-list mailing list