Re: virtualpython / workingenv / virtualenv ... shouldn't this be part of python

2008-01-15 Thread Damjan
>> My question is, shoudn't it be enough to set PYTHONPATH and everything >> automagically to work then? Is there some work done on this for python >> 3.0 or 2.6 perhaps? > > I'm working on a PEP for a per user site dir for 2.6 and 3.0 great .. can't hardly wait. -- damjan -- http://mail.pytho

Re: hide object property from dir() function?

2008-01-15 Thread Tim Golden
jerryji wrote: > Sorry for this newbie question, I was puzzled why the existing > property of an object is not shown in the dir() function output. The under-development version of Python (2.6) allows for a __dir__ magic method by which the class implementer can return whatever he wishes from a dir

Re: import from question

2008-01-15 Thread Duncan Booth
iu2 <[EMAIL PROTECTED]> wrote: > file a3.py: > > from a1 import the_number > import a2 > ... > > Why doesn't it work in the first version of a3.py? > Think of 'import a2' as being the same as: a2 = __import__('a2') and 'from a1 import the_number' as roughly the same as: the_number =

print >> to a derived file

2008-01-15 Thread iu2
Hi, I'm trying to write data to both a file and the console, so I did: class File_and_console(file): def write(self, s): file.write(self, s) print s, >>> f = File_and_console('1.txt', 'w') >>> f.write('hello') hello >>> print >>f, 'world' >>> the 'write'

Re: "env" parameter to "popen" won't accept Unicode on Windows - minor Unicode bug

2008-01-15 Thread Diez B. Roggisch
John Nagle wrote: > Benjamin wrote: >> On Jan 14, 6:26 pm, Bjoern Schliessmann > [EMAIL PROTECTED]> wrote: >>> John Nagle wrote: It turns out that the strings in the "env" parameter have to be ASCII, not Unicode, even though Windows fully supports Unicode in CreateProcess. That's o

Re: Dynamical scoping

2008-01-15 Thread Kay Schluehr
On 15 Jan., 02:13, Paul Rubin wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > What's the best way to simulate dynamically scoped variables ala Lisp ? > > Ugh check the docs for the python 2.5 "with" statement, which > gives you sort of a programmable unwind-pro

[help request] how to set sys.stderr to object of cStringIO type

2008-01-15 Thread grbgooglefan
I am in a perculiar situation. I want to use PyRun_SimpleString for creating Python functions in embedded Python in C++. But there could be cases when Python function code compilation could fail & PyRun_SimpleString will return -1 as return status. At this time, it prints the error message to sys.s

Re: Append zip files together, just get the binary data (in memory)

2008-01-15 Thread John Machin
On Jan 15, 9:58 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Module StringIO is your friend. and cStringIO is your ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Data mapper - need to map an dictionary of values to a model

2008-01-15 Thread bearophileHUGS
Luke: >What design patterns would you use here?< What about "generator (scanner) with parameters"? :-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: __init__ explanation please

2008-01-15 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : > Ben Finney <[EMAIL PROTECTED]> writes: > >> Hrvoje Niksic <[EMAIL PROTECTED]> writes: >> >>> Wildemar Wildenburger <[EMAIL PROTECTED]> writes: __init__() /initializes/ an instance (automatically after creation). It is called, /after/ the instance has been constr

Re: Python too slow?

2008-01-15 Thread bearophileHUGS
Paul Boddie: > what is everyone with any degree of > concern about Python's performance doing to improve the situation? They are probably developing systems like Cython and ShedSkin, and hoping to see Psyco improved again to manage itertools better (and maybe 64 bit CPUs too). > Sure, C (or actu

Re: Dynamical scoping

2008-01-15 Thread Kay Schluehr
On 14 Jan., 21:17, George Sakkis <[EMAIL PROTECTED]> wrote: > What's the best way to simulate dynamically scoped variables ala > Lisp ? The use case is an open-ended set of objects that need to > access the same piece of information (e.g. a dict, a ConfigParser > object, a logger etc.). I know tha

Re: Python too slow?

2008-01-15 Thread Bruno Desthuilliers
Jaimy Azle a écrit : > <[EMAIL PROTECTED]> wrote: > fact 1: CPython compiles source code to byte-code. fact 2: CPython executes this byte-code. fact 3: Sun's JDK compiles source code to byte-code. fact 4: Sun's JDK executes this byte-code. >>> Fact 4 is misleading because it is

common problem - elegant solution sought

