Re: Method much slower than function?

2007-06-13 Thread Bruno Desthuilliers
Neil Cerutti a écrit : (snip) > class bar: > def readgenome(self, filehandle): > self.s = ''.join(line.strip() for line in filehandle) => self.s = ''.join(line.strip() for line in filehandle if not '>' in line) -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamically generated runtime methods & reflection

2007-06-13 Thread Josiah Carlson
Jay Loden wrote: > Hi all, > > First, apologies if anyone gets this twice, but it took me quite a > while to figure out that Python.org is evidently rejecting all mail > from my mail server because I don't have reverse DNS configured. > Anyway: > > I'm not even sure how to phrase this question pr

Re: How to save python codes in files?

2007-06-13 Thread Gabriel Genellina
En Thu, 14 Jun 2007 01:56:13 -0300, why? <[EMAIL PROTECTED]> escribió: > I tried but its not working. Here's a code for sum of two numbers. Now > how do i save it? > #! /usr/bin/env python > ... def sum(x,y): > ... return x+y > ... x=int(raw_input('Enter a number: ')) > Enter a

Re: How to save python codes in files?

2007-06-13 Thread why?
Also, how can i save a file using text editor in linux? -- http://mail.python.org/mailman/listinfo/python-list

Re: Method much slower than function?

2007-06-13 Thread Leo Kislov
On Jun 13, 5:40 pm, [EMAIL PROTECTED] wrote: > Hi all, > > I am running Python 2.5 on Feisty Ubuntu. I came across some code that > is substantially slower when in a method than in a function. > > >>> cProfile.run("bar.readgenome(open('cb_foo'))") > > 20004 function calls in 10.214 CPU sec

Re: Method much slower than function?

2007-06-13 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > take virtually the same amount of time on my machine (2.5), and the > non-join version is clearer, IMO. I'd still use join in case I wind > up running under an older Python, but it's probably not a big issue here. You should not rely on using 2.5

Re: Method much slower than function?

2007-06-13 Thread Gabriel Genellina
En Thu, 14 Jun 2007 01:39:29 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > Gabriel Genellina wrote: >> In addition, += is rather inefficient for strings; the usual idiom is >> using ''.join(items) > > Ehh. Python 2.5 (and probably some earlier versions) optimize += on > strings prett

Re: save class

2007-06-13 Thread Josiah Carlson
Gabriel Genellina wrote: > En Wed, 13 Jun 2007 23:11:22 -0300, nik <[EMAIL PROTECTED]> escribió: >> It would seem that I want to actually save the source code for the >> class. I know that I could of course open up an editor and just make >> it, but my ideal would be to have the base class, Map, be

Re: passing arguments to tcpserver classes

2007-06-13 Thread Mark T
"Eric Spaulding" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there an easy way to pass arguments to a handler class that is used by > the standard TCPServer? > > normally --> srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass) > > I'd like to be able to: srvr =Socke

Re: How to save python codes in files?

2007-06-13 Thread why?
I tried but its not working. Here's a code for sum of two numbers. Now how do i save it? >>> #! /usr/bin/env python ... >>> def sum(x,y): ... return x+y ... >>> x=int(raw_input('Enter a number: ')) Enter a number: 35 >>> y=int(raw_input('Enter a number: ')) Enter a number: 7 >>> print 'sum is

dynamically generated runtime methods & reflection

2007-06-13 Thread Jay Loden
Hi all, First, apologies if anyone gets this twice, but it took me quite a while to figure out that Python.org is evidently rejecting all mail from my mail server because I don't have reverse DNS configured. Anyway: I'm not even sure how to phrase this question properly or the right terminology o

Re: passing arguments to tcpserver classes

2007-06-13 Thread Justin Ezequiel
On Jun 13, 10:19 pm, Eric Spaulding <[EMAIL PROTECTED]> wrote: > Is there an easy way to pass arguments to a handler class that is used > by the standard TCPServer? > > normally --> srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass) > > I'd like to be able to: srvr =SocketServer.TCPServer

Re: Method much slower than function?

