Re: survey

2005-03-12 Thread beliavsky
[EMAIL PROTECTED] wrote: > > The Language Shootout at http://shootout.alioth.debian.org/ has code > > samples in many languages, both interpreted and compiled, including > the > > ones you mentioned. Don't trust the lines-of-code statistics, though > -- > > the LOC measure is wrongly shown as zero

Re: a program to delete duplicate files

2005-03-12 Thread Patrick Useldinger
John Machin wrote: Oh yeah, "the computer said so, it must be correct". Even with your algorithm, I would be investigating cases where files were duplicates but there was nothing in the names or paths that suggested how that might have come about. Of course, but it's good to know that the computer

Re: is there a problem on this simple code

2005-03-12 Thread jrlen balane
this is not working, what is wrong with this code?? what it "should" do is find first the command "70" then read the remaining 9 bytes once the command was found: rx_data1=0 while (rx_data1 != 0x46): rx_data1 = ser.read(1) (rx_command) = unpack('1B', rx_data1) rc_data2=ser.read(9) (rx_ms

Re: Turning String into Numerical Equation

2005-03-12 Thread Michael Spencer
Brian Kazian wrote: Thanks for the help, I didn't even think of that. I'm guessing there's no easy way to handle exponents or logarithmic functions? I will be running into these two types as well. "Artie Gold" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] eval will handle exponent

Re: psycopg authentication

2005-03-12 Thread [EMAIL PROTECTED]
Thanks for the reply. I figured it out, the problem was with my postgresql configuration. the following seemed to do the trick. localall md5 host all 0.0.0.0 0.0.0.0 md5 -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a problem on this simple code

2005-03-12 Thread jrlen balane
the hardware is a school project that uses a microcontroller for "light dimming" the message command "67" will tell the microcontroller (PIC16F877) to do a command (to control the intensity of a lamp) the message command "70" should tell the GUI that the microcontroller has started transmitting. th

Re: Itertools wishlists

2005-03-12 Thread Raymond Hettinger
[Ville Vainio] > >For quick-and-dirty stuff, it's often convenient to flatten a sequence > >(which perl does, surprise surprise, by default): . . . > >but something like this would be handy in itertools as well. > > > >It seems trivial, but I managed to screw up several times when trying > >to pro

Re: psycopg authentication

2005-03-12 Thread [EMAIL PROTECTED]
I did, the pg_hba conf is a big tricky to me. I've tried the following things.. the commented out lines I also tried. #localall ident sameuser localall md5 host all 127.0.0.1 255

Why is lower() deprecated and how should I replace it?

2005-03-12 Thread gf gf
I read that lower() is deprecated. Unfortunately, I can't find the preferred way of lowercasing a string. What is it? Thanks PS Please cc me on all responses. __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://small

Re: Overloading the "and" operator

2005-03-12 Thread Robert Kern
Fredrik Bertilsson wrote: I am trying to overload the "and" operatior, but my __and__ method is never called. __and__ overloads the "&" operator. The "and" keyword cannot be overloaded. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allo

Re: Turning String into Numerical Equation

2005-03-12 Thread Robert Kern
Artie Gold wrote: [BTW -- cultural question: Do we top-post here?] Please don't. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list

Re: bsddb support for berkeley db 4.3?

2005-03-12 Thread janeaustine50
Martin v. Löwis wrote: > [EMAIL PROTECTED] wrote: > > It doesn't seem like the python 2.4(and the recent 2.4.1) support > > berkeley db 4.3. > > What makes you say that? It builds fine for me. Oh, it doesn't work with 2.4(I tried this one) but with 2.4.1 seemingly. In the setup.py from 2.4 there

Re: is there a problem on this simple code

2005-03-12 Thread Bengt Richter
On 12 Mar 2005 20:12:19 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: > >Bengt Richter wrote: >> On 12 Mar 2005 17:35:50 -0800, "John Machin" <[EMAIL PROTECTED]> >wrote: >> >> > >> >[EMAIL PROTECTED] wrote: >> >> >> >> What actually gets transmitted is "C\x01\x02\x10'\x83". >> > >> >No, that's r

Re: dinamically altering a function

2005-03-12 Thread Bengt Richter
On Sat, 12 Mar 2005 23:09:58 -0400, vegetax <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: [...] >> Please pretend things worked the way you want, and post an example. Maybe >> we can make it work. >> >> Regards, >> Bengt Richter > >Ok , the complete use case is : > >def fun1(a,b,obj = None): >

Re: Turning String into Numerical Equation

2005-03-12 Thread Artie Gold
Brian Kazian wrote: Thanks for the help, I didn't even think of that. I'm guessing there's no easy way to handle exponents or logarithmic functions? I will be running into these two types as well. Well, consider: import math eval("log(pow(x,2)*pow(y,3),2)",{'pow':math.pow,'log':math.log},{'x':1,'

Re: Huge performance gain compared to perl while loading a text file in a list ...!?

2005-03-12 Thread Paul Rubin
"Marc H." <[EMAIL PROTECTED]> writes: > I'm fairly new to python, and don't know much of its inner working so > I wonder if someone could explain to me why it is so much faster in > python to open a file and load it in a list/array ? My guess is readlines() in Python is separating on newlines whil

Re: try / except not worknig correctly

2005-03-12 Thread Pete
'@'.join([..join(['fred','dixon']),..join(['gmail','com'])]) wrote: 1) the tutor list is really slow. but thanks. 2) Thanks Brain, i was missing the string bit. the code i posted (opps) was not exactly where i was having problems, it just looked like it. also thanks for the 'in' test, that will com

