os.path.isdir question
Hello,
I'm having some problems with os.path.isdir I think it is something
simple that I'm overlooking.
#!/usr/bin/python
import os
my_path = os.path.expanduser("~/pictures/")
print my_path
results = os.listdir(my_path)
for a_result in results:
if os.path.isdir(str(my_path) + str(a_result)):
results.remove(a_result)
for x in results: print x
The problem is, that the directories are never removed. Can anyone
point out what I'm missing that is causing the bug? Is there a better
way of doing this?
Thanks,
--
http://mail.python.org/mailman/listinfo/python-list
Re: os.path.isdir question
On Mar 15, 9:27 pm, Benjamin <[EMAIL PROTECTED]> wrote:
> On Mar 15, 8:12 pm, lampshade <[EMAIL PROTECTED]> wrote:> Hello,
>
> > I'm having some problems with os.path.isdir I think it is something
> > simple that I'm overlooking.
>
> > #!/usr/bin/python
> > import os
>
> > my_path = os.path.expanduser("~/pictures/")
> > print my_path
> > results = os.listdir(my_path)
> > for a_result in results:
> > if os.path.isdir(str(my_path) + str(a_result)):
>
> Try if os.path.isdir(os.path.join(my_path, a_result)):>
> results.remove(a_result)
>
> > for x in results: print x
>
> > The problem is, that the directories are never removed. Can anyone
> > point out what I'm missing that is causing the bug? Is there a better
> > way of doing this?
>
> You should always use os.path.join to join paths. You shouldn't add
> them like normal strings. I suspect you're getting a combination which
> doesn't exist, so it isn't a dir. :)
>
>
>
> > Thanks,
Thanks, that nailed it perfectly! I'll remember the os.path.join from
now on!
--
http://mail.python.org/mailman/listinfo/python-list
Arch problems--how do I build PIL to be 64 bit so it plays nicely on OS X?
Hello, I'm using python + django to do some web design and I would really like to use the python image library as part of this. There seems to be a problem, however, with apache and mod_python being 64 bit while my python image library(PIL) is only 32 bit. Does anyone have experience with building the correct architectures so that OS X 10.5 plays nicely? I think, when it comes down to it, I just need PIL at this point to be x86_64 so that it plays with apache and mod_python. Any advice, hand-holding, or sage wisdom? -- http://mail.python.org/mailman/listinfo/python-list
