Nested os.path.join()'s

Grant Edwards grante at visi.com
Mon May 5 10:35:44 EDT 2008


On 2008-05-05, Paul Scott <pscott at uwc.ac.za> wrote:

> Today, I needed to concatenate a bunch of directory paths and files
> together based on user input to create file paths. I achieved this
> through nested os.path.join()'s which I am unsure if this is a good
> thing or not.
>
> example:
>
> if os.path.exists(os.path.join(basedir,picdir)) == True :
>     blah blah

That's not an example of nested os.path.join()'s.

> Question is, is there a better way of doing this? 

I don't think so.

> The above *works* but it looks kinda hackish...

What about it do you think looks hackish?

I supposed you could do this instead:

  path = os.path.join(basedir,picdir)
  if os.path.exists(path) == True :
      blah blah

But I don't really see why that's any better.      

-- 
Grant Edwards                   grante             Yow! Like I always say
                                  at               -- nothing can beat
                               visi.com            the BRATWURST here in
                                                   DUSSELDORF!!



More information about the Python-list mailing list