Re: sockets -- basic udp client

2008-02-16 Thread 7stud
On Feb 15, 6:48 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Fri, 15 Feb 2008 20:24:19 -0200, 7stud [EMAIL PROTECTED]   escribió: My question pertains to this example: #!/usr/bin/env python import socket, sys, time host = sys.argv[1] textport = sys.argv[2] s =

Re: Help Parsing an HTML File

2008-02-16 Thread Peter Otten
Stefan Behnel wrote: [EMAIL PROTECTED] wrote: I have a single unicode file that has descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted below. I need to parse the file in such a way to extract data out of the html and to come up with a tab separated file

Re: Inter-process communication, how? Part 2

2008-02-16 Thread makkalot
Sunday 23 December 2007 Tarihinde 03:56:05 yazmıştı: Hello, just to recap: last time I asked how to do an interprocess communitation, between one Manager process (graphical beckend) and some Worker processes. Why just dont use dbus , and then have a drink :) --

any python wrapper to call .lib static library(ufmod.lib)?

2008-02-16 Thread est
I want to play .XM music using Python, now I found ufmod http://ufmod.sourceforge.net It only provide a ufmod.lib to be compiled in C/C++/BASIC, and Python as a scripting language could not handle these static libraries. What could I do to with these .lib files? Cheers --

mapping problem

2008-02-16 Thread Mr Shore
I've now crawled the meta infor,but with multi name all means the same thing, such as MS,microsoft,microsoft corporation all means the same thing, how can I mapping words like this to the same thing? -- http://mail.python.org/mailman/listinfo/python-list

Re: ways to declare empty set variable

2008-02-16 Thread Boris Borcic
[EMAIL PROTECTED] wrote: ...Missing that, I think dict() and set() and tuple() and list() look better than using {} for the empty dict and {/} for the empty set and () for empty tuple (or {} for the empty dict and set() for the empty set). The problem I have with them is in no way the

Re: Floating point bug?

2008-02-16 Thread Steven D'Aprano
On Fri, 15 Feb 2008 17:30:03 -0800, Jeff Schwab wrote: But good advice becomes a superstition when it becomes treated as a law: never test floats for equality. That's simply not true. For example, floats are exact for whole numbers, up to the limits of overflow. That's not true. Epsilon

Re: ways to declare empty set variable

2008-02-16 Thread Steve Holden
Boris Borcic wrote: [EMAIL PROTECTED] wrote: ...Missing that, I think dict() and set() and tuple() and list() look better than using {} for the empty dict and {/} for the empty set and () for empty tuple (or {} for the empty dict and set() for the empty set). The problem I have with them

Re: mapping problem

2008-02-16 Thread Steven D'Aprano
On Sat, 16 Feb 2008 01:35:32 -0800, Mr Shore wrote: I've now crawled the meta infor,but with multi name all means the same thing, such as MS,microsoft,microsoft corporation all means the same thing, how can I mapping words like this to the same thing? The same way you would map anything: use

Re: mapping problem

2008-02-16 Thread Steve Holden
Mr Shore wrote: I've now crawled the meta infor,but with multi name all means the same thing, such as MS,microsoft,microsoft corporation all means the same thing, how can I mapping words like this to the same thing? http://docs.python.org/lib/typesmapping.html regards Steve -- Steve

Re: Where can I get the module MyUtils?

2008-02-16 Thread Diez B. Roggisch
Python_Doctor schrieb: I inherited a piece of python code which imports MyUtils i.e. it has a line: import MyUtils When I execute the code I get: ImportError: No module named MyUtils I assume the code is looking for another module called MyUtils.py. Is this a standard Python module?

Re: any python wrapper to call .lib static library(ufmod.lib)?

2008-02-16 Thread Diez B. Roggisch
est schrieb: I want to play .XM music using Python, now I found ufmod http://ufmod.sourceforge.net It only provide a ufmod.lib to be compiled in C/C++/BASIC, and Python as a scripting language could not handle these static libraries. What could I do to with these .lib files? I'm not sure

Re: ways to declare empty set variable

