Re: descriptor & docstring

2008-04-28 Thread Gabriel Genellina
En Tue, 29 Apr 2008 01:29:40 -0300, George Sakkis <[EMAIL PROTECTED]> escribió: On Apr 28, 10:59 pm, "Gabriel Genellina" def property_default(prop_name, default_value=None, doc=None):      attr_name = '_'+prop_name      def fget(self, attr_name=attr_name,                     default_value=de

Re: File IO Issues, help :(

2008-04-28 Thread Peter Otten
Kevin K wrote: > On Apr 29, 12:55 am, Peter Otten <[EMAIL PROTECTED]> wrote: >> Kevin K wrote: >> > On Apr 29, 12:38 am, "Eric Wertman" <[EMAIL PROTECTED]> wrote: >> >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> >> are doing now. jsfile.flush() might work... not sure.

Re: Sphinx 0.2 released

2008-04-28 Thread Stefan Behnel
Hi Georg, Georg Brandl wrote: > I'm pleased to announce the release 0.2 of Sphinx, the Python documentation > generation tool. There were some intermediate smaller releases in the 0.1 > series, but for 0.2 there are quite a lot new features and fixes. > > What is it? > === > > Sphinx is

Re: python script as executable

2008-04-28 Thread Arnaud Delobelle
sandipm <[EMAIL PROTECTED]> writes: > Hi, > I have written a python script to run from cron. > I have put #!/usr/bin/env python at top. file executes correctly when > I run using python filename.py but > it fails to execute when try to run it like script/command. > it throws error: > :No such fil

Re: File IO Issues, help :(

2008-04-28 Thread Kevin K
On Apr 29, 12:55 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Kevin K wrote: > > On Apr 29, 12:38 am, "Eric Wertman" <[EMAIL PROTECTED]> wrote: > >> chuck in a jsfile.close(). The buffer isn't flushing with what you > >> are doing now. jsfile.flush() might work... not sure. Closing and > >> re-o

Re: File IO Issues, help :(

2008-04-28 Thread Peter Otten
Kevin K wrote: > On Apr 29, 12:38 am, "Eric Wertman" <[EMAIL PROTECTED]> wrote: >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> are doing now. jsfile.flush() might work... not sure. Closing and >> re-opening the file for sure will help though. >> > > Yeah sorry I forgo

Re: python script as executable

2008-04-28 Thread sandipm
thanks it worked On Apr 29, 10:49 am, "Eric Wertman" <[EMAIL PROTECTED]> wrote: > Try to ftp it in ascii mode, or find a dos2unix utility .. the file > has probably got \r\n (windows) line terminators in it.. causes > problems. I guess it's also possible that /usr/bin/env doesn't > exist... not

Re: File IO Issues, help :(

2008-04-28 Thread Kevin K
On Apr 29, 12:38 am, "Eric Wertman" <[EMAIL PROTECTED]> wrote: > chuck in a jsfile.close(). The buffer isn't flushing with what you > are doing now. jsfile.flush() might work... not sure. Closing and > re-opening the file for sure will help though. > Yeah sorry I forgot to include the close() i

Re: python script as executable

2008-04-28 Thread Eric Wertman
Try to ftp it in ascii mode, or find a dos2unix utility .. the file has probably got \r\n (windows) line terminators in it.. causes problems. I guess it's also possible that /usr/bin/env doesn't exist... not likely though. On Tue, Apr 29, 2008 at 1:36 AM, sandipm <[EMAIL PROTECTED]> wrote: > Hi

Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-28 Thread John Henry
On Apr 28, 12:41 pm, John Henry <[EMAIL PROTECTED]> wrote: > On Apr 27, 12:23 pm, Fred Pacquier <[EMAIL PROTECTED]> wrote: > > > > > Do keep us posted ! > > > TIA, > > fp > > Check it out now. > > Only one to be added is the Multicolumn List (table), and then menus. > The other widgets (Togglebutto

python script as executable

2008-04-28 Thread sandipm
Hi, I have written a python script to run from cron. I have put #!/usr/bin/env python at top. file executes correctly when I run using python filename.py but it fails to execute when try to run it like script/command. it throws error: :No such file or directory I am editing file from eclipse for

Re: File IO Issues, help :(

2008-04-28 Thread Eric Wertman
chuck in a jsfile.close(). The buffer isn't flushing with what you are doing now. jsfile.flush() might work... not sure. Closing and re-opening the file for sure will help though. On Tue, Apr 29, 2008 at 1:26 AM, Kevin K <[EMAIL PROTECTED]> wrote: > Hey everyone, I'm new to python and am trying

File IO Issues, help :(

2008-04-28 Thread Kevin K
Hey everyone, I'm new to python and am trying to do a little project with it. I'm running into problems writing over a file. I read from the file and loop through for a specfic case in which I change something. After I open and give it opening options (w, r, etc) one of two things happens: either t

Re: descriptor & docstring

2008-04-28 Thread George Sakkis
On Apr 28, 10:59 pm, "Gabriel Genellina" > def property_default(prop_name, default_value=None, doc=None): > >      attr_name = '_'+prop_name > >      def fget(self, attr_name=attr_name, >                     default_value=default_value): >          return getattr(self, attr_name, default_value) >

Re: cytpes **int

2008-04-28 Thread Gabriel Genellina
En Mon, 28 Apr 2008 18:55:15 -0300, Diez B. Roggisch <[EMAIL PROTECTED]> escribió: VernM schrieb: I am using ctypes to wrap a set of functions in a DLL. It has been going very well, and I am very impressed with ctypes. I want to call a c function with a signature of: void func(int **cube), wher

Re: Python Math libraries - How to?

2008-04-28 Thread Cousin Stanley
> > Here is the arithmetic program I made that it worked before I added > the "import math" line. > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math > > > NameError: global name 'pi' is not defined > >>> from math import * >>> >>> def surfac

Re: Python Math libraries - How to?

2008-04-28 Thread Terry Reedy
"Gary Herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: You have several ways to import a module, and your choice determines how you access things. Method 1: import math Then use: math.pi, math.sqrt, math.sin, math.cos, ... Method 2: from math imp

Re: descriptor & docstring

2008-04-28 Thread Gabriel Genellina
En Mon, 28 Apr 2008 14:35:40 -0300, cyril giraudon <[EMAIL PROTECTED]> escribió: Hello, I try to use python descriptors to define attributes with default value (the code is reported below). But apparently, it breaks the docstring mechanism. help(Basis) shows the right help but help(Rectangle

Re: Python Math libraries - How to?

2008-04-28 Thread aguirre . adolfo
Thank you :-), I´ll do Adolfo > > pi is not a global name. When you do "import math",you aren't adding > everything to the name space, you are just telling python that you are > going to be using that file. You then refer to it as math.*, such as > "math.pi", or "math.pow(r,3)". To use it the way y

Re: Python Math libraries - How to?

2008-04-28 Thread aguirre . adolfo
> > Thank you. I´ll try all methods to figure out the convenience of each Adolfo > > -- http://mail.python.org/mailman/listinfo/python-list

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread George Sakkis
On Apr 28, 10:10 pm, [EMAIL PROTECTED] wrote: > George, > > > Is there an elegant way to unget a line when reading from a file/stream > > iterator/generator? > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 > > That's exactly what I was looking for! > > For those following this t

Re: Python Math libraries - How to?

2008-04-28 Thread aguirre . adolfo
Hi, thak you. I get the following: > > > *** Error message * > > > Traceback (most recent call last): > > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, > > in > > > > main() > > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, > > in main > > vo

Re: xcode able to run script?

2008-04-28 Thread Stormbringer
On Apr 28, 1:52 pm, Alex Pavluck <[EMAIL PROTECTED]> wrote: > Does anyone know if it is possible to test your scripts from within > the xcode editor?  I am currently using Uilipad on windows and there > is a sub window that lets you view your output when you launch the > script from within the ide.

Re: Python Math libraries - How to?

2008-04-28 Thread Benjamin Kaplan
On Mon, Apr 28, 2008 at 10:07 PM, <[EMAIL PROTECTED]> wrote: > Hi, I am a very newbie who would very much appreciate some hints. > > Python 2.52. on Windows XP for now. Soon on Ubuntu 8 > > I am teaching myself Python following free tutorials. I can solve > problems using arithmetic, but when I

Re: Python Math libraries - How to?

2008-04-28 Thread John Henderson
[EMAIL PROTECTED] wrote: > Hi, I am a very newbie who would very much appreciate some > hints. > > Python 2.52. on Windows XP for now. Soon on Ubuntu 8 > > I am teaching myself Python following free tutorials. I can > solve problems using arithmetic, but when I try to upgrade the > programs usin

Re: Python Math libraries - How to?

2008-04-28 Thread Gary Herron
[EMAIL PROTECTED] wrote: Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math librarie

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread python
George, > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 That's exactly what I was looking for! For those following this thread, the above recipe creates a generic object that wraps a

Python Math libraries - How to?

2008-04-28 Thread aguirre . adolfo
Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math libraries nothing seems to work. I

Python Math libraries - How to?

2008-04-28 Thread aguirre . adolfo
Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math libraries nothing seems to work. I

Re: Receive data from socket stream

2008-04-28 Thread Gabriel Genellina
En Mon, 28 Apr 2008 19:29:33 -0300, <[EMAIL PROTECTED]> escribió: A question regarding cStringIO.StringIO(): is there a way to do get getvalue() to return all the bytes after the current file position (not before)? For example buf = cStringIO.StringIO() buf.write("foo bar") buf.seek(3) buf.getv

Re: Automating IE 6.0

2008-04-28 Thread Mike Driscoll
Michael Harris wrote: I tried to use the sample code to print a webpage via ie and I get the following error: Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__d

Re: Simple unicode-safe version of str(exception)?

2008-04-28 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > >> I have code like this: > >> except Exception, e: > >>self.setState(self.Failed, str(e)) > >> which fails if the exception contains a unicode argument. > > > > Fails how? > > ASCII encoding error, I suppose. It

Re: Question regarding Queue object

2008-04-28 Thread Terry
On Apr 28, 10:48 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I've never used it myself but you may find candygram > interesting;http://candygram.sourceforge.net, which AFAIK implements > Erlang-style > message queues in Python. Thank you. I will look at candygram and stackless. I believ

Re: Question regarding Queue object

2008-04-28 Thread Terry
On Apr 28, 5:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > David <[EMAIL PROTECTED]> wrote: > > Another idea would be to have multiple queues, one per thread or per > > message type "group". The producer thread pushes into the appropriate > > queues (through an intelligent PutMsg function)

Re: Simple unicode-safe version of str(exception)?

2008-04-28 Thread Martin v. Löwis
>> I have code like this: >> except Exception, e: >>self.setState(self.Failed, str(e)) >> which fails if the exception contains a unicode argument. > > Fails how? ASCII encoding error, I suppose. It fails only if a) one argument is a Unicode object, and b) that Unicode object contains non-ASC

Re: Tremendous slowdown due to garbage collection

2008-04-28 Thread Martin v. Löwis
> I do not argue that Python's default GC parameters must change -- only > that applications with lots of objects may want to consider a > reconfiguration. That's exactly what I was trying to say: it's not that the parameters are useful for *all* applications (that's why they are tunable parameter

Re: Receive data from socket stream

2008-04-28 Thread s0suk3
On Apr 28, 4:42 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > What you are missing is that if the recv ever returns no bytes at all > > then the other end has closed the connection. So something like this > > is the correct thing to write :- > > >

Re: py3k concerns. An example

2008-04-28 Thread Martin v. Löwis
> Unless I mix my psuedodicts with standard dicts > in the same list, for example, or pass them to > functions intended to accept any dict-like object, > including the especially important case of standard > dicts. > > Who knows? Maybe I'm wrong about this being a much of > problem. I think so.

Re: Given a string - execute a function by the same name

2008-04-28 Thread Max M
[EMAIL PROTECTED] skrev: I'm parsing a simple file and given a line's keyword, would like to call the equivalently named function. There are 3 ways I can think to do this (other than a long if/elif construct): 1. eval() 2. Convert my functions to methods and use getattr( myClass, "method" )

Re: cytpes **int

2008-04-28 Thread Diez B. Roggisch
VernM schrieb: I am using ctypes to wrap a set of functions in a DLL. It has been going very well, and I am very impressed with ctypes. I want to call a c function with a signature of: void func(int **cube), where the array if ints in cube is modified by func. I want to setup cube with int values

Re: Installed python 2.5 over 2.4 and lost installed packages

2008-04-28 Thread Jason
On Apr 28, 1:46 pm, [EMAIL PROTECTED] wrote: > On Apr 27, 8:42 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > > On Apr 27, 8:15 am, [EMAIL PROTECTED] wrote: > > > I recently updated os x from python 2.4 to 2.5 (from python.org) and > > > in doing so I lost my old python path entries. > > > So wha

Re: Little novice program written in Python

2008-04-28 Thread Rogério Brito
On 04/25/2008 09:30 AM, Nick Craig-Wood wrote: When you are up to speed in python I suggest you check out gmpy for number theory algorithms. Thanks. That is quite useful to know when I don't want to code explicitly the details of the algorithm. Thanks, Rogério. -- Rogério Brito : [EMAIL PR

Re: Little novice program written in Python

2008-04-28 Thread Rogério Brito
On 04/25/2008 05:00 AM, John Machin wrote: On Apr 25, 5:44 pm, Robert Bossy <[EMAIL PROTECTED]> wrote: If the OP insists in not examining a[0] and a[1], this will do exactly the same as the while version: for p in a[2:]: if p: print p ... at the cost of almost doubling the amount

Re: descriptor & docstring

2008-04-28 Thread cyril giraudon
A precision, I use python 2.5.2 under linux mandiva 2007.0 Cyril. -- http://mail.python.org/mailman/listinfo/python-list

Re: Little novice program written in Python

2008-04-28 Thread Rogério Brito
On 04/25/2008 01:30 AM, Steve Holden wrote: Rogério Brito wrote: I'm just getting my feet wet on Python and, just for starters, I'm coding some elementary number theory algorithms (yes, I know that most of them are already implemented as modules, but this is an exercise in learning the languag

Re: Little novice program written in Python

2008-04-28 Thread Rogério Brito
On 04/25/2008 01:09 AM, Dennis Lee Bieber wrote: On Thu, 24 Apr 2008 21:31:15 -0300, Rogério Brito <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: a = [i for i in range(0,n+1)] Uhm... At least in 2.4 and earlier, range() returns a list... No need for the list-comp in t

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread George Sakkis
On Apr 28, 2:07 pm, [EMAIL PROTECTED] wrote: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternative I can see is

Python-URL! - weekly Python news and links (Apr 28)

2008-04-28 Thread Gabriel Genellina
QOTW: "Posting to comp.lang.python is pair programming with the entire internet ;-)" - Nick Craig-Wood http://groups.google.com/group/comp.lang.python/msg/6f13cfca8a92c1a2 "When it got to the point where managers were asking, 'Why didn't you use the config check tool?', it was a done deal." -

Re: Simple unicode-safe version of str(exception)?

2008-04-28 Thread Bjoern Schliessmann
Russell E. Owen wrote: > I have code like this: > except Exception, e: >self.setState(self.Failed, str(e)) > which fails if the exception contains a unicode argument. Fails how? > I did, of course, try unicode(e) but that fails. Converting unicode to unicode doesn't help. Instead of just e

Re: Installed python 2.5 over 2.4 and lost installed packages

2008-04-28 Thread james
On Apr 27, 8:42 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Apr 27, 8:15 am, [EMAIL PROTECTED] wrote: > > I recently updated os x from python 2.4 to 2.5 (from python.org) and > > in doing so I lost my old python path entries. > > So what is the right thing to do in this situation? > > Is cp

Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-28 Thread John Henry
On Apr 27, 12:23 pm, Fred Pacquier <[EMAIL PROTECTED]> wrote: > > Do keep us posted ! > > TIA, > fp Check it out now. Only one to be added is the Multicolumn List (table), and then menus. The other widgets (Togglebutton, BitmapCanvas, Gauge, Notebook, CodeEditor) will not be implemented initially

Simple unicode-safe version of str(exception)?

2008-04-28 Thread Russell E. Owen
I have code like this: except Exception, e: self.setState(self.Failed, str(e)) which fails if the exception contains a unicode argument. I did, of course, try unicode(e) but that fails. The following works, but seems rather messy: except Exception, e: errStr = ",".join([unicode(s) for s i

Newbie Help - Alarms

2008-04-28 Thread Paul Jefferson
Hi, I'm new to this having previously done some programming in Game Maker. In Game Maker there was a function (Alarm) that lets you run a block of code run every x seconds without freezing up the whole program waiting for it. Is there an equavalant for this built in Python beacuse I can't find it?

Re: So you think PythonCard is old? Here's new wine in an old bottle.

2008-04-28 Thread Fred Pacquier
John Henry <[EMAIL PROTECTED]> said : > The performance of Qooxdoo is quite amazing - for a Javascript based > web application. Don't know about cell-phones though. You can try > their showcase web site I cited earlier. Just for the record, Nokia Internet tablets (770, N800, N810) are the only

Re: list.reverse()

2008-04-28 Thread Arnaud Delobelle
Mark Bryan Yu <[EMAIL PROTECTED]> writes: > This set of codes works: > x = range(5) x.reverse() x > [4, 3, 2, 1, 0] > > But this doesn't: > x = range(5).reverse() print x > None > > Please explain this behavior. range(5) returns a list from 0 to 4 and > reverse just revers

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternative I can see is to put my line rea

Re: Cookie Confusion - How to Set a Cookie

2008-04-28 Thread Aaron Watters
On Apr 28, 9:42 am, [EMAIL PROTECTED] wrote: > I see the cookie in my HTTP header > but do not get anything in the cookie text file. I'm working on > linux. > > print "Content-type: text/html" > cookie = Cookie.SimpleCookie() > cookie['Test'] = 'abc' > print cookie > print > > Are there rules

Re: list.reverse()

2008-04-28 Thread Gary Herron
Mark Bryan Yu wrote: This set of codes works: x = range(5) x.reverse() x [4, 3, 2, 1, 0] But this doesn't: x = range(5).reverse() print x None Please explain this behavior. range(5) returns a list from 0 to 4 and reverse just reverses the items on the list that is

Re: Tremendous slowdown due to garbage collection

2008-04-28 Thread John Nagle
Dieter Maurer wrote: Christian Heimes <[EMAIL PROTECTED]> writes on Sat, 12 Apr 2008 18:47:32 +0200: [EMAIL PROTECTED] schrieb: which made me suggest to use these as defaults, but then We observed similar very bad behaviour -- in a Web application server. Apparently, the standard behaviour i

Python 2.6, building SDL for Pygame

2008-04-28 Thread L. Lindstrom
I build the Pygame releases for Windows. Pygame wraps the Simple Directmedia Layer (SDL) C library. I am doing preliminary research into porting Pygame to Python 2.6. For Pythons 2.4 and 2.5 the Pygame extension modules are built with MinGW. They link cleanly against msvcr71.dll. A custom SDL,

cytpes **int

2008-04-28 Thread VernM
I am using ctypes to wrap a set of functions in a DLL. It has been going very well, and I am very impressed with ctypes. I want to call a c function with a signature of: void func(int **cube), where the array if ints in cube is modified by func. I want to setup cube with int values, and access them

list.reverse()

2008-04-28 Thread Mark Bryan Yu
This set of codes works: >>> x = range(5) >>> x.reverse() >>> x [4, 3, 2, 1, 0] But this doesn't: >>> x = range(5).reverse() >>> print x None Please explain this behavior. range(5) returns a list from 0 to 4 and reverse just reverses the items on the list that is returned by range(5). Why is x

How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread python
Is there an elegant way to unget a line when reading from a file/stream iterator/generator? By "unget" I mean a way to push back a line into the source stream and backtrack the iterator/generator one step? The only alternative I can see is to put my line reading in a while-True loop (vs. a for-lo

xcode able to run script?

2008-04-28 Thread Alex Pavluck
Does anyone know if it is possible to test your scripts from within the xcode editor? I am currently using Uilipad on windows and there is a sub window that lets you view your output when you launch the script from within the ide. hopefully this makes sense. thanks, Alex -- http://mail.python.or

Automating IE 6.0

2008-04-28 Thread Michael Harris
I tried to use the sample code to print a webpage via ie and I get the following error: Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" , line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\ie.py", line

descriptor & docstring

2008-04-28 Thread cyril giraudon
Hello, I try to use python descriptors to define attributes with default value (the code is reported below). But apparently, it breaks the docstring mechanism. help(Basis) shows the right help but help(Rectangle) shows only two lines : " Help on class Rectangle in module basis2: Rectangle = " I

Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread blaine
On Apr 28, 6:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > blaine <[EMAIL PROTECTED]> wrote: > > I'm trying to write a string matching algorithm for genomic > > sequences. I'm pulling out Genes from a large genomic pattern, with > > certain start and stop codons on either side. This is s

Re: Remove multiple inheritance in Python 3000

2008-04-28 Thread Dieter Maurer
Nick Stinemates <[EMAIL PROTECTED]> writes on Thu, 24 Apr 2008 08:26:57 -0700: > On Tue, Apr 22, 2008 at 04:07:01AM -0700, GD wrote: > > Please remove ability to multiple inheritance in Python 3000. I hope your request will not be followed. > > Multiple inheritance is bad for design, rarely used

Re: Given a string - execute a function by the same name

2008-04-28 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClas

Re: Given a string - execute a function by the same name

2008-04-28 Thread Gary Herron
[EMAIL PROTECTED] wrote: I'm parsing a simple file and given a line's keyword, would like to call the equivalently named function. There are 3 ways I can think to do this (other than a long if/elif construct): 1. eval() 2. Convert my functions to methods and use getattr( myClass, "method" )

bisect intersection

2008-04-28 Thread Robert Bossy
Hi, I stumbled into a sorted list intersection algorithm by Baeza-Yates which I found quite elegant. For the lucky enough to have a springerlink access, here's the citation: http://dblp.uni-trier.de/rec/bibtex/conf/cpm/Baeza-Yates04 I implemented this algorithm in python and I thought I could

Re: Given a string - execute a function by the same name

2008-04-28 Thread Matimus
On Apr 28, 9:33 am, [EMAIL PROTECTED] wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and us

Re: Given a string - execute a function by the same name

2008-04-28 Thread marek . rocki
One solution may be to use globals(): >>> globals()['foo']() Regards, Marek -- http://mail.python.org/mailman/listinfo/python-list

Re: Tremendous slowdown due to garbage collection

2008-04-28 Thread Dieter Maurer
"Martin v. Löwis" wrote at 2008-4-27 19:33 +0200: >> Martin said it but nevertheless it might not be true. >> >> We observed similar very bad behaviour -- in a Web application server. >> Apparently, the standard behaviour is far from optimal when the >> system contains a large number of objects an

Re: Given a string - execute a function by the same name

2008-04-28 Thread Robert Bossy
[EMAIL PROTECTED] wrote: I'm parsing a simple file and given a line's keyword, would like to call the equivalently named function. There are 3 ways I can think to do this (other than a long if/elif construct): 1. eval() 2. Convert my functions to methods and use getattr( myClass, "method" )

Given a string - execute a function by the same name

2008-04-28 Thread python
I'm parsing a simple file and given a line's keyword, would like to call the equivalently named function. There are 3 ways I can think to do this (other than a long if/elif construct): 1. eval() 2. Convert my functions to methods and use getattr( myClass, "method" ) 3. Place all my functions i

Re: class or class-instance ?

2008-04-28 Thread Stef Mientki
There is a isclass in the module inspect. Diez thanks Diez, that's exactly what I was looking for. cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list

Re: Receive data from socket stream

2008-04-28 Thread Jean-Paul Calderone
On Mon, 28 Apr 2008 07:26:13 -0700 (PDT), [EMAIL PROTECTED] wrote: [snip] BTW, has anybody used sockets as file-like objects (client.makefile())? Is it more secure? More efficient? It's not more (or less) secure. In certain cases, it's significantly less efficient. It's for simplicity of pr

Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread Helmut Jarausch
blaine wrote: Hey everyone, For the regular expression gurus... I'm trying to write a string matching algorithm for genomic sequences. I'm pulling out Genes from a large genomic pattern, with certain start and stop codons on either side. This is simple enough... for example: start = AUG sto

Wing IDE 3.1beta3 released

2008-04-28 Thread Wingware
Hi, Wingware has released version 3.1 beta3 of Wing IDE, an integrated development environment for the Python programming language. It is available from: http://wingware.com/wingide/beta This release includes the following changes: * How-To and improvements for using Wing IDE with Google App E

Wing IDE 3.0.5 released

2008-04-28 Thread Wingware
Hi, We're happy to announce version 3.0.5 of Wing IDE, an integrated development environment for the Python programming language. It is available from: http://wingware.com/downloads Version 3.0.5 is a bug fix release that adds many vi mode improvements, improves stability, and fixes other usabi

Re: Question regarding Queue object

2008-04-28 Thread [EMAIL PROTECTED]
I've never used it myself but you may find candygram interesting; http://candygram.sourceforge.net, which AFAIK implements Erlang-style message queues in Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieving int from hex in a file.

2008-04-28 Thread Grant Edwards
On 2008-04-28, Filipe Teixeira <[EMAIL PROTECTED]> wrote: > Hi. > > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > > f=open('file.bin','rb') > a=f.read() > f.close() > > a in now a string full of hex representations in the form:

Re: Receive data from socket stream

2008-04-28 Thread Hrvoje Niksic
Nick Craig-Wood <[EMAIL PROTECTED]> writes: >> Note that appending to a string is almost never a good idea, since it >> can result in quadratic allocation. > > My aim was clear exposition rather than the ultimate performance! That would normally be fine. My post wasn't supposed to pick perform

Re: API's and hardware communication. Newbie

2008-04-28 Thread Grant Edwards
On 2008-04-26, Grayham <[EMAIL PROTECTED]> wrote: > Hi all > > I am new to this group so 'Hello All' > > I have a PC which is running linux and in it have installed a digital > satellite card. I would like to write some software to access the card, > tune it and bring back video. Basically a home b

Re: Receive data from socket stream

2008-04-28 Thread s0suk3
On Apr 28, 4:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I wanted to ask for standard ways to receive data from a socket stream > > (with socket.socket.recv()). It's simple when you know the amount of > > data that you're going to receive,

Chapter on real-time signal processing using numerical Python

2008-04-28 Thread Johannes Nix
Hi, this might be of interest for people who are look for practical information on doing real-time signal processing, possibly using multiple CPUs, and wonder whether it's possible to use Python for audio-type worst case latencies (around 25 ms). I've done that in my PhD work, both with real-time

Re: ANN: pyspread 0.0.4

2008-04-28 Thread Martin Manns
On Sun, 27 Apr 2008 05:21:56 +0200 Martin Manns <[EMAIL PROTECTED]> wrote: > The newest version pyspread 0.0.4 now runs on > + GTK > + Windows > + Mac (not tested myself but got positive reports) > > New features in 0.0.4: > + Column, line and table insertion and deletion > + Themeable toolbar

Re: Receive data from socket stream

2008-04-28 Thread Jean-Paul Calderone
On Mon, 28 Apr 2008 08:30:03 -0500, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: Hrvoje Niksic <[EMAIL PROTECTED]> wrote: Nick Craig-Wood <[EMAIL PROTECTED]> writes: > What you are missing is that if the recv ever returns no bytes at all > then the other end has closed the connection. So someth

Cookie Confusion - How to Set a Cookie

2008-04-28 Thread cbhoem
Hi - I am trying my hand at python cookies. I'm confused about a few things though. Do the python cookies get written to a cookies text file? I have simple code below -- I see the cookie in my HTTP header but do not get anything in the cookie text file. I'm working on linux. print "Content-ty

is there a threadsafe cookie library?

2008-04-28 Thread fritz
I'm working with a script written in python2.4 that has to handle multiple http connections but I'm having concurrency issues with cookielib. Does anyone know of a threadsafe library that handles cookies? -- http://mail.python.org/mailman/listinfo/python-list

Re: Receive data from socket stream

2008-04-28 Thread Nick Craig-Wood
Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > > What you are missing is that if the recv ever returns no bytes at all > > then the other end has closed the connection. So something like this > > is the correct thing to write :- > > > > data = "" > >

Re: function that accepts any amount of arguments?

2008-04-28 Thread Bruno Desthuilliers
Lie a écrit : On Apr 25, 2:12 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: (...) FWIW, I'd personnaly write avg as taking a sequence - ie, not using varargs - in which case calling it without arguments would a TypeError (so BTW please s/Value/Type/ in my previous post). The problem wi

Checking for existance of feature / tools / solutions -- Something like Java webstart

2008-04-28 Thread Banibrata Dutta
Hi, I've tried searching this list & googling around a bit -- trying to see if there is a Java-Webstart like alternative for Python, the closest approximate I've found is something suggested in this post: http://mail.python.org/pipermail/python-list/2004-September/282837.html Is this still prett

Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread Jeff
Regular expressions for that sort of thing can get *really* big. The most efficient way would be to programmatically compose the regular expression to be as exact as possible. import re def permutation(lst): From http://labix.org/snippets/permutations/. Computes permutations

Re: Need help on left padding

2008-04-28 Thread Albert Leibbrandt
Marc 'BlackJack' Rintsch wrote: On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote: My requirement is I am using one variable ex. var = 5 which is integer. And this variable, I m using in some string. But I want this var to be used as 005 again integer in this string.

Re: Retrieving int from hex in a file.

2008-04-28 Thread Filipe Teixeira
> > Use ord(q) > > py> help(ord) > Help on built-in function ord in module __builtin__: > > ord(...) > ord(c) -> integer > > Return the integer ordinal of a one-character string. > > py> > > -- > Gabriel Genellina Thank you Gabriel. It fit's my purpose. -- http://mail.python.org/mailman

Re: Retrieving int from hex in a file.

2008-04-28 Thread bgeddy
Filipe Teixeira wrote: Hi. I have to open a binary file from an old computer and recover the information stored (or at least try to). I use: f=open('file.bin','rb') a=f.read() f.close() a in now a string full of hex representations in the form: a[6]='\x14' a[7]='\x20' I would like to convert

Re: apache module: python and web programming, easy way...?

2008-04-28 Thread Graham Dumpleton
On Apr 28, 7:42 pm, bvidinli <[EMAIL PROTECTED]> wrote: > is there any apache module, you know, that i can just install with apt-get, > then put my .py file, and run it ? http://www.modwsgi.org http://www.modpython.org The mod_wsgi module supports WSGI (http://www.wsgi.org) specification which is

Re: Need help on left padding

2008-04-28 Thread Marc 'BlackJack' Rintsch
On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote: > My requirement is I am using one variable ex. var = 5 which is > integer. > And this variable, I m using in some string. But I want this var > to be used as 005 again integer in this string. In [22]: '%03d' % 5 Out[22]: '005'

  1   2   >