Re: [Tutor] changing string in place

2009-01-09 Thread Martin Walsh
Jon Crump wrote: > I'm still faced with the problem of the javascript months being 0 > indexed. I have to add 1 to group \2 in order to get my acurate > date-string. Obviously I can't do > > print jdate.sub(r'"\1-\2+1-\3"', s) > > because the first argument to sub() is a string. How can I act on \2

Re: [Tutor] website login

2009-01-09 Thread Kent Johnson
On Fri, Jan 9, 2009 at 6:53 PM, phr34kc0der wrote: > Hi everyone, > > I have a python question i would like to ask. > > Im trying to write a script to login to a website and mirror it. I need to > submit a post request to /login.php which is fine, but how can i access > other pages on the site. S

Re: [Tutor] changing string in place

2009-01-09 Thread Martin Walsh
Jon Crump wrote: > Dear all, > > I've been around and around with this and can't seem to conceptualize it > properly. > > I've got a javascript object in a text file that I'd like to treat as > json so that I can import it into a python program via > simplejson.loads(); however, it's not proper j

[Tutor] changing string in place

2009-01-09 Thread Jon Crump
Dear all, I've been around and around with this and can't seem to conceptualize it properly. I've got a javascript object in a text file that I'd like to treat as json so that I can import it into a python program via simplejson.loads(); however, it's not proper json because it has new Date(

[Tutor] website login