2008-01-15 Thread Helmut Jarausch
Hi, I'm looking for an elegant solution of the following tiny but common problem. I have a list of tuples (Unique_ID,Date) both of which are strings. I want to delete the tuple (element) with a given Unique_ID, but I don't known the corresponding Date. My straight forward solution is a bit leng

Re: MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread Jarek Zgoda
washakie napisał(a): > I need to install the MySQL-python-1.2.2 connector in order to access a db > on another machine. In the install it asks for the location of the > mysql_config file, and if I leave it as the default I get: > > [EMAIL PROTECTED] MySQL-python-1.2.2]# python setup.py build > sh

Re: Python too slow?

2008-01-15 Thread cokofreedom
A lecturer gave me the perfect answer to the question of speed. "You have two choices when it comes to programming. Fast code, or fast coders." -- http://mail.python.org/mailman/listinfo/python-list

Re: common problem - elegant solution sought

2008-01-15 Thread cokofreedom
> I have a list of tuples (Unique_ID,Date) both of which are strings. > I want to delete the tuple (element) with a given Unique_ID, but > I don't known the corresponding Date. > > My straight forward solution is a bit lengthy, e.g. > > L=[("a","070501"),("b","080115"),("c","071231")] Do they hav

Re: common problem - elegant solution sought

2008-01-15 Thread Tim Golden
Helmut Jarausch wrote: > I'm looking for an elegant solution of the following tiny but common problem. > > I have a list of tuples (Unique_ID,Date) both of which are strings. > I want to delete the tuple (element) with a given Unique_ID, but > I don't known the corresponding Date. > > My straigh

Re: print >> to a derived file

2008-01-15 Thread Ben Fisher
This might have something to do with the class being derived from file. I've written it so that it doesn't derive from file, and it works. class File_and_console(): def __init__(self, *args): self.fileobj = open(*args) def write(self, s): self.fileo

MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread washakie
Hello, I need to install the MySQL-python-1.2.2 connector in order to access a db on another machine. In the install it asks for the location of the mysql_config file, and if I leave it as the default I get: [EMAIL PROTECTED] MySQL-python-1.2.2]# python setup.py build sh: mysql_config: command n

Re: __init__ explanation please

2008-01-15 Thread Hrvoje Niksic
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > So while it's true that __init__ is the closest equivalent to what > C++ and Java (and possibly a couple "other languages") call a > constructor, it doesn't imply that you should refer to it as "the > constructor". As Neil Cerutti points out, there

Re: print >> to a derived file

2008-01-15 Thread iu2
On Jan 15, 12:44 pm, "Ben Fisher" <[EMAIL PROTECTED]> wrote: > This might have something to do with the class being derived from file. > > I've written it so that it doesn't derive from file, and it works. > > class File_and_console(): >         def __init__(self, *args): >                 self.fil

Re: common problem - elegant solution sought

2008-01-15 Thread Bruno Desthuilliers
Helmut Jarausch a écrit : > Hi, > > I'm looking for an elegant solution of the following tiny but common > problem. > > I have a list of tuples (Unique_ID,Date) both of which are strings. > I want to delete the tuple (element) with a given Unique_ID, but > I don't known the corresponding Date.

Re: common problem - elegant solution sought

2008-01-15 Thread Helmut Jarausch
Thanks to you all for your help. The solution to regenerate the list skipping the one to be deleted is fine for me since my lists are of moderate size and the operation is infrequent. Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germ

Re: how to set sys.stderr to object of cStringIO type

2008-01-15 Thread grbgooglefan
On Jan 15, 5:45 pm, grbgooglefan <[EMAIL PROTECTED]> wrote: > I am in a perculiar situation. I want to use PyRun_SimpleString for > creating Python functions in embedded Python in C++. > But there could be cases when Python function code compilation could > fail & PyRun_SimpleString will return -1

Re: common problem - elegant solution sought

2008-01-15 Thread Diez B. Roggisch
Helmut Jarausch wrote: > Hi, > > I'm looking for an elegant solution of the following tiny but common > problem. > > I have a list of tuples (Unique_ID,Date) both of which are strings. > I want to delete the tuple (element) with a given Unique_ID, but > I don't known the corresponding Date. >

Re: MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread Jarek Zgoda
washakie napisał(a): > Okay, I've installed mysql then using yum... it installed the same version > running on another machine with identical python where all works well... but > now I get this error during build... thoughts?!?? mysql_config is there, and > the site.cfg file is pointing correctly t