Huge performance gain compared to perl while loading a text file in a list ...!?

2005-03-12 Thread Marc H.
Hello, I recently converted one of my perl scripts to python. What the script does is simply search a lot of big mail files (~40MB) to retrieve specific emails. I simply converted the script line by line to python, keeping the algorithms & functions as they were in perl (no optimization). The purp

Overloading the "and" operator

2005-03-12 Thread Fredrik Bertilsson
I am trying to overload the "and" operatior, but my __and__ method is never called. The code look like this: class Filter: column = "" operator = "" value = "" def __init__(self, col, op, val): self.column = col self.operator = op

Beware complexity

2005-03-12 Thread Philip Smith
I wonder if anyone has any thoughts not on where Python should go but where it should stop? One of the faults with langauges like C++ was that so many new features/constructs were added that it became a nightmare right from the design stage of a piece of software deciding which of the almost in

Re: is there a problem on this simple code

2005-03-12 Thread [EMAIL PROTECTED]
John Machin wrote: > [EMAIL PROTECTED] wrote: > > > > What actually gets transmitted is "C\x01\x02\x10'\x83". > > No, that's repr(What actually gets transmitted) Drat, I always get burned by that. > > > That's 18 bytes. Is the command supposed to be the ASCII > > characters \x01 or a single byte

Beware complexity

2005-03-12 Thread Philip Smith
-- http://mail.python.org/mailman/listinfo/python-list

Re: Using reverse iteration to clean up a list

2005-03-12 Thread Luis M. Gonzalez
Well, I'm not sure if this is what you want, but you could use a dictionary: >>> d={} >>> for i,e in L: if d.has_key(i): d[i] += e else: d[i] = e >>> d {'A': 500, 'B': 200} >>> -- http://mail.python.org/mailman/listinfo/python-lis

Re: Turning String into Numerical Equation

2005-03-12 Thread Brian Kazian
Thanks for the help, I didn't even think of that. I'm guessing there's no easy way to handle exponents or logarithmic functions? I will be running into these two types as well. "Artie Gold" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Brian Kazian wrote: >> Here's my problem, a

Re: Why does this not work?

2005-03-12 Thread Gensek
I fixed it already, as I said. The problem had nothing to do with wxPython. I just used my own functions in the wrong way. -- http://mail.python.org/mailman/listinfo/python-list

Re: Add Properties to Instances?

2005-03-12 Thread Bengt Richter
On Sun, 13 Mar 2005 03:18:51 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote: >On 12 Mar 2005 09:48:42 -0800, "Martin Miller" <[EMAIL PROTECTED]> wrote: > >>I'm trying to create some read-only instance specific properties, but >>the following attempt didn't work: >> >>> class Foobar(object): >>>

Re: Using reverse iteration to clean up a list

2005-03-12 Thread John Machin
Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > I have list of lists of the following form > > > > L=[['A', 100], ['B', 300], ['A', 400], ['B', -100]] > > > > I want to aggregate these lists, i.e. to reduce L to > > L=[['A', 500], ['B', 200]] #500 = 100+400, 200=300-100 > > How about: > > v

