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

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

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

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

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: 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: 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 '@'.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: 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: 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: 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: 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: 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
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: 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: 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" >>>

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

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

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

Beware complexity

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

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

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

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

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

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

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

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

<    1   2