Re: How to display unicode with the CGI module?

2007-11-26 Thread greg
paul wrote: However, this will change in py3k..., what's the new rule of thumb? In py3k, the str type will be what unicode is now, and there will be a new type called bytes for holding binary data -- including text in some external encoding. These two types will not be compatible. At the

Re: better way to write this function

2007-11-26 Thread Peter Otten
Kelie wrote: Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what pythonic means yet. def divide_list(lst, n): Divide a list into a number of lists, each with n items. Extra items are

Re: How to display unicode with the CGI module?

2007-11-26 Thread greg
coldpizza wrote: I am always confused as to which one to use: encode() or decode(); In unicode land, an encoding is a method of representing unicode data in an external format. So you encode unicode data in order to send it into the outside world, and you decode it in order to turn it back into

Re: basic if stuff- testing ranges

2007-11-26 Thread Peter Otten
Donn Ingle wrote: x in range(1,20) ? Sure, that's okay, but it has clarity issues, and is calling a func. and it requires that x is integral (1.0 is in the range, 1.001 is not), and becomes dog slow when the range gets larger. Not a good idea. Peter --

Re: better way to write this function

2007-11-26 Thread Chris
On Nov 26, 9:42 am, Kelie [EMAIL PROTECTED] wrote: Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what pythonic means yet. def divide_list(lst, n): Divide a list into a number of lists,

Re: Installing modules via setuptools in a script