Re: is there a problem on this simple code

2005-03-12 Thread John Machin
Bengt Richter wrote: > On 12 Mar 2005 17:35:50 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: > > > > >[EMAIL PROTECTED] wrote: > >> > >> What actually gets transmitted is "C\x01\x02\x10'\x83". > > > >No, that's repr(What actually gets transmitted) > > If so, that's 6 bytes, not 18: > > >>> "C\x

Re: survey

2005-03-12 Thread D H
Peter Hansen wrote: Dave Zhu wrote: Hello All, Is there any survey on scripting languages? I would like to get information on several scripting languages including Python, Perl, Ruby, Tcl, etc. What kind of information? ... See the other responses to his question. -- http://mail.python.org/mailman

Re: Using reverse iteration to clean up a list

2005-03-12 Thread Paul Rubin
[EMAIL PROTECTED] writes: > I have list of lists of the following form > > L=[['A', 100], ['B', 300], ['A', 400], ['B', -100]] > > I want to aggregate these lists, i.e. to reduce L to > L=[['A', 500], ['B', 200]] #500 = 100+400, 200=300-100 How about: v = {} for name,val in L: v[n

Re: Why does this not work?

2005-03-12 Thread D H
Gensek wrote: Thanks, guys, it works now. I couldn't have done it without your generous help. Ask on the wxpython or python-tutor list instead of this one. You'll get better help than there as you've already found out. The only thing I'd agree with is what Michael Hoffman said about posting a sn

Using reverse iteration to clean up a list

2005-03-12 Thread tkpmep
I have list of lists of the following form L=[['A', 100], ['B', 300], ['A', 400], ['B', -100]] I want to aggregate these lists, i.e. to reduce L to L=[['A', 500], ['B', 200]] #500 = 100+400, 200=300-100 Here's how I have done it: L.sort() for i in range(len(L),0,-1): if L[i-1][0]=L[i][0]:

Re: Turning String into Numerical Equation

2005-03-12 Thread Artie Gold
Brian Kazian wrote: Here's my problem, and hopefully someone can help me figure out if there is a good way to do this. I am writing a program that allows the user to enter an equation in a text field using pre-existing variables. They then enter numerical values for these variables, or can tel

Turning String into Numerical Equation

2005-03-12 Thread Brian Kazian
Here's my problem, and hopefully someone can help me figure out if there is a good way to do this. I am writing a program that allows the user to enter an equation in a text field using pre-existing variables. They then enter numerical values for these variables, or can tell the program to ran

Re: is there a problem on this simple code

2005-03-12 Thread Bengt Richter
On 12 Mar 2005 17:35:50 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: > >[EMAIL PROTECTED] wrote: >> >> What actually gets transmitted is "C\x01\x02\x10'\x83". > >No, that's repr(What actually gets transmitted) If so, that's 6 bytes, not 18: >>> "C\x01\x02\x10'\x83" "C\x01\x02\x10'\x83" >>>

Re: Add Properties to Instances?

2005-03-12 Thread Bengt Richter
On 12 Mar 2005 09:48:42 -0800, "Martin Miller" <[EMAIL PROTECTED]> wrote: >I'm trying to create some read-only instance specific properties, but >the following attempt didn't work: > >> class Foobar(object): >> pass >> >> foobar = Foobar() >> foobar.x = property(fget=lambda: 42) >> >> print "f

Re: dinamically altering a function

2005-03-12 Thread vegetax
Bengt Richter wrote: > On Sat, 12 Mar 2005 18:19:36 -0400, vegetax <[EMAIL PROTECTED]> wrote: > >>Steven Bethard wrote: >> >>> vegetax wrote: I i need a decorator that adds a local variable in the function it decorates, probably related with nested scopes, for example: def de

Re: Why does this not work?

2005-03-12 Thread Gensek
Thanks, guys, it works now. I couldn't have done it without your generous help. -- http://mail.python.org/mailman/listinfo/python-list

Re: dinamically altering a function

2005-03-12 Thread vegetax
thanks , i guess the best option is a callable class which builds the functions with the common code. Once again,we REALLY need a patterns book for python. =/ -- http://mail.python.org/mailman/listinfo/python-list

Re: dinamically altering a function

