Re: problem with mod_python

2008-02-16 Thread Arnaud Delobelle
Pradnyesh Sawant wrote: > Hello, Hi [...] > So, my Q is, is it possible to make mod_python use the same PYTHONPATH as > the python2.5 interpreter? if so, how? You can use the PythonPath directive to set the PYTHONPATH to whatever you want > any other suggestions to solve the above problem are

Re: sockets -- basic udp client

2008-02-16 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Historically, though, the ultimate authority on this kind of stuff is > Richard Stevens and his Unix and TCP/IP books > > I recommend these books if you want to get into network programming. I keep wanting to get that book, but it gets older and o

Re: sockets -- basic udp client

2008-02-16 Thread [EMAIL PROTECTED]
If you don't care about the address of the sender, e.g. you are not going to send anything back, is there an advantage to using recv()? Or, as a matter of course should you always use recvfrom() with udp sockets? I don't know of a reason why you couldn't use recvfrom() all the time, and that is w

Re: Critique of first python code

2008-02-16 Thread Dan Bishop
On Feb 8, 7:30 pm, Zack <[EMAIL PROTECTED]> wrote: >[snip] > > The generators you show here are interesting, and it prodded me on how > to add tuples but at the moment (I'm a python newbie) the generator > seems less readable to me than the alternative. After some input from > Scott David Daniels I

Re: Validating cElementTrees with lxml

2008-02-16 Thread Stefan Behnel
Hi, Ryan K wrote: > If I have a cElementTree.ElementTree (or the one from the Standard > Library), can I use lxml's validation features on it since it > implements the same ElementTree API? Not directly. lxml and cElementTree use different tree models internally, so you can't just apply C-impleme

Re: xmltramp with python2.(4-5)

2008-02-16 Thread John Machin
On Feb 17, 5:40 pm, Pradnyesh Sawant <[EMAIL PROTECTED]> wrote: > Hello, > I have a code snippet which does 'import xmltramp' to parse an xml file > received over the network. Also, I have 2 instances of python, namely > python2.4 and python2.5 on my box. The confusing thing is that the code > work

Re: Validating cElementTrees with lxml

2008-02-16 Thread John Machin
On Feb 17, 3:23 pm, Ryan K <[EMAIL PROTECTED]> wrote: > If I have a cElementTree.ElementTree (or the one from the Standard > Library), can I use lxml's validation features on it since it > implements the same ElementTree API? > I've not used lxml ... the answer depends on whether the lxml validati

xmltramp with python2.(4-5)

2008-02-16 Thread Pradnyesh Sawant
Hello, I have a code snippet which does 'import xmltramp' to parse an xml file received over the network. Also, I have 2 instances of python, namely python2.4 and python2.5 on my box. The confusing thing is that the code works fine with python2.4, but gives the error: ImportError: No module named

Re: Critique of first python code

2008-02-16 Thread John Machin
On Feb 17, 4:42 pm, TerryP <[EMAIL PROTECTED]> wrote: > Tomek Paczkowski wrote: > > You can try to put your code through pylint. It will give you some > > automatic critique. > > There is a pylint !? > > That one is defiantly making my workstation later just for fun hehe. > See if you can find an

Re: Python GUI toolkit

2008-02-16 Thread TerryP
[EMAIL PROTECTED] wrote: > what would be the best python GUI toolkit, it must be cross platform. > > i have tried gtk, but it interface are real bad and its coding was > difficult so i dropped it, > > the only remaining are qt4 and wx, i would like to know if one of these or > any other toolkit

Re: Critique of first python code

2008-02-16 Thread TerryP
Tomek Paczkowski wrote: > You can try to put your code through pylint. It will give you some > automatic critique. > There is a pylint !? That one is defiantly making my workstation later just for fun hehe. -- There seems no plan because it is all plan. -- C.S. Lewis -- http:/

problem with mod_python

2008-02-16 Thread Pradnyesh Sawant
Hello, I have a small program which does 'import hashlib'. This program runs fine with python2.5. But when I try running the same program through mod_python, I get the error: 'ImportError: No module named hashlib' in the apache2 error.log Searching online suggested me to include md5.so or md5modul

Validating cElementTrees with lxml

2008-02-16 Thread Ryan K
If I have a cElementTree.ElementTree (or the one from the Standard Library), can I use lxml's validation features on it since it implements the same ElementTree API? Thanks, Ryan -- http://mail.python.org/mailman/listinfo/python-list

Re: flattening a dict

2008-02-16 Thread Jeff Schwab
Benjamin wrote: > How would I go about "flattening" a dict with many nested dicts > within? The dicts might look like this: > {"mays" : {"eggs" : "spam"}, > "jam" : {"soda" : {"love" : "dump"}}, > "lamba" : 23 > } > I'd like it to put "/" inbetween the dicts to make it a one > dimensional dict and

Re: Help Parsing an HTML File

2008-02-16 Thread Paul McGuire
On Feb 15, 3:28 pm, [EMAIL PROTECTED] wrote: > Hello Python Community, > > It'd be great if someone could provide guidance or sample code for > accomplishing the following: > > I have a single unicode file that has  descriptions of hundreds of > objects. The file fairly resembles HTML-EXAMPLE paste

flattening a dict

2008-02-16 Thread Benjamin
How would I go about "flattening" a dict with many nested dicts within? The dicts might look like this: {"mays" : {"eggs" : "spam"}, "jam" : {"soda" : {"love" : "dump"}}, "lamba" : 23 } I'd like it to put "/" inbetween the dicts to make it a one dimensional dict and look like this: {"mays/eggs" : "

Re: Passing a callable object to Thread

2008-02-16 Thread Benjamin
On Feb 15, 9:31 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2008-02-15 at 19:21 -0800, Benjamin wrote: > > You could type args=tuple("data/w7/"). > > That will produce an 8-tuple containing single-character strings, not a > 1-tuple containing one string. Opps. That iterable thing of stri

Tkinter. Why the Need for a Frame, or no Frame?

2008-02-16 Thread W. Watson
The following two examples are from Grayson's book on Tkinter. He's making a simple dialog with three buttons. In the first example, he does not use the Frame class, but in the second he does. Doesn't the first example need a container? What's the difference here? ==5.1

RE: installing on vista

2008-02-16 Thread Adam Pletcher
I have Python 2.5 and win32 extensions on Vista at work, no problems. I have to ask the obvious question... did you download the right win32 installer? There's different ones for Python 2.4 vs. 2.5, etc. - Adam From: [EMAIL PROTECTED] on behalf of [EMAIL PRO

Re: class static variables and __dict__

2008-02-16 Thread 7stud
On Feb 16, 5:03 pm, Zack <[EMAIL PROTECTED]> wrote: > 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)

