Re: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-22 Thread Peter Otten
Sandra-24 wrote: > Now that is a clever little trick. I never would have guessed you can > assign to __class__, Python always surprises me in it's sheer > flexibility. > > In this case it doesn't work. > > TypeError: __class__ assignment: only for heap types > > I suspect that's because this ob

Job title: $300 flat for job in perl, cgi, Visual Basic/Asp.Net, whatever online project

2006-04-22 Thread swordedotcom
Posted: April 22, 2006 Job title: $300 flat for job in perl, cgi, Visual Basic/Asp.Net, whatever online project Company name: Sworde.com Location: United States, Colorado, Glenwood Springs Pay rate: 300.00 flat for job Travel: 0% Length of employment: Until job done Hours: Flexible Onsite: no Descr

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-22 Thread Nick Craig-Wood
Gerard Flanagan <[EMAIL PROTECTED]> wrote: > def distribution(N=2): > p = [0] + sorted( random.random() for _ in range(N-1) ) + [1] > for j in range(N): > yield p[j+1] - p[j] > > spread = list(distribution(10)) > > print spread > print sum(spread) This is simpler, easier t

Re: Custom data type in a matrix.

2006-04-22 Thread Robert Kern
Gaz wrote: > Hi guys. I've been lookig for this in the numpy pdf manual, in this > group and on google, but i could not get an answer... You will probably want to look or ask on the numpy list, too. https://lists.sourceforge.net/lists/listinfo/numpy-discussion > Is there a way to create a cust

Re: Custom data type in a matrix.

2006-04-22 Thread Gaz
BTW, i tried the "classe Thinge(): pass" but does not qualify as "data type" for a numpy array. -- http://mail.python.org/mailman/listinfo/python-list

Custom data type in a matrix.

2006-04-22 Thread Gaz
Hi guys. I've been lookig for this in the numpy pdf manual, in this group and on google, but i could not get an answer... Is there a way to create a custom data type (eg: Name: string(30), Age: int(2), married: boolean, etc) and then use that custom data in a matrix? Actually, this is a two questi

Re: check whether a value is scalar

2006-04-22 Thread Eli
Python treats integers as objects, but as I mentioned that I do care about the value only, and not its object methods. I mean that it's not possible to share objects among application in different programming languages, but it's possible to share the scalar values among them. Strings, booleans, int

Re: Performance of Python 2.3 and 2.4

