python-colormath 1.0.5 Released

2009-09-29 Thread Greg Taylor
An error in the CIE2000 Delta E equation has been found and corrected, necessitating the immediate release of python-colormath 1.0.5. All users of the 1.x series are encouraged to upgrade to avoid this mathematical error. What new in 1.0.5? === * The examples and unit tests may be ran

Re: Global array in python

2009-09-29 Thread Olof Bjarnason
2009/9/29 rantingrick rantingr...@gmail.com: On Sep 28, 8:04 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Sep 28, 2009 at 5:48 PM, Rudolf yellowblueyel...@gmail.com wrote: How can i declare a global array in python? Python has no concept of declarations. And it doesn't have arrays, it

Re: Global array in python

2009-09-29 Thread Chris Rebert
On Mon, Sep 28, 2009 at 6:55 PM, rantingrick rantingr...@gmail.com wrote: On Sep 28, 8:04 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Sep 28, 2009 at 5:48 PM, Rudolf yellowblueyel...@gmail.com wrote: How can i declare a global array in python? Python has no concept of declarations.

Re: Why the file mode of .pyc files has x?

2009-09-29 Thread greg
Peng Yu wrote: What python/OS are you using? python 2.6.2 and CentOS Just tried 2.6 on Darwin, and it does happen. So looks like 2.6 has been changed to inherit the permission bits from the .py. Makes sense, except that the x bits should really be turned off. -- Greg --

os.listdir unwanted behaviour

2009-09-29 Thread Chris Adamson
Hello, I am writing code that cycles through files in a directory and for each file it writes out another file with info in it. It appears that as I am iterating through the list returned by os.listdir it is being updated with the new files that are being added to the directory. This occurs

Re: os.listdir unwanted behaviour

2009-09-29 Thread Chris Rebert
On Mon, Sep 28, 2009 at 11:03 PM, Chris Adamson chris.adam...@mcri.edu.au wrote: Hello, I am writing code that cycles through files in a directory and for each file it writes out another file with info in it. It appears that as I am iterating through the list returned by os.listdir it is

Re: Repeated output when logging exceptions

2009-09-29 Thread Vinay Sajip
On Sep 28, 9:38 pm, John Gordon gor...@panix.com wrote: If I didn't do all that in a class, where would I do it? You could, for example, use the basicConfig() function to do it all for you. import logging logging.basicConfig(filename='/path/to/my/log',level=logging.DEBUG) logging.debug('This

Re: Why the file mode of .pyc files has x?

2009-09-29 Thread Steven D'Aprano
On Tue, 29 Sep 2009 18:21:09 +1200, greg wrote: Peng Yu wrote: What python/OS are you using? python 2.6.2 and CentOS Just tried 2.6 on Darwin, and it does happen. So looks like 2.6 has been changed to inherit the permission bits from the .py. Makes sense, except that the x bits should

Re: os.listdir unwanted behaviour

2009-09-29 Thread Peter Otten
Chris Adamson wrote: I am writing code that cycles through files in a directory and for each file it writes out another file with info in it. It appears that as I am iterating through the list returned by os.listdir it is being updated with the new files that are being added to the directory.

Re: os.listdir unwanted behaviour

2009-09-29 Thread Steven D'Aprano
On Tue, 29 Sep 2009 16:03:46 +1000, Chris Adamson wrote: Hello, I am writing code that cycles through files in a directory and for each file it writes out another file with info in it. It appears that as I am iterating through the list returned by os.listdir it is being updated with the

[off-topic] Pessimal (was: Detecting changes to a dict)

2009-09-29 Thread John Posner
If you can enumerate the language of possible inputs you could generate a unique binary representation. Against a language of size l that would only take you O(l*n) to build the repr for a dict and for certain repr sizes the comparison could be O(1), making the entire operation O(l*n+l*m) vs

Re: Most active coroutine library project?

2009-09-29 Thread Grant Edwards
On 2009-09-28, Hendrik van Rooyen hend...@microcorp.co.za wrote: On Saturday, 26 September 2009 16:55:30 Grant Edwards wrote: On 2009-09-26, Dave Angel da...@ieee.org wrote: Actually even 64k looked pretty good, compared to the 1.5k of RAM and 2k of PROM for one of my projects, a navigation

Re: custom data warehouse in python vs. out-of-the-box ETL tool

2009-09-29 Thread Jim
On this post, you are talking about Talend and Informatica like both are comparable... indeed both tools are comparable in power and functionality. But keep in mind Informatica is a proprietary solution, with no access to the code. You have a license fee + other costs associated to the use of

Re: Global array in python

2009-09-29 Thread koranthala
On Sep 29, 5:48 am, Rudolf yellowblueyel...@gmail.com wrote: How can i declare a global array in python? As others have mentioned, you do not have concept of declaration. But if you are looking for creating a global variable, it is like any other language. Declare the same in a module, outside

MySQL Matrix manipulation in Python

2009-09-29 Thread Threader Slash
Hello Everybody, My doubt is about matrix data manipulation in python - I hope someone can point me some direction. I googled around, but there is not much good examples about playing with matrix in python on internet. My following function works pretty well, and gives me the outup from my

Re: os.listdir unwanted behaviour

2009-09-29 Thread Piet van Oostrum
Steven D'Aprano ste...@remove.this.cybersource.com.au (SD) wrote: SD What you describe is impossible -- os.listdir() returns an ordinary list, SD it isn't a lazy iterator that updates automatically as the directory SD changes. (At least not in Python2.5 -- I haven't checked Python 3.1.) He's

Re: SQLObject

2009-09-29 Thread CCW
On Sep 28, 9:41 pm, Daniel Fetchinson fetchin...@googlemail.com wrote: I'm new to using SQLObject, and having some problems with getting it to recognise my current MySQL database. I've set up my connection fine, but it won't recognise the names of the columns (presumably because they're

Storing a C pointer in a Python class instance

2009-09-29 Thread lallous
Hello From my C extension module I want to store a C pointer in a given PyObject. The only way I figure how to do it is to use Py_BuildValues and store the poiner casted to Py_ssize_t, thus: Py_BuildValues(n, (Py_ssize_t)my_ptr) Can it be done differently? Regards, Elias --

Re: Passing tuples of tuples to sqlite

2009-09-29 Thread lolmc
On 28 Sep, 17:49, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Mon, 28 Sep 2009 03:35:44 -0700 (PDT), xera121 lolmcbr...@googlemail.com declaimed the following in gmane.comp.python.general: Hi I have tuples in the format shown below:

Re: MySQL Matrix manipulation in Python

2009-09-29 Thread MRAB
Threader Slash wrote: Hello Everybody, My doubt is about matrix data manipulation in python - I hope someone can point me some direction. I googled around, but there is not much good examples about playing with matrix in python on internet. My following function works pretty well, and

Re: os.listdir unwanted behaviour

2009-09-29 Thread Tim Chase
Piet van Oostrum wrote: Steven D'Aprano ste...@remove.this.cybersource.com.au (SD) wrote: SD What you describe is impossible -- os.listdir() returns an ordinary list, SD it isn't a lazy iterator that updates automatically as the directory SD changes. (At least not in Python2.5 -- I haven't

Re: Global array in python

2009-09-29 Thread Jean-Michel Pichavant
Rudolf wrote: How can i declare a global array in python? import __builtin__ __builtin__.myList = [] Now you can use myList everywhere in your code. Note that modifying __builtin__ is **not** recommended at all. I don't have time to detail that point, google it if you want the answer. I

different behaviour for user defined exception with attribute args

2009-09-29 Thread Visco Shaun
Hi all For an exception defined as below class OptionError(Exception): def __init__(self, args): self.args = args def __str__(self): return repr(self.v) an iteration is happening when the exception is raised Meanwhile for almost the same structured exception replacing

Re: different behaviour for user defined exception with attribute args

2009-09-29 Thread M.-A. Lemburg
Visco Shaun wrote: Hi all For an exception defined as below class OptionError(Exception): def __init__(self, args): self.args = args This should read: def __init__(self, *args): self.args = args (notice the * !) self.args holds the constructor argument tuple or

Re: variable scope

2009-09-29 Thread Bruno Desthuilliers
Mark Dickinson a écrit : On Sep 28, 9:37 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Joel Juvenal Rivera Rivera a écrit : Yeah i forgot the self an try the code then i see an error that it was not defines _uno__a so that's where i define the global and see

Re: variable scope

2009-09-29 Thread Mark Dickinson
On Sep 29, 11:11 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Mark Dickinson a écrit : On Sep 28, 9:37 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Looks like a bug to me. I Think you should fill a ticket... I don't think it's a

Restarting IDLE without closing it

2009-09-29 Thread candide
Hi I was wondering if there exists somme way to clear memory of all objects created during a current IDLE session (with the same effect as if one starts an IDLE session). Thanks. -- http://mail.python.org/mailman/listinfo/python-list

How to use variable in a file name

2009-09-29 Thread kks
if myFile variable contains the actual filename then how can i open a file for wirte so that complete filename appears as actualname_kks.txt -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use variable in a file name

2009-09-29 Thread Andre Engels
On Tue, Sep 29, 2009 at 3:35 PM, kks kkis.thek...@gmail.com wrote: if myFile variable contains the actual filename then how can i open a file for wirte so that complete filename appears as actualname_kks.txt open(myFile + _kks.txt, w) -- André Engels, andreeng...@gmail.com --

Re: Using String for new List name

2009-09-29 Thread Hendrik van Rooyen
On Monday, 28 September 2009 18:54:09 Scott wrote: I am new to Python but I have studied hard and written a fairly big (to me) script/program. I have solved all of my problems by Googling but this one has got me stumped. I want to check a string for a substring and if it exists I want to

Re: Using String for new List name

2009-09-29 Thread Peter Otten
Hendrik van Rooyen wrote: On Monday, 28 September 2009 18:54:09 Scott wrote: I am new to Python but I have studied hard and written a fairly big (to me) script/program. I have solved all of my problems by Googling but this one has got me stumped. I want to check a string for a substring and

Re: Idiom for last word in a string

2009-09-29 Thread Scott David Daniels
Grant Edwards wrote: I recently ran across this construct for grabbing the last (whitespace delimited) word in a string: s.rsplit(None,1)[1] ... I've always done this: s.split()[-1] I was wondering what the advantage of the rsplit(None,1)[1] approach would be ... Others have pointed out

Re: Using String for new List name

2009-09-29 Thread nn
On Sep 28, 7:37 pm, Scott scott.freem...@gmail.com wrote: On Sep 28, 2:00 pm, Dave Angel da...@ieee.org wrote: Scott wrote: Thank you fine folks for getting back with your answers! So down the road I do dictname[line42].append(new stuff). (or [var] if I'm looping through the dict)

Re: os.listdir unwanted behaviour

2009-09-29 Thread Hendrik van Rooyen
On Tuesday, 29 September 2009 11:03:17 Tim Chase wrote: I think Steven may be remembering the conversation here on c.l.p a month or two back where folks were asking to turn os.listdir() into an iterator (or create an os.xlistdir() or os.iterdir() function) because directories with lots of

Re: variable scope

2009-09-29 Thread Carl Banks
On Sep 29, 3:11 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Mark Dickinson a écrit : On Sep 28, 9:37 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Joel Juvenal Rivera Rivera a écrit : Yeah i forgot the self an try the code

Re: Restarting IDLE without closing it

2009-09-29 Thread Scott David Daniels
candide wrote: Hi I was wondering if there exists somme way to clear memory of all objects created during a current IDLE session (with the same effect as if one starts an IDLE session). Thanks. Different than Shell / Restart Shell (Ctrl+F6) ? Of course this doesn't work if you started Idle

Split string but ignore quotes

2009-09-29 Thread Scooter
I'm attempting to reformat an apache log file that was written with a custom output format. I'm attempting to get it to w3c format using a python script. The problem I'm having is the field-to-field matching. In my python code I'm using split with spaces as my delimiter. But it fails when it

Re: variable scope

2009-09-29 Thread Bruno Desthuilliers
Carl Banks a écrit : On Sep 29, 3:11 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Mark Dickinson a écrit : (snip) The double underscores and name mangling are a red herring: I beg to disagree. The problem (well... what I think is a problem, actually) IS that

Re: Split string but ignore quotes

2009-09-29 Thread Björn Lindqvist
2009/9/29 Scooter slbent...@gmail.com: I'm attempting to reformat an apache log file that was written with a custom output format. I'm attempting to get it to w3c format using a python script. The problem I'm having is the field-to-field matching. In my python code I'm using split with spaces

Re: create a class instance from C API?

2009-09-29 Thread lallous
Thanks Carl, that does it! -- Elias Carl Banks pavlovevide...@gmail.com wrote in message news:48ce343a-36ef-406f-bea3-851444785...@b18g2000vbl.googlegroups.com... On Sep 28, 8:19 am, lallous lall...@lgwm.org wrote: Hello How to programmatically create a class instance of a given Python

print object attributes recursively

2009-09-29 Thread lallous
Hello Suppose I have this code: class X: def __init__(self, n): self.L = [x for x in xrange(0, n+1)] class Y: def __init__(self, n): self.M = [X(x) for x in xrange(0, n)] t = Y(5) How can I easily print t and all its nested attributes? (Something like PHP's print_r())

two html pages from twisted server

2009-09-29 Thread Mikie
Could soneone show me a simple example of a twisted server that loads 2 html pages www..com:7899/page1/ www..com:7899/page2/ Thanx -- http://mail.python.org/mailman/listinfo/python-list

Simple if-else question

2009-09-29 Thread Sandy
Hi all, A simple and silly if-else question. I saw some code that has the following structure. My question is why else is used there though removing else has the same result. More important, is it not syntactically wrong :-( for i in xrange(8): if i 4: print i else: print i

Re: Split string but ignore quotes

2009-09-29 Thread MRAB
Björn Lindqvist wrote: 2009/9/29 Scooter slbent...@gmail.com: I'm attempting to reformat an apache log file that was written with a custom output format. I'm attempting to get it to w3c format using a python script. The problem I'm having is the field-to-field matching. In my python code I'm

Re: Simple if-else question

2009-09-29 Thread Joel Goldstick
Sandy wrote: Hi all, A simple and silly if-else question. I saw some code that has the following structure. My question is why else is used there though removing else has the same result. More important, is it not syntactically wrong :-( for i in xrange(8): if i 4: print i else:

Re: Simple if-else question

2009-09-29 Thread Gary Herron
Sandy wrote: Hi all, A simple and silly if-else question. I saw some code that has the following structure. My question is why else is used there though removing else has the same result. More important, is it not syntactically wrong :-( for i in xrange(8): if i 4: print i else:

Re: Simple if-else question

2009-09-29 Thread Ethan Furman
Sandy wrote: Hi all, A simple and silly if-else question. I saw some code that has the following structure. My question is why else is used there though removing else has the same result. More important, is it not syntactically wrong :-( for i in xrange(8): if i 4: print i else:

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread Falcolas
On Sep 29, 2:27 am, lallous lall...@lgwm.org wrote: Hello From my C extension module I want to store a C pointer in a given PyObject. The only way I figure how to do it is to use Py_BuildValues and store the poiner casted to Py_ssize_t, thus: Py_BuildValues(n, (Py_ssize_t)my_ptr) Can it

Cannot get POST to work

2009-09-29 Thread tedpot...@gmail.com
Hi, I'm trying to post data to a short test script in php I wrote. The python code to do the post is import httplib #server address conn = httplib.HTTPConnection(localhost) #file location conn.request(POST, /programming/bots/test.php,ted=fred) r1 = conn.getresponse() print r1.status, r1.reason

Re: Cannot get POST to work

2009-09-29 Thread Falcolas
On Sep 29, 10:24 am, tedpot...@gmail.com tedpot...@gmail.com wrote: Hi, I'm trying to post data to a short test script in php I wrote. The python code to do the post is import httplib #server address conn = httplib.HTTPConnection(localhost) #file location conn.request(POST,

How to pass a global variable to a module?

2009-09-29 Thread Mars creature
Dear Python users, I just start to use python and love this language. I met this problem when I try to save my functions in a separate file. The question is how I can pass a global variable to a function which is saved in another file. If I save the function I defined in the same file with the

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread sturlamolden
On 29 Sep, 10:27, lallous lall...@lgwm.org wrote: Hello From my C extension module I want to store a C pointer in a given PyObject. The only way I figure how to do it is to use Py_BuildValues and store the poiner casted to Py_ssize_t, Formally, you should cast the pointer to Py_intptr_t, as

Re: Simple if-else question

2009-09-29 Thread Chris Kaynor
If I'm reading the indentation correctly, the else is applying to the for loop, not the if statement. When used in this way, the else occurs only if the for loop exits due to completion (aka, the for loop does not exit due to a break or return statement). I would expect the output from that

Re: How to pass a global variable to a module?

2009-09-29 Thread Gregor Horvath
Hi, Am Tue, 29 Sep 2009 09:40:29 -0700 (PDT) schrieb Mars creature jin...@gmail.com: I just start to use python and love this language. I met this problem when I try to save my functions in a separate file. The question is how I can pass a global variable to a function which is saved in

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread Carl Banks
On Sep 29, 9:42 am, sturlamolden sturlamol...@yahoo.no wrote: You can use PyCObject, or write your own extension type that wraps the pointer (very easy to to with Cython or Pyrex). The advantage of using an extension type is you have a guarantee from Python on the deallocator method being

Re: os.listdir unwanted behaviour

2009-09-29 Thread Tim Chase
a month or two back where folks were asking to turn os.listdir() into an iterator (or create an os.xlistdir() or os.iterdir() function) because directories with lots of files were causing inordinate slowdown. Yes, listdir() in both 2.x and 3.x both return lists while such a proposed iterator

Re: Simple if-else question

2009-09-29 Thread Carl Banks
On Sep 29, 9:08 am, Gary Herron gher...@islandtraining.com wrote: Sandy wrote: Hi all, A simple and silly if-else question. I saw some code that has the following structure. My question is why else is used there though removing else has the same result. More important, is it not

Re: How python source code in large projects are organized?

2009-09-29 Thread Jonathan Gardner
On Sep 20, 8:19 am, Peng Yu pengyu...@gmail.com wrote: I am wondering what is the best way of organizing python source code in a large projects. There are package code, testing code. I'm wondering if there has been any summary on previous practices. (Sorry for the late reply.) My advice:

Re: Simple if-else question

2009-09-29 Thread MRAB
Ethan Furman wrote: Sandy wrote: Hi all, A simple and silly if-else question. I saw some code that has the following structure. My question is why else is used there though removing else has the same result. More important, is it not syntactically wrong :-( for i in xrange(8): if i 4:

Re: How to pass a global variable to a module?

2009-09-29 Thread Jean-Michel Pichavant
Mars creature wrote: Dear Python users, I just start to use python and love this language. I met this problem when I try to save my functions in a separate file. The question is how I can pass a global variable to a function which is saved in another file. If I save the function I defined in

Re: Simple if-else question

2009-09-29 Thread Duncan Booth
Carl Banks pavlovevide...@gmail.com wrote: Hmm, I wonder if Python should emit a warning if an else is used on a for block with no break inside. I don't think the else can be invoked in any other way. As a bonus it could catch some cases where people mistakenly use it thinking it will

Re: How to pass a global variable to a module?

2009-09-29 Thread Rami Chowdhury
On Tue, 29 Sep 2009 09:40:29 -0700, Mars creature jin...@gmail.com wrote: Dear Python users, I just start to use python and love this language. I met this problem when I try to save my functions in a separate file. The question is how I can pass a global variable to a function which is saved

Remote uptime with win32pdh

2009-09-29 Thread Jamie
I'm new to python and I'm trying to write a script which takes the computer name from the variable 'name' and gets the uptime. What I have so far: query = win32pdh.OpenQuery() counter = win32pdh.AddCounter(query, r'\System\System Up Time') win32pdh.CollectQueryData(query) var1,

Re: Remote uptime with win32pdh

2009-09-29 Thread Jamie
On Sep 29, 1:08 pm, Jamie jamie.iva...@gmail.com wrote: I'm new to python and I'm trying to write a script which takes the computer name from the variable 'name' and gets the uptime. What I have so far:     query = win32pdh.OpenQuery()     counter = win32pdh.AddCounter(query,

Re: Storing a C pointer in a Python class instance

2009-09-29 Thread sturlamolden
On 29 Sep, 19:11, Carl Banks pavlovevide...@gmail.com wrote: CObjects can be passed a C function as a deallocator; this should work as reliably as a custom class deallocator. Carl Banks Except that __del__ prevents cyclic GC. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to pass a global variable to a module?

2009-09-29 Thread Mars creature
On Sep 29, 12:49 pm, Rami Chowdhury rami.chowdh...@gmail.com wrote: On Tue, 29 Sep 2009 09:40:29 -0700, Mars creature jin...@gmail.com wrote: Dear Python users,   I just start to use python and love this language. I met this problem when I try to save my functions in a separate file. The

Re: Split string but ignore quotes

2009-09-29 Thread Simon Forman
On Tue, Sep 29, 2009 at 11:11 AM, Scooter slbent...@gmail.com wrote: I'm attempting to reformat an apache log file that was written with a custom output format. I'm attempting to get it to w3c format using a python script. The problem I'm having is the field-to-field matching. In my python

Re: How to pass a global variable to a module?

2009-09-29 Thread MRAB
Mars creature wrote: On Sep 29, 12:49 pm, Rami Chowdhury rami.chowdh...@gmail.com wrote: On Tue, 29 Sep 2009 09:40:29 -0700, Mars creature jin...@gmail.com wrote: Dear Python users, I just start to use python and love this language. I met this problem when I try to save my functions in a

Re: How to use variable in a file name

2009-09-29 Thread kks
On Sep 29, 9:43 am, Andre Engels andreeng...@gmail.com wrote: On Tue, Sep 29, 2009 at 3:35 PM, kks kkis.thek...@gmail.com wrote: if myFile variable contains the actual filename then how can i open a file for wirte so that complete filename appears as actualname_kks.txt open(myFile +

Re: Remote uptime with win32pdh

2009-09-29 Thread Jamie
On Sep 29, 1:19 pm, Jamie jamie.iva...@gmail.com wrote: On Sep 29, 1:08 pm, Jamie jamie.iva...@gmail.com wrote: I'm new to python and I'm trying to write a script which takes the computer name from the variable 'name' and gets the uptime. What I have so far:     query =

Re: Simple if-else question

2009-09-29 Thread Carl Banks
On Sep 29, 10:38 am, Duncan Booth duncan.bo...@invalid.invalid wrote: Carl Banks pavlovevide...@gmail.com wrote: Hmm, I wonder if Python should emit a warning if an else is used on a for block with no break inside.  I don't think the else can be invoked in any other way.  As a bonus it

Re: How to pass a global variable to a module?

2009-09-29 Thread Terry Reedy
Mars creature wrote: I just start to use python and love this language. I met this problem when I try to save my functions in a separate file. The question is how I can pass a global variable to a function which is saved in another file. This question is somewhat mis-phrased. In Python, one

Re: Restarting IDLE without closing it

2009-09-29 Thread candide
Scott David Daniels a écrit : Different than Shell / Restart Shell (Ctrl+F6) ? Of course this doesn't work if you started Idle ith the -n switch. Thanks for the info : by default on my Ubuntu distrib, IDLE is launched with the -n option ;) Now, all is clear ! --

ARP code

2009-09-29 Thread Nattapong Limprungpattanakit
Hello. I have a problem can not run. I'm not understand. Help me please. How to use and detail ? Thanks. #!/usr/bin/python2.5 import py_net_libs class dissect: def __init__(self,pkt,offset): self.pkt, self.offset = py_net_libs.arp_dissect(pkt,offset) self.next

Re: setting up dynamic descriptors in Python

2009-09-29 Thread brian h
I created a new class for each instance as you suggested and added the descriptor to the class. It worked great. Thanks for the help. Brian Huggins -- http://mail.python.org/mailman/listinfo/python-list

Re: different behaviour for user defined exception with attribute args

2009-09-29 Thread Dave Angel
Visco Shaun wrote: Hi all For an exception defined as below class OptionError(Exception): def __init__(self, args): self.args = args def __str__(self): return repr(self.v) an iteration is happening when the exception is raised snip What is self.v intended to

Re: Re: variable scope

2009-09-29 Thread Dave Angel
Bruno Desthuilliers wrote: (snip) Joel Juvenal Rivera Rivera wrote: Hi i was playing around with my code the i realize of this ### _uno__a = 1 class uno(): __a = 2 def __init__(self): print __a uno() ### and prints 1 snip I beg to disagree. The

Serial connections and threads in a GUI

2009-09-29 Thread Aaron Hoover
I have a wx-based GUI application that I'd like to have read streaming data from a serial port and plot that data using matplotlib and a figure canvas. It's a robotic application where the workflow goes something like this: 1) Connect to robot 2) Configure robot settings 3) Command robot

Re: How to pass a global variable to a module?

2009-09-29 Thread Dave Angel
Mars creature wrote: snip I can understand the point that global variables tends to mess up programs. Assume that I have 10 parameters need to pass to the function. If these parameters are fixed, I can use another module to store these 10 parameters, and import to the module, as suggested by

Re: Serial connections and threads in a GUI

2009-09-29 Thread sturlamolden
On 29 Sep, 23:56, Aaron Hoover ahoo...@eecs.berkeley.edu wrote: how can I allow the thread   access to the connection for reading, but then have it give up control   over the connection when it's done so the main GUI thread can access   the connection again for writing? Protect read/write

Re: How to pass a global variable to a module?

2009-09-29 Thread alex23
Mars creature jin...@gmail.com wrote: Assume that I have 10 parameters need to pass to the function. If these parameters are fixed, I can use another module to store these 10 parameters, and import to the module, as suggested by jean-michel. But what if these 10 parameters will be changed in

Re: Split string but ignore quotes

2009-09-29 Thread BJ Swope
Would the csv module be appropriate? On 9/29/09, Scooter slbent...@gmail.com wrote: I'm attempting to reformat an apache log file that was written with a custom output format. I'm attempting to get it to w3c format using a python script. The problem I'm having is the field-to-field matching.

Re: two html pages from twisted server

2009-09-29 Thread alex23
On Sep 30, 1:30 am, Mikie thephantom6...@hotmail.com wrote: Could soneone show me a simple example of a twisted server that loads 2 html pages www..com:7899/page1/ www..com:7899/page2/ Thanx Hey Mikie, Jp Calderone has been writing a very handy 'Twisted Web in 60 seconds' series,

Re: Most active coroutine library project?

2009-09-29 Thread Hendrik van Rooyen
On Monday, 28 September 2009 16:44:48 Grant Edwards wrote: $10 is pretty expensive for a lot of applications. I bet that processor also uses a lot of power and takes up a lot of board space. If you've only got $2-$3 in the money budget, 200uA at 1.8V in the power budget, and 6mm X 6mm of

Partial directory search question

2009-09-29 Thread chad
I have a directory that contains the following login rc sum _1 _2 _3 _4 What's the sanest way to print out all the files in the directory that start with the underscore? Ie, I just want to list _1, _2, _3, _4. -- http://mail.python.org/mailman/listinfo/python-list

Re: Most active coroutine library project?

2009-09-29 Thread Grant Edwards
On 2009-09-29, Hendrik van Rooyen hend...@microcorp.co.za wrote: On Monday, 28 September 2009 16:44:48 Grant Edwards wrote: $10 is pretty expensive for a lot of applications. I bet that processor also uses a lot of power and takes up a lot of board space. If you've only got $2-$3 in the

Re: Partial directory search question

2009-09-29 Thread Tim Chase
What's the sanest way to print out all the files in the directory that start with the underscore? Ie, I just want to list _1, _2, _3, _4. I'd use a string's join() method to combine the results of a list-comprehension or generator that filtered the output of os.listdir() based on the

Can I make these getters/setters?

2009-09-29 Thread Michael George Lerner
Hi, As part of my GUI, I have lots of fields that people can fill in, defined like this: self.selection = Pmw.EntryField(group.interior(), labelpos='w', label_text='Selection to use: ',

Re: Partial directory search question

2009-09-29 Thread chad
On Sep 29, 7:20 pm, Tim Chase python.l...@tim.thechases.com wrote: What's the sanest way to print out all the files in the directory that start with the underscore? Ie, I just want to list _1, _2, _3, _4. I'd use a string's join() method to combine the results of a list-comprehension or

Re: Partial directory search question

2009-09-29 Thread chad
On Sep 29, 7:52 pm, chad cdal...@gmail.com wrote: On Sep 29, 7:20 pm, Tim Chase python.l...@tim.thechases.com wrote: What's the sanest way to print out all the files in the directory that start with the underscore? Ie, I just want to list _1, _2, _3, _4. I'd use a string's join() method

Re: Serial connections and threads in a GUI

2009-09-29 Thread user
Aaron Hoover wrote: I have a wx-based GUI application that I'd like to have read streaming data from a serial port and plot that data using matplotlib and a figure canvas. It's a robotic application where the workflow goes something like this: 1) Connect to robot 2) Configure robot

Re: Can I make these getters/setters?

2009-09-29 Thread Steven D'Aprano
On Tue, 29 Sep 2009 19:48:51 -0700, Michael George Lerner wrote: I then use self.selection.get_value() and self.selection.set_value(), and those two functions are the only ways in which I care about self.selection. I've never really used properties, getters or setters before. I tried this,

UnboundLocalError with extra code after return

2009-09-29 Thread Rich Healey
I'm trying to write a decorator that causes a function to do nothing if called more than once- the reason for this is trivial and to see if I can (Read- I'm enjoying the challenge, please don't ruin it for me =] ) However I'm getting strange results with Python 2.6.2 on win32. With this code:

Re: Partial directory search question

2009-09-29 Thread Martien Verbruggen
On Tue, 29 Sep 2009 19:09:16 -0700 (PDT), chad cdal...@gmail.com wrote: I have a directory that contains the following login rc sum _1 _2 _3 _4 What's the sanest way to print out all the files in the directory that start with the underscore? Ie, I just want to list _1, _2, _3,

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Rich Healey
On Sep 30, 2:15 pm, Rich Healey healey.r...@gmail.com wrote: I'm trying to write a decorator that causes a function to do nothing if called more than once- the reason for this is trivial and to see if I can (Read- I'm enjoying the challenge, please don't ruin it for me =] ) However I'm

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Chris Rebert
On Tue, Sep 29, 2009 at 9:15 PM, Rich Healey healey.r...@gmail.com wrote: However: def callonce(func):    def nullmethod(): pass    def __():        return func()        func = nullmethod When Python sees this assignment to func as it compiles the __() method, it marks func as a local

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Chris Rebert
On Tue, Sep 29, 2009 at 9:41 PM, Chris Rebert c...@rebertia.com wrote: On Tue, Sep 29, 2009 at 9:15 PM, Rich Healey healey.r...@gmail.com wrote: However: def callonce(func):    def nullmethod(): pass    def __():        return func()        func = nullmethod Additionally, to rebind a

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Albert Hopkins
On Tue, 2009-09-29 at 21:15 -0700, Rich Healey wrote: However: def callonce(func): def nullmethod(): pass def __(): return func() func = nullmethod return ret return __ @callonce def t2(): print T2 called t2() Gives me:

Re: Simple if-else question

2009-09-29 Thread John Yeung
On Sep 29, 1:15 pm, Carl Banks pavlovevide...@gmail.com wrote: Hmm, I wonder if Python should emit a warning if an else is used on a for block with no break inside.  I don't think the else can be invoked in any other way.  As a bonus it could catch some cases where people mistakenly use it

Re: Simple if-else question

2009-09-29 Thread John Yeung
On Sep 29, 1:25 pm, MRAB pyt...@mrabarnett.plus.com wrote: The example that makes it clearest for me is searching through a list for a certain item and breaking out of the 'for' loop if I find it. If I get to the end of the list and still haven't broken out then I haven't found the item, and

  1   2   >