Re: [Tutor] Getting traceback info from C-API

2010-04-05 Thread Stefan Behnel
Shu, 06.04.2010 01:06: I have a CAPI extension module that is giving me MemoryError exceptions from once in a while with no other information MemoryError is a bit special in that it usually only occurs when memory allocation fails, in which case raising a new exception object would likely al

[Tutor] Extracting lines in a file

2010-04-05 Thread ranjan das
Hi, I am new to python, and specially to file handling. I need to write a program which reads a unique string in a file and corresponding to the unique string, extracts/reads the n-th line (from the line in which the unique string occurs). I say 'n-th line' as I seek a generalized way of doing

Re: [Tutor] Matching zipcode in address file

2010-04-05 Thread TGW
I got it. I was comparing '345' to '345\n' Adding the '\n' to the slice did indeed do the trick. #!/usr/bin/env python import string def main(): infile = open("filex") outfile = open("results_testx", "w") zips = open("zippys", "r") match_zips = zips.readlines() lines =

Re: [Tutor] Matching zipcode in address file

2010-04-05 Thread TGW
OK - you handled the problem regarding reading to end-of-file. Yes it takes a lot longer, because now you are actually iterating through match_zips for each line. How large are these files? Consider creating a set from match_zips. As lists get longer, set membership test become faster than list

Re: [Tutor] Menu data from file

2010-04-05 Thread Lie Ryan
On 04/06/10 08:05, Neven Goršić wrote: > OK, I will describe my "case". > > I use menu date stored in list "shape" in file CMFlowData.py in the same > directory as my main program x.py. In the beginning of the program I > have command: > > import CMFlowData > > and everything works fine till I m

Re: [Tutor] Scraping gov site: site looking for Flash player

2010-04-05 Thread Benno Lang
On 6 April 2010 03:31, Roy Hinkelman wrote: > I am using urllib2 to open some government pages, and they have some js > checking for Flash on my computer. > Is there a way to show them that I have flash? Or possibly another solution? >From reading the JavaScript, you should fetch the URL domain.t

Re: [Tutor] Simple bank account oriented object

2010-04-05 Thread Steven D'Aprano
On Tue, 6 Apr 2010 06:31:30 am Marco Rompré wrote: > Hi im doin a programmin course at university and in one on my > exercise i have to do that > > I had to define a class CompteBancaire(CompteBancaire is bankaccount > in french), that would allow me to create objects Compte1, > Compte2,etc. [...]

[Tutor] Getting traceback info from C-API

2010-04-05 Thread Shu
Hi, I have a CAPI extension module that is giving me MemoryError exceptions from once in a while with no other information, so clearly none of my exception handlers are catching it. Is there any way I can traceback information for the extension module? Thanks in advance, .S __

Re: [Tutor] Simple bank account oriented object

2010-04-05 Thread Alan Gauld
I don't speak French so I'm struggling a bit with the variable names, however... "Marco Rompré" wrote in message class CompteBancaire: def __init__(self,nom,solde,interet): #Nous allons instancier et self.nom, self.solde, self.interet = nom,solde,interet def depot(self,somme

Re: [Tutor] Menu data from file

2010-04-05 Thread Neven Goršić
OK, I will describe my "case". I use menu date stored in list "shape" in file CMFlowData.py in the same directory as my main program x.py. In the beginning of the program I have command: import CMFlowData and everything works fine till I make executable with py2exe. There are no error during "co

[Tutor] Need Maze traverse to move through start and find exit. replacing x on the path.

