Re: SuSE 9.1: updating to python-2.4

2005-01-09 Thread Peter Maas
Torsten Mohr schrieb: along with my distribution SuSE 9.1 came python 2.3.3. I'd like to update to 2.4 now, is this an easy thing to do or will lots of installed modules refuse to work then? Is there an easy way to find out what i need to update? I uninstalled 2.3.3 and compiled/installed 2.4 from

Re: Speed revisited

2005-01-09 Thread Andrea Griffini
On 9 Jan 2005 16:03:34 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: >My wild guess: Not a common use case. Double-ended queue is a special >purpose structure. > >Note that the OP could have implemented the 3-tape update simulation >efficiently by reading backwards i.e. del alist[-1] Note that

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Steven Bethard
[EMAIL PROTECTED] wrote: Steve Bethard wrote: Robert Kern wrote: def square(x): return x*x map(square, range(1000)) versus [x*x for x in range(1000)] Hint: function calls are expensive. $ python -m timeit -s "def square(x): return x*x" "map(square, range(1000))" 1000 loops, best of 3:

Re: Datetime module

2005-01-09 Thread Binu K S
The time module will do. >>> import time >>> time.ctime() 'Mon Jan 10 11:17:54 2005' Use strftime if you need to format the time differently. >>> time.strftime("%Y-%m-%d %H:%m:%S",time.localtime()) '2005-01-10 11:01:45' On 9 Jan 2005 21:46:12 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Steven Bethard
John Machin wrote: Steven Bethard wrote: Note that list comprehensions are also C-implemented, AFAIK. Rather strange meaning attached to "C-implemented". The implementation generates the code that would have been generated had you written out the loop yourself, with a speed boost (compared with the

Datetime module

2005-01-09 Thread rublind
I am writing a script that acts as an AIM bot [using twisted.IM's base scripts] and I want to add a logging feature. I got it to log who sends what to whom, but what I want to add is the date and time that the message was sent (or recieved by the bot), I tried to look at datetime on my own, and I c

Re: else condition in list comprehension

2005-01-09 Thread It's me
> z = [i + (2, -2)[i % 2] for i in range(10)] But then why would you want to use such feature? Wouldn't that make the code much harder to understand then simply: z=[] for i in range(10): if i%2: z.append(i-2) else: z.append(i+2) Or are we trying to write a book on "Puzz

Re: a new Perl/Python a day

2005-01-09 Thread Andy Gross
On Jan 10, 2005, at 12:11 AM, Scott Bryce wrote: No. Perl may have some interesting idiosyncrasies, especially for a programmer with little or no Unix experience, but I find it neither frustrating, inane nor incompetent. The more I use it, the more I like it. I don't see what UNIX experience has

Re: Python Operating System???

2005-01-09 Thread Paul Rubin
Arich Chanachai <[EMAIL PROTECTED]> writes: > > And I think Pypy is currently set up to compile Python > >into Pyrex and then run the Pyrex results through GCC. > > > But of course, who's going to argue that Pyrex produces "compiled > Python"? Pyrex produces compiled Python in the same sense th

Re: Long strings as function parameters

2005-01-09 Thread Jeremy Bowers
On Sun, 09 Jan 2005 08:36:04 -0800, onlyonemc wrote: > I would like to have functions that operate on long strings, 10-100 MB. In > C I would of course pass a pointer to the string for a quick function > call. What is an efficient way to do this in python? Cheers, > -mark Others have pointed ou

Re: a new Perl/Python a day

2005-01-09 Thread Scott Bryce
Bob Smith wrote: Scott Bryce wrote: Xah Lee wrote: frustrated constantly by its inanities and incompetences.) I don't see what this has to do with Perl. You're joking, right? No. Perl may have some interesting idiosyncrasies, especially for a programmer with little or no Unix experience, but I f

Re: Python Operating System???

2005-01-09 Thread Arich Chanachai
Paul Rubin wrote: Arich Chanachai <[EMAIL PROTECTED]> writes: Yes, compiled Lisp. There are Python compilers too.\ ??? You mean like Pyrex or some such? I wouldn't exactly call these "Python" compilers, as that kind of obscures some underlying (critical) facts. Also psyco. Directl

Re: Getting rid of "self."

2005-01-09 Thread Jeremy Bowers
On Mon, 10 Jan 2005 01:51:07 +0100, BJÃrn Lindqvist wrote: > This is promising, I'm content with whatever slowdowns necessary as long > as I can prove those who say "you can't do it" wrong. :) Since I think I'm the only person in this discussion that said anything about what you can't do, be clear

Re: Old Paranoia Game in Python

2005-01-09 Thread [EMAIL PROTECTED]
Paul McGuire wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > Aahz wrote: > > > Trust the computer, the computer is your friend. > > > > However, the computer isn't a fuckin' mind reader. > > > > If you're going to post source code on the usenet, don't > > have lines

Re: Python Operating System???

2005-01-09 Thread Paul Rubin
"Roose" <[EMAIL PROTECTED]> writes: > Are you actually going to answer any of my questions? Let's see > this "JavaScript task scheduler" you have written! I wrote it at a company and can't release it. It ran inside a browser. There was nothing terribly amazing about it. Obviously the tasks it

Re: Python Operating System???

2005-01-09 Thread Roose
"Paul Rubin" wrote in message news:[EMAIL PROTECTED] > "Roose" <[EMAIL PROTECTED]> writes: > > > I've written file systems in Python, and task schedulers in > > > Javascript, and they were fine for their purposes > > > > Uh, not to be rude, but what are you talking about

Re: Python Operating System???

2005-01-09 Thread Paul Rubin
Arich Chanachai <[EMAIL PROTECTED]> writes: > >Yes, compiled Lisp. There are Python compilers too.\ > > > ??? You mean like Pyrex or some such? I wouldn't exactly call these > "Python" compilers, as that kind of obscures some underlying > (critical) facts. Also psyco. And I think Pypy is curre

Re: Python Operating System???

2005-01-09 Thread Arich Chanachai
Paul Rubin wrote: "Roose" <[EMAIL PROTECTED]> writes: ... Upon reading back in the thread I see that you mean compiled Lisp, no? I was thinking that there would be a Lisp interpreter in a kernel, which afaik doesn't exist. Yes, compiled Lisp. There are Python compilers too.\ ??? You m

Re: a new Perl/Python a day

2005-01-09 Thread Charlton Wilbur
> "XL" == Xah Lee <[EMAIL PROTECTED]> writes: XL> i'll cross post to comp.lang.perl.misc and comp.lang.python. XL> If you spot mistakes, feel free to correct or discourse here. Error #1: crossposting to those two groups. (Error #2 is implying that you're a Perl expert, but someone

Re: Old Paranoia Game in Python

2005-01-09 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Aahz wrote: > > Trust the computer, the computer is your friend. > > However, the computer isn't a fuckin' mind reader. > > If you're going to post source code on the usenet, don't > have lines longer than 72 characters. Otherwise you'

Re: Python Operating System???

2005-01-09 Thread Paul Rubin
"Roose" <[EMAIL PROTECTED]> writes: > > I've written file systems in Python, and task schedulers in > > Javascript, and they were fine for their purposes > > Uh, not to be rude, but what are you talking about? If I'm not mistaken > Javascript is that scripting language that runs inside a browser,

Re: Python Operating System???

2005-01-09 Thread Roose
> I've written file systems in Python, and task schedulers in > Javascript, and they were fine for their purposes Uh, not to be rude, but what are you talking about? If I'm not mistaken Javascript is that scripting language that runs inside a browser, an application. How are you going to save an

Re: a new Perl/Python a day

2005-01-09 Thread Bob Smith
Scott Bryce wrote: Xah Lee wrote: frustrated constantly by its inanities and incompetences.) I don't see what this has to do with Perl. You're joking, right? -- http://mail.python.org/mailman/listinfo/python-list