Re: How about adding rational fraction to Python?

2008-02-16 Thread Steven D'Aprano
On Sat, 16 Feb 2008 18:21:40 -0800, Carl Banks wrote: > Consider what happens when you add two fractions: > > 1/2 + 1/5 > > To do that, you have to take the LCD of the denomintor, in this case 10, > so you get > > 5/10 + 2/10 = 7/10 > > Now imagine that you're adding a lot of different numbers

Re: Video4Linux for [EMAIL PROTECTED]

2008-02-16 Thread Carl K
Ok, that post was somewhat bleck. Here is a much better version: http://chipy.org/V4l2forPyCon Carl K -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Mark Dickinson
On Feb 16, 9:39 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 16 Feb 2008 17:47:39 -0800, Mark Dickinson wrote: > > I've no clue where your (Steven's) idea that 'all ordinals are surreal > > numbers' came from.  They're totally unrelated. > > Tell that to John Conway.

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Steven D'Aprano
On Sat, 16 Feb 2008 17:47:39 -0800, Mark Dickinson wrote: > I've no clue where your (Steven's) idea that 'all ordinals are surreal > numbers' came from. They're totally unrelated. Tell that to John Conway. [quote] Just as the *real* numbers fill in the gaps between the integers, the *surreal*

Re: How about adding rational fraction to Python?

2008-02-16 Thread Carl Banks
On Feb 16, 7:54 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > 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 > bette

installing on vista

2008-02-16 Thread [EMAIL PROTECTED]
Hi, I just got a new computer with windows vista, big mistake, I install python 2.4 ok, but the win32 package keeps saying it cannot find the python instaltion in the registry, help! -Ted -- http://mail.python.org/mailman/listinfo/python-list

Re: Solve a Debate

2008-02-16 Thread Steve Holden
John Machin wrote: > On Feb 17, 11:11 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> 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 &

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

2008-02-16 Thread Ilias Lazaridis
On 16 Φεβ, 15:45, Steve Holden <[EMAIL PROTECTED]> wrote: > 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 implementat

Re: How about adding rational fraction to Python?

2008-02-16 Thread [EMAIL PROTECTED]
On Feb 16, 6:50�pm, Carl Banks <[EMAIL PROTECTED]> wrote: > 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 f

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Mark Dickinson
On Feb 16, 7:30 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > The real line, considered as a topological space, has limit points. > Two of them. Ignore that. It was nonsense. A better statement: the completion (in the sense of lattices) of the real numbers is (isomorphic to) the doubly-extende

Re: Solve a Debate

2008-02-16 Thread John Machin
On Feb 17, 11:11 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > 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 > > > Alter

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

2008-02-16 Thread Ilias Lazaridis
On 16 Φεβ, 19:15, Jeff Schwab <[EMAIL PROTECTED]> wrote: > Ilias Lazaridis wrote: > > Essence: > > Spam spam spam spam... > > I just looked at your resume. http://lazaridis.com/resumes/lazaridis.html (need to update it, lot's of irrelevant stuff, should focus on my failures) > What is Abstract P

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

2008-02-16 Thread Ilias Lazaridis
On 16 Φεβ, 15:45, Robert Klemme <[EMAIL PROTECTED]> wrote: > On 16.02.2008 13:16, Ilias Lazaridis wrote: > > > > Oh, it's him again. Please do not respond. > > http://dev.eclipse.org/newslists/news.eclipse.foundation/msg00167.html Thanks, nice message, I've added it to the section: http://case.

Re: How about adding rational fraction to Python?

2008-02-16 Thread Jeff Schwab
Carl Banks wrote: > 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 t

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 ca

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.

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

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

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

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 T

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 t

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

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

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

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 f

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

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 ca

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 > http://msdn2.microsoft.com/en-us/library/ms6463

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 "", li

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 formul

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: > > http://www

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

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

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

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 http://www.tra

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 n

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

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 w

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

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

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 m

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 c

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

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

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 so

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: 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: 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: >> >> >> >> Oh, it's him again. Please do not respond. >> >> http://dev.eclipse.org/newslists/news.eclipse.foundation/msg00167.htm

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

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 contain

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

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

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] = ... ... = im

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 roundi

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

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 -- http://mail.python.o

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

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

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

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.

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

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 s

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

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 d

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

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

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 numbe

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

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

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 fil

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

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

  1   2   >