Re: Symbols as parameters?

2010-01-21 Thread Stefan Behnel
Alf P. Steinbach, 21.01.2010 20:24: > Do you understand how bad that makes you look? I think the right thing to say at this point is "don't feed the troll". Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Symbols as parameters?

2010-01-21 Thread Martin Drautzburg
Here is a complete expample using a decorator, still a bit noisy def move(aDirection): print "moving " + aDirection #Here comes the decorator def scope(aDict): def save(locals): """Set symbols in locals and remember their original state""" setSymbols={} unsetSymbol

Re: substitution

2010-01-21 Thread Anthra Norell
Iain King wrote: On Jan 21, 2:18 pm, Wilbert Berendsen wrote: Op maandag 18 januari 2010 schreef Adi: keys = [(len(key), key) for key in mapping.keys()] keys.sort(reverse=True) keys = [key for (_, key) in keys] pattern = "(%s)" % "|".join(keys) repl = lambda x : mapping[x.grou

Re: Memory usage problem of twisted server

2010-01-21 Thread Dieter Maurer
Victor Lin writes on Wed, 20 Jan 2010 02:52:25 -0800 (PST): > Hi, > > I encountered an increasing memory usage problem of my twisted server. > I have posted a question on stackoverflow: > http://stackoverflow.com/questions/2100192/how-to-find-the-source-of-increasing-memory-usage-of-a-twisted-ser

Re: Inheriting methods but over-riding docstrings

2010-01-21 Thread Gabriel Genellina
En Thu, 21 Jan 2010 03:17:40 -0300, Michele Simionato escribió: On Jan 21, 12:09 am, "Gabriel Genellina" wrote: This is basically the same technique as in but there is a difference: you clone the function object *and* the code o

Re: Rounding up to the next 100

2010-01-21 Thread casevh
On Jan 21, 1:58 pm, noydb wrote: > Sorry, although what I really need is the string-number rounded UP > every time.  So if the number is 3890.32, it needs to go to 3900; if > the number is 3811.345, it needs to go to 3900 also. > > So, Florian's answer works. Another option is using math.ceil and

Re: counting lines of code

2010-01-21 Thread Michele Simionato
On Jan 21, 9:24 pm, Phlip wrote: > On Jan 20, 11:20 pm, Michele Simionato > wrote: > > > pylint does too many things, I want something fast that just counts > > the lines and can be run on thousands of files at once. > > cloc seems fine, I have just tried on 2,000 files and it gives me a > > repo

Re: deriving MySQLdb class

2010-01-21 Thread Sean DiZazzo
On Jan 21, 8:17 pm, tekion wrote: > Sean, > I did a little investigation, there are other classes besides > Connection. So, could I only set up a derived class from Connection > and still be able to use the connection to query database and retrieve > data? Im not sure I understand you completely.

Re: deriving MySQLdb class

2010-01-21 Thread tekion
Sean, I did a little investigation, there are other classes besides Connection. So, could I only set up a derived class from Connection and still be able to use the connection to query database and retrieve data? -- http://mail.python.org/mailman/listinfo/python-list

Re: deriving MySQLdb class

2010-01-21 Thread Sean DiZazzo
On Jan 21, 8:00 pm, tekion wrote: > Sean, > Thanks.  This is useful.  For future reference, how do I know what > class is in MySQLdb module? You have to explore. ;) I found the MySQLdb module, and looked inside the __init__.py. Then looked for "connect" and followed the trail. -- http://mail.

Re: deriving MySQLdb class

2010-01-21 Thread Sean DiZazzo
On Jan 21, 5:48 pm, tekion wrote: > All, > I am trying to write a class which inherits from MySQLdb class.  Below > is code snippet: > import MySQLdb > import sys > > class  msql_connect(MySQLdb): >     def __init__(self): >         self.host     =  "hostname" >         self.user     = "user" >  

Re: Default return values for out-of-bounds list item

