the usage of 'yield' keyword

2009-10-14 Thread Peng Yu
http://docs.python.org/reference/simple_stmts.html#grammar-token-yield_stmt The explanation of yield is not clear to me, as I don't know what a generator is. I see the following example using 'yield'. Could somebody explain how 'yield' works in this example? Thank you! def brange(limit): i = 0

Re: efficient running median

2009-10-14 Thread sturlamolden
On 14 Okt, 00:03, Steven D'Aprano wrote: > Obviously to run in O(log n) you must have already built the tree. You don't need a tree. Quickselect is a partial quicksort. But my memory served me badly, quickselect is O(n). -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-14 Thread TerryP
Mensanator, thank goodness that was generated :-P -- http://mail.python.org/mailman/listinfo/python-list

Re: efficient running median

2009-10-14 Thread Janto Dreijer
On Oct 13, 6:33 pm, Paul Rubin wrote: > Janto Dreijer writes: > > I'm looking for code that will calculate the running median of a > > sequence, efficiently. (I'm trying to subtract the running median from > > a signal to correct for gradual drift). > > Is that a kno

Re: efficient running median

2009-10-14 Thread Janto Dreijer
On Oct 13, 7:37 pm, Ethan Furman wrote: > Janto Dreijer wrote: > > I'm looking for code that will calculate the running median of a > > sequence, efficiently. (I'm trying to subtract the running median from > > a signal to correct for gradual drift). > > > My naive attempt (taking the median of a

Re: efficient running median

2009-10-14 Thread Janto Dreijer
On Oct 14, 12:13 am, Paul Rubin wrote: > Janto Dreijer writes: > > Well, I don't have a lot of theoretical reasoning behind wanting to > > use a median filter. I have some experience applying it to images with > > very good results, so that was the first thing I trie

Re: the usage of 'yield' keyword

2009-10-14 Thread Javier Collado
Hello, I think that the best information available on the subject is the following: http://www.dabeaz.com/generators/ http://www.dabeaz.com/coroutines/ Best regards, Javier 2009/10/14 Peng Yu : > http://docs.python.org/reference/simple_stmts.html#grammar-token-yield_stmt > > The explanation

Re: MUD Game Programmming - Python Modules in C++

2009-10-14 Thread Ulrich Eckhardt
Irmen de Jong wrote: > [...] is there any reason why you would go the route of embedding python > in C++ ? Why not just stick to (pure) Python? Embedding C or C++ stuff > as extension modules in Python (if you really need to do this) is easier > than the other way around, in my experience. If you

Re: MUD Game Programmming - Python Modules in C++

2009-10-14 Thread Ulrich Eckhardt
Christopher Lloyd wrote: > I'm a relatively inexperienced programmer, and have been learning some > basic C++ and working through the demos in Ron Penton's "MUD Game > Programming" book. In it, Python modules are run from inside a C++ > program. [...] > If I try to compile this in MS Visual C++ 200

Re: MUD Game Programmming - Python Modules in C++

2009-10-14 Thread Ulrich Eckhardt
Gabriel Genellina wrote: >> #ifdef _DEBUG >> #undef _DEBUG >> #include >> #define _DEBUG >> #else >> #include >> #endif [...to keep Python from linking against non-existant debug libraries.] > > No, don't do that. Just compile your application in release mode. Why not, does it break anything?

win32com.client import problem

2009-10-14 Thread Threader Slash
Hi Everybody, I have 2 imports: import pythoncom from win32com.client import Dispatch if I run it on my Python 2.6 Console, it works nicely. However, when I go to Eclipse IDE, open a project, open a main.py file, and try run, it gives the error: import pythoncom ImportError: No module named pyt

Re: The rap against "while True:" loops

2009-10-14 Thread Marco Mariani
Dennis Lee Bieber wrote: One thing to note is that "break" ONLY exits the innermost loop -- Ada adds the confusion that one could define a label on the loops, and have the innermost use exit outer_label [when condition] THAT I find scary... Since you have to match the l

Re: for loop: range() result has too many items

2009-10-14 Thread Mark Dickinson
On Oct 13, 10:39 pm, Steven D'Aprano wrote: > On Tue, 13 Oct 2009 16:17:58 -0500, Peng Yu wrote: > > Hi, > > > The following code does not run because range() does not accept a big > > number. > > Incorrect. > > >>> range(sys.maxint+2, sys.maxint+5) > > [2147483649L, 2147483650L, 2147483651L] For

Re: python along or bash combined with python (for manipulating files)

2009-10-14 Thread Jean-Michel Pichavant
Peng Yu wrote: Bash is easy to use +JOTW :) JM -- http://mail.python.org/mailman/listinfo/python-list