2008-02-16 Thread Steven D'Aprano
On Sat, 16 Feb 2008 05:21:22 -0500, Steve Holden wrote: Before you have any code is exactly the *wrong* time to be considering performance. Well, not really. Don't we already tell people don't use repeated string concatenation, because it is slow, even *before* we know whether it is a

Re: returning regex matches as lists

2008-02-16 Thread John Machin
On Feb 16, 8:25 am, Jonathan Lukens [EMAIL PROTECTED] wrote: What would you like to see instead? I had mostly just expected that there was some method that would return each entire match as an item on a list. I have this pattern: import re corporate_names =

Re: Encrypting a short string?

2008-02-16 Thread Lie
On Feb 12, 2:45 am, erikcw [EMAIL PROTECTED] wrote: Hi, I'm trying to devise a scheme to encrypt/obfuscate a short string that basically contains the user's username and record number from the database.  I'm using this encrypted string to identify emails from a user. (the string will be in

TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread Ilias Lazaridis
Essence: * Trac is deficient, cause of proud to be an egoism driven amateur developers * Python and it's communities is excellent for learning. Not programming, but to learn from deficiency, community organization, transparency, efficiency etc.! * Do it in perl, if you need something more

Re: Encrypting a short string?

2008-02-16 Thread Bjoern Schliessmann
Lie wrote: There is a simple encryption, called ROT13 (Rotate 13). This is very unsecure for any cryptographical purpose, For enhanced security use TROT13 (triple ROT13). but enough to make uninformed user to think it's just a random piece of letters. Security by obscurity doesn't work.

Re: returning regex matches as lists

2008-02-16 Thread Jonathan Lukens
John, (1) raw string for improved legibility ru'(?u)\b([á-ñ]{2,}\s+)([][Á-Ñá-ñ]+)(\s*-?[Á-Ñá-ñ]+)*([])' This actually escaped my notice after I had posted -- the letters with diacritics are incorrectly decoded Cyrillic letters -- I suppose I code use the Unicode escape sequences (the sets

Re: sockets -- basic udp client

2008-02-16 Thread [EMAIL PROTECTED]
Here is the example above converted to a more straightforward udp client that isolates the part I am asking about: import socket, sys host = 'localhost' #sys.argv[1] port = 3300 s = socket.socket(socket.AF_INET,

Re: sockets -- basic udp client

2008-02-16 Thread Gabriel Genellina
En Sat, 16 Feb 2008 05:56:39 -0200, 7stud [EMAIL PROTECTED] escribi�: while 1:     buf = s.recv(2048)     if not len(buf):         break     print Received: %s % buf As far as I can tell, the if statement: if not len(buf):    break does nothing.  Either recv() is going to

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread Steve Holden
Ilias Lazaridis wrote: [...] Of course I'll not stay with trac, I'll leave the sinking ship, I've prepare long time ago to do so, step by step. An will migrate step by step away from trac and python - toward an own implementation based on... perl and it's libraries. I'm sure you will find

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread Robert Klemme
On 16.02.2008 13:16, Ilias Lazaridis wrote: snip/ Oh, it's him again. Please do not respond. http://dev.eclipse.org/newslists/news.eclipse.foundation/msg00167.html http://www.encyclopediadramatica.com/index.php/Ilias Cheers robert --

Re: ways to declare empty set variable

2008-02-16 Thread Boris Borcic
Steve Holden wrote: Boris Borcic wrote: [EMAIL PROTECTED] wrote: ...Missing that, I think dict() and set() and tuple() and list() look better than using {} for the empty dict and {/} for the empty set and () for empty tuple (or {} for the empty dict and set() for the empty set). The problem

basic wxpython help

2008-02-16 Thread Vamp4L
Hello, I'm brand new to wxpython, trying to implement some code to add rows in the GUI dynamically. What I want to do is when you click on the Add Row button, a new row gets added after the first row, before the button. This code adds a row in the right place, but it overlaps the button

Re: simple python script to zip files

2008-02-16 Thread T_T
On Sat, 16 Feb 2008 15:37:16 +, T_T wrote: Hi, I'm just starting to learn some Python basics and are not familiar with file handling. Looking for a python scrip that zips files. So aaa.xx bbb.yy ccc.xx should be zipped to aaa.zip bbb.zip ccc.zip I haven't been able to type more

Re: ways to declare empty set variable

2008-02-16 Thread Steve Holden
Boris Borcic wrote: Steve Holden wrote: [...] Before you have any code is exactly the *wrong* time to be considering performance. Yeah right, [] and {} are premature optimizations, one should always use list() or dict() unless one detains figures to justify the more exotic forms :)