Re: a new Perl/Python a day

2005-01-09 Thread James Stroud
On Sunday 09 January 2005 05:31 pm, Scott Bryce wrote: > Xah Lee wrote: > > frustrated constantly by its inanities and incompetences.) > > I don't see what this has to do with Perl. On Sunday 09 January 2005 04:28 pm, Matt Garrish wrote: > What language are you an expert at? It certainly isn't Per

Powerful CGI libraries for Python?

2005-01-09 Thread sam
Hi, I m looking for a CGI libraries just like perl's CGI.pm for Python. From google, I found quite a few of CGI libraries already written for python. But I haven't had experience to try any of them in Python. Can anyone share your Python CGI experience with me? Which library is better in terms

Re: python3: 'where' keyword

2005-01-09 Thread Paul Rubin
"Carl Banks" <[EMAIL PROTECTED]> writes: > And a suite, be it a def statement, a where block, or whatever, belongs > in a statement, not an expression. So do you approve of the movement to get rid of the print statement? -- http://mail.python.org/mailman/listinfo/python-list

Re: Please Contribute Python Documentation!

2005-01-09 Thread Kent Johnson
Aahz wrote: In article <[EMAIL PROTECTED]>, Tony Meyer <[EMAIL PROTECTED]> wrote: I don't think I've seen such a statement before - the stuff I've seen all indicates that one should be submitting proper LaTeX docs/patches. If plain-text contributions are welcome, could this be added to the doc abou

Re: a new Perl/Python a day

2005-01-09 Thread Scott Bryce
Xah Lee wrote: frustrated constantly by its inanities and incompetences.) I don't see what this has to do with Perl. -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed revisited

2005-01-09 Thread Kent Johnson
Andrea Griffini wrote: I've to admit that I also found strange that deleting the first element from a list is not O(1) in python. My wild guess was that the extra addition and normalization required to have insertion in amortized O(1) and deletion in O(1) at both ends of a random access sequence wa

RE: Please Contribute Python Documentation!

2005-01-09 Thread Tony Meyer
> It *is* in the docs now -- see the top of > http://www.python.org/doc/2.4/doc/doc.html Oops. I ought to have checked rather than going by memory (I suppose the last time I looked 2.3 would have been current). Thanks for correcting me! =Tony.Meyer -- http://mail.python.org/mailman/listinfo/p

Re: path to python file given module

2005-01-09 Thread Gene
It works now. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: path to python file given module

2005-01-09 Thread Steve Holden
Gene wrote: that method doesn't seem to work as well on UNIX: wla apocalypse[94] ~/filegen > ls filegen.py OLDwla_csv2objects.py wlaclasses.py filegen.pyc templates/ wlaclasses.pyc gen_all_from_csv.py test.py* wla apocalypse[95] ~/filegen > python Us

Re: python3: 'where' keyword

2005-01-09 Thread Carl Banks
Paul Rubin wrote: > Nick Coghlan <[EMAIL PROTECTED]> writes: > > Trying to push it a level further (down to expressions) would, IMO, be > > a lot of effort for something which would hurt readability a lot. > > I think we should just try to do things in a simple and general way > and not try to enf

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Steve Holden
[EMAIL PROTECTED] wrote: Steve Holden wrote: No he didn't. I think you will find you are attributing Steven Bethard's comments to me. [...] The Numeric and Numarray Python modules have predefined ufunc's that are essentially elemental functions with one or two arguments. It would be nice if one c

Re: path to python file given module

2005-01-09 Thread Kartic
That is because your module in not in a standard location that python can find it in. It is not that inspect.getsourcefile() is not working. Actually if you try reloading your filegen module after the os.chdir(), you will see that import fails. If you copy your filegen directory to the site-packag

Re: Old Paranoia Game in Python

2005-01-09 Thread [EMAIL PROTECTED]
Aahz wrote: > Trust the computer, the computer is your friend. However, the computer isn't a fuckin' mind reader. If you're going to post source code on the usenet, don't have lines longer than 72 characters. Otherwise you'll find your code has wrapped lines. This not only causes syntax errors i

Re: path to python file given module

2005-01-09 Thread Gene
that method doesn't seem to work as well on UNIX: wla apocalypse[94] ~/filegen > ls filegen.py OLDwla_csv2objects.py wlaclasses.py filegen.pyc templates/ wlaclasses.pyc gen_all_from_csv.py test.py* wla apocalypse[95] ~/filegen > python ... >>> import fil

Re: Getting rid of "self."

2005-01-09 Thread BJörn Lindqvist
Thank you for your replies. It is very nice to see that a thread you started is generating so much discussion, but please, I have read the previous debates so I know all about what people think about self. Spare the "you shouldn't do that" and "self is here to stay" replies to the threads in which

xml.sax._exceptions.SAXReaderNotAvailable

2005-01-09 Thread iwcook58
I am having a problem running py2exe on my computer. When running the exe that has been generated by py2exe the following error comes up. C:\MyPython\dist>kirbyutils.exe kirby350.xml Traceback (most recent call last): File "kirbyutils.py", line 292, in ? File "kirbyutils.py", line 261, in main Fi

Re: a new Perl/Python a day

2005-01-09 Thread Matt Garrish
"Xah Lee" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > i'm starting a yahoo group for learning python. Each day, a tip of > python will be shown, with the perl equivalent. For those of you > perlers who always wanted to learn python, this is suitable. (i started > it because i al

Re: Speed revisited

2005-01-09 Thread John Machin
Andrea Griffini wrote: > On 9 Jan 2005 12:39:32 -0800, "John Machin" <[EMAIL PROTECTED]> > wrote: > > >Tip 1: Once you have data in memory, don't move it, move a pointer or > >index over the parts you are inspecting. > > > >Tip 2: Develop an abhorrence of deleting data. > > I've to admit that I al

Re: Please Contribute Python Documentation!

2005-01-09 Thread Aahz
In article <[EMAIL PROTECTED]>, Tony Meyer <[EMAIL PROTECTED]> wrote: > >I don't think I've seen such a statement before - the stuff I've seen >all indicates that one should be submitting proper LaTeX docs/patches. >If plain-text contributions are welcome, could this be added to the doc >about cont

Re: vi and python

2005-01-09 Thread David Wilson
km wrote: Is there a way to display inbuilt function syntax as the user starts typing a function name with 'Vi' editor in console mode? Hi there, Unfortunately due to the highly dynamic nature of Python, this is difficult to do reliably. It is one benefit that static typing, to a certain exte

Re: Old Paranoia Game in Python

2005-01-09 Thread Aahz
In article <[EMAIL PROTECTED]>, Lucas Raab <[EMAIL PROTECTED]> wrote: >Aahz wrote: >> In article <[EMAIL PROTECTED]>, >> Lucas Raab <[EMAIL PROTECTED]> wrote: >>>Sean P. Kane wrote: Equipment: Red Reflec Armour, Laser Pistol, Laser Barrel (red), Notebook & Stylus, Knife, Co

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread beliavsky
Steve Holden wrote: >> def square(x): >> return x*x >> map(square, range(1000)) >> versus >> [x*x for x in range(1000)] >> Hint: function calls are expensive. >$ python -m timeit -s "def square(x): return x*x" "map(square, range(1000))" >1000 loops, best of 3: 693 usec per loop >$

Re: path to python file given module

2005-01-09 Thread Kartic
Try this:; >>> import filegen >>> import inspect >>> print inspect.getsourcefile(filegen.SomeClass) 'C:\\Python23\\Lib\\site-packages\\filegen\filegen.py' Cheers, --Kartic -- http://mail.python.org/mailman/listinfo/python-list

path to python file given module

2005-01-09 Thread Gene
Is there a way to get a relative or absolute path to a python file once it's been imported as a module? For example, I type: >>> import filegen and I want a string that represents the path to filegen.py (either relative to current working directory or the absolute path) -- http://mail.python.or

RE: Please Contribute Python Documentation!

2005-01-09 Thread Tony Meyer
> I'm changing the subject so that hopefully people who have > long ago tuned out the "Python evolution: Unease" subject > will read this note. Worked for me :) Two other pages that are probably of use to people interested in this are:

Re: else condition in list comprehension

