Re: Python-URL! - weekly Python news and links (Nov 17)

2008-11-19 Thread Daniel Fetchinson
>> > One of the reasons I would like to formulate a good >> > model of an object's value and type is so that I could >> > try to offer something better. Responses like yours >> > are significantly demotivating. >> >> And yet you argue when people try to explain to you that objects don't >> *have*

Re: python vs smalltalk 80

2008-11-19 Thread Erik Max Francis
Lawrence D'Oliveiro wrote: gavino wrote: which is nicer? If I were to lock you and INTERCAL in a room until only one is left alive, who do you think would survive? The rest of us. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-19 Thread Antoon Pardon
On 2008-11-19, greg <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> Call by value is officially defined in terms of assignment in >> a context where assignments means copying and in a definition >> of a specifix language. >> >> You can't lift this part out of the definition of algol 60 >> and

Re: Will MySQLdb, the Python shim, be supported for Python 2.6 or 3.x?

2008-11-19 Thread Tino Wildenhain
Hi, Dennis Lee Bieber wrote: ... I'm not any heavy user -- but if it means anything... I finally converted my home machine from 2.4 to 2.5 only a few months ago! (My work machine is still running 2.4). Converted? You can install and run more then one Python version in parallel. (Of c

Re: regular expressions ... slow

2008-11-19 Thread Kay Schluehr
On 18 Nov., 18:47, Stefan Behnel <[EMAIL PROTECTED]> wrote: > Kay Schluehr wrote: > > All of this is prototyped in Python and it is still work in progress. > > As long as development has not reached a stable state I refuse to > > rebuild the system in an optimized C version. > > And rightfully so:

Re: Python bytecode STORE_NAME

2008-11-19 Thread Peter Otten
[EMAIL PROTECTED] wrote: > As part of some research I am doing a Python Virtual Machine in Java, > and the exact semantics of the STORE_NAME bytecode is unclear to be, > so I was hoping somebody here could clarify it. > The STORE_NAME bytecode is supposed to set a value for a name in the > current

Re: compressed serialization module

2008-11-19 Thread Nick Craig-Wood
greg <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > (Note that basic pickle protocol is likely to be more compressible > > than the binary version!) > > Although the binary version may be more compact to > start with. It would be interesting to compare the > two and see which one wins

Re: Sieve of Zakiya

2008-11-19 Thread Mark Dickinson
On Nov 19, 5:16 am, jzakiya <[EMAIL PROTECTED]> wrote: [Lots of stuff snipped] > My SoZ mathematical analysis shows why its algorithmically faster than > both the SoA & SoE, to explain its demonstrated computational > superiority. Again, hopefully professional mathematicians will become > intereste

Possible bug in Tkinter for Python 2.6

2008-11-19 Thread Eric Brunel
Hello all, I'm trying out Python 2.6 and I found what might be a bug in the Tkinter module. How can I report it? The possible bug is a traceback when trying to delete a menu item in a menu where no items have associated commands. For example: -- from Tkinter im

Re: Possible bug in Tkinter for Python 2.6

2008-11-19 Thread Jeremiah Dodds
On Wed, Nov 19, 2008 at 4:57 AM, Eric Brunel <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm trying out Python 2.6 and I found what might be a bug in the Tkinter > module. How can I report it? > > The possible bug is a traceback when trying to delete a menu item in a menu > where no items have ass

Re: Non blocking socket server and storage engine

2008-11-19 Thread Lawrence D'Oliveiro
kdeveloper wrote: > The server needs to run at least three threads: Get it working without threading first. -- http://mail.python.org/mailman/listinfo/python-list

Re: Non blocking socket server and storage engine

2008-11-19 Thread kdeveloper
On Nov 19, 10:51 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > kdeveloper wrote: > > The server needs to run at least three threads: > > Get it working without threading first. Lawrence, I was following article [1] when building my code. So I guess it should be ok. A

Re: sorting list of complex numbers

2008-11-19 Thread Hrvoje Niksic
Terry Reedy <[EMAIL PROTECTED]> writes: > Do your tuple destructuring in the first statement in your body and > nothing will break. Unless you were using a lambda, which is quite useful as argument to "sort". -- http://mail.python.org/mailman/listinfo/python-list

Re: Non blocking socket server and storage engine

2008-11-19 Thread kdeveloper
On Nov 19, 10:57 am, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > Quoting from Wikipedia (http://en.wikipedia.org/wiki/User_Datagram_Protocol): > "UDP does not guarantee reliability or ordering in the way that TCP > does. Datagrams may arrive out of order, ***appear duplicated***, or > go missing w

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-19 Thread jhermann
c.execute("select * from stocks") for s in list(c): print s[0] c.execute("select * from stocks where price<20") for sp in c: print ' '+sp[0] c.close() The simple addition of list() should do away with the dependency on mysql's implementation, since it forces the instant fetch of al

Re: Python 3.0 - is this true?

2008-11-19 Thread Duncan Grisby
In article <[EMAIL PROTECTED]>, Martin v. Löwis <[EMAIL PROTECTED]> wrote: >> The sorting is in a performance-critical part of the system, so the >> overhead of evaluating a key function is not insignificant. > >Can you easily produce an example? It doesn't have to be real data, >but should have t

Re: Identifying unicode punctuation characters with Python regex

2008-11-19 Thread jhermann
> >>> P=P.replace('\\','').replace(']','\\]')   # escape both of them. re.escape() does this w/o any assumptions by your code about the regex implementation. -- http://mail.python.org/mailman/listinfo/python-list

Re: unittest exits

2008-11-19 Thread jhermann
On 13 Nov., 20:20, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > try: >     unittest.main() > except SystemExit: >     pass You most probably want this instead: try: unittest.main() except SystemExit, exc: # only exit if tests failed if exc.code: raise --

Re: Non blocking socket server and storage engine

2008-11-19 Thread Chris Rebert
On Wed, Nov 19, 2008 at 2:36 AM, kdeveloper <[EMAIL PROTECTED]> wrote: > Hello Pythonists, > > I am building a non blocking socket server for incomming UDP packets. > The server needs to run at least three threads: > 1. getting data and pushing to "some" storage (at the moment I use > queue), > 2.

Re: Programming exercises/challenges

2008-11-19 Thread Jeremiah Dodds
On Wed, Nov 19, 2008 at 7:12 AM, Mr. SpOOn <[EMAIL PROTECTED]> wrote: > On Wed, Nov 19, 2008 at 2:39 AM, Mensanator <[EMAIL PROTECTED]> wrote: > > What > requisites should have the host to run python code? > > Thanks and sorry for the meddling. > -- > http://mail.python.org/mailman/listinfo/pytho

Inheriting frozenset gives bug if i overwrite __repr__ method

2008-11-19 Thread srinivasan srinivas
Hi, I am getting an error while executing the following snippet. If i comment out method __repr__ , it works fine. class fs(frozenset):     def __new__(cls, *data):     data = sorted(data)     self = frozenset.__new__(cls, data)     self.__data = data     return self     def __re

Re: Programming exercises/challenges

2008-11-19 Thread greg
On Nov 18, 6:39 pm, [EMAIL PROTECTED] wrote: > Hi guys, > > I'm learning Python by teaching myself, and after going through several > tutorials I feel like I've learned the basics. Since I'm not taking a > class or anything, I've been doing challenges/programs to reinforce the > material and improv

Re: Programming exercises/challenges

2008-11-19 Thread Jeremiah Dodds
On Wed, Nov 19, 2008 at 7:44 AM, Mr. SpOOn <[EMAIL PROTECTED]> wrote: > On Wed, Nov 19, 2008 at 1:35 PM, Jeremiah Dodds > <[EMAIL PROTECTED]> wrote: > > > > Personally, I prefer a host that gives me root on a box (or virtual > > machine). I've had a great time with slicehost (http://slicehost.com)

Re: Programming exercises/challenges

2008-11-19 Thread Mr . SpOOn
On Wed, Nov 19, 2008 at 1:50 PM, Jeremiah Dodds <[EMAIL PROTECTED]> wrote: > If you need to do it on the extremely cheap, you can host on your own > machine on a port other than 80, make sure your router / firewall is > forwarding the port to your machine, and use dyndns (http://dyndns.com) to > gi

Re: Possible bug in Tkinter for Python 2.6

2008-11-19 Thread Anton Vredegoor
On Wed, 19 Nov 2008 10:57:53 +0100 "Eric Brunel" <[EMAIL PROTECTED]> wrote: > I'm trying out Python 2.6 and I found what might be a bug in the > Tkinter module. How can I report it? maybe here: http://bugs.python.org/issue3774 > The possible bug is a traceback when trying to delete a menu item

Re: Programming exercises/challenges

2008-11-19 Thread Mr . SpOOn
On Wed, Nov 19, 2008 at 1:35 PM, Jeremiah Dodds <[EMAIL PROTECTED]> wrote: > > Personally, I prefer a host that gives me root on a box (or virtual > machine). I've had a great time with slicehost (http://slicehost.com). Yes, I knew about slicehost, but it is expensive for what I need to do, that i

Re: compressed serialization module

2008-11-19 Thread Tino Wildenhain
Hi, greg wrote: Mark wrote: Thanks guys. This is for serializing to disk. I was hoping to not have to use too many intermediate steps You should be able to use a gzip.GzipFile or bz2.BZ2File and pickle straight into it. also: import codecs out=codecs.open("picklefile.bz2",mode="wb",enc

Re: regular expressions ... slow

2008-11-19 Thread Lawrence D'Oliveiro
Uwe Schmitt wrote: > Are there any plans to speed up Pythons regular expression module ? > Or > is the example in this artricle too far from reality ??? -- http://mail.python.org/mailman/listinfo/python-list

Getting fractional part from a float without using string operations

2008-11-19 Thread srinivasan srinivas
Thanks, Srini Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/ -- http://mail.python.org/mailman/listinfo/python-list

Non blocking socket server and storage engine

2008-11-19 Thread kdeveloper
Hello Pythonists, I am building a non blocking socket server for incomming UDP packets. The server needs to run at least three threads: 1. getting data and pushing to "some" storage (at the moment I use queue), 2. acknowledge the package received 3. retrieve the information from the storage and in

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Jeremiah Dodds
On Wed, Nov 19, 2008 at 8:35 AM, srinivasan srinivas < [EMAIL PROTECTED]> wrote: > Thanks, > Srini > > > Add more friends to your messenger and enjoy! Go to > http://messenger.yahoo.com/invite/ > -- > http://mail.python.org/mailman/listinfo/python-list > x = 2.99340584 y = abs(int(x) - x) y

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-19 Thread Rick Giuly
Thanks to all for your replies All things considered, I vote for evaluating the arguments at runtime (each time the function is called). Good reasons for this have already been mentioned so I won't repeat them. A programming language is a user interface of sorts. (Pretty much all languages are log

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread John Machin
On Nov 20, 12:35 am, srinivasan srinivas <[EMAIL PROTECTED]> wrote: | >>> import math | >>> num = 123.4567 | >>> math.modf(num) | (0.456699789, 123.0) -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoiding local variable declarations?

2008-11-19 Thread Mark Wooding
greg <[EMAIL PROTECTED]> wrote: > I've only ever seen "identity element" in English mathematics. > "Neutral element" sounds like something my car's gearbox > might have... I've encountered both. I think `neutral element' is more common when dealing with the possibility that it might not be uniqu

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread srinivasan srinivas
Yes. But it didn't give only the expected decimals. For ex: >>> a = 1.23 >>> abs(int(a) -a) 0.22998 I would like to get the result '0.23' only. Thanks, Srini From: Jeremiah Dodds <[EMAIL PROTECTED]> To: python-list@python.org Sent: Wednesday, 19 No

Re: file tell in a for-loop

2008-11-19 Thread Tim Chase
Magdoll wrote: I was trying to map various locations in a file to a dictionary. At first I read through the file using a for-loop, but tell() gave back weird results, so I switched to while, then it worked. The for-loop version was something like: d = {} for line

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread MRAB
On Nov 19, 1:44 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Nov 20, 12:35 am, srinivasan srinivas <[EMAIL PROTECTED]> > wrote: > > > | >>> import math > | >>> num = 123.4567 > | >>> math.modf(num) > | (0.456699789, 123.0) def frac(n): return n - int(n) -- http://mail.python.org/ma

Re: wildcard match with list.index()

2008-11-19 Thread Sion Arrowsmith
jeff <[EMAIL PROTECTED]> wrote: list >[['a', [], []], ['b', [1, 2], []], ['c', [3, 4], [5, 6]]] list.index(['b',[],[]]) > >ie, would like to match the second element in the list with something >where i just know 'b' is the first element, but have no idea what the >other elements will be:

Re: Programming exercises/challenges

2008-11-19 Thread Mr . SpOOn
On Wed, Nov 19, 2008 at 2:39 AM, Mensanator <[EMAIL PROTECTED]> wrote: > Another hobby I have is tracking movie box-office receipts > (where you can make interesting graphs comparing Titanic > to Harry Potter or how well the various sequels do, if Pierce > Brosnan saved the James Bond franchise, wh

Re: How to deal with globals during refactoring classes into separate files.

2008-11-19 Thread r0g
r0g wrote: > Hi There, > > I'm refactoring some old code that uses global variables and was > originally written in one big flat file with a view to nicening it up > and then extending it. The problem I have though is when I move the Hi Chris / Gabriel, Thanks v.much, that's really helped my un

Re: Exception difference 2.4 ==> 2.5

2008-11-19 Thread D'Arcy J.M. Cain
On Wed, 19 Nov 2008 01:57:37 -0500 Ross Ridge <[EMAIL PROTECTED]> wrote: > D'Arcy J.M. Cain <[EMAIL PROTECTED]> wrote: > >Under Python 2.4 this works fine. If an exception is raised in the > >looked up method it gets handled by this code just fine. Under 2.5, > >however, the exception is not caug

Re: Inheriting frozenset gives bug if i overwrite __repr__ method

2008-11-19 Thread Mark Dickinson
On Nov 19, 12:39 pm, srinivasan srinivas <[EMAIL PROTECTED]> wrote: > a1 = fs(1,2,3) > a2 = fs(3,4,5) > print a1.difference(a2) > > Error: >     return "%s(%r)" % (self.__class__.__name__, self.__data) > AttributeError: 'fs' object has no attribute '_fs__data' I guess you need to implement the dif

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Tino Wildenhain
srinivasan srinivas wrote: Yes. But it didn't give only the expected decimals. For ex: >>> a = 1.23 >>> abs(int(a) -a) 0.22998 I would like to get the result '0.23' only. well, thats what get stored internally - there is no way around it if you are using floating point numbers:

Re: how to acces the block inside of a context manager as sourcecode

2008-11-19 Thread Daniel
Hi Aaron, let me give you the reason for the context manager: I am driving handware with a python script, basically a data acquisition program which looks like this: with dataStore('measurement1.dat') as d: magnet.setField(0) r1=doExperiment(voltage=0.345, current=0.346, temperat

More elegant way to try running a function X times?

2008-11-19 Thread Gilles Ganault
Hello As a newbie, it's pretty likely that there's a smarter way to do this, so I'd like to check with the experts: I need to try calling a function 5 times. If successful, move on; If not, print an error message, and exit the program: = success = None for i in range(5): #Try to fet

Re: More elegant way to try running a function X times?

2008-11-19 Thread Tim Chase
I need to try calling a function 5 times. If successful, move on; If not, print an error message, and exit the program: success = None for i in range(5): #Try to fetch public IP success = CheckIP() if success: break if not success: print "Exiting."

Re: Programming exercises/challenges

2008-11-19 Thread Philip Semanchuk
On Nov 19, 2008, at 7:12 AM, Mr.SpOOn wrote: On Wed, Nov 19, 2008 at 2:39 AM, Mensanator <[EMAIL PROTECTED]> wrote: Another hobby I have is tracking movie box-office receipts (where you can make interesting graphs comparing Titanic to Harry Potter or how well the various sequels do, if Pierce

Re: More elegant way to try running a function X times?

2008-11-19 Thread Sion Arrowsmith
Gilles Ganault <[EMAIL PROTECTED]> wrote: >As a newbie, it's pretty likely that there's a smarter way to do this, >so I'd like to check with the experts: > >I need to try calling a function 5 times. If successful, move on; If >not, print an error message, and exit the program: > >= >success =

Re: More elegant way to try running a function X times?

2008-11-19 Thread Nicholas Ferenc Fabry
On Nov 19, 2008, at 09:09, Gilles Ganault wrote: Hello As a newbie, it's pretty likely that there's a smarter way to do this, so I'd like to check with the experts: I need to try calling a function 5 times. If successful, move on; If not, print an error message, and exit the program: = s

wxPython BoxSizer

2008-11-19 Thread Jamie McQuay
Simple question, i just can't make it work. I need to center a StaticText component in its parent (Panel). I want to do this with BoxSizer(s). if i use: box = wx.BoxSizer(wx.VERTICAL) #or wx.HORIZONTAL box.Add(myText,0,wx.ALIGN_CENTER) parentPanel.Sizer = box i can get it to center either ver

Re: Python bytecode STORE_NAME

2008-11-19 Thread schwarz
On 19 Nov., 10:14, Peter Otten <[EMAIL PROTECTED]> wrote: > > Every code object has its own co_names attribute (a tuple). The arguments > are offsets into that tuple. > > Using Python 2.5 I can't reproduce your example, I get 0 offsets in both > cases. Here's a simpler one: > > >>> import dis > >>>

Re: More elegant way to try running a function X times?

2008-11-19 Thread Gilles Ganault
On 19 Nov 2008 14:37:06 + (GMT), Sion Arrowsmith <[EMAIL PROTECTED]> wrote: >Note very carefully that the "else" goes with the "for" and not the "if". Thanks guys. -- http://mail.python.org/mailman/listinfo/python-list

Re: redirecting stdout/err to mysql table

2008-11-19 Thread pruebauno
On Nov 18, 2:07 pm, n00b <[EMAIL PROTECTED]> wrote: > greetings, > > i need to log to the db directly and wrote a little script to do so. > since i'm pretty new to python, > i was wondering if a) you could review the enclosed code and b) > provide suggestions to harden to code to turn it into a mor

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-19 Thread George Sakkis
On Nov 19, 8:41 am, Rick Giuly <[EMAIL PROTECTED]> wrote: > Python provides, for the most part, an *excellent* user > interface to the programmer. Why not make it even "better" > by evaluating the arguments each time the function is called? > It will be harder to change the language 10 years from

Why is try...except in my code not working (gzip/text files) ?

2008-11-19 Thread Barak, Ron
Hi, I need to read a file that is either a gzip or a text file (on both *nix and Windows). Since I didn't find a way to determine a file type, I thought of using the following: import gzip FILE = "../dpm/save_state-ssp8400-F0023209_080723-110131/top.1" #FILE = "../dpm/save_state-ssp8400-F00232

Python image library issue: domain users cannot save files?

2008-11-19 Thread [EMAIL PROTECTED]
Hi, Has anyone try to use PIL in a windows domain environment? I am having a permission issue. If I am a domain user, even I have the permission to write a folder, when I tried to do simple things like Image.open ("foo.tif").save("bar.tif"), i am getting exception IOError ("0", "Error"). I tried to

XML -> Tab-delimited text file (using lxml)

2008-11-19 Thread Gibson
I'm attempting to do the following: A) Read/scan/iterate/etc. through a semi-large XML file (about 135 mb) B) Grab specific fields and output to a tab-delimited text file The only problem I'm having is that the tab-delimited text file requires a different order of values than which appear in the X

Re: redirecting stdout/err to mysql table

2008-11-19 Thread Aleksandar Radulovic
On Tue, Nov 18, 2008 at 7:07 PM, n00b <[EMAIL PROTECTED]> wrote: > greetings, > > i need to log to the db directly and wrote a little script to do so. > since i'm pretty new to python, > i was wondering if a) you could review the enclosed code and b) > provide suggestions to harden to code to turn

Re: Python bytecode STORE_NAME

2008-11-19 Thread Peter Otten
[EMAIL PROTECTED] wrote: > On 19 Nov., 10:14, Peter Otten <[EMAIL PROTECTED]> wrote: >> >> Every code object has its own co_names attribute (a tuple). The arguments >> are offsets into that tuple. >> >> Using Python 2.5 I can't reproduce your example, I get 0 offsets in both >> cases. Here's a sim

Re: XML -> Tab-delimited text file (using lxml)

2008-11-19 Thread Stefan Behnel
Gibson wrote: > I'm attempting to do the following: > A) Read/scan/iterate/etc. through a semi-large XML file (about 135 mb) > B) Grab specific fields and output to a tab-delimited text file > [...] > out = open('output.txt','w') > cat = etree.parse('catalog.xml') Use iterparse() instead of pa

Re: More elegant way to try running a function X times?

2008-11-19 Thread George Sakkis
On Nov 19, 10:21 am, Gilles Ganault <[EMAIL PROTECTED]> wrote: > On 19 Nov 2008 14:37:06 + (GMT), Sion Arrowsmith > > <[EMAIL PROTECTED]> wrote: > >Note very carefully that the "else" goes with the "for" and not the "if". > > Thanks guys. And if you end up doing this for several different fun

Re: python vs smalltalk 80

2008-11-19 Thread Grant Edwards
On 2008-11-19, gavino <[EMAIL PROTECTED]> wrote: > python vs smalltalk 80 > > which is nicer? Yes. -- Grant Edwards grante Yow! ... I want to perform at cranial activities with visi.com

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-19 Thread Terry Reedy
Steven D'Aprano wrote: On Tue, 18 Nov 2008 15:55:10 -0500, Terry Reedy wrote: To me, that distortion of his (and my) point is silly. 0 partipipates in numerous integer operations, whereas None participates in no NoneType operations. (Neither has attributes.) And that is the difference he is

Re: Inheriting frozenset gives bug if i overwrite __repr__ method

2008-11-19 Thread Gabriel Genellina
En Wed, 19 Nov 2008 11:56:28 -0200, Mark Dickinson <[EMAIL PROTECTED]> escribió: On Nov 19, 12:39 pm, srinivasan srinivas <[EMAIL PROTECTED]> wrote: a1 = fs(1,2,3) a2 = fs(3,4,5) print a1.difference(a2) Error:     return "%s(%r)" % (self.__class__.__name__, self.__data) AttributeError: 'fs'

Re: Exception difference 2.4 ==> 2.5

2008-11-19 Thread D'Arcy J.M. Cain
On Tue, 18 Nov 2008 22:33:35 -0800 "Chris Rebert" <[EMAIL PROTECTED]> wrote: > What happens under Python 2.6? Interesting. I installed 2.6 and tried it. My unit test still failed but for a different reason that I will have to investigate but the exceptions were handled correctly. Does this sugg

Re: python vs smalltalk 80

2008-11-19 Thread Jason Scheirer
On Nov 18, 10:53 pm, gavino <[EMAIL PROTECTED]> wrote: > python vs smalltalk 80 > > which is nicer? I thought this was comp.lang.colorforth. WHAT IS GOING ON? -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting list of complex numbers

2008-11-19 Thread Terry Reedy
Hrvoje Niksic wrote: Terry Reedy <[EMAIL PROTECTED]> writes: Do your tuple destructuring in the first statement in your body and nothing will break. Unless you were using a lambda, which is quite useful as argument to "sort". So write a separate def statement. If you do not want to do that,

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Blind Anagram
"MRAB" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Nov 19, 1:44 pm, John Machin <[EMAIL PROTECTED]> wrote: On Nov 20, 12:35 am, srinivasan srinivas <[EMAIL PROTECTED]> wrote: | >>> import math | >>> num = 123.4567 | >>> math.modf(num) | (0.456699789, 123.0) def fra

broken setuptools dependencies

2008-11-19 Thread Mac
I just tried to set up a Windows box as a client talking to a MySQL database on Linux using Python. So I installed the most recent version of Python (2.6) and then I tried to add the MySQLdb module. There wasn't any binary pre-built for Python 2.6 on Windows (or any other OS), so I pulled down the

Re: Python 3.0 - is this true?

2008-11-19 Thread Terry Reedy
Duncan Grisby wrote: Sorry for the delay in replying. Yes, that's not far off. Most of the time the lists contain strings, though. A better approximation might be to read lines from a file and randomly replace them with Nones: l = [] for line in open("bigfile.txt"): x = random.randint(0,10

Re: file tell in a for-loop

2008-11-19 Thread Magdoll
Gotcha. Thanks! Magdoll On Nov 19, 2:57 am, Tim Chase <[EMAIL PROTECTED]> wrote: > Magdoll wrote: > > I was trying to map various locations in a file to a dictionary. At > > first I read through the file using a for-loop, buttell() gave back > > weird results, so I switched to while, then it work

Re: python vs smalltalk 80

2008-11-19 Thread Pierre-Alain Dorange
gavino <[EMAIL PROTECTED]> wrote: > python vs smalltalk 80 > > which is nicer? 1st clue : Python got less letters in its name. 2nd clue : 80 is the year of the release of Alan Vega/Martin Rev album 3rd clue : Smalltalk began with an S, but Python with a P -- Pierre-Alain Dorange Ce message es

Re: zope vs openACS

2008-11-19 Thread [EMAIL PROTECTED]
On Nov 19, 1:50 am, gavino <[EMAIL PROTECTED]> wrote: > what is nicer about each? Yes. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheriting frozenset gives bug if i overwrite __repr__ method

2008-11-19 Thread Terry Reedy
srinivasan srinivas wrote: Hi, I am getting an error while executing the following snippet. If i comment out method __repr__ , it works fine. class fs(frozenset): def __new__(cls, *data): data = sorted(data) self = frozenset.__new__(cls, data) self.__data = data

Re: sorting list of complex numbers

2008-11-19 Thread Hrvoje Niksic
Terry Reedy <[EMAIL PROTECTED]> writes: > Hrvoje Niksic wrote: >> Terry Reedy <[EMAIL PROTECTED]> writes: >> >>> Do your tuple destructuring in the first statement in your body and >>> nothing will break. >> >> Unless you were using a lambda, which is quite useful as argument to >> "sort". > > So

Re: wxPython BoxSizer

2008-11-19 Thread Mike Driscoll
Hi Jamie, On Nov 19, 9:16 am, Jamie McQuay <[EMAIL PROTECTED]> wrote: > Simple question, i just can't make it work. > > I need to center a StaticText component in its parent (Panel).  I want > to do this with BoxSizer(s). > > if i use: > box = wx.BoxSizer(wx.VERTICAL)   #or wx.HORIZONTAL > box.Add

Re: Programming exercises/challenges

2008-11-19 Thread Mr . SpOOn
On Wed, Nov 19, 2008 at 3:41 PM, Philip Semanchuk <[EMAIL PROTECTED]> wrote: > I'm not sure why you'd need to host the Python code anywhere other than your > home computer. If you wanted to pull thousands of pages from a site like > that, you'd need to respect their robots.txt file. Don't forget to

Re: PEP 324 error

2008-11-19 Thread Terry Reedy
Andrew wrote: It appears PEP 324 is missing the part about check_call(): http://www.python.org/dev/peps/pep-0324/ ... ... In the docstring of subprocess in python 2.5: ... I don't know if check_call is going to be deprecated, but there still appears to be a missing function. I'm not sure i

python template: may help at starting a new script

2008-11-19 Thread Stephane Bulot
Hello, I've created a python script template that I've been using for a while, but that I improved recently. This script is a class that you can inherit into your main class. In the source package, you have a main template, a thread template, and two example files. If you are interested in this p

Re: wxPython BoxSizer

2008-11-19 Thread Jamie McQuay
> > Try the style=wx.CENTER like this: > > box.Add(myText,0,wx.CENTER) tried but i still get the same result. The text is either at the top of the panel (centered) or in the middle (on the left side). If i manually call CenterOnParent when the panel is resized it goes to the center but i want t

Re: XML -> Tab-delimited text file (using lxml)

2008-11-19 Thread Gibson
On Nov 19, 11:03 am, Stefan Behnel <[EMAIL PROTECTED]> wrote: > > Use iterparse() instead of parsing the file into memory completely. > > *stuff* > > Stefan That worked wonders. Thanks a lot, Stefan. So, iterparse() uses an iterate -> parse method instead of parse() and iter()'s parse -> iterate

Re: python vs smalltalk 80

2008-11-19 Thread George Sakkis
On Nov 19, 1:53 am, gavino <[EMAIL PROTECTED]> wrote: > python vs smalltalk 80 > > which is nicer? Dunno but there's an interesting talk about this: http://www.youtube.com/watch?v=oHg5SJYRHA0 -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheriting frozenset gives bug if i overwrite __repr__ method

2008-11-19 Thread Mark Dickinson
On Nov 19, 4:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > Yep; looks like a bug in the set/frozenset implementation. Thanks! I was about to report this to bugs.python.org, but it looks as though Raymond's been at the time machine again: http://bugs.python.org/issue1721812 It's fixed

Quick nested loop syntax?

2008-11-19 Thread Johannes Bauer
Hi group, if I remember correctly, wasn't there a way to quickly iterate through nested loops? Something like a = { "a", "b", "c" } b = { 4, 9, 13} for (x, y) in someoperator(a, b): print(x, y) which would print all tuples of "a", 4 "a", 9 "a", 13 "b", 4 "b", 9 "b", 13 "c", 4 "c", 9 "c",

Re: Possible bug in Tkinter for Python 2.6

2008-11-19 Thread Terry Reedy
Anton Vredegoor wrote: On Wed, 19 Nov 2008 10:57:53 +0100 "Eric Brunel" <[EMAIL PROTECTED]> wrote: I'm trying out Python 2.6 and I found what might be a bug in the Tkinter module. How can I report it? maybe here: http://bugs.python.org/issue3774 The fix will be in 2.6.1, which might be in D

wxPython Crashes with basic example

2008-11-19 Thread Samuel Morhaim
Hi, I am trying to run the basic wxpython example as seen here http://www.zetcode.com/wxpython/firststeps/ and everytime i run it, it crashes python/wxpython .. meaning it doesnt close gracefully. The error I get is Problem signature: Problem Event Name: APPCRASH Application Name: pythonw.exe

Re: Quick nested loop syntax?

2008-11-19 Thread Mark Dickinson
On Nov 19, 5:48 pm, Johannes Bauer <[EMAIL PROTECTED]> wrote: > Hi group, > > if I remember correctly, wasn't there a way to quickly iterate through > nested loops? Something like Python 2.6 has itertools.product: http://docs.python.org/library/itertools.html#itertools.product If you don't have

Re: Finding the instance reference of an object

2008-11-19 Thread Douglas Alan
greg <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: >> At least some sections of the Java community seem to prefer a >> misleading and confusing use of the word "value" over clarity and >> simplicity, but I for one do not agree with them. > I don't see anything inherently confusing or misl

Re: Quick nested loop syntax?

2008-11-19 Thread Terry Reedy
Johannes Bauer wrote: Hi group, if I remember correctly, wasn't there a way to quickly iterate through nested loops? Something like a = { "a", "b", "c" } b = { 4, 9, 13} for (x, y) in someoperator(a, b): print(x, y) from itertools import product a = { "a", "b", "c" } b = { 4, 9, 13} f

Re: wxPython BoxSizer

2008-11-19 Thread Jamie McQuay
> > > FYI: There's a great wxPython mailing list too. Check it out > > here:http://wxpython.org/maillist.php > > thanks, i will take a look. Here is the answer i got from the mailing list (and it works) Try adding a spacer on both sides of text. i.e) box.AddStretchSpacer() box.Add(myText, 0, w

Re: Finding the instance reference of an object

2008-11-19 Thread Joe Strout
On Nov 19, 2008, at 11:05 AM, Douglas Alan wrote: Personally, I find this whole debate kind of silly, as it is based on a completely fallacious either/or dichotomy. (1) It is unarguably true that Python and Java use a type of call-by-value. This follows from the standard definition of ca

Re: Quick nested loop syntax?

2008-11-19 Thread Vlastimil Brom
2008/11/19 Johannes Bauer <[EMAIL PROTECTED]> > Hi group, > > if I remember correctly, wasn't there a way to quickly iterate through > nested loops? Something like > > a = { "a", "b", "c" } > b = { 4, 9, 13} > for (x, y) in someoperator(a, b): >print(x, y) > > which would print all tuples

Re: wxPython BoxSizer

2008-11-19 Thread Mike Driscoll
On Nov 19, 12:22 pm, Jamie McQuay <[EMAIL PROTECTED]> wrote: > > > FYI: There's a great wxPython mailing list too. Check it out > > > here:http://wxpython.org/maillist.php > > > thanks, i will take a look. > > Here is the answer i got from the mailing list (and it works) > > Try adding a spacer on

Re: wxPython Crashes with basic example

2008-11-19 Thread Benjamin Kaplan
On Wed, Nov 19, 2008 at 12:51 PM, Samuel Morhaim <[EMAIL PROTECTED]>wrote: > Hi, I am trying to run the basic wxpython example as seen here > http://www.zetcode.com/wxpython/firststeps/ and everytime i run it, it > crashes python/wxpython .. meaning it doesnt close gracefully. > The error I get is

GzipFile as a Context manager

2008-11-19 Thread Mikolai Fajer
Is there a reason that the gzip.GzipFile class does not have __enter__ and __exit__ methods that mimic those of the file object? I expected the following to work but it doesn't: import gzip with gzip.open('temp.gz', 'w') as fhandle: gzip.write('Hello world.') If there is no reason to avoid t

Re: Avoiding local variable declarations?

2008-11-19 Thread Arnaud Delobelle
greg <[EMAIL PROTECTED]> writes: > Arnaud Delobelle wrote: > >> Neutral element is correct. But maybe its use is limited to >> mathematicians in the english-speaking word. > > I've only ever seen "identity element" in English mathematics. > "Neutral element" sounds like something my car's gearbox

calling python scripts as a sub-process

2008-11-19 Thread Catherine Moroney
I have one script (Match1) that calls a Fortran executable as a sub-process, and I want to write another script (Match4) that spawns off several instances of Match1 in parallel and then waits until they all finish running. The only way I can think of doing this is to call it as a sub-process, ra

Re: Programming exercises/challenges

2008-11-19 Thread Stef Mientki
hi Ben, [EMAIL PROTECTED] wrote: Hi guys, I'm learning Python by teaching myself, and after going through several tutorials I feel like I've learned the basics. Since I'm not taking a class or anything, I've been doing challenges/programs to reinforce the material and improve my skills. I st

Re: calling python scripts as a sub-process

2008-11-19 Thread Philip Semanchuk
On Nov 19, 2008, at 2:03 PM, Catherine Moroney wrote: The command (stored as an array of strings) that I'm executing is: ['python ../src_python/Match1.py ', '-- file_ref=MISR_AM1_GRP_ELLIPSOID_GM_P228_O003571_BF_F03_0024.hdf ', '--file_cmp=MISR_AM1_GRP_ELLIPSOID_GM_P228_O003571_DF_F03_0024.

Re: calling python scripts as a sub-process

2008-11-19 Thread Dan Upton
On Wed, Nov 19, 2008 at 2:13 PM, Philip Semanchuk <[EMAIL PROTECTED]> wrote: > > On Nov 19, 2008, at 2:03 PM, Catherine Moroney wrote: > >> The command (stored as an array of strings) that I'm executing is: >> >> ['python ../src_python/Match1.py ', >> '--file_ref=MISR_AM1_GRP_ELLIPSOID_GM_P228_O003

  1   2   >