Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 10:26 PM, odeits wrote: > On Feb 26, 3:05 am, Clarendon 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

Re: Delete all items in the list

2009-02-26 Thread odeits
On Feb 26, 3:05 am, Clarendon 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 list. > But if L.remove('a') o

Re: PythonWin -vs- Idle

2009-02-26 Thread Niklas Norrthon
On 27 Feb, 01:40, Steve Holden wrote: > Chris Rebert wrote: > > On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells 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 > >> ment

Re: removing duplication from a huge list.

2009-02-26 Thread odeits
On Feb 26, 9:15 pm, Chris Rebert wrote: > On Thu, Feb 26, 2009 at 8:49 PM, Benjamin Peterson > wrote: > > Shanmuga Rajan gmail.com> writes: > > >> f any one suggests better solution then i will be very happy.Advance thanks > > for any help.Shan > > > Use a set. > > To expand on that a bit: > >

Killing Child Process

2009-02-26 Thread tarun
Hello Group, I've spwaned a process using os.spwanl. As part of this process, I spwan one more process, using subprocess.Popen. After I close the the process spwaned using os.spwanl, the child process started by it using subprocess.Popen, doesn't get closed. Is there any way to do this in python 2

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, 11:14 pm, "Paddy O'Loughlin" wrote: > 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 > fr

Re: removing duplication from a huge list.

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 8:49 PM, Benjamin Peterson wrote: > Shanmuga Rajan gmail.com> writes: > >> f any one suggests better solution then i will be very happy.Advance thanks > for any help.Shan > > Use a set. To expand on that a bit: counted_recs = set(rec[0] for rec in some_fun()) #or in Pyth

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 8:39 PM, Anjanesh Lekshminarayanan wrote: >> How do we know that from the what the OP posted? > Its CGI alright. > spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' > > But I just dont see how > spaces = (form.has_key('spaces') ? form.getvalue('spaces') ==

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Raymond Hettinger
[Paul Rubin] > Ehh, I guess I'm not surprised at the slowdown and extra complexity > from the second dict.  Oh well.  If the module really turns out to be > really used a lot, another (messy) approach would be to write a C > extension that uses a doubly linked list some day. That seems like an ide

Re: removing duplication from a huge list.

2009-02-26 Thread Benjamin Peterson
Shanmuga Rajan gmail.com> writes: > f any one suggests better solution then i will be very happy.Advance thanks for any help.Shan Use a set. -- http://mail.python.org/mailman/listinfo/python-list

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-26 Thread Dan Goodman
MRAB wrote: Here's my solution (I haven't bothered with making it efficient, BTW): import operator def solve(n): best_len = n best_expr = "" for x in range(1, n - 2): for y in range(x, n): for op, name in operator_list: # Does this pair with this

Re: Multiple conditional expression

2009-02-26 Thread Anjanesh Lekshminarayanan
> How do we know that from the what the OP posted? Its CGI alright. spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' But I just dont see how spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True: False : False) is complicated in anyway. Its not that hard to read

Re: Multiple conditional expression

2009-02-26 Thread Grant Edwards
On 2009-02-27, Paul Rubin wrote: > But the == 1 comparison will always fail, since getvalue returns a string. How do we know that from the what the OP posted? -- Grant -- http://mail.python.org/mailman/listinfo/python-list

removing duplication from a huge list.

2009-02-26 Thread Shanmuga Rajan
Hi I have a list of Records with some details.(more than 15 million records) with duplication I need to iterate through every record and need to eliminate duplicate records. Currently i am using a script like this. counted_recs = [ ] x = some_fun() # will return a generator, this generator

[numerical optimization] Poll "what do you miss in OpenOpt framework"

2009-02-26 Thread dmitrey
Hi all, I created a poll "what do you miss in OpenOpt framework", could you take participation? http://www.doodle.com/participation.html?pollId=a78g5mk9sf7dnrbe Let me remember for those ones who is not familiar with OpenOpt - it's a free Python-written numerical optimization framework: http://o

Re: Queries