2006-04-22 Thread Felipe Almeida Lessa
Em Dom, 2006-04-23 às 00:20 +0200, Michal Kwiatkowski escreveu: > Hi! > > I was just wondering... Probably there is another factor involved: $ python2.3 Python 2.3.5 (#2, Mar 6 2006, 10:12:24) [GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2 Type "help", "copyright", "credits" or "

Re: Application Generators

2006-04-22 Thread rajeev . tandon
Hi walterbyrd, I had also gone through this search earlier, but unfortunately the app generators generate a lot of code, and more imp is that inspite of this, they are not very close to what you really need. I had been evaluating these from time to time. Appgini is good but mostly from an academic

Re: howto py2exe/py2app for self updating application

2006-04-22 Thread Tony Meyer
> I'm creating a GUI program > with wxPython which will be distributed for Mac and Windows. [...] > The program should be able to update itself [...] By default, py2exe puts all the .pyc files used in a zip file. The simplest way to do this it let py2exe do what it normally does. Code all o

Re: problems when unpacking tuple ...

2006-04-22 Thread John Machin
On 23/04/2006 2:21 AM, harold wrote: > Dear all, > > Maybe I stared on the monitor for too long, because I cannot find the > bug ... You already have your answer, but below are clues on how to solve such problems much faster by yourself. > My script "transition_filter.py" starts with the follow

Re: Performance of Python 2.3 and 2.4

2006-04-22 Thread Tim Peters
[Michal Kwiatkowski] > I was just wondering... > > Python 2.3.5 (#2, Mar 6 2006, 10:12:24) > [GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import timeit > >>> a = timeit.Timer('2**1') > >>> b = t

Re: need a thread to keep a socket connection alive?

2006-04-22 Thread nephish
thanks for the info, i will likely use the first link you posted with the async module just to get it going, but i want to learn more about twisted for later. there is even an O'Reilly book on it i see. thanks for the tips, sk -- http://mail.python.org/mailman/listinfo/python-list

Re: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "Sandra-24" <[EMAIL PROTECTED]> wrote: >Now that is a clever little trick. I never would have guessed you can >assign to __class__, Python always surprises me in it's sheer >flexibility. That's because you're still thinking in OO terms. -- http://mail.python.org/

Re: another question about buffers

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: >i think it may be, Moral: don't use arbitrary values as booleans. -- http://mail.python.org/mailman/listinfo/python-list

Performance of Python 2.3 and 2.4

2006-04-22 Thread Michal Kwiatkowski
Hi! I was just wondering... Python 2.3.5 (#2, Mar 6 2006, 10:12:24) [GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import timeit >>> a = timeit.Timer('2**1') >>> b = timeit.Timer('112233445566778899

Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-22 Thread Ant
Take a look at the newgroup archives over the last week or two - there seem to have been a glut of people coming from Java to Python and asking the same sort of questions. There were some links to a bunch of Python 'gotcha' pages which will be useful. For my part, I came from Java to Python, and f

Re: Problem calling math.cos()

2006-04-22 Thread Robert Kern
Tim Peters wrote: > [Robert Kern] > >>... >>ph3 = math.atan( ac3.imag / ac3.real ) >>... > > Don't do that: atan2 is the correct way to compute the angle, because > the signs of both inputs are needed to determine the correct quadrant. > So do: > > ph3 = math.atan2(ac3.imag, ac3.real)

Re: Problem calling math.cos()

2006-04-22 Thread Sambo
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, Sambo <[EMAIL PROTECTED]> > wrote: > > >>I have the following module: >>--- >>import math >> >>def ac_add_a_ph( amp1, ph1, amp2, ph2 ): >> >>amp3 = 0.0 >>ph3 = 0.0 >>ac1 = ( 0, 0j ) >>ac2 = ( 0, 0j )

Re: check whether a value is scalar

2006-04-22 Thread harold
would isinstance(value,(type(None),str,int,float,bool)) be enough? This yields true if the type value is in the list of type objects given as second argument, or a subtype of one of them. What, however, do you mean with "I care about the value only, and not its class method"? -- http://mail

Re: check whether a value is scalar

2006-04-22 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Eli" <[EMAIL PROTECTED]> wrote: > Hi, > > I want to check whether a value is a scalar. A scalar can be: > - None (null) > - string > - number (integer, float) > - boolean > How can I validate a value is one of these types? > > I care about the value only, and no

Re: problems when unpacking tuple ...

2006-04-22 Thread harold
Thanks for all your answer! Of course, I wanted to assign the outcome of the split(), not to iterate over them. Thinks are done so easy in python that, sometimes, one does not even notice that one actually does them ;-) Cheers, - harold - -- http://mail.python.org/mailman/listinfo/python-list

Re: list example

2006-04-22 Thread bearophileHUGS
PAolo>any comment, suggestion? Is there something not elegant?< Here you can see many little differences, some of them reflect just my style, but some other of them are Python standard style guidelines: even = [] odd = [] for i in xrange(1, 10): if i % 2: odd.append(i)

Re: Can my python script return a value to the c program executing it?

2006-04-22 Thread Philippe Martin
Like this ? http://aspn.activestate.com/ASPN/Mail/Message/python-list/1304518 Philippe vduber6er wrote: > I have a C program that calls my python script by > > exec_pycode(code); > > code = "import CheckFasta\nCheckFasta.CheckFasta (\"sampledata.txt\", > %d)\n", PyNum); > > CheckFasta.p

check whether a value is scalar

2006-04-22 Thread Eli
Hi, I want to check whether a value is a scalar. A scalar can be: - None (null) - string - number (integer, float) - boolean How can I validate a value is one of these types? I care about the value only, and not its class methods. An object is not a scalar, since it's not a simple value. An array

Re: Problem calling math.cos()

2006-04-22 Thread Tim Peters
[Roy Smith] > I certainly agree about using atan2() instead of atan(), but I'm surprised > there's not an easier way to get the phase of a complex, just like abs() > gives you the modulus. I can see why you wouldn't want to pollute the > global namespace with another built-in just for this purpose

Re: Lamdba forms

2006-04-22 Thread Duncan Booth
Ant wrote: > Fair enough. I've just found this as well, which implies that lambda > isn't being killed off in 3.0: > > http://www.python.org/dev/peps/pep-3100/ > > In particular: > "Lambdas will have to be parenthesized [23]" > Also: http://www.python.org/doc/essays/ppt/accu2006/Py3kACCU.ppt s

Re: list example

2006-04-22 Thread Wojciech Muła
PAolo wrote: > any comment, suggestion? Is there something not elegant? Try this: even = range(10)[0::2] odd = range(10)[1::2] -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem calling math.cos()

2006-04-22 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Tim Peters" <[EMAIL PROTECTED]> wrote: > [Robert Kern] > > ... > > ph3 = math.atan( ac3.imag / ac3.real ) > > ... > > Don't do that: atan2 is the correct way to compute the angle, because > the signs of both inputs are needed to determine the correct quadran

Python on WinXP: 7 Minutes To "Hello World!"

2006-04-22 Thread BartlebyScrivener
I started a long email to a friend about how to get up and running on Python, then I thought, why not make something I can post? It's NOT a tutorial. Just a specific, narrow, quick installation guide for Windows XP users. Would love comments, but probably can't incorporate them until Monday, beca

Re: list example

2006-04-22 Thread Edward Elliott
No substantive problems. The str() calls are unnecessary, print calls list.__str__ already. You can replace the loop with list comprehensions or slices. Same result, a bit more succinct. See these pages for more: http://docs.python.org/lib/typesseq.html http://docs.python.org/tut/node7.html

list example

2006-04-22 Thread PAolo
Hi, I wrote this small example to illustrate the usage of lists: even=[] odd=[] for i in range(1,10): if i%2: odd.append(i) else: even.append(i) print "odd: "+str(odd) print "even: "+str(even) numbers=even numbers.extend(odd) print "numbers:"+str(

Re: quick surface plots

2006-04-22 Thread nich2o
Did you try mplot3D ? http://www.scipy.org/Wiki/Cookbook/Matplotlib/mplot3D -- N -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem calling math.cos()

2006-04-22 Thread Tim Peters
[Robert Kern] > ... > ph3 = math.atan( ac3.imag / ac3.real ) > ... Don't do that: atan2 is the correct way to compute the angle, because the signs of both inputs are needed to determine the correct quadrant. So do: ph3 = math.atan2(ac3.imag, ac3.real) instead. -- http://mail.python.o

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-22 Thread Anthony Liu
Thanks a lot, Alex and Gerard. I am actually not very concerned about the inter-dependency of the floating numbers generated randomly. They are good enough if they are subject to the constraint of summing up to 1. It is simply not worth the time to get an HMM by training it on a large corpus.

Re: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-22 Thread Sandra-24
Now that is a clever little trick. I never would have guessed you can assign to __class__, Python always surprises me in it's sheer flexibility. In this case it doesn't work. TypeError: __class__ assignment: only for heap types I suspect that's because this object begins its life in C code. The

Re: Problem calling math.cos()

2006-04-22 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-22 às 15:14 -0400, Sambo escreveu: > when I import it (electronics) in python.exe in windows2000 and > try to use it, it croaks. ??? $ python2.4 Python 2.4.3 (#2, Mar 30 2006, 21:52:26) [GCC 4.0.3 (Debian 4.0.3-1)] on linux2 Type "help", "copyright", "credits" or "license" for m

Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-22 Thread Chris Lambacher
http://dirtsimple.org/2004/12/python-is-not-java.html http://dirtsimple.org/2004/12/java-is-not-python-either.html http://dirtsimple.org/2004/12/python-interfaces-are-not-java.html This link seems to be down at the moment. http://naeblis.cx/rtomayko/2004/12/15/the-static-method-thing The above a

Re: Problem calling math.cos()

2006-04-22 Thread Robert Kern
Sambo wrote: > I have the following module: > --- > import math > > def ac_add_a_ph( amp1, ph1, amp2, ph2 ): > > amp3 = 0.0 > ph3 = 0.0 > ac1 = ( 0, 0j ) > ac2 = ( 0, 0j ) > ac3 = ( 0, 0j ) >

Re: Problem calling math.cos()

2006-04-22 Thread Alex Martelli
Sambo <[EMAIL PROTECTED]> wrote: > I have the following module: > --- > import math > > def ac_add_a_ph( amp1, ph1, amp2, ph2 ): > > amp3 = 0.0 > ph3 = 0.0 > ac1 = ( 0, 0j ) > ac2 = ( 0, 0j ) > ac3 = ( 0, 0j ) You're defining ac1, ac2, ac3 as tup

Re: Problem calling math.cos()

2006-04-22 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Sambo <[EMAIL PROTECTED]> wrote: > I have the following module: > --- > import math > > def ac_add_a_ph( amp1, ph1, amp2, ph2 ): > > amp3 = 0.0 > ph3 = 0.0 > ac1 = ( 0, 0j ) > ac2 = ( 0, 0j )

Re: repr() for Perl?

2006-04-22 Thread skip
>> Does Perl have something like Python's repr() function? Mirco> Have a look at this: ... Thanks, I'm getting set up to try it just for the exercise. I went with John Lee's Data::Dumper suggestion simply because I already had it installed and have neither String::Escape nor Inlin

Re: repr() for Perl?

2006-04-22 Thread skip
>> Does Perl have something like Python's repr() function? John> perldoc Data::Dumper Thanks. Just what the doctor ordered (after setting Useqq). Skip -- http://mail.python.org/mailman/listinfo/python-list

Problem calling math.cos()

2006-04-22 Thread Sambo
I have the following module: --- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j ) ac3 = ( 0, 0j ) ac1 = complex( amp1 * math.cos( mat

Re: perspective on ruby

2006-04-22 Thread Edward Elliott
robert wrote: > Yes - start them explore. I'd not want to be "teached" a specific > _language_ in a course longer that one day. A language cannot be teached. > Who of the posters in this thread want themselves to be _teached_ more > than one day on a language? > > Isn't the fun, finding the ri

Re: send cookie on request with urllib2

2006-04-22 Thread itay_k
Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: problems when unpacking tuple ...

2006-04-22 Thread Gerard Flanagan
harold wrote: > Thank you Gerard. > This must be the problem. Now I can get it working. Good! I got confused thinking about it too, but I think you just had one loop too many. for line in sys.stdin : try : a,b,c,d = line.split() not: for line in sys.stdin : try : for a

Re: problems when unpacking tuple ...

2006-04-22 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-22 às 14:25 -0300, Felipe Almeida Lessa escreveu: > Em Sáb, 2006-04-22 às 09:21 -0700, harold escreveu: > > for line in sys.stdin : > > try : > > for a,b,c,d in line.split() : > > pass > > > > except ValueError , err : > > print line.split() > >

Re: Define type of 'module' object that is imported

2006-04-22 Thread Zachary Pincus
>> I would like a given module to be created as an >> instance of that particular subclass on import, so that if I do: >> >> import foo >> type(foo) >> >> I get instead of . >> >> Is there any way to effect this? Something like __metaclass__ >> = ... but >> at the beginning of a module instead

Re: problems when unpacking tuple ...

2006-04-22 Thread Rene Pijlman
harold: >A similar error happens in an interpreter session, when typing for line in ["1 2 3 4"] : >...for a,b,c,d in line.split() : >...pass >... >Traceback (most recent call last): > File "", line 2, in ? >ValueError: need more than 1 value tyo unpack > >maybe this might help to

Re: problems when unpacking tuple ...

2006-04-22 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-22 às 09:21 -0700, harold escreveu: > for line in sys.stdin : > try : > for a,b,c,d in line.split() : > pass > > except ValueError , err : > print line.split() > raise err Try this: for a, b, c, d in sys.stdin: print a, b, c, d -

Re: String formatting using dictionaries

2006-04-22 Thread Clodoaldo Pinto
Thank you guys, you are great! -- http://mail.python.org/mailman/listinfo/python-list

Re: proposed Python logo

2006-04-22 Thread EP
Michael Yanowitz wrote: > How about having something from Monty Python in the logo rather >than something snakelike. Python was named after Monty Python and not >the snake. Snakes also don't appear friendly to me. > I think the new logo, while professionally done (bravo!) is unmemmorable. And

Re: problems when unpacking tuple ...

2006-04-22 Thread harold
Thank you Gerard. This must be the problem. Now I can get it working. -- http://mail.python.org/mailman/listinfo/python-list

Re: problems when unpacking tuple ...

2006-04-22 Thread harold
Rene Pijlman schrieb: > harold: > >The output (when given the data I want to parse) is: > > If you'd told us that data, and told us what version of Python you're > using, we could have reproduced the problem to look into it. > Thank you for the answers and sorry that I did not provide more inform

Re: problems when unpacking tuple ...

2006-04-22 Thread Gerard Flanagan
harold wrote: > Dear all, > > Maybe I stared on the monitor for too long, because I cannot find the > bug ... > My script "transition_filter.py" starts with the following lines: > > import sys > > for line in sys.stdin : > try : > for a,b,c,d in line.split() : > pass > >

Re: problems when unpacking tuple ...

2006-04-22 Thread Rene Pijlman
harold: >The output (when given the data I want to parse) is: If you'd told us that data, and told us what version of Python you're using, we could have reproduced the problem to look into it. >ValueError: need more than 3 values to unpack > >Why does python think that I want to unpack the outcom

Re: problems when unpacking tuple ...

2006-04-22 Thread Tim Chase
> for a,b,c,d in line.split() : > [snip] > > The output (when given the data I want to parse) is: > ['0.0','1','0.04','0'] You'll notice that you're not passing any parameters to split(). By default, it splits on whitespace, and your input doesn't have any whitespace in it. Thus, you'

Re: need a thread to keep a socket connection alive?

2006-04-22 Thread Rene Pijlman
[EMAIL PROTECTED]: >i have a script that waits for message packets from a data server over >a socket. Using what network protocol? >it works fine for a while, but the server requires that i send a >heartbeat ping every 600 seconds or it will terminate the connection. [...] >should i do this with

problems when unpacking tuple ...

2006-04-22 Thread harold
Dear all, Maybe I stared on the monitor for too long, because I cannot find the bug ... My script "transition_filter.py" starts with the following lines: import sys for line in sys.stdin : try : for a,b,c,d in line.split() : pass except ValueError , err : pri

Re: howto py2exe/py2app for self updating application

2006-04-22 Thread SPE - Stani's Python Editor
Can you be more specific? Which module do you mean at python.org? Stani -- http://mail.python.org/mailman/listinfo/python-list

Re: proposed Python logo

2006-04-22 Thread jarrells
Mike, Excellent artwork! I don't like reinventing the wheel so I propose we reuse someone else's work. I propose something like: http://www.dvdweb.co.uk/reviewgfx/bompfc1.jpg which symbolizes Python's ability to quickly implement many coding ideas or: http://www.phill.co.uk/comedy/python/pyth

Re: howto py2exe/py2app for self updating application

2006-04-22 Thread [EMAIL PROTECTED]
of course! your can be carefully if you do it. but why you ask some here ? in http://www.python.org completly a module for your problem look and try again! [roRoNoaZoro] -- http://mail.python.org/mailman/listinfo/python-list

need a thread to keep a socket connection alive?

2006-04-22 Thread nephish
hey there, i have a script that waits for message packets from a data server over a socket. it goes a little like this: while 1: x+=1 databack = sockobj.recv(158) if databack: print 'caught a message %s bytes ' % len(databack) if len(databa

Jython/Python Programmers

2006-04-22 Thread Solar^
Greetings Group! I'm trying to do a project for my CS class. I'm using this program from Mark Guzdial Jython text: def echoes(snd, delay, factor): sound1 = makeSound(snd) sndlen1 = getLength(sound1) sndlen2 = sndlen1 + (delay * factor) sound2 =decideLen(sound1, sndlen2) # this function

Re: String formatting using dictionaries

2006-04-22 Thread Fredrik Lundh
Clodoaldo Pinto wrote: > I know how to format strings using a dictionary: > > >>> d = {'list':[0, 1]} > >>> '%(list)s' % d > '[0, 1]' > > Is it possible to reference an item in the list d['list']?: > > >>> '%(list[0])s' % d > Traceback (most recent call last): > File "", line 1, in ? > KeyError:

Re: 有關於 Mining google web services : Building applications with the Google API這本書的範例

2006-04-22 Thread pou
I have found the way to solve . So long as alter and establish reading account number and password of the database , finish. Thank you very mush. -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-22 Thread Gerard Flanagan
Gerard Flanagan wrote: > Gerard Flanagan wrote: > > Anthony Liu wrote: > > > I am at my wit's end. > > > > > > I want to generate a certain number of random numbers. > > > This is easy, I can repeatedly do uniform(0, 1) for > > > example. > > > > > > But, I want the random numbers just generated s

Re: 有關於 Mining google web services : Building applications with the Google API這本書的範例

2006-04-22 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > ?z?n?A > ?O?o?A?e???b???s "Mining Google Web Services >: Building Applications with > the Google API"[EMAIL PROTECTED] 6??"Using SQL Server as a > Database"?? > ?M?B?A???q???w?g?w??SQL Server 2000 > sp4?A?b?d???{?A.net?X

Re: a flattening operator?

2006-04-22 Thread Michael Tobis
I think by "regular expressions" you mean "expressions". "regular expressions" are what you get from "import re" . mt -- http://mail.python.org/mailman/listinfo/python-list

Re: String formatting using dictionaries

2006-04-22 Thread Peter Otten
Clodoaldo Pinto wrote: > I know how to format strings using a dictionary: > d = {'list':[0, 1]} '%(list)s' % d > '[0, 1]' > > Is it possible to reference an item in the list d['list']?: > '%(list[0])s' % d > Traceback (most recent call last): > File "", line 1, in ? > KeyError:

Re: python's thread problem on Linux platform

2006-04-22 Thread Irmen de Jong
[EMAIL PROTECTED] wrote: > I found that multi-threaded program(io-centralize ) runs very slowly > on linux while the same program runs very quickly on windows.If I > change the thread number to one ,the program runs quickly on linux, in > fact the speed is quicker than the multi-threaded vers

Re: another question about buffers

2006-04-22 Thread nephish
i think it may be, i am just doing a while 1: loop to just wait for whatever comes in. thanks -- http://mail.python.org/mailman/listinfo/python-list

String formatting using dictionaries

2006-04-22 Thread Clodoaldo Pinto
I know how to format strings using a dictionary: >>> d = {'list':[0, 1]} >>> '%(list)s' % d '[0, 1]' Is it possible to reference an item in the list d['list']?: >>> '%(list[0])s' % d Traceback (most recent call last): File "", line 1, in ? KeyError: 'list[0]' Regards, Clodoaldo Pinto -- htt

howto py2exe/py2app for self updating application

2006-04-22 Thread SPE - Stani's Python Editor
Hi, I'm creating a GUI program with wxPython which will be distributed for Mac and Windows. The audience of the program is not technical at all (eg they've never heard about Python yet ;-), so everything should go automatically. The program should be able to update itself and to update its databa

Re: repr() for Perl?

2006-04-22 Thread Mirco Wahab
Hi skip > Sorry to ask a Perl question here, but... Does Perl have something like > Python's repr() function? I want to print out a string and have CR print as > \r, LF as \n, etc. I looked in the Perl/Python phrasebook: Have a look at this: # cmp_rep.pl --- # #!/usr/bin/perl

python's thread problem on Linux platform

2006-04-22 Thread devdoer
I found that multi-threaded program(io-centralize ) runs very slowly on linux while the same program runs very quickly on windows.If I change the thread number to one ,the program runs quickly on linux, in fact the speed is quicker than the multi-threaded version . It turns out that python'

Re: repr() for Perl?

2006-04-22 Thread John J. Lee
[EMAIL PROTECTED] writes: > Sorry to ask a Perl question here, but... Does Perl have something like > Python's repr() function? I want to print out a string and have CR print as > \r, LF as \n, etc. I looked in the Perl/Python phrasebook: > > http://wiki.python.org/moin/PerlPhrasebook > >

Re: what has python added to programming languages? (lets be esoteric, shall we ;)

2006-04-22 Thread skip
Wildemar> Are there any concepts that python has not borrowed, concepts Wildemar> that were not even inspired by other languages? I'd say Guido's willingness to borrow heavily from the best ideas present in other languages ranks right up there as one of its key concepts. Skip -- http://

repr() for Perl?

2006-04-22 Thread skip
Sorry to ask a Perl question here, but... Does Perl have something like Python's repr() function? I want to print out a string and have CR print as \r, LF as \n, etc. I looked in the Perl/Python phrasebook: http://wiki.python.org/moin/PerlPhrasebook but saw nothing along those lines. Thx,

Re: String To Dict Problem

2006-04-22 Thread Clodoaldo Pinto
Michael Spencer wrote: > Alternatively, you could edit visitName to allow 'True' and any other > identifiers you specify e.g. (untested): > > allowed = {"True": True, "False": False} > def visitName(self,node, **kw): > try: > return self.allowed[node.name] > e

Re: how to append to a list twice?

2006-04-22 Thread Fredrik Lundh
Alex Martelli wrote: > > But Now You've Violated The DRY Principle!!! > > Just as with any other unrolled loop, yes -- loop unrolling is an > optimization which is based exactly on exchanging some textual > repetition for a tiny bit more speed. I had hoped that the Unusual Capitalization would ha

Re: Uniquifying a list?

2006-04-22 Thread bearophileHUGS
There is my version too: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438599 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: perspective on ruby

2006-04-22 Thread robert
Edward Elliott wrote: > Alex Martelli wrote: > >> While Mozart appears cool, I really think that a wider variety of >> languages would help -- some machine code (possibly abstract a la >> Mixal), C (a must, *SO* much is written in it!), at least one of C++, D, >> or ObjectiveC, either Scheme or L

Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-22 Thread Anton Vredegoor
ToddLMorgan wrote: > I'm just starting out with python, after having a long history with > Java. I was wondering if there were any resources or tips from anyone > out there in Python-land that can help me make the transition as > successfully as possible? Perhaps you've made the transition yoursel

Re: a flattening operator?

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "gangesmaster" <[EMAIL PROTECTED]> wrote: >as we all know, * (asterisk) can be used to "inline" or "flatten" a >tuple into an argument list, i.e.: > >def f(a, b, c): >... >x = (1,2,3) >f(*x) > >so... mainly for symmetry's sake, why not make a "flattening" opera

Re: [OT] Any Python lullabies?

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, Ralf Muschall <[EMAIL PROTECTED]> wrote: >Christos Georgiou wrote: >> ... that I can sing to my newborn son (actually, born yesterday)? > >...but the baby probably won't see the difference. Boy, some people do take the "born yesterday" bit to heart. don't they. :

Re: Uniquifying a list?

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, Felipe Almeida Lessa <[EMAIL PROTECTED]> wrote: >"list(set(x))" is the clear winner with almost O(1) performance. Moral: in an interpreted language, use builtins as much as possible. -- http://mail.python.org/mailman/listinfo/python-list

Re: FOUNDIT (was Re: massive threading performance)

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, Paul Sijben <[EMAIL PROTECTED]> wrote: >I found that the problem was caused by the sending thread not giving >control back quickly enough to the receiving thread. > >Also in going through the code I found an old self.s.setblocking(0)call >that was no longer relevan

Re: Define type of 'module' object that is imported

2006-04-22 Thread robert
Zachary Pincus wrote: > Hi folks, > > I'm sure this has come up before, but the search terms I've been using > are so non-specific that I can't get any traction on Google. > > Here's my question: > I have written a subclass of ModuleType that handles lazy loading of > some slow resources. I

Re: send cookie on request with urllib2

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (John J. Lee) wrote: >"No," scolded Yoda. "Do, or do not. There is no try." Convincing argument against exceptions, don't you think. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: another question about buffers

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: >databack = sockobj.recv(1028) >if databack: > print 'caught a message %s bytes ' % len(databack) >else: > print 'fail to recieve data from server' > >the output in the terminal runs fine until it fails to get the >databack, it

Re: Raising a specific OSError

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, David Hirschfield <[EMAIL PROTECTED]> wrote: >When I attempt to perform a file operation on a non-existent file, I get >an OSError: [Errno 2], but what if I want to raise one of those myself? raise OSError(2, "No such file or directory") -- http://mail.python.or

Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "ToddLMorgan" <[EMAIL PROTECTED]> wrote: >Are there python specific equivalents to the common Patterns, >Anti-Patterns and Refactoring books that are so prevalent as >reccomended reading in C++ and Java? I don't think they exist. Such books are targeted more towar

Re: Looking for resources for making the jump from Java to Python easier and more productive

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "ToddLMorgan" <[EMAIL PROTECTED]> wrote: >I'm looking for the common types of mistakes that say a Java/C# or >even C++ developer may commonly make. Using subclassing when you don't have to. For instance, you might have a Java method which takes an argument of typ

Re: proposed Python logo

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >On Fri, 21 Apr 2006 16:13:53 -0700, "Carl J. Van Arsdall" ><[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> Lawrence D'Oliveiro wrote: >> > >> > Six words: copyright violation ... trademark violatio

Re: Pythonesque interface.

2006-04-22 Thread bearophileHUGS
Gaz: > Right now im trying to dl Jython (SF.net server down?), if it's > language sintaxis is just like Python and allows to use numpy and PIL, > im in! (i think :) ) I don't think you can do that, but you can create and show images anyway (and maybe read the pointer position too). Sorry for the "

Re: ANN: XMLObject

2006-04-22 Thread Nicolay A. Vasiliev
Hello! I tried to use this class in my work. But I Can't understand the next. I have an XML file, where I store an information by this way Wesley Hunter ie. How can I get the value between and ? Thanks in advance. aum wrote: > Hi folks, > > I've just released an XML object wrapper called XMLO

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-22 Thread Gerard Flanagan
Gerard Flanagan wrote: > Anthony Liu wrote: > > I am at my wit's end. > > > > I want to generate a certain number of random numbers. > > This is easy, I can repeatedly do uniform(0, 1) for > > example. > > > > But, I want the random numbers just generated sum up > > to 1 . > > > > I am not sure h

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-22 Thread Gerard Flanagan
Anthony Liu wrote: > I am at my wit's end. > > I want to generate a certain number of random numbers. > This is easy, I can repeatedly do uniform(0, 1) for > example. > > But, I want the random numbers just generated sum up > to 1 . > > I am not sure how to do this. Any idea? Thanks. > ---

  1   2   >