Invitation to connect on LinkedIn

2009-10-14 Thread Frank Pan
LinkedIn Frank Pan requested to add you as a connection on LinkedIn: -- Jaime, I'd like to add you to my professional network on LinkedIn. - Frank Accept invitation from Frank Pan http://www.linkedin.com/e/I2LlXdLlWUhFABKmxVOlgGLlWUhFAfhMPPF

Re: the usage of 'yield' keyword

2009-10-14 Thread Stephen Fairchild
Peng Yu wrote: > http://docs.python.org/reference/simple_stmts.html#grammar-token-yield_stmt > > The explanation of yield is not clear to me, as I don't know what a > generator is. I see the following example using 'yield'. Could > somebody explain how 'yield' works in this example? Thank you! >

Re: Poll on Eval in Python

2009-10-14 Thread Kazimir Majorinc
THE RESULTS OF THE POLLS . Lisp Python Ruby Eval is evil, harmful or at least unnecessary 2 (4.9%) 7 (21.9%) 0 (0.0%) -- Eval is useful but ov

Re: Writing to function arguments during execution

2009-10-14 Thread Dave Angel
John O'Hagan wrote: Thanks, sockets are the way to go for this and surprisingly easy to use once you get your head around them. I tried Rhodri's suggested approach but for now I used the original terminal for both starting the program and entering new options (still via raw_input) and a new t

id( ) function question

2009-10-14 Thread raffaele ponzini
Dear all, I have a question concerning the output of the id() function. In particular since is should: "" Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (Hint: it's the object's memory address.) "" i expect that for two differnt objects it

shelve, segfault and bsddb.db.DBPageNotFoundError: (-30987, 'DB_PAGE_NOTFOUND: Requested page not found')

2009-10-14 Thread Gabriel Rossetti
Hello everyone, I get the following error with the shelve module (python 2.5.2) sometimes : >>> s = shelve.open("save.dat", writeback=True) >>> s Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/UserDict.py", line 167, in __repr__ return repr(dict(self.iterit

id( ) function question

2009-10-14 Thread raffaele ponzini
Dear all, I have a question concerning the output of the id() function. In particular since is should: "" Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (Hint: it's the object's memory address.) "" i expect that for two differnt objects it

Re: the usage of 'yield' keyword

2009-10-14 Thread Dave Angel
Peng Yu wrote: http://docs.python.org/reference/simple_stmts.html#grammar-token-yield_stmt The explanation of yield is not clear to me, as I don't know what a generator is. I see the following example using 'yield'. Could somebody explain how 'yield' works in this example? Thank you! def brange

Re: win32com.client import problem

2009-10-14 Thread Dave Angel
Threader Slash wrote: Hi Everybody, I have 2 imports: import pythoncom from win32com.client import Dispatch if I run it on my Python 2.6 Console, it works nicely. However, when I go to Eclipse IDE, open a project, open a main.py file, and try run, it gives the error: import pythoncom ImportEr

Re: python performance on Solaris

2009-10-14 Thread Antoine Pitrou
inaf gmail.com> writes: > > Good point. I failed to compare the CPU power on these machines.. 32 > bit linux box I have is 2666 Mhz vs the Solaris zone is 1415 Mhz.. I > guess that explains :) Thank you for the tip.. You have to compare not only CPU frequencies but the CPU models. Recently Sun h

Re: id( ) function question

2009-10-14 Thread Christian Heimes
raffaele ponzini schrieb: > Dear all, > I have a question concerning the output of the id() function. > In particular since is should: > "" > Return the identity of an object. This is guaranteed to be unique among > simultaneously existing objects. (Hint: it's the object's memory address.) > "" >

Re: id( ) function question

2009-10-14 Thread Andre Engels
What is going on is that a few objects that are often used, in particular the small (how small is small depends on the implementation) integers, are 'preloaded'. When one of these is then referred to, a new object is not created, but the pre-defined object is used. 10 is apparently a preloaded cons

Re: id( ) function question

