[Tutor] returning the entire line when regex matches

2009-05-03 Thread Nick Burgess
How do I make this code print lines NOT containing the string 'Domains'? import re for line in log: if re.search (r'Domains:', line): print line This does not work... if re.search != (r'Domains:', line): ___ Tutor maillist - Tutor@pytho

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Steve Willoughby
Nick Burgess wrote: > How do I make this code print lines NOT containing the string 'Domains'? > > > import re > for line in log: > if re.search (r'Domains:', line): > print line > > > This does not work... > > if re.search != (r'Domains:', line): re.search (r'Domains:', line) is

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Alan Gauld
"Nick Burgess" wrote How do I make this code print lines NOT containing the string 'Domains'? Don't use regex, use in: for line in log: if "Domains" in line: print line This does not work... if re.search != (r'Domains:', line): Because you are assigning a tuple containing

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Steve Willoughby
Alan Gauld wrote: >> if re.search != (r'Domains:', line): > > Because you are assigning a tuple containing a string and a line of text > to a name which is currently bound to a function object (re.search) Actually, he's COMPARING the two, not assigning. But comparing a function object and a tupl

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Alan Gauld
"Steve Willoughby" wrote if re.search != (r'Domains:', line): Because you are assigning a tuple containing a string and a line of text to a name which is currently bound to a function object (re.search) Actually, he's COMPARING the two, not assigning. But comparing a function object and a

Re: [Tutor] returning the entire line when regex matches

2009-05-03 Thread Alan Gauld
"Alan Gauld" wrote How do I make this code print lines NOT containing the string 'Domains'? Don't use regex, use in: for line in log: if "Domains" in line: print line Should, of course, be if "Domains" not in line: print line Alan G. _

[Tutor] Code Dosent work.

2009-05-03 Thread Jacob Mansfield
hi everyone, I'm a bit new here but i was wondering if someone could check some of my code, it's not doing quite what it's meant to. thanks Databox_2_0.py: import pygame, sys, os pygame.init() def load(filename): if filename != '': e = 1 dec = "placeholder" fic = open(

Re: [Tutor] Code Dosent work.

2009-05-03 Thread David
Jacob Mansfield wrote: hi everyone, I'm a bit new here but i was wondering if someone could check some of my code, it's not doing quite what it's meant to. thanks Works without pygame; filename, blank for none. Welcome to databox V2.0. 1. Searth the database. 2. Add a record. 3.

[Tutor] Iterating over a long list with regular expressions and changing each item?

2009-05-03 Thread Dan Liang
Hi tutors, I am working on a file and need to replace each occurrence of a certain label (part of speech tag in this case) by a number of sub-labels. The file has the following format: word1 \tTag1 word2 \tTag2 word3 \tTag3 Now the tags are complex and I wanted to split them in a

Re: [Tutor] Code Dosent work.

2009-05-03 Thread Lie Ryan
David wrote: Jacob Mansfield wrote: hi everyone, I'm a bit new here but i was wondering if someone could check some of my code, it's not doing quite what it's meant to. thanks Why were you using pygame? The only line that uses pygame is pygame.time.delay(900). It is an overkill to import

Re: [Tutor] Code Dosent work.

2009-05-03 Thread Stefan Behnel
Jacob Mansfield wrote: > hi everyone, I'm a bit new here but i was wondering if someone could check > some of my code, it's not doing quite what it's meant to. As a general remark: it's a good idea to add a note on what your code is supposed to do, and in what way it behaves unexpectedly, i.e. wha