2009-01-09 Thread phr34kc0der
Hi everyone, I have a python question i would like to ask. Im trying to write a script to login to a website and mirror it. I need to submit a post request to /login.php which is fine, but how can i access other pages on the site. For example data = urllib.urlencode({"username" : "my

Re: [Tutor] Where's Psyco now?

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 10:41 AM, Vicent wrote: > Hello. This is my first message to the list. > > In this article written in 2002 > > http://www.ibm.com/developerworks/library/l-psyco.html > > they talk about Psyco as a module that makes it possible to accelerate > Python. > > Is it still a state-

[Tutor] Where's Psyco now?

2009-01-09 Thread Vicent
Hello. This is my first message to the list. In this article written in 2002 http://www.ibm.com/developerworks/library/l-psyco.html they talk about Psyco as a module that makes it possible to accelerate Python. Is it still a state-of-the-art module? I found it here also: http://pypi.python.org

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread culpritNr1
Hello Kent and All, Errata: int() does work. I think that in my test code a number such as '4.5' might have slipped in and then int() protested. eval() worked in all my attempts. So, thanks Daniel Sarmiento, your solution is correct as is. By the way, when I said 'cast' I really meant 'conver

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread wesley chun
>> A tuple of exceptions works, just like what we did above, and more, >> i.e., (IndexError, ValueError, TypeError, KeyError... >> > Thank you, thank you, thank you! I'm sure it's been staring me in the face, > but I never realized I could use a tuple of exception types - that's why I > said it wa

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread spir
Forgot a "detail" > def possible_cube(val): > try: > return val ** 3 > except TypeError: > return val denis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread spir
Le Fri, 9 Jan 2009 08:10:27 -0800 (PST), culpritNr1 a écrit : > > Hello Denis and All, > > Your solution does show elegance. To remind people, it's this one: > > lol = [[1,2,3],[4,5,6],[7,8,9]] > new_lol = [[a,b**3,c] for [a,b,c] in lol] > print lol > print new_lol > ==> > [[1, 2, 3], [4, 5, 6

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread Kent Johnson
On Fri, Jan 9, 2009 at 11:23 AM, culpritNr1 wrote: > That is EXACTLY what I was looking for. > > Actually, int() does not really work but this does: > > [ [line[0], eval(line[1]), eval(line[2])] + line[3:] for line in LoL] That's strange. What happened when you tried int() ? What version of Pytho

Re: [Tutor] What does OP stand for?

2009-01-09 Thread Tim Golden
Eduardo Vieira wrote: Hello, I'm new to this list, and am enjoying it. I just wonder what "OP" stands for, as I have seen quite a few mentions in the python lists Original Poster - ie whoever it was who first raised the question we're discussing now. In the case of this thread, you're the OP.

Re: [Tutor] What does OP stand for?

2009-01-09 Thread Tim Golden
Eduardo Vieira wrote: Hello, I'm new to this list, and am enjoying it. I just wonder what "OP" stands for, as I have seen quite a few mentions in the python lists Original Poster - ie whoever it was who first raised the question we're discussing now. In the case of this thread, you're the OP.

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread culpritNr1
Thanks Daniel, That is EXACTLY what I was looking for. Actually, int() does not really work but this does: [ [line[0], eval(line[1]), eval(line[2])] + line[3:] for line in LoL] Again, thanks. culpritNr1 Daniel Sarmiento-2 wrote: > > I am not an expert and don't know if this is considered

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread culpritNr1
Hello Denis and All, Your solution does show elegance. To remind people, it's this one: lol = [[1,2,3],[4,5,6],[7,8,9]] new_lol = [[a,b**3,c] for [a,b,c] in lol] print lol print new_lol ==> [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [[1, 8, 3], [4, 125, 6], [7, 512, 9]] Now, as I said in my original pos

[Tutor] What does OP stand for?

2009-01-09 Thread Eduardo Vieira
Hello, I'm new to this list, and am enjoying it. I just wonder what "OP" stands for, as I have seen quite a few mentions in the python lists Thanks Edu ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread Daniel Sarmiento
I am not an expert and don't know if this is considered 'elegant', but this is what I would try conv = [[j[0], int(j[1]), int(j[2])] + j[3:] for j in LoL] > Hi Your, > > I work with genomic datasets as well and have recently only started > working with python (so my advice is a bit naive) > >

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread spir
Le Fri, 9 Jan 2009 06:20:26 -0800 (PST), culpritNr1 a écrit : > > Hello Trias and all, > > Glad to see that somebody recognized the BED genomic annotation format. > Being a relative newcomer to python, my question was if there was an ELEGANT > way to do this casting, perhaps as a list comprehe

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread culpritNr1
Hello Trias and all, Glad to see that somebody recognized the BED genomic annotation format. Your naive approach is probably the first thing that one could try. It is sure to work. The problem is that your code becomes unnecessarily long/cumbersome: every time I would have to use a particular el

Re: [Tutor] Python debugger

2009-01-09 Thread Kent Johnson
On Fri, Jan 9, 2009 at 7:36 AM, Michael Bernhard Arp Sørensen wrote: > I can't use a graphical debugger because i mostly code python over ssh on > remote servers in my company. Winpdb opens a socket connection between the debugger and debuggee. Perhaps it would run over an ssh tunnel... Kent __

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread Triantafyllos Gkikopoulos
Hi Your, I work with genomic datasets as well and have recently only started working with python (so my advice is a bit naive) I would say although there may be different ways you can cast an integer or float type into your list of lists you may actually no need to do so with your starting f

Re: [Tutor] Python debugger

2009-01-09 Thread Michael Bernhard Arp Sørensen
Hi. Thanks for the input. Your way of doing it is simpler and possible to use as an alias in pdb. I can't use a graphical debugger because i mostly code python over ssh on remote servers in my company. Thanks anyway. It was actually helpfull. :-) /Michael On Fri, Jan 9, 2009 at 12:38 PM, Kent

Re: [Tutor] Python debugger

2009-01-09 Thread Kent Johnson
On Fri, Jan 9, 2009 at 3:27 AM, Michael Bernhard Arp Sørensen wrote: > Hi there. > > I've just started using the python debugger and I wonder how I could have > lived without it earlier. > > I just wonder if there is a smarter way to show what all the variables > contain in any given point in the

[Tutor] Python debugger

2009-01-09 Thread Michael Bernhard Arp Sørensen
Hi there. I've just started using the python debugger and I wonder how I could have lived without it earlier. I just wonder if there is a smarter way to show what all the variables contain in any given point in the debugger. I'm using this approach: import sys f = sys._getframe() p f.f_locals.it