Dear all,
Thanks for all your help. I followed Alan's suggestion -- dealing with the
directory search path, by the method sys.path.append(). At first I thought
it would mess up the whole sys.path after running the script. But it
actually doesn't. Thanks again!
Regards,
PB
___
Alan,
Good point. Earlier I was trying to figure out how the script worked, and
having else: print "break" seemed to help with that. For example, in one
version that I was tinkering with, break was printed 17 times. In the
current version, break is printed twice.
hope that makes sense,
Grnat
O
"Grant Hagstrom" <[EMAIL PROTECTED]> wrote
> The reason why I didn't want the import solution is that I am
> learning
> python because I want to parse text data. This problem was perfect
> practice.
The best book on this topic is David Mertz' book Text Processing in
Python. The draft version i
Grant Hagstrom wrote:
> Thanks for the links. I'll check them out. You don't happen to have any
> parsing tutorials bookmarked somewhere do you? I'm already exploring
> http://gnosis.cx/TPiP/. It's pretty heavy though.
For general text processing, you might want to browse the Text section
of t
Grant,
> My question is, is it possible to strip out multiple characters at once?
Kent answered that bit.
> started = False
> for line in file('mylist.py'):
> if 'jobs' in line and not started:
> ...
>if ']' not in line and started:
>
jobs.append(line.strip('...'))
>else: p
Kent,
Your multistrip tid-bit worked perfectly. Thanks!
The reason why I didn't want the import solution is that I am learning
python because I want to parse text data. This problem was perfect practice.
Thanks for the links. I'll check them out. You don't happen to have any
parsing tutorials b
Grant Hagstrom wrote:
> Thanks for your help Alan.
>
> I found that when I used the code, it did returne a list but it is
> riddled with formatting characters.
> My question is, is it possible to strip out multiple characters at once?
Yes, just pass multiple characters to strip(), e.g.
line = li
Thanks for your help Alan.
I found that when I used the code, it did returne a list but it is riddled
with formatting characters.
My question is, is it possible to strip out multiple characters at once?
started = False
for line in file('mylist.py'):
if 'jobs' in line and not started:
j
Hi Grant,
> I'm a newbie and this is my first script submission to this email list.
> I was able to parse out the jobs list into a string: "jobs = [ . . ."
> However, I can't make python interpret that string as the command "jobs = [
> some list]"
There are ways of doing that but unless you are
Hey,
I'm a newbie and this is my first script submission to this email list.
I was able to parse out the jobs list into a string: "jobs = [ . . ."
However, I can't make python interpret that string as the command "jobs = [
some list]"
#SCRIPT
# open the file and assign it to the variable "thefi
"Preecha Bundrikwong" <[EMAIL PROTECTED]> wrote
> I have a text file (mylist.py actually), it contains exactly below:
> ---
> # file mylist.py
> jobs = [
>'Lions',
>'SysTest',
>]
>
>
> I want to write another script and get the list "jobs" from
> I have a text file (mylist.py actually), it contains exactly below:
> ---
> # file mylist.py
> jobs = [
> 'Lions',
> 'SysTest',
> 'trainDD',
> 'Cats',
> 'train',
> 'sharks',
> 'whale',
> ]
>
>
> I want
Dear Tutors,
I have a text file (mylist.py actually), it contains exactly below:
---
# file mylist.py
jobs = [
'Lions',
'SysTest',
'trainDD',
'Cats',
'train',
'sharks',
'whale',
]
I want to write another script
13 matches
Mail list logo