2005-01-09 Thread Reinhold Birkenfeld
Matteo Dell'Amico wrote: > Luis M. Gonzalez wrote: >> Hi there, >> >> I'd like to know if there is a way to add and else condition into a >> list comprehension. I'm sure that I read somewhere an easy way to do >> it, but I forgot it and now I can't find it... >> >> for example: >> z=[i+2 for i in

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread John Machin
Steven Bethard wrote: > Note that list comprehensions are also C-implemented, AFAIK. Rather strange meaning attached to "C-implemented". The implementation generates the code that would have been generated had you written out the loop yourself, with a speed boost (compared with the fastest DIY ap

Re: read numbers from file and covert to integer

2005-01-09 Thread beliavsky
If you have a file "ints.txt" with contents 10 20 30 40 50 60 You could read integers into a list with ivec = [] for text in open("ints.txt","r"): words = text.split() for x in words: ivec.append(int(x)) print ivec If you know you want to read two integers into variables a,b from a line you cou

Re: time module precision

2005-01-09 Thread Bengt Richter
On 9 Jan 2005 03:09:27 -0800, [EMAIL PROTECTED] wrote: [...] > >What I want to do is waiting(not busy-delaying) for a few tens to >hundreds of microseconds in some threads. The closet solution I got is >using windows QueryPerformanceCounter (in Python, time.clock) with busy >looping checking if we

Re: pyparsing: how to negate a grammar

2005-01-09 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi Paul, > > I am trying to extract HTTP response codes from a HTTP page send from > a web server. Below is my test program. The program just hangs. > > Thanks, > Khoa > ## > > Khoa - T

Re: use a file as a database, access rights

2005-01-09 Thread Steve Holden
Kartic wrote: Steve Holden wrote: Sounds to me like you need to add a rights layer to gadfly. Aha...I did not consider that possibility. I have not gone indepth into Gadfly...is that a straigtforward thing to implement? Gadfly has been a very straightforwad installation for me. Of course the com

Re: else condition in list comprehension

2005-01-09 Thread Dan Bishop
Luis M. Gonzalez wrote: > Hi there, > > I'd like to know if there is a way to add and else condition into a > list comprehension. I'm sure that I read somewhere an easy way to do > it, but I forgot it and now I can't find it... > > for example: > z=[i+2 for i in range(10) if i%2==0] > what if I wan

Re: Python serial data aquisition

2005-01-09 Thread Michael Fuhr
[EMAIL PROTECTED] (Flavio codeco coelho) writes: > my hardware represents analog voltages as 12bit numbers. So, according > to the manufacturer, this number will be stored in two bytes like > this; > |-bits(1-8)---| > Byte1: x x x n1 n2 n3 n4 n5 > Byte2: x n6

compiler version mismatch when building ext_modules with MSVC

2005-01-09 Thread Bo Peng
Dear list, I was using autoconf/automake etc to build my python extension. Since distutil seems to be easier, I have switched to this method. However, when I build the module under windows, I am told that compiler version mismatch... I am using msvc 7 and python was build by msvc 6.0. I am not

Python serial data aquisition

2005-01-09 Thread Flavio codeco coelho
Hi, I am using pyserial to acquire data from an A/D converter plugged to my serial port. my hardware represents analog voltages as 12bit numbers. So, according to the manufacturer, this number will be stored in two bytes like this; |-bits(1-8)---| Byte1: x x x n1

Re: Speed revisited

2005-01-09 Thread Andrea Griffini
On 9 Jan 2005 12:39:32 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: >Tip 1: Once you have data in memory, don't move it, move a pointer or >index over the parts you are inspecting. > >Tip 2: Develop an abhorrence of deleting data. I've to admit that I also found strange that deleting the first

Re: Guild of Python consultants?

2005-01-09 Thread Miklós P
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I also know of many people (myself included) who restrict the term > to those who have a deep expertise in one or more areas and who > look for projects where they can be brought in to apply that > expertise, usually by t

Re: Python serial data aquisition

2005-01-09 Thread Steve Holden
Flavio codeco coelho wrote: Hi, I am using pyserial to acquire data from an A/D converter plugged to my serial port. my hardware represents analog voltages as 12bit numbers. So, according to the manufacturer, this number will be stored in two bytes like this; |-bits(1-8)---

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread John Roth
"Andrey Tatarinov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html This is fairly old. Note that the fastest v

RE: interpreter Py_Initialize/Py_Finalize mem leak?

2005-01-09 Thread Delaney, Timothy C (Timothy)
Roman Suzi wrote: > In pure curiosity I tried to compile loop.c from Demo/embed > and started it with 'print 2+2'. It seems, that both 2.3 and 2.4 > pythons have memory leaks in Py_Initialize/Py_Finalize calls. > (That is, interpreter doesn't clean up well after itself). What's your evidence for

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Steven Bethard
Robert Kern wrote: Andrey Tatarinov wrote: anyway list comprehensions are just syntaxic sugar for >>> for var in list: >>> smth = ... >>> res.append(smth) (is that correct?) so there will be no speed gain, while map etc. are C-implemented It depends. Try def square(x): return x*

Re: Old Paranoia Game in Python

2005-01-09 Thread Lucas Raab
Aahz wrote: In article <[EMAIL PROTECTED]>, Lucas Raab <[EMAIL PROTECTED]> wrote: Sean P. Kane wrote: I ported the old (and long since removed) game from the bsd-game pacakge called, Paranoia, based on the old Paranoia role playing game from C to Python as a simple exercise in learning the langu

Re: else condition in list comprehension

2005-01-09 Thread Luis M. Gonzalez
Thank you guys! -- http://mail.python.org/mailman/listinfo/python-list

Re: else condition in list comprehension

2005-01-09 Thread Matteo Dell'Amico
Luis M. Gonzalez wrote: Hi there, I'd like to know if there is a way to add and else condition into a list comprehension. I'm sure that I read somewhere an easy way to do it, but I forgot it and now I can't find it... for example: z=[i+2 for i in range(10) if i%2==0] what if I want i to be "i-2" if

Re: python3: accessing the result of 'if'

2005-01-09 Thread Bengt Richter
On Sat, 08 Jan 2005 18:30:25 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: >Carl Banks wrote: >> Right. But you know that as soon as you add this to simple >> expressions, a bunch of people are going to come here whining about how >> they don't get to use where with if-expressions. So why should

Re: else condition in list comprehension

2005-01-09 Thread Reinhold Birkenfeld
Luis M. Gonzalez wrote: > Hi there, > > I'd like to know if there is a way to add and else condition into a > list comprehension. I'm sure that I read somewhere an easy way to do > it, but I forgot it and now I can't find it... > > for example: > z=[i+2 for i in range(10) if i%2==0] > what if I w

Re: python3: 'where' keyword

2005-01-09 Thread Bengt Richter
On 09 Jan 2005 03:10:15 -0800, Paul Rubin wrote: >Nick Coghlan <[EMAIL PROTECTED]> writes: >> Trying to push it a level further (down to expressions) would, IMO, be >> a lot of effort for something which would hurt readability a lot. > >I think we should just try to do t

Re: windows mem leak

2005-01-09 Thread Roel Schroeven
Peter Hansen wrote: Roel Schroeven wrote: Peter Hansen wrote: How have you proven that it is not *that* program which is at fault?) It would surprise me: even if it consumes much CPU-time, memory and other resources, each instances returns all resources when it exits. I agree with that statement

Re: Speed revisited

2005-01-09 Thread John Machin
Bulba! wrote: > On 8 Jan 2005 18:25:56 -0800, "John Machin" <[EMAIL PROTECTED]> > wrote: > > >Secondly, you are calling cmp() up to THREE times when once is enough. > >Didn't it occur to you that your last elif needed an else to finish it > >off, and the only possible action for the else suite was

else condition in list comprehension

2005-01-09 Thread Luis M. Gonzalez
Hi there, I'd like to know if there is a way to add and else condition into a list comprehension. I'm sure that I read somewhere an easy way to do it, but I forgot it and now I can't find it... for example: z=[i+2 for i in range(10) if i%2==0] what if I want i to be "i-2" if i%2 is not equal to 0

Re: windows mem leak

2005-01-09 Thread Peter Hansen
Roel Schroeven wrote: Peter Hansen wrote: How have you proven that it is not *that* program which is at fault?) It would surprise me: even if it consumes much CPU-time, memory and other resources, each instances returns all resources when it exits. I agree with that statement, but you assume that

Re: unicode support

2005-01-09 Thread Charlton Wilbur
> "xah" == xah <[EMAIL PROTECTED]> writes: xah> python supports unicode in source xah> code by putting a coding declaration as the first line. [...] xah> In perl, support of unicode is very flaky. The language does xah> not support it, [...] All: Xah Lee is trolli

Re: printing line numbers for debugging purpose

2005-01-09 Thread python
Below is a function to get the current line number and file name. /Jean Brouwers - # dashes added to preserve indentation. - - import traceback - - def caller(up=0): - '''Get file name, line number, function name and -source text of the caller's caller as 4-tuple: -(file, li

Re: windows mem leak

2005-01-09 Thread Roel Schroeven
Bob Smith wrote: Peter Hansen wrote: How have you proven that it is not *that* program which is at fault?) It would surprise me: even if it consumes much CPU-time, memory and other resources, each instances returns all resources when it exits. I have not. All I know is that on WinXP, the program

