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

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

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: 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 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: 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 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: 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
> > Thank you. I´ll try all methods to figure out the convenience of each Adolfo > > -- http://mail.python.org/mailman/listinfo/python-list

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

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

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

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

<    1   2