2005-03-12 Thread Bengt Richter
On Sat, 12 Mar 2005 18:19:36 -0400, vegetax <[EMAIL PROTECTED]> wrote: >Steven Bethard wrote: > >> vegetax wrote: >>> I i need a decorator that adds a local variable in the function it >>> decorates, probably related with nested scopes, for example: >>> >>> def dec(func): >>> def wrapper(obj

Re: is there a problem on this simple code

2005-03-12 Thread John Machin
[EMAIL PROTECTED] wrote: > > What actually gets transmitted is "C\x01\x02\x10'\x83". No, that's repr(What actually gets transmitted) > That's 18 bytes. Is the command supposed to be the ASCII > characters \x01 or a single byte whose value is 1? For a start, according to the OP's code, the comma

Re: is there a problem on this simple code

2005-03-12 Thread John Machin
jrlen balane *TOP-POSTED*: > On 12 Mar 2005 07:39:31 -0800, Harlin Seritt <[EMAIL PROTECTED]> wrote: > > hah, this code is anything but simple... > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > @sir harlin > so you are saying that there is nothing wrong in this simple progr

Re: try / except not worknig correctly

2005-03-12 Thread '@'.join([..join(['fred', 'dixon']), ..join(['gmail', 'com'])])
1) the tutor list is really slow. but thanks. 2) Thanks Brain, i was missing the string bit. the code i posted (opps) was not exactly where i was having problems, it just looked like it. also thanks for the 'in' test, that will come in handy. i am using chain because i need to do something differ

Re: try / except not worknig correctly

2005-03-12 Thread Brian van den Broek
'@'.join([..join(['fred', 'dixon']), ..join(['gmail', 'com'])]) said unto the world upon 2005-03-12 19:20: the code below will not execute the except section when i enter a number. what am i missing ? # .while 1: . print 'Pump Protection ? ' . #line 133 .

Re: try / except not worknig correctly

2005-03-12 Thread Robert Kern
'@'.join([..join(['fred','dixon']),..join(['gmail','com'])]) wrote: the code below will not execute the except section when i enter a number. what am i missing ? Something that will actually raise ValueError. It looks like you could use the help of the Python Tutor mailing list. http://www.python

Re: is there a problem on this simple code

2005-03-12 Thread [EMAIL PROTECTED]
jrlen balane wrote: > basically what the code does is transmit data to a hardware and then > receive data that the hardware will transmit. > > import serial > import string > import time > from struct import * > > > ser = serial.Serial() > > ser.baudrate = 9600 > ser.port = 0 > ser > ser.close() >

Re: Tkinter WEIRDNESS or Python WEIRDNESS?

2005-03-12 Thread Brian van den Broek
steve said unto the world upon 2005-03-12 18:46: Brian van den Broek <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... steve said unto the world upon 2005-03-12 00:06: In a nutshell, my problem is that I am getting this runtime error, and I have no clue why. Please bear in mind its

pygtk help

2005-03-12 Thread Johan
[x-posted to PyGTk mailing list as well] Hello! I'm trying to figure out how to use PYGTK to implement a rudimentary UI: I want to have an Image as the background, and then be able to put buttons (eventually icons, but buttons for now) The PyGTK FAQ (pygtk.org) has some suggestions, but they h

try / except not worknig correctly

2005-03-12 Thread '@'.join([..join(['fred', 'dixon']), ..join(['gmail', 'com'])])
the code below will not execute the except section when i enter a number. what am i missing ? # .while 1: . print 'Pump Protection ? ' . #line 133 .try: .myInput = raw_input('A B C D E F G H I J K L ? ') .myInput = string.upper(myInpu

Re: bsddb support for berkeley db 4.3?

2005-03-12 Thread Andrew MacIntyre
[EMAIL PROTECTED] wrote: It doesn't seem like the python 2.4(and the recent 2.4.1) support berkeley db 4.3. (4.3 fixes some deadlock bugs I occasionally encounter using 4.2.) bsddb3(at pybsddb.sf.net) already supports 4.3 since last December(but doesn't explicitly support win32 -- see the assert st

Re: Tkinter WEIRDNESS or Python WEIRDNESS?

2005-03-12 Thread steve
Brian van den Broek <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > steve said unto the world upon 2005-03-12 00:06: > > In a nutshell, my problem is that I am getting this runtime error, and > > I have no clue why. Please bear in mind its my first python program: > > > > "loc