2010-04-05 Thread Ravinder Singh
I do not know the code to move the traversal. Maze = [ [ '#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' ],\ [ '#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' ],\ [ '#','#','#','#','#','#','#','#','#','#','#','#','

Re: [Tutor] Simple bank account oriented object

2010-04-05 Thread Marco Rompré
Hi im doin a programmin course at university and in one on my exercise i have to do that I had to define a class CompteBancaire(CompteBancaire is bankaccount in french), that would allow me to create objects Compte1, Compte2,etc. The following methods need to be defined - depot(somme)

Re: [Tutor] New class, how return value of x in interactive shell

2010-04-05 Thread Alan Gauld
"Vincent Davis" wrote class BString(XString): """ Biological string """ _bstring_constructor = biostrings.BString @classmethod def new(cls, x): """ :param x: a (biological) string """ res = cls(cls._bstring_constructor(conversion.py2ri(x))) _setExtractDelegato

Re: [Tutor] New class, how return value of x in interactive shell

2010-04-05 Thread Alan Gauld
"Vincent Davis" wrote Take a look at the repr and str methods: http://docs.python.org/reference/datamodel.html#basic-customization Ok so I am still a little confused, It seems that __str__ is used for print and str() That's right and repr() is used when evaluating the object, as at the >>

Re: [Tutor] New class, how return value of x in interactive shell

2010-04-05 Thread Vincent Davis
> > That' a very strange idiom in Python. > Can you show us the class definition? It's a bioconductor extension to rpy2 http://www.bitbucket.org/lgautier/rpy2-bioc-extensions/overview/ I am trying to learn R and at they same time more about python and R bioconductor packages. So no it is not home

Re: [Tutor] New class, how return value of x in interactive shell

2010-04-05 Thread Alan Gauld
"Vincent Davis" wrote I am working an a open source project and would like to add feature to a class. Current action: in:>>>b = BString.new('I am a BString object') That' a very strange idiom in Python. Can you show us the class definition? out: >>>b in:>>> in:>>>print(b) out:

Re: [Tutor] New class, how return value of x in interactive shell

2010-04-05 Thread Vincent Davis
Take a look at the repr and str methods: http://docs.python.org/reference/datamodel.html#basic-customization Ok so I am still a little confused, It seems that __str__ is used for print and str() byt what allows whats below. That is why does just entering the name of the instance return print(b).

[Tutor] Scraping gov site: site looking for Flash player

2010-04-05 Thread Roy Hinkelman
Interesting. I am using urllib2 to open some government pages, and they have some js checking for Flash on my computer. Is there a way to show them that I have flash? Or possibly another solution? My code: user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = {'User-Agent' : us

Re: [Tutor] New class, how return value of x in interactive shell

2010-04-05 Thread Wayne Werner
On Mon, Apr 5, 2010 at 12:08 PM, Vincent Davis wrote: > I am working an a open source project and would like to add feature to a > class. > Current action: > in:>>>b = BString.new('I am a BString object') > out: >>>b > in:>>> > in:>>>print(b) > out: >>> 21-letter "BString" instance >

[Tutor] New class, how return value of x in interactive shell

2010-04-05 Thread Vincent Davis
I am working an a open source project and would like to add feature to a class. Current action: in:>>>b = BString.new('I am a BString object') out: >>>b in:>>> in:>>>print(b) out: >>> 21-letter "BString" instance seq: I am a BString object What I would like is to be ab

Re: [Tutor] Menu data from file

2010-04-05 Thread Lie Ryan
On 04/05/10 17:39, Neven Goršić wrote: > Thank you for mentioning the possible options. > I already use option where I import .py module, > but I run into troubles when making executable with py2exe. Maybe you should elaborate what problems you're experiencing with py2exe? Probably we can solve th

Re: [Tutor] Matching zipcode in address file

2010-04-05 Thread bob gailer
On 4/5/2010 1:15 AM, TGW wrote: Sorry - my mistake - try: infile = open("filex") match_zips = open("zippys") result = [line for line in infile if line in match_zips] print result When I apply the readlines to the original file, It is taking a lot longer to process and the outfile still remains

Re: [Tutor] Menu data from file

2010-04-05 Thread Neven Goršić
Thank you for mentioning the possible options. I already use option where I import .py module, but I run into troubles when making executable with py2exe. I suppose that XML approach is the most general method. Can you recommend a good introduction text (not for experts :-)) and give more details

Re: [Tutor] Matching zipcode in address file

2010-04-05 Thread ALAN GAULD
Please use Reply All whern responding to the list. > lines = [line for line in infile if line[149:154] not in match_zips] > >Nope. I tried that. I actually modified your comprehension >that you provided about a month ago. >Works great for NOT matching, but can't figure out how to match. >Do