2007-06-13 Thread [EMAIL PROTECTED]
Gabriel Genellina wrote: > In the function above, s is a local variable, and accessing local > variables is very efficient (using an array of local variables, the > compiler assigns statically an index for each one). > Using self.s, on the other hand, requires a name lookup for each access. > The m

Re: Build EXE on Mac OsX 10.4

2007-06-13 Thread Sherm Pendley
"Gabriel Genellina" <[EMAIL PROTECTED]> writes: > En Wed, 13 Jun 2007 17:35:19 -0300, Paul McNett <[EMAIL PROTECTED]> escribió: > >> Tempo wrote: >>> Has anyone sucesfully built a *.exe file on a mac operating system >>> before from a *.py file? I have been trying to do this with >>> pyinstaller,

Re: Method much slower than function?

2007-06-13 Thread Grant Edwards
On 2007-06-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > The method takes > 10 seconds, the function call 0.041 seconds! What happens when you run them in the other order? The first time you read the file, it has to read it from disk. The second time, it's probably just reading from the buf

Re: SimplePrograms challenge

2007-06-13 Thread Steven Bethard
Rob Wolfe wrote: > # HTML page > dinner_recipe = ''' > Recipe > > amtunititem > 24slicesbaguette > 2+tbspolive_oil > 1cuptomatoes > 1-2tbspgarlic > 1/2cupParmesan > 1jarpesto > > ''' > > # program > import xml.etree.ElementTree as etree > tree = etree.fromstring(dinner_recipe) > > #import Eleme

Re: one-time initialization of class members

2007-06-13 Thread Steven Bethard
James Turk wrote: > It actually occured to me that I could use a @classmethod to do the > loading and take that out of the BaseClass constructor. What I have > makes more sense and eliminates the unecessary constructors. > > ie. > > class BaseClass: > @classmethod > def loadData(params):

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-13 Thread John Nagle
Paul Rubin wrote: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > >>And if only the html-parsing is slow, you might consider creating an >>extension for that. Using e.g. Pyrex. > > > I just tried using BeautifulSoup to pull some fields out of some html > files--about 2 million files, output o

Re: save class

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 23:11:22 -0300, nik <[EMAIL PROTECTED]> escribió: > On Jun 13, 6:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> En Wed, 13 Jun 2007 22:20:16 -0300, nik <[EMAIL PROTECTED]> escribió: >> >> > I would like to create a class and then save it for re-use later. I >> > hav

Re: SimplePrograms challenge

2007-06-13 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > Rob Wolfe wrote: > > Steve Howell wrote: > > > >> I suggested earlier that maybe we post multiple > >> solutions. That makes me a little nervous, to > the > >> extent that it shows that the Python community > has a > >> hard time coming to consens

Re: Cretins.

2007-06-13 Thread Cousin Stanley
> On Thu, 14 Jun 2007 09:32:10 +1000, Ben Finney wrote: > >> "Dr. Pastor" <[EMAIL PROTECTED]> writes: >> >>> Please do not do business with those cretins >>> who without authorization attaching [spam footers] >> >> Indeed. The cost of Usenet access should not be translated >> to spam on message

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-13 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > And if only the html-parsing is slow, you might consider creating an > extension for that. Using e.g. Pyrex. I just tried using BeautifulSoup to pull some fields out of some html files--about 2 million files, output of a web crawler. It parsed very

Re: save class

2007-06-13 Thread nik
On Jun 13, 6:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 13 Jun 2007 22:20:16 -0300, nik <[EMAIL PROTECTED]> escribió: > > > I would like to create a class and then save it for re-use later. I > > have tried to usepickle, but am not sure if that is right. I am > > sorry, but I a

Re: save class

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 22:20:16 -0300, nik <[EMAIL PROTECTED]> escribió: > I would like to create a class and then save it for re-use later. I > have tried to use pickle, but am not sure if that is right. I am > sorry, but I am new to python. Do you want to save the *source*code* of your class, or d

Re: one-time initialization of class members

2007-06-13 Thread James Turk
On Jun 13, 9:03 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 13 Jun 2007 23:55:02 +, James Turk wrote: > > On Jun 13, 6:54 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > >> James Turk wrote: > >> > Hi, > > >> > I have a situation where I have some class members that should only be