Re: PythonWin

2005-03-12 Thread Neil Hodgson
Thomas Philips: > However, if I run it in ActivePython's PythonWin, a small message > box pops up, with hardly any space to diplay msg and a smallish > space into which I can type my answer. How can I force PythonWin > to get its input from the execution window You will have to implement t

Re: a program to delete duplicate files

2005-03-12 Thread John Machin
Patrick Useldinger wrote: > John Machin wrote: > > > Maybe I was wrong: lawyers are noted for irritating precision. You > > meant to say in your own defence: "If there are *any* number (n >= 2) > > of identical hashes, you'd still need to *RE*-read and *compare* ...". > > Right, that is what I mea

Re: Confused with classmethods

2005-03-12 Thread Bengt Richter
On Fri, 11 Mar 2005 14:04:26 -0800, jfj <[EMAIL PROTECTED]> wrote: >Hi. > >Suppose this: > > > >def foo (x): > print x > >f = classmethod (foo) > >class A: pass > >a=A() >a.f = f > >a.f() ># TypeError: 'classmethod' object is not callable! > >### > >

Re: PythonWin

2005-03-12 Thread Colin J. Williams
[EMAIL PROTECTED] wrote: I have a Python program that collects user input using msg = "Enter the full path and name of the file to be processed: " answer = raw_input(msg) If I run it in IDLE, the question is splashed across the execution window, and if it is long, simply wraps to the next line. Mos

Re: dinamically altering a function

2005-03-12 Thread Jeremy Bowers
> What i want is to declare in the decorator some code that is common to all > these functions, so the functions assume that the decorator will be there > and wont need to duplicate the code provided by it, and the functions are > not known ahead of time, it has to be dynamic. This sounds like a c

Re: i18n: looking for expertise

2005-03-12 Thread klappnase
"Martin v. Löwis" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > klappnase wrote: > > enc = locale.nl_langinfo(locale.CODESET).lower() > > Notice that this may fail on systems which don't provide the > CODESET information. Recent Linux systems (glibc 6) have it, > and so d

Re: dinamically altering a function

2005-03-12 Thread Steven Bethard
vegetax wrote: Steven Bethard wrote: Have you considered using OO here? You might find that this is more easily written as: py> class Object(object): ... pass ... py> class fun(object): ... def __new__(self, *args): ... if len(args) == 2: ... obj, b = args ... e

Re: csv module and unicode, when or workaround?

2005-03-12 Thread John Machin
Chris wrote: > hi, > thanks for all replies, I try if I can at least get the work done. > > I guess my problem mainly was the rather mindflexing (at least for me) > coding/decoding of strings... > > But I guess it would be really helpful to put the UnicodeReader/Writer > in the docs UNFORTUNATELY

Re: Why does this not work?

2005-03-12 Thread Michael Hoffman
Gensek wrote: PingGUI is a program that nobody but me knows anything about. If I wanted help from people who are experts on it, I'd get nothing at all. It appears as if that's the situation anyway, at least so far. But you want wxPython help so you should ask for that instead. Something like "Why d

Re: error sending path to Win OS

