R
Raaijmakers, Vincent (GE Infrastructure)
What is the easiest way of getting this information out of a string:
foo = "My number 70 is what I want to parse" => 70
foo = "My info {info} between the curly brackets is what I want to parse" => {info}
foo = "My info between [hello world] is what I want to parse" => [hello world]
At this moment my way to go is splitting the strings in substring, and do different checks on these substrings like:
- try: int(substring)
- substring.find('{') or substring.find('[')
Works but.. my guess is that it can be way more smarter, I must miss a strong library that can help me in simplifying the job.
Thanks,
Vincent
-----Original Message-----
From: [email protected]
[mailto[email protected]]On
Behalf Of Duncan Booth
Sent: Monday, March 01, 2004 8:54 AM
To: (e-mail address removed)
Subject: Re: pyAlbum
A few more:
Slide 17: 'Tuples are enclosed in parentheses'
The commas make the tuple, not the parentheses. The first example could
equally be written:
myTuple = 1, 4, 5
Parentheses are only required to remove ambiguity (or for empty tuples).
Slide 21, it is worth pointing out the weakness of '{', '}' which is that
the parenthese you think match up by looking at the block structure aren't
necessarily the ones that do match: as in the example given where the last
'}' actually closes the else block.
The 'if' statement shows the full range if..elif..else. It would be
consistent to mention the else clause on while and for loops also.
foo = "My number 70 is what I want to parse" => 70
foo = "My info {info} between the curly brackets is what I want to parse" => {info}
foo = "My info between [hello world] is what I want to parse" => [hello world]
At this moment my way to go is splitting the strings in substring, and do different checks on these substrings like:
- try: int(substring)
- substring.find('{') or substring.find('[')
Works but.. my guess is that it can be way more smarter, I must miss a strong library that can help me in simplifying the job.
Thanks,
Vincent
-----Original Message-----
From: [email protected]
[mailto[email protected]]On
Behalf Of Duncan Booth
Sent: Monday, March 01, 2004 8:54 AM
To: (e-mail address removed)
Subject: Re: pyAlbum
Some fairly rudimentary fact-checking would have prevented the
errors/oversights listed above.
A few more:
Slide 17: 'Tuples are enclosed in parentheses'
The commas make the tuple, not the parentheses. The first example could
equally be written:
myTuple = 1, 4, 5
Parentheses are only required to remove ambiguity (or for empty tuples).
Slide 21, it is worth pointing out the weakness of '{', '}' which is that
the parenthese you think match up by looking at the block structure aren't
necessarily the ones that do match: as in the example given where the last
'}' actually closes the else block.
The 'if' statement shows the full range if..elif..else. It would be
consistent to mention the else clause on while and for loops also.