Re: copying files through Python

2008-02-16 Thread Lalit Krishna
Hi this is the code which I wrote till now. It is giving permission denied error for sub folders of source directory. Does anyone have any idea what is going wrong import os import shutil def copytreetosinglefolder(src, dst): names = os.listdir(src) if (os.path.isdir(dst)==False): os.mkdir(dst)

Easy PIL question

2008-02-16 Thread Adam W.
I know there is an easy way to do this, but I can't figure it out, how do I get the color of a pixel? I used the ImageGrab method and I want to get the color of a specific pixel in that image. If you know how to make it only grab that pixel, that would also be helpful. Basically I'm trying to

simple python script to zip files

2008-02-16 Thread T_T
Hi, I'm just starting to learn some Python basics and are not familiar with file handling. Looking for a python scrip that zips files. So aaa.xx bbb.yy ccc.xx should be zipped to aaa.zip bbb.zip ccc.zip I haven't been able to type more than 'import gzip'.. Just a script I need for

SOAP strategies

2008-02-16 Thread Paul Watson
What are the reasonable current day choices and best bets for the future when doing SOAP programming in Python? SOAP batteries do not appear to be in the standard Python distribution. Most of the SOAP related information I have been able to find on the web is from 2001-2002. I am not sure if

Re: Easy PIL question

2008-02-16 Thread Gary Herron
Adam W. wrote: I know there is an easy way to do this, but I can't figure it out, how do I get the color of a pixel? I used the ImageGrab method and I want to get the color of a specific pixel in that image. If you know how to make it only grab that pixel, that would also be helpful.

[OT] Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread Jeff Schwab
Ilias Lazaridis wrote: Essence: snipSpam spam spam spam.../snip I just looked at your resume. What is Abstract Project Management? -- http://mail.python.org/mailman/listinfo/python-list

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread Jeff Schwab
Robert Klemme wrote: On 16.02.2008 13:16, Ilias Lazaridis wrote: snip/ Oh, it's him again. Please do not respond. http://dev.eclipse.org/newslists/news.eclipse.foundation/msg00167.html http://www.encyclopediadramatica.com/index.php/Ilias Thank you. I didn't recognize his name at

Re: basic wxpython help

2008-02-16 Thread Mike Driscoll
On Feb 16, 10:04 am, Vamp4L [EMAIL PROTECTED] wrote: Hello, I'm brand new to wxpython, trying to implement some code to add rows in the GUI dynamically. What I want to do is when you click on the Add Row button, a new row gets added after the first row, before the button. This code adds a

Re: Pop-up Menu of a Graphics Image?

2008-02-16 Thread Mike Driscoll
On Feb 15, 2:28 pm, W. Watson [EMAIL PROTECTED] wrote: I want to allow a user who is looking at a graphic to be able to right-click on the graphic to produce a menu of choices. Does the PIL have something, a class or whatever? What in Tkinter would be useful for this purpose? GTK? Jon

Re: simple python script to zip files

2008-02-16 Thread Tim Chase
I'm just starting to learn some Python basics and are not familiar with file handling. Looking for a python scrip that zips files. So aaa.xx bbb.yy ccc.xx should be zipped to aaa.zip bbb.zip ccc.zip I haven't been able to type more than 'import gzip'.. Well, you ask for zip files, but

Re: QOTW: Re: dream hardware

2008-02-16 Thread Aahz
In article [EMAIL PROTECTED], Jeff Schwab [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Feb 14, 10:50 pm, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL PROTECTED] wrote: On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote: What is dream

Re: copying files through Python

2008-02-16 Thread [EMAIL PROTECTED]
On Feb 16, 6:21 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Please use a mailer/news-agent that preserves whitespace on the beginning of the line, and make sure you don't use tabs but spaces to indent. Apart from that - why don't you use shutil.copytree? Regarding the error - are you

