Re: Is this the right way to use unicode in a user defined Exception?

2009-02-26 Thread Terry Reedy
一首诗 wrote: # class MyError(Exception): def __init__(self): self.message = u'Some Chinese:中文' def __str__(self): return self.message.encode('utf8') # This is an exception that

The Python's regex different from Perl's ,I want know what's the different?

2009-02-26 Thread qq13234722
The Python's regex different from Perl's ,I want know what's the different? -- http://mail.python.org/mailman/listinfo/python-list

i have problem with glob.glob() in remotely directory

2009-02-26 Thread lameck kassana
hey i want to count number of files in remote computer example of my code is import glob import os import time from datetime import date today=date.today() dir_count, file_count=0, 0 for files in glob.glob('\\192.168.0.45\files\*.txt'): file_count += len(files) print 'the count of

Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Raymond Hettinger
Here's a proposed implementation for Py2.7 and Py3.1: http://code.activestate.com/recipes/576669/ Would like you guys to kick the tires, exercise it a bit, and let me know what you think. The recipe runs under 2.6 and 3.0 without modification so it should be easy to play with. The main

Re: i have problem with glob.glob() in remotely directory

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 1:05 AM, lameck kassana chela...@gmail.com wrote: hey i want to count number of files in remote computer example of my code is import glob import os import time from datetime import date today=date.today() dir_count, file_count=0, 0 for files in

Re: File Path retrieving problem

2009-02-26 Thread music24by7
Hi Dennis Thanks for your reply and also the detailed explanation. Or do you mean you want something that, given a bare name, searches your file system to find where a file with that name actually is? Yes, this is what i exactly needed. I have found something interesting to do this

Re: a look at the browser scene emacs

2009-02-26 Thread Xah Lee
On Feb 26, 12:57 am, Miles Bader mi...@gnu.org wrote: There is ample room for people to discuss this evolution, but approaches that start with first, toss out the existing user interface aren't gonna fly. Who said to toss out existing user interface, you? Are you saying that i start my

RE: Queries

2009-02-26 Thread Murray
It is, however I was able to get the first 8 done, I am struggling with these 3 particular ones. I have to make an SQL file based off of it, so this seems to be a blockage in my works. -Original Message- From: Gary Herron [mailto:gher...@islandtraining.com] Sent: Thursday, February 26,

Building python extensions

2009-02-26 Thread Jrod
Lets say I compile python 2.6.1 without readline support due to not having the readline headers installed prior. Is there a standard way to recompile the extension without having to rebuild the entire source. Looking at the makefile, I found the gcc line (modified to dump the relocatable in

Python-URL! - weekly Python news and links (Feb 26)

2009-02-26 Thread Gabriel Genellina
QOTW: I believe this is because Microsoft failed to understand the original meaning of ___, and persisted with this ghastly error in the name of backwards compatibility, justifying it by suggesting that _. Somebody should have cards printed up... - the

Re: a look at the browser scene emacs

2009-02-26 Thread Tassilo Horn
Xah Lee xah...@gmail.com writes: Hi Xah, is the suggestion of using modern standard shortcut set of X C V for Cut, Copy, Paste, of which Linux uses, means it is turning emacs to a fancy Notepad clone? The functionality stays the same, but IMO it would confuse most users. Killing is not

subprocess module: execution of standard binaries without shell?

2009-02-26 Thread Visco Shaun
hi all while getting used to with subprocess module i failed in executuing a) but succeeded in running b). Can anyone explain me why as i am providing absolute path? Is this has to do anything with shared library.. which must be accessed based on system variables? a) pipe =

Re: subprocess module: execution of standard binaries without shell?

2009-02-26 Thread Christian Heimes
Visco Shaun schrieb: hi all while getting used to with subprocess module i failed in executuing a) but succeeded in running b). Can anyone explain me why as i am providing absolute path? Is this has to do anything with shared library.. which must be accessed based on system variables?

EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread jkv
Hi, Are there any way to change the EOL character for sys.stdin.readline() and raw_input()? My problem is that i cannot rely on that the clients connection to my application will end all lines with \n or \r\n. Sometimes they will use \r\000 as EOL. Example from my code:

Re: subprocess module: execution of standard binaries without shell?

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 2:41 AM, Visco Shaun visc...@gmail.com wrote: hi all while getting used to with subprocess module i failed in executuing a) but succeeded in running b). Can anyone explain me why as i am providing absolute path? Is this has to do anything with shared library.. which

Delete all items in the list

2009-02-26 Thread Clarendon
Hi. This must be a simple command but I just can't find it in the Phthon manual. How do I delete all items with a certain condition from a list? For instance: L=['a', 'b', 'c', 'a'] I want to delete all 'a's from the list. But if L.remove('a') only deletes the first 'a'. How do you delete all

sending gmail with smtplib from behind a proxy

2009-02-26 Thread Bjorn
Hi, I tried the script below to send mail by gmail from python using smptlib. I got the script here (http://kutuma.blogspot.com/2007/08/ sending-emails-via-gmail-with-python.html) It works fine from home, but at work not. I think it is because I am behind a http or a socks proxy server at work.

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 3:05 AM, Clarendon jine...@hotmail.com wrote: Hi. This must be a simple command but I just can't find it in the Phthon manual. How do I delete all items with a certain condition from a list? For instance: L=['a', 'b', 'c', 'a'] I want to delete all 'a's from the

Re: The Python's regex different from Perl's ,I want know what's the different?

2009-02-26 Thread Tim Chase
The Python's regex different from Perl's ,I want know what's the different? Easy: bash$ diff (lynx -dump http://perldoc.perl.org/perlre.html) (lynx -dump http://docs.python.org/library/re.html) Had you tried the great Google in the sky, you might have found such pages as:

Re: i have problem with glob.glob() in remotely directory

2009-02-26 Thread lameck kassana
i did try but still not working.But also i try os.walk() for remote computer like os.walk('\\192.168.0.45') it also failed Thats it is my main problem do i need any new imports besides import os On 2/26/09, Chris Rebert c...@rebertia.com wrote: On Thu, Feb 26, 2009 at 1:05 AM, lameck kassana

Efficient searching through objects

2009-02-26 Thread sert
I have written a program that reads data and updates the records for some people. They are represented by objects, and I need to read the data from a file, look the person up and then update his record. I have implemented this by creating a list with all the people's names and another list

Re: Is there something easier than ORM?

2009-02-26 Thread Kevin Dangoor (Mozilla)
On Feb 17, 10:28 pm, alex23 wuwe...@gmail.com wrote: On Feb 18, 3:10 am, Robert Kern robert.k...@gmail.com wrote: Its public image definitely suffers from the impression that it's an ORM that can be compared on equal terms with packages that actually are just ORMs. I describe it as a

Efficient searching through objects

2009-02-26 Thread rdmurray
sert je...@hotmail.com wrote: I have written a program that reads data and updates the records for some people. They are represented by objects, and I need to read the data from a file, look the person up and then update his record. I have implemented this by creating a list with all the

Re: Efficient searching through objects

2009-02-26 Thread bearophileHUGS
sert: I have implemented this by creating a list with all the people's names and another list with their objects (their data). It works but after profiling the code it turns out that half the time spent in the program is spent in the list.index() function looking up names. Isn't there a less

problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread lameck kassana
i am trying to write script which will count files for remote directory which having certain pattern. i tried with my code and have a look at this code. --- import glob import os import time from datetime import date

Re: Efficient searching through objects

2009-02-26 Thread sert
bearophileh...@lycos.com wrote in news:37632421-5475-4859-be83-07ae2eca1...@r4g2000yqa.googlegro ups.com: Try using a dict instead, where keys are the names and objects the values (it turns a linear search in a quick hash look up). . Then tell us the performance changes. It halved the

Re: File Path retrieving problem

2009-02-26 Thread Steve Holden
music24...@gmail.com wrote: On Feb 26, 9:03 am, Steve Holden st...@holdenweb.com wrote: music24...@gmail.com wrote: On Feb 26, 2:35 am, Emile van Sebille em...@fenx.com wrote: Peter Otten wrote: Maybe it's about access rights? $ mkdir alpha $ touch alpha/beta $ python -cimport os; print

Re: Delete all items in the list

2009-02-26 Thread Bruno Desthuilliers
Clarendon a écrit : Hi. This must be a simple command but I just can't find it in the Phthon manual. How do I delete all items with a certain condition from a list? For instance: L=['a', 'b', 'c', 'a'] I want to delete all 'a's from the list. But if L.remove('a') only deletes the first 'a'.

Re: File Path retrieving problem

2009-02-26 Thread Steve Holden
Dennis Lee Bieber wrote: On Wed, 25 Feb 2009 07:37:21 -0800 (PST), music24...@gmail.com declaimed the following in comp.lang.python: WARNING -- I will probably NOT see your response; since 90+% of the spam in comp.lang.python is injected via googlegroups and gmail accounts, my client

Re: Queries

2009-02-26 Thread Steve Holden
Murray wrote: [top-posting corrected] -Original Message- From: Gary Herron [mailto:gher...@islandtraining.com] Sent: Thursday, February 26, 2009 1:46 AM To: mmcclaf; python-list@python.org Subject: Re: Queries mmcclaf wrote: I have to make some queries for 4 tables I have. The

Re: i have problem with glob.glob() in remotely directory

2009-02-26 Thread Steve Holden
Chris Rebert wrote: On Thu, Feb 26, 2009 at 1:05 AM, lameck kassana chela...@gmail.com wrote: hey i want to count number of files in remote computer example of my code is import glob import os import time from datetime import date today=date.today() dir_count, file_count=0, 0 for

Run a python script as an exe and run a new process from it

2009-02-26 Thread venutaurus...@gmail.com
Hello all, I've a strange requirement where I need to run a python script just as we run an exe (by double clicking through windows explorer or by typing the script name at command prompt). In that process I should be able to execute another python script in such a way that, the second

Re: Delete all items in the list

2009-02-26 Thread Boris Borcic
Chris Rebert wrote: On Thu, Feb 26, 2009 at 3:05 AM, Clarendon jine...@hotmail.com wrote: ... L=['a', 'b', 'c', 'a'] I want to delete all 'a's from the list. But if L.remove('a') only deletes the first 'a'. How do you delete all 'a's? There are several ways. I'd go with a list

Re: Queries

2009-02-26 Thread Bret Fledderjohn
2009/2/26 Steve Holden st...@holdenweb.com Murray wrote: [top-posting corrected] -Original Message- From: Gary Herron [mailto:gher...@islandtraining.com] Sent: Thursday, February 26, 2009 1:46 AM To: mmcclaf; python-list@python.org Subject: Re: Queries mmcclaf wrote: I

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread Tim Wintle
On Thu, 2009-02-26 at 04:55 -0800, venutaurus...@gmail.com wrote: Hello all, I've a strange requirement where I need to run a python script just as we run an exe (by double clicking through windows explorer or by typing the script name at command prompt). I don't know how windows

Re: Efficient searching through objects

2009-02-26 Thread Tim Rowe
2009/2/26 sert je...@hotmail.com: bearophileh...@lycos.com wrote in news:37632421-5475-4859-be83-07ae2eca1...@r4g2000yqa.googlegro ups.com: Try using a dict instead, where keys are the names and objects the values (it turns a linear search in a quick hash look up). . Then tell us the

Re: Efficient searching through objects

2009-02-26 Thread Tim Chase
relational database will be optimised to do these operations and so is likely to be faster still. I think there are a couple that Python works well with, but I've never looked into that -- others will no doubt be along with recommendations now I've raised the subject. batteries-included support

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread Steve Holden
lameck kassana wrote: i am trying to write script which will count files for remote directory which having certain pattern. Please refrain from repeating questions. When you posted this a reply had already been made to your original posting. Remember, this isn't a paid help desk ... regards

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread lameck kassana
ok my original question is how can count the files of ceratin pattern(eg *.txt) in remote directory .It seems use of glob.glob() for remote directory is not working .Example I want to count the files in following shared folder \\192.168.0.45\files file://192.168.0.45/files how can do it by using

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread venutaurus...@gmail.com
On Feb 26, 6:10 pm, Tim Wintle tim.win...@teamrubber.com wrote: On Thu, 2009-02-26 at 04:55 -0800, venutaurus...@gmail.com wrote: Hello all,            I've a strange requirement where I need to run a python script just as we run an exe (by double clicking through windows explorer or by

Re: class property not working in python 2.5.1

2009-02-26 Thread utnapistim
On Feb 26, 9:56 am, Christian Heimes li...@cheimes.de wrote: Dan Barbus schrieb: Hi, I have a problem with setting a property to a class instance, in python 2.5.1. The property is defined through get and set methods, but when I set it, the setter doesn't get called. Instead, I believe

Re: Queries

2009-02-26 Thread mmcclaf
On Feb 26, 7:51 am, Steve Holden st...@holdenweb.com wrote: Murray wrote: [top-posting corrected] -Original Message- From: Gary Herron [mailto:gher...@islandtraining.com] Sent: Thursday, February 26, 2009 1:46 AM To: mmcclaf; python-l...@python.org Subject: Re: Queries

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread venutaurus...@gmail.com
On Feb 26, 7:00 pm, venutaurus...@gmail.com venutaurus...@gmail.com wrote: On Feb 26, 6:10 pm, Tim Wintle tim.win...@teamrubber.com wrote: On Thu, 2009-02-26 at 04:55 -0800, venutaurus...@gmail.com wrote: Hello all,            I've a strange requirement where I need to run a python

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread Steve Holden
lameck kassana wrote: ok my original question is how can count the files of ceratin pattern(eg *.txt) in remote directory .It seems use of glob.glob() for remote directory is not working .Example I want to count the files in following shared folder \\192.168.0.45\files

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread Bret Fledderjohn
2009/2/26 venutaurus...@gmail.com venutaurus...@gmail.com On Feb 26, 7:00 pm, venutaurus...@gmail.com venutaurus...@gmail.com wrote: On Feb 26, 6:10 pm, Tim Wintle tim.win...@teamrubber.com wrote: On Thu, 2009-02-26 at 04:55 -0800, venutaurus...@gmail.com wrote: Hello all,

Re: thread safe to lock on key, val pairs on a dict instead of entire dict?

2009-02-26 Thread Gabriel Genellina
En Thu, 26 Feb 2009 00:39:30 -0200, birdsong david.birds...@gmail.com escribió: Dictionaries just store references to objects, right? So is it thread safe to lock a specific key/val pair on a dictionary and modify its val and release the lock? example snippet: # assuming d_lock was

Re: memory recycling/garbage collecting problem

2009-02-26 Thread David Niergarth
On Feb 16, 11:21 pm, Yuanxin Xi xi11w...@gmail.com wrote: Could anyone please explain why this happens?  It seems some memory are not freed. There is a bug in versions of Python prior to 2.5 where memory really isn't released back to the OS. Python 2.5 contains a new object allocator that is

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread Tim Wintle
On Thu, 2009-02-26 at 06:00 -0800, venutaurus...@gmail.com wrote: Thanks for the reply, Being a newbie to python, I am finding it difficult to understand the logic even after thorough reading of comments. Is there any simpler way where I can just run a python script from the main

Re: memory recycling/garbage collecting problem

2009-02-26 Thread David Niergarth
Tim Peters showed a way to demonstrate the fix in http://mail.python.org/pipermail/python-dev/2006-March/061991.html For simpler fun, run this silly little program, and look at memory consumption at the prompts: x = [] for i in xrange(100): x.append([]) raw_input(full ) del x[:]

RE: XML Parsing

2009-02-26 Thread Paul McGuire
You flatter me sir (or madam? can't tell from your name...), but I wouldn't presume to so lofty a title among this crowd. I'd save that for the likes of Alan Gauld and Kent Johnson, who are much more prolific and informative contributors to this list than I. -- Paul -Original Message-

OT: handling multiple software repositories

2009-02-26 Thread Thomas Guettler
Hi, this is a bit off topic. In our company we have several SVN repositories. According to [1] Trac by default only handles one repository. Of course Trac links like changeset [1234] would not work anymore. You would need [repro/1234] or something like this. I think many (python) programmer

Re: Delete all items in the list

2009-02-26 Thread Gabriel Genellina
En Thu, 26 Feb 2009 11:00:30 -0200, Boris Borcic bbor...@gmail.com escribió: Chris Rebert wrote: On Thu, Feb 26, 2009 at 3:05 AM, Clarendon jine...@hotmail.com wrote: ... L=['a', 'b', 'c', 'a'] I want to delete all 'a's from the list. But if L.remove('a') only deletes the first 'a'. How

Re: PyCrypto AES MODE_CBC - How to?

2009-02-26 Thread M.-A. Lemburg
On 2009-02-25 13:25, Helmut Jarausch wrote: Helmut Jarausch wrote: Hi, I've just tried to write a simple example using PyCrypto's AES (CBC mode) #!/usr/bin/python from Crypto.Cipher import AES PWD='abcdefghijklmnop' Initial16bytes='0123456789ABCDEF' crypt = AES.new(PWD,

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread venutaurus...@gmail.com
On Feb 26, 7:47 pm, Tim Wintle tim.win...@teamrubber.com wrote: On Thu, 2009-02-26 at 06:00 -0800, venutaurus...@gmail.com wrote: Thanks for the reply,            Being a newbie to python, I am finding it difficult to understand the logic even after thorough reading of comments. Is there

Re: The Python's regex different from Perl's , I want know what's the different?

2009-02-26 Thread Shawn Milochik
The regular expression syntax is basically exactly the same. The main difference is that a regex can't just be written into a statement as part of the syntax; you have to create a regular expression object and use its methods. So, instead of: new_thing =~ s/pattern/replacement/ it's:

RE: Delete all items in the list

2009-02-26 Thread John Posner
L = filter('a'.__ne__,L) And this is probably the fastest. But not all types define __ne__ so a more generic answer would be: from functools import partial from operator import ne L = filter(partial(ne, 'a'), L) And don't forget this traditional solution: L=['a',

functools.partial (was: Delete all items in the list)

2009-02-26 Thread John Posner
from functools import partial from operator import ne L = filter(partial(ne, 'a'), L) I learned about functools.partial only recently (on this list). functools is implemented in C, not Python, so I couldn't answer this question for myself: Is functools.partial completely

Re: OT: handling multiple software repositories

2009-02-26 Thread Tim Golden
Thomas Guettler wrote: Hi, this is a bit off topic. In our company we have several SVN repositories. According to [1] Trac by default only handles one repository. Of course Trac links like changeset [1234] would not work anymore. You would need [repro/1234] or something like this. I think

Re: EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread MRAB
jkv wrote: Hi, Are there any way to change the EOL character for sys.stdin.readline() and raw_input()? My problem is that i cannot rely on that the clients connection to my application will end all lines with \n or \r\n. Sometimes they will use \r\000 as EOL. Example from my code:

Re: OT: handling multiple software repositories

2009-02-26 Thread Luis Zarrabeitia
On Thursday 26 February 2009 11:10:15 am Tim Golden wrote: Have a look at DrProject[1], a Trac-alike which handles multiple projects. (Not used it myself). [1] https://www.drproject.org/ I've used DrProject a bit (my gf is one of the developers). If you like trac, chances are that you will

Re: memory recycling/garbage collecting problem

2009-02-26 Thread Steve Holden
David Niergarth wrote: Tim Peters showed a way to demonstrate the fix in http://mail.python.org/pipermail/python-dev/2006-March/061991.html For simpler fun, run this silly little program, and look at memory consumption at the prompts: x = [] for i in xrange(100): x.append([])

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread Gabriel Genellina
En Thu, 26 Feb 2009 13:32:27 -0200, venutaurus...@gmail.com venutaurus...@gmail.com escribió: On Feb 26, 7:47 pm, Tim Wintle tim.win...@teamrubber.com wrote: On Thu, 2009-02-26 at 06:00 -0800, venutaurus...@gmail.com wrote: Thanks for the reply,            Being a newbie to python, I am

embedding Python in a shared library

2009-02-26 Thread Deepak Chandran
I have embedded Python in a shared library. This works fine in Windows (dll), but I get the following error is Ubuntu when I try to load modules: /usr/lib/python2.5/lib-dynload/time.so: error: symbol lookup error: undefined symbol: PyExc_ValueError I found many postings on this issue on the

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Benjamin Peterson
Raymond Hettinger python at rcn.com writes: Here's a proposed implementation for Py2.7 and Py3.1: http://code.activestate.com/recipes/576669/ Would like you guys to kick the tires, exercise it a bit, and let me know what you think. The recipe runs under 2.6 and 3.0 without

Re: EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread Terry Reedy
jkv wrote: Hi, Are there any way to change the EOL character for sys.stdin.readline() and raw_input()? My problem is that i cannot rely on that the clients connection to my application will end all lines with \n or \r\n. Sometimes they will use \r\000 as EOL. Example from my code:

Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread Paddy O'Loughlin
Try this as an outline: script1.py from subprocess import Popen if __name__ == '__main__': scriptname = script2.py Popen(python %s % scriptname, shell=True) print I'm done script2.py from time import sleep if __name__ == '__main__': while (True):

What functions, other than sleep(), can be interrupted by Ctrl-C?

2009-02-26 Thread Maxim Khitrov
Greetings, I'm looking for a function in the standard library or pywin32 package that will block until a certain condition is met or it is interrupted by Ctrl-C. For example, time.sleep() would have been perfect for my needs if thread.interrupt_main() could interrupt the call from another thread

Re: memory recycling/garbage collecting problem

2009-02-26 Thread Terry Reedy
Steve Holden wrote: David Niergarth wrote: Tim Peters showed a way to demonstrate the fix in http://mail.python.org/pipermail/python-dev/2006-March/061991.html For simpler fun, run this silly little program, and look at memory consumption at the prompts: x = [] for i in xrange(100):

Re: Delete all items in the list

2009-02-26 Thread Terry Reedy
Gabriel Genellina wrote: L = filter('a'.__ne__,L) And this is probably the fastest. But not all types define __ne__ In Py3, all classes inherit .__ne__ from 'object'. -- http://mail.python.org/mailman/listinfo/python-list

Re: memory recycling/garbage collecting problem

2009-02-26 Thread Steve Holden
Terry Reedy wrote: Steve Holden wrote: David Niergarth wrote: [...] I'm not sure what deleting a slice accomplishes (del x[:]); the behavior is the same whether I do del x or del x[:]. Any ideas? del x removes the name x from the current namespace, garbage collecting the object to which it

Re: Delete all items in the list

2009-02-26 Thread Steve Holden
Terry Reedy wrote: Gabriel Genellina wrote: L = filter('a'.__ne__,L) And this is probably the fastest. But not all types define __ne__ In Py3, all classes inherit .__ne__ from 'object'. Isn't that inherited method just an identity comparison? However in this particular case the main

Re: EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread skip
What is it about with statements that makes you want to so frequently embed them in try/except statements? Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread jkv
Terry Reedy wrote: jkv wrote: Hi, Are there any way to change the EOL character for sys.stdin.readline() and raw_input()? My problem is that i cannot rely on that the clients connection to my application will end all lines with \n or \r\n. Sometimes they will use \r\000 as EOL. Example

Re: EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread Jean-Paul Calderone
On Thu, 26 Feb 2009 11:46:24 +0100, jkv j...@unixcluster.dk wrote: Hi, Are there any way to change the EOL character for sys.stdin.readline() and raw_input()? My problem is that i cannot rely on that the clients connection to my application will end all lines with \n or \r\n. Sometimes they

How to parse form in client side?

2009-02-26 Thread Muddy Coder
Hi Folks, cgi module can easily acquire the all fields of data input from client side, through a form. Then, a simple line of code: form_dict = cgi.FieldStorage() grabs all data into a dictionary form_dict. The rest becomes a piece of cake by querying the form_dict. Nice! However, it is done

Re: How to parse form in client side?

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 12:19 PM, Muddy Coder cosmo_gene...@yahoo.com wrote: Hi Folks, cgi module can easily acquire the all fields of data input from client side, through a form. Then, a simple line of code: form_dict = cgi.FieldStorage() grabs all data into a dictionary form_dict. The

Re: Delete all items in the list

2009-02-26 Thread Terry Reedy
Steve Holden wrote: Terry Reedy wrote: Gabriel Genellina wrote: L = filter('a'.__ne__,L) And this is probably the fastest. But not all types define __ne__ In Py3, all classes inherit .__ne__ from 'object'. Isn't that inherited method just an identity comparison? Yes. And so is, by

How can I know when a sub-process is effectively initialized?

2009-02-26 Thread Giampaolo Rodola'
Hi, I'm working on a Python module called psutil [1] for reading process information in a cross-platform way. I'm having a problem with psutil test suite. Almost all the test cases we implemented so far look like this: def test_foo(self): test_process = subprocess.Popen(sys.executable,

Re: Delete all items in the list

2009-02-26 Thread Steve Holden
Terry Reedy wrote: Steve Holden wrote: Terry Reedy wrote: Gabriel Genellina wrote: L = filter('a'.__ne__,L) And this is probably the fastest. But not all types define __ne__ In Py3, all classes inherit .__ne__ from 'object'. Isn't that inherited method just an identity comparison?

Re: Extending Python Questions .....

2009-02-26 Thread Nick Craig-Wood
Ben bnsili...@gmail.com wrote: On Feb 24, 11:31?am, Nick Craig-Wood n...@craig-wood.com wrote: So do you want to embed python into your code? I'm still not clear what you are trying to achieve with python, though I have a better idea what SLAG is now! Actually no, I want to EXTEND

Re: What functions, other than sleep(), can be interrupted by Ctrl-C?

2009-02-26 Thread Gabriel Genellina
En Thu, 26 Feb 2009 16:17:42 -0200, Maxim Khitrov mkhit...@gmail.com escribió: I'm looking for a function in the standard library or pywin32 package that will block until a certain condition is met or it is interrupted by Ctrl-C. For example, time.sleep() would have been perfect for my needs

Re: How can I know when a sub-process is effectively initialized?

2009-02-26 Thread Jean-Paul Calderone
On Thu, 26 Feb 2009 12:27:26 -0800 (PST), Giampaolo Rodola' gne...@gmail.com wrote: Hi, I'm working on a Python module called psutil [1] for reading process information in a cross-platform way. I'm having a problem with psutil test suite. Almost all the test cases we implemented so far look

best way to parse a function-call-like string?

2009-02-26 Thread mh
I have some strings that look like function calls, e.g. junkpkg.f1 junkpkg.f1() junkpkg.f1('aaa') junkpkg.f1('aaa','bbb') junkpkg.f1('aaa','bbb','ccc') junkpkg.f1('aaa','with,comma') and I need to split them into the function name and list of

Re: best way to parse a function-call-like string?

2009-02-26 Thread Tim Wintle
On Thu, 2009-02-26 at 21:29 +, m...@pixar.com wrote: I have some strings that look like function calls, e.g. junkpkg.f1 junkpkg.f1() junkpkg.f1('aaa') junkpkg.f1('aaa','bbb') junkpkg.f1('aaa','bbb','ccc') junkpkg.f1('aaa','with,comma') and I need to split them into the function

Re: best way to parse a function-call-like string?

2009-02-26 Thread Tim Wintle
On Thu, 2009-02-26 at 21:39 +, Tim Wintle wrote: On Thu, 2009-02-26 at 21:29 +, m...@pixar.com wrote: junkpkg.f1, ['aaa','with,comma'] oops - missed this one, ignore my last reply. -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to parse a function-call-like string?

2009-02-26 Thread Robert Kern
On 2009-02-26 15:29, m...@pixar.com wrote: I have some strings that look like function calls, e.g. junkpkg.f1 junkpkg.f1() junkpkg.f1('aaa') junkpkg.f1('aaa','bbb') junkpkg.f1('aaa','bbb','ccc') junkpkg.f1('aaa','with,comma') and I need to split

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Hrvoje Niksic
Raymond Hettinger pyt...@rcn.com writes: Here's a proposed implementation for Py2.7 and Py3.1: http://code.activestate.com/recipes/576669/ Several methods like __contains__() and __getitem__() are not overridden, so their performance is just as fast as a regular dictionary.

Re: best way to parse a function-call-like string?

2009-02-26 Thread mh
Robert Kern robert.k...@gmail.com wrote: On 2009-02-26 15:29, m...@pixar.com wrote: Use the compiler module to generate an AST and walk it. That's the real way. For me, that would also be the quick way because I am familiar with the API, but it may take you a little bit of time to get used

Can someone explain this behavior to me?

2009-02-26 Thread Jesse Aldridge
I have one module called foo.py - class Foo: foo = None def get_foo(): return Foo.foo if __name__ == __main__: import bar Foo.foo = foo bar.go() - And another one called bar.py - import foo def go(): assert

Re: best way to parse a function-call-like string?

2009-02-26 Thread John Machin
On Feb 27, 8:29 am, m...@pixar.com wrote: I have some strings that look like function calls, e.g.         junkpkg.f1         junkpkg.f1()         junkpkg.f1('aaa')         junkpkg.f1('aaa','bbb')         junkpkg.f1('aaa','bbb','ccc')         junkpkg.f1('aaa','with,comma') Examples are

Re: Can someone explain this behavior to me?

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 1:48 PM, Jesse Aldridge jessealdri...@gmail.com wrote: I have one module called foo.py - class Foo:    foo = None def get_foo():    return Foo.foo if __name__ == __main__:    import bar    Foo.foo = foo    bar.go() - And

Re: Can someone explain this behavior to me?

2009-02-26 Thread ma
I'm pretty sure that Foo is getting replaced once you import Foo, why not pass the Foo() object to bar's go? I'm sure there are other ways, but yes, circular imports are indeed evil. On Thu, Feb 26, 2009 at 5:13 PM, Chris Rebert c...@rebertia.com wrote: On Thu, Feb 26, 2009 at 1:48 PM, Jesse

PythonWin -vs- Idle

2009-02-26 Thread Gary Schells
Hello, Python newbie here. I am working with Python and geoprocessing in ArcGIS. I'm taking a training course online and the exercise I'm working on makes mention of using PythonWin instead of Idle. I am using version 2.5 and have not been able to locate PythonWin. The download just

Re: EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread jkv
Jean-Paul Calderone wrote: sys.stdout.write('Password: '); #IAC DO ECHO sys.stdout.write('\xFF\xFB\x01') password = raw_input() If the client sends 'qwerty\r\n' everything is fine and the password get stored in the variable. But sometimes, depending on how broken the telnet

Re: Battleship style game

2009-02-26 Thread Lie
On Feb 26, 3:50 am, Shawn Milochik sh...@milochik.com wrote: On Wed, Feb 25, 2009 at 11:38 AM, Marco Mariani ma...@sferacarta.com wrote: Yes it's in Python alright, but it's not Pythonese yet. You could try avoiding the getter/setter stuff, and camelCase method naming, things like that,

Re: PythonWin -vs- Idle

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells gsche...@hotmail.com wrote: Hello, Python newbie here.  I am working with Python and geoprocessing in ArcGIS. I'm taking a training course online and the exercise I'm working on makes mention of using PythonWin instead of Idle. I am using

Re: Can someone explain this behavior to me?

2009-02-26 Thread John Machin
On Feb 27, 8:48 am, Jesse Aldridge jessealdri...@gmail.com wrote: I have one module called foo.py - class Foo:     foo = None def get_foo():     return Foo.foo if __name__ == __main__:     import bar     Foo.foo = foo     bar.go() - And another

Re: EOL for sys.stdin.readline() and raw_input()

2009-02-26 Thread Jean-Paul Calderone
On Thu, 26 Feb 2009 23:32:13 +0100, jkv j...@unixcluster.dk wrote: Jean-Paul Calderone wrote: sys.stdout.write('Password: '); #IAC DO ECHO sys.stdout.write('\xFF\xFB\x01') password = raw_input() If the client sends 'qwerty\r\n' everything is fine and the password get stored in

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Raymond Hettinger
[Benjamin Peterson] Why not just inherit from collections.MutableMapping? It makes the recipe shorter to inherit some methods from dict. Also, subclassing from dict gives a speedup for __getitem__(), __len__(), and get(). -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to parse a function-call-like string?

2009-02-26 Thread Paul McGuire
On Feb 26, 3:29 pm, m...@pixar.com wrote: I have some strings that look like function calls, e.g.         junkpkg.f1         junkpkg.f1()         junkpkg.f1('aaa')         junkpkg.f1('aaa','bbb')         junkpkg.f1('aaa','bbb','ccc')         junkpkg.f1('aaa','with,comma') and I need to

  1   2   3   >