Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread J. Peng
J. Peng 写道: >k = (i.split())[3] >y = (i.split())[1] btw, why can't I write the above two into one statement? (k,y) = (i.split())[3,1] -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in __init__?

2008-01-21 Thread cokofreedom
Is there no way of adding a possible warning message (that obviously could be turned off) to warn users of possible problems linked to using mutable types as parameters? Seems to me this could save users a few minutes/hours of headaches and headscratching. (The biggest issue affecting new programm

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread J. Peng
I tried to write it below,it can work,:) v= """preference 10 host mx1.domain.com preference 30 host anotherhost.domain.com preference 20 host mx2.domain.com""" x=v.split("\n") li =[] for i in x: k = (i.split())[3] y = (i.split())[1] li.append((y,k)) li.sort() print li the output is:

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread pythonewbie
On 21 jan, 05:31, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 20 Jan 2008 13:58:13 -0800 (PST), pythonewbie > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > I just would like to know if I would ALWAYS find the install directory > > in sys.path[6] and site-packages

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Paul Rubin
Arnaud Delobelle <[EMAIL PROTECTED]> writes: > Update: 2, 4, 5, 8, 9, 25 can reach any target between 100 and 999. Are you sure? What expression do you get for target = 758? -- http://mail.python.org/mailman/listinfo/python-list

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread dg . google . groups
Hi all, It's great how many different sorts of solutions (or almost solutions) this puzzle has generated. Speedwise, for reference my solution posted above takes about 40 seconds on my 1.8GHz laptop, and the less elegant version (on my webpage linked to in the original post) takes about 15 seconds

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Steven D'Aprano
On Sun, 20 Jan 2008 21:15:02 -0600, Albert Hopkins wrote: > This issue may have been referred to in > news:<[EMAIL PROTECTED]> but I didn't > entirely understand the explanation. Basically I have this: > > >>> a = float(6) > >>> b = float('nan') > >>> min(a, b) > 6.0 > >>> mi

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Terry Jones
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes: Arnaud> In countdown you are not required to use all numbers to reach the Arnaud> target. This means you are missing solutions, e.g. (1, 3, 6, Arnaud> 'mul', 'add', 7 , 'add', 9, 'mul') Hi Arnaud. Thanks, I didn't know that. The fix

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread pythonewbie
On 21 jan, 09:53, pythonewbie <[EMAIL PROTECTED]> wrote: > On 21 jan, 05:31, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > > > On Sun, 20 Jan 2008 13:58:13 -0800 (PST), pythonewbie > > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > I just would like to know if I would

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Terry Jones
> "Paul" == Paul Rubin <"http://phr.cx"@NOSPAM.invalid> writes: Hi Paul Paul> Here's my latest, which I think is exhaustive, but it is very slow. Paul> It prints a progress message now and then just to give the user some Paul> sign of life. It should print a total of 256-8 = 248 of those Pau

Re: eucledian dist calculations

2008-01-21 Thread John Machin
On Jan 21, 6:44 pm, nodrogbrown <[EMAIL PROTECTED]> wrote: > hi > i am using python to do some image data calculations..I use the > following numpy.ndarrays ,(i have given their shapes and ranks) > > weights=ndarray :shape(100,30),ndim=2 will have vals like > 2458121847.49 (of type 'numpy.float6

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 16:23:50 +0800, J. Peng wrote: > J. Peng 写道: > >>k = (i.split())[3] >>y = (i.split())[1] > > btw, why can't I write the above two into one statement? > > (k,y) = (i.split())[3,1] I don't know. What's "i"? I'm guessing "i" is a string (and what a horrible choice of

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread Peter Otten
Santiago Romero wrote: > I'm trying to sort both lists so that they end like this: > > preferences = [10, 20, 30] > hosts = [ "mx1.domain.com", "mx2.domain.com", > "anotherhost.domain.com" ] > > I want to sort hosts list depending on the numeric order of > "preferences". The following relies

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread dg . google . groups
Decided I may as well post my other solution while I'm at it. The neat trick here is redefining the add, mul, etc. functions so that they raise exceptions for example if x>y then add(x,y) raises an exception which is handled by the search algorithm to mean don't continue that computation - this sto

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread John Machin
On Jan 21, 8:12 pm, pythonewbie <[EMAIL PROTECTED]> wrote: > On 21 jan, 09:53, pythonewbie <[EMAIL PROTECTED]> wrote: > > > > > On 21 jan, 05:31, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > > On Sun, 20 Jan 2008 13:58:13 -0800 (PST), pythonewbie > > > <[EMAIL PROTECTED]> declaimed the follow

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 01:15:50 -0800, dg.google.groups wrote: > Decided I may as well post my other solution while I'm at it. The neat > trick here is redefining the add, mul, etc. functions so that they raise > exceptions for example if x>y then add(x,y) raises an exception which is > handled by th

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread Diez B. Roggisch
pythonewbie > > Because the solution using distutils.sysconfig.get_python_lib() is > very smart ! Depending on your goal. You said """ My goal is to verify if an/several extension(s) are installed and to automatically install the missing ones on Linux or Win32. """ This goal can't be reached

Re: Default attribute values pattern

2008-01-21 Thread Bruno Desthuilliers
David Tweet a écrit : (please, don't top-post) > > def Grab(argdict, key, default): cf pep08 for naming conventions... > """Like argdict.get(key, default), but also deletes key from argdict.""" > if key in argdict: > retval = argdict["key"] > del(argdict[key]) > else: > retval

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread J. Peng
Steven D'Aprano 写道: > On Mon, 21 Jan 2008 16:23:50 +0800, J. Peng wrote: > >> J. Peng 写道: >> >>>k = (i.split())[3] >>>y = (i.split())[1] >> btw, why can't I write the above two into one statement? >> >> (k,y) = (i.split())[3,1] > > I don't know. What's "i"? > > I'm guessing "i" is a stri

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread Santiago Romero
Thanks all for the answers ... I'll use a tuple as you said :) Anyway, is interesting to know how to sort 2 lists when you dont want to use tuples, so thanks also to Peter :) > Then one have to split the list twice.Given the list is large,it's maybe > not good for performance.Is it a more effe

Re: Default attribute values pattern

2008-01-21 Thread cokofreedom
> Grab(argdict, key, default) is argdict.pop(key, default) "pop() raises a KeyError when no default value is given and the key is not found." > def grab(kw, key, default=None): >try: > return kw.pop(key) >except KeyError: > return default So Bruno's technique seems to me to be

building psycopg2 on windows using mingw, "cannot find -lpq"

2008-01-21 Thread GHUM
The compile works, BUT linking fails: 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: \python25\PCBuild -Lc:/p ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build \lib.win32-2.5\psy copg2\_psycopg.pyd c:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread pythonewbie
On 21 jan, 10:34, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie > > > > > Because the solution using distutils.sysconfig.get_python_lib() is > > very smart ! > > Depending on your goal. You said > > """ > My goal is to verify if an/several extension(s) are installed and to > automatic

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Terry Jones
> "dg" == dg google groups <[EMAIL PROTECTED]> writes: dg> It's great how many different sorts of solutions (or almost solutions) dg> this puzzle has generated. Speedwise, for reference my solution posted dg> above takes about 40 seconds on my 1.8GHz laptop, and the less elegant dg> version (o

Re: problem with 'global'

2008-01-21 Thread Duncan Booth
Mel <[EMAIL PROTECTED]> wrote: > oyster wrote: >> why the following 2 prg give different results? a.py is ok, but b.py >> is 'undefiend a' >> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC >> v.1310 32 bit (Intel)] on win32 >> #a.py >> def run(): >> if 1==2:

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread pythonewbie
On 21 jan, 10:34, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie > > > > > Because the solution using distutils.sysconfig.get_python_lib() is > > very smart ! > > Depending on your goal. You said > > """ > My goal is to verify if an/several extension(s) are installed and to > automatic

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread John Machin
On Jan 21, 9:05 pm, pythonewbie <[EMAIL PROTECTED]> wrote: > On 21 jan, 10:34, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: [snip] > > Diez > > To John Machin, Get a clue #1: read the instructions for your news client ... like the bit that says "click on the message/posting that you want to reply

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Arnaud Delobelle
On Jan 21, 9:01 am, [EMAIL PROTECTED] wrote: > Hi all, > > It's great how many different sorts of solutions (or almost solutions) > this puzzle has generated. Speedwise, for reference my solution posted > above takes about 40 seconds on my 1.8GHz laptop, and the less elegant > version (on my webpag

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread Diez B. Roggisch
> > Diez, > > I repeat I am a newbie, so please don't be angry against me, if I say > something stupid or if I propose a method not efficient. Where did I sound angry? > An easy way to get the absolute path of site-packages seems very > useful to me, in order to check anything (all extensions

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread cokofreedom
On Jan 21, 11:29 am, Terry Jones <[EMAIL PROTECTED]> wrote: > > "dg" == dg google groups <[EMAIL PROTECTED]> writes: > > dg> It's great how many different sorts of solutions (or almost solutions) > dg> this puzzle has generated. Speedwise, for reference my solution posted > dg> above takes abou

Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

2008-01-21 Thread pythonewbie
On 21 jan, 11:49, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Diez, > > > I repeat I am a newbie, so please don't be angry against me, if I say > > something stupid or if I propose a method not efficient. > > Where did I sound angry? > > > An easy way to get the absolute path of site-packages

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Arnaud Delobelle
On Jan 21, 9:12 am, Terry Jones <[EMAIL PROTECTED]> wrote: [...] > Hi Arnaud. Hi Terry [...] > WRT to the missing solution, note that my code only allowed multiplication > by 1 if it was the last thing done. That was because you can multiply by 1 > at any time, and I didn't want to see those triv

Re: Default attribute values pattern

2008-01-21 Thread Arnaud Delobelle
On Jan 21, 10:09 am, [EMAIL PROTECTED] wrote: > > Grab(argdict, key, default) is argdict.pop(key, default) > > "pop() raises a KeyError when no default value is given and the key is > not found." And it doesn't if a default is provided, which is always the case in the uses of Grab(...), so it seem

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Terry Jones
> "cokofreedom" == cokofreedom <[EMAIL PROTECTED]> writes: cokofreedom> Terry, your technique is efficient and pretty readable! All cokofreedom> that could be added now is a way to output the data in a more cokofreedom> user-friendly print. Yes, and a fix for the bug Arnaud just pointed out

Q: paramiko/SSH/ how to get a remote host_key

2008-01-21 Thread DHR
I'm trying to run the simpliest example form paramiko readme(Homepage: http://www.lag.net/paramiko/), and cannot find out how to get the remote SSH server host_key. This is the code. It is supposed to connect to a remote SSH host and execute an 'ls' command: import paramiko, base64 key = parami

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Terry Jones
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes: Arnaud> Sorry I gave an incorrect example to illustrate my question last Arnaud> night (I blame this on baby-induced sleep deprivation ;), so I'll Arnaud> have another go: Arnaud> Say I have 2, 3, 4, 100 and I want to make 406. AFAIC

Re: How to use py2exe ...

2008-01-21 Thread DHR
Here is how I am creating my win32 exe with py2exe: 1. create a setup.py file with the following: from distutils.core import setup import py2exe #setup(console=['main_script.py']) setup(windows=['main_script.py'] ) 2. run the following command from console: 'python setup.py py2exe' Hope this hel

Re: Q: paramiko/SSH/ how to get a remote host_key

2008-01-21 Thread Guilherme Polo
2008/1/21, DHR <[EMAIL PROTECTED]>: > I'm trying to run the simpliest example form paramiko readme(Homepage: > http://www.lag.net/paramiko/), and > cannot find out how to get the remote SSH server host_key. > > > This is the code. It is supposed to connect to a remote SSH host and > execute an 'ls'

[HELP] SMTPlib not sending my mail

2008-01-21 Thread ornto
Hi, I'm trying to create an application which checks a dynamic web site and on certain events sends an email to me. My problem though is with the email task. By now I made this simple test code: #prova invio email smtpserver = smtplib.SMTP(mailserver) messaggio= "Messaggio di prova" print mai

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 17:32:42 +0800, J. Peng wrote: > Steven D'Aprano 写道: >> On Mon, 21 Jan 2008 16:23:50 +0800, J. Peng wrote: >> >>> J. Peng 写道: >>> k = (i.split())[3] y = (i.split())[1] >>> btw, why can't I write the above two into one statement? >>> >>> (k,y) = (i.split())[3,1]

Re: Basic inheritance question

2008-01-21 Thread Bruno Desthuilliers
Lie a écrit : > On Jan 16, 9:23 pm, Bjoern Schliessmann [EMAIL PROTECTED]> wrote: >> Lie wrote: >>> [EMAIL PROTECTED]> wrote: I used to systematically use it - like I've always systematically used 'this' in C++ and Java. >>> And that is what reduces readability. >> IMHO not, IOPHO not.

Re: Q: paramiko/SSH/ how to get a remote host_key

2008-01-21 Thread DHR
I am connecting from a WindowsXP SP2 machine. When using Putty as an SSH client, if you connect for the first time then you get somethign like this: ''' The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key

Re: Q: paramiko/SSH/ how to get a remote host_key

2008-01-21 Thread Guilherme Polo
2008/1/21, DHR <[EMAIL PROTECTED]>: > I am connecting from a WindowsXP SP2 machine. When using Putty as an > SSH client, if you connect for the first time then you get somethign > like this: > > ''' The server's host key is not cached in the registry. You > have no guarantee that the server is the

where to join a open project in Python

2008-01-21 Thread scsoce sc
hi,all: as a newbie, i found that finding a suitable open project in Python seems hard, well, i has tried sourceforge and google code, python project is just rare or not fit for me. so i want to get any suggestion or experience from you dear pythonmates. thank you scsoce -- http://mail.python.org

Re: Q: paramiko/SSH/ how to get a remote host_key

2008-01-21 Thread DHR
Thank you! Now it works and the code looks like this: import paramiko import base64 from paramiko import AutoAddPolicy, SSHClient client = paramiko.SSHClient() client.set_missing_host_key_policy(AutoAddPolicy()) client.connect('hostIP', username='uname', password='pass') stdin, stdout, stderr = c

Re: problem with 'global'

2008-01-21 Thread Mel
Duncan Booth wrote: > Mel <[EMAIL PROTECTED]> wrote: > >> oyster wrote: >>> why the following 2 prg give different results? a.py is ok, but b.py >>> is 'undefiend a' >>> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC >>> v.1310 32 bit (Intel)] on win32 >>> #a.py >>> def run(): >>

Re: Memory errors with imaplib

2008-01-21 Thread Christian Heimes
Grant Edwards wrote: > If the solution shown in the bug report is correct, I'd be more > than happy to generate a patch. The solution seems fine but IMO it should be fixed in the ssl socket and not in imaplib. I like to get it *fixed* and not *worked around*. :) Christian -- http://mail.pytho

[OT] Valid Mail addresses modifications (WAS: Re: Looping through the gmail dot trick)

2008-01-21 Thread Martin Marcher
Martin Vilcans wrote: > Try the SMTP spec. IIRC there's a passage there that says that the > server should try to make sense of addresses that don't map directly > to a user name. Specifically, it says that firstname.lastname should > be mapped to the user with those first and last names. Short s

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 09:53:10 +0100, Peter Otten wrote: > Santiago Romero wrote: > >> I'm trying to sort both lists so that they end like this: >> >> preferences = [10, 20, 30] >> hosts = [ "mx1.domain.com", "mx2.domain.com", "anotherhost.domain.com" >> ] >> >> I want to sort hosts list depen

stdin, stdout, redmon

2008-01-21 Thread Bernard Desnoues
Hi, I've got a problem with the use of Redmon (redirection port monitor). I intend to develop a virtual printer so that I can modify data sent to the printer. Redmon send the data flow to the standard input and lauchs the Python program which send modified data to the standard output (Windows X

Re: Q: paramiko/SSH/ how to get a remote host_key

2008-01-21 Thread Guilherme Polo
2008/1/21, DHR <[EMAIL PROTECTED]>: > Thank you! Now it works and the code looks like this: > > import paramiko > import base64 > from paramiko import AutoAddPolicy, SSHClient > > client = paramiko.SSHClient() > client.set_missing_host_key_policy(AutoAddPolicy()) > client.connect('hostIP', username

Re: stdin, stdout, redmon

2008-01-21 Thread Rolf van de Krol
According to various tutorials this should work. |import sys data = sys.stdin.readlines() print "Counted", len(data), "lines."| Please use google before asking such questions. This was found with only one search for the terms 'python read stdin' Rolf Bernard Desnoues wrote: > Hi, > > I've go

Re: How to use py2exe ...

2008-01-21 Thread Mike Driscoll
On Jan 21, 1:45 am, Santiago Romero <[EMAIL PROTECTED]> wrote: > Hi... > > I'm a Linux user, and I would like some windows-friends to test a > game I'm writing with python+pygame without they needing to install > python, pygame, and so on. > > I've heard about py2exe and pygame2exe, but I'm not

Re: stdin, stdout, redmon

2008-01-21 Thread Bernard Desnoues
Rolf van de Krol a écrit : > According to various tutorials this should work. > > > |import sys > data = sys.stdin.readlines() > print "Counted", len(data), "lines."| > > > Please use google before asking such questions. This was found with only > one search for the terms 'python read stdin' >

Re: stdin, stdout, redmon

2008-01-21 Thread Rolf van de Krol
I don't know what you did with your Python installation, but for me this works perfectly. test3.py contains: import sys print sys.stdin.readlines() test.txt contains: Testline1 Testline2 Output of 'python test3.py < test.txt' is: ['Testline1\n', 'Testline2'] Just plain simple and just w

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Jason
On Jan 21, 12:00 am, Albert Hopkins <[EMAIL PROTECTED]> wrote: > On Sun, 20 Jan 2008 20:16:18 -0800, Paddy wrote: > > I am definitely NOT a floating point expert, but I did find this: > >http://en.wikipedia.org/wiki/IEEE_754r#min_and_max > > > P.S. What platform /Compiler are you using for Python?

Re: Sorting a list depending of the indexes of another sorted list

2008-01-21 Thread Peter Otten
Steven D'Aprano wrote: >> The following relies on undocumented (I hope) behaviour: > preferences = [10, 30, 20] > hosts = [ "mx1.domain.com", "anotherhost.domain.com", >>... "mx2.domain.com"] > hosts.sort(key=lambda x, p=iter(preferences).next: p()) > preferences.sort() > ho

Re: Looping through the gmail dot trick

2008-01-21 Thread Martin Marcher
Steven D'Aprano wrote: > Postfix, I think, interpets "foo+bar" the same as "foo". yup it does, but "foo" has to be a valid localpart so "foo+bar" -> foo foo+baz -> foo f+oobar -> f - which is a different user (aliases set aside) famous call on plus addressing, and you it's just a default you can

Re: Memory errors with imaplib

2008-01-21 Thread Grant Edwards
On 2008-01-21, Christian Heimes <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > >> If the solution shown in the bug report is correct, I'd be >> more than happy to generate a patch. > > The solution seems fine but IMO it should be fixed in the ssl > socket and not in imaplib. I like to get it *

Re: dynamic type variable

2008-01-21 Thread Grant Edwards
On 2008-01-21, J. Peng <[EMAIL PROTECTED]> wrote: > Python's variable is dynamic type,is it? > But why this can't work? > 3 + 'a' It can't work because the compiler has no way of knowing whether the correct answer is '3a', 0x0d, the color purple, or to reboot. > So I see the number 3 can't

Re: eucledian dist calculations

2008-01-21 Thread nodrogbrown
> > 1. 'temp' is not used > 2. Lose the superfluous parentheses in 'if' statements > 3. Put space around operators > 4. I've never used any of numpy & friends, but: > (a) Can't you replace the inner loop with something like this: >distance = abs(input_weight - weights[image, :]) > (b) I doubt

Help with cPAMIE

2008-01-21 Thread romo20350
Hi, I'm in need of help with cPAMIE. I'm currently trying to submit this form on a webpage: Submit Coupon Coupon Code: Submit Coupon I can fill in the textboxes alright but I'm having trouble submitting it. I've tried using: ie.buttonClick('action') but It returns some thing about it being

Re: building psycopg2 on windows using mingw, "cannot find -lpq"

2008-01-21 Thread Tom Brown
On Mon, 2008-01-21 at 01:57 -0800, GHUM wrote: > What am I missing? any hints? I use psycopg2 all the time on windows. I use the binary installer instead of source. Works great for me. -Tom -- http://mail.python.org/mailman/listinfo/python-list

Trouble writing to database: RSS-reader

2008-01-21 Thread Arne
Hi! I try to make a rss-reader in python just for fun, and I'm almost finished. I don't have any syntax-errors, but when i run my program, nothing happends. This program is supposed to download a .xml-file, save the contents in a buffer-file(buffer.txt) and parse the file looking for start-tags.

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Mark Dickinson
On Jan 21, 9:55 am, Jason <[EMAIL PROTECTED]> wrote: > display.  On windows, "float('nan')" will cause an exception, as there > are no valid string representations of NAN that can be converted to > the special floating point value.  Also, if you manage to create a nan > under Windows, it displays a

How to solve "TypeError: list indices must be integers".

2008-01-21 Thread 顏灝
This is more details about my problem, which I running my py script for my project. Programming in pythoncard that we can develop a GUI based application easily. I was assigned dialog.colorDialog(self) return value to a result object, but I suspect that result.color is the attribute of the result

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Grant Edwards
On 2008-01-21, Albert Hopkins <[EMAIL PROTECTED]> wrote: > This issue may have been referred to in > news:<[EMAIL PROTECTED]> but I didn't > entirely understand the explanation. Basically I have this: > > >>> a = float(6) > >>> b = float('nan') > >>> min(a, b) > 6.0 > >>> min

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Grant Edwards
On 2008-01-21, Jason <[EMAIL PROTECTED]> wrote: > Infinite values are also problematic. In almost all cases, it is far > better to avoid infinite and NaN values. In many applications (e.g. process control) propogating NaN values are way too useful to avoid. Avoiding NaN would make a lot of code

Python-URL! - weekly Python news and links (Jan 21)

2008-01-21 Thread Gabriel Genellina
QOTW: "I'd say Java was never sexy, but dressed up in expensive lingerie by marketing maniacs..." - Diez B. Roggisch http://groups.google.com/group/comp.lang.python/msg/ae0463c921077f7f "I must say that the richness that list comprehensions, generators and iterators have brought to Python are

Re: building psycopg2 on windows using mingw, "cannot find -lpq"

2008-01-21 Thread Diez B. Roggisch
GHUM wrote: > The compile works, BUT linking fails: > > 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: > \python25\PCBuild -Lc:/p > ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build > \lib.win32-2.5\psy > copg2\_psycopg.pyd > c:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\.

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Arnaud Delobelle
On Jan 21, 9:01 am, [EMAIL PROTECTED] wrote: > Arnaud: I haven't had time to play with your solution yet - how quick > does it run? Ok I've done some quick timings, it's faster than I remembered it: numbers = [2, 4, 5, 8, 25] target = 758 Average time to find (1) best solution (in terms of leng

ctypes CDLL - which paths are searched?

2008-01-21 Thread Helmut Jarausch
Hi, how can I specify the paths to be searched for a dynamic library to be loaded by ctypes' CDLL class on a Linux system. Do I have to set os.environment['LD_LIBRARY_PATH'] ? Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52

is it possible to set namespace to an object.

2008-01-21 Thread glomde
Hi, is it somehow possible to set the current namespace so that is in an object. Somthing like. class Test(): testObj = Test() set namespace testObj Name = "Test" Name would set testObj.Name to "Test". I was thinking this could be done with the with statement somehow (without using

Re: Basic inheritance question

2008-01-21 Thread Lie
> > Please stop taking my words to its letters. > > So we're supposed to actually guess what you really mean ??? That's what human does, otherwise you'll "Fail the Turing Test". > >> Personally, I've seen many C++ programs with complex class designs > >> where it definitely helps to consistently

Re: Is there a portable way to tell if data is available on a pipe?

2008-01-21 Thread Scott David Daniels
John Nagle wrote: >I need some way to find out if a pipe has data available for > a read without blocking if it does not. ... > I'd like to avoid having a thread to manage each pipe, but if I > have to, so be it. Well, without granting your wish, put a Queue.Queue "in front" of each pipe. Th

Berlin (Germany) Python User Group is meeting on 23.1.

2008-01-21 Thread Stephan Diehl
The Berlin Python User Group is meeting on the 23.1. at newthinking store at 7pm. All details can be found at http://wiki.python.de/User_Group_Berlin. The Berlin Python User Group is planning to meet every two month to talk about Python. Most talking will be done in german, but I can assure you th

Re: is it possible to set namespace to an object.

2008-01-21 Thread Wildemar Wildenburger
glomde wrote: > Hi, > > is it somehow possible to set the current namespace so that is in an > object. > [snip] > set namespace testObj > Name = "Test" > > Name would set testObj.Name to "Test". > > [snip] > > Is the above possible? > Don't know, sorry. But let me ask you this: Why do you want

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Pete Forman
Grant Edwards <[EMAIL PROTECTED]> writes: > For applications I work on, it should be NaN. But I think the > result of comparing a Normal to a NaN is undefined, so the > above behavior is allowed by the IEEE spec. Comparison of two floating point datums results in exactly one of these being tr

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Bruno Desthuilliers
Arne a écrit : > Hi! > > I try to make a rss-reader in python just for fun, and I'm almost > finished. Bad news : you're not. > I don't have any syntax-errors, but when i run my program, > nothing happends. > > This program is supposed to download a .xml-file, save the contents in > a buffer-fi

Re: Default attribute values pattern

2008-01-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : >> Grab(argdict, key, default) is argdict.pop(key, default) > > "pop() raises a KeyError when no default value is given and the key is > not found." Then use it with a default value !-) >> def grab(kw, key, default=None): >>try: >> return kw.pop(key) >>ex

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : > On Mon, 21 Jan 2008 08:12:43 -0800 (PST), Arne <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> The problem is that i cant find the data in the database! If i watch >> my program while im running it, i can see that it sucsessfuly >> downloads th

index of min element of sequence

2008-01-21 Thread Neal Becker
What's a good/fast way to find the index of the minimum element of a sequence? (I'm fairly sure sorting the sequence is not the fastest approach) -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 14:12:43 -0200, Arne <[EMAIL PROTECTED]> escribi�: > I try to make a rss-reader in python just for fun, and I'm almost > finished. I don't have any syntax-errors, but when i run my program, > nothing happends. > > This program is supposed to download a .xml-file, save the conte

Re: index of min element of sequence

2008-01-21 Thread Peter Otten
Neal Becker wrote: > What's a good/fast way to find the index of the minimum element of a > sequence? (I'm fairly sure sorting the sequence is not the fastest > approach) >>> items = "defbhkamnz" >>> min(xrange(len(items)), key=items.__getitem__) 6 >>> items[6] 'a' Peter -- http://mail.python.

Re: is it possible to set namespace to an object.

2008-01-21 Thread glomde
On 21 Jan, 18:59, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > glomde wrote: > > Hi, > > > is it somehow possible to set the current namespace so that is in an > > object. > > [snip] > > set namespace testObj > > Name = "Test" > > > Name would set testObj.Name to "Test". > > > [snip] > > > Is

Re: problem with 'global'

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 11:44:54 -0200, Mel <[EMAIL PROTECTED]> escribi�: > Duncan Booth wrote: >> >> The first sentence (which hasn't changed since 2.4) describing the >> global >> statement seems clear enough to me: "The global statement is a >> declaration >> which holds for the entire current

Re: How to solve "TypeError: list indices must be integers".

2008-01-21 Thread John Machin
On Jan 22, 3:15 am, "" <[EMAIL PROTECTED]> wrote: > This is more details about my problem, which I running my py script > for my project. Programming in pythoncard that we can develop a GUI > based application easily. > > I was assigned dialog.colorDialog(self) return value to a result > object

Re: is it possible to set namespace to an object.

2008-01-21 Thread George Sakkis
On Jan 21, 1:56 pm, glomde <[EMAIL PROTECTED]> wrote: > On 21 Jan, 18:59, Wildemar Wildenburger > > > > <[EMAIL PROTECTED]> wrote: > > glomde wrote: > > > Hi, > > > > is it somehow possible to set the current namespace so that is in an > > > object. > > > [snip] > > > set namespace testObj > > > Na

Re: problem with 'global'

2008-01-21 Thread Marc 'BlackJack' Rintsch
On Mon, 21 Jan 2008 17:08:46 -0200, Gabriel Genellina wrote: > The future statement is another example, even worse: > > if 0: > from __future__ import with_statement > > with open("xxx") as f: > print f In Python >=2.5 it's a compile time error if that import is not the very first sta

Re: Default attribute values pattern

2008-01-21 Thread George Sakkis
On Jan 19, 6:02 pm, "David Tweet" <[EMAIL PROTECTED]> wrote: > Hello, > > Seems to me that setattrs sort of assumes that you want to have all your > initialization arguments set as attributes of the same name. I would think > you'd sometimes want to be able to process the extra arguments inside of

Re: Bug in __init__?

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 05:59:38 -0200, <[EMAIL PROTECTED]> escribi�: > Is there no way of adding a possible warning message (that obviously > could be turned off) to warn users of possible problems linked to > using mutable types as parameters? > > Seems to me this could save users a few minutes/hour

Re: problem with 'global'

2008-01-21 Thread Duncan Booth
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 21 Jan 2008 17:08:46 -0200, Gabriel Genellina wrote: > >> The future statement is another example, even worse: >> >> if 0: >> from __future__ import with_statement >> >> with open("xxx") as f: >> print f > > In Python >=2.

Re: index of min element of sequence

2008-01-21 Thread Paul Rubin
Neal Becker <[EMAIL PROTECTED]> writes: > What's a good/fast way to find the index of the minimum element of a > sequence? (I'm fairly sure sorting the sequence is not the fastest > approach) Python 2.5 (untested): from operator import itemgetter minindex = min(enumerate(seq), key=itemgett

Re: index of min element of sequence

2008-01-21 Thread Roger Miller
On Jan 21, 8:48 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Neal Becker wrote: > > What's a good/fast way to find the index of the minimum element of a > > sequence? ... > >>> min(xrange(len(items)), key=items.__getitem__) ... Or just items.index(min(items)) I found this to be significantly

Re: is it possible to set namespace to an object.

2008-01-21 Thread glomde
On 21 Jan, 20:16, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jan 21, 1:56 pm, glomde <[EMAIL PROTECTED]> wrote: > > > > > On 21 Jan, 18:59, Wildemar Wildenburger > > > <[EMAIL PROTECTED]> wrote: > > > glomde wrote: > > > > Hi, > > > > > is it somehow possible to set the current namespace so that

Building a pretrigger / posttrigger framework class

2008-01-21 Thread rh0dium
Hi all, I am thinking about a class which can automatically determine the order which it is run. I would like to implement a super class which has a run() method and a pretrigger() method. The purpose of the pretrigger method is to state what classes need to be run before this class.run() method

Re: index of min element of sequence

2008-01-21 Thread John Machin
On Jan 22, 6:38 am, Paul Rubin wrote: > Neal Becker <[EMAIL PROTECTED]> writes: > > What's a good/fast way to find the index of the minimum element of a > > sequence? (I'm fairly sure sorting the sequence is not the fastest > > approach) > > Python 2.5 (untested): > >

Re: Is there a portable way to tell if data is available on a pipe?

2008-01-21 Thread John Nagle
Scott David Daniels wrote: > John Nagle wrote: >>I need some way to find out if a pipe has data available for >> a read without blocking if it does not. > ... >> I'd like to avoid having a thread to manage each pipe, but if I >> have to, so be it. > > Well, without granting your wish, put a Q

Re: index of min element of sequence

2008-01-21 Thread Peter Otten
Roger Miller wrote: > On Jan 21, 8:48 am, Peter Otten <[EMAIL PROTECTED]> wrote: > >> Neal Becker wrote: >> > What's a good/fast way to find the index of the minimum element of a >> > sequence? > ... > >> >>> min(xrange(len(items)), key=items.__getitem__) > ... > > Or just >items.index(min(

Re: problem with 'global'

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 17:36:29 -0200, Duncan Booth <[EMAIL PROTECTED]> escribi�: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> On Mon, 21 Jan 2008 17:08:46 -0200, Gabriel Genellina wrote: >> >>> The future statement is another example, even worse: >>> >>> if 0: >>> from __future_

  1   2   >