How about adding rational fraction to Python?

2008-02-16 Thread Lie
Would all these problems with floating points be a rational reason to add rational numbers support in Python or Py3k? (pun not intended) I agree, there are some numbers that is rationals can't represent (like pi, phi, e) but these rounding problems also exist in floating points, and rational

Is there a way to link a python program from several files?

2008-02-16 Thread Edward A. Falk
IOW, is there a linker for python? I've written a program comprised of about five .py files. I'd like to find a way to combine them into a single executable. Obviously, I could hand-edit them into a single .py file, but I'm looking for a way to keep them as seperate files for development but

Re: QOTW: Re: dream hardware

2008-02-16 Thread Jeff Schwab
Aahz wrote: In article [EMAIL PROTECTED], Jeff Schwab [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Feb 14, 10:50 pm, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL PROTECTED] wrote: On Tue, 12 Feb 2008 10:05:59 -0800, castironpi wrote: What

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread George Sakkis
On Feb 16, 12:15 pm, Jeff Schwab [EMAIL PROTECTED] wrote: Ilias Lazaridis wrote: Essence: snipSpam spam spam spam.../snip I just looked at your resume. What is Abstract Project Management? A branch of Analysis Paralysis Vaporware. -- http://mail.python.org/mailman/listinfo/python-list

Re: copying files through Python

2008-02-16 Thread Diez B. Roggisch
Lalit Krishna schrieb: Hi this is the code which I wrote till now. It is giving permission denied error for sub folders of source directory. Does anyone have any idea what is going wrong import os import shutil def copytreetosinglefolder(src, dst): names = os.listdir(src) if

Re: How about adding rational fraction to Python?

2008-02-16 Thread Jeff Schwab
Lie wrote: Would all these problems with floating points be a rational reason to add rational numbers support in Python or Py3k? (pun not intended) I agree, there are some numbers that is rationals can't represent (like pi, phi, e) but these rounding problems also exist in floating points,

Re: How about adding rational fraction to Python?

2008-02-16 Thread Mark Dickinson
On Feb 16, 1:35 pm, Lie [EMAIL PROTECTED] wrote: Would all these problems with floating points be a rational reason to add rational numbers support in Python or Py3k? (pun not intended) It's already in the trunk! Python will have a rational type (called Fraction) in Python 2.6 and Python 3.0,

Re: simple python script to zip files

2008-02-16 Thread T_T
seems to do the trick for me. -tkc Thanks! Works indeed. Strange thing is though, the files created are the exact size as the original file. So it seems like it is zipping without compression. -- http://mail.python.org/mailman/listinfo/python-list

How do I use SendInput in Python?

2008-02-16 Thread Adam W.
I'm at the last stage of my project and the only thing left to do is trigger a mouse click. I did some searching around for example code and stumped upon SendInput http://msdn2.microsoft.com/en-us/library/ms646310.aspx . However I was not able to find example code for python USING SendInput,

Re: How about adding rational fraction to Python?

2008-02-16 Thread Lie
On Feb 17, 1:40 am, Jeff Schwab [EMAIL PROTECTED] wrote: Lie wrote: Would all these problems with floating points be a rational reason to add rational numbers support in Python or Py3k? (pun not intended) I agree, there are some numbers that is rationals can't represent (like pi, phi, e)

Re: Is there a way to link a python program from several files?

2008-02-16 Thread Diez B. Roggisch
Edward A. Falk schrieb: IOW, is there a linker for python? I've written a program comprised of about five .py files. I'd like to find a way to combine them into a single executable. Obviously, I could hand-edit them into a single .py file, but I'm looking for a way to keep them as

Re: simple python script to zip files

2008-02-16 Thread Tim Chase
Thanks! Works indeed. Strange thing is though, the files created are the exact size as the original file. So it seems like it is zipping without compression. The instantiation of the ZipFile object can take an optional parameter to control the compression. The zipfile module only supports

Re: QOTW: Re: dream hardware

2008-02-16 Thread Jeff Schwab
[EMAIL PROTECTED] wrote: IHNTA, IJWTSA Thanks, but... That defines IHNTA, but not IJWTSA or IJWTW. I just want to say...? I just want to watch?- Hide quoted text - I just want to what? Exactly! -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-02-16 Thread Mark Dickinson
On Feb 16, 1:35 pm, Lie [EMAIL PROTECTED] wrote: Would all these problems with floating points be a rational reason to add rational numbers support in Python or Py3k? (pun not intended) Forgot to give the link: http://docs.python.org/dev/library/fractions.html Mark --

Re: How about adding rational fraction to Python?

2008-02-16 Thread Lie
On Feb 17, 2:26 am, Mark Dickinson [EMAIL PROTECTED] wrote: On Feb 16, 1:35 pm, Lie [EMAIL PROTECTED] wrote: Would all these problems with floating points be a rational reason to add rational numbers support in Python or Py3k? (pun not intended) It's already in the trunk!  Python will have

Re: QOTW: Re: dream hardware

2008-02-16 Thread castironpi
IHNTA, IJWTSA Thanks, but... That defines IHNTA, but not IJWTSA or IJWTW.  I just want to say...?  I just want to watch?- Hide quoted text - I just want to what? -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-02-16 Thread [EMAIL PROTECTED]
On Feb 16, 12:35�pm, Lie [EMAIL PROTECTED] wrote: Would all these problems with floating points be a rational reason to add rational numbers support in Python or Py3k? (pun not intended) I agree, there are some numbers that is rationals can't represent (like pi, phi, e) but these rounding

Re: Easy PIL question

2008-02-16 Thread bearophileHUGS
Gary Herron: Try image.getpixel((x,y)) to retrieve the pixel at (x,y). If the OP needs to access many pixels, then he can use the load() method on the image object, and then read/write pixels (tuples of 3 ints) using getitem [] import Image im = Image img = im.load() img[x,y] = ... ... =

Re: Solve a Debate

2008-02-16 Thread castironpi
On Feb 15, 11:50 pm, Steve Holden [EMAIL PROTECTED] wrote: Dan Bishop wrote: On Feb 15, 10:24 am, nexes [EMAIL PROTECTED] wrote: Alright so me and my friend are having argument. Ok the problem we had been asked a while back, to do a programming exercise (in college) That would tell you

Re: QOTW: Re: dream hardware

2008-02-16 Thread Carl Banks
On Feb 16, 1:39 pm, Jeff Schwab [EMAIL PROTECTED] wrote: Aahz wrote: In article [EMAIL PROTECTED], Jeff Schwab [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Feb 14, 10:50 pm, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL PROTECTED]

Re: simple python script to zip files

2008-02-16 Thread T_T
f = zipfile.ZipFile(zipfilename, 'w', compression=zipfile.ZIP_DEFLATED) -tkc Adding the compression rule works great, thanks again! -- http://mail.python.org/mailman/listinfo/python-list

Re: simple python script to zip files

2008-02-16 Thread John Machin
On Feb 17, 6:52 am, Tim Chase [EMAIL PROTECTED] wrote: Thanks! Works indeed. Strange thing is though, the files created are the exact size as the original file. So it seems like it is zipping without compression. The instantiation of the ZipFile object can take an optional parameter to

Re: Assignment saves time?

2008-02-16 Thread rpglover64
I ran the following in the python shell: import timeit storeit=timeit.Timer('s=len(li);s==1000', 'li=range(1000)') checkit=timeit.Timer('len(li)==1000', 'li=range(1000)') listofresults=[(min(storeit.repeat(5)),min(checkit.repeat(5))) for i in xrange(20)] listofresults contained these

Re: QOTW: Re: dream hardware

2008-02-16 Thread Jeff Schwab
Carl Banks wrote: On Feb 16, 1:39 pm, Jeff Schwab [EMAIL PROTECTED] wrote: Aahz wrote: In article [EMAIL PROTECTED], Jeff Schwab [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Feb 14, 10:50 pm, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Steven D'Aprano [EMAIL

Re: basic wxpython help

2008-02-16 Thread Vamp4L
Thanks Mike, Simple enough! I was wandering about the close method too, I had to hack that together from what I knew about python already. I'll be sure to join that mailing list. -- http://mail.python.org/mailman/listinfo/python-list

Re: copying files through Python

2008-02-16 Thread Tim Chase
OP stated requirements were to move all the files into a single folder. Copytree will preserve the directory structure from the source side of the copy operation. well, it would be copying [not moving] files through Python, but if the desire is to flatten the tree into a single directory,

Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)