Re: How can I capture all exceptions especially when os.system() fail? Thanks

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 21:47:16 -0300, mike <[EMAIL PROTECTED]> escribió: > Following piece of code can capture IOError when the file doesn't > exist, also, other unknown exceptions can be captured when I press > Ctrl-C while the program is sleeping(time.sleep). Now the question is: > when I run the

Re: Method much slower than function?

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 21:40:12 -0300, <[EMAIL PROTECTED]> escribió: > Hi all, > > I am running Python 2.5 on Feisty Ubuntu. I came across some code that > is substantially slower when in a method than in a function. > > # START SOURCE # > # The function > > def readgenome

Re: Method much slower than function?

2007-06-13 Thread Neil Cerutti
On 2007-06-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi all, > > I am running Python 2.5 on Feisty Ubuntu. I came across some code that > is substantially slower when in a method than in a function. > > # START SOURCE # > # The function > > def readgenome(fileha

save class

2007-06-13 Thread nik
Hi, I would like to create a class and then save it for re-use later. I have tried to use pickle, but am not sure if that is right. I am sorry, but I am new to python. Basically, I have a class, Map. I want to be able to create new maps: MapA, MapB... that have Map as the base class. start with-

Re: one-time initialization of class members

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 22:03:50 -0300, Steven D'Aprano <[EMAIL PROTECTED]> escribió: > On Wed, 13 Jun 2007 23:55:02 +, James Turk wrote: >>> James Turk wrote: >>> >>> > I have a situation where I have some class members that should only >>> be >>> > done once. Essentially my problem looks li

Re: Build EXE on Mac OsX 10.4

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 17:35:19 -0300, Paul McNett <[EMAIL PROTECTED]> escribió: > Tempo wrote: >> Has anyone sucesfully built a *.exe file on a mac operating system >> before from a *.py file? I have been trying to do this with >> pyinstaller, but I keep getting errors and I don't know how to instal

Re: one-time initialization of class members

2007-06-13 Thread Steven D'Aprano
On Wed, 13 Jun 2007 23:55:02 +, James Turk wrote: > On Jun 13, 6:54 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: >> James Turk wrote: >> > Hi, >> >> > I have a situation where I have some class members that should only be >> > done once. Essentially my problem looks like this: >> >> > class

How can I capture all exceptions especially when os.system() fail? Thanks

2007-06-13 Thread mike
Hi Guys, Following piece of code can capture IOError when the file doesn't exist, also, other unknown exceptions can be captured when I press Ctrl-C while the program is sleeping(time.sleep). Now the question is: when I run the non-exist command, the exception cannot be captured. Here is the code

Re: Cretins.

2007-06-13 Thread Steven D'Aprano
On Thu, 14 Jun 2007 09:32:10 +1000, Ben Finney wrote: > "Dr. Pastor" <[EMAIL PROTECTED]> writes: > >> Please do not do business with >> those cretins who without authorization >> attaching [spam footers] > > Indeed. The cost of Usenet access should not be translated to spam on > messages. Out o

Method much slower than function?

2007-06-13 Thread idoerg
Hi all, I am running Python 2.5 on Feisty Ubuntu. I came across some code that is substantially slower when in a method than in a function. # START SOURCE # # The function def readgenome(filehandle): s = '' for line in filehandle.xreadlines():

native python matrix class (2D list), without inverse

2007-06-13 Thread DarrenWeber
# Copyright (C) 2007 Darren Lee Weber # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This p

Re: one-time initialization of class members