2007-11-26 Thread Thorsten Kampe
* Ben Finney (Mon, 26 Nov 2007 09:04:51 +1100) Thorsten Kampe [EMAIL PROTECTED] writes: * Robert Kern (Sat, 24 Nov 2007 16:33:37 -0600) Thorsten Kampe wrote: can anyone give me a short code snippet how to install a missing module via setuptools (assuming setuptools is already

Re: How to Teach Python Variables

2007-11-26 Thread greg
none wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. If you're talking to C programmers, just tell them that Python variables always contain pointers. That should give them the right

Tk 8.5

2007-11-26 Thread Ron Provost
Hello, According to the tk wiki, the final release of Tcl/Tk is just weeks away (see http://wiki.tcl.tk/12753). Does anyone know if the Tk enhancements will be in Python 2.6? Since I don't use tk but I do use Python and Tkinter (and Tix) extensively, I'm excited about these long-awaited

Re: better way to write this function

2007-11-26 Thread Paul Rubin
Chris [EMAIL PROTECTED] writes: for i in range(int(round((len(lst)/n),0))): ... Ugh!!! Not even correct (under future division), besides being ugly. I think you mean: for i in xrange(len(lst) // n): ... Really though, this grouping function gets reimplemented so often that it should be

Re: How to Teach Python Variables

2007-11-26 Thread Simon Brunning
On Nov 25, 2007 6:19 PM, @bag.python.org none wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? Perhaps you mean: http://effbot.org/zone/python-objects.htm

Re: i want to know what is the problem in this code

2007-11-26 Thread Bruno Desthuilliers
nani a écrit : i am getting the following error for below code (snip) C:\Program Files\Apache Group\Apache2\cgi-bin\hello.py in () 7 8 val = cgi.FieldStorage() 9 name = val[name].value (snip) type 'exceptions.KeyError': 'name' Obviously there's no 'name' argument in the

Re: better way to write this function

2007-11-26 Thread Chris
On Nov 26, 10:51 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Chris [EMAIL PROTECTED] writes: for i in range(int(round((len(lst)/n),0))): ... Ugh!!! Not even correct (under future division), besides being ugly. I think you mean: for i in xrange(len(lst) // n): ... Really

Re: better way to write this function

2007-11-26 Thread Paul Rudin
Kelie [EMAIL PROTECTED] writes: Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what pythonic means yet. def divide_list(lst, n): Divide a list into a number of lists, each with n items.

Re: How to Teach Python Variables

2007-11-26 Thread Hrvoje Niksic
greg [EMAIL PROTECTED] writes: none wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. If you're talking to C programmers, just tell them that Python variables always contain pointers.

Re: Installing modules via setuptools in a script

2007-11-26 Thread Robert Kern
Thorsten Kampe wrote: * Robert Kern (Sat, 24 Nov 2007 16:33:37 -0600) Thorsten Kampe wrote: can anyone give me a short code snippet how to install a missing module via setuptools (assuming setuptools is already installed)?! Something like this: try: import missing_module except

Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread Ravi Kumar
Hi, First of all, since this is my first mail to Python-List, I want to say Hello world! After that; I am stuck in a project. Actually I am writing a module (for testing now), which takes URL, parses it, finds which modules and then which method to call or which class to initiate and which string

Re: basic if stuff- testing ranges

2007-11-26 Thread Donn Ingle
The output of the following program might help: Hey, nifty! Thanks Paddy. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread Donn Ingle
Well, I don't know all the answers, but you can start here: def boobs(): print Oohh little birds! b=boobs eval(b)() Ohhh little birds! Naturally, eval is going to run anything... Even code to format your drive. HTH \d -- http://mail.python.org/mailman/listinfo/python-list

Re: How to display unicode with the CGI module?

2007-11-26 Thread paul
greg schrieb: paul wrote: However, this will change in py3k..., what's the new rule of thumb? [snipp] So you won't be able to get away with ignoring encoding issues in py3k. On the plus side, it should all be handled in a much more consistent and less error-prone way. If you mistakenly

regex and IGNORECASE

2007-11-26 Thread Yann Le Boulanger
Hi all, I have a problem with regex , utf-8 chars and IGNORECASE re.search(u'é', u'qwért', re.IGNORECASE) _sre.SRE_Match object at 0x2ed0c100 Here everything is ok. re.search(u'É', u'qwért', re.IGNORECASE) Here that doesn't work. but: print u'é'.upper() É is it a bug in IGNORECASE

C pointer representation in python

2007-11-26 Thread abarun22
Hi I am new to SWIG and python. I have a problem while trying to call a C function from Python using SWIG as an interface. The function is defined as follows. void* myfunc(TfichierDLR *fichier, char *nom, char *type, char *txt, char *classe, TicThemeDLR *icTheme, int **num, int *ier) The last

Re: regex and IGNORECASE

2007-11-26 Thread John Machin
On Nov 26, 9:53 pm, Yann Le Boulanger [EMAIL PROTECTED] wrote: Hi all, I have a problem with regex , utf-8 chars and IGNORECASE re.search(u'é', u'qwért', re.IGNORECASE) _sre.SRE_Match object at 0x2ed0c100 Here everything is ok. re.search(u'É', u'qwért', re.IGNORECASE) Here that

[announce] WARPY, Nov. 29, Warsaw, Poland

2007-11-26 Thread Jarek Zgoda
I'm pleased to announce the first WARsaw PYthoneers meeting which will be held Nov. 29 at 7 p.m. on Politechnika Warszawska, 15/19 Nowowiejska st., Warsaw, Poland. More information (in Polish) can be found at http://7thguard.net/news.php?id=5721 and in an announcement made on pl.comp.lang.python.

Re: how to change current working directory while using pdb within emacs

2007-11-26 Thread du yan ning
On Nov 21, 1:28 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: duyanningwrote: I have written a pyhton script that will process data file in current working directory. My script is in an different directory to data file. When I debug this script using pdb within emacs, emacs will change

Add speller to Python application

2007-11-26 Thread helzer
I need to add spell checking to my Python application (for Windows). Any ideas on where to start? Thanks, Helzer -- http://mail.python.org/mailman/listinfo/python-list

Re: Add speller to Python application

2007-11-26 Thread Jarek Zgoda
helzer napisał(a): I need to add spell checking to my Python application (for Windows). Any ideas on where to start? There is Python2.4 compatible binary of aspell-python available at http://www.wmula.republika.pl/proj/aspell-python/index-c.html -- Jarek Zgoda Skype: jzgoda | GTalk: [EMAIL

Re: i want to know what is the problem in this code

2007-11-26 Thread Gerardo Herzig
nani wrote: i am getting the following error for below code type 'exceptions.KeyError' Python 2.5.1: C:\Python25\python.exe Mon Nov 26 10:13:17 2007 A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. C:\Program

howto write matplotlib backend?

2007-11-26 Thread mihail . udov
Somewhere on http://matplotlib.sourceforge.net or elsewhere I found some hints how to get started writing a new backend for matplotlib. It mentioned some almost empty kind of template that you could extend for your needs. I cannot find this description again. Would somebody help, please? Cheers

Re: the annoying, verbose self

2007-11-26 Thread BJörn Lindqvist
On Nov 24, 2007 11:55 AM, jakub silar [EMAIL PROTECTED] wrote: Below is my coding standard - I'm lazy, even lazy to persuade comutinties into strange (imho) language syntax extensions. class Vector: def __init__(s, x, y, z): s.x = x s.y = y

Re: Add speller to Python application

2007-11-26 Thread Shane Geiger
http://pyenchant.sourceforge.net/ helzer wrote: I need to add spell checking to my Python application (for Windows). Any ideas on where to start? Thanks, Helzer -- Shane Geiger IT Director National Council on Economic Education [EMAIL PROTECTED] | 402-438-8958 |

Re: Installing modules via setuptools in a script

2007-11-26 Thread Thorsten Kampe
* Robert Kern (Mon, 26 Nov 2007 04:34:17 -0600) Thorsten Kampe wrote: * Robert Kern (Sat, 24 Nov 2007 16:33:37 -0600) Thorsten Kampe wrote: can anyone give me a short code snippet how to install a missing module via setuptools (assuming setuptools is already installed)?! Something

Re: Handling Menubars in WXGlade

2007-11-26 Thread kyosohma
On Nov 23, 7:57 am, jatin patni [EMAIL PROTECTED] wrote: Hi, I recently started working on WXGlade... I found some amount of documentation online I am having problems integrating event handlers with MenubarsI want each menu item to open a new window with custom made controls...but I

Re: eof

2007-11-26 Thread Boris Borcic
[EMAIL PROTECTED] wrote: def xor(a, b): return a and not b or b and not a from operator import xor help(xor) Help on built-in function xor in module operator: xor(...) xor(a, b) -- Same as a ^ b. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread J. Clifford Dyer
On Mon, Nov 26, 2007 at 04:07:03PM +0530, Ravi Kumar wrote regarding Need to call functions/class_methods etc using string ref :How: Hi, First of all, since this is my first mail to Python-List, I want to say Hello world! After that; I am stuck in a project. Actually I am

Re: basic if stuff- testing ranges

2007-11-26 Thread Erik Jones
On Nov 25, 2007, at 9:49 PM, Donn Ingle wrote: if 0 x 20: print within That means if x LESS THAN 0 and x 20. Oh, bugger. It's tricky. So try if 0 x 20: Thanks. I was flipping signs in my tests, but I guess I flipped both and got myself all confused. Likely manuals: Tutorial

Re: eof

2007-11-26 Thread Grant Edwards
On 2007-11-26, Boris Borcic [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: def xor(a, b): return a and not b or b and not a from operator import xor help(xor) Help on built-in function xor in module operator: xor(...) xor(a, b) -- Same as a ^ b. Which isn't the same

Re: Running unmodified CGI scripts persistently under mod_wsgi.

2007-11-26 Thread Jeffrey Froman
Graham Dumpleton wrote: The other question is whether there is even a demand for this. Do people want to be able to take unmodified Python CGI scripts and try to run them persistently in this way, or would they be better off converting them to proper WSGI applications. I would personally be

Re: basic if stuff- testing ranges

2007-11-26 Thread Erik Jones
On Nov 26, 2007, at 2:29 AM, Peter Otten wrote: Donn Ingle wrote: x in range(1,20) ? Sure, that's okay, but it has clarity issues, and is calling a func. and it requires that x is integral (1.0 is in the range, 1.001 is not), and becomes dog slow when the range gets larger. Not a good

Re: Code Management

2007-11-26 Thread Sergio Correia
Bluebird: If you are using python 2.5, relative imports are no longer an issue: http://docs.python.org/whatsnew/pep-328.html That problem solved, what you sometimes want is to change the version of your package. I just change the text in the PTH file, to point to another version, and voilá (no

Re: eof

2007-11-26 Thread ZeD
Grant Edwards wrote: The user-defined xor is operates on logical boolean values. The one in the operator module is a bitwise operator. def xor(a, b): return bool(a) ^ bool(b) seems more explicit to me. maybe, to make more explicit (too much, onestly...) from operator import xor as

Re: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread Donn Ingle
I see someone already showed you eval.  Eval is evil.  Don't use it. Especially if the functions are coming to you from a public URL! Yes, I suggested to him (by email) this: thisinstance =  SomeObject.__class__.__dict__ Then you have a list of strings that may be function names, so: for f in

Re: mod_python

2007-11-26 Thread Aaron Watters
On Nov 24, 1:19 am, Vernon Wenberg III [EMAIL PROTECTED] wrote: Why do I receive a File not found error on a perfect good and simple script but properly receive errors when I deliberately add errors in the script? The file is there, it just doesn't do anything. Any help would be appreciated.

Re: better way to write this function

2007-11-26 Thread Kelie
On Nov 25, 10:51 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: Really though, this grouping function gets reimplemented so often that it should be built into the stdlib, maybe in itertools. thanks Paul. itertools? that was actually the first module i checked. --

Re: Installing modules via setuptools in a script

2007-11-26 Thread Robert Kern
Thorsten Kampe wrote: * Robert Kern (Mon, 26 Nov 2007 04:34:17 -0600) Thorsten Kampe wrote: * Robert Kern (Sat, 24 Nov 2007 16:33:37 -0600) Thorsten Kampe wrote: can anyone give me a short code snippet how to install a missing module via setuptools (assuming setuptools is already

Re: better way to write this function

2007-11-26 Thread Kelie
On Nov 25, 11:24 pm, Paul Rudin [EMAIL PROTECTED] wrote: See the last recipe from:http://docs.python.org/lib/itertools-recipes.html. It's not doing quite the same thing, but gives an illustration of one way to approach this sort of thing. Thanks for the link! --

How to write Regular Expression for recursive matching?

2007-11-26 Thread lisong
Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.' in mid. so the output I expect is : 'abc.defg', 'defg.hij', 'hij.klmnop' a simple regular expression '\w+.\w' will only return: 'abc.defg', 'hij.klmnop' is there a way

Re: eof

2007-11-26 Thread Boris Borcic
ZeD wrote: Grant Edwards wrote: The user-defined xor is operates on logical boolean values. The one in the operator module is a bitwise operator. def xor(a, b): return bool(a) ^ bool(b) seems more explicit to me. maybe, to make more explicit (too much, onestly...) from operator

Re: better way to write this function

2007-11-26 Thread Chris Mellon
On Nov 26, 2007 3:24 AM, Paul Rudin [EMAIL PROTECTED] wrote: Kelie [EMAIL PROTECTED] writes: Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what pythonic means yet. def divide_list(lst,

Re: win32serviceutil won't start

2007-11-26 Thread kyosohma
On Nov 25, 5:11 pm, Nikola Skoric [EMAIL PROTECTED] wrote: Dana Sun, 25 Nov 2007 13:52:35 -0800 (PST), [EMAIL PROTECTED] [EMAIL PROTECTED] kaze: Looks like Microsoft thinks you mis-spelled it. http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w... I would check and see

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread Paul McGuire
On Nov 26, 10:40 am, lisong [EMAIL PROTECTED] wrote: Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.' in mid. so the output I expect is : 'abc.defg', 'defg.hij', 'hij.klmnop' a simple regular expression

spawning a process with subprocess

2007-11-26 Thread bhunter
Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's finished, and if it is look at its output. I may want to send a signal at some point to kill the

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread Diez B. Roggisch
lisong wrote: Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.' in mid. so the output I expect is : 'abc.defg', 'defg.hij', 'hij.klmnop' a simple regular expression '\w+.\w' will only return: 'abc.defg',

Re: spawning a process with subprocess

2007-11-26 Thread kyosohma
On Nov 26, 10:54 am, bhunter [EMAIL PROTECTED] wrote: Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's finished, and if it is look at its output.

Re: Should proxy objects lie about their class name?

2007-11-26 Thread John J. Lee
[EMAIL PROTECTED] (John J. Lee) writes: Not much to add to the subject line. I mean something like this: ProxyClass.__name__ = ProxiedClass.__name__ I've been told that this is common practice. Is it? Would this surprise you if you ran into it in a debugging session? Does nobody have

Re: better way to write this function

2007-11-26 Thread Paul McGuire
On Nov 26, 1:42 am, Kelie [EMAIL PROTECTED] wrote: Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what pythonic means yet. def divide_list(lst, n): Divide a list into a number of lists,

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread Paul McGuire
On Nov 26, 10:51 am, Paul McGuire [EMAIL PROTECTED] wrote: On Nov 26, 10:40 am, lisong [EMAIL PROTECTED] wrote: Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.' in mid. so the output I expect is :

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread Boris Borcic
lisong wrote: Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.' in mid. so the output I expect is : 'abc.defg', 'defg.hij', 'hij.klmnop' a simple regular expression '\w+.\w' will only return: 'abc.defg',

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread J. Clifford Dyer
On Mon, Nov 26, 2007 at 06:04:54PM +0100, Diez B. Roggisch wrote regarding Re: How to write Regular Expression for recursive matching?: lisong wrote: Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.'

Re: spawning a process with subprocess

2007-11-26 Thread bhunter
I've read that this sort of thing can be a pain. I'm sure someone will post and have other views though. I have had some success using Python's threading module though. There's a pretty good walkthrough here (it uses wxPython in its example): http://wiki.wxpython.org/LongRunningTasks Other

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread lisong
On Nov 26, 12:34 pm, J. Clifford Dyer [EMAIL PROTECTED] wrote: On Mon, Nov 26, 2007 at 06:04:54PM +0100, Diez B. Roggisch wrote regarding Re: How to write Regular Expression for recursive matching?: lisong wrote: Hi All, I have problem to split a string like this:

Re: Tk 8.5

2007-11-26 Thread James Matthews
I also cannot wait! On Nov 24, 2007 4:12 PM, Ron Provost [EMAIL PROTECTED] wrote: Hello, According to the tk wiki, the final release of Tcl/Tk is just weeks away (see http://wiki.tcl.tk/12753). Does anyone know if the Tk enhancements will be in Python 2.6? Since I don't use tk but I do

Re: spawning a process with subprocess

2007-11-26 Thread kyosohma
On Nov 26, 12:27 pm, bhunter [EMAIL PROTECTED] wrote: I've read that this sort of thing can be a pain. I'm sure someone will post and have other views though. I have had some success using Python's threading module though. There's a pretty good walkthrough here (it uses wxPython in its

Re: spawning a process with subprocess

2007-11-26 Thread Diez B. Roggisch
bhunter schrieb: Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's finished, and if it is look at its output. I may want to send a signal at some

Re: Should proxy objects lie about their class name?

2007-11-26 Thread Diez B. Roggisch
John J. Lee schrieb: [EMAIL PROTECTED] (John J. Lee) writes: Not much to add to the subject line. I mean something like this: ProxyClass.__name__ = ProxiedClass.__name__ I've been told that this is common practice. Is it? Would this surprise you if you ran into it in a debugging

Re: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread Bruno Desthuilliers
Donn Ingle a écrit : I see someone already showed you eval. Eval is evil. Don't use it. Especially if the functions are coming to you from a public URL! Yes, I suggested to him (by email) this: thisinstance = SomeObject.__class__.__dict__ Then you have a list of strings that may be

Re: better way to write this function

2007-11-26 Thread Paul Hankin
On Nov 26, 7:42 am, Kelie [EMAIL PROTECTED] wrote: Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what pythonic means yet. def divide_list(lst, n): Divide a list into a number of lists,

Re: the annoying, verbose self

2007-11-26 Thread Bruno Desthuilliers
Ton van Vliet a écrit : On 24 Nov 2007 13:56:37 GMT, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: (snip) So:: def meth(self): using self: tmp = raw_input('Enter age: ') age = int(tmp) becomes:: def meth(self): using self: self.tmp =

Re: the annoying, verbose self

2007-11-26 Thread Bruno Desthuilliers
samwyse a écrit : (snip) Besides Pascal, Visual Basic also offers a 'with' statement that behaves almost in this way. That in itself should be an indication that the whole thing is a bad idea. ;-) FWIW, Javascript has it too - and it's considered a BadPractice(tm) to use it... --

Re: the annoying, verbose self

2007-11-26 Thread Bruno Desthuilliers
Ton van Vliet a écrit : On 24 Nov 2007 16:07:18 GMT, Duncan Booth [EMAIL PROTECTED] wrote: Ton van Vliet [EMAIL PROTECTED] wrote: It would boil down to choice: explicit/speed vs implicit/readability No, it would boil down to explicit+speed+readability+maintainability vs implicit+error

Re: How to Teach Python Variables

2007-11-26 Thread [EMAIL PROTECTED]
Hrvoje Niksic wrote: greg [EMAIL PROTECTED] writes: none wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. IMHO, this is nonsense. All that variables are (in any language) are

Re: the annoying, verbose self

2007-11-26 Thread Bruno Desthuilliers
Patrick Mullen a écrit : (snip) Still an unnecessary lookup on tmp though :) And it would be useless to use it for one assignment, the idea is to eliminate all the typing with this: self.var1 = 5 self.var2 = a value self.var3 = stuff self.var4 = [2,54,7,7] self.var5 = dingaling

Re: the annoying, verbose self

2007-11-26 Thread Bruno Desthuilliers
samwyse a écrit : (snip) Actually, the chained dots are solving a completely different problem, that of refactoring a collection of functions that use global vars into a class. Using globals to maintain state between functions being bad practice in most cases, I don't see any reason to

Re: spawning a process with subprocess

2007-11-26 Thread bhunter
This is just the way I do it...as I said, there are probably some other people in the group who will have other opinions. By the way, your statement I was hoping not to have to avoid that means that you hoped to use threading...which I think is contradictory to what you meant. Mike That

Re: better way to write this function

2007-11-26 Thread Peter Otten
Peter Otten wrote: def chunks(items, n): ... return [items[start:start+n] for n in range(0, len(items)-n+1, n)] Ouch, this should be def chunks(items, n): return [items[start:start+n] for start in range(0, len(items)-n+1, n)] Peter --

Re: spawning a process with subprocess

2007-11-26 Thread bhunter
On Nov 26, 1:50 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: bhunter schrieb: Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's finished,

Best ways of managing text encodings in source/regexes?

2007-11-26 Thread tinkerbarbet
Hi I've read around quite a bit about Unicode and python's support for it, and I'm still unclear about how it all fits together in certain scenarios. Can anyone help clarify? * When I say # -*- coding: utf-8 -*- and confirm my IDE is saving the source file as UTF-8, do I still need to prefix

Re: How to Teach Python Variables

2007-11-26 Thread Chris Mellon
On Nov 26, 2007 1:21 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hrvoje Niksic wrote: greg [EMAIL PROTECTED] writes: none wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects.

gnosis XML objectify

2007-11-26 Thread Wang, Harry
The gnosis xml libs should not be version specific, but when I try to use Python 2.5, I am getting not well formed (invalid token) errors. Harry -- http://mail.python.org/mailman/listinfo/python-list

Re: C pointer representation in python

2007-11-26 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Hi | I am new to SWIG and python. I have a problem while trying to call a C | function from Python using SWIG as an interface. Did you consider using the ctypes module? (It is new in the stdlib for 2.5, I believe.) Some consider it

Re: spawning a process with subprocess

2007-11-26 Thread Diez B. Roggisch
bhunter schrieb: On Nov 26, 1:50 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: bhunter schrieb: Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's

Re: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread Donn Ingle
target = module or any other objet here for funcname in funclist: func = getattr(target, funcname, None) if callable(func): func(*args, **kwargs) Nice. 'callable' is new to me. Live and learn :) \d -- http://mail.python.org/mailman/listinfo/python-list

Re: gnosis XML objectify

2007-11-26 Thread kyosohma
On Nov 26, 1:46 pm, Wang, Harry [EMAIL PROTECTED] wrote: The gnosis xml libs should not be version specific, but when I try to use Python 2.5, I am getting not well formed (invalid token) errors. Harry When does this happen? When you import the module? When you pass it some xml? Do you have

Re: gnosis XML objectify

2007-11-26 Thread Sébastien Boisgérault
On Nov 26, 8:46 pm, Wang, Harry [EMAIL PROTECTED] wrote: The gnosis xml libs should not be version specific, but when I try to use Python 2.5, I am getting not well formed (invalid token) errors. Harry Could you show us a simple example that exhibits this behavior please ? SB --

RE: gnosis XML objectify

2007-11-26 Thread Wang, Harry
Full Traceback enclosed: Test Suite Started @ 2007-11-26 11:34:46.617000 Traceback (most recent call last): File C:\UDR2\UDRxmlGateway.py, line 370, in module ParseAll() File C:\UDR2\UDRxmlGateway.py, line 286, in ParseAll py_obj =

Re: Need to call functions/class_methods etc using string ref :How

2007-11-26 Thread Bruno Desthuilliers
Donn Ingle a écrit : target = module or any other objet here for funcname in funclist: func = getattr(target, funcname, None) if callable(func): func(*args, **kwargs) Nice. 'callable' is new to me. What about getattr, then ?-) And FWIW, callable will disappear in py3k... (anyway, you can just

RE: gnosis XML objectify

2007-11-26 Thread Wang, Harry
I can't tell where in the XML file it throws the error. Here is the snippet of the Python code: def ParseAll(): py_obj = gnosis.xml.objectify.XML_Objectify(InputFile).make_instance() Harry C. Wang Sr. Test Engineer (Automation) AOL Mobile Phone 206 - 268 - 7502 temporary e-mail: [EMAIL

Re: the annoying, verbose self

2007-11-26 Thread Ton van Vliet
On Mon, 26 Nov 2007 20:14:50 +0100, Bruno Desthuilliers [EMAIL PROTECTED] wrote: However, I was more thinking in terms of attributes only Too bad : in Python, everything's an object, so 'methods' are attributes too. Right, but I'm sure *you* know a way to distinguish between them (I'm just a

Re: gnosis XML objectify

2007-11-26 Thread kyosohma
On Nov 26, 2:33 pm, Wang, Harry [EMAIL PROTECTED] wrote: Full Traceback enclosed: Test Suite Started @ 2007-11-26 11:34:46.617000 Traceback (most recent call last): File C:\UDR2\UDRxmlGateway.py, line 370, in module ParseAll() File C:\UDR2\UDRxmlGateway.py, line 286, in ParseAll

gnosis XML objectify

2007-11-26 Thread Wang, Harry
Problem solved. I left out a right closing tag () in the XML, but I am having another problem. Harry C. Wang Sr. Test Engineer (Automation) AOL Mobile Phone 206 - 268 - 7502 temporary e-mail: [EMAIL PROTECTED] Personal e-mail: [EMAIL PROTECTED] --

Re: spawning a process with subprocess

2007-11-26 Thread bhunter
On Nov 26, 3:05 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: bhunter schrieb: On Nov 26, 1:50 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: bhunter schrieb: Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output.

Re: basic if stuff- testing ranges

2007-11-26 Thread John Machin
On Nov 27, 3:01 am, Erik Jones [EMAIL PROTECTED] wrote: On Nov 25, 2007, at 9:49 PM, Donn Ingle wrote: if 0 x 20: print within That means if x LESS THAN 0 and x 20. Oh, bugger. It's tricky. So try if 0 x 20: Thanks. I was flipping signs in my tests, but I guess I flipped

Re: the annoying, verbose self

2007-11-26 Thread Colin J. Williams
Bruno Desthuilliers wrote: [snip] Too bad : in Python, everything's an object, so 'methods' are attributes too. What do you see as a problem here? Surely it gives useful flexibility. Colin W. -- http://mail.python.org/mailman/listinfo/python-list

Re: better way to write this function

2007-11-26 Thread Arnaud Delobelle
On Nov 26, 8:19 am, Peter Otten [EMAIL PROTECTED] wrote: [...] Or build a generator that works with arbitrary iterables: from itertools import * def chunks(items, n): ... items = iter(items) ... while 1: ... chunk = list(islice(items, n-1)) ...

Installing Python 3000

2007-11-26 Thread André
Sorry about the simple question ... I'd like to install Python 3000 on my computers (Mac, and possibly Windows), without messing up the existing versions. So far, I've always relied on using .msi on Windows and .dmg on the Mac. From the Python site, I read (different version, but still...):

Re: How to Teach Python Variables

2007-11-26 Thread jkn
On Nov 25, 10:36 pm, Ben Finney [EMAIL PROTECTED] wrote: In addition to the good answers you've had already, I highly recommend David Goodger's Code like a Pythonista page URL:http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html, which contains a very good cardboard boxes

fork/exec with input redirection

2007-11-26 Thread Dan Upton
I have a Python script that does a fork/exec, so the parent process can get the child's PID and monitor /proc/PID/stat (on a CentOS system). Most of my processes' command lines are straightforward enough to do this with, but I have a handful that use on the command line, eg

Re: Installing Python 3000

2007-11-26 Thread Peter Otten
André wrote: The step that gets me worried is the make install one... I don't want it to take over as default. I would like to be able to invoke it by typing python3k ... from anywhere and have it work - while still having python invoke the default 2.5 version. You want make altinstall

Re: fork/exec with input redirection

2007-11-26 Thread Erik Jones
On Nov 26, 2007, at 3:58 PM, Dan Upton wrote: I have a Python script that does a fork/exec, so the parent process can get the child's PID and monitor /proc/PID/stat (on a CentOS system). Most of my processes' command lines are straightforward enough to do this with, but I have a handful that

Re: Installing Python 3000

2007-11-26 Thread Martin v. Löwis
I'd like to install Python 3000 on my computers (Mac, and possibly Windows), without messing up the existing versions. So far, I've always relied on using .msi on Windows and .dmg on the Mac. From the Python site, I read (different version, but still...): Unpack the archive with tar

Re: How to Teach Python Variables

2007-11-26 Thread Steven D'Aprano
On Mon, 26 Nov 2007 21:37:19 +1300, greg wrote: none wrote: IIRC, I once saw an explanation how Python doesn't have variables in the sense that, say, C does, and instead has bindings from names to objects. If you're talking to C programmers, just tell them that Python variables always

  1   2   >