Re: Python too slow?

2008-01-15 Thread Paul Boddie
On 15 Jan, 08:33, "Jaimy Azle" <[EMAIL PROTECTED]> wrote: > > perhaps in the future another sillly point could be added also, Java has > Jython, while Python doesn't have some thing like PyJava or... perhaps Py-va > (Python based Java Language). You could compile Java to CPython bytecode or, in th

Re: common problem - elegant solution sought

2008-01-15 Thread Steven D'Aprano
On Tue, 15 Jan 2008 11:33:36 +0100, Helmut Jarausch wrote: > Hi, > > I'm looking for an elegant solution of the following tiny but common > problem. > > I have a list of tuples (Unique_ID,Date) both of which are strings. I > want to delete the tuple (element) with a given Unique_ID, but I don't

Re: MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread washakie
Okay, I've installed mysql then using yum... it installed the same version running on another machine with identical python where all works well... but now I get this error during build... thoughts?!?? mysql_config is there, and the site.cfg file is pointing correctly to it... : [root@ MySQL-pyth

Re: Python too slow?

2008-01-15 Thread Paul Rudin
[EMAIL PROTECTED] writes: > A lecturer gave me the perfect answer to the question of speed. > > "You have two choices when it comes to programming. Fast code, or fast > coders." Yes, although it's more a continuum than that suggests. The tricky bit is deciding in each situation where you should b

RE: "env" parameter to "popen" won't accept Unicode on Windows -minor Unicode bug

2008-01-15 Thread Brian Smith
Diez B. Roggisch wrote: > Sure thing, python will just magically convert unicode to the > encoding the program YOU invoke will expect. Right after we > introduced the > > solve_my_problem() > > built-in-function. Any other wishes? There's no reason to be rude. Anyway, at least on Windows it m

Re: common problem - elegant solution sought

2008-01-15 Thread Neil Cerutti
On Jan 15, 2008 5:33 AM, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > Hi, > > I'm looking for an elegant solution of the following tiny but common problem. > > I have a list of tuples (Unique_ID,Date) both of which are strings. > I want to delete the tuple (element) with a given Unique_ID, but > I

Re: Append zip files together, just get the binary data (in memory)

2008-01-15 Thread Neil Cerutti
On Jan 15, 2008 4:28 AM, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 15, 9:58 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > Module StringIO is your friend. > > and cStringIO is your ? ... friend +1? -- Neil Cerutti <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/

RE: "env" parameter to "popen" won't accept Unicode on Windows -minor Unicode bug

2008-01-15 Thread Diez B. Roggisch
Brian Smith wrote: > Diez B. Roggisch wrote: >> Sure thing, python will just magically convert unicode to the >> encoding the program YOU invoke will expect. Right after we >> introduced the >> >> solve_my_problem() >> >> built-in-function. Any other wishes? > > There's no reason to be rude. I

Re: Python too slow?