2007-06-13 Thread James Turk
On Jun 13, 8:00 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > James Turk wrote: > > Hi, > > > I have a situation where I have some class members that should only be > > done once. Essentially my problem looks like this: > > > class Base(object): > > dataset = None > > > def __init__(self, p

Re: one-time initialization of class members

2007-06-13 Thread Larry Bates
James Turk wrote: > Hi, > > I have a situation where I have some class members that should only be > done once. Essentially my problem looks like this: > > class Base(object): > dataset = None > > def __init__(self, param): > if type(self).dataset is None: > # code t

Re: one-time initialization of class members

2007-06-13 Thread James Turk
On Jun 13, 6:54 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > James Turk wrote: > > Hi, > > > I have a situation where I have some class members that should only be > > done once. Essentially my problem looks like this: > > > class Base(object): > > dataset = None > > > def __init__(self

Re: Cretins.

2007-06-13 Thread Ben Finney
"Dr. Pastor" <[EMAIL PROTECTED]> writes: > Please do not do business with > those cretins who without authorization > attaching [spam footers] Indeed. The cost of Usenet access should not be translated to spam on messages. -- \ "If consumers even know there's a DRM, what it is, and how i

Re: Bytes/File Size Format Function

2007-06-13 Thread Ben Finney
Avell Diroll <[EMAIL PROTECTED]> writes: > I have to disagree: 'mb' should stand for "milli-bit" :) Yes, you're right. My "metre-bit" was wrong. -- \ "Whenever you read a good book, it's like the author is right | `\ there, in the room talking to you, which is why I don't like to |

Re: one-time initialization of class members

2007-06-13 Thread Steven Bethard
James Turk wrote: > Hi, > > I have a situation where I have some class members that should only be > done once. Essentially my problem looks like this: > > class Base(object): > dataset = None > > def __init__(self, param): > if type(self).dataset is None: > # code t

Re: mapping subintervals

2007-06-13 Thread Nis Jørgensen
Matteo skrev: > OK - I'm going to assume your intervals are inclusive (i.e. 34-51 > contains both 34 and 51). > > If your intervals are all really all non-overlapping, one thing you > can try is to put all the endpoints in a single list, and sort it. > Then, you can use the bisect module to searc

Re: Build EXE on Mac OsX 10.4

2007-06-13 Thread Kevin Walzer
Paul McNett wrote: > Tempo wrote: >> Has anyone sucesfully built a *.exe file on a mac operating system >> before from a *.py file? I have been trying to do this with >> pyinstaller, but I keep getting errors and I don't know how to install >> UPX properly. I tried putting the linux UPX folder in m

one-time initialization of class members

2007-06-13 Thread James Turk
Hi, I have a situation where I have some class members that should only be done once. Essentially my problem looks like this: class Base(object): dataset = None def __init__(self, param): if type(self).dataset is None: # code to load dataset based on param, expensive

Re: Windows XP timezone language issue

2007-06-13 Thread MRAB
On Jun 13, 7:31 am, Paul Sijben <[EMAIL PROTECTED]> wrote: > I ran into an internationalization issue. I need a consistent idea about > the timezone my application is running on. However when I run the following: > >>> import time > >>> time.tzname > > I get back ('West-Europa (standaardtijd)', '

Re: SimplePrograms challenge

2007-06-13 Thread infidel
# writing/reading CSV files, tuple-unpacking, cmp() built-in import csv writer = csv.writer(open('stocks.csv', 'wb')) writer.writerows([ ('GOOG', 'Google, Inc.', 505.24, 0.47, 0.09), ('YHOO', 'Yahoo! Inc.', 27.38, 0.33, 1.22), ('CNET', 'CNET Networks, Inc.', 8.62, -0.13, -1.49) ]) sto

Re: mapping subintervals

2007-06-13 Thread Matteo
On Jun 13, 2:32 pm, Lee Sander <[EMAIL PROTECTED]> wrote: > hi, > I have the following problem which is turning out to be non-trivial. I > realize that this is not > exactly a python problem but more of an algorithm problem -- but I > post it here because > I want to implement this in python. > > I

Re: How to create a tuple quickly with list comprehension?

2007-06-13 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | I can use list comprehension to create list quickly. So I expected that I | can created tuple quickly with the same syntax. But I found that the | same syntax will get a generator, not a tuple. Here is my example: | | In [147]: a = (i f

Re: Build EXE on Mac OsX 10.4

2007-06-13 Thread -b
Okay. Great. Thanks for clarifying that for me. -- http://mail.python.org/mailman/listinfo/python-list

Re: Goto

2007-06-13 Thread HMS Surprise
Thanks folks! jh -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Terry Reedy
"Steve Howell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | | You would just change the language definition to say | that once you enter f(), any call to f() from within | f() behaves as if the recursively called f() still | points to the originally bound version of f. I am pret

Re: Build EXE on Mac OsX 10.4

2007-06-13 Thread Paul McNett
Tempo wrote: > Has anyone sucesfully built a *.exe file on a mac operating system > before from a *.py file? I have been trying to do this with > pyinstaller, but I keep getting errors and I don't know how to install > UPX properly. I tried putting the linux UPX folder in my python 2.4 > directory,

wx Listbox event

2007-06-13 Thread Marcpp
Hi, I need to charge a list when starts the program. I've tried a few events like: self.llistatids = wx.ListBox(self, -1, choices=['a'], style=wx.LB_SINGLE|wx.LB_ALWAYS_SB) self.llistatids.SetBackgroundColour(wx.Colour(255, 255, 220)) self.llistatids.Bind(wx.EVT_LISTBOX, self.carrega_llistatids)

Re: Goto

2007-06-13 Thread Carsten Haese
On Wed, 2007-06-13 at 12:20 -0700, HMS Surprise wrote: > How does one effect a goto in python? One doesn't. > I only want to use it for debug. > I dasn't slap an "if" clause around the portion to dummy out, the > indentation police will nab me. If you want to disable a code block without indent

Re: SimplePrograms challenge

2007-06-13 Thread Steven Bethard
Rob Wolfe wrote: > Steven Bethard <[EMAIL PROTECTED]> writes: > >>> I vote for example with ElementTree (without xpath) >>> with a mention of using ElementSoup for invalid HTML. >> Sounds good to me. Maybe something like:: >> >> import xml.etree.ElementTree as etree >> dinner_recipe = ''' >> >>

Re: In C extension .pyd, sizeof INT64 = 4?

2007-06-13 Thread Gabriel Genellina
On 12 jun, 17:06, "Martin v. Lo"wis" <[EMAIL PROTECTED]> wrote: > > What *is*INT64? It's not a builtin type of standard C, it isn't > defined by Microsoft C, and it isn't predefined by Python. > > So it must be something that you have defined, and apparently > incorrectly. How did you define it? I

mapping subintervals

2007-06-13 Thread Lee Sander
hi, I have the following problem which is turning out to be non-trivial. I realize that this is not exactly a python problem but more of an algorithm problem -- but I post it here because I want to implement this in python. I want to write a code that given an interval (integer tuple: start,stop)

Re: SimplePrograms challenge

2007-06-13 Thread Rob Wolfe
Steven Bethard <[EMAIL PROTECTED]> writes: >> I vote for example with ElementTree (without xpath) >> with a mention of using ElementSoup for invalid HTML. > > Sounds good to me. Maybe something like:: > > import xml.etree.ElementTree as etree > dinner_recipe = ''' > > 24slicesbaguette > 2+tbspol

Re: Goto

2007-06-13 Thread Daniel Nogradi
> How does one effect a goto in python? I only want to use it for debug. > I dasn't slap an "if" clause around the portion to dummy out, the > indentation police will nab me. http://entrian.com/goto/ -- http://mail.python.org/mailman/listinfo/python-list

Build EXE on Mac OsX 10.4

2007-06-13 Thread Tempo
Has anyone sucesfully built a *.exe file on a mac operating system before from a *.py file? I have been trying to do this with pyinstaller, but I keep getting errors and I don't know how to install UPX properly. I tried putting the linux UPX folder in my python 2.4 directory, but that didn't work.

Goto

2007-06-13 Thread HMS Surprise
How does one effect a goto in python? I only want to use it for debug. I dasn't slap an "if" clause around the portion to dummy out, the indentation police will nab me. Thanx, jh -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
On 2007-06-13, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-06-13, Anders J. Munch <[EMAIL PROTECTED]> wrote: >> General tail-call optimisation is of course completely >> out-of-bounds for Python, because it ruins tracebacks. Unlike >> tail recursion, which could use recursion counters. > > I

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Carsten Haese
On Wed, 2007-06-13 at 18:22 +, Neil Cerutti wrote: > On 2007-06-13, Anders J. Munch <[EMAIL PROTECTED]> wrote: > > General tail-call optimisation is of course completely > > out-of-bounds for Python, because it ruins tracebacks. Unlike > > tail recursion, which could use recursion counters. >

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
On 2007-06-13, Anders J. Munch <[EMAIL PROTECTED]> wrote: > General tail-call optimisation is of course completely > out-of-bounds for Python, because it ruins tracebacks. Unlike > tail recursion, which could use recursion counters. Is it really ruined? To use a similar example: def foo(x):

Re: logging module and threading

2007-06-13 Thread Vinay Sajip
On Jun 13, 1:28 am, "James T. Dennis" <[EMAIL PROTECTED]> wrote: > This sounds like a job for the Queue class/module to me. > Could you create a Queue such that all your worker threads > are producers to it and you have one dedicated thread as a > consumer that relays log entries from the Queue

Re: Python Help!!!

2007-06-13 Thread Christof Winter
Elfine Peterson Tjio wrote: > I'm trying to make a program that reads Fasta file and print it out. I used > the SeqIO module and the results is: > > 'ATGGTCATSingleAlphabet()' > > For this purpose, should I use SeqIO or Fasta? > > for example: > > from Bio import SeqIO > > or > > from Bio

Re: problem on waiting exit thread and write on file

2007-06-13 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Flyzone wrote: > I need to run in thread a command, one thread for one parameter. > So i made a for loop, creating 5 threads and waiting their stop with: > Main { >open file BW2 for write >. (creating list of thread with a counter) >Stopped=False >wh

Re: Focus to be removed

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 07:13:18 -0300, <[EMAIL PROTECTED]> escribió: > I'm very pleased to have your help about to solve a technical issue > related to HTML Editlet Editor. In this I' m facing the problem that You should ask the author - I don't think this product has anything to do with Python.

Re: Windows build of PostgreSQL library for 2.5

2007-06-13 Thread George Sakkis
On Jun 13, 12:57 pm, Ben Sizer <[EMAIL PROTECTED]> wrote: > On 30 May, 16:20, Ben Sizer <[EMAIL PROTECTED]> wrote: > > > On 30 May, 15:42, Frank Millman <[EMAIL PROTECTED]> wrote: > > > > On May 30, 4:15 pm,BenSizer<[EMAIL PROTECTED]> wrote: > > > > > I've been looking for a Windows version of a li

Re: Optimizing constants in loops

2007-06-13 Thread Michael Hoffman
Thomas Heller wrote: > Just use the builtin __debug__ variable for that purpose. > __debug__ is 'True' if Python is run normally, and 'False' > if run with the '-O' or '-OO' command line flag. > The optimizer works in the way you describe above (which > it will not if you use a custom variable).

Re: Python Help!!!

2007-06-13 Thread Nathan Harmston
Hi, you could try this: def parse(self, ifile): id="" seq="" for line in open(ifile, 'r'): if '>'==line[0]: if id!="" and len(seq)>0: yield id,seq seq = "" id=line[1:].strip("\n")

Re: Bytes/File Size Format Function

2007-06-13 Thread Avell Diroll
Ben Finney wrote: > The symbol for "bit" is 'b'. The symbol for "byte" is 'B'. 'kb' is > 'kilobit', i.e. 1000 bits. 'mb' is a "metre-bit", a combination of two > units. And so on. The SI units have definitions that are only muddied > by misusing them this way. I have to disagree: 'mb' should stand

Re: Windows build of PostgreSQL library for 2.5

2007-06-13 Thread Ben Sizer
On 30 May, 16:20, Ben Sizer <[EMAIL PROTECTED]> wrote: > On 30 May, 15:42, Frank Millman <[EMAIL PROTECTED]> wrote: > > > On May 30, 4:15 pm,BenSizer<[EMAIL PROTECTED]> wrote: > > > > I've been looking for a Windows version of a library to interface to > > > PostgreSQL, but can only find ones compi

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Anders J. Munch
Alexander Schmolck wrote: > "Anders J. Munch" <[EMAIL PROTECTED]> writes: > >> Like Steven said, tail-call optimisation is not necessary as you can always >> hand-optimise it yourself. > > Care to demonstrate on some code written in CPS (a compiler or parser, say)? I meant tail recursion, not ta

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Anders J. Munch
Neil Cerutti wrote: > On 2007-06-12, Anders J. Munch <[EMAIL PROTECTED]> wrote: >> Converting tail-recursion to iteration is trivial, and >> perfectly reasonable for a human to do by hand. > > For simple recursive tail calls, yeah, it can be. Translating a > tail-recursive Factorial function int

Cretins.

2007-06-13 Thread Dr. Pastor
Please do not do business with those cretins who without authorization attaching the following text to my postings: == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and

Re: Bytes/File Size Format Function

2007-06-13 Thread samuraisam
Haha, you guys. Use it however you want. But trust me, if you put MiB and GiB instead of the more-common mb and gb [MB and GB] in your applications, your users will probably have a harder time understanding what you mean. -- http://mail.python.org/mailman/listinfo/python-list

Re: MS Word parser

2007-06-13 Thread [EMAIL PROTECTED]
On Jun 13, 1:28 am, Tim Golden <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hi all, > > I'm currently using antiword to extract content from MS Word files. > > Is there another way to do this without relying on any command prompt > > application? > > Well you haven't given your environ

problem on waiting exit thread and write on file

2007-06-13 Thread Flyzone
I have a list of parameters. I need to run in thread a command, one thread for one parameter. So i made a for loop, creating 5 threads and waiting their stop with: for parameter in parameters Thread{ write on BW2 } Main { open file BW2 for write . (creating list of

Re: Optimizing constants in loops

2007-06-13 Thread Thomas Heller
Michael Hoffman schrieb: > The peephole optimizer now takes things like > > if 0: > do_stuff() > > and optimizes them away, and optimizes away the conditional in "if 1:". > > What if I had a function like this? > > def func(debug=False): > for index in xrange(100): > if de

Re: SimplePrograms challenge

2007-06-13 Thread Steven Bethard
Rob Wolfe wrote: > Steve Howell wrote: > >> I suggested earlier that maybe we post multiple >> solutions. That makes me a little nervous, to the >> extent that it shows that the Python community has a >> hard time coming to consensus on tools sometimes. > > We agree that BeautifulSoup is the bes

Python Job Opportunity

2007-06-13 Thread Brettmf
My company : EWT, LLC EWT is a proprietary securities trading company and is a member firm of major stock and futures exchanges. Founded in 2002, EWT was formed to capitalize on the shift of the securities industry towards electronic platforms in the United States and abroad. Location: Beverly Hi

Optimizing constants in loops

2007-06-13 Thread Michael Hoffman
The peephole optimizer now takes things like if 0: do_stuff() and optimizes them away, and optimizes away the conditional in "if 1:". What if I had a function like this? def func(debug=False): for index in xrange(100): if debug: print index do_stuff(i

Re: Is there any way to catch expections when call python method in C++

2007-06-13 Thread Robert Bauck Hamar
Allen wrote: > I use try catch, but cannot catch the execeptions of execution python > method. > > PYCALL_API void PyCall(const char * pszModule, const char * pszFunc, > void * pArg) > { > if (pszModule == NULL || pszFunc == NULL) > { > return; > } > > Py_Initialize(); > > PyObject * pModule =

Re: Postpone creation of attributes until needed

2007-06-13 Thread Steven D'Aprano
On Wed, 13 Jun 2007 02:15:11 -0700, Frank Millman wrote: > Thanks very much for all your attempts to help me, Steven. You have > succeeded in getting me to think properly about my problem and come up > with a much cleaner solution. I really appreciate it. Glad to be of help. -- Steven. -- ht

Re: httplib / connection

2007-06-13 Thread rhXX
> The > httplib.HTTP class that you were using is very old and deprecated for > several years now. > > -- > Gabriel Genellina :-( oh , tks! i took it from www.ug.it.usyd.edu.au/~comp5315/lec-09.html which class must i use? tks in advance -- http://mail.python.org/mailman/listinfo/python

passing arguments to tcpserver classes

2007-06-13 Thread Eric Spaulding
Is there an easy way to pass arguments to a handler class that is used by the standard TCPServer? normally --> srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass) I'd like to be able to: srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass, (arg1,arg2)) And have arg1, arg2 avai

Re: Convert binary string to something meaningful??

2007-06-13 Thread Grant Edwards
On 2007-06-13, supercooper <[EMAIL PROTECTED]> wrote: > I have this string that is being returned from a query on a DBISAM > database. The field must be some sort of blob, and when I connect to > the database thru ODBC in MS Access, the field type comes thru as OLE > Object, and Access cannot read

Re: cgi.FieldStorage() not working on Windows

2007-06-13 Thread arorap
OOps .. yes I mean mod_python. I've been using PHP way too long :P .. hence the typo On Jun 13, 4:01 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Jun 13, 12:58 pm,arorap<[EMAIL PROTECTED]> wrote: > > > Thanks for your reply. > > > The reason I want to run it as CGI (even though mod_php is

Convert binary string to something meaningful??

2007-06-13 Thread supercooper
I have this string that is being returned from a query on a DBISAM database. The field must be some sort of blob, and when I connect to the database thru ODBC in MS Access, the field type comes thru as OLE Object, and Access cannot read the field (it usually crashes Access). I can sorta pick out th

shape recognition

2007-06-13 Thread madprocessor
hi there, does anybody know about shape / gesture recognition librarys for python? like cali: http://immi.inesc-id.pt/cali/ thx joerg -- http://mail.python.org/mailman/listinfo/python-list

Re: How to format a string from an array?

2007-06-13 Thread Gerard Flanagan
On Jun 13, 11:11 am, Allen <[EMAIL PROTECTED]> wrote: > a = range(256) > I want to output the formated string to be: > 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f > 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f > > f

ANN: xlrd 0.6.1 final is now available

2007-06-13 Thread John Machin
The final release of version 0.6.1 of xlrd is now available from http://www.lexicon.net/sjmachin/xlrd.htm and from the Cheeseshop (http://cheeseshop.python.org/pypi/xlrd). What is xlrd? It's a small (download approx 0.1 Mb) pure-Python library for extracting information from Microsoft Excel (tm)

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
On 2007-06-13, Steve Howell <[EMAIL PROTECTED]> wrote: > You would just change the language definition to say that once > you enter f(), any call to f() from within f() behaves as if > the recursively called f() still points to the originally bound > version of f. To want any other behavior would

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-13 Thread Neil Cerutti
On 2007-06-12, Anders J. Munch <[EMAIL PROTECTED]> wrote: > Paul Rubin wrote: >> Steven D'Aprano <[EMAIL PROTECTED]> writes: Not tail calls, in general, no. >>> Sorry, how does that work? You're suggesting that there is an >>> algorithm which the compiler could follow to optimize away >>> tail

Re: Is there any way to catch expections when call python method in C++

2007-06-13 Thread cptnwillard
One way is to create an intermediate python function, which returns a special value when an exception is caught. def ExceptionCatcher(FunctionToCall): def F(): try: FunctionToCall() except: return -1 return 0 return F Then instead of calling your function, you woul

Re: SimplePrograms challenge

2007-06-13 Thread Rob Wolfe
Steve Howell wrote: > I suggested earlier that maybe we post multiple > solutions. That makes me a little nervous, to the > extent that it shows that the Python community has a > hard time coming to consensus on tools sometimes. We agree that BeautifulSoup is the best for parsing HTML. :) > Th

Re: How to create a tuple quickly with list comprehension?

2007-06-13 Thread Dustan
On Jun 13, 5:37 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > > > No need to create the intermediate list, a generator expression works just > > fine: > > > a = tuple(i for i in range(10)) > > But `range()` creates the intermediate list

Re: Why can't easy_install Django

2007-06-13 Thread Paul Boddie
On 13 Jun, 03:21, kernel1983 <[EMAIL PROTECTED]> wrote: > I look it up in PyPI [...] > Django is a big project. Why no one maintain this? Did the guy lost > his password? Who knows? But then, if you're running a GNU/Linux distribution like Debian, it's quite possible to use a system package, any

  1   2   >