George Sakkis wrote:
> By the way, an easier way to deal with paths is the path.py module
> (http://www.jorendorff.com/articles/python/path/). Your example could
> be rewritten simply as:
>
> from path import path
> for html_file in path(start_dir).walkfiles('*.html'):
> print 'html file found
codefire wrote:
> Ah of course, isfile(f) can only return true if it can find f! :)
>
> I'm going to investigate those other functions too :)
>
> Thanks a lot guys!
> Tony
By the way, an easier way to deal with paths is the path.py module
(http://www.jorendorff.com/articles/python/path/). Your ex
Ah of course, isfile(f) can only return true if it can find f! :)
I'm going to investigate those other functions too :)
Thanks a lot guys!
Tony
--
http://mail.python.org/mailman/listinfo/python-list
> [code]
> import os
>
> def print_tree(start_dir):
> for f in os.listdir(start_dir):
> fp = os.path.join(start_dir, f)
> print fp
> if os.path.isfile(fp): # will return false if use f here!
> if os.path.splitext(fp)[1] == '.html':
>
codefire wrote:
> As above it all works as expected. However, on the marked line, if I
> use f instead of fp then that condition returns false! Surely,
> isfile(f) should return true, even if I just give a filename, rather
> than the full path?
Hi Tony,
Actually the file is in a different directo
codefire wrote:
> Hi,
>
> I have some simple code - which works...kind of..here's the code:
>
> [code]
> import os
>
> def print_tree(start_dir):
> for f in os.listdir(start_dir):
> fp = os.path.join(start_dir, f)
> print fp
> if os.path.isfile(fp): # will return fal
ining.
Hope this was helpful.
Yours truly,
Rich.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
codefire
Sent: Tuesday, September 19, 2006 1:08 PM
To: python-list@python.org
Subject: Curious issue with simple code
Hi,
I have some simple code -
codefire wrote:
> As above it all works as expected. However, on the marked line, if I
> use f instead of fp then that condition returns false! Surely,
> isfile(f) should return true, even if I just give a filename, rather
> than the full path?
try printing both "f" and "fp", and see if you can
Hi,
I have some simple code - which works...kind of..here's the code:
[code]
import os
def print_tree(start_dir):
for f in os.listdir(start_dir):
fp = os.path.join(start_dir, f)
print fp
if os.path.isfile(fp): # will return false if use f here!
if os.path.