[Tutor] Getting started with Python

2008-05-16 Thread ppaarrkk
I can't. >>> import file.py is all very well if the interpreter knows where file.py is. I want to do this : >>> import /directory1/directory2/file.py Is this not possible ? -- View this message in context: http://www.nabble.com/Getting-started-with-Python-tp17273337p17273337.html Sent

[Tutor] sys.path.append

2008-12-17 Thread ppaarrkk
I can do this : >>> sys.path.append ( 'C:\dump1' ) but not : >>> x = 'C:\dir1' >>> sys.path.append(x) or : but not : >>> x = ['C:\dir1'] >>> sys.path.append(x) Can I append variables to the path, rather than explicit strings ? -- View this message in context: http://www.nabble.com/sys.p

[Tutor] Equivalent of grep in python

2008-12-21 Thread ppaarrkk
The following works : file1 = open (file0, "r") re.findall ( 'some_text', file1.readline() ) But this doesn't : re.findall ( 'some_text', file1.readlines() ) How do I use grep for a whole text file, not just a single string ? -- View this message in context: http://www.nabble.com/Equival

Re: [Tutor] Equivalent of grep in python

2008-12-21 Thread ppaarrkk
rc.count('\n', 0, start) + 1 offset = start - src.rfind('\n', 0, start) word = m.group(1) print "2.htm(%s,%s): %s" % (lineno, offset, word) Is there not a simpler way than this ? ppaarrkk wrote: > > The following works : > &g