howto? "def create_dir"

Robin Munn rmunn at pobox.com
Mon Dec 2 12:11:03 EST 2002


Michael <micyaro at hotmail.com> wrote:
> Hi all,
> 
> I´ve wrote a script in python which remote copies zip files from a server to
> another server. It upacks it and delete the source-zipfile from the remote
> server. All is working fine. But since a few days i got stuck with a simple
> "mkdir-def"...
> 
> I have built a class in python containig several def´s for copying,
> upacking, checking.... Now I am trying to write a def which creates a
> directory at the destination server. On the destination server I ve got a
> directory (/some/where) where the upacked files are placed. I would like to
> write a def which creates the dest.dir (/some/where/destdir) where the name
> "destdir" is taken from a variable within the class.
> 
> After studying 4 python books and asking google for help without success, I
> have to ask the python gurus in this group :-) Thanks in advanced.

Well, without more detailed information, all I have to go on in
answering your question is guesswork as to what you're trying to do.

If all you're trying to do is create a directory (like "mkdir foo" on
Unix), then you probably want to use:

    import os
    # Should be portable, but not guaranteed
    os.mkdir('/some/where/foo')
    # Or, guaranteed to be portable:
    dirname = os.path.join('','some','where','foo')
    os.mkdir(dirname)

If you know you're only going to be running on Unix, you could go ahead
and use slashes in the path; but it's always a good idea to write
portable code, so I would recommend using os.path.join to construct your
path.

If this isn't what you were trying to do, let us know.

-- 
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838    50FF 2478 CFFB 081A 8338  54F7 845D ACFD 6AFB 6838



More information about the Python-list mailing list