2009-10-14 Thread Tim Chase
But if I chose as a value another number (a big one, let say 1e10) I get what I will expect also in the case of the chose of the integer 10 showed above: a=1e10 d=1e10 d is a False id(a) 11388984 id(d) 11388920 CPython has the option to cache frequently used items, and does so for a small

Re: id( ) function question

2009-10-14 Thread Christian Heimes
Andre Engels schrieb: > What is going on is that a few objects that are often used, in > particular the small (how small is small depends on the > implementation) integers, are 'preloaded'. When one of these is then > referred to, a new object is not created, but the pre-defined object > is used. 1

Unexpected exit of Python script

2009-10-14 Thread vicky
Hello All, I am a new Python user and don't know much about it. I just want to know that, due to any reason if a script exits, is their some way to release all the resources acquired by the script during execution ? Actually In my system I want to execute some piece of code at the time of script

Clear interface for mail class

2009-10-14 Thread Benedict Verheyen
Hi, I'm trying to come up with a decent interface for my email class. Basically, i have one email function but it has many (too many?) variables: send_mail(self, send_from, send_to, send_cc, subject, text, separate_emails = False, files=[], inline_files=[], server="localhost", charset="iso-

Re: Clear interface for mail class

2009-10-14 Thread Marco Mariani
Benedict Verheyen wrote: Any ideas are welcome. easy_install turbomail :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected exit of Python script

2009-10-14 Thread Diez B. Roggisch
vicky wrote: > Hello All, > > I am a new Python user and don't know much about it. > > I just want to know that, due to any reason if a script exits, is > their some way to release all the resources acquired by the script > during execution ? > > Actually In my system I want to execute some pie

Re: Multi-arrays python

2009-10-14 Thread Piet van Oostrum
> [email protected] (b) wrote: >b> Hi again! >b> After testing the whole day, I have got my goals from the last email, but >b> as always, another issues came up! and now that Ive been able to save a >b> list of list (or multi-arrays) as below : >b> ['100.mp3\n' '10008.mp3\n' '10005.mp3

Python and USB

2009-10-14 Thread Ronn Ross
I'm new to Python and would like to capture mouse movements. I envision writing a script that will just write out the mouse movements in the term. Is this possible? Can someone point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected exit of Python script

2009-10-14 Thread Donn
On Wednesday 14 October 2009 14:23:11 vicky wrote: > I just want to know that, due to any reason if a script exits, is > their some way to release all the resources acquired by the script > during execution ? Python cleans-up after itself so I would not worry about that until you are an expert and

Re: Unexpected exit of Python script

2009-10-14 Thread Mick Krippendorf
vicky schrieb: > Actually In my system I want to execute some piece of code at the time > of script exit (expected or unexpected) to ensure the release of all > the resources. I don't know how to do that :( You maybe want to use a context manager. Look for 'with statement' and 'contextlib' in your

Re: cpython compilation parameter

2009-10-14 Thread Jorgen Grahn
On Thu, 2009-10-08, Diez B. Roggisch wrote: > cEd wrote: > >> Hello, >> >> I'm wondering how to compile python to get good performance. >> Because when I compare this ugly code which find prime number: ... >> between : >> - the python distributed with my ubuntu >> #time python prime_number.py

Re: Clear interface for mail class

2009-10-14 Thread Benedict Verheyen
Marco Mariani wrote: > Benedict Verheyen wrote: > >> Any ideas are welcome. > > easy_install turbomail > > :) > Looks good but i'm still interested in how one would make a clean class interface for this type of problem. Having said that, turbomail looks quite good :) Thanks -- http://mail.

Re: Unexpected exit of Python script

2009-10-14 Thread vicky
On Oct 14, 5:52 pm, "Diez B. Roggisch" wrote: > vicky wrote: > > Hello All, > > > I am a new Python user and don't know much about it. > > > I just want to know that, due to any reason if a script exits, is > > their some way to release all the resources acquired by the script > > during execution

Re: python performance on Solaris

2009-10-14 Thread Jorgen Grahn
On Wed, 2009-10-14, Antoine Pitrou wrote: > inaf gmail.com> writes: >> >> Good point. I failed to compare the CPU power on these machines.. 32 >> bit linux box I have is 2666 Mhz vs the Solaris zone is 1415 Mhz.. I >> guess that explains :) Thank you for the tip.. > > You have to compare not only

