howto? "def create_dir"
Michael
micyaro at hotmail.com
Mon Dec 2 14:25:12 EST 2002
First of all I should have mentioned the script is running on HP-UX
workstations on the intranet.
What I am trying to do is not a "simple" os.makedir. It should be embedded
in a class where the directory name is given by a variable (after a name
resolving process).
I ´ll try to make an example:
class remote_copy(self,...):
def command_rcp...
dest_dir = /some/where
def name_resolve(...):
part_name1 = foo
part_name2 = bar
def create_dir(...):
new_dir = dest_dir + "/" + "part_name1"
Maybe now you´ve got an idea of what I am trying to do... If not, please let
me know to give you more information.
Thanks,
Mike
"Robin Munn" <rmunn at pobox.com> schrieb im Newsbeitrag
news:slrnaun58c.dc3.rmunn at rmunnlfs.dyndns.org...
> 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