Re: switch

2009-12-09 Thread Carl Banks
On Dec 8, 9:36 pm, Asun Friere wrote: > This code is probably symptomatic of poor design. (Not to mention that > your condition tests).  For which reason python has no 'case' > statement and why no decent OO language should. > > It is a principle of OO design that "an object should know what to do

Re: switch

2009-12-09 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Tue, 08 Dec 2009 21:36:23 -0800, Asun Friere wrote: (snip) It is a principle of OO design that "an object should know what to do itself." Rather running an object though a series of tests, it is better to send the object a message, relying on polymorphism or duck-

problem in freezing python script...

2009-12-09 Thread Jebagnana Das
Hello all, I'm using cxfreeze to freeze the python script in my ubuntu 9.04 machine. Now when i tried to execute the binary in mandriva 2008 the error message is.. File "/usr/local/lib/python3.1/site-packages/cx_Freeze/initscripts/Console3.py", line 27, in File "test.py", line 7,

UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Gabriel Rossetti
Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what I don't get is that it worked on mac os x 10

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Richard Thomas
On Dec 9, 10:17 am, Gabriel Rossetti wrote: > Hello everyone, > > I get this error on python 2.6.1 on mac os x 10.6 : > > UnboundLocalError: local variable '_[1]' referenced before assignment > > here's the code that raises this: > > params = [ self.__formatData(paramProcFunc, query, p) for p in p

Question about 'remote objects'

2009-12-09 Thread Frank Millman
Hi all I am writing a multi-user business/accounting application. It is getting rather complex and I am looking at how to, not exactly simplify it, but find a way to manage the complexity. I have realised that it is logically made up of a number of services - database service with connectio

ANN: London Financial Python Users Group

2009-12-09 Thread Giles Thomas
Hi all, If you're based in or visiting London, and have an interest in using Python for financial software, you might want to come to the next meeting of the London Financial Python Users Group! The time: Monday 14 December 2009 at 7pm The place: MWB Regent Street, Liberty House 222 Regen

Re: relative imports with the __import__ function

2009-12-09 Thread Chris Colbert
On Tue, Dec 8, 2009 at 5:48 PM, Peter Otten <__pete...@web.de> wrote: > Chris Colbert wrote: > >> I have package tree that looks like this: >> >> main.py >> package >> __init__.py >> configuration.ini >> server >> __init__.py >> xmlrpc_server.py >> controller.py

Pydev 1.5.2 Released

2009-12-09 Thread Fabio Zadrozny
Hi All, Pydev 1.5.2 has been released Details on Pydev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: --- * Profile to have much lower memory requirements (especially on code-analysis rebuilds) * Profile for parsing to be

Re: Request for py program to insert space between two characters and saved as text?

2009-12-09 Thread Dave Angel
r0g wrote: Dave Angel wrote: r0g wrote: Dave Angel wrote: r0g wrote: Dennis Lee Bieber wrote: On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old declaimed the following in gmane.comp.python.general: For Kannada project .

Re: In lista infinita?

2009-12-09 Thread Andrea Crotti
On 8 Dic, 18:50, Andreas Waldenburger wrote: > Maybe. But I'm sure it.comp.lang.python might help you better. And from > the looks of it, you seem to have started a similar thread there > (called "Generatori infiniti"). > > Generally, you'll fare better with English (even broken English will be >

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Dave Angel
Gabriel Rossetti wrote: Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what I don't get is tha

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Bruno Desthuilliers
Richard Thomas a écrit : On Dec 9, 10:17 am, Gabriel Rossetti wrote: UnboundLocalError: local variable '_[1]' referenced before assignment That isn't an error that should occur, not least because _[1] isn't a valid name It's an internal identifier used in list comps. Implementation detail

no SPA in poplib?

2009-12-09 Thread Gabriel Rossetti
Hello, I couldn't find SPA in poplib, does anyone know of an alternative implementation? Thanks, Gabriel -- Arimaz SA Ingénieur en Informatique Av. du 24 Janvier 11 Ateliers de la Ville de Renens, Atelier 5 1020 Renens, Switzerland www.arimaz.com www.mydeskfriend.com Mob: +41-(0)79-539-0069 T

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Gabriel Rossetti
Dave Angel wrote: Gabriel Rossetti wrote: Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what

a huge shared read-only data in parallel accesses -- How? multithreading? multiprocessing?

2009-12-09 Thread Valery
Hi all, Q: how to organize parallel accesses to a huge common read-only Python data structure? Details: I have a huge data structure that takes >50% of RAM. My goal is to have many computational threads (or processes) that can have an efficient read-access to the huge and complex data structure.

Re: Question about 'remote objects'

2009-12-09 Thread J Kenneth King
"Frank Millman" writes: > Hi all > > I am writing a multi-user business/accounting application. It is getting > rather complex and I am looking at how to, not exactly simplify it, but find > a way to manage the complexity. > > I have realised that it is logically made up of a number of services

plain text parsing to html (newbie problem)

2009-12-09 Thread João
I apologize for my newbiness but I'm banging my head making this work : ( What change must I made for the tag enforcement being reflected to the 'mail' file? Am I using the WritableObject class correctly? (I'm getting a blank 'mail' file after running the .py script) How can I see the output run in

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Hrvoje Niksic
Richard Thomas writes: > That isn't an error that should occur, not least because _[1] isn't a > valid name. Can you post a full traceback? The name _[n] is used internally when compiling list comprehensions. The name is chosen precisely because it is not an (otherwise) valid identifier. For ex