2008-02-16 Thread Tad J McClellan
[Followup-To: header set to comp.lang.perl.misc.] Jeff Schwab [EMAIL PROTECTED] wrote: Robert Klemme wrote: On 16.02.2008 13:16, Ilias Lazaridis wrote: snip/ Oh, it's him again. Please do not respond. http://dev.eclipse.org/newslists/news.eclipse.foundation/msg00167.html

Re: How about adding rational fraction to Python?

2008-02-16 Thread Carl Banks
On Feb 16, 3:03 pm, Lie [EMAIL PROTECTED] wrote: Although rationals have its limitations too, it is a much better choice compared to floats/Decimals for most cases. Maybe that's true for your use cases, but it's not true for most cases in general. Rationals are pretty useless for almost any

Re: sockets -- basic udp client

2008-02-16 Thread 7stud
On Feb 16, 6:18 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Here is the example above converted to a more straightforward udp client that isolates the part I am asking about: import socket, sys host =  'localhost'  

Re: sockets -- basic udp client

2008-02-16 Thread 7stud
On Feb 16, 6:32 am, Gabriel Genellina [EMAIL PROTECTED] wrote: That example is plain wrong; looks like some TCP code but with   SOCK_STREAM   blindy replaced with SOCK_DGRAM. connect, sendall and recv are not used   for UDP; sendto and recvfrom are used instead. There are some examples  

Re: Solve a Debate

2008-02-16 Thread John Machin
On Feb 16, 3:48 pm, Dan Bishop [EMAIL PROTECTED] wrote: On Feb 15, 10:24 am, nexes [EMAIL PROTECTED] wrote: Alright so me and my friend are having argument. Ok the problem we had been asked a while back, to do a programming exercise (in college) That would tell you how many days there

RE: Is there a way to link a python program from several files?

2008-02-16 Thread Brian Smith
Diez B. Roggisch wrote: Edward A. Falk schrieb: IOW, is there a linker for python? I've written a program comprised of about five .py files. I'd like to find a way to combine them into a single executable. Obviously, I could hand-edit them into a single .py file, but I'm looking for

An idea for fast function composition

2008-02-16 Thread Arnaud Delobelle
Hi all, Recently there was a thread about function composition in Python (and this was probably not the first). The fast way to create a (anonymous) composite function f1 o f2 o ... o fn in Python is via lambda x: f1(f2(...fn(x)...)), but according to some this is neither the most

Re: How about adding rational fraction to Python?

2008-02-16 Thread Paul Rubin
Carl Banks [EMAIL PROTECTED] writes: Rationals are pretty useless for almost any extended calculations, since the denominator tends to grow in size till it's practically unusbale, which means you have to periodically do non-exact reductions to keep things running, and if you do that you might

Re: How about adding rational fraction to Python?

2008-02-16 Thread Lie
On Feb 17, 4:25 am, Carl Banks [EMAIL PROTECTED] wrote: On Feb 16, 3:03 pm, Lie [EMAIL PROTECTED] wrote: Although rationals have its limitations too, it is a much better choice compared to floats/Decimals for most cases. Maybe that's true for your use cases, but it's not true for most

Re: ways to declare empty set variable

2008-02-16 Thread Steven D'Aprano
On Sat, 16 Feb 2008 11:14:10 -0500, Steve Holden wrote: It's about four years since I wrote a program that ran for more than 24 hours. Let me guess... and then you discovered ''.join(['x', 'y']) instead of 'x'+'y'? *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Solve a Debate

2008-02-16 Thread Steve Holden
[EMAIL PROTECTED] wrote: On Feb 15, 11:50 pm, Steve Holden [EMAIL PROTECTED] wrote: Dan Bishop wrote: On Feb 15, 10:24 am, nexes [EMAIL PROTECTED] wrote: [...] What are everyone else's thoughts on this? days_in_month = lambda m: m - 2 and 30 + bool(1 m 5546) or 28 Elegant, but the 5546 is

class static variables and __dict__

2008-02-16 Thread Zack
If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__', '__doc__': None, 'n': 4} print x.__dict__ {} This behavior makes sense to me as n is not encapsulated in x's namespace but

Re: How about adding rational fraction to Python?

2008-02-16 Thread Jeff Schwab
Carl Banks wrote: On Feb 16, 3:03 pm, Lie [EMAIL PROTECTED] wrote: Although rationals have its limitations too, it is a much better choice compared to floats/Decimals for most cases. Maybe that's true for your use cases, but it's not true for most cases in general. Rationals are pretty

Re: Solve a Debate

2008-02-16 Thread castironpi
days_in_month = lambda m: m - 2 and 31 - ((m + 9) % 12 % 5 % 2) or 28 the guts of which is slightly more elegant than the ancient writing from which it was derived: Lacks citation. -- http://mail.python.org/mailman/listinfo/python-list

Re: class static variables and __dict__

2008-02-16 Thread Diez B. Roggisch
Zack schrieb: If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__', '__doc__': None, 'n': 4} print x.__dict__ {} This behavior makes sense to me as n is not

Video4Linux for [EMAIL PROTECTED]

2008-02-16 Thread Carl K
This would be Off Topic, but it is for PyCon, so there will be lots of Python side effects. I am looking for help with a Video4Linux2 driver, which is C code. I am trying to get a piece of hardware working with trascode. hardware: http://www.epiphan.com/products/product.php?pid=66

Re: An idea for fast function composition

2008-02-16 Thread castironpi
On Feb 16, 3:47 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: Hi all, Recently there was a thread about function composition in Python (and this was probably not the first).  The fast way to create a (anonymous) composite function      f1 o f2 o ... o fn in Python is via      lambda x:

Re: Is there a way to link a python program from several files?

2008-02-16 Thread Diez B. Roggisch
Brian Smith schrieb: Diez B. Roggisch wrote: Edward A. Falk schrieb: IOW, is there a linker for python? I've written a program comprised of about five .py files. I'd like to find a way to combine them into a single executable. Obviously, I could hand-edit them into a single .py file, but

Re: class static variables and __dict__

2008-02-16 Thread Zack
Diez B. Roggisch wrote: Zack schrieb: If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__', '__doc__': None, 'n': 4} print x.__dict__ {} This behavior makes sense to me

RE: Is there a way to link a python program from several files?

2008-02-16 Thread Brian Smith
Diez B. Roggisch wrote: Brian Smith wrote: I would be interested in a program that can combine multiple modules into a single module, which removes all the inter-package imports and fixes other inter-module references, like Haskell All-in-One does for Haskell:

Re: Solve a Debate

2008-02-16 Thread John Machin
On Feb 17, 9:57 am, [EMAIL PROTECTED] wrote: days_in_month = lambda m: m - 2 and 31 - ((m + 9) % 12 % 5 % 2) or 28 the guts of which is slightly more elegant than the ancient writing from which it was derived: Lacks citation. Maxima mea culpa. Pages 294-295 (in particular formula 23.12)

Re: An idea for fast function composition

2008-02-16 Thread castironpi
def compose( funcs ):    def reccompose( *args ):       return compose( funcs[:-1] )( funcs[-1]( *args ) ) if funcs else funcs[0]( *args )    return reccompose- Hide quoted text - Which was, if funcs 1, which is len( funcs ) 1. [1]0 Traceback (most recent call last): File stdin, line 1,

Re: How do I use SendInput in Python?

2008-02-16 Thread Gabriel Genellina
En Sat, 16 Feb 2008 17:08:59 -0200, Adam W. [EMAIL PROTECTED] escribi�: I'm at the last stage of my project and the only thing left to do is trigger a mouse click. I did some searching around for example code and stumped upon SendInput

Re: How about adding rational fraction to Python?

