Re: Failing on string exceptions in 2.4

2007-06-14 Thread Fredrik Lundh
Stephen R Laniel wrote: > End goal being that string exceptions would cause > compilation to fail. A few times now, I've found myself > doing > > class SomeClass: > """docstring""" > pass > > raise SomeClass, "Some description" > > and I've gotten a weird compiler error about the constr

Re: python i2c ioctl

2007-06-14 Thread Tim Roberts
luca <[EMAIL PROTECTED]> wrote: > > I was trying to make to work directly l i2c with python with the >calls ioctl. But I have of the problems and I do not succeed to go >ahead. > >[EMAIL PROTECTED] /usr/local/wrap]129# python pcf8591_ioctl.py >Reading from 4 ch 8 bit A/D converter PCF8591 >Tracebac

Re: Convert to C/C++?

2007-06-14 Thread Tim Roberts
SpreadTooThin <[EMAIL PROTECTED]> wrote: > >I am wondering if someone who knows the implemention of python's time >could help converting this to c/c++ If you are running on Windows, you can replace this entire thing with one call to CoCreateGuid, possibly with a call to StringFromGUID to make

Re: using Mac OS X CoreGraphics via ctypes

2007-06-14 Thread Diez B. Roggisch
Daniel schrieb: > I'm trying to implement a routine that converts a PDF document to > image files using ctypes and the Apple CoreGraphics library as per the > 'Splitting a PDF File' example on Apple's web site [0]. Unfortunately > I cannot use the CoreGraphics module used in that example because I'

Re: FTP Date Format Function

2007-06-14 Thread billiejoex
On 14 Giu, 19:25, samuraisam <[EMAIL PROTECTED]> wrote: > FTP LST/LIST/NLST date field formatting function for all those seekers > out there... > > import time > import datetime > > def ftpdateformat(value): > """Formats dates from most FTP servers""" > if ":" in value: # within 6 months >

Re: FTP Date Format Function

2007-06-14 Thread MC
Thank. -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Python rocks

2007-06-14 Thread Carl Banks
On Jun 3, 11:56 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > Allowing a trailing ! in method names has no such cost, because in no > language I know is ! used as a "postfix unary operator"; Some math oriented languages use it as the factorial function. E.g., Mathematica: In[1] := 10! Out[1]=

Re: Convert to C/C++?

2007-06-14 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, SpreadTooThin <[EMAIL PROTECTED]> writes: > I am wondering if someone who knows the implemention of python's time > could help converting this to c/c++ First the obligatory sermon: If you are truly intending to utilize a UUID generator on a UNIX platform, I ur

Re: Where can I suggest an enchantment for Python Zip lib?

2007-06-14 Thread Tim Roberts
durumdara <[EMAIL PROTECTED]> wrote: > >The problem, that: > - I want to process 100-200 MB zip files. > - I want to abort in process > - I want to know the actual position > - I want to slow the operation sometimes! > >Why I want to slow? > >The big archiving is slow operation. When it is slow, I

Re: inverting a dictionary of lists