Re: Unexpected exit of Python script

2009-10-14 Thread Diez B. Roggisch
vicky wrote: > On Oct 14, 5:52 pm, "Diez B. Roggisch" wrote: >> vicky wrote: >> > Hello All, >> >> > I am a new Python user and don't know much about it. >> >> > I just want to know that, due to any reason if a script exits, is >> > their some way to release all the resources acquired by the scri

Re: Clear interface for mail class

2009-10-14 Thread Joe Riopel
On Wed, Oct 14, 2009 at 8:39 AM, Benedict Verheyen wrote: > This kind of problems seems to happen sometimes: i need to fix something > quickly, > build a script for it, and then i realise that the code i've written is not > the best in > terms of reusability and has some "not so great" functions

Re: MUD Game Programmming - Python Modules in C++

2009-10-14 Thread Gabriel Genellina
En Wed, 14 Oct 2009 05:19:06 -0300, Ulrich Eckhardt escribió: Gabriel Genellina wrote: #ifdef _DEBUG #undef _DEBUG #include #define _DEBUG #else #include #endif [...to keep Python from linking against non-existant debug libraries.] No, don't do that. Just compile your application in relea

Re: What is Islam?-1

2009-10-14 Thread Aahz
In article , J wrote: >On Tue, Oct 13, 2009 at 20:05, Aahz wrote: Mensanator: > >There's no point in trying to reason with a Muslim. That's not funny, and if you were being serious, that was incredibly rude. >>> >>>Not as much as posting in comp.lang.python. >> >> What

Pyusb

2009-10-14 Thread Ronn Ross
I'm running Python 2.6 on windows. I'm install Pyusb and I'm having trouble including the library in my script. Can someone point me in the right direction to get this working or know of a good tutorial to help me out. Best regards -- http://mail.python.org/mailman/listinfo/python-list

Help with regex and optional substring in search string

2009-10-14 Thread Timur Tabi
I'm having trouble creating a regex pattern that matches a string that has an optional substring in it. What I'm looking for is a pattern that matches both of these strings: Subject: [PATCH 08/18] This is the patch name Subject: This is the patch name What I want is to extract the "This is the p

Re: efficient running median

2009-10-14 Thread Peter Otten
Janto Dreijer wrote: > On Oct 13, 6:12 pm, Peter Otten <[email protected]> wrote: >> Janto Dreijer wrote: >> > I'm looking for code that will calculate the running median of a >> > sequence, efficiently. (I'm trying to subtract the running median from >> > a signal to correct for gradual drift). >>

Re: Clear interface for mail class

2009-10-14 Thread Francesco Bochicchio
On Oct 14, 2:39 pm, Benedict Verheyen wrote: > Hi, > > I'm trying to come up with a decent interface for my email class. > Basically, i have one email function but it has many (too many?) variables: > >     send_mail(self, send_from, send_to, send_cc, subject, text, > separate_emails = False, fil

Re: Help with regex and optional substring in search string

2009-10-14 Thread Timur Tabi
On Oct 14, 9:51 am, Timur Tabi wrote: > I'm having trouble creating a regex pattern that matches a string that > has an optional substring in it.  What I'm looking for is a pattern > that matches both of these strings: > > Subject: [PATCH 08/18] This is the patch name > Subject: This is the patch

Re: Python and USB

2009-10-14 Thread Gabriel Genellina
En Wed, 14 Oct 2009 09:55:15 -0300, Ronn Ross escribió: I'm new to Python and would like to capture mouse movements. I envision writing a script that will just write out the mouse movements in the term. Is this possible? Can someone point me in the right direction? Capture mouse movement

Re: Help with regex and optional substring in search string

2009-10-14 Thread Zero Piraeus
: 2009/10/14 Timur Tabi : > I'm having trouble creating a regex pattern that matches a string that > has an optional substring in it.  What I'm looking for is a pattern > that matches both of these strings: > > Subject: [PATCH 08/18] This is the patch name > Subject: This is the patch name > > Wha

Re: Help with regex and optional substring in search string

2009-10-14 Thread Zero Piraeus
: 2009/10/14 Timur Tabi : > Never mind ... I figured it out.  The middle block should have been [\w > \s/]* This is fragile - you'll have to keep adding extra characters to match if the input turns out to contain them. -[]z. -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-14 Thread Tim Rowe
2009/10/14 Marco Mariani : > Dennis Lee Bieber wrote: > >>        One thing to note is that "break" ONLY exits the innermost loop -- >> Ada adds the confusion that one could define a label on the loops, and >> have the innermost use >>        exit outer_label [when condition] >> >> >>        THAT I