2005-03-12 Thread [EMAIL PROTECTED]
To generate path names take a look at os.path.join(see http://docs.python.org/lib/module-os.path.html) -- http://mail.python.org/mailman/listinfo/python-list

Re: error sending path to Win OS

2005-03-12 Thread Michael Hoffman
Earl Eiland wrote: os.path.getsize(Inputdirectory + '\\' + Filename) works, but os.path.getsize(Inputdirectory + '\\' + Filename.split('.') + '.ext') Fails reporting "no such file or directory InputDirectory\\Filename.ext". No, that should be a TypeError. This will be easier if you copy and paste y

Re: dinamically altering a function

2005-03-12 Thread vegetax
Steven Bethard wrote: > vegetax wrote: >> I i need a decorator that adds a local variable in the function it >> decorates, probably related with nested scopes, for example: >> >> def dec(func): >> def wrapper(obj = None): >> if not obj : obj = Obj() >> >> return func() >> >>

Re: blocking a program until a non-Python process terminates

2005-03-12 Thread Michael Hoffman
Earl Eiland wrote: I'm running an .exe in Python, using subProcess.Popen. The executable writes data to a file I process later on in the program. Unfortunately, my program returns the error "no such file...". How do I block execution until the external executable terminates? Either: 1) returncod

Re: is there a problem on this simple code

2005-03-12 Thread jrlen balane
@sir harlin so you are saying that there is nothing wrong in this simple program. On 12 Mar 2005 07:39:31 -0800, Harlin Seritt <[EMAIL PROTECTED]> wrote: > hah, this code is anything but simple... > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/l

Re: dinamically altering a function

2005-03-12 Thread Steven Bethard
vegetax wrote: I i need a decorator that adds a local variable in the function it decorates, probably related with nested scopes, for example: def dec(func): def wrapper(obj = None): if not obj : obj = Obj() return func() return wrapper() @dec() def fun(b): obj.desc = 'marke

Re: a program to delete duplicate files

2005-03-12 Thread Patrick Useldinger
John Machin wrote: Maybe I was wrong: lawyers are noted for irritating precision. You meant to say in your own defence: "If there are *any* number (n >= 2) of identical hashes, you'd still need to *RE*-read and *compare* ...". Right, that is what I meant. 2. As others have explained, with a decent

Re: head for grouped data - looking for best practice

2005-03-12 Thread Harald Massa
Steve, > Why don't you just pass a slice to itemgetter? py> for key, bereich in groupby(eingabe, itemgetter(slice(0, 2))): WHOW, that is great! that makes it really simple, just have to structure the SQL to make a real "cut first, serve first" structure. Thanks to all who helped! also the "f

Re: a program to delete duplicate files

2005-03-12 Thread John Machin
Patrick Useldinger wrote: > John Machin wrote: > > > Just look at the efficiency of processing N files of the same size S, > > where they differ after d bytes: [If they don't differ, d = S] > > > > PU: O(Nd) reading time, O(Nd) data comparison time [Actually (N-1)d > > which is important for small

error sending path to Win OS

2005-03-12 Thread Earl Eiland
os.path.getsize(Inputdirectory + '\\' + Filename) works, but os.path.getsize(Inputdirectory + '\\' + Filename.split('.') + '.ext') Fails reporting "no such file or directory InputDirectory\\Filename.ext". os.path.getsize(Inputdirectory + r'\' + Filename.split('.') + '.ext') generates a syntax error

Re: newbie: dictionary - howto get key value

2005-03-12 Thread Bengt Richter
On Thu, 10 Mar 2005 18:56:41 +0100, bruno modulix <[EMAIL PROTECTED]> wrote: >G. Völkl wrote: >> Hello, >> >> I use a dictionary: >> >> phone = {'mike':10,'sue':8,'john':3} >> >> phone['mike'] --> 10 >> >> I want to know who has number 3? >> 3 --> 'john' > >Note that you can have many keys

dinamically altering a function

2005-03-12 Thread vegetax
I i need a decorator that adds a local variable in the function it decorates, probably related with nested scopes, for example: def dec(func): def wrapper(obj = None): if not obj : obj = Obj() return func() return wrapper() @dec() def fun(b): obj.desc = 'marked' obj.

Re: Safe Local XMLRPC

2005-03-12 Thread Stephen Waterbury
Diez B. Roggisch wrote: ... corba is 10-100 times faster over the network than soap/xmlrpc. ... I'm not challenging these statistics (because I don't know), but I would be interested in the source. Are you referring to the results of an actual benchmark, or something more subjective? Steve -- http

Re: PEP 309 (Partial Function Application) Idea

2005-03-12 Thread Steven Bethard
Chris Perkins wrote: [snip implementation] While I think that func(x, ...) is more readable than partial(func, x), I'm not sure that I would use either of them often enough to warrant special syntax. Interesting. Thought it might be worth listing a few of the current places people use lambdas (an

Re: Add Properties to Instances?

2005-03-12 Thread Martin Miller
So far a couple of people have asked: > What's the situation in which you think you want different properties > for different instances of the same class? Fair enough -- here goes: Essentially what I'm doing is implementing (yes, yet another ;-) 'enumeration' class using an an approach which invo

Re: Installation Guide

2005-03-12 Thread Skip Montanaro
Kevin> I'm in critical need to install Python Imaging Library on my Kevin> linux/cpanel server. I'm not very experienced and I almost always Kevin> have to use instalation guides. Take a look at the BUILDME and README files in the top-level directory. Skip -- http://mail.python.org/

Re: Why does this not work?

2005-03-12 Thread Gensek
PingGUI is a program that nobody but me knows anything about. If I wanted help from people who are experts on it, I'd get nothing at all. -- http://mail.python.org/mailman/listinfo/python-list

blocking a program until a non-Python process terminates

2005-03-12 Thread Earl Eiland
I'm running an .exe in Python, using subProcess.Popen. The executable writes data to a file I process later on in the program. Unfortunately, my program returns the error "no such file...". How do I block execution until the external executable terminates? Earl -- http://mail.python.org/mailm

Re: pre-PEP: Print Without Intervening Space

2005-03-12 Thread Marcin Ciura
Bengt Richter wrote: BTW, what makes you think any self-respecting "scientist" wouldn't be insulted by the idea of your spoon-feeding them a dumbed-down programming equivalent of "See Spot run"? Am I right thinking that your dream 3 R's curriculum starts with "Stately, plump Buck Mulligan" and Póly

wishlist item: itertools.partition (WAS: Wishlist item: itertools.flatten)

2005-03-12 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > window / cons / fencepost / slice functions: +1 > > (with a flag to say if you want to truncate or pad incomplete tuples > at end of input sequence. > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303279 > http://aspn.activestate.com/ASPN/Cookbook/Python/Recip

Installation Guide

2005-03-12 Thread Online Support
Hello,   I'm in critical need to install Python Imaging Library on my linux/cpanel server. I'm not very experienced and I almost always have to use instalation guides. I have downloaded the software, unzipped it, and now I think I just need to install it somehow. Are there files that need to be

Re: Safe Local XMLRPC

2005-03-12 Thread Diez B. Roggisch
> Hmm. On inspection, pyro seems to be really heavy, what with its > requirement of a pyro-nameserver, and using TCP as the transport. The nameserver is purely optional. Regarding the overhead of transport - well, I didn't check pyro on that, but corba is 10-100 times faster over the network than

Re: Can't seem to insert rows into a MySQL table

2005-03-12 Thread deelan
deelan wrote: which version of MySQLdb are you running? versions 1.1.6 and below gained a connection.autocommit) method set by default ehm, 1.1.6 and *above*, of course. :) -- "Però è bello sapere che, di questi tempi spietati, almeno un mistero sopravvive: l'età di Afef Jnifen." -- dagospia.com -

Thank you. New question concerning text encoding

2005-03-12 Thread grumfish
Patrick Useldinger wrote: Just a guess "in the dark" (I don't use MySQL): is "commit" implicit, or do you have to add it yourself? Thank you. Inserts work fine now. Another question. I'm trying to insert Japanese text into the table. I created the database using 'CHARACTER SET UTF8'. In Python I

Re: Can't seem to insert rows into a MySQL table

2005-03-12 Thread deelan
grumfish wrote: I'm trying to add a row to a MySQL table using insert. Here is the code: connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", db="japanese") cursor = connection.cursor() cursor.execute("INSERT INTO edict (kanji, kana, meaning) VALUES (%s, %s, %s)", ("a", "b", "

Re: PEP 309 (Partial Function Application) Idea

2005-03-12 Thread Chris Perkins
>Scott David Daniels wrote: >>>Chris Perkins wrote: Random idea of the day: How about having syntax support for currying/partial function application, like this: func(..., a, b) func(a, ..., b) func(a, b, ...) That is: 1) Make an Ellipsis literal legal syntax in an

Re: Can't seem to insert rows into a MySQL table

2005-03-12 Thread Stephen Prinster
grumfish wrote: The rowcount of the cursor is 1 after the execute is 1 and the table's auto_increment value is increased for each insert done. If the auto_increment is increased, then it seems like the row was inserted. Are you sure the problem is not with your SELECT attempt? Just a guess, b

SimpleXMLServer meets inetd

2005-03-12 Thread Marek Kubica
Hi! I was thinking about connecting SimpleXMLRPCServer with inetd.. but I haven't been able to replace the socket by sys.stdin and sys.stdout. Maybe socket.fromfd(sys.stdin.fileno()) could help me, but I can't get it to work, I always get connection refused. Any ideas? greets, Marek -- http://m

Re: Safe Local XMLRPC

2005-03-12 Thread Michael Urman
Thanks for your time everyone; I got it XMLRPC working over unix domain stream sockets. In case people are interested, here's the pieces I put together. I'm sure they throw away a little flexibility, but they work for my purpose. Any pointers to make the code more robust, or do less total overridin

Re: Wishlist item: itertools.flatten

2005-03-12 Thread gene . tani
window / cons / fencepost / slice functions: +1 (with a flag to say if you want to truncate or pad incomplete tuples at end of input sequence. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303279 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303060 http://aspn.activestate.com/

Re: Debugging Python Scripts inside other processes

2005-03-12 Thread A. Klingenstein
Robin Becker wrote: A. Klingenstein wrote: I embedded Python in a Windows C++ program. Now I want to debug my embedded scripts which of course won't run in any IDE process. Commercial IDEs like WingIDE can attach to external processes by importing a module in the scripts. Is there a debugger cap

Building Python 2.4 with icc and processor-specific optimizations

2005-03-12 Thread Michael Hoffman
Just out of curiosity, I was wondering if anyone has compiled Python 2.4 with the Intel C Compiler and its processor specific optimizations. I can build it fine with OPT="-O3" or OPT="-xN" but when I try to combine them I get this as soon as ./python is run: """ case $MAKEFLAGS in \ *-s*) CC='icc

Re: confusion around CustomException example in 'Python in a Nutshell'

2005-03-12 Thread erick_bodine
Peter Hansen wrote: > [EMAIL PROTECTED] wrote: > > In Martinelli's Nutshell book in the Exceptions chapter there is an > > example of a custom exception class (pg.112) that I am trying to > > implement without success. The custom exception class example pulls > > sys.exc_info() into an attribute

Re: Add Properties to Instances?

2005-03-12 Thread Jeremy Bowers
On Sat, 12 Mar 2005 09:48:42 -0800, Martin Miller wrote: > I'm trying to create some read-only instance specific properties, but the > following attempt didn't work: I'm going to echo Steven's comment: "What's the situation in which you think you want different properties for different instances

Re: Can't seem to insert rows into a MySQL table

2005-03-12 Thread Patrick Useldinger
grumfish wrote: connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", db="japanese") cursor = connection.cursor() cursor.execute("INSERT INTO edict (kanji, kana, meaning) VALUES (%s, %s, %s)", ("a", "b", "c") ) connection.close() Just a guess "in the dark" (I don't use MySQL):

Re: Generating data types automatically

2005-03-12 Thread Steven Bethard
Torsten Bronger wrote: Okay this works: def generate_type_dublett(visa_type, ctypes_type): return visa_type + "=" + ctypes_type + ";" + \ "ViP" + visa_type[2:] + "=POINTER(" + visa_type + ")" def generate_type_triplett(visa_type, ctypes_type): return generate_type_dublett(visa_type,

Re: bsddb support for berkeley db 4.3?

2005-03-12 Thread "Martin v. Löwis"
[EMAIL PROTECTED] wrote: It doesn't seem like the python 2.4(and the recent 2.4.1) support berkeley db 4.3. What makes you say that? It builds fine for me. bsddb3(at pybsddb.sf.net) already supports 4.3 since last December(but doesn't explicitly support win32 -- see the assert statement in setup.p

Re: Generating data types automatically

2005-03-12 Thread Michael Hoffman
Torsten Bronger wrote: def generate_type_dublett(visa_type, ctypes_type): visa_type_name = visa_type.__name__ exec visa_type_name + "=" + ctypes_type.__name__ exec "ViP" + visa_type_name[2:] + "=POINTER(" + visa_type_name + ")" You shouldn't need to use exec for this, and it is best to

Can't seem to insert rows into a MySQL table

2005-03-12 Thread grumfish
I'm trying to add a row to a MySQL table using insert. Here is the code: connection = MySQLdb.connect(host="localhost", user="root", passwd="pw", db="japanese") cursor = connection.cursor() cursor.execute("INSERT INTO edict (kanji, kana, meaning) VALUES (%s, %s, %s)", ("a", "b", "c") ) connection

Re: Debugging Python Scripts inside other processes

2005-03-12 Thread Robin Becker
A. Klingenstein wrote: I embedded Python in a Windows C++ program. Now I want to debug my embedded scripts which of course won't run in any IDE process. Commercial IDEs like WingIDE can attach to external processes by importing a module in the scripts. Is there a debugger capable of this which

  1   2   >