2010-01-21 Thread Tim Chase
MRAB wrote: gburde...@gmail.com wrote: Is there a built-in method in python that lets you specify a "default" value that will be returned whenever you try to access a list item that is out of bounds? Basically, it would be a function like this: def item(x,index,default): try: return x[

Re: Symbols as parameters?

2010-01-21 Thread Steven D'Aprano
On Fri, 22 Jan 2010 02:42:55 +, MRAB wrote: > Steven D'Aprano wrote: > [snip] >> An example from the standard library: the re module defines constants >> I, L, M, etc. representing flags that are passed to the re.compile. >> They are implemented as integers so they can easily be combined with

Re: py2exe and pydocs. Downloads?

2010-01-21 Thread Jorgen Grahn
On Thu, 2010-01-21, Gib Bogle wrote: > Gabriel Genellina wrote: > >> You found a bug. Looks like it depends on the environment, or what >> packages are installed, or something like that, because it worked on my >> other PC but not here. >> Please report it at http://bugs.python.org so it doesn't

Re: Symbols as parameters?

2010-01-21 Thread MRAB
Steven D'Aprano wrote: [snip] An example from the standard library: the re module defines constants I, L, M, etc. representing flags that are passed to the re.compile. They are implemented as integers so they can easily be combined with &, but another implementation might use symbols. You will

Re: Default return values for out-of-bounds list item

2010-01-21 Thread MRAB
gburde...@gmail.com wrote: Is there a built-in method in python that lets you specify a "default" value that will be returned whenever you try to access a list item that is out of bounds? Basically, it would be a function like this: def item(x,index,default): try: return x[index] exc

Re: Default return values for out-of-bounds list item

2010-01-21 Thread Steven D'Aprano
On Thu, 21 Jan 2010 17:56:00 -0800, gburde...@gmail.com wrote: > Is there a built-in method in python that lets you specify a "default" > value that will be returned whenever you try to access a list item that > is out of bounds? No. > Basically, it would be a function like this: > > def item

Re: Create object name from string value?

2010-01-21 Thread Steven D'Aprano
On Thu, 21 Jan 2010 06:23:17 -0800, Gnarlodious wrote: >> The right way to solve this problem is with a dictionary: >> >> for name in ["object1", "object2", "object3"]: >>     d = {name: classname()} >>     print d[name] > > This works! However I end up saying: > > d['Server'].Config.BaseURL >

Re: Symbols as parameters?

2010-01-21 Thread Steven D'Aprano
On Thu, 21 Jan 2010 22:51:34 +0100, Martin Drautzburg wrote: > Thanks for all the answers. Let me summarize > > (1) I fail to see the relevance of >  >>> def move( direction ): > ...   print( "move " + str( direction ) ) ... >  >>> move( "up" ) > move up I'm glad it's not just me then. > not o

Default return values for out-of-bounds list item

2010-01-21 Thread gburde...@gmail.com
Is there a built-in method in python that lets you specify a "default" value that will be returned whenever you try to access a list item that is out of bounds? Basically, it would be a function like this: def item(x,index,default): try: return x[index] except IndexError: return

deriving MySQLdb class

2010-01-21 Thread tekion
All, I am trying to write a class which inherits from MySQLdb class. Below is code snippet: import MySQLdb import sys class msql_connect(MySQLdb): def __init__(self): self.host = "hostname" self.user = "user" self.password = "passoword" self.database

Re: Python and Tkinter Programming by John Grayson

2010-01-21 Thread Ethan Furman
Peter wrote: On Jan 15, 9:12 am, Kevin Walzer wrote: On Jan 15, 6:24 am, Mark Roseman wrote: Peter wrote: Besides, the book is mainly about using Python with Tkinter - and Tkinter hasn't changed that much since 2000, so I believe it is just as relevant today as it was back then. I'd sa

Re: Symbols as parameters?

2010-01-21 Thread Ben Finney
Carl Banks writes: > On Jan 21, 1:51 pm, Martin Drautzburg > wrote: > > (2) Using enum's was suggested. That is good to know, but again it > > is just a way to define constants in the caller's namespace. > > It'll at least corral the symbols you want. It also satisfies the strongly-expressed de

Re: counting lines of code

2010-01-21 Thread Robert Kern
On 2010-01-21 15:31 , Phlip wrote: Aahz wrote: In article <7e09df6a-cda1-480e-a971-8f8a70ac4...@b9g2000yqd.googlegroups.com>, Phlip wrote: On Jan 20, 11:20=A0pm, Michele Simionato wrote: pylint does too many things, I want something fast that just counts the lines and can be run on thousands

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
On Jan 21, 1:51 pm, Martin Drautzburg wrote: > Thanks for all the answers. Let me summarize [snip] > (2) Using enum's was suggested. That is good to know, but again it is > just a way to define constants in the caller's namespace. It'll at least corral the symbols you want. [snip] > (4) Finally

Re: Symbols as parameters?

2010-01-21 Thread Diez B. Roggisch
Am 21.01.10 22:51, schrieb Martin Drautzburg: Thanks for all the answers. Let me summarize (1) I fail to see the relevance of >>> def move( direction ): ... print( "move " + str( direction ) ) ... >>> move( "up" ) move up not only in the context of my question. And I don't see an abuse

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Martin Drautzburg: Thanks for all the answers. Let me summarize (1) I fail to see the relevance of >>> def move( direction ): ... print( "move " + str( direction ) ) ... >>> move( "up" ) move up not only in the context of my question. And I don't see an abuse of the language either. May

Re: Dynamic HTML controls

2010-01-21 Thread Alan Harris-Reid
Aahz wrote: In article , Alan Harris-Reid wrote: Does anyone know where I can find any decent dynamically-constructed HTML control classes (dropdown list, table, input field, checkbox, etc.) written in Python. For example, for a HTML table I would like something like... You might

Re: Symbols as parameters?

2010-01-21 Thread Martin Drautzburg
Thanks for all the answers. Let me summarize (1) I fail to see the relevance of  >>> def move( direction ): ...   print( "move " + str( direction ) ) ...  >>> move( "up" ) move up not only in the context of my question. And I don't see an abuse of the language either. Maybe this could pass as a

Re: Rounding up to the next 100

2010-01-21 Thread Alf P. Steinbach
* noydb: Sorry, although what I really need is the string-number rounded UP every time. So if the number is 3890.32, it needs to go to 3900; if the number is 3811.345, it needs to go to 3900 also. So, Florian's answer works. You might also consider -100*(-3579.127893//100) :-) Which avoi

Re: py2exe and pydocs. Downloads?

2010-01-21 Thread Gib Bogle
Gabriel Genellina wrote: En Wed, 20 Jan 2010 21:22:19 -0300, Gib Bogle escribió: Gabriel Genellina wrote: c:\temp>python -m pydoc sys Help on built-in module sys: [...same info...] When I do this I get: No module named tempfile You found a bug. Looks like it depends on the environment,

RE: Rounding up to the next 100

2010-01-21 Thread Michael . Coll-Barth
> From: Arnaud Delobelle > > > > >>> XstrNmbr = 3579.127893 > > I meant > >>> XstrNmbr = "3579.127893" > > > >>> round(float(XstrNmbr), -2) > > 3600.0 Ah, then you will need to cast it first. >>> XstrNmbr = '3579.127893' >>> round(float(XstrNmbr) ,-2) 3600.0 The information contained in

Re: Rounding up to the next 100

2010-01-21 Thread noydb
Sorry, although what I really need is the string-number rounded UP every time. So if the number is 3890.32, it needs to go to 3900; if the number is 3811.345, it needs to go to 3900 also. So, Florian's answer works. -- http://mail.python.org/mailman/listinfo/python-list

Re: Rounding up to the next 100

2010-01-21 Thread noydb
On Jan 21, 4:30 pm, michael.coll-ba...@verizonwireless.com wrote: > > From: noydb > > If one has a floating number as a string, is there a spiffy way to > > round that string-number UP to the nearest 100? > > > XstrNmbr = 3579.127893 -- would want to round that to 3600. > > What's wrong with round?

Re: Rounding up to the next 100

2010-01-21 Thread Alf P. Steinbach
* michael.coll-ba...@verizonwireless.com: From: noydb If one has a floating number as a string, is there a spiffy way to round that string-number UP to the nearest 100? XstrNmbr = 3579.127893 -- would want to round that to 3600. What's wrong with round? round( XstrNmbr, -2 ) seems to d

Re: Rounding up to the next 100

2010-01-21 Thread Florian Diesch
noydb writes: > If one has a floating number as a string, is there a spiffy way to > round that string-number UP to the nearest 100? > > XstrNmbr = 3579.127893 -- would want to round that to 3600. math.ceil(3579.127893/100)*100 Florian -- GUIs programmieren mit Python und Glade:

RE: Rounding up to the next 100

2010-01-21 Thread Michael . Coll-Barth
> From: noydb > If one has a floating number as a string, is there a spiffy way to > round that string-number UP to the nearest 100? > > XstrNmbr = 3579.127893 -- would want to round that to 3600. What's wrong with round? round( XstrNmbr, -2 ) seems to do the trick. Or do you want to get ri

Re: Rounding up to the next 100

2010-01-21 Thread Arnaud Delobelle
Arnaud Delobelle writes: > >>> XstrNmbr = 3579.127893 I meant >>> XstrNmbr = "3579.127893" > >>> round(float(XstrNmbr), -2) > 3600.0 -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Rounding up to the next 100

2010-01-21 Thread Arnaud Delobelle
noydb writes: > If one has a floating number as a string, is there a spiffy way to > round that string-number UP to the nearest 100? > > XstrNmbr = 3579.127893 -- would want to round that to 3600. > > Thanks for any help! >>> XstrNmbr = 3579.127893 >>> round(float(XstrNmbr), -2) 3600.0 >>> HTH

Re: counting lines of code

2010-01-21 Thread Phlip
Aahz wrote: In article <7e09df6a-cda1-480e-a971-8f8a70ac4...@b9g2000yqd.googlegroups.com>, Phlip wrote: On Jan 20, 11:20=A0pm, Michele Simionato wrote: pylint does too many things, I want something fast that just counts the lines and can be run on thousands of files at once. cloc seems fine,

Re: Python and Tkinter Programming by John Grayson

2010-01-21 Thread Peter
On Jan 15, 9:12 am, Kevin Walzer wrote: > On 1/14/10 3:39 PM, Peter wrote: > > > > > > > On Jan 15, 6:24 am, Mark Roseman  wrote: > >>   Peter  wrote: > >>> Besides, the book is mainly about using Python with Tkinter - and > >>> Tkinter hasn't changed that much since 2000, so I believe it is just

Re: py2exe and pydocs. Downloads?

2010-01-21 Thread Gib Bogle
Gabriel Genellina wrote: You found a bug. Looks like it depends on the environment, or what packages are installed, or something like that, because it worked on my other PC but not here. Please report it at http://bugs.python.org so it doesn't get forgotten. Done -- http://mail.python.org/m

Re: counting lines of code

2010-01-21 Thread Aahz
In article <7e09df6a-cda1-480e-a971-8f8a70ac4...@b9g2000yqd.googlegroups.com>, Phlip wrote: >On Jan 20, 11:20=A0pm, Michele Simionato >wrote: >> >> pylint does too many things, I want something fast that just counts >> the lines and can be run on thousands of files at once. >> cloc seems fine, I

Rounding up to the next 100

2010-01-21 Thread noydb
If one has a floating number as a string, is there a spiffy way to round that string-number UP to the nearest 100? XstrNmbr = 3579.127893 -- would want to round that to 3600. Thanks for any help! -- http://mail.python.org/mailman/listinfo/python-list

Re: simple pub/sub

2010-01-21 Thread Steve Howell
On Jan 21, 9:37 am, a...@pythoncraft.com (Aahz) wrote: > In article > <0af0eff2-50e2-44aa-81f1-b3d12cb26...@a15g2000yqm.googlegroups.com>, > Steve Howell   wrote: > > > > >Hi, I'm looking for ideas on building a simple architecture that > >allows a bunch of independent Python processes to exchange

Re: Closures in metaclasses

2010-01-21 Thread Arnaud Delobelle
Falcolas writes: > On Jan 21, 12:10 pm, Arnaud Delobelle wrote: [...] >> Or you could override __getattr__ >> >> -- >> Arnaud > > I tried overriding __getattr__ and got an error at runtime (the > instance did not have xyz key, etc), and the Tag dict is not > modifiable (granted, I tried Tag.__di

Re: Closures in metaclasses

2010-01-21 Thread Falcolas
On Jan 21, 1:55 pm, Peter Otten <__pete...@web.de> wrote: > Falcolas wrote: > > I tried overriding __getattr__ and got an error at runtime (the > > You can either move __getattr__() into the metaclass or instantiate the > class. I prefer the latter. > > Both approaches in one example: > > >>> class

Re: what test runner should I use?

2010-01-21 Thread Lacrima
On Jan 19, 12:56 pm, Chris Withers wrote: > Hi All, > > I'm wondering what test runner I should use. Here's my list of requirements: > > - cross platform (I develop for and on Windows, Linux and Mac) > > - should not prevent tests from running with other test runners >    (so no plugins/layers/etc

Re: Closures in metaclasses

2010-01-21 Thread Peter Otten
Falcolas wrote: > I tried overriding __getattr__ and got an error at runtime (the You can either move __getattr__() into the metaclass or instantiate the class. I prefer the latter. Both approaches in one example: >>> class Tag: ... class __metaclass__(type): ... def __getattr_

Re: Closures in metaclasses

2010-01-21 Thread Falcolas
On Jan 21, 12:10 pm, Arnaud Delobelle wrote: > On Jan 21, 6:37 pm, Falcolas wrote: > > > On Jan 21, 11:24 am, Arnaud Delobelle wrote: > > > It was the easiest way I found to add a lot of static methods to the > > Tag class without writing each one out. __getattr__ was not working > > for this ap

Re: Dynamic HTML controls

2010-01-21 Thread Aahz
In article , Alan Harris-Reid wrote: > >Does anyone know where I can find any decent dynamically-constructed >HTML control classes (dropdown list, table, input field, checkbox, etc.) >written in Python. For example, for a HTML table I would like something >like... You might look at Quixote:

Re: counting lines of code

2010-01-21 Thread Phlip
On Jan 20, 11:20 pm, Michele Simionato wrote: > pylint does too many things, I want something fast that just counts > the lines and can be run on thousands of files at once. > cloc seems fine, I have just tried on 2,000 files and it gives me a > report in just a few seconds. In my experience wit

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Carl Banks: On Jan 21, 10:46 am, "Alf P. Steinbach" wrote: * Carl Banks: On Jan 21, 2:38 am, "Alf P. Steinbach" wrote: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip] What I am really looking for is a way - to be able to call move(up) - having the "up" symbo

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
On Jan 21, 10:46 am, "Alf P. Steinbach" wrote: > * Carl Banks: > > > > > > > On Jan 21, 2:38 am, "Alf P. Steinbach" wrote: > >> * Carl Banks: > > >>> On Jan 20, 11:43 pm, Martin Drautzburg > >> [snip] > > What I am really looking for is a way >         - to be able to call move(up) > >

Re: Sorted dictionary

2010-01-21 Thread Arnaud Delobelle
"Jan Kaliszewski" writes: > Dnia 21-01-2010 o 09:27:52 Raymond Hettinger napisał(a): > >> On Jan 20, 5:02 pm, "Jan Kaliszewski" wrote: > >>> http://code.activestate.com/recipes/576998/ > >> Using an underlying list to track sorted items >> means that insertion and deletion take O(n) time. >> Th

Re: Sorted dictionary

2010-01-21 Thread Daniel Stutzbach
On Thu, Jan 21, 2010 at 12:45 PM, Jan Kaliszewski wrote: > Please note that I used funcions from bisect, that use binary search. > > Doesn't it take O(log n) time? > It takes O(log n) time to find the point to insert, but O(n) time to perform the actual insertion. -- Daniel Stutzbach, Ph.D. Pre

Re: multiprocessing as batch system

2010-01-21 Thread Neal Becker
Adam Tauno Williams wrote: > On Thu, 2010-01-21 at 07:13 -0500, Neal Becker wrote: >> I'm using multiprocessing as a poor man's batch system. It is working >> OK, except that it doesn't seem to do load balancing quite right. >> I have a 8-cpu machine. If I start, using multiprocessing pool, call

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Diez B. Roggisch: Am 21.01.10 20:01, schrieb Alf P. Steinbach: * Diez B. Roggisch: Am 21.01.10 19:48, schrieb Alf P. Steinbach: * Diez B. Roggisch: Am 21.01.10 12:58, schrieb Alf P. Steinbach: * Stefan Behnel: Alf P. Steinbach, 21.01.2010 11:38: * Carl Banks: On Jan 20, 11:43 pm, Martin

Re: Closures in metaclasses

2010-01-21 Thread Arnaud Delobelle
On Jan 21, 6:37 pm, Falcolas wrote: > On Jan 21, 11:24 am, Arnaud Delobelle wrote: > > > > > > > Falcolas writes: > > > I'm running into an issue with closures in metaclasses - that is, if I > > > create a function with a closure in a metaclass, the closure appears > > > to be lost when I access

Re: Symbols as parameters?

2010-01-21 Thread Diez B. Roggisch
Am 21.01.10 20:01, schrieb Alf P. Steinbach: * Diez B. Roggisch: Am 21.01.10 19:48, schrieb Alf P. Steinbach: * Diez B. Roggisch: Am 21.01.10 12:58, schrieb Alf P. Steinbach: * Stefan Behnel: Alf P. Steinbach, 21.01.2010 11:38: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip]

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Diez B. Roggisch: Am 21.01.10 19:48, schrieb Alf P. Steinbach: * Diez B. Roggisch: Am 21.01.10 12:58, schrieb Alf P. Steinbach: * Stefan Behnel: Alf P. Steinbach, 21.01.2010 11:38: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip] What I am really looking for is a way - to b

Re: Symbols as parameters?

2010-01-21 Thread Diez B. Roggisch
Am 21.01.10 19:48, schrieb Alf P. Steinbach: * Diez B. Roggisch: Am 21.01.10 12:58, schrieb Alf P. Steinbach: * Stefan Behnel: Alf P. Steinbach, 21.01.2010 11:38: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip] What I am really looking for is a way - to be able to call move(u

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Diez B. Roggisch: Am 21.01.10 12:58, schrieb Alf P. Steinbach: * Stefan Behnel: Alf P. Steinbach, 21.01.2010 11:38: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip] What I am really looking for is a way - to be able to call move(up) - having the "up" symbol only in the contex

Re: Sorted dictionary

2010-01-21 Thread Jan Kaliszewski
Dnia 21-01-2010 o 09:27:52 Raymond Hettinger napisał(a): On Jan 20, 5:02 pm, "Jan Kaliszewski" wrote: http://code.activestate.com/recipes/576998/ Using an underlying list to track sorted items means that insertion and deletion take O(n) time. That could be reduced to O(log n) time by usi

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Carl Banks: On Jan 21, 2:38 am, "Alf P. Steinbach" wrote: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip] What I am really looking for is a way - to be able to call move(up) - having the "up" symbol only in the context of the function call Short answer is, y

Re: Symbols as parameters?

2010-01-21 Thread Diez B. Roggisch
Am 21.01.10 12:58, schrieb Alf P. Steinbach: * Stefan Behnel: Alf P. Steinbach, 21.01.2010 11:38: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip] What I am really looking for is a way - to be able to call move(up) - having the "up" symbol only in the context of the function cal

Re: Sorted dictionary

2010-01-21 Thread Jan Kaliszewski
Dnia 21-01-2010 o 08:49:22 Chris Rebert napisał(a): On Wed, Jan 20, 2010 at 5:50 PM, Steven D'Aprano wrote: On Thu, 21 Jan 2010 02:02:02 +0100, Jan Kaliszewski wrote: http://code.activestate.com/recipes/576998/ What's the advantage of that over sorting the keys as needed? E.g. for ke

Re: Closures in metaclasses

2010-01-21 Thread Falcolas
On Jan 21, 11:24 am, Arnaud Delobelle wrote: > Falcolas writes: > > I'm running into an issue with closures in metaclasses - that is, if I > > create a function with a closure in a metaclass, the closure appears > > to be lost when I access the final class. I end up getting the text > > 'param' i

Re: Closures in metaclasses

2010-01-21 Thread Arnaud Delobelle
Falcolas writes: > I'm running into an issue with closures in metaclasses - that is, if I > create a function with a closure in a metaclass, the closure appears > to be lost when I access the final class. I end up getting the text > 'param' instead of the actual tags I am expecting: > > ALL_TAGS

Re: installing psycopg2-2.0.13 with python3.1

2010-01-21 Thread Iain Barnett
On 21 Jan 2010, at 00:11, Gabriel Genellina wrote: > En Wed, 20 Jan 2010 19:45:44 -0300, Iain Barnett > escribió: > >> Would anyone know if it's possible to install psycopg2-2.0.13 with >> python3.1.1 (or similar)?I can install it with python2.6 with no problems, >> but obviously I'd prefer

Re: Sorted dictionary

2010-01-21 Thread Jan Kaliszewski
21-01-2010, 07:21:22 Dennis Lee Bieber wrote: How does this differ from all the other "ordered dictionary" schemes out there (and maybe even included in 2.7? I'm still on 2.5) It's completely different, please read first paragraph of page I linked (http://code.activestate.com/recipe

Closures in metaclasses

2010-01-21 Thread Falcolas
I'm running into an issue with closures in metaclasses - that is, if I create a function with a closure in a metaclass, the closure appears to be lost when I access the final class. I end up getting the text 'param' instead of the actual tags I am expecting: ALL_TAGS = ['a', 'abbr', 'acronym', 'a

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
On Jan 21, 2:38 am, "Alf P. Steinbach" wrote: > * Carl Banks: > > > On Jan 20, 11:43 pm, Martin Drautzburg > [snip] > > >> What I am really looking for is a way > > >>         - to be able to call move(up) > >>         - having the "up" symbol only in the context of the function call > > > Short

Re: simple pub/sub

2010-01-21 Thread Aahz
In article <0af0eff2-50e2-44aa-81f1-b3d12cb26...@a15g2000yqm.googlegroups.com>, Steve Howell wrote: > >Hi, I'm looking for ideas on building a simple architecture that >allows a bunch of independent Python processes to exchange data using >files and perform calculations. SQLite? -- Aahz (a...@p

Re: simple pub/sub

2010-01-21 Thread Steve Howell
On Jan 21, 9:03 am, Adam Tauno Williams wrote: > On Thu, 2010-01-21 at 08:54 -0800, Steve Howell wrote: > > Hi, I'm looking for ideas on building a simple architecture that > > allows a bunch of independent Python processes to exchange data using > > files and perform calculations. > > One Python

Python sys.prefix

2010-01-21 Thread zachar
Hi All, I need some help about my "problem": I compiled and installed python with ./configure --prefix=/opt/pyhon2.6.4... But I have to move it to a different directory (the reason is very difficult but I must do this)... I started the interpreter from shell and I was surprised because It still

Re: simple pub/sub

2010-01-21 Thread Adam Tauno Williams
On Thu, 2010-01-21 at 08:54 -0800, Steve Howell wrote: > Hi, I'm looking for ideas on building a simple architecture that > allows a bunch of independent Python processes to exchange data using > files and perform calculations. > One Python program would be collecting data from boat instruments on

Re: Create object name from string value?

2010-01-21 Thread Stephen Hansen
On Thu, Jan 21, 2010 at 6:23 AM, Gnarlodious wrote: > This works! However I end up saying: > > d['Server'].Config.BaseURL > > to get the data, when I should be saying: > > Server.Config.BaseURL That's the thing: you should not actually be saying that. d['Server'].Config.BaseURL is precisely wh

simple pub/sub

2010-01-21 Thread Steve Howell
Hi, I'm looking for ideas on building a simple architecture that allows a bunch of independent Python processes to exchange data using files and perform calculations. One Python program would be collecting data from boat instruments on a serial port, then writing that info out to a file, and also

Re: Create object name from string value?

2010-01-21 Thread Dave Angel
Gnarlodious wrote: On Jan 20, 10:35 pm, Steven D'Aprano wrote: That's the wrong way to handle the problem. Named objects are only useful if you know the name of the object when writing the code. Otherwise, how do you know what name to use in the code? Thank you for the help. I am gath

Re: multiprocessing as batch system

2010-01-21 Thread Adam Tauno Williams
On Thu, 2010-01-21 at 07:13 -0500, Neal Becker wrote: > I'm using multiprocessing as a poor man's batch system. It is working OK, > except that it doesn't seem to do load balancing quite right. > I have a 8-cpu machine. If I start, using multiprocessing pool, calling map > with more than 8 elem

Re: Create object name from string value?

2010-01-21 Thread Adam Tauno Williams
> > but for the record, the way to use exec is like this: > > exec("object1 = classname()") > I failed to make that work. So back to the original question. How to > make an instance named according to a string inside a variable? I > guess it should be in the top-level namespace, not inside a list o

Re: Symbols as parameters?

2010-01-21 Thread Dave Angel
Martin Drautzburg wrote: Hello all, When passing parameters to a function, you sometimes need a paramter which can only assume certain values, e.g. def move (direction): ... If direction can only be "up", "down", "left" or "right", you can solve this by passing strings,

distutils not finding all of my pure python modules

2010-01-21 Thread Jeremy
I have a small set of Python packages/modules that I am putting together. I'm having trouble in that when I run python setup.py sdist I don't get all of my pure python modules. The setup.py script I use is: # = from distutils.core import setup purePythonMod

Re: Create object name from string value?

2010-01-21 Thread Tim Chase
Gnarlodious wrote: for name in ["object1", "object2", "object3"]: d = {name: classname()} print d[name] This works! However I end up saying: d['Server'].Config.BaseURL to get the data, when I should be saying: Server.Config.BaseURL It sounds like you want a mapping of strings to cl

Re: substitution

2010-01-21 Thread Wilbert Berendsen
Op donderdag 21 januari 2010 schreef MRAB: > For longest first you need: > > keys = sorted(mapping.keys(), key=len, reverse=True) Oh yes, I cut/pasted the wrong line :-) Just for clarity: import re mapping = { "foo" : "bar", "baz" : "quux", "quuux" : "foo" } # sor

Re: substitution

2010-01-21 Thread Iain King
On Jan 21, 2:18 pm, Wilbert Berendsen wrote: > Op maandag 18 januari 2010 schreef Adi: > > > keys = [(len(key), key) for key in mapping.keys()] > > keys.sort(reverse=True) > > keys = [key for (_, key) in keys] > > > pattern = "(%s)" % "|".join(keys) > > repl = lambda x : mapping[x.group(1)] > > s

PyQt v4.7 Released

2010-01-21 Thread Phil Thompson
PyQt v4.7 has been released and is available from http://www.riverbankcomputing.com/software/pyqt/. PyQt is a comprehensive set of bindings for the Qt application and UI framework from Nokia. It supports the same platforms as Qt (Windows, Linux and MacOS/X). PyQt supports Python v3 and Python v2

Re: Create object name from string value?

2010-01-21 Thread Alf P. Steinbach
* Gnarlodious: On Jan 20, 10:35 pm, Steven D'Aprano wrote: That's the wrong way to handle the problem. Named objects are only useful if you know the name of the object when writing the code. Otherwise, how do you know what name to use in the code? Thank you for the help. I am gathering the na

creating a python program to control the cursor and click a location on the screen at specified delay interval?

2010-01-21 Thread John Haggerty
HiSo just testing the feasibility of doing this but I was interested in creating a primitive way of scripting gui applications w/o using a remote network client by having the application up and then almost just using the pointer position to figure out where it is and then click it and any subse

Re: Sorted dictionary

2010-01-21 Thread Daniel Stutzbach
On Thu, Jan 21, 2010 at 2:27 AM, Raymond Hettinger wrote: > Using an underlying list to track sorted items > means that insertion and deletion take O(n) time. > That could be reduced to O(log n) time by using > a blist or skiplist as the underlying structure > for maintaining a sort. > Indeed.

Re: substitution

2010-01-21 Thread MRAB
Wilbert Berendsen wrote: Op maandag 18 januari 2010 schreef Adi: keys = [(len(key), key) for key in mapping.keys()] keys.sort(reverse=True) keys = [key for (_, key) in keys] pattern = "(%s)" % "|".join(keys) repl = lambda x : mapping[x.group(1)] s = "fooxxxbazyyyquuux" re.subn(pattern, repl, s

SIP v4.10 Released (Python Bindings Generator)

2010-01-21 Thread Phil Thompson
SIP v4.10 has been released and can be downloaded from http://www.riverbankcomputing.com/software/sip/. SIP is a tool for generating Python modules that wrap C or C++ libraries. It is similar to SWIG. It is used to generate PyQt and PyKDE. The SIP license is similar to the Python License and is

Re: Create object name from string value?

2010-01-21 Thread Gnarlodious
On Jan 20, 10:35 pm, Steven D'Aprano wrote: > That's the wrong way to handle the problem. Named objects are only useful > if you know the name of the object when writing the code. Otherwise, how > do you know what name to use in the code? Thank you for the help. I am gathering the names of all *.

Re: substitution

2010-01-21 Thread Wilbert Berendsen
Op maandag 18 januari 2010 schreef Adi: > keys = [(len(key), key) for key in mapping.keys()] > keys.sort(reverse=True) > keys = [key for (_, key) in keys] > > pattern = "(%s)" % "|".join(keys) > repl = lambda x : mapping[x.group(1)] > s = "fooxxxbazyyyquuux" > > re.subn(pattern, repl, s) I manag

ReportLab PDF Toolkit v2.4 released

2010-01-21 Thread Tim
We're pleased to announce the latest version of the ReportLab open source PDF toolkit, now available for download here: https://www.reportlab.com/software/opensource/rl-toolkit/download/ The ReportLab Toolkit is a library for programatically creating documents in PDF format. It's free, open-sour

Re: subprocess troubles

2010-01-21 Thread Tomas Pelka
On 01/21/2010 11:39 AM, Javier Collado wrote: Hello, If you set shell=False, then I think that arg2 should be separated into two different parts. Also, arg3 could be set just to pattern (no need to add extra spaces or using str function). Best regards, Javier 2010/1/21 Tomas Pelka: Hey

Re: covert number into string

2010-01-21 Thread Joel Goldstick
anusha k wrote: Hi, Can anyone tell me how to convert number to words For example: If number = then it should give me *Nine thousand nine hundred ninetynine* Is there any build-in function or something that can do this for me Thank you in advance Anusha Kadambala This might help: http:

multiprocessing as batch system

2010-01-21 Thread Neal Becker
I'm using multiprocessing as a poor man's batch system. It is working OK, except that it doesn't seem to do load balancing quite right. I have a 8-cpu machine. If I start, using multiprocessing pool, calling map with more than 8 elements, it will start 8 processes. It seems, though, that whe

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Stefan Behnel: Alf P. Steinbach, 21.01.2010 11:38: * Carl Banks: On Jan 20, 11:43 pm, Martin Drautzburg [snip] What I am really looking for is a way - to be able to call move(up) - having the "up" symbol only in the context of the function call Short answer is, you can't

  1   2   >