2009-02-26 Thread mmcclaf
Another problem with this assignment... I have to list all the ships mentioned in the database. All the ships may not appear in the Ships relations... I said the following in algebraic expression SELECT name(Ships UNION (SELECT ship (Outcome UNION(SELECT class (Classes))) Would that work? -- http

Re: PythonWin -vs- Idle

2009-02-26 Thread alex23
On Feb 27, 8:40 am, Chris Rebert wrote: > On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells wrote: > > I am using version 2.5 and have not been able to locate PythonWin.  The > > download just includes Idle for the environment.  Can anyone point me in the > > right direction to download the PythonWin

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2009-02-26 Thread Anjanesh Lekshminarayanan
> (1) what is produced on Anjanesh's machine >>> sys.getdefaultencoding() 'utf-8' > (2) it looks like a small snippet from a Python source file! Its a file containing just JSON data - but has some unicode characters as well as it has data from the web. > Anjanesh, Is it a .py file Its a .json fil

Re: Multiple conditional expression

2009-02-26 Thread Paul Rubin
Chris Rebert writes: > spaces = bool(form.has_key('spaces') and form.getvalue('spaces') == 1) spaces = form.has_key('spaces') and form.getvalue('spaces') == 1 or even (this is about the cgi module, I think) spaces = form.getvalue('spaces', None) == 1 But the == 1 comparison will always fail,

Re: Multiple conditional expression

2009-02-26 Thread Grant Edwards
On 2009-02-27, Anjanesh Lekshminarayanan wrote: > How do I achieve something like this using python ? > spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True : > False : False) if form.has_key('spaces'): spaces = form.getvalue('spaces') == 1 else: spaces = Fal

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 7:11 PM, Anjanesh Lekshminarayanan wrote: > How do I achieve something like this using python ? > spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True > : False : False) > > spaces = True if form.getvalue('spaces') == 1 if > form.has_key('spaces') else Fal

Re: Multiple conditional expression

2009-02-26 Thread Steve Holden
Anjanesh Lekshminarayanan wrote: > How do I achieve something like this using python ? > spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True > : False : False) > > spaces = True if form.getvalue('spaces') == 1 if > form.has_key('spaces') else False else False If you've got any

Multiple conditional expression

2009-02-26 Thread Anjanesh Lekshminarayanan
How do I achieve something like this using python ? spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True : False : False) spaces = True if form.getvalue('spaces') == 1 if form.has_key('spaces') else False else False -- Anjanesh Lekshmnarayanan -- http://mail.python.org/mailman/l

factoring wx.Image

2009-02-26 Thread Astan Chee
Hi, I want to factor (red, green and blue at the same time) an image using wx but without any GUI display or windows but it keeps crashing and if I set the checks to ignore it, it doesn't produce the images at all. It looks like this: import wx img = wx.Image("star.jpg",wx.BITMAP_TYPE_BMP) fac

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-26 Thread geremy condra
Use 1 and 2 and treat them as equivalent to boolean true and false. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using xreadlines

2009-02-26 Thread bearophileHUGS
Brett Hedges: > My question is how do I go to a previous line in the file? xreadlines has a > file.next() statement that gives the next line, and I need a statement that > gives me the previous line.< In modern versions of Python you usually don't need xreadlines, because files are iterable. If

Re: Using xreadlines

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:32 PM, Brett Hedges wrote: > > Hi, > > I am using both xreadlines and files iterators for a script that I need to > finish. I am iterating over the entire file but stopping to use xreadlines to > grab certain lines as strings to process them. > > My question is how do I

Re: PythonWin -vs- Idle

2009-02-26 Thread Steve Holden
Chris Rebert wrote: > On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells 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

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:37 PM, Gabriel Genellina wrote: > En Thu, 26 Feb 2009 22:18:18 -0200, Chris Rebert > escribió: >> >> On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam >> wrote: >>> >>> On 2009-02-26, Clarendon wrote: Hi. This must be a simple command but I just can't find it in

Using xreadlines

2009-02-26 Thread Brett Hedges
Hi, I am using both xreadlines and files iterators for a script that I need to finish. I am iterating over the entire file but stopping to use xreadlines to grab certain lines as strings to process them. My question is how do I go to a previous line in the file? xreadlines has a file.next() s

Re: Can someone explain this behavior to me?

2009-02-26 Thread Steve Holden
Jesse Aldridge 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 one called bar.py >

Re: Delete all items in the list

2009-02-26 Thread Gabriel Genellina
En Thu, 26 Feb 2009 22:18:18 -0200, Chris Rebert escribió: On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam wrote: On 2009-02-26, Clarendon 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? F

Re: Delete all items in the list

2009-02-26 Thread Steve Holden
Peter Billam wrote: > On 2009-02-26, Clarendon 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 list. > But

Re: Delete all items in the list

2009-02-26 Thread Peter Billam
On 2009-02-27, Chris Rebert wrote: > On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam wrote: >> On 2009-02-26, Clarendon wrote: >>> How do you delete all 'a's? >> >> L2 = list(set(L)) >> works for me... > > A. That doesn't by itself remove all the 'a's, although it does > remove all but 1 'a' > B.

Re: Delete all items in the list

2009-02-26 Thread Gabriel Genellina
En Thu, 26 Feb 2009 22:08:26 -0200, Peter Billam escribió: On 2009-02-26, Clarendon 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

Re: a look at the browser scene & emacs