Re: ANN: Testoob 1.15 released

2009-10-14 Thread Jorgen Grahn
On Thu, 2009-10-08, oripel wrote: > Testoob is the advanced Python test runner and testing framework that > spices up any existing unittest test suite. > > Home: http://code.google.com/p/testoob But this sentence on the home page The documentation is sadly outdated, but may be a starting

Re: Are there any modules for IRC, that work with Python 3.1?

2009-10-14 Thread Jorgen Grahn
On Sat, 2009-10-10, TerryP wrote: > Does anyone know of any modules for dealing with the IRC protocol, > that will work with Python 3.1? It doens't have to be super great, > just less time consuming then playing with sockets directly (and obv. > stable). The only module in my systems package manage

Re: The rap against "while True:" loops

2009-10-14 Thread TerryP
When all is said and done, is not all looping *basically* equivalent to something like this? begin_loop: unless TEST goto end_loop ;; loop body here if TEST goto begin_loop end_loop: Which could likely be used to implement something like: while TEST: # loop body

Re: The rap against "while True:" loops

2009-10-14 Thread Mensanator
On Oct 14, 2:19�am, Dennis Lee Bieber wrote: > On Tue, 13 Oct 2009 15:02:09 -0700 (PDT), Mensanator > declaimed the following in > gmane.comp.python.general: > > > You're not getting away that easy. > > > What's YOUR opinion of "whilr True"? > > � � � � Uhm... that it isn't valid in any language

Pyusb

2009-10-14 Thread Ronn Ross
Does anyone know where I can download a copy of PyUSB 1.0? I can only find 0.x versions on sourceforge. I'm following a tutorial that requires 1.0. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Why is python so sad?

2009-10-14 Thread Zac Burns
There are 10741 occurences of ): or :( in our source code and only 2 occurrences of :) or (:. Not what you would expect from a language named after a comedian. -- Zachary Burns (407)590-4814 Aim - Zac256FL Production Engineer (Digital Overlord) Zindagi Games -- http://mail.python.org/mailman/list

Re: The rap against "while True:" loops

2009-10-14 Thread MRAB
Dennis Lee Bieber wrote: On Tue, 13 Oct 2009 15:02:09 -0700 (PDT), Mensanator declaimed the following in gmane.comp.python.general: You're not getting away that easy. What's YOUR opinion of "whilr True"? Uhm... that it isn't valid in any language having English influence upon it's k

Re: XML-RPC(using SimpleXMLRPCServer) slow on the first call

2009-10-14 Thread Mahi Haile
-- Forwarded message -- > From: "Gabriel Genellina" > To: [email protected] > Date: Wed, 14 Oct 2009 00:52:13 -0300 > Subject: Re: XML-RPC(using SimpleXMLRPCServer) slow on the first call > En Mon, 12 Oct 2009 18:58:45 -0300, Mahi Haile > escribió: > > Hello all,I have an xm

Re: Why is python so sad?

2009-10-14 Thread Chris Withers
Zac Burns wrote: There are 10741 occurences of ): or :( in our source code and only 2 occurrences of :) or (:. Not what you would expect from a language named after a comedian. def ...(...): ... class ...(...): ... etc ;-) Chris -- Simplistix - Content Management, Batch Processing & Py

Re: Pyusb

2009-10-14 Thread Chris Withers
Ronn Ross wrote: Does anyone know where I can download a copy of PyUSB 1.0? I can only find 0.x versions on sourceforge. I'm following a tutorial that requires 1.0. Thanks Googling "pyusb" gives me loads of hits and the newer versions appear to be on about the 3rd link down... Chris -- Sim

Re: RotatingFileHandler issue

2009-10-14 Thread Max Lynch
I never got a response back from this, but I'm noticing even more odd behavior, see inline: On Wed, Sep 30, 2009 at 4:38 PM, Max Lynch wrote: > Hi. > I have a RotatingFileHandler for my logging system. I have it set to > rotate once the file becomes 5MB in size. Here is the conf line I have in

Re: The rap against "while True:" loops