2008-02-16 Thread Carl Banks
On Feb 16, 5:51 pm, Jeff Schwab [EMAIL PROTECTED] wrote: Carl Banks wrote: On Feb 16, 3:03 pm, Lie [EMAIL PROTECTED] wrote: Although rationals have its limitations too, it is a much better choice compared to floats/Decimals for most cases. Maybe that's true for your use cases, but it's

Re: class static variables and __dict__

2008-02-16 Thread Dustan
On Feb 16, 4:40 pm, Zack [EMAIL PROTECTED] wrote: what method can you use on x to find all available attributes for that class? class Foo(object): bar = hello, world! def __init__(self, baz): self.baz = baz x = Foo(42) x.__dict__.keys() # Does not include

Re: Is there a way to link a python program from several files?

2008-02-16 Thread Paul Rubin
Brian Smith [EMAIL PROTECTED] writes: So does Haskell. Haskell All-In-One handles that by renaming every top-level artifact. That can't be done reliably in python because namespaces are dynamic. If it is possible to run an egg as a CGI (without modifying the web server configuration file),

Re: An idea for fast function composition

2008-02-16 Thread Boris Borcic
[EMAIL PROTECTED] wrote: On Feb 16, 3:47 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: Hi all, Recently there was a thread about function composition in Python (and this was probably not the first). The fast way to create a (anonymous) composite function f1 o f2 o ... o fn in

Re: class static variables and __dict__

2008-02-16 Thread Zack
Zack wrote: Diez B. Roggisch wrote: Zack schrieb: If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__', '__doc__': None, 'n': 4} print x.__dict__ {} This behavior

Re: class static variables and __dict__

2008-02-16 Thread Zack
Dustan wrote: On Feb 16, 4:40 pm, Zack [EMAIL PROTECTED] wrote: what method can you use on x to find all available attributes for that class? class Foo(object): bar = hello, world! def __init__(self, baz): self.baz = baz x = Foo(42) x.__dict__.keys() # Does

Re: An idea for fast function composition

2008-02-16 Thread castironpi
On Feb 16, 5:57 pm, Boris Borcic [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Feb 16, 3:47 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: Hi all, Recently there was a thread about function composition in Python (and this was probably not the first).  The fast way to create a

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Steven D'Aprano
On Fri, 15 Feb 2008 17:31:51 -0800, Mark Dickinson wrote: On Feb 15, 7:59 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Fri, 15 Feb 2008 14:35:34 -0500, Steve Holden wrote: I don't understand: why would +INF not be equal to itself? Having INF == INF be True seems

Re: Solve a Debate

2008-02-16 Thread Gabriel Genellina
En Sat, 16 Feb 2008 19:43:37 -0200, John Machin [EMAIL PROTECTED] escribi�: On Feb 16, 3:48 pm, Dan Bishop [EMAIL PROTECTED] wrote: days_in_month = lambda m: m - 2 and 30 + bool(1 m 5546) or 28 Alternatively: days_in_month = lambda m: m - 2 and 31 - ((m + 9) % 12 % 5 % 2) or 28 the

Re: Floating point bug?

2008-02-16 Thread Dan Bishop
On Feb 14, 8:10 pm, Zentrader [EMAIL PROTECTED] wrote: That's a misconception. The decimal-module has a different base (10 instead of 2), and higher precision. But that doesn't change the fact that it will expose the same rounding-errors as floats do - just for different numbers.

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Mark Dickinson
On Feb 16, 7:08 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Fri, 15 Feb 2008 17:31:51 -0800, Mark Dickinson wrote: Not sure that alephs have anything to do with it.  And unless I'm missing something, minus aleph(0) is nonsense. (How do you define the negation of a

Re: class static variables and __dict__

2008-02-16 Thread Dustan
On Feb 16, 5:59 pm, Zack [EMAIL PROTECTED] wrote: Zack wrote: Diez B. Roggisch wrote: Zack schrieb: If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__',

Re: class static variables and __dict__

2008-02-16 Thread Zack
Dustan wrote: On Feb 16, 5:59 pm, Zack [EMAIL PROTECTED] wrote: Zack wrote: Diez B. Roggisch wrote: Zack schrieb: If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__',

  1   2   >