2007-06-14 Thread Raymond Hettinger
On Jun 14, 8:20 pm, [EMAIL PROTECTED] wrote: > I have a very large dictionary of lists: > d = {a:[1,2], b:[2,3], c:[3]} > and i want to reverse the associativity of the integers thusly: > inverse(d) makes {1:[a], 2:[a,b], 3:[b,c]} Try using setdefault: >>> d = {'a':[1,2], 'b':[2,3], 'c':[3]

Re: Python rocks

2007-06-14 Thread Aahz
In article <[EMAIL PROTECTED]>, George Sakkis <[EMAIL PROTECTED]> wrote: >On Jun 2, 4:58 pm, [EMAIL PROTECTED] (Aahz) wrote: >> In article <[EMAIL PROTECTED]>, >> George Sakkis <[EMAIL PROTECTED]> wrote: >>> >>>- Strings being iterable; unfortunately this will stay in Py3K. >> >> I'll repeat the

Re: inverting a dictionary of lists

2007-06-14 Thread Gabriel Genellina
En Fri, 15 Jun 2007 00:20:33 -0300, <[EMAIL PROTECTED]> escribió: > I searched for an hour and don't see a solution to this (i assume > somewhat common) problem. > > I have a very large dictionary of lists: > d = {a:[1,2], b:[2,3], c:[3]} > and i want to reverse the associativity of the integers t

inverting a dictionary of lists

2007-06-14 Thread bpowah
I searched for an hour and don't see a solution to this (i assume somewhat common) problem. I have a very large dictionary of lists: d = {a:[1,2], b:[2,3], c:[3]} and i want to reverse the associativity of the integers thusly: inverse(d) makes {1:[a], 2:[a,b], 3:[b,c]} my solution expands the

using Mac OS X CoreGraphics via ctypes

2007-06-14 Thread Daniel
I'm trying to implement a routine that converts a PDF document to image files using ctypes and the Apple CoreGraphics library as per the 'Splitting a PDF File' example on Apple's web site [0]. Unfortunately I cannot use the CoreGraphics module used in that example because I'm using Python 2.5 (AFAI

Re: dynamically generated runtime methods & reflection

2007-06-14 Thread Josiah Carlson
Josiah Carlson wrote: > Well, the particular operation is typically called 'currying a > function', and unless you know what to look for, it isn't very easy to > make happen. Replace "make happen" to "discover in the standard library". - Josiah -- http://mail.python.org/mailman/listinfo/pyth

Re: save class

2007-06-14 Thread Josiah Carlson
nik wrote: > of having to keep track of a separate dictionary file. I am new to > this, but I thought that this would be a regular thing to do in > python, because people must make classes in the interactive console > and then export them somehow for later use. Create a file. Put your code in it.

Re: SimplePrograms challenge

2007-06-14 Thread Steve Howell
--- Joe Riopel <[EMAIL PROTECTED]> wrote: > How about this one for recursion and control flow: > > >>> def hcd(m,n): > ... r = m % n > ... if( r > 0 ): > ... hcd(n, r) > ... else: > ... print "hcd = %d" % (n,) > ... > >>> hcd(119, 544) > hcd = 17 > >>> > > It

Re: SimplePrograms challenge

2007-06-14 Thread Joe Riopel
How about this one for recursion and control flow: >>> def hcd(m,n): ... r = m % n ... if( r > 0 ): ... hcd(n, r) ... else: ... print "hcd = %d" % (n,) ... >>> hcd(119, 544) hcd = 17 >>> It calculates the highest common denominator for m and n. Plus it's E1 in

Re: Problems with regular expressions

2007-06-14 Thread Jay Loden
Carlos Luis Pérez Alonso wrote: > I have the next piece of code: > > > if re.search('^(taskid|bugid):\\d+',logMessage): > return 0 > else: > sys.stderr.write("El comentario tiene que contener el taski

Re: poking around a running program

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 21:42:50 -0300, Paul Rubin <"http://phr.cx"@NOSPAM.invalid> escribió: > I have a long-running program that has lots of net connections open on > separate threads. I'm twiddling my thumbs waiting for it to finish > (each run takes maybe an hour) and although I'm logging vario

Re: Problems with regular expressions

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 21:42:02 -0300, Carlos Luis Pérez Alonso <[EMAIL PROTECTED]> escribió: > I have the next piece of code: > > if re.search('^(taskid|bugid):\\d+',logMessage): > return 0 > else: > sys.stde

Re: SimplePrograms challenge

2007-06-14 Thread Steve Howell
--- rzed <[EMAIL PROTECTED]> wrote: > Hm > > ... and so on. > > In much of Python's documentation, and in this case, > an occasional > working example of use would go FAR in aiding > understanding of the > underlying concept. > I agree with your sentiment 100%. Feel free to change t

Re: Failing on string exceptions in 2.4

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 18:45:08 -0300, Stephen R Laniel <[EMAIL PROTECTED]> escribió: > Reading the Python docs, it looks like string exceptions > will be a DeprecationWarning in Python 2.5. Is there any way > to make them so in 2.4? Now how about if I want to turn all > DeprecationWarnings into co

Re: SimplePrograms challenge

2007-06-14 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > > How about including a driver? > > Yes, absolutely a good idea. Fortunately, the other > Steve borrowed the > time machine already and added this to the end:: > > for p in iter_primes(): > if p > 1000: break > print p >

Re: Questions about mathematical and statistical functionality in Python

2007-06-14 Thread Josh Gilbert
On Thursday 14 June 2007 5:54 pm, Tim Churches wrote: > Michael Hoffman wrote: > > Talbot Katz wrote: > >> I hope you'll indulge an ignorant outsider. I work at a financial > >> software firm, and the tool I currently use for my research is R, a > >> software environment for statistical computing

Problems with regular expressions

2007-06-14 Thread Carlos Luis Pérez Alonso
I have the next piece of code: if re.search('^(taskid|bugid):\\d+',logMessage): return 0 else: sys.stderr.write("El comentario tiene que contener el taskid: o el bugid:") return

Re: OS X install confusion

2007-06-14 Thread 7stud
On Jun 14, 11:21 am, [EMAIL PROTECTED] (John Fisher) wrote: > Hi Groupies, > > I have an Intel Macbook running OS X 10.4. > > It came installed with Python 2.3.5. I have since installed MacPython > with version 2.4.4, cool. > > When I open a bash terminal session and type python, it brings up > ver

poking around a running program

2007-06-14 Thread Paul Rubin
I have a long-running program that has lots of net connections open on separate threads. I'm twiddling my thumbs waiting for it to finish (each run takes maybe an hour) and although I'm logging various info that I can monitor as the run progresses, it would be cool to be able to actually poke arou

Re: OS X install confusion

2007-06-14 Thread Paul McNett
John Fisher wrote: > Ted <[EMAIL PROTECTED]> wrote: > >> On Jun 14, 1:31 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote: >>> John Fisher wrote: Hi Groupies, I have an Intel Macbook running OS X 10.4. It came installed with Python 2.3.5. I have since installed MacPython with version

Re: OS X install confusion

2007-06-14 Thread John Fisher
Ted <[EMAIL PROTECTED]> wrote: > On Jun 14, 1:31 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote: > > John Fisher wrote: > > > Hi Groupies, > > > > > I have an Intel Macbook running OS X 10.4. > > > > > It came installed with Python 2.3.5. I have since installed MacPython > > > with version 2.4.4, cool

Re: save class

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 16:05:14 -0300, nik <[EMAIL PROTECTED]> escribió: > On Jun 13, 10:04 pm, Josiah Carlson <[EMAIL PROTECTED]> > wrote: >> 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 sour

Re: Moving items from list to list

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 14:23:14 -0300, Evan Klitzke <[EMAIL PROTECTED]> escribió: > On 6/14/07, HMS Surprise <[EMAIL PROTECTED]> wrote: >> >> Just wondered if there was some python idiom for moving a few items >> from one list to another. I often need to delete 2 or 3 items from one >> list and put t

Failing on string exceptions in 2.4

2007-06-14 Thread Stephen R Laniel
Reading the Python docs, it looks like string exceptions will be a DeprecationWarning in Python 2.5. Is there any way to make them so in 2.4? Now how about if I want to turn all DeprecationWarnings into compile-time errors? Is there some way to do this? End goal being that string exceptions would

Re: Method much slower than function?

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 05:54:25 -0300, Francesco Guerrieri <[EMAIL PROTECTED]> escribió: > On 6/14/07, Peter Otten <[EMAIL PROTECTED]> wrote: >> Gabriel Genellina wrote: >> > ... >> > py> print timeit.Timer("f2()", "from __main__ import >> f2").repeat(number=1) >> > [0.42673663831576358, 0.428075

Re: Efficient way of generating original alphabetic strings like unix file "split"

2007-06-14 Thread [EMAIL PROTECTED]
On Jun 14, 4:39 pm, py_genetic <[EMAIL PROTECTED]> wrote: > > You didn't try hard enough. :) > > >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 > > > -- > > HTH, > > Rob > > Thanks Rob, "permutation" was the keyword I shcould have used! See my other post to see if that is indeed w

Re: Efficient way of generating original alphabetic strings like unix file "split"

2007-06-14 Thread [EMAIL PROTECTED]
On Jun 14, 3:08 pm, Rob Wolfe <[EMAIL PROTECTED]> wrote: > py_genetic <[EMAIL PROTECTED]> writes: > > Hi, > > > I'm looking to generate x alphabetic strings in a list size x. This > > is exactly the same output that the unix command "split" generates as > > default file name output when splitting

Re: Questions about mathematical and statistical functionality in Python

2007-06-14 Thread Tim Churches
Michael Hoffman wrote: > Talbot Katz wrote: > >> I hope you'll indulge an ignorant outsider. I work at a financial >> software firm, and the tool I currently use for my research is R, a >> software environment for statistical computing and graphics. R is >> designed with matrix manipulation i

RE: Questions about mathematical and statistical functionality in Python

2007-06-14 Thread John Krukoff
On Jun 14, 4:02 pm, "Talbot Katz" <[EMAIL PROTECTED]> wrote: > Greetings Pythoners! > > I hope you'll indulge an ignorant outsider. I work at a financial > software > firm, and the tool I currently use for my research is R, a software > environment for statistical computing and graphics. R is d

Re: Efficient way of generating original alphabetic strings like unix file "split"

2007-06-14 Thread py_genetic
> > You didn't try hard enough. :) > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 > > -- > HTH, > Rob Thanks Rob, "permutation" was the keyword I shcould have used! -- http://mail.python.org/mailman/listinfo/python-list

Re: Questions about mathematical and statistical functionality in Python

2007-06-14 Thread Michael Hoffman
Talbot Katz wrote: > I hope you'll indulge an ignorant outsider. I work at a financial > software firm, and the tool I currently use for my research is R, a > software environment for statistical computing and graphics. R is > designed with matrix manipulation in mind, and it's very easy to d

Re: MS Word parser

2007-06-14 Thread Ben C
On 2007-06-13, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > 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 comma

Re: a_list.count(a_callable) ?

2007-06-14 Thread Carsten Haese
On Thu, 2007-06-14 at 12:53 -0700, Ping wrote: > Hi, > > I'm wondering if it is useful to extend the count() method of a list > to accept a callable object? What it does should be quite intuitive: > count the number of items that the callable returns True or anything > logically equivalent (non-e

Re: Questions about mathematical and statistical functionality in Python

2007-06-14 Thread kyosohma
On Jun 14, 4:02 pm, "Talbot Katz" <[EMAIL PROTECTED]> wrote: > Greetings Pythoners! > > I hope you'll indulge an ignorant outsider. I work at a financial software > firm, and the tool I currently use for my research is R, a software > environment for statistical computing and graphics. R is desig

Re: a_list.count(a_callable) ?

2007-06-14 Thread Carsten Haese
On Thu, 2007-06-14 at 21:06 +, Dustan wrote: > On Jun 14, 3:37 pm, Dustan <[EMAIL PROTECTED]> wrote: > > Which can then be converted into a generator expression (round > > brackets instead of square brackets) to avoid the intermediate list: > > len((i for i in a_list if a_callable(i))) > > Sor

Re: a_list.count(a_callable) ?

2007-06-14 Thread Dustan
On Jun 14, 3:37 pm, Dustan <[EMAIL PROTECTED]> wrote: > Which can then be converted into a generator expression (round > brackets instead of square brackets) to avoid the intermediate list: > len((i for i in a_list if a_callable(i))) Sorry for the excess of posts everybody. I just realized that t

Re: os.path.normpath bug?

2007-06-14 Thread billiejoex
On 14 Giu, 22:35, Michael Hoffman <[EMAIL PROTECTED]> wrote: > Intentional. > > http://en.wikipedia.org/wiki/Path_(computing)#Universal_Naming_Conven... > -- > Michael Hoffman Got it. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Serialization across languages?

2007-06-14 Thread Martin v. Löwis
> First, what do I need to be aware of when sending arbitrary > data by a POST, and Second, is there a universally supported > version of what python can do with pickle? I mostly need > python and PHP, but perl would be nice too. You might want to use WDDX. There are WDDX libraries for Python, PH

Questions about mathematical and statistical functionality in Python

2007-06-14 Thread Talbot Katz
Greetings Pythoners! I hope you'll indulge an ignorant outsider. I work at a financial software firm, and the tool I currently use for my research is R, a software environment for statistical computing and graphics. R is designed with matrix manipulation in mind, and it's very easy to do regr

Re: a_list.count(a_callable) ?

2007-06-14 Thread Dustan
On Jun 14, 3:37 pm, Dustan <[EMAIL PROTECTED]> wrote: > map and filter are basically obsolete after the introduction of list > comprehensions It is probably worth noting that list comprehensions do not require that you write a new function; they take any expression where appropriate. For more info

Serialization across languages?

2007-06-14 Thread Tobiah
I want to do SOAP like calls from a device who's libraries don't include SOAP. I'm thinking of using simple HTTP posts, but I'm going to want to send arrays and hashes. First, what do I need to be aware of when sending arbitrary data by a POST, and Second, is there a universally supported version

Re: a_list.count(a_callable) ?

2007-06-14 Thread Dustan
On Jun 14, 2:53 pm, Ping <[EMAIL PROTECTED]> wrote: > Hi, > > I'm wondering if it is useful to extend the count() method of a list > to accept a callable object? What it does should be quite intuitive: > count the number of items that the callable returns True or anything > logically equivalent (n

Re: os.path.normpath bug?

2007-06-14 Thread Michael Hoffman
billiejoex wrote: > Hi there, > I've noticed that os.path.normpath does not collapse redundant > separators if they're located at the beginning of the string: > print os.path.normpath('/a//b//c') > \a\b\c print os.path.normpath('//a//b//c') > \\a\b\c > > Is it intentional or is it a bug

os.path.normpath bug?

2007-06-14 Thread billiejoex
Hi there, I've noticed that os.path.normpath does not collapse redundant separators if they're located at the beginning of the string: >>> print os.path.normpath('/a//b//c') \a\b\c >>> print os.path.normpath('//a//b//c') \\a\b\c Is it intentional or is it a bug? -- http://mail.python.org/mailma

python i2c ioctl

2007-06-14 Thread luca
Hi, I was trying to make to work directly l i2c with python with the calls ioctl. But I have of the problems and I do not succeed to go ahead. this and l error [EMAIL PROTECTED] /usr/local/wrap]129# python pcf8591_ioctl.py Reading from 4 ch 8 bit A/D converter PCF8591 Traceback (most recent cal

Proper licensing and copyright attribution for extracted Python code

2007-06-14 Thread Douglas Alan
Hi. I extracted getpath.c out of Python and modified it to make a generally useful facility for C and C++ programming. These comments are at the top of my .c file, and I would like to know if they pass muster for meeting licensing, copyright, and aesthetics requirements: // -*- Mode: C; fill-col

Re: Moving items from list to list

2007-06-14 Thread George Sakkis
On Jun 14, 12:30 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > Just wondered if there was some python idiom for moving a few items > from one list to another. I often need to delete 2 or 3 items from one > list and put them in another. Delete doesn't seem to have a return > value. I don't care whi

Convert to C/C++?

2007-06-14 Thread SpreadTooThin
I am wondering if someone who knows the implemention of python's time could help converting this to c/c++ nanoseconds = int(time.time() * 1e9) # 0x01b21dd213814000 is the number of 100-ns intervals between the # UUID epoch 1582-10-15 00:00:00 an

Re: Efficient way of generating original alphabetic strings like unix file "split"

2007-06-14 Thread Rob Wolfe
py_genetic <[EMAIL PROTECTED]> writes: > Hi, > > I'm looking to generate x alphabetic strings in a list size x. This > is exactly the same output that the unix command "split" generates as > default file name output when splitting large files. > > Example: > > produce x original, but not random s

Re: Efficient way of generating original alphabetic strings like unix file "split"

2007-06-14 Thread [EMAIL PROTECTED]
On Jun 14, 1:41 pm, py_genetic <[EMAIL PROTECTED]> wrote: > Hi, > > I'm looking to generate x alphabetic strings in a list size x. This > is exactly the same output that the unix command "split" generates as > default file name output when splitting large files. > > Example: > > produce x original

a_list.count(a_callable) ?

2007-06-14 Thread Ping
Hi, I'm wondering if it is useful to extend the count() method of a list to accept a callable object? What it does should be quite intuitive: count the number of items that the callable returns True or anything logically equivalent (non-empty sequence, non-zero number, etc). This would return th

Re: Method much slower than function?

2007-06-14 Thread Josiah Carlson
Francesco Guerrieri wrote: > On 6/14/07, Peter Otten <[EMAIL PROTECTED]> wrote: >> Gabriel Genellina wrote: >> > ... >> > py> print timeit.Timer("f2()", "from __main__ import >> f2").repeat(number=1) >> > [0.42673663831576358, 0.42807591467630662, 0.44401481193838876] >> > py> print timeit.Timer("

Re: Moving items from list to list

2007-06-14 Thread HMS Surprise
Thanks. That will work. The 2nd, smaller lst starts out empty but this is easily adapted. jh -- http://mail.python.org/mailman/listinfo/python-list

Re: Method much slower than function?

2007-06-14 Thread Josiah Carlson
[EMAIL PROTECTED] wrote: > On Jun 14, 1:10 am, Paul Rubin wrote: >> "[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 runn

Re: dynamically generated runtime methods & reflection

2007-06-14 Thread Josiah Carlson
Jay Loden wrote: > Josiah Carlson wrote: >> Ahh, so you want to pass the method name to the method that you are >> returning to be called. No problem. >> >> >>> import functools >> >>> >> >>> class foo: >> ... def __getattr__(self, name): >> ... return functools.partial(self.Actual

Re: save class

2007-06-14 Thread nik
On Jun 13, 10:04 pm, Josiah Carlson <[EMAIL PROTECTED]> wrote: > 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

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

2007-06-14 Thread mike
On Jun 14, 2:55 am, Michael Hoffman <[EMAIL PROTECTED]> wrote: > Gabriel Genellina wrote: > > 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 wh

Re: Method much slower than function?

2007-06-14 Thread [EMAIL PROTECTED]
On Jun 14, 1:10 am, Paul Rubin wrote: > "[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, b

Efficient way of generating original alphabetic strings like unix file "split"

2007-06-14 Thread py_genetic
Hi, I'm looking to generate x alphabetic strings in a list size x. This is exactly the same output that the unix command "split" generates as default file name output when splitting large files. Example: produce x original, but not random strings from english alphabet, all lowercase. The lengt

Re: SimplePrograms challenge

2007-06-14 Thread Steven Bethard
rzed wrote: > Steven Bethard <[EMAIL PROTECTED]> wrote in >> def iter_primes(): >> # an iterator of all numbers between 2 and +infinity >> numbers = itertools.count(2) >> >> # generate primes forever >> while True >> >> # generate the first number from the iterator, >>

Re: Method much slower than function?

2007-06-14 Thread [EMAIL PROTECTED]
On Jun 14, 1:12 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > 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) > > > Eh

Re: qt4 setFlags

2007-06-14 Thread Diez B. Roggisch
luca72 schrieb: > Hello > > I make this code: > row = self.tableWidget.rowCount() > for a in range(row): > self.tableWidget.item(row, 0).setFlags(Qt.IsSelectable) > > i have this erroror : > > global name Qt is not definied import Qt might help. And reading the python tutori

lagrange multipliers in python

2007-06-14 Thread [EMAIL PROTECTED]
Hi all, Sorry for the cross-posting. I'm trying to find the minimum of a multivariate function F(x1, x2, ..., xn) subject to multiple constraints G1(x1, x2, ..., xn) = 0, G2(...) = 0, ..., Gm(...) = 0. The conventional way is to construct a dummy function Q, $$Q(X, \Lambda) = F(X) + \lambda_1 G

Re: OS X install confusion

2007-06-14 Thread Ted
On Jun 14, 1:31 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote: > John Fisher wrote: > > Hi Groupies, > > > I have an Intel Macbook running OS X 10.4. > > > It came installed with Python 2.3.5. I have since installed MacPython > > with version 2.4.4, cool. > > > When I open a bash terminal session and

Re: Method much slower than function?

2007-06-14 Thread Peter Otten
Chris Mellon wrote: > On 6/14/07, Peter Otten <[EMAIL PROTECTED]> wrote: >> Peter Otten wrote: >> >> > Leo Kislov wrote: >> > >> >> 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 substantial

Re: OS X install confusion

2007-06-14 Thread Kevin Walzer
John Fisher wrote: > Hi Groupies, > > I have an Intel Macbook running OS X 10.4. > > It came installed with Python 2.3.5. I have since installed MacPython > with version 2.4.4, cool. > > When I open a bash terminal session and type python, it brings up > version 2.3.5. If I type IDLE it brings u

Re: Method much slower than function?

2007-06-14 Thread Steven D'Aprano
On Thu, 14 Jun 2007 00:40:12 +, idoerg 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. After further testing, I think I have found the cause of the speed difference -- and it isn't tha

FTP Date Format Function

2007-06-14 Thread samuraisam
FTP LST/LIST/NLST date field formatting function for all those seekers out there... import time import datetime def ftpdateformat(value): """Formats dates from most FTP servers""" if ":" in value: # within 6 months return datetime.datetime( *time.strptime( # have to gu

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

2007-06-14 Thread Gabriel Genellina
En Wed, 13 Jun 2007 12:03:00 -0300, Robert Bauck Hamar <[EMAIL PROTECTED]> escribió: > Allen wrote: > >> I use try catch, but cannot catch the execeptions of execution python >> method. > > No. CPython is written in C, not C++, and C has no concept of exceptions. > Exceptions in Python is usuall

OS X install confusion

2007-06-14 Thread John Fisher
Hi Groupies, I have an Intel Macbook running OS X 10.4. It came installed with Python 2.3.5. I have since installed MacPython with version 2.4.4, cool. When I open a bash terminal session and type python, it brings up version 2.3.5. If I type IDLE it brings up version 2.4.4. My question: what

Re: Moving items from list to list

2007-06-14 Thread Evan Klitzke
On 6/14/07, HMS Surprise <[EMAIL PROTECTED]> wrote: > > Just wondered if there was some python idiom for moving a few items > from one list to another. I often need to delete 2 or 3 items from one > list and put them in another. Delete doesn't seem to have a return > value. I don't care which items

Re: Method much slower than function?

2007-06-14 Thread Grant Edwards
On 2007-06-14, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > However, having said that, the speed difference does seem to be real: even > when I correct the above issue, I get a large time difference using > either cProfile.run() or profile.run(), and timeit agrees: > f = bar().readgenome

Re: Method much slower than function?

2007-06-14 Thread Steven D'Aprano
On Thu, 14 Jun 2007 00:40:12 +, idoerg wrote: cProfile.run("bar.readgenome(open('cb_foo'))") > 20004 function calls in 10.214 CPU seconds This calls the method on the CLASS, instead of an instance. When I try it, I get this: TypeError: unbound method readgenome() must be calle

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

2007-06-14 Thread Laurent Pointal
Allen wrote: > On 6 13 , 11 55 , "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: >> > I used INT64 and initialize its value from PyArg_ParseTuple. >> > The code is PyArg_ParseTuple(args, "l", &nValue). >> > It should be PyArg_ParseTuple(args, "L", &nValue). >> >> That's still incorrect. For the L f

Re: Method much slower than function?

2007-06-14 Thread Chris Mellon
On 6/14/07, Peter Otten <[EMAIL PROTECTED]> wrote: > Peter Otten wrote: > > > Leo Kislov wrote: > > > >> 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

Re: Method much slower than function?

2007-06-14 Thread Peter Otten
Peter Otten wrote: > Leo Kislov wrote: > >> 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_fo

qt4 setFlags

2007-06-14 Thread luca72
Hello I make this code: row = self.tableWidget.rowCount() for a in range(row): self.tableWidget.item(row, 0).setFlags(Qt.IsSelectable) i have this erroror : global name Qt is not definied Regards Luca -- http://mail.python.org/mailman/listinfo/python-list

Moving items from list to list

2007-06-14 Thread HMS Surprise
Just wondered if there was some python idiom for moving a few items from one list to another. I often need to delete 2 or 3 items from one list and put them in another. Delete doesn't seem to have a return value. I don't care which items I get so now I just use a couple of pops or a for loop for m

Re: dynamically generated runtime methods & reflection

2007-06-14 Thread Jay Loden
Josiah Carlson wrote: > > Ahh, so you want to pass the method name to the method that you are > returning to be called. No problem. > > >>> import functools > >>> > >>> class foo: > ... def __getattr__(self, name): > ... return functools.partial(self.ActualMethod, name) > ... >

Re: for web application development

2007-06-14 Thread Evan Klitzke
On 6/14/07, james_027 <[EMAIL PROTECTED]> wrote: > My problem is looking for a web framework for python, that could > provide a natural way of developing web app. I am avoiding to learn > template language as much as possible. You should definitely reconsider avoiding templates -- it's hard to ima

Re: Method much slower than function?

2007-06-14 Thread Diez B. Roggisch
Grant Edwards schrieb: > On 2007-06-14, Leo Kislov <[EMAIL PROTECTED]> wrote: >> 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. >>> >> cProfi

Re: Method much slower than function?

2007-06-14 Thread Matimus
> The first time you read the file, it has to read it from disk. > The second time, it's probably just reading from the buffer > cache in RAM. I can verify this type of behavior when reading large files. Opening the file doesn't take long, but the first read will take a while (multiple seconds dep

Re: Python-URL! - weekly Python news and links (Jun 11)

2007-06-14 Thread Alex Martelli
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > QOTW: "That's the Martellibot for you. Never use a word where a paragraph > with explanatory footnotes will do. > > Sigh. I miss him on c.l.py." - Simon Brunning Funny -- didn't Simon write this in 2005 referring to an essay of mine that I had po

Re: one-time initialization of class members

2007-06-14 Thread James Turk
On Jun 13, 11:42 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > 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. > > >

Re: Method much slower than function?

2007-06-14 Thread Grant Edwards
On 2007-06-14, Leo Kislov <[EMAIL PROTECTED]> wrote: > 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

Re: Build EXE on Mac OsX 10.4

2007-06-14 Thread Paul McNett
Sherm Pendley wrote: > "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

Re: How to save python codes in files?

2007-06-14 Thread BartlebyScrivener
On Jun 13, 12:04 am, why? <[EMAIL PROTECTED]> wrote: > Im working with Python 2.2 on my red hat linux system. Is there any > way to write python codes in separate files and save them so that i > can view/edit them in the future? Actually I've just started with > python and would be grateful for a r

Re: xmlrpclib hangs execution

2007-06-14 Thread itkovian
On Jun 14, 3:10 pm, [EMAIL PROTECTED] wrote: > Hi, > > > 2. The Python implementation ofxmlrpcis not very robust. It just waits for > > the connection to close. A well-written client (like your Java client) > > would detect the presence of a Content-Length header and use that. > > I'm facing a simi

Re: xmlrpclib hangs execution

2007-06-14 Thread itkovian
Hi, > 2. The Python implementation ofxmlrpcis not very robust. It just waits for > the connection to close. A well-written client (like your Java client) > would detect the presence of a Content-Length header and use that. I'm facing a similar ordeal here. I think the right thing to do would be t

Re: Convert String to Int and Arithmetic

2007-06-14 Thread Facundo Batista
tereglow wrote: > cpuSpeed = 'Speed: 10' > > What I would like to do is extract the '10' from the string, > and divide that by 1000 twice to get the speed of a processor in MHz. >>> cpuSpeed = 'Speed: 10' >>> p = cpuSpeed.split(":") >>> p ['Speed', ' 10'] >>> p[1]

Re: Method much slower than function?

2007-06-14 Thread Neil Cerutti
On 2007-06-14, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > 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 > '

  1   2   >