2009-10-14 Thread Tim Rowe
2009/10/14 Dennis Lee Bieber : >        If anything -- I'd suggest a proposal to add a plain    loop    as a > keyword in Python, whose effect is equivalent to a "while True", but a > break    must be used to exit said loop (well, we'll ignore raising an > exception ) And with enough static analy

Re: python along or bash combined with python (for manipulating files)

2009-10-14 Thread edexter
On Oct 14, 3:42 am, Jean-Michel Pichavant wrote: > Peng Yu wrote: > > Bash is easy to use > > +JOTW > > :) > > JM why choose.. http://shython.sourceforge.net/ I don't think this is the most recent I would also try the package index -- http://mail.python.org/mailman/listinfo/python-list

Re: python along or bash combined with python (for manipulating files)

2009-10-14 Thread Falcolas
On Oct 13, 10:18 pm, TerryP wrote: > On Oct 14, 2:13 am, Peng Yu wrote: > > > Bash is easy to use on manipulating files and directories (like change > > name or create links, etc) and on calling external programs. For > > simple functions, bash along is enough. However, bash does not support > >

Re: Parsing email attachments: get_payload() produces unsaveable data

2009-10-14 Thread dpapathanasiou
On Oct 4, 10:27 am, dpapathanasiou wrote: > I'm using python to access an email account via POP, then for each > incoming message, save any attachments. > > This is the function which scans the message for attachments: > > def save_attachments (local_folder, msg_text): >     """Scan the email mess

Re: The rap against "while True:" loops

2009-10-14 Thread Ethan Furman
Mensanator wrote: On Oct 14, 2:19�am, Dennis Lee Bieber wrote: On Tue, 13 Oct 2009 15:02:09 -0700 (PDT), Mensanator declaimed the following in gmane.comp.python.general: You're not getting away that easy. What's YOUR opinion of "whilr True"? � � � � Uhm... that it isn't valid in any l

win32com.client import problem : solved

2009-10-14 Thread Threader Slash
-- Forwarded message -- From: Dave Angel To: Threader Slash Date: Wed, 14 Oct 2009 07:04:21 -0400 Subject: Re: win32com.client import problem Threader Slash wrote: > Hi Everybody, > > I have 2 imports: > > import pythoncom > from win32com.client import Dispatch > > if I run it on

Re: Why is python so sad?

2009-10-14 Thread Dotan Cohen
> ;-) > Be careful, that looks dangerously close to PHP: function(); -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is python so sad?

2009-10-14 Thread James Matthews
This posting just made my day! On Wed, Oct 14, 2009 at 2:59 PM, Dotan Cohen wrote: > > ;-) > > > > Be careful, that looks dangerously close to PHP: > function(); > > > -- > Dotan Cohen > > http://what-is-what.com > http://gibberish.co.il > -- > http://mail.python.org/mailman/listinfo/python-list

Re: python performance on Solaris

2009-10-14 Thread James Matthews
I use python in almost the same environment. I use it on Joyent and on the Rackspace cloud. Joyent is faster for a few reasons (cpu bursting and faster disks) but these aren't real benchmarks until they are on the same machines. James On Wed, Oct 14, 2009 at 9:59 AM, Jorgen Grahn > wrote: > On

Re: The rap against "while True:" loops

2009-10-14 Thread Jorgen Grahn
On Mon, 2009-10-12, RDrewD wrote: ... > I was a bit surprised that nobody in this discussion so far bantered > around the phrase "loop invariant", but then I looked in > http://en.wikipedia.org/wiki/Loop_invariant and found it was draped in > so much formalism that it's sure to put off all but the

Re: The rap against "while True:" loops

2009-10-14 Thread Jorgen Grahn
On Mon, 2009-10-12, Grant Edwards wrote: > On 2009-10-12, Gabriel Genellina wrote: > >>> my_prissy_little_indicator_variable = true >>> while (my_prissy_little_indicator_variable){ >>> >>> } >>> isn't satisfying because it doesn't guard the with any >>> assurance that the loop invariant will

where's self.assertMatch (for Django)?

2009-10-14 Thread Phlip
Hypo Nt: Been a while, now I'm back, and the first helpless question is... When I google (including codesearch) for assertMatch, I get a mishmash of opinions. Am I missing the One True assertMatch(), or isn't there one and I gotta write it? or copy and use one of the pretenders? Distractingl

how to handle broken pipes

2009-10-14 Thread Igor Mikushkin
Hello all! Could anyone please say me what is the right way to handle broken pipes in Python? I can wrap all my print statements with try/except blocks but it looks like overkill for me. I'm using my Python script this way: my_script | less The script produces a lot of data. So usually when I fin

Re: The rap against "while True:" loops

2009-10-14 Thread Jorgen Grahn
On Wed, 2009-10-14, Marco Mariani wrote: > Dennis Lee Bieber wrote: > >> One thing to note is that "break" ONLY exits the innermost loop -- >> Ada adds the confusion that one could define a label on the loops, and >> have the innermost use >> exit outer_label [when condition] >> >> >>

Re: The rap against "while True:" loops

2009-10-14 Thread Raymond Hettinger
> And I know somebody, in other languages, thinks > it's a Best Practice to avoid using exceptions for flow control. Ah, now we have two code prions in just one thread. I hope no newbie or supervisor reads this thread and latches on to those two counter-productive ideas. ISTM, both ideas are dang

Re: how to handle broken pipes

2009-10-14 Thread Jorgen Grahn
On Wed, 2009-10-14, Igor Mikushkin wrote: > Hello all! > > Could anyone please say me what is the right way to handle broken > pipes in Python? > I can wrap all my print statements with try/except blocks but it looks > like overkill for me. > > I'm using my Python script this way: my_script | less

Re: The rap against "while True:" loops

2009-10-14 Thread Paul Rubin
Raymond Hettinger writes: > IIRC, the C++ admonition against using exceptions for flow control > was rooted in performance concerns specific to that language and > its compilers. It was not stylistic advice and did not deny that > flow control exceptions could provide elegant solutions to some >

Looking for programmer experienced in Python/Django/Git/Unix

2009-10-14 Thread TMChris
Hi everyone, We're looking for an expert in Python, Django, Git and Unix. We have multiple projects needed paid on hourly basis. Do you have a strong confidence in all of these? If so, please provide a resume and a little bit about yourself in regards to these. Thank you, Chris -- http://mail.

Re: python performance on Solaris

2009-10-14 Thread inaf
On Oct 14, 7:15 am, Antoine Pitrou wrote: > inaf gmail.com> writes: > > > > > Good point. I failed to compare the CPU power on these machines.. 32 > > bit linux box I have is 2666 Mhz vs the Solaris zone is 1415 Mhz.. I > > guess that explains :) Thank you for the tip.. > > You have to compare no

Re: windows side-by-side configuration woes on windows HPC

2009-10-14 Thread Nick Touran
I've made enough progress to get my setup working! I attempted to apply the patch and recompile the packages that complained but got in too deep while compiling matplotlib on windows (I don't have admin privileges and can't install the prereqs) so I dug deeper. I found this: http://blog.kalmbachne

Re: Poll on Eval in Python

2009-10-14 Thread Kazimir Majorinc
On 14.10.2009 17:55, TerryP wrote: And what about exec? (note: exec in python is more in spirit of eval then C-style exec functions) I thought about that, but decided not to ask about it in poll, because I wanted to compare opinions on eval specifically, not on all similar features. Do you t

Re: efficient running median

2009-10-14 Thread Janto Dreijer
On Oct 14, 4:53 pm, Peter Otten <[email protected]> wrote: > Some numbers: > > 10.197 seconds for running_median_scipy_medfilt > 25.043 seconds for running_median_python > 13.040 seconds for running_median_python_msort > 14.280 seconds for running_median_python_scipy_median > 4.024 seconds for runni

Re: Help with regex and optional substring in search string

2009-10-14 Thread Timur Tabi
On Wed, Oct 14, 2009 at 10:30 AM, Zero Piraeus wrote: > '(?:etc)' instead of '(etc)' are non-grouping parentheses (since you > apparently don't care about that bit). Ah yes, thanks. > '[^\]]' instead of '[\w\s]' matches "everything except a closing bracket". I originally had just '[^\]', and I

Re: Poll on Eval in Python

2009-10-14 Thread TerryP
On Oct 14, 9:48 pm, Kazimir Majorinc wrote: > Do you think > it would be better if I asked that? That result would > be significantly different? > Not really. The eval, exec, and compile builtins are more or less related and serve similar purposes, but don't seem to be highly used in Python. Ther

Re: The rap against "while True:" loops