2009-02-26 Thread Xah Lee
On Feb 26, 1:59 am, Tassilo Horn wrote: > Xah Lee 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 woul

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam wrote: > On 2009-02-26, Clarendon 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 dele

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-26 Thread MRAB
Trip Technician wrote: anyone interested in looking at the following problem. we are trying to express numbers as minimal expressions using only the digits one two and three, with conventional arithmetic. so for instance 33 = 2^(3+2)+1 = 3^3+(3*2) are both minimal, using 4 digits but 33 = ((3

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-26 Thread Rhodri James
On Thu, 26 Feb 2009 23:10:20 -, Jonathan Gardner wrote: [snip] For each iteration, you take each surviving walker and spawn a new walker that takes a step in each possible direction. Then you check if any of those walkers found the value you are looking for. If so, you've found the answe

Re: Delete all items in the list

2009-02-26 Thread Peter Billam
On 2009-02-26, Clarendon 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 list. > But if L.remove('a') > only de

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Paul Rubin
Raymond Hettinger writes: > > What about using a second dictionary > My first attempt used exactly that approach and it works fine > though it does complicate the code quite a bit and slows down > all of the common operations by a constant factor. Ehh, I guess I'm not surprised at the slowdown a

Re: Can someone explain this behavior to me?

2009-02-26 Thread Albert Hopkins
On Thu, 2009-02-26 at 13:48 -0800, Jesse Aldridge 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() > - > A

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Raymond Hettinger
> > What about using a second dictionary (indexed by the incrementing > > counter) instead of a list to record the insertion order?  Then you > > have O(1) deletion, and traversal takes an O(n log n) sorting > > operation. > My first attempt used exactly that approach and it works fine > though it

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Raymond Hettinger
[Paul Rubin] > What about using a second dictionary (indexed by the incrementing > counter) instead of a list to record the insertion order?  Then you > have O(1) deletion, and traversal takes an O(n log n) sorting > operation. My first attempt used exactly that approach and it works fine though i

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Paul Rubin
Raymond Hettinger writes: > I don't see any fast/clean way. It's possible to tracking pending > deletions and do them all at once but that's a bit messy and slow. What about using a second dictionary (indexed by the incrementing counter) instead of a list to record the insertion order? Then you

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-26 Thread Jonathan Gardner
On Feb 20, 6:31 am, Trip Technician wrote: > anyone interested in looking at the following problem. > > we are trying to express numbers as minimal expressions using only the > digits one two and three, with conventional arithmetic. so for > instance > > 33 = 2^(3+2)+1 = 3^3+(3*2) > > are both min

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Raymond Hettinger
[Hrvoje Niksic] > It seems that __delitem__ of an existing key is O(n), whereas it's > amortized constant time for dicts.  (__setitem__ is constant time for > both.)  Is there a way to avoid this? I don't see any fast/clean way. It's possible to tracking pending deletions and do them all at once

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')

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: 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 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 the variable. But som

Re: Can someone explain this behavior to me?

2009-02-26 Thread John Machin
On Feb 27, 8:48 am, Jesse Aldridge 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 one c

Re: PythonWin -vs- Idle

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells 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 version 2.5 and have

Re: "Battleship" style game

2009-02-26 Thread Lie
On Feb 26, 3:50 am, Shawn Milochik wrote: > On Wed, Feb 25, 2009 at 11:38 AM, Marco Mariani 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, for a start. > > > -- > >http://m

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 clien

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 includ

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 wrote: > On Thu, Feb 26, 2009 at 1:48 PM, Jesse Aldridge > wrote:

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 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 anoth

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')

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 f

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

2009-02-26 Thread mh
Robert Kern 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 to it. ah, that's

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Hrvoje Niksic
Raymond Hettinger 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. Methods l

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 nee

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 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

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 li

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' 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 like this: def test

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 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 if thread.interrupt

Re: Extending Python Questions .....

2009-02-26 Thread Nick Craig-Wood
Ben wrote: > On Feb 24, 11:31?am, Nick Craig-Wood 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 python using the lower levels

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 id

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, stdout=

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 defau

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 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 rest becomes a pie

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 in

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 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 E

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 fro

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: 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 c

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 obje

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 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):

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 i

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):

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: sys.s

Re: Proposed implementation for an Ordered Dictionary

2009-02-26 Thread Benjamin Peterson
Raymond Hettinger 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 > modifica

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 int

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 escribió: On Feb 26, 7:47 pm, Tim Wintle 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 ev

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):

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 wil

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: sys.s

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 ma

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: 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 "traditio

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: myPat

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 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 > > any simpler way w

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

Re: Delete all items in the list

2009-02-26 Thread Gabriel Genellina
En Thu, 26 Feb 2009 11:00:30 -0200, Boris Borcic escribió: Chris Rebert wrote: On Thu, Feb 26, 2009 at 3:05 AM, Clarendon 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 s

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 ha

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-

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

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

  1   2   >