Re: [Tutor] sorting and editing large data files

2004-12-16 Thread Rich Krauter
Scott Melnyk wrote: Hello! I recently suffered a loss of programming files (and I had been putting off my backups...) [snip] #regular expression to pull out gene, transcript and exon ids info=re.compile('^(ENSG\d+\.\d).+(ENST\d+\.\d).+(ENSE\d+\.\d)+') #above is match gene, transcript, then one or m

RE: [Tutor] How to substitute an element of a list as a pattern for re.compile()

2004-12-29 Thread Rich Krauter
kumar s wrote: I have Question: How can I substitute an object as a pattern in making a pattern. x = 30 pattern = re.compile(x) Kumar, You can use string interpolation to insert x into a string, which can then be compiled into a pattern: x = 30 pat = re.compile('%s'%x) I really doubt regular

Re: [Tutor] Basic question -> How to use a class from a file?

2005-01-02 Thread Rich Krauter
Bernard Lebel wrote: Okay here comes the next question. In that class, I have 3 functions. Actually, one of them calls the two others. However when I call these functions (wich are placed before the caller in the file), I get an error saying that the global name x (the function name) is not def

Re: [Tutor] CGI help

2005-01-03 Thread Rich Krauter
David Holland wrote: I have written my first cgi script :- The .html code is :- Friends CGI Demo (Static Screen) Friends list for:New User Enter your name> How many friends do you have ? 0 10 25 50 100 The python code is :- #!/usr/bin/env python import cgi reshtml = '''Content-Type: text/html\

Re: [Tutor] CGI help

2005-01-04 Thread Rich Krauter
David Holland wrote: Rich, That worked although I had to set the address to :- http://127.0.0.1:8000/friends1.html Thanks. Good catch, sorry about that. I noticed you had spaces in the "how many" field in your form. Did your cgi still work? If not, I guess you figured that out by now too. Intere

Re: [Tutor] regex problem

2005-01-04 Thread Rich Krauter
Michael Powe wrote: Hello, I'm having erratic results with a regex. I'm hoping someone can pinpoint the problem. This function removes HTML formatting codes from a text email that is poorly exported -- it is supposed to be a text version of an HTML mailing, but it's basically just a text version o

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-15 Thread Rich Krauter
Brian van den Broek wrote: [snip text] class A: def __init__(self): self.something = None self.something_else = None self.still_another_thing = None def update(self, data): for key in metadata_dict: if data.startswith(key): exec('''self.%s = ""

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Rich Krauter
Brian van den Broek wrote: [text and code snipped] FWIW, I ran your code using python 2.3.4 on linux with the following modifications, and it worked fine (no failing tests out of 9): 1- added 'from sets import Set as set' since set() isn't built in in 2.3 2- changed True back to False in the foll

Re: [Tutor] odd behavior within __init__

2005-04-14 Thread Rich Krauter
Orri Ganel wrote: Hello all, As part of a project i'm doing (mostly for the fun of it), I have a class which creates a sort of wrapper around any object to make it suitable for use in a custom container. However, if the class receives an already wrapped object, I want it to just return the object

Re: [Tutor] iterator question for a toy class

2005-04-23 Thread Rich Krauter
Marcus Goldfish wrote: I'm trying to understand custom iterators in Python, and created the following toy class for sequence comparison, which seems to work: class Foo(object): """A toy class to experiment with __eq__ and __iter__""" def __init__(self, listA, listB): self.head, self.tai

Re: [Tutor] iterator question for a toy class

2005-04-23 Thread Rich Krauter
Kent Johnson wrote: Rich Krauter wrote: 2) Or, if you really want your __eq__ method to use the iterator returned by __iter__(), def __eq__(self, other): for i, j in map(None,self, other): if i != j: return False return True That's not right either, it will co

Re: [Tutor] design questions: pythonic approach to ostriches

2005-04-23 Thread Rich Krauter
Brian van den Broek wrote: Hi all, I am wondering about the Pythonic way to handle the problem of ostriches, emus, and penguins. (I cannot recall from where I got the example.) Here's what I mean: class Bird(object): def fly(self): # flying logic here def lay(self): # egg

Re: [Tutor] Class and Scope Question

2005-05-06 Thread Rich Krauter
Tim Johnson wrote: > The following test script is kind of got me baffled: > #!/usr/local/bin/python > class Eval: > def __getitem__(self,key): > return eval(key) > ##def test(): > ## i = 100 > ## b = ["My", "name", "is", "Tim"] > ## test = "this is number %(str(i))s for a test %(' '.

Re: [Tutor] ftplib: retrbinary all files in directory

2005-05-31 Thread Rich Krauter
Israel Carr wrote: > I'm using ftplib to connect to a server, and I want to grab every file > from a specific folder. The filenames change frequently. What is the > best way to use retrbinary with wildcards(or some better option) to > transfer all files? > > Thanks, > Israel > > ___