2009-10-14 Thread Jack Norton
kj wrote: I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with "while True". Of course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the con

Re: The rap against "while True:" loops

2009-10-14 Thread Tim Rowe
2009/10/12 RDrewD : > I was a bit surprised that nobody in this discussion so far bantered > around the phrase "loop invariant", but then I looked in > http://en.wikipedia.org/wiki/Loop_invariant and found it was draped in > so much formalism that it's sure to put off all but the most dedicated > o

Re: efficient running median

2009-10-14 Thread Ethan Furman
Janto Dreijer wrote: On Oct 13, 7:37 pm, Ethan Furman wrote: Janto Dreijer wrote: I'm looking for code that will calculate the running median of a sequence, efficiently. (I'm trying to subtract the running median from a signal to correct for gradual drift). My naive attempt (taking the me

Re: The rap against "while True:" loops

2009-10-14 Thread Rhodri James
On Wed, 14 Oct 2009 02:26:17 +0100, Mensanator wrote: On Oct 13, 5:38�pm, "Rhodri James" wrote: On Tue, 13 Oct 2009 22:59:04 +0100, Mensanator wrote: > And I'm not saying John nor the OP should stop > using what works for them. But there are certainly > valid reasons for "don't use while T

Re: id( ) function question

2009-10-14 Thread Laszlo Nagy
Andre Engels schrieb: What is going on is that a few objects that are often used, in particular the small (how small is small depends on the implementation) integers, are 'preloaded'. When one of these is then referred to, a new object is not created, but the pre-defined object is used. 10 i

Re: The rap against "while True:" loops

2009-10-14 Thread Steven D'Aprano
On Wed, 14 Oct 2009 09:34:28 -0700, Mensanator wrote: > On Oct 14, 2:19�am, Dennis Lee Bieber wrote: >> On Tue, 13 Oct 2009 15:02:09 -0700 (PDT), Mensanator >> declaimed the following in >> gmane.comp.python.general: >> >> > You're not getting away that easy. >> >> > What's YOUR opinion of "whil

Re: The rap against "while True:" loops

2009-10-14 Thread Steven D'Aprano
On Wed, 14 Oct 2009 18:30:06 +0100, Tim Rowe wrote: > 2009/10/14 Dennis Lee Bieber : > >>        If anything -- I'd suggest a proposal to add a plain    loop >>           as a >> keyword in Python, whose effect is equivalent to a "while True", but a >> break    must be used to exit said loop (wel

Re: The rap against "while True:" loops

2009-10-14 Thread Steven D'Aprano
On Wed, 14 Oct 2009 20:17:40 +, Jorgen Grahn wrote: >> But we have exceptions. And I know somebody, in other languages, thinks >> it's a Best Practice to avoid using exceptions for flow control. > > A lot of C++ programmers think so, and Stroustrup himself says > "exceptions are for exception

Re: id( ) function question

2009-10-14 Thread Chris Rebert
On Wed, Oct 14, 2009 at 1:37 PM, Laszlo Nagy wrote: >> Andre Engels schrieb: >>> What is going on is that a few objects that are often used, in >>> particular the small (how small is small depends on the >>> implementation) integers, are 'preloaded'. When one of these is then >>> referred to, a ne

Re: id( ) function question

2009-10-14 Thread Stephen Hansen
On Wed, Oct 14, 2009 at 1:37 PM, Laszlo Nagy wrote: > > Andre Engels schrieb: >> >>> >>> None, True, False, NotImplemented are guaranteed to be singletons, all >> builtin types and exceptions can be considered as singletons, too. >> >> > I thought that different mutable objects always have differ

Re: id( ) function question

2009-10-14 Thread Christian Heimes
Chris Rebert wrote: > The built-ins aren't mutable, and the singletons are each immutable > and/or unique; so in no case do objects that are both different and > mutable have the same ID. Correct, the fact allows you to write code like "type(egg) is str" to check if an object *is* an instance of s

Re: id( ) function question

2009-10-14 Thread Stephen Hansen
On Wed, Oct 14, 2009 at 4:19 PM, Chris Rebert wrote: > Although I have no idea how it is that `id({}) == id({})` as a prior > posted showed; FWIW, I can't manage to reproduce that outcome. > With Python 2.5.1 on MacOS X, I can; it looks like there's an optimization in there where its 'saving' di

  1   2   >