tkinter photoimage, couldn't recognize image data (PPM)

2009-12-09 Thread Martin P. Hellwig
Hi all, I've tried to display an image with the source being a string but it fails (see below). Is there a way to display PPM without writing it first to a file? Thanks, Martin - snippet - ''' Ubuntu 9.04 64bit, python 3.1 ''' import tkinter DATA="""P3 3 2 255 255 0 0 0 255

More stuff added to ch 2 of my programming intro

2009-12-09 Thread Alf P. Steinbach
Format: PDF http://preview.tinyurl.com/ProgrammingBookP3> The new stuff, section 2.7, is about programs as simulations and handling data, focusing on modeling things. It includes some Python GUI programming. The plan is to discuss containers like lists and dictionaries in perhaps two more

How do I Block Events in wxPython

2009-12-09 Thread Wanderer
I have a wxPython program which does some calculations and displays the results. During these calculations if I click the mouse inside the dialog the program locks up. If I leave the dialog alone the process completes fine. I have tried running the function from a separate dialog with Show Modal an

Re: plain text parsing to html (newbie problem)

2009-12-09 Thread MRAB
João wrote: I apologize for my newbiness but I'm banging my head making this work : ( What change must I made for the tag enforcement being reflected to the 'mail' file? Am I using the WritableObject class correctly? (I'm getting a blank 'mail' file after running the .py script) How can I see the

Re: Question about 'remote objects'

2009-12-09 Thread Diez B. Roggisch
> I am writing a multi-user business/accounting application. It is getting > rather complex and I am looking at how to, not exactly simplify it, but > find a way to manage the complexity. > > I have realised that it is logically made up of a number of services - > database service with connect

Re: Request for py program to insert space between two characters and saved as text?

2009-12-09 Thread r0g
Dave Angel wrote: > > > r0g wrote: >> Dave Angel wrote: >> >>> r0g wrote: >>> Dave Angel wrote: > r0g wrote: > >> Dennis Lee Bieber wrote: >> >> >>> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old >>> >>> decla

Re: How do I Block Events in wxPython

2009-12-09 Thread Philip Semanchuk
On Dec 9, 2009, at 10:42 AM, Wanderer wrote: I have a wxPython program which does some calculations and displays the results. During these calculations if I click the mouse inside the dialog the program locks up. If I leave the dialog alone the process completes fine. I have tried running the f

Re: How do I Block Events in wxPython

2009-12-09 Thread zeph
The wxPython wiki actually has a page on dealing with long running tasks called from event handlers called (surprise surprise): http://wiki.wxpython.org/LongRunningTasks Hint: the second to last example on that page has the clearest example - using a worker thread object to do your DoEfficiency()

Re: How do I Block Events in wxPython

2009-12-09 Thread r0g
Wanderer wrote: > I have a wxPython program which does some calculations and displays > the results. During these calculations if I click the mouse inside the > dialog the program locks up. If I leave the dialog alone the process > completes fine. If anything in your GUI app takes a non trivial le

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Terry Reedy
Gabriel Rossetti wrote: Gabriel Rossetti wrote: I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what I don't g

Re: plain text parsing to html (newbie problem)

2009-12-09 Thread Terry Reedy
João wrote: I apologize for my newbiness but I'm banging my head making this work : ( What change must I made for the tag enforcement being reflected to the 'mail' file? Am I using the WritableObject class correctly? (I'm getting a blank 'mail' file after running the .py script) How can I see the

Re: How do I Block Events in wxPython

2009-12-09 Thread Wanderer
On Dec 9, 11:48 am, r0g wrote: > Wanderer wrote: > > I have a wxPython program which does some calculations and displays > > the results. During these calculations if I click the mouse inside the > > dialog the program locks up. If I leave the dialog alone the process > > completes fine. > > If an

ANN: WHIFF.0.7 += GAE + jQueryUI + internationalization + testdrive = (last beta?)

2009-12-09 Thread Aaron Watters
ANNOUNCING WHIFF [WSGI HTTP Integrated Filesystem Frames] release 0.7 WHIFF INDEX PAGE: http://whiff.sourceforge.net The new release adds many new features, including - Google app engine support with tutorial: http://whiffdoc.appspot.com/docs/W1100_2300.GAEDeploy - jQueryUI interactive w

Re: How do I Block Events in wxPython

2009-12-09 Thread Jeff Peck
Philip Semanchuk wrote: On Dec 9, 2009, at 10:42 AM, Wanderer wrote: I have a wxPython program which does some calculations and displays the results. During these calculations if I click the mouse inside the dialog the program locks up. If I leave the dialog alone the process completes fine. I

Re: subprocess kill

2009-12-09 Thread Nobody
On Mon, 07 Dec 2009 11:04:06 +0100, Jean-Michel Pichavant wrote: > When using shell=True, your process is started in a shell, meaning the > PID of your subprocess is not self.luca.pid, self.luca.pid is the PID of > the shell. This isn't true for a simple command on Unix (meaning a program name

Re: xmlrpc idea for getting around the GIL

2009-12-09 Thread Patrick Stinson
On Wed, Dec 2, 2009 at 7:42 AM, sturlamolden wrote: > On 2 Des, 02:47, Patrick Stinson > wrote: > >> We don't need extension modules, and all we need to do is run some >> fairly basic scripts that make callbacks and use some sip-wrapped >> types. > > Sure, you use SIP but not extension modules...

Sum of the factorial of the digits of a number - wierd behaviour

2009-12-09 Thread SiWi
Dear python community, I've got a wierd problem and I hope you can help me out at it. I wrote the following code to find the Sum of the factorial of the digits of a number (this is for Project Euler 74): def fac(n): x=1 for i in range(2,n+1): x*=i return x t=tuple(fac(n) for n

Re: Sum of the factorial of the digits of a number - wierd behaviour

2009-12-09 Thread SiWi
On Dec 9, 6:36 pm, SiWi wrote: > Dear python community, > I've got a wierd problem and I hope you can help me out at it. > I wrote the following code to find the Sum of the factorial of the > digits of a number (this is for Project Euler 74): > > def fac(n): >     x=1 >     for i in range(2,n+1):

Re: How do I Block Events in wxPython

2009-12-09 Thread Stephen Hansen
On Wed, Dec 9, 2009 at 9:06 AM, Wanderer wrote: > Found another strange bug (Strange to me, anyway). int(0.8 * 10.0) = > 7. Had to change the code to int(0.8 * 10.0 + 0.0001). > > http://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm Floating point math is not precise; if

Re: How decoupled are the Python frameworks?

2009-12-09 Thread mdipierro
Interesting post. I would like to make some comments about design decisions that went into web2py: - For each app Model/View/Controllers/Language Files/Static Files/ Modules/Cron Tasks are stored in separated folders - You can code only the models (no controllers and no view) and you get a fully f

Re: tkinter photoimage, couldn't recognize image data (PPM)

2009-12-09 Thread Terry Reedy
Martin P. Hellwig wrote: Hi all, I've tried to display an image with the source being a string but it fails (see below). Is there a way to display PPM without writing it first to a file? Thanks, Martin - snippet - ''' Ubuntu 9.04 64bit, python 3.1 ''' import tkinter DATA="""P3 3 2

Re: When will Python 3 be fully deployed

2009-12-09 Thread Nobody
On Sun, 06 Dec 2009 22:10:15 +, Edward A. Falk wrote: >>I recently read that many libraries, including Numpy have not been >>ported to Python 3. >> >>When do you think that Python 3 will be fully deployed? > > It will never be fully deployed. There will always be people out there who > haven

Re: switch

2009-12-09 Thread Matt McCredie
hong zhang yahoo.com> writes: > > List, > > Python does not have switch statement. Any other option does similar work? > Thanks for help. > > --henry > > I see a couple of people have mentioned using a dictionary. If the value that you are switching on is a string, or could be made i

Re: When will Python 3 be fully deployed

2009-12-09 Thread Rami Chowdhury
On Wed, Dec 9, 2009 at 09:53, Nobody wrote: > > I'm sure that the Unicode approach works great on Windows, where wchar_t > is so pervasive that Microsoft may as well have just redefined "char" > (even to the point of preferring UTF-16-LE for text files over UTF-8, > ASCII-compatibility be damned).

Re: tkinter photoimage, couldn't recognize image data (PPM)

2009-12-09 Thread Martin P. Hellwig
Terry Reedy wrote: DATA="""P3 3 2 255 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0""" Should the string really have the newlines? Or should this be DATA="""P3\ 3 2\ 255\ 255 0 0 0 255 0 0 0 255\ 255 255 0 255 255 255 0 0 0""" I'

Re: ANN: WHIFF.0.7 += GAE + jQueryUI + internationalization + testdrive = (last beta?)

2009-12-09 Thread Terry Reedy
Aaron Watters wrote: Also the WHIFF documentation is now hosted on Google App Engine at the http://whiffdoc.appspot.com/ domain. When I went there and clicked on the "scatter chart is generated by a straightforward invocation of the standard WHIFF OpenFlashChart middleware: ", Firefox *immed

Re: switch

2009-12-09 Thread Nobody
On Tue, 08 Dec 2009 21:02:44 -0800, Kee Nethery wrote: > I string together a bunch of elif statements to simulate a switch > > if foo == True: > blah > elif bar == True: > blah blah > elif bar == False: > blarg > elif This isn't what would normally be considered a switch (

Re: Brent's variation of a factorization algorithm

2009-12-09 Thread n00m
Being an absolute dummy in Theory of Number for me ***c'est fantastique*** that brent() works =) PS 1. Values of magic parameters c = 11 and m = 137 almost don't matter. Usually they choose c = 2 (what about to run brent() in parallel with different values of "c" waiting for "n" is cracked?) 2. B

Re: attributes, properties, and accessors -- philosophy

2009-12-09 Thread Trevor Dorsey
Back to the subject of good tools. Use an IDE that's intended for python. We started using WingIDE because it had an inline debugger and came with all the nice things like autocomplete etc that things like eclipse or visual studio have. On Wed, Nov 25, 2009 at 8:46 AM, Bruno Desthuilliers wrote

Re: Implementation suggestions for creating a Hierarchical circuit database

2009-12-09 Thread Ask me about System Design
On Dec 9, 9:57 am, nick wrote: > Hi, > > I am writing a personal software that will read circuit design/ > netlist. I will be using the MCNC benchmarks that contain different > types of designs in SPICE netlist format. > > I need some pointers/papers/suggestions on creating a "hierarchical" > netl

Re: When will Python 3 be fully deployed

2009-12-09 Thread Nobody
On Wed, 09 Dec 2009 10:28:40 -0800, Rami Chowdhury wrote: >> But on Unix, it's a square-peg-round-hole situation. > > I dunno, I find it rather useful not to have to faff about with > encoding to/from when working with non-ASCII files (with non-ASCII > filenames) on Linux. For the kind of task I

Re: ANN: WHIFF.0.7 += GAE + jQueryUI + internationalization + testdrive = (last beta?)

2009-12-09 Thread Aaron Watters
On Dec 9, 1:48 pm, Terry Reedy wrote: > Aaron Watters wrote: > > Also the WHIFF documentation is now hosted on Google App > > Engine at thehttp://whiffdoc.appspot.com/domain. > > When I went there and clicked on the "scatter chart is generated by a > straightforward invocation of the standard WHIF

Recommendation for small, fast, Python based web server

2009-12-09 Thread python
I'm looking for a small, simple, fast, Python based web server for a simple, client side application we're building. We don't want to distrubute and support a "real" web server like Apache or Tomcat or depend on the presence of local web server such as IIS. The application in question will service

Re: When will Python 3 be fully deployed

2009-12-09 Thread Rami Chowdhury
On Wed, Dec 9, 2009 at 11:25, Nobody wrote: > On Wed, 09 Dec 2009 10:28:40 -0800, Rami Chowdhury wrote: > >>> But on Unix, it's a square-peg-round-hole situation. >> >> I dunno, I find it rather useful not to have to faff about with >> encoding to/from when working with non-ASCII files (with non-A

Re: Question about 'remote objects'

2009-12-09 Thread Irmen de Jong
On 9-12-2009 13:56, Frank Millman wrote: My first thought was to look into Pyro. It seems quite nice. One concern I had was that it creates a separate thread for each object made available by the server. It doesn't. Pyro creates a thread for every active proxy connection. You can register thous

Re: switch

2009-12-09 Thread Tim Chase
Carl Banks wrote: What if the object is a string you just read from a file? How do you dispatch using polymorphism in that case? This is where I most miss a switch/case statement in Python...I do lots of text-file processing (cellular provider data), so I have lots of code (for each provider

using freeze.py with python3

2009-12-09 Thread Patrick Stinson
Has anyone tried using Python-3.1.1/Tools/freeze/freeze.py with the encodings package? It appears that encodings is required to intialize the interpreter, but PyImport_ImportFrozenModule is failing for the "encodings" module in marshal.c:r_object(), after trying to demarshal an object of type 0. T

Re: switch

2009-12-09 Thread MRAB
Tim Chase wrote: Carl Banks wrote: What if the object is a string you just read from a file? How do you dispatch using polymorphism in that case? [snip] which would nicely change into something like switch row['recordtype']: case '01': phone.international += Decimal(row['inter

Re: Sum of the factorial of the digits of a number - wierd behaviour

2009-12-09 Thread Jon Clements
Even though you've worked it out -- a couple of tips: On Dec 9, 5:39 pm, SiWi wrote: > On Dec 9, 6:36 pm, SiWi wrote: > > > > > Dear python community, > > I've got a wierd problem and I hope you can help me out at it. > > I wrote the following code to find the Sum of the factorial of the > > dig

Perl to Python conversion

2009-12-09 Thread Martin Schöön
First off: I am new here and this is my first post after lurking for quite some time. Second off: I don't know much Python---yet. Problem: I have come across a small open source application that I find quite useful. It does have one major flaw though. Its output is in imperial units. Converting i

Re: a huge shared read-only data in parallel accesses -- How? multithreading? multiprocessing?

2009-12-09 Thread Emile van Sebille
On 12/9/2009 6:58 AM Valery said... Hi all, Q: how to organize parallel accesses to a huge common read-only Python data structure? I have such a structure which I buried in a zope process which keeps it in memory and is accessed through http requests. This was done about 8 years ago, and I

Re: Sum of the factorial of the digits of a number - wierd behaviour

2009-12-09 Thread geremy condra
> numpy/scipy etc... are quite useful for Euler :) I've come to love sympy, personally. > They contain a function to do factorials (and loads more). >>> from math import factorial >>> factorial(5) 120 Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list

Re: switch

2009-12-09 Thread Tim Chase
MRAB wrote: Tim Chase wrote: switch row['recordtype']: case '01': phone.international += Decimal(row['internationalcost']) // optionally a "break" here depending on // C/C++/Java/PHP syntax vs. Pascal syntax which // doesn't have fall-through case '02': ph

Re: plain text parsing to html (newbie problem)

2009-12-09 Thread akean
On Dec 10, 3:59 am, João wrote: > I apologize for my newbiness but I'm banging my head making this work : > ( ... > How can I see the output run in debug mode like in perl? > One method: install ipython (another python shell, but with some useful extra features) and then run the program inside

Re: Perl to Python conversion

2009-12-09 Thread zeph
Python and Perl often have different design idioms - learning to write *well* in a language involves understanding those idioms, and being able to translate between languages involves understanding the source language well enough to understand the intent of the program's code (even if its poorly wr

Re: a huge shared read-only data in parallel accesses -- How? multithreading? multiprocessing?

2009-12-09 Thread Aaron Watters
On Dec 9, 9:58 am, Valery wrote: > Hi all, > > Q: how to organize parallel accesses to a huge common read-only Python > data structure? Use a BTree on disk in a file. A good file system will keep most of the pages you need in RAM whenever the data is "warm". This works for Python or any other p

Re: Perl to Python conversion

2009-12-09 Thread Intchanter / Daniel Fackrell
On Dec 9, 1:33 pm, martin.sch...@gmail.com (Martin Schöön) wrote: > First off: I am new here and this is my first post after > lurking for quite some time. > > Second off: I don't know much Python---yet. > > Problem: I have come across a small open source application > that I find quite useful. It

Python-URL! - weekly Python news and links (Dec 9)

2009-12-09 Thread Cameron Laird
QOTW: "I'm not sure you ever understood what the problem was, or where, but I'm happy you feel like you've solved it." - Marco Mariani http://groups.google.com/group/comp.lang.python/browse_thread/thread/8ec7ad4fcc714538 Python 2.7a1, the first alpha release of the 2.7 series, is availa

Re: Recommendation for small, fast, Python based web server

2009-12-09 Thread Tim Chase
pyt...@bdurham.com wrote: I'm looking for a small, simple, fast, Python based web server for a simple, client side application we're building. I've used WebStack[1] for this in the past. It allows for stand-alone serving as well as plugging nicely into various "real" servers (apache+mod_pyt

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Dave Angel
Gabriel Rossetti wrote: Dave Angel wrote: Gabriel Rossetti wrote: Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p

Re: Request for py program to insert space between two characters and saved as text?

2009-12-09 Thread Dave Angel
r0g wrote: Dave Angel wrote: r0g wrote: Dave Angel wrote: r0g wrote: Dave Angel wrote: r0g wrote: Dennis Lee Bieber wrote: On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old declaimed the

Python-URL! - weekly Python news and links (Dec 9)

2009-12-09 Thread Gabriel Genellina
QOTW: "I'm not sure you ever understood what the problem was, or where, but I'm happy you feel like you've solved it." - Marco Mariani http://groups.google.com/group/comp.lang.python/browse_thread/thread/8ec7ad4fcc714538 Python 2.7a1, the first alpha release of the 2.7 series, i

Re: How do I Block Events in wxPython

2009-12-09 Thread Dave Angel
Wanderer wrote: Found another strange bug (Strange to me, anyway). int(0.8 * 10.0) 7. Had to change the code to int(0.8 * 10.0 + 0.0001). Floating point is intrinsically imprecise. The value 0.8 cannot be exactly represented in IEEE fp notation (binary). One answer is to round() the r

Parsing json where object keys are not quoted?

2009-12-09 Thread Wells
Is there some way to finagle the json module to parse JSON (well, almost JSON) where the object keys are not in quotes? I know it's not 100% valid JSON, but I'm just curious. I don't have control over the data, so I can't make it fit the spec :) -- http://mail.python.org/mailman/listinfo/python-l

Re: Graph library for Python

2009-12-09 Thread Rhodri James
On Wed, 09 Dec 2009 03:47:03 -, geremy condra wrote: On Tue, Dec 8, 2009 at 8:42 PM, Rhodri James wrote: g = Graph( nodes=[Node("a", colour="red"), Node("b", colour="white"), Node("c", colour="blue")], edges=[Edge("a", "b", "ab", weight=2), Edge("a",

Re: Brent's variation of a factorization algorithm

2009-12-09 Thread Irmen de Jong
On 27-11-2009 16:36, n00m wrote: Maybe someone'll make use of it: def gcd(x, y): if y == 0: return x return gcd(y, x % y) def brent(n): [...] [D:\Projects]python brentfactor.py 9 == 27 * 37037037 What gives? Isn't this thing supposed to factor numbers into the pro

Porting pyftpdlib to Python 3.x: question about tarball naming convention

2009-12-09 Thread Giampaolo Rodola'
Hi, I've started the (hard) process of porting pyftpdlib [1] to Python 3. In order to do that I'm working on a separate SVN branch and I plan to maintain two different releases of my software, one for 2.x and another one for 3.x. My doubts are about the naming convention I have to use for the tarb

Re: Recommendation for small, fast, Python based web server

2009-12-09 Thread Daniel Fetchinson
> I'm looking for a small, simple, fast, Python based web server > for a simple, client side application we're building. We don't > want to distrubute and support a "real" web server like Apache or > Tomcat or depend on the presence of local web server such as IIS. > The application in question wil

Re: Parsing json where object keys are not quoted?

2009-12-09 Thread Intchanter / Daniel Fackrell
On Dec 9, 3:51 pm, Wells wrote: > Is there some way to finagle the json module to parse JSON (well, > almost JSON) where the object keys are not in quotes? I know it's not > 100% valid JSON, but I'm just curious. > > I don't have control over the data, so I can't make it fit the spec :) Hopefully

Re: Perl to Python conversion

2009-12-09 Thread Peter Chant
Martin Schöön wrote: > Hence, are there any Perl to Python converters? So far I > have only found bridgekeeper which really is (was?) consultancy. > Apart from that I only find people recommending a manual re-write. > > Any thoughts/recommendations? Voice of almost no experience. I once ran a f

Re: Graph library for Python

2009-12-09 Thread geremy condra
On Wed, Dec 9, 2009 at 6:04 PM, Rhodri James wrote: > On Wed, 09 Dec 2009 03:47:03 -, geremy condra > wrote: > >> On Tue, Dec 8, 2009 at 8:42 PM, Rhodri James >> wrote: >>> >>> g = Graph( >>>   nodes=[Node("a", colour="red"), >>>          Node("b", colour="white"), >>>          Node("c", col

Immediate Help with python program!

2009-12-09 Thread Daniel
i am making a tic-tac-toe game using python. i am pretty new to it, but cant seem to figure this one out. Here is my code: X = "X" O = "O" empty = " " tie = "Tie" squares = 9 def display(): print """Welcome to Tic-Tac-Toe. Player will play against the computer. \nYou will move by

Re: Recommendation for small, fast, Python based web server

2009-12-09 Thread python
Tim, > I've used WebStack[1] for this in the past. It allows for stand-alone serving > as well as plugging nicely into various "real" servers (apache+mod_python, > etc) with a small tweak in how it's configured. Thanks for that recommendation. > I'm not sure what caused the slowness you've exp

Re: Graph library for Python

2009-12-09 Thread Rhodri James
On Wed, 09 Dec 2009 23:42:13 -, geremy condra wrote: On Wed, Dec 9, 2009 at 6:04 PM, Rhodri James wrote: On Wed, 09 Dec 2009 03:47:03 -, geremy condra wrote: g = Graph( nodes={'a':{'colour':'red'}, 'b':{'colour':'white'}, 'c':{'colour':'blue'}},

Re: Recommendation for small, fast, Python based web server

2009-12-09 Thread python
Daniel, > I'm using cherrypy for this purpose, actually together with turbogears 1. My research has constantly pointed back to cherrypy as a tool of choice for building local web servers. My initial impression was that cherrypy was too big and complicated for my simple task. However, I'm going to

Re: Immediate Help with python program!

2009-12-09 Thread Jon Clements
On Dec 9, 11:55 pm, Daniel wrote: > i am making a tic-tac-toe game using python. i am pretty new to it, > but cant seem to figure this one out. > Here is my code: > > X = "X" > O = "O" > empty = " " > tie = "Tie" > squares = 9 > > def display(): >     print """Welcome to Tic-Tac-Toe. Player will p

Re: Graph library for Python

2009-12-09 Thread M.-A. Lemburg
geremy condra wrote: > On Mon, Dec 7, 2009 at 6:28 PM, M.-A. Lemburg wrote: * Graph.__init__ should be able to take a list or set of nodes and edges as initializer >>> >>> The format of this will need to be thought all the way >>> through before being implemented. To date, we haven't

Re: Graph library for Python

2009-12-09 Thread Patrick Laban
On Wed, Dec 9, 2009 at 4:02 PM, Rhodri James wrote: > > Here's a thought: are > > g.add_edge("a", "b", "ab") > > and > > g.add_edge("a", "b", name="ab") > > equivalent? If so, there's no reason not to have both forms of the > initialiser. If not, that weighs against having 'name' as a dictiona

Re: Immediate Help with python program!

2009-12-09 Thread Daniel
On Dec 9, 6:18 pm, Jon Clements wrote: > On Dec 9, 11:55 pm, Daniel wrote: > > > > > i am making a tic-tac-toe game using python. i am pretty new to it, > > but cant seem to figure this one out. > > Here is my code: > > > X = "X" > > O = "O" > > empty = " " > > tie = "Tie" > > squares = 9 > > > d

Re: Immediate Help with python program!

2009-12-09 Thread Intchanter / Daniel Fackrell
On Dec 9, 5:18 pm, Jon Clements wrote: > Someone's homework assignment is overdue/due very soon? And, I don't > believe for a second this is your code. In fact, just searching for > (the obvious Java based) function names leads me to believe you've > 'butchered' it from Java code (do you not th

Re: Graph library for Python

2009-12-09 Thread geremy condra
On Wed, Dec 9, 2009 at 7:02 PM, Rhodri James wrote: > On Wed, 09 Dec 2009 23:42:13 -, geremy condra > wrote: > >> On Wed, Dec 9, 2009 at 6:04 PM, Rhodri James >> wrote: >>> >>> On Wed, 09 Dec 2009 03:47:03 -, geremy condra >>> wrote: > g = Graph(   nodes={'a':{'colour':'red'},

Re: Recommendation for small, fast, Python based web server

2009-12-09 Thread birdsong
On Dec 9, 4:05 pm, pyt...@bdurham.com wrote: > Daniel, > > > I'm using cherrypy for this purpose, actually together with turbogears 1. > > My research has constantly pointed back to cherrypy as a tool of choice > for building local web servers. My initial impression was that cherrypy > was too big

Re: Immediate Help with python program!

2009-12-09 Thread Rhodri James
Ahem. This is a newsgroup/mailing list, not IM. I happen to have seen this within half an hour of you posting it, but that's just luck. Expecting an "immediate" response is unrealistic. Furthermore, this is comp.lang.python, a group right up there in pedantry terms with cam.misc. Wander

web crawler in python

2009-12-09 Thread my name
I'm currently planning on writing a web crawler in python but have a question as far as how I should design it. My goal is speed and maximum efficient use of the hardware\bandwidth I have available. As of now I have a Dual 2.4ghz xeon box, 4gb ram, 500gb sata and a 20mbps bandwidth cap (for now) .

Re: Graph library for Python

2009-12-09 Thread geremy condra
>> Generally, we've tried to discourage people from instantiating >> nodes and edges directly, in favor of having them controlled >> through the graph. Maybe something along the lines of: >> >> g = Graph(nodes=['a', 'b', 'c'], edges=[('a', 'b'), ('a', 'c'), ('b', 'c')]) >> >> ? > > That would work

Re: switch

2009-12-09 Thread Asun Friere
On Dec 9, 5:39 pm, Steven D'Aprano wrote: > On Tue, 08 Dec 2009 21:36:23 -0800, Asun Friere wrote: > > On Dec 9, 4:02 pm, Kee Nethery wrote: > >> I string together a bunch of elif statements to simulate a switch > > >> if foo == True: > >>         blah > >> elif bar == True: > >>         blah bl

Re: Immediate Help with python program!

2009-12-09 Thread MRAB
Daniel wrote: i am making a tic-tac-toe game using python. i am pretty new to it, but cant seem to figure this one out. Here is my code: [snip] You problem is due to your choice of variable names, because '0' looks too much like 'O'. You also don't define 'ask'. -- http://mail.python.org/mailm

Re: switch

2009-12-09 Thread Asun Friere
On Dec 9, 7:08 pm, Carl Banks wrote: > What if the object is a string you just read from a file? > > How do you dispatch using polymorphism in that case? This would be a pertinent question, were I advocating that _all_ switch statements should, or even can, be replaced with "dispatch using polymo

Re: Immediate Help with python program!

2009-12-09 Thread Daniel
On Dec 9, 6:50 pm, MRAB wrote: > Daniel wrote: > > i am making a tic-tac-toe game using python. i am pretty new to it, > > but cant seem to figure this one out. > > Here is my code: > > [snip] > You problem is due to your choice of variable names, because '0' looks > too much like 'O'. > > You als

Re: Graph library for Python

2009-12-09 Thread Bearophile
Robin Becker: > There are already very many implementations eg > > http://code.google.com/p/igraphhttp://www.boost.org/doc/libs/release/libs/graphhttp://ernst-schroeder.uni.lu/Digraph/doc/http://code.google.com/p/python-graphhttp://compbio.washington.edu/~zach/py_graph/doc/html/public/py_graph...

Python for Newbies

2009-12-09 Thread rm
Here is a new tutorial that may be a good starting point for learning Python. http://www.themaemo.com/python-for-newbies/ -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >