RE: tutorial on parser

2008-12-16 Thread Barak, Ron
Hi John, You may want to read http://nedbatchelder.com/text/python-parsers.html Bye, Ron. -Original Message- From: John Fabiani [mailto:jfabi...@yolo.com] Sent: Tuesday, December 16, 2008 08:47 To: python-list@python.org Subject: tutorial on parser Hi, I'm attempting to learn how to con

Re: Python music sequencer timing problems

2008-12-16 Thread John O'Hagan
On Mon, 15 Dec 2008, John O'Hagan wrote: > On Sun, 14 Dec 2008, Bad Mutha Hubbard wrote: > > John O'Hagan wrote: > > > On Wed, 10 Dec 2008, badmuthahubbard wrote: > > [...] > > > > from time import time, sleep > > > > > > start = time() > > > for event in music: > > > duration=len(event) #Reall

Re: Memory leak when using a C++ module for Python

2008-12-16 Thread Gabriel Genellina
En Thu, 11 Dec 2008 15:35:58 -0200, Jaume Bonet escribió: This is the function that is visible from python and the one that the python code calls: static PyObject * IMFind (PyObject *self, PyObject *args, PyObject *kwargs) { Your function does not call any Python function except PyArg_P

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Joel Hedlund
Duncan Booth wrote: It could happen quite easily if the hash value of the object has changed since it was put in the dictionary. what does the definition of your core.gui.FragmentInfo object look like? Dunno if it'll help much, but: class FragmentInfo(object): def __init__(self, renderer,

Re: ethical questions about global variables

2008-12-16 Thread Bruno Desthuilliers
Giampaolo Rodola' a écrit : Hi, in a module of mine (ftpserver.py) I'd want to add a (boolean) global variable named "use_gmt_times" to decide whether the server has to return times in GMT or localtime but I'm not sure if it is a good idea because of the "ethical" doubts I'm gonna write below. I

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread Pete Forman
Steve Holden writes: > Ben Finney wrote: >> James Stroud writes: >> >>> Ben Finney wrote: James Stroud writes: > Yes. I think it was the British who decided that the apostrophe > rule for "it" would be reversed from normal usage relative to > just about every other noun.

Re: Structure using whitespace vs logical whitespace

2008-12-16 Thread Gabriel Genellina
En Mon, 15 Dec 2008 14:29:31 -0200, cmdrrickhun...@yaho.com escribió: PS. In my opinion the solution would be to have the option of entering a "whitespace insensitive" mode which uses C style {} and ;. The token to enter it could be as complicated as you want (in fact, it may make sense to m

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Arnaud Delobelle
Joel Hedlund writes: > I'm having a very hard time explaining why this snippet *sometimes* > raises KeyError: > > snippet: >> print type(self.pool) >> for frag in self.pool.keys(): >> if frag is fragment_info: >> print "the fragment_info *is* in the pool", hash(frag), >> hash(fragmen

Re: [Tutor] Having Issues with CMD and the 'python' command

2008-12-16 Thread W W
On Mon, Dec 15, 2008 at 9:56 AM, Benjamin Kaplan wrote: > It's not a question of sensibility. It's a question of purpose. The Zen is > the philosophy of a language that tries to be easy to learn and easy to use. > Python is used by programmers who want to experiment with it, but who > usually know

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread Aaron Brady
On Dec 15, 11:04 am, Steve Holden wrote: > Tim Chase wrote: > > Steve Holden wrote: > >> This led to a schism between the British and the > >> newly-independent Americans, who responded by taking the "u" > >> out of colour, valour, and aluminium. > > > Darn Americans and their alminim ;-) > >

Re: Need help improving number guessing game

2008-12-16 Thread Bruno Desthuilliers
feba a écrit : .strip() returns a copy of the string without leading and ending whitespaces (inlcuding newlines, tabs etc). Ahh. I had removed it because it didn't seem to do anything, but I've readded it. And I understand your dictionary stuff correctly now, I think, and I worked it in. Curre

subprocess.Popen inheriting

2008-12-16 Thread Aaron Brady
Hi, I have a file handle I want to inherit in a child process. I am looking at '_make_inheritable' in 'Popen', but it needs an instance, and by the time I have one, the subprocess is already running. Can't I call 'Popen._make_inheritable( None, handle )'? The method does not use 'self'. -- http

Re: ethical questions about global variables

2008-12-16 Thread Gabriel Genellina
En Tue, 16 Dec 2008 00:45:05 -0200, Giampaolo Rodola' escribió: Another doubt is the naming convention. PEP-8 states that global variables should use the lower_case_naming_convention but I've seen a lot of library module using the UPPER_CASE_NAMING_CONVENTION. What am I supposed to do about it?

Re: Interface & Implementation

2008-12-16 Thread Gabriel Genellina
En Fri, 12 Dec 2008 19:48:09 -0200, Lie Ryan escribió: but if you really want it, simple inheritance might be better anyway, though not really pythonic: class MyIfc(object): def myMeth1(self): return NotImplemented def myMeth2(self): return NotImplemented class MyClass(MyIfc): def

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread Hendrik van Rooyen
"Dennis Lee Bieber" wrote: 8<- stuff blaming Davy for "aluminum" -- > Isn't Davy a Brit? No, he was a Brit. He's dead now. His safety lamp lives on. It's a good thing its got that heat-sink sieve- it's enabled countless miners to flee when they see its change of colour. Thus it's s

Re: Generator slower than iterator?

2008-12-16 Thread MRAB
Federico Moreira wrote: Hi all, Im parsing a 4.1GB apache log to have stats about how many times an ip request something from the server. The first design of the algorithm was for line in fileinput.input(sys.argv[1:]): ip = line.split()[0] if match_counter.has_key(ip): match_

Re: Structure using whitespace vs logical whitespace

2008-12-16 Thread Lie Ryan
On Mon, 15 Dec 2008 08:29:31 -0800, cmdrrickhun...@yaho.com wrote: > I've been trying to search through the years of Python talk to find an > answer to this, but my Googlefu is weak. > > In most languages, I'll do something like this > > xmlWriter.BeginElement("parent"); > xmlWriter.BeginEle

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread Grant Edwards
On 2008-12-16, Hendrik van Rooyen wrote: > "Dennis Lee Bieber" wrote: > > 8<- stuff blaming Davy for "aluminum" -- > >> Isn't Davy a Brit? > > No, he was a Brit. > He's dead now. > His safety lamp lives on. > It's a good thing its got that heat-sink sieve- should be "it's got" (cont

Re: Structure using whitespace vs logical whitespace

2008-12-16 Thread Eric Brunel
On Tue, 16 Dec 2008 10:00:32 +0100, Gabriel Genellina wrote: En Mon, 15 Dec 2008 14:29:31 -0200, cmdrrickhun...@yaho.com escribió: PS. In my opinion the solution would be to have the option of entering a "whitespace insensitive" mode which uses C style {} and ;. The token to enter it co

[cookielib] How to add cookies myself?

2008-12-16 Thread Gilles Ganault
Hello I'm using urllib and urlib to download data from a web server that requires cookies. The issue I'm having, is the server uses JavaScript in the response to insert new cookies and send them with the next query, so I need to manually add a couple of cookies in the CookieJar, but I don't know

Re: Generator slower than iterator?

2008-12-16 Thread Lie Ryan
On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > Hi all, > > Im parsing a 4.1GB apache log to have stats about how many times an ip > request something from the server. > > The first design of the algorithm was > > for line in fileinput.input(sys.argv[1:]): > ip = line.split()[

Re: Generator slower than iterator?

2008-12-16 Thread Lie Ryan
On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > Hi all, > > Im parsing a 4.1GB apache log to have stats about how many times an ip > request something from the server. > > The first design of the algorithm was > > for line in fileinput.input(sys.argv[1:]): > ip = line.split()[

RE: String slices work only for first string character ?

2008-12-16 Thread Barak, Ron
Hi Mr. Cain, Mae culpa: obviously, I erroneously understood the number after the ':' as the string length. Thanks, Ron. -Original Message- From: D'Arcy J.M. Cain [mailto:da...@druid.net] Sent: Tuesday, December 16, 2008 15:45 To: Barak, Ron Cc: python-list@python.org Subject: Re: String s

Re: Bidirectional Networking

2008-12-16 Thread Emanuele D'Arrigo
Thanks everybody and in particular Gabriel and Bryan for their contributions to this thread. Very much useful information. Manu -- http://mail.python.org/mailman/listinfo/python-list

help I'm getting delimited

2008-12-16 Thread aka
Hi, I'm going nuts over the csv.reader and UnicodeReader class. Somehow I can't get this method working which is supposed to read a csv file which name is inputted but here now hardcoded. What I need for now is that the string version of the list is put out for control. Later on I will only need to

Re: Generator slower than iterator?

2008-12-16 Thread Gary Herron
Lie Ryan wrote: > On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > > >> Hi all, >> >> Im parsing a 4.1GB apache log to have stats about how many times an ip >> request something from the server. >> >> The first design of the algorithm was >> >> for line in fileinput.input(sys.argv[1

Re: ethical questions about global variables

2008-12-16 Thread Giampaolo Rodola'
On 16 Dic, 07:23, Michele Simionato wrote: > On Dec 16, 3:45 am, "Giampaolo Rodola'" wrote: > > > Hi, > > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > > variable named "use_gmt_times" to decide whether the server has to > > return times in GMT or localtime but I'm not s

Re: Free place to host python files?

2008-12-16 Thread skip
feba> I'm getting started in python, and it would be helpful to have a feba> place to put up various code snippets I've made, so I don't have feba> to send them individually to each person I want to show it to. feba> I'd prefer to use something that would give me a directory for my

Re: help I'm getting delimited

2008-12-16 Thread Paul Watson
On Tue, 2008-12-16 at 08:26 -0800, aka wrote: > Hi, I'm going nuts over the csv.reader and UnicodeReader class. > Somehow I can't get this method working which is supposed to read a > csv file which name is inputted but here now hardcoded. What I need > for now is that the string version of the lis

Re: Generator slower than iterator?

2008-12-16 Thread bearophileHUGS
MRAB: > from collections import defaultdict > match_counter = defaultdict(int) > for line in fileinput.input(sys.argv[1:]): > ip = line.split()[0] > match_counter[ip] += 1 This can be a little faster still: match_counter = defaultdict(int) for line in fileinput.input(sys.argv[1:]):

Re: Generator slower than iterator?

2008-12-16 Thread Federico Moreira
The defaultdict option looks faster than the standard dict (20 secs aprox). Now i have: # import fileinput import sys from collections import defaultdict match_counter = defaultdict(int) for line in fileinput.input(sys.argv[1:]): match_counter[line.split()[0]] +=

Re: Copying files in directory

2008-12-16 Thread ianaré
On Dec 15, 9:49 pm, pacsciad...@gmail.com wrote: > I'm writing a project management system, and I need the ability to > accept a directory name and move its contents to another directory. > Can someone give me a code sample that will handle this? I can't find > any "copying" functions in os or os.p

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread J. Cliff Dyer
On Tue, 2008-12-16 at 12:27 +0200, Hendrik van Rooyen wrote: > "Dennis Lee Bieber" wrote: > > 8<- stuff blaming Davy for "aluminum" -- > > > Isn't Davy a Brit? > > No, he was a Brit. > He's dead now. > His safety lamp lives on. > It's a good thing its got that heat-sink sieve- > i

Re: zipfile.is_zipfile() and string buffers

2008-12-16 Thread Gabriel Genellina
En Tue, 16 Dec 2008 12:28:00 -0200, Brendan escribió: I would like zipfile.is_zipfile(), to operate on a cStringIO.StringIO string buffer, but is seems only to accept file names as arguments. Should it not be able to handle string buffers too? A version of zipfile.is_zipfile() accepting bot

Does Python3 offer a FrozenDict?

2008-12-16 Thread Johannes Bauer
Hello group, is there anything like a frozen dict in Python3, so I could do a foo = { FrozenDict({"a" : "b"}): 3 } or something like that? Regards, Johannes -- "Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit, verlästerung von Gott, Bibel und mir und bewusster Blasphemie."

Re: ethical questions about global variables

2008-12-16 Thread ianaré
For anything more complicated than a simple script, I find it easier to use some sort of config object. This could be a simple dictionnary type class, where the values can be set/retrieved by the other classes directly, or a more elaborate class including functions to set/ retrieve the variables. T

String slices work only for first string character ?

2008-12-16 Thread Barak, Ron
Hi, Can any one explain why the following string slice works only for the first character, but not for any other ? $ cat /tmp/tmp.py #!/usr/bin/env python data = 'F0023209006-0101' print data print "|"+data[0:1]+"|" print "|"+data[1:1]+"|" print "|"+data[2:1]+"|" $ python `cygpath -w /tmp/tmp.

Re: Python plugin for Netbeans

2008-12-16 Thread ianaré
On Dec 15, 3:23 pm, a wrote: > Netbeans added a python plugin to its plugin repository. > Do you tried it? What do you think about this plugin? If you like netbeans already it's great to finally have python officially supported. I find netbeans to be easier to use than eclipse. -- http://mail.pyt

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Duncan Booth
Joel Hedlund wrote: > I should probably do this with lists instead because I can't really > think of a way of salvaging this. Am i right? > I think you probably are correct. The only thing I can think that might help is if you can catch all the situations where changes to the dependent value

Re: String slices work only for first string character ?

2008-12-16 Thread Tim Chase
Can any one explain why the following string slice works only for the first character, but not for any other ? $ cat /tmp/tmp.py #!/usr/bin/env python data = 'F0023209006-0101' print data print "|"+data[0:1]+"|" print "|"+data[1:1]+"|" print "|"+data[2:1]+"|" $ python `cygpath -w /tmp/tmp.py`

Re: tricky nested list unpacking problem

2008-12-16 Thread Steve Holden
Chris Rebert wrote: > On Mon, Dec 15, 2008 at 11:06 AM, Reckoner wrote: >> Hi, >> >> I have lists of the following type: >> >> [1,2,3,[5,6]] >> >> and I want to produce the following strings from this as >> >> '0-1-2-3-5' >> '0-1-2-3-6' >> >> That was easy enough. The problem is that these can be

Re: weird dict problem, how can this even happen?

2008-12-16 Thread Joel Hedlund
Duncan Booth wrote: I think you probably are correct. The only thing I can think that might help is if you can catch all the situations where changes to the dependent values might change the hash and wrap them up: before changing the hash pop the item out of the dict, then reinsert it after the

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread Hendrik van Rooyen
"Aaron Brady" wrote: >There's an 'I' in Python. No! It's supposed to be : There's a T in python. "an" is only used when the next word starts with a vowel, as in: It's been an hour now... All this is because English speakers are genetically incapable of moving their tongues. :-) - Hendri

Re: Does Python3 offer a FrozenDict?

2008-12-16 Thread bearophileHUGS
Johannes Bauer: > is there anything like a frozen dict in Python3, so I could do a > foo = { FrozenDict({"a" : "b"}): 3 } You can adapt this code to Python3 (and post a new recipe? It may be positive to create a new section of the Cookbook for Py3 only): http://code.activestate.com/recipes/414283/

Re: Need help improving number guessing game

2008-12-16 Thread feba
>The good news is that Python functions are objects too, so you can pass >them as params to another function. duh, duh, duh, duh, duh! I knew I was missing something there. Thanks. >if not mini <= x <= maxi: also thanks for this, I forgot about that. But I have it as if not minr < guess < maxr:

Re: tricky nested list unpacking problem

2008-12-16 Thread Arnaud Delobelle
bearophileh...@lycos.com writes: > I was waiting to answer because so far I have found a bad-looking > solution only. Seeing there's only your solution, I show mine too. It > seems similar to your one. I think that the solution below is a bit clearer, although I think it is more resource intensiv

Re: Structure using whitespace vs logical whitespace

2008-12-16 Thread Ken Seehart
cmdrrickhun...@yaho.com wrote: I've been trying to search through the years of Python talk to find an answer to this, but my Googlefu is weak. In most languages, I'll do something like this xmlWriter.BeginElement("parent"); xmlWriter.BeginElement("child"); --xml.Writer.Characters("s

Re: Deepcopying slice objects

2008-12-16 Thread Gabriel Genellina
En Sun, 14 Dec 2008 15:43:01 -0200, Max Argus escribió: I stumbled across a thread about that suggests fixing deepcopy to let it copy slice objects. ( http://mail.python.org/pipermail/python-list/2006-August/398206.html). I expected this to work and don't see any reason why it shouldn't in case

Re: Generator slower than iterator?

2008-12-16 Thread rdmurray
Quoth Lie Ryan : > On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > > > Hi all, > > > > Im parsing a 4.1GB apache log to have stats about how many times an ip > > request something from the server. > > > > The first design of the algorithm was > > > > for line in fileinput.input(sy

Re: subprocess.Popen inheriting

2008-12-16 Thread Gabriel Genellina
En Tue, 16 Dec 2008 07:29:19 -0200, Aaron Brady escribió: I have a file handle I want to inherit in a child process. I am looking at '_make_inheritable' in 'Popen', but it needs an instance, and by the time I have one, the subprocess is already running. Can't I call 'Popen._make_inheritable

Re: Free place to host python files?

2008-12-16 Thread Giampaolo Rodola'
On 16 Dic, 15:56, feba wrote: > On Dec 16, 8:29 am, s...@pobox.com wrote: > > >     feba> I'm getting started in python, and it would be helpful to have a > >     feba> place to put up various code snippets I've made, so I don't have > >     feba> to send them individually to each person I want to

Re: Free place to host python files?

2008-12-16 Thread mudzot
> well, ignoring the fact that pastebin doesn't work for me for some > reason, I'm talking about hosting it as a .py downloadable, not a hunk > of text. maybe one option is registering in some free project hosting service like code.google.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Free place to host python files?

2008-12-16 Thread feba
Stuff like code.google, sf.net, are more oriented towards serious development, not just holding random apps, aren't they? Anyway, I found MediaFire, which looks like it will suffice for now. -- http://mail.python.org/mailman/listinfo/python-list

Re: help I'm getting delimited

2008-12-16 Thread MRAB
Paul Watson wrote: On Tue, 2008-12-16 at 08:26 -0800, aka wrote: Hi, I'm going nuts over the csv.reader and UnicodeReader class. Somehow I can't get this method working which is supposed to read a csv file which name is inputted but here now hardcoded. What I need for now is that the string vers

Python Dictionary Algorithm Question

2008-12-16 Thread Brigette Hodson
Hello! I am in a beginning algorithms class this semester and I am working on a presentation. I want to discuss in some detail the algorithm python uses to determine the hash function for python dictionaries. Does anyone know what this algorithm is? Or where I can go to find information on it? Tha

Re: Generator slower than iterator?

2008-12-16 Thread Federico Moreira
2008/12/16 > Python 3.0 does not support has_key, it's time to get used to not using it > :) > Good to know line.split(None, 1)[0] really speeds up the proccess Thanks again. -- http://mail.python.org/mailman/listinfo/python-list

Generator slower than iterator?

2008-12-16 Thread Federico Moreira
Hi all, Im parsing a 4.1GB apache log to have stats about how many times an ip request something from the server. The first design of the algorithm was for line in fileinput.input(sys.argv[1:]): ip = line.split()[0] if match_counter.has_key(ip): match_counter[ip] += 1 else:

AIM client code for Python?

2008-12-16 Thread Joe Strout
I'd like to write an AIM bot in Python. I found and tried , but it doesn't work for me: Connecting... Traceback (most recent call last): File "aimbot-1.py", line 17, in bot.go() File "/Users/jstrout/Documents/Python-Dev/AIMbot/toc.py", line 62, in go

Re: Does Python3 offer a FrozenDict?

2008-12-16 Thread Paul Moore
On 16 Dec, 17:28, bearophileh...@lycos.com wrote: > Johannes Bauer: > > > is there anything like a frozen dict in Python3, so I could do a > > foo = { FrozenDict({"a" : "b"}): 3 } > > You can adapt this code to Python3 (and post a new recipe? It may be > positive to create a new section of the Cook

Re: Free place to host python files?

2008-12-16 Thread feba
On Dec 16, 8:29 am, s...@pobox.com wrote: >     feba> I'm getting started in python, and it would be helpful to have a >     feba> place to put up various code snippets I've made, so I don't have >     feba> to send them individually to each person I want to show it to. >     feba> I'd prefer to us

Re: String slices work only for first string character ?

2008-12-16 Thread D'Arcy J.M. Cain
On Tue, 16 Dec 2008 13:35:27 + "Barak, Ron" wrote: > Can any one explain why the following string slice works only for the first > character, but not for any other ? I think that you need to reread the docs on slices. > print "|"+data[0:1]+"|" > print "|"+data[1:1]+"|" If you want the seco

Re: Python Dictionary Algorithm Question

2008-12-16 Thread Christian Heimes
Brigette Hodson schrieb: > Hello! I am in a beginning algorithms class this semester and I am working > on a presentation. I want to discuss in some detail the algorithm python > uses to determine the hash function for python dictionaries. Does anyone > know what this algorithm is? Or where I can g

Re: alt.possessive.its.has.no.apostrophe

2008-12-16 Thread Pete Forman
Aaron Brady writes: > On Dec 15, 11:04 am, Steve Holden wrote: >> Tim Chase wrote: >> > Steve Holden wrote: >> >> This led to a schism between the British and the >> >> newly-independent Americans, who responded by taking the "u" >> >> out of colour, valour, and aluminium. >> >> > Darn American

Re: ethical questions about global variables

2008-12-16 Thread Yinon Ehrlich
On Dec 16, 4:45 am, "Giampaolo Rodola'" wrote: > Hi, > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > variable named "use_gmt_times" to decide whether the server has to > return times in GMT or localtime but I'm not sure if it is a good idea > because of the "ethical" doub

mysql hash generator in python

2008-12-16 Thread Matías Hernández
(sorry for my english, but i'm speak spanish) Hi list.. this is my first post... and obviously if for help.. I try to implement the password function of mysql in a python script. I read that the password function of mysql was implemented with a double sha1() I python i try this: example1: if __

Free place to host python files?

2008-12-16 Thread feba
I'm getting started in python, and it would be helpful to have a place to put up various code snippets I've made, so I don't have to send them individually to each person I want to show it to. I'd prefer to use something that would give me a directory for my use only, instead of something where you

Re: AIM client code for Python?

2008-12-16 Thread Jean-Paul Calderone
On Tue, 16 Dec 2008 10:54:38 -0700, Joe Strout wrote: I'd like to write an AIM bot in Python. I found and tried , but it doesn't work for me: Connecting... Traceback (most recent call last): File "aimbot-1.py", line 17, in bot.go() File "/Users/jstrout/Do

Re: cx_Oracle issues

2008-12-16 Thread huw_at1
On Dec 15, 12:59 pm, "ron.re...@gmail.com" wrote: > On Dec 15, 2:44 am, huw_at1 wrote: > > > > > On Dec 11, 5:34 pm, "ron.re...@gmail.com" wrote: > > > > On Dec 10, 9:48 am, huw_at1 wrote: > > > > > Hey all. When usingcx_Oracleto run a procedure like: > > > > > cursor.execute("select (obj.funct

Re: Generator slower than iterator?

2008-12-16 Thread Arnaud Delobelle
bearophileh...@lycos.com writes: > This can be a little faster still: > > match_counter = defaultdict(int) > for line in fileinput.input(sys.argv[1:]): > ip = line.split(None, 1)[0] > match_counter[ip] += 1 > > Bye, > bearophile Or maybe (untested): match_counter = defaultdict(int) for l

Re: Python Dictionary Algorithm Question

2008-12-16 Thread Scott MacDonald
You might be interested in the "Beautiful Code" book: http://oreilly.com/catalog/9780596510046/ It has a chapter on Python's dict implementation that is pretty good. On Tue, Dec 16, 2008 at 10:51 AM, Brigette Hodson wrote: > Hello! I am in a beginning algorithms class this semester and I am work

sorting for recursive folder rename

2008-12-16 Thread ianaré
Hello all, I trying to recursively rename folders and files, and am looking for some ideas on the best way of doing this. The problem is that the given list of items can be in order, and one to all items may be renamed. Here is some preliminary code I have, but which does not work very well. self

Re: os.environ.get('SSH_ORIGINAL_COMMAND') returns None

2008-12-16 Thread Yinon Ehrlich
On Dec 15, 8:51 pm, Tzury Bar Yochay wrote: > Trying to follow a technique found at bzr I did the following > > added to ~/.ssh/authorized_keys the command="my_parder" parameter > which point to a python script file named 'my_parser' and located in / > usr/local/bin  (file was chmoded as 777) > >

Re: cx_Oracle issues

2008-12-16 Thread huw_at1
On Dec 15, 12:59 pm, "ron.re...@gmail.com" wrote: > On Dec 15, 2:44 am, huw_at1 wrote: > > > > > On Dec 11, 5:34 pm, "ron.re...@gmail.com" wrote: > > > > On Dec 10, 9:48 am, huw_at1 wrote: > > > > > Hey all. When usingcx_Oracleto run a procedure like: > > > > > cursor.execute("select (obj.funct

subprocess returncode windows

2008-12-16 Thread Andrew
Hello, I'm running into a strange situation with getting incorrect returncodes / exit status from python subprocess.call. I'm using a python script (runtime 2.6.1 on windows) to automate the deploy of java applications to glassfish application server. Below is an example of using a subprocess call

Re: ethical questions about global variables

2008-12-16 Thread Giampaolo Rodola'
On 16 Dic, 18:01, ianaré wrote: > For anything more complicated than a simple script, I find it easier > to use some sort of config object. This could be a simple dictionnary > type class, where the values can be set/retrieved by the other classes > directly, or a more elaborate class including fu

sys.maxint in Python 2.6.1 (amd64) on Windows XP x64

2008-12-16 Thread Lin
Hi, I installed the amd64 version of Python 2.6.1 on my Windows XP x64 system. I was expecting sys.maxint to be 9223372036854775807 (or 2 ^63 -1), but instead I got 2147483647 (i.e., 2^31-1) just like what I got from a 32-bit version of Python. Is this by design or does it indicate a bug or an ins

Re: Python Dictionary Algorithm Question

2008-12-16 Thread Steve Holden
Brigette Hodson wrote: > Hello! I am in a beginning algorithms class this semester and I am > working on a presentation. I want to discuss in some detail the > algorithm python uses to determine the hash function for python > dictionaries. Does anyone know what this algorithm is? Or where I can go

Re: Does Python3 offer a FrozenDict?

2008-12-16 Thread bearophileHUGS
Paul Moore: > Moral - don't assume that all code needs to be rewritten for Python > 3.0 :-) In practice this time your moral is of little use: having a place that allows you to choose Py3 OR Py2 code is much better and tidier, helps you save time, helps you avoid wasting some time, etc. Bye, bear

zipfile.is_zipfile() and string buffers

2008-12-16 Thread Brendan
I would like zipfile.is_zipfile(), to operate on a cStringIO.StringIO string buffer, but is seems only to accept file names as arguments. Should it not be able to handle string buffers too? -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.maxint in Python 2.6.1 (amd64) on Windows XP x64

2008-12-16 Thread Christian Heimes
Lin schrieb: > Hi, > > I installed the amd64 version of Python 2.6.1 on my Windows XP x64 > system. I was expecting sys.maxint to be 9223372036854775807 (or 2 ^63 > -1), but instead I got 2147483647 (i.e., 2^31-1) just like what I got > from a 32-bit version of Python. Is this by design or does it

Re: subprocess returncode windows

2008-12-16 Thread Christian Heimes
Andrew schrieb: > Hello, > > I'm running into a strange situation with getting incorrect > returncodes / exit status from python subprocess.call. I'm using a > python script (runtime 2.6.1 on windows) to automate the deploy of > java applications to glassfish application server. Below is an exampl

Re: sorting for recursive folder rename

2008-12-16 Thread MRAB
ianaré wrote: Hello all, I trying to recursively rename folders and files, and am looking for some ideas on the best way of doing this. The problem is that the given list of items can be in order, and one to all items may be renamed. Here is some preliminary code I have, but which does not work

Re: Memory leak when using a C++ module for Python

2008-12-16 Thread Jaume Bonet
When I tried the C++ function with a C++ main() (skipping the Python part) it didn't show any memory problem, but I'll re-check it anyway, thanks... On Dec 16, 9:16 am, "Gabriel Genellina" wrote: > En Thu, 11 Dec 2008 15:35:58 -0200, Jaume Bonet   > escribió: > > > This is the function that is v

Where is a good open source python project to be used as example?

2008-12-16 Thread Andrea Francia
I'm looking for a python project to use as example to learning python. The project should have these features: 1. is almost fully unit tested 2. use consistently the code convention recommended by PEP 8 3. it's elements are almost fully documented Extra point features are: 4. build

executables no longer executing on PC's without Python installed

2008-12-16 Thread jefm
Hi, I recently figured out a problem that came up with the latest versions of Python and cx_Freeze. I thought I post it here so that it might be usefull to someone. The problem was that, when I switched to Python 2.6.x and cx_Freeze-4.0.1.win32-py2.6.msi, the executables that were produced ran per

Re: subprocess returncode windows

2008-12-16 Thread Andrew
On Dec 16, 12:50 pm, Christian Heimes wrote: > Andrew schrieb: > > > > > Hello, > > > I'm running into a strange situation with getting incorrect > > returncodes / exit status from python subprocess.call. I'm using a > > python script (runtime 2.6.1 on windows) to automate the deploy of > > java a

Re: sys.maxint in Python 2.6.1 (amd64) on Windows XP x64

2008-12-16 Thread Lin
> > > I installed the amd64 version of Python 2.6.1 on my Windows XP x64 > > system. I was expecting sys.maxint to be 9223372036854775807 (or 2 ^63 > > -1), but instead I got 2147483647 (i.e., 2^31-1) just like what I got > > from a 32-bit version of Python. Is this by design or does it indicate >

Re: Where is a good open source python project to be used as example?

2008-12-16 Thread D'Arcy J.M. Cain
On Tue, 16 Dec 2008 19:13:00 GMT Andrea Francia wrote: > I'm looking for a python project to use as example to learning python. > > The project should have these features: > > 1. is almost fully unit tested > 2. use consistently the code convention recommended by PEP 8 > 3. it's elem

Re: Generator slower than iterator?

2008-12-16 Thread Arnaud Delobelle
Arnaud Delobelle writes: > match_total = dict((key, val()) for key, val in match_counter.iteritems()) Sorry I meant match_total = dict((key, val.next()) for key, val in match_counter.iteritems()) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Free place to host python files?

2008-12-16 Thread Mr . SpOOn
2008/12/16 feba : > Stuff like code.google, sf.net, are more oriented towards serious > development, not just holding random apps, aren't they? > > Anyway, I found MediaFire, which looks like it will suffice for now. Take a look to Dropbox (http://www.getdropbox.com/). You can use it to directly

Re: Where is a good open source python project to be used as example?

2008-12-16 Thread Andrea Francia
D'Arcy J.M. Cain wrote: On Tue, 16 Dec 2008 19:13:00 GMT Andrea Francia wrote: I'm looking for a python project to use as example to learning python. The project should have these features: 1. is almost fully unit tested 2. use consistently the code convention recommended by PEP 8

Re: Where is a good open source python project to be used as example?

2008-12-16 Thread D'Arcy J.M. Cain
On Tue, 16 Dec 2008 20:03:21 GMT Andrea Francia wrote: > >> Did you know where are such projects? > > > > http://www.PyGreSQL.org/. > > > > Thanks! But I can't find any unit test in the code. Look again. They are in the files named TEST_PyGreSQL_classic.py and TEST_PyGreSQL_dbapi20.py. -- D

Re: subprocess.Popen inheriting

2008-12-16 Thread Aaron Brady
On Dec 16, 4:15 am, "Gabriel Genellina" wrote: > En Tue, 16 Dec 2008 07:29:19 -0200, Aaron Brady   > escribió: > > > I have a file handle I want to inherit in a child process.  I am > > looking at '_make_inheritable' in 'Popen', but it needs an instance, > > and by the time I have one, the subpro

Can anyone suggest a good HTTP/1.1 web client?

2008-12-16 Thread Kottiyath
Hi all, I have to connect to a secure website every second to get the data and then post to it. I have been investigating on many web clients in python, but nothing fits the bill properly. The ones I tried implementing are: 1. httplib based - I created myself. (I cannot use urllib2 sinc

Re: sys.maxint in Python 2.6.1 (amd64) on Windows XP x64

2008-12-16 Thread Christian Heimes
Lin schrieb: > Ah, this makes sense. Thanks.. The main reason I'm trying 64-bit > Python is that I want to write files bigger than 4GB. This should work > on Windows x64, right? (i.e., are the pointers bona fide 64 bit?) You can create files with more than 4GB on a 32bit OS, too. It depends on

mod_python resources

2008-12-16 Thread tmallen
I'm trying again because I'm stubborn. Maybe the fourth time will be the charm... Are there any good tutorials out there for setting up Apache with mod_python? Thanks, Thomas -- http://mail.python.org/mailman/listinfo/python-list

How to modify a program while it's running?

2008-12-16 Thread Joe Strout
Here's my situation: I'm making an AIM bot, but the AIM server will get annoyed if you log in too frequently (and then lock you out for a while). So my usual build-a-little, test-a-little methodology doesn't work too well. So I'd like to restructure my app so that it can stay running and s

Re: Memory leak when using a C++ module for Python

2008-12-16 Thread Ivan Illarionov
On Dec 11, 8:35 pm, Jaume Bonet wrote: >         //Here we take the info coming from python and transform it > into a vector (will allow us to work with numbers instead of >         // strings) and shareInt which is an array of sets (form > std::set) >         vector translator = string2int > (sh

Re: Can anyone suggest a good HTTP/1.1 web client?

2008-12-16 Thread Jean-Paul Calderone
On Tue, 16 Dec 2008 12:18:17 -0800 (PST), Kottiyath wrote: Hi all, I have to connect to a secure website every second to get the data and then post to it. I have been investigating on many web clients in python, but nothing fits the bill properly. The ones I tried implementing are: 1.

Re: How to modify a program while it's running?

2008-12-16 Thread Craig Allen
On Dec 16, 10:25 am, Joe Strout wrote: > Here's my situation: I'm making an AIM bot, but the AIM server will > get annoyed if you log in too frequently (and then lock you out for a > while). So my usual build-a-little, test-a-little methodology doesn't > work too well. > > So I'd like to restruct

  1   2   >