2008-01-15 Thread cokofreedom
On Jan 15, 1:28 pm, Paul Rudin <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > A lecturer gave me the perfect answer to the question of speed. > > > "You have two choices when it comes to programming. Fast code, or fast > > coders." > > Yes, although it's more a continuum than that sugge

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-15 Thread aspineux
On Jan 15, 12:15 am, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > > map = {'a': Aclass, 'b': Bclass, 'c': Cclass} > > class_ = map.get(astring, default=Zclass) > > > The result I want is the class, not the result of calling the class > > (which would

Re: Basic inheritance question

2008-01-15 Thread Bruno Desthuilliers
Lie a écrit : > On Jan 7, 2:46 am, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >> Lie a écrit : >> >>> On Jan 5, 5:40 pm, [EMAIL PROTECTED] wrote: Jeroen Ruigrok van der Werven wrote: > Shouldn't this be: > self.startLoc = start > self.stopLoc = stop Thanks! Of course it

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-15 Thread aspineux
On Jan 14, 8:07 pm, aspineux <[EMAIL PROTECTED]> wrote: > On Jan 14, 7:49 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > > > On Jan 14, 2008 12:39 PM, aspineux <[EMAIL PROTECTED]> wrote: > > > > This append in both case > > > > dict(a=1).get('a', f()) > > > dict(a=1).setdefault('a', f()) > > > > T

Re: Restart crashing modules in windows

2008-01-15 Thread Mike Driscoll
On Jan 14, 9:02 pm, Astan Chee <[EMAIL PROTECTED]> wrote: > Hi, > I have a python module that keeps on crashing with various windows > errors (not BSOD but the less lethal windows XP popup ones). Now these > are intentional and rather sporadic so I cant really solve it by > attempting to fix the cr

Re: i am new guy for this discussion group

2008-01-15 Thread cnboy
HI! I'm also chinese. welcome to you! "bill.wu" <[EMAIL PROTECTED]> ??:[EMAIL PROTECTED] >i am new guy to learn python,also for this discussion group, i am > chinese. > nice to meet you, everyone. -- http://mail.python.org/mailman/listinfo/python-list

ElementTree and namespaces in the header only

2008-01-15 Thread Peter Bengtsson
Here's my code (simplified): NS_URL = 'http://www.snapexpense.com/atom_ns#' ElementTree._namespace_map[NS_URL] = 'se' def SEN(tag): return "{%s}%s" % (NS_URL, tag) root = Element('feed', xmlns='http://www.w3.org/2005/Atom') root.set('xmlns:se', NS_URL) entry = SubElement(root, 'entry') SubEle

Re: common problem - elegant solution sought

2008-01-15 Thread Helmut Jarausch
Neil Cerutti wrote: > On Jan 15, 2008 5:33 AM, Helmut Jarausch <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I'm looking for an elegant solution of the following tiny but common problem. >> >> I have a list of tuples (Unique_ID,Date) both of which are strings. >> I want to delete the tuple (element) wit

Re: A question about event handlers with wxPython

2008-01-15 Thread Erik Lind
> def HandleSomething(self, event): >generating_control = event.GetEventObject() >print generating_control > > HTH, Thank you.That is what I was looking for, but as often seems the case, one thing exposes another. Is there any way to listen for events without specifically binding to a ha

Benchmark [was Re: common problem - elegant solution sought]

2008-01-15 Thread Helmut Jarausch
Again, many thanks to all who provide their solution. I have timed these (though on my old P3(0.9GHz)) - see below Helmut. Helmut Jarausch wrote: > Hi, > > I'm looking for an elegant solution of the following tiny but common > problem. > > I have a list of tuples (Unique_ID,Date) both of which

Why this apparent assymetry in set operations?

2008-01-15 Thread skip
I've noticed that I can update() a set with a list but I can't extend a set with a list using the |= assignment operator. >>> s = set() >>> s.update([1,2,3]) >>> s set([1, 2, 3]) >>> s |= [4,5,6] Traceback (most recent call last): File "", line 1, in TypeError:

Interesting Thread Gotcha

2008-01-15 Thread Hendrik van Rooyen
I thought I would share this nasty little gotcha with the group. Consider the following code fragment: print 'starting kbd thread' keyboard_thread = thread.start_new_thread(kbd_driver (port_q,kbd_q)) print 'starting main loop' error = Mainloop(s,port_q,active_q_list) It produces, as output, t

Re: A question about event handlers with wxPython

2008-01-15 Thread Mike Driscoll
On Jan 15, 9:04 am, "Erik Lind" <[EMAIL PROTECTED]> wrote: > > def HandleSomething(self, event): > >generating_control = event.GetEventObject() > >print generating_control > > > HTH, > > Thank you.That is what I was looking for, but as often seems the case, one > thing exposes another. Is t

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Colin J. Williams
Neil Cerutti wrote: > On Jan 15, 2008 10:10 AM, <[EMAIL PROTECTED]> wrote: >> I've noticed that I can update() a set with a list but I can't extend a set >> with a list using the |= assignment operator. >> >> >>> s = set() >> >>> s.update([1,2,3]) >> >>> s >> set([1, 2, 3]) >>

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Neil Cerutti
On Jan 15, 2008 10:10 AM, <[EMAIL PROTECTED]> wrote: > > I've noticed that I can update() a set with a list but I can't extend a set > with a list using the |= assignment operator. > > >>> s = set() > >>> s.update([1,2,3]) > >>> s > set([1, 2, 3]) > >>> s |= [4,5,6] > Trace

Re: Interesting Thread Gotcha

2008-01-15 Thread Dan
On Jan 15, 10:07 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > I thought I would share this nasty little gotcha with the group. > > Consider the following code fragment: > > > print 'starting kbd thread' > keyboard_thread = thread.start_new_thread(kbd_driver (port_q,kbd_q)) > print 'starti

Re: jpype with JFreeChart, anyone interested to help?

2008-01-15 Thread Peter Wang
On Jan 14, 8:25 pm, oyster <[EMAIL PROTECTED]> wrote: > Thanx > However I knew Chaco and matplotlib, and I use matplotlib during my > school days. And as I have pointed out, they are for "plot", but not > "chart". If you don't know the difference between plot and chart, you > can have a look at ath

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Colin J. Williams
Colin J. Williams wrote: > Neil Cerutti wrote: >> On Jan 15, 2008 10:10 AM, <[EMAIL PROTECTED]> wrote: >>> I've noticed that I can update() a set with a list but I can't extend a set >>> with a list using the |= assignment operator. >>> >>> >>> s = set() >>> >>> s.update([1,2,3]) >>> >

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Skip Montanaro
> If the RHS is a set then it works OK: Yup, I understand that. Would be kind of bad if it didn't. ;-) > It could be modifies to handle any > iterable on the RHS. That's my question. Why does it work in one place but not everywhere? Skip -- http://mail.python.org/mailman/listinfo/python-

Retrieving info from DBUS at application startup

2008-01-15 Thread Frank Aune
Hello, Detecting Hotpluggable hardware using DBUS works great, but usually peripherals are already connected when launching the application. How can I (preferably using DBUS) detect which USB printers for example are connected to the system at application launch without engaging in some insane

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Skip Montanaro
> > Why is that? Doesn't the |= operator essentially map to an update() call? > > No, according to 3.7 Set Types, s | t maps to s.union(t). I was asking about the |= assignment operator which according to the docs *does* map to the update method. Skip -- http://mail.python.org/mailman/list

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Sergio Correia
Both of you are correct. >>> x = set([1,2,3]) >>> y = set([4,5]) >>> x |= y >>> x set([1, 2, 3, 4, 5]) On Jan 15, 2008 11:07 AM, Skip Montanaro <[EMAIL PROTECTED]> wrote: > > > Why is that? Doesn't the |= operator essentially map to an update() call? > > > > No, according to 3.7 Set Types, s |

Leo 4.4.6 beta 2 released

2008-01-15 Thread Edward K Ream
Leo 4.4.6 beta 2 is available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 Leo 4.4.6 fixes several recently reported bugs, all minor. Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The

Re: Python too slow?

2008-01-15 Thread bearophileHUGS
[EMAIL PROTECTED]: > A lecturer gave me the perfect answer to the question of speed. > "You have two choices when it comes to programming. Fast code, or fast > coders." I don't believe that anymore, ShedSkin compiles slowly and it has limitations still, but it shows that it's possible to create a

Re: Benchmark [was Re: common problem - elegant solution sought]

2008-01-15 Thread bearophileHUGS
Helmut Jarausch: > The clear winner is > > def del_by_key(L,key) : >for pos, (k,d) in enumerate(L): > if k == key : >del L[pos] >break If you use Psyco this is faster: def del_by_key(L,key): pos = 0 for pair in L: if pair[0] == key : del L[pos]

Re: A question about event handlers with wxPython

2008-01-15 Thread Mike Driscoll
On Jan 15, 9:04 am, "Erik Lind" <[EMAIL PROTECTED]> wrote: > > def HandleSomething(self, event): > >generating_control = event.GetEventObject() > >print generating_control > > > HTH, > > Thank you.That is what I was looking for, but as often seems the case, one > thing exposes another. Is t

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Neil Cerutti
On Jan 15, 2008 11:07 AM, Skip Montanaro <[EMAIL PROTECTED]> wrote: > > > Why is that? Doesn't the |= operator essentially map to an update() call? > > > > No, according to 3.7 Set Types, s | t maps to s.union(t). > > I was asking about the |= assignment operator which according to the > docs *doe

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Chris M
On Jan 15, 11:51 am, "Neil Cerutti" <[EMAIL PROTECTED]> wrote: > > So this is a bug in set_update or in set_ior. They can't both be > right. > It's not a bug. "Note, the non-operator versions of union(), intersection(), difference(), and symmetric_difference(), issubset(), and issuperset() method

Re: ElementTree and namespaces in the header only

2008-01-15 Thread Fredrik Lundh
Peter Bengtsson wrote: > root = Element('feed', xmlns='http://www.w3.org/2005/Atom') > root.set('xmlns:se', NS_URL) > entry = SubElement(root, 'entry') > SubElement(root, 'title').text = 'Title' > SubElement(entry, SEN('category')).text = 'Category' > But surely the xmlns:se attribute on the tag

Re: super, decorators and gettattribute

2008-01-15 Thread Rhamphoryncus
On Jan 13, 5:51 am, Richard Szopa <[EMAIL PROTECTED]> wrote: > On Jan 13, 8:59 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > On Sat, 12 Jan 2008 14:23:52 -0800, Richard Szopa wrote: > > > However, I am very surprised to learn that > > > > super_object.__getattr__(name)(*args, **kwar

Re: Python's great, in a word

2008-01-15 Thread Jan Claeys
Op Mon, 07 Jan 2008 05:09:15 -0800, schreef MartinRinehart: > Would you Python old-timers try to agree on a word or two that > completes: > > The best thing about Python is ___. > > Please, no laundry lists, just a word or two. I'm thinking "fluid" or > "grace" but I'm not sure I've done eno

Open existing Word document, modify and save.

2008-01-15 Thread gsal
New to Python and new to Win32. Help please. O.k., so this might seem like one of those "can you do my homework" kind of postings, except that is not homework, it is officework. I have been reading the Core Python book and I am really excited about starting my next project with Python, instead of

Re: Dynamical scoping

2008-01-15 Thread Paul Rubin
Kay Schluehr <[EMAIL PROTECTED]> writes: > On 15 Jan., 02:13, Paul Rubin wrote: > > George Sakkis <[EMAIL PROTECTED]> writes: > > > What's the best way to simulate dynamically scoped variables ala Lisp ? > > > > Ugh check the docs for the python 2.5 "with" statement,

Re: Benchmark [was Re: common problem - elegant solution sought]

2008-01-15 Thread Paul Rubin
Helmut Jarausch <[EMAIL PROTECTED]> writes: > def del_by_key(L,key) : >for pos, (k,d) in enumerate(L): > if k == key : >del L[pos] >break This looks very dangerous, mutating L while iterating over it. -- http://mail.python.org/mailman/listinfo/python-list

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-15 Thread Paul Rubin
aspineux <[EMAIL PROTECTED]> writes: > Nice idea, but if I want args I need to write it like that: > > x=d.get('a', defaultfunc=f, funcargs=(1,2,3)) Yeah, that looks good. The default arg to f should be the key being looked up. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Paul Rubin
Chris M <[EMAIL PROTECTED]> writes: > precludes error-prone constructions like set('abc') & 'cbs' in favor > of the more readable set('abc').intersection('cbs')." set('abc') & set('cbs') -- http://mail.python.org/mailman/listinfo/python-list

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Neil Cerutti
On Jan 15, 2008 12:06 PM, Chris M <[EMAIL PROTECTED]> wrote: > On Jan 15, 11:51 am, "Neil Cerutti" <[EMAIL PROTECTED]> wrote: > > > > So this is a bug in set_update or in set_ior. They can't both be > > right. > > > > It's not a bug. > > "Note, the non-operator versions of union(), intersection(),

Iterate through slots

2008-01-15 Thread Jared Grubb
How can I iterate through the slots of a class, including those it inherits from parent classes? class C(object): __slots__ = ['a'] class D(C): __slots__ = ['b'] >>> d = D() >>> d.__slots__ ['b'] >>> d.a = 1 # this works, so slots inherit properly >>> d.b = 2 >>> d.c = 3 # this doesnt work,

Re: Open existing Word document, modify and save.

2008-01-15 Thread Mike Driscoll
On Jan 15, 12:01 pm, gsal <[EMAIL PROTECTED]> wrote: > New to Python and new to Win32. Help please. > > O.k., so this might seem like one of those "can you do my homework" > kind of postings, except that is not homework, it is officework. > > I have been reading the Core Python book and I am really

Re: SyntaxError: 'import *' not allowed with 'from .'

2008-01-15 Thread Steven Bethard
George Sakkis wrote: > Unless I missed it, PEP 328 doesn't mention anything about this. > What's the reason for not allowing "from .relative.module import *' ? Generally, there's a move away from all "import *" versions these days. For example, Python 3.0 removes the ability to use "import *" wit

Re: Python in IIS + WSGI

2008-01-15 Thread Phillip Sitbon
Looks like Sourceforge had a problem with the file upload, causing it to be empty - I just fixed it. http://pyisapie.sourceforge.net/ > On Jan 11, 4:37 pm, Phillip Sitbon <[EMAIL PROTECTED]> wrote: > > > Recently (finally) updated the PyISAPIe project. Version 1.0.4 > > includes WSGI support (tes

Re: Benchmark [was Re: common problem - elegant solution sought]

2008-01-15 Thread Helmut Jarausch
Paul Rubin wrote: > Helmut Jarausch <[EMAIL PROTECTED]> writes: >> def del_by_key(L,key) : >>for pos, (k,d) in enumerate(L): >> if k == key : >>del L[pos] >>break > > This looks very dangerous, mutating L while iterating over it. No, as Bruno Desthuilliers has pointed ou

Re: super, decorators and gettattribute

2008-01-15 Thread Helmut Jarausch
Michele Simionato wrote: > I really need to publish this one day or another, since these > questions > about super keeps coming out: > > http://www.phyast.pitt.edu/~micheles/python/super.html Unfortunately the links [2], [3] and [4] are not given, Helmut. -- Helmut Jarausch Lehrstuhl fuer N

Re: Data mapper - need to map an dictionary of values to a model

2008-01-15 Thread Luke
On Jan 15, 1:53 am, [EMAIL PROTECTED] wrote: > Luke: > > >What design patterns would you use here?< > > What about "generator (scanner) with parameters"? :-) > > Bye, > bearophile I'm not familiar with this pattern. I will search around, but if you have any links or you would like to elaborate, th

Re: Benchmark [was Re: common problem - elegant solution sought]

2008-01-15 Thread [EMAIL PROTECTED]
On Jan 15, 6:18 pm, Paul Rubin wrote: > Helmut Jarausch <[EMAIL PROTECTED]> writes: > > def del_by_key(L,key) : > >for pos, (k,d) in enumerate(L): > > if k == key : > >del L[pos] > >break > > This looks very dangerous, mutating L while iterating

RE: "env" parameter to "popen" won't accept Unicode on Windows -minor Unicode bug

2008-01-15 Thread Bjoern Schliessmann
Brian Smith wrote: > popen() knows that it is running on Windows, and it knows what > encoding Windows needs for its environment (it's either UCS2 or > UTF-16 for most Windows APIs). At least when it receives a unicode > string, it has enough information to apply the conversion > automatically, and

Re: Data mapper - need to map an dictionary of values to a model

2008-01-15 Thread bearophileHUGS
Luke: > I'm not familiar with this pattern. I will search around, but if you > have any links or you would like to elaborate, that would be > wonderful. :) It's not a pattern, it's a little thing: def line_filter(filein, params): for line in filein: if good(line, params): yield extrac

Re: Perl Template Toolkit: Now in spicy new Python flavor

2008-01-15 Thread SJ Carter
Congrats. This will no doubt prove valuable to any Python programmer. -- http://mail.python.org/mailman/listinfo/python-list

UTF-8 in basic CGI mode

2008-01-15 Thread coldpizza
Hi, I have a basic Python CGI web form that shows data from a SQLite3 database. It runs under the built-in CGIWebserver which looks like this: [code] import SimpleHTTPServer import SocketServer SocketServer.TCPServer(("", 80),SimpleHTTPServer.SimpleHTTPRequestHandler).serve_forever() [/code] The

Re: MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread washakie
Thank you... after: %yum install mysql* I was able to build and install mysql-python -- View this message in context: http://www.nabble.com/MySQL-python-1.2.2-install-with-no-mysql-tp14836669p14845579.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://ma

Re: Perl Template Toolkit: Now in spicy new Python flavor

2008-01-15 Thread Joshua Kugler
[EMAIL PROTECTED] wrote: > I'd like to inform the Python community that the powerful and popular > Template Toolkit system, previously available only in its original > Perl implementation, is now also available in a beta Python > implementation: > > http://tt2.org/python/index.html > > I created

Re: "env" parameter to "popen" won't accept Unicode on Windows - minor Unicode bug

2008-01-15 Thread John Nagle
Diez B. Roggisch wrote: > John Nagle wrote: > >> Benjamin wrote: >>> On Jan 14, 6:26 pm, Bjoern Schliessmann >> [EMAIL PROTECTED]> wrote: John Nagle wrote: > It turns out that the strings in the "env" parameter have to be > ASCII, not Unicode, even though Windows fully supports Unicod

Re: A question about event handlers with wxPython

2008-01-15 Thread Erik Lind
That all looks cool. I will experiment more. I'm a bit slow on this as only two weeks old so far. Thanks for the patience -- http://mail.python.org/mailman/listinfo/python-list

searching an XML doc

2008-01-15 Thread Gowri
Hello, I've been reading about ElementTreee and ElementPath so I could use them to find the right elements in the DOM. Unfortunately neither of these seem to offer XPath like capabilities where I can find elements based on tag, attribute values etc. Are there any libraries which can give me XPath

Re: A question about event handlers with wxPython

2008-01-15 Thread Mike Driscoll
On Jan 15, 2:20 pm, "Erik Lind" <[EMAIL PROTECTED]> wrote: > That all looks cool. I will experiment more. I'm a bit slow on this as only > two weeks old so far. > > Thanks for the patience No problem. I'm pretty slow with some toolkits too...such as SQLAlchemy. Ugh. Mike -- http://mail.python.or

UTF-8 in basic CGI mode

2008-01-15 Thread coldpizza
Hi, I have a basic Python CGI web form that shows data from a SQLite3 database. It runs under the built-in CGIWebserver which looks something like this: [code] from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler HTTPServer("8000", CGIHTTPRequestHandler).serve_fo

Compile with GLib-1.2 instead of 2.4

2008-01-15 Thread Brandon Perry
Hi, I am having to compile a standalone python because the webserver I use doesn't allow access to /usr/lib/python. I tried compiling on my lappy and uploading it, but the webserver does not have GLib-2.4. What arguments would I have to include in order for it to compile with GLib-1.2 instead of/an

Re: super, decorators and gettattribute

2008-01-15 Thread Richard Szopa
On Jan 15, 8:06 pm, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > Unfortunately the links [2], [3] and [4] are not given, Luckily, there's Google :) [2] Article about MRO: http://www.python.org/download/releases/2.3/mro/ [3] Descriptor HowTo: http://users.rcn.com/python/download/Descriptor.htm [4

Re: ElementTree and namespaces in the header only

2008-01-15 Thread Torsten Bronger
Hallöchen! Fredrik Lundh writes: > Peter Bengtsson wrote: > >> root = Element('feed', xmlns='http://www.w3.org/2005/Atom') >> root.set('xmlns:se', NS_URL) >> entry = SubElement(root, 'entry') >> SubElement(root, 'title').text = 'Title' >> SubElement(entry, SEN('category')).text = 'Category' > >>

Running Multiple Versions

2008-01-15 Thread noel
Hi, We are windows shop with some unix servers as well. We run 2.4.1 and want to begin migrating to 2.5.1. I am looking for information dealing with having more than one version of python on a server at one time. I believe this is called side-by-side and all that is needed to select a version on

Re: Compile with GLib-1.2 instead of 2.4

2008-01-15 Thread Brandon Perry
Sorry, I know what arg to use with ./configure. With --with-libc=STRING, do I put the version I want, or the path to my GLib 1.2 files? On Tue, 2008-01-15 at 14:53 -0600, Brandon Perry wrote: > Hi, I am having to compile a standalone python because the webserver I > use doesn't allow access to /usr

Re: "env" parameter to "popen" won't accept Unicode on Windows -minor Unicode bug

2008-01-15 Thread John Nagle
Diez B. Roggisch wrote: > Brian Smith wrote: > >> Diez B. Roggisch wrote: >>> Sure thing, python will just magically convert unicode to the >>> encoding the program YOU invoke will expect. Right after we >>> introduced the >>> >>> solve_my_problem() >>> >>> built-in-function. Any other wishes? >>

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Steven D'Aprano
On Tue, 15 Jan 2008 11:25:25 -0500, Colin J. Williams wrote: > I'm sorry, there appears to be a bug: # tSet.py > import sets > s1= sets.Set([1, 2, 3]) > s1.union_update([3, 4,5]) > print(s1) > s2= sets.Set([6, 7, 8]) > s1 |+ s2 # This fails: > exceptions.TypeError: bad operand type for un

Re: Running Multiple Versions

2008-01-15 Thread Moises Alberto Lindo Gutarra
that is correct, you can work several version of python in same machine. When you execute some script you only need redirect %PATH% and %PYTHONPATH% 2008/1/15, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > Hi, > > We are windows shop with some unix servers as well. We run 2.4.1 and > want to begin migr

Re: Perl Template Toolkit: Now in spicy new Python flavor

2008-01-15 Thread George Sakkis
On Jan 15, 3:15 pm, Joshua Kugler <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I'd like to inform the Python community that the powerful and popular > > Template Toolkit system, previously available only in its original > > Perl implementation, is now also available in a beta Python >

  1   2   >