Re: "A Fundamental Turn Toward Concurrency in Software"

2005-01-09 Thread Jorgen Grahn
On 07 Jan 2005 13:48:41 -0800, Paul Rubin <> wrote: > aurora <[EMAIL PROTECTED]> writes: >> Just gone though an article via Slashdot titled "The Free Lunch Is >> Over: A Fundamental Turn Toward Concurrency in Software" >> [http://www.gotw.ca/publications/concurrency-ddj.htm]. It argues that >> the

Re: Speed revisited

2005-01-09 Thread Bulba!
On Sat, 08 Jan 2005 17:57:30 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: >Note that Python lists are implemented basically as arrays, which means >that deleting an item from anywhere but the end of the list is O(n) >because all items in the list must be moved down to fill the hole. Ouch...

Re: windows mem leak

2005-01-09 Thread Peter Hansen
Bob Smith wrote: Peter Hansen wrote: [snip details of Bob's platform] WinXP Home, Service Pack 2, AMD 1400MHz proc, 256MB Ram That's not really much RAM for a WinXP box. Do you have lots of physical memory available before running? (I presume you're using a version of nmap that's compiled for Wind

Re: read numbers from file and covert to integer

2005-01-09 Thread Peter Hansen
Øystein Western wrote: I got a file with a lot blocks of numbers that are strings. I'd like to read all this numbers and convert them to numbers for futher compareation. How can I convert all this numbers to integer? Do I have to put all numbers into a list? It would help immensely if you could p

Re: Speed revisited

2005-01-09 Thread Bulba!
On 8 Jan 2005 18:25:56 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: >> Both versions use local variables, etc. Both have their >> lists initially sorted. Both essentially use a loop with >> conditional for comparison, >> then process the record in the >> same way. > >"process the record in the

Re: Guild of Python consultants?

2005-01-09 Thread Peter Hansen
Miklós P wrote: Hello freelancers out there, Is there such a thing somewhere? Yes, I'm aware of the Python Business Forum. But I mean something specifically for (individual) consultants. By searching on Google, I couldn't find a "virtual guild" of consultants who try to make a living from Python a

Re: Recent infoworld column

2005-01-09 Thread Stephen Waterbury
Roger Binns wrote: You may also find a talk I gave at baypiggies in July 2004 of interest. http://bitpim.org/papers/baypiggies/ It covers the various issues in doing a "real world" Python application, including packaging [etc -- lots of great stuff ...] *Very* nice presentation -- THANKS! Especia

Re: windows mem leak

2005-01-09 Thread Bob Smith
Peter Hansen wrote: Bob Smith wrote: Attached is the code. Run it yourself and see. You too Peter. Be gentle with me, this was my first attempt with threads. Thanks, Bob, and I will, but not before you answer some of my questions. I had good reasons to ask them, one of which is that I don't feel

Re: Python Installation

2005-01-09 Thread Peter Hansen
Steve Holden wrote: Peter Hansen wrote: Simon John wrote: I would say install on one machine, then just copy the C:\Python24 directory, but then you'd have to deal with the missing Registry entries That part is pretty trivial to automate as well. Fredrik Lundh has a useful utility on his web

Re: unicode support

2005-01-09 Thread Matt Garrish
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] # -*- coding: utf-8 -*- # python supports unicode in source code by putting a coding declaration # as the first line. print "look chinese chars: ?" # Note, however, identifiers cannot use unicode chars. # e.g. you cannot define a fu

read numbers from file and covert to integer

2005-01-09 Thread Øystein Western
I got a file with a lot blocks of numbers that are strings. I'd like to read all this numbers and convert them to numbers for futher compareation. How can I convert all this numbers to integer? Do I have to put all numbers into a list? regards frengky -- Organisation nr: 983063349 Frengky, Ol

Dr. Dobb's Python-URL! - weekly Python news and links (Jan 9)

2005-01-09 Thread Josiah Carlson
QOTW: Jim Fulton: "[What's] duck typing?" Andrew Koenig: "That's the Australian pronunciation of 'duct taping'." "I'm thinking that the I-Ching is a vast untapped resource for programming wisdom, plus it makes it funny." -- Mark Carter Nick Coghlan brings up the 'lambdas are going away in 3

Re: Pre/Postconditions with decorators

2005-01-09 Thread Andrew Dalke
Paul Rubin wrote: > [Type checking] should be left on. Leaving it in for development > and turning it off for production is like wearing a parachute > during ground training and taking it off once you're in the air. Why isn't it like practicing the trapeze with a net but going without a net when

Re: Pre/Postconditions with decorators

2005-01-09 Thread George Sakkis
"Stephen Thorne" <[EMAIL PROTECTED]> wrote: > Unresolved Problems: > 1) How do you handle duck types, i.e. a method that accepts StringIO, > cStringIO or any other object that has a .readlines(), .seek() and > .read() method? I think the 'proper' way of checking duck types (among other things) is

SuSE 9.1: updating to python-2.4

2005-01-09 Thread Torsten Mohr
Hi, along with my distribution SuSE 9.1 came python 2.3.3. I'd like to update to 2.4 now, is this an easy thing to do or will lots of installed modules refuse to work then? Is there an easy way to find out what i need to update? Thanks for any hints, Torsten. -- http://mail.python.org/mailma

Re: time module precision

2005-01-09 Thread Tim Peters
[Tim Peters] >> Python's time.sleep() calls the Win32 API Sleep() function on >> Windows. All behavior is inherited from the latter. See MS's docs: >> >> >> [EMAIL PROTECTED] > Oh, after a short research, I

Re: Recent infoworld column

2005-01-09 Thread Roger Binns
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dwarf Electrician wrote: >> from a long time listener... >> >> http://www.infoworld.com/article/04/12/30/01OPstrategic_1.html > > Kudos for Roger Binns! It is a very nice article :-) BitPim like many other projects is a

Re: use a file as a database, access rights

2005-01-09 Thread Torsten Mohr
Hi, sorry for being unclear and thanks for your answers. Yes, i'd like to use a flat-file database AND access rights. One way i thought of would be to handle the access rights in the script that i write. But to let some other module handle it would also be great. If for example i could embed so

Re: Long strings as function parameters

2005-01-09 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > I would like to have functions that operate on long strings, 10-100 MB. > In C I would of course pass a pointer to the string for a quick > function call. What is an efficient way to do this in python? > Cheers, In Python, *every* expression is a pointer. This fact is

Re: Securing a future for anonymous functions in Python

2005-01-09 Thread Anna
Jacek Generowicz wrote: > "Anna" <[EMAIL PROTECTED]> writes: > > > Having taken some calculus (derivatives, limits, some integrals) but > > never even heard of lambda calculus, to me, lambda means absolutely > > NOTHING. Less than nothing. > > And before you took calculus, the chances are that der

Re: Long strings as function parameters

2005-01-09 Thread Irmen de Jong
[EMAIL PROTECTED] wrote: I would like to have functions that operate on long strings, 10-100 MB. In C I would of course pass a pointer to the string for a quick function call. What is an efficient way to do this in python? Err, just pass the string to the function? In Python, all function argument

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Robert Kern
Andrey Tatarinov wrote: Steve Holden wrote: Andrey Tatarinov wrote: Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html > And note that the summary in the conclusiogn BEGINS

Re: Old Paranoia Game in Python

2005-01-09 Thread Aahz
In article <[EMAIL PROTECTED]>, Lucas Raab <[EMAIL PROTECTED]> wrote: >Sean P. Kane wrote: >> >> I ported the old (and long since removed) game from the bsd-game pacakge >> called, Paranoia, based on the old Paranoia role playing game from C to >> Python as a simple exercise in learning the lang

  1   2   >