Re: Symbols as parameters?

2010-01-21 Thread Andre Engels
On Thu, Jan 21, 2010 at 8:43 AM, 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 "rig

Re: html code generation

2010-01-21 Thread John Nagle
George Trojan wrote: I need an advice on table generation. The table is essentially a fifo, containing about 200 rows. The rows are inserted every few minutes or so. The simplest solution is to store row data per line and write directly html code: line = "value1value2>... " each run of the pro

Re: Sorted dictionary

2010-01-21 Thread Raymond Hettinger
On Jan 20, 5:02 pm, "Jan Kaliszewski" wrote: > Hello, > > Inspired by some my needs as well as some discussions in the net, I've   > implemented a sorted dictionary (i.e. a dict that returns keys, values and   > items always sorted by keys): > > http://code.activestate.com/recipes/576998/ > > Mayb

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Martin Drautzburg: 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, but

Re: Symbols as parameters?

2010-01-21 Thread Javier Collado
Hello, I'd say that isn't totally incorrect to use strings instead of symbols. Please note that in other programming languages symbols, atoms and the like are in fact immutable strings, which is what python provides by default. Best regards, Javier 2010/1/21 Alf P. Steinbach : > * Martin Dra

Re: Symbols as parameters?

2010-01-21 Thread Ben Finney
Martin Drautzburg writes: > When passing parameters to a function, you sometimes need a paramter > which can only assume certain values You might like to try the ‘enum’ library for this http://pypi.python.org/pypi/enum>. -- \ “You could augment an earwig to the point where it understood

Re: Symbols as parameters?

2010-01-21 Thread Bearophile
Martin Drautzburg, having symbols spread in the namespace is bad. And too much magic is even worse. You seem to need something like an enum that must be used with its qualified name, as: move(direction.up) That works well unless the symbols name are keywords. Creating a small class like this (that

Re: Sorted dictionary

2010-01-21 Thread Bearophile
Raymond Hettinger: > 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. In the collections module it can be useful to have o

Re: Symbols as parameters?

2010-01-21 Thread Iain King
On Jan 21, 7:43 am, 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 ca

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
Huh? I guess you meant to reply to the OP, not me. Cheers, - Alf * Javier Collado: Hello, I'd say that isn't totally incorrect to use strings instead of symbols. Please note that in other programming languages symbols, atoms and the like are in fact immutable strings, which is what python pro

deleting, then re-importing a class method

2010-01-21 Thread Robert P. J. Day
(once again, never ashamed to ask the dumb questions.) still playing with python3, and testing whether i can delete/unimport a specific method, then re-import it: >>> import sys >>> print(sys.__doc__) ... blah blah blah ... >>> del(sys.__doc__) >>> print(sys.__doc__) module(name[, doc]) Cre

Re: why the super class can access the subclass's attribute

2010-01-21 Thread Jean-Michel Pichavant
yousay wrote: I have sees aprogram like this ,i confusing why super class can access the subclass's attribute ,this is the program,thanks in advance: class MyThread(threading.Thread): def join(self): super(MyThread,self).join() return self.result class Worker(MyThread): i

subprocess troubles

2010-01-21 Thread Tomas Pelka
Hey all, have a problem with following piece of code: -- import subprocess paattern = "python" cmd = "/usr/bin/locate" arg1 = " -i" arg2 = " -d /var/www/books/mlocate.db" arg3 = str(" " + pattern) p1 = subprocess.Popen([cmd, arg1, arg2, arg3], sh

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
On Jan 20, 11:43 pm, 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 c

Re: subprocess troubles

2010-01-21 Thread Javier Collado
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 all, > > have a problem with following piece of

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* 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 do it. On the contrary, it's not difficult to do.

Re: deleting, then re-importing a class method

2010-01-21 Thread Jean-Michel Pichavant
Robert P. J. Day wrote: (once again, never ashamed to ask the dumb questions.) still playing with python3, and testing whether i can delete/unimport a specific method, then re-import it: import sys print(sys.__doc__) ... blah blah blah ... del(sys.__doc__) print(sys.__doc_

Re: deleting, then re-importing a class method

2010-01-21 Thread Peter Otten
Robert P. J. Day wrote: > > (once again, never ashamed to ask the dumb questions.) > > still playing with python3, and testing whether i can > delete/unimport a specific method, then re-import it: > import sys print(sys.__doc__) > ... blah blah blah ... del(sys.__doc__)

Re: Symbols as parameters?

2010-01-21 Thread Jean-Michel Pichavant
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,

Re: Best way to convert sequence of bytes to long integer

2010-01-21 Thread Helmut Jarausch
On 01/20/10 22:23, Steven D'Aprano wrote: I'm writing a module that handles, I won't call it encryption, obfuscation using classical cryptographic algorithms. One of the functions needs a deterministic but unpredictable integer generated from a human-generated password or passphrase, so I'm usin

covert number into string

2010-01-21 Thread anusha k
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 -- http://mail.python.org/mailman/listinfo/py

Re: Symbols as parameters?

2010-01-21 Thread Stefan Behnel
Alf P. Steinbach, 21.01.2010 09:30: > * Martin Drautzburg: >> - to be able to call move(up) >> - having the "up" symbol only in the context of the function call >> >> So it should look something like this >> >> ... magic, magic ... >> move(up) >> ... unmagic, unmagic ... >> print up

Re: Symbols as parameters?

2010-01-21 Thread 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,

Re: covert number into string

2010-01-21 Thread Jan Ulrich Hasecke
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 21.01.10 12:18, 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

Re: Symbols as parameters?

2010-01-21 Thread Alf P. Steinbach
* Stefan Behnel: Alf P. Steinbach, 21.01.2010 09:30: * Martin Drautzburg: - to be able to call move(up) - having the "up" symbol only in the context of the function call So it should look something like this ... magic, magic ... move(up) ... unmagic, unmagic ... print up Loo

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

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: 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:

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

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: 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

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 *.

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: 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

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.

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: 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

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: 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

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: 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

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: 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,

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: 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 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

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 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

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

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 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

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: 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

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: 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

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: 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: 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: 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: 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: 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: 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
* 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: 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 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 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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

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: 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

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: 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: 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: 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: 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 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 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 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 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 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 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: 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 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: 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: 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 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: 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

  1   2   >