python-dev Summary for 2005-03-16 through 2005-03-31 (my last)

2005-04-02 Thread Brett C.
[The HTML version of this Summary is available at http://www.python.org/dev/summary/2005-03-16_2005-03-31.html] = Summary Announcements = --- My last summary --- So, after nearly 2.5 years, this is my final python-dev Summary. Ste

Re: Docorator Disected

2005-04-02 Thread Bengt Richter
On Sun, 03 Apr 2005 05:09:07 GMT, Ron_Adam <[EMAIL PROTECTED]> wrote: >On 2 Apr 2005 20:02:47 -0800, "El Pitonero" <[EMAIL PROTECTED]> >wrote: > >>Ron_Adam wrote: >>> >>> So I didn't know I could do this: >>> >>> def foo(a1): >>> def fee(a2): >>> return a1+a2 >>> return fee >>> >>>

Re: Finding attributes in a list

2005-04-02 Thread Bengt Richter
On Sat, 2 Apr 2005 23:44:11 -0500, Marcus Goldfish <[EMAIL PROTECTED]> wrote: >> class Player(object): >>def __init__(self, **kw): self.__dict__.update(kw) >>def __repr__(self): return ''%getattr(self, 'name', >> '(anonymous)') >> >> import operator >> [p.name for p in sorted(players, key

threading.Event file descriptor

2005-04-02 Thread Nicolas Fleury
Hi, Is there any way to get the file descriptor on Unix or handle on Windows associated internally with a threading.Event object? So that it can be used in a call to select or WaitForMultipleObjects. Thx and regards, Nicolas -- http://mail.python.org/mailman/listinfo/python-list

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Terry Reedy
"Brian van den Broek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > I'm just starting to employ unit testing (I'm using doctest), and I am > uncertain how to handle writing tests where the behaviour being tested is > dependant on whether certain file paths point to ac

Re: Docorator Disected

2005-04-02 Thread "Martin v. Löwis"
Ron_Adam wrote: Ah, so you did not know functions are objects just like numbers, strings or dictionaries. I think you may have been influenced by other languages where there is a concept of static declaration of functions. No, I did not know that you could pass multiple sets of arguments to nested

Re: Lambda: the Ultimate Design Flaw

2005-04-02 Thread alex goldman
Artie Gold wrote: > Torsten Bronger wrote: >> Hallöchen! >> >> Daniel Silva <[EMAIL PROTECTED]> writes: >> >> >>>Shriram Krishnamurthi has just announced the following elsewhere; it >>>might be of interest to c.l.s, c.l.f, and c.l.p: >>>http://list.cs.brown.edu/pipermail/plt-scheme/2005-April/0

Re: Decorator Dissection

2005-04-02 Thread "Martin v. Löwis"
Ron_Adam wrote: I wasn't aware that the form: result = function(args)(args) Was a legal python statement. So python has a built in mechanism for passing multiple argument sets to nested defined functions! (click) Which means this is a decorator without the decorator syntax. No. There is no

Re: Finding attributes in a list

2005-04-02 Thread James Stroud
On Saturday 02 April 2005 09:51 pm, James Stroud wrote: > where team could be initialized by a tuple: > >   class Team(list): >     def __init__(self, azip): >       for azip in alist: >         self.data.append(Player(atup)) Sorry, this should read: where team could be initialized by a list of t

Re: Finding attributes in a list

2005-04-02 Thread James Stroud
On Saturday 02 April 2005 08:44 pm, Marcus Goldfish wrote: >(2) The Player class looks like a nice model for a data table when one > wants to sort by arbitrary column. Would you agree? The Player class is (and any class) is absolutely fabulous when you have heterogenous data (string,

Re: Docorator Disected

2005-04-02 Thread Ron_Adam
On 2 Apr 2005 20:02:47 -0800, "El Pitonero" <[EMAIL PROTECTED]> wrote: >Ron_Adam wrote: >> >> So I didn't know I could do this: >> >> def foo(a1): >> def fee(a2): >> return a1+a2 >> return fee >> >> fum = foo(2)(6) <-- !!! > >Ah, so you did not know functions are objects just

Re: Finding attributes in a list

2005-04-02 Thread Marcus Goldfish
> class Player(object): >def __init__(self, **kw): self.__dict__.update(kw) >def __repr__(self): return ''%getattr(self, 'name', > '(anonymous)') > > import operator > [p.name for p in sorted(players, key=operator.attrgetter('attacking'), > reverse=True)] Just happened to read this threa

Re: Lambda: the Ultimate Design Flaw

2005-04-02 Thread Artie Gold
Torsten Bronger wrote: HallÃchen! Daniel Silva <[EMAIL PROTECTED]> writes: Shriram Krishnamurthi has just announced the following elsewhere; it might be of interest to c.l.s, c.l.f, and c.l.p: http://list.cs.brown.edu/pipermail/plt-scheme/2005-April/008382.html The Fate Of LAMBDA in

Re: Docorator Disected

2005-04-02 Thread El Pitonero
Ron_Adam wrote: > > So I didn't know I could do this: > > def foo(a1): > def fee(a2): > return a1+a2 > return fee > > fum = foo(2)(6) <-- !!! Ah, so you did not know functions are objects just like numbers, strings or dictionaries. I think you may have been influenced by othe

Re: Name of IDLE on Linux

2005-04-02 Thread Joal Heagney
Edward Diener wrote: Thomas Rast wrote: Edward Diener <[EMAIL PROTECTED]> writes: It is a pity the Python Linux binary installations do not create folders on the desktop or in the Gnome menu system with links to the Python to the documentation and a readme telling me what executables were installe

Re: instance name

2005-04-02 Thread Bengt Richter
On Sat, 02 Apr 2005 15:48:21 GMT, "max(01)*" <[EMAIL PROTECTED]> wrote: >hi. > >is there a way to define a class method which prints the instance name? > >e.g.: > > >>> class class_1: >... def myName(self): >... what should i do here >... > >>> instance_1 = class_1() > >>> instance_1

Re: Help with splitting

2005-04-02 Thread George Sakkis
Jeremy Bowers wrote: > On Fri, 01 Apr 2005 14:20:51 -0800, RickMuller wrote: > > > I'm trying to split a string into pieces on whitespace, but I want to > > save the whitespace characters rather than discarding them. > > > > For example, I want to split the string '12' into ['1',' ','2']. > > I

Re: Decorater inside a function? Is there a way?

2005-04-02 Thread Ron_Adam
On 2 Apr 2005 10:23:53 -0800, "George Sakkis" <[EMAIL PROTECTED]> wrote: >It turns out it's not a "how to inflate tires with a hammer" request; >I've actually written an optional type checking module using >decorators. The implementation details are not easy to grok, but the >usage is straightforw

Re: redundant imports

2005-04-02 Thread Bengt Richter
On Sat, 02 Apr 2005 16:44:29 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote: >"max(01)*" <[EMAIL PROTECTED]> writes: > >> Peter Hansen wrote: >>> max(01)* wrote: >>> hi everybody. suppose that code-1.py imports code-2.py and code-3.py (because it uses names from both), and that co

Re: Name of IDLE on Linux

2005-04-02 Thread Edward Diener
Thomas Rast wrote: > Edward Diener <[EMAIL PROTECTED]> writes: > >> It is a pity the Python Linux binary installations do not >> create folders on the desktop or in the Gnome menu system with links >> to the Python to the documentation and a readme telling me what >> executables were installed. > >

Re: Corectly convert from %PATH%=c:\\X; "c:\\a; b" TO ['c:\\X', 'c:\\a; b']

2005-04-02 Thread Michael Spencer
chirayuk wrote: Hi, I am trying to treat an environment variable as a python list - and I'm sure there must be a standard and simple way to do so. I know that the interpreter itself must use it (to process $PATH / %PATH%, etc) but I am not able to find a simple function to do so. os.environ['PATH']

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Jeremy Bowers
On Sat, 02 Apr 2005 15:30:13 -0500, Brian van den Broek wrote: > So, how does one handle such cases with tests? When I had a similar situation, I created a directory for testing that was in a known state, and tested on that. If you can test based on a relative directory, that should work OK. Non-

Corectly convert from %PATH%=c:\\X; "c:\\a; b" TO ['c:\\X', 'c:\\a; b']

2005-04-02 Thread chirayuk
Hi, I am trying to treat an environment variable as a python list - and I'm sure there must be a standard and simple way to do so. I know that the interpreter itself must use it (to process $PATH / %PATH%, etc) but I am not able to find a simple function to do so. os.environ['PATH'].split(os.sep)

Re: Docorator Disected

2005-04-02 Thread Ron_Adam
On Sat, 02 Apr 2005 21:28:36 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote: >I think it might help you to start out with very plain decorators rather than >decorators as factory functions that return decorator functions that wrap the >decorated function in a wrapper function. E.g., (this could obvi

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Grig Gheorghiu
Can't you use the tempfile module to generate unique names for non-existent files and directories? Take a look at http://www.python.org/doc/lib/module-tempfile.html -- it works on all supported platforms. Grig -- http://mail.python.org/mailman/listinfo/python-list

Re: string goes away

2005-04-02 Thread Mike Meyer
Andreas Beyer <[EMAIL PROTECTED]> writes: > OK, you won. I read in an (regretably old) guidline for improving > Python's performance that you should prefer map() compared to list > comprehensions. Apparently the performance of list comprehensions has > improved a lot, which is great. (Or the overh

Re: instance name

2005-04-02 Thread Mark Winrock
max(01)* wrote: hi. is there a way to define a class method which prints the instance name? e.g.: >>> class class_1: ... def myName(self): ... what should i do here ... >>> instance_1 = class_1() >>> instance_1.myName() 'instance_1' >>> bye macs macs, The object instance doesn't k

Re: Simple thread-safe counter?

2005-04-02 Thread Paul Rubin
Tim Peters <[EMAIL PROTECTED]> writes: > If you don't want to exploit it, that's fine: there was always an > obvious approach using an explicit mutex here, and the only thing > stopping you from using it is a desire to be clever. Exploiting the > GIL in CPython is clever; using an explicit mutex

Re: Simple thread-safe counter?

2005-04-02 Thread Heiko Wundram
Am Sonntag, 3. April 2005 00:57 schrieb Heiko Wundram: > > or Make that: create_counter = syncronized_iterator(itertools.count) and counter = create_counter() to create the actual counter regardless of iterator. -- --- Heiko. pgpuQ5CRv1IKe.pgp Description: PGP signature -- http://mail.py

Re: Simple thread-safe counter?

2005-04-02 Thread Heiko Wundram
Am Samstag, 2. April 2005 22:28 schrieb Paul Rubin: > I'm starting to believe the GIL covers up an awful lot of sloppiness > in Python. I wonder if there could be a decorator approach: > > @synchronized > def counter(): >t = itertools.count() >while True: > yield t

Re: Docorator Disected

2005-04-02 Thread M.E.Farmer
Hello Ron , You have many good explanations already, but I thought that this __might__ help others. Like you I was confused by the decorator syntax. till I realized it was shorthand for ... def identity(f): return f def foo(): pass # this is the 'old way' foo = identity(foo) It just re

Re: (win32) speedfan api control

2005-04-02 Thread Claudio Grondi
your script works ok on my W2K box :-). It makes me curious if I can get also the temperatures into Python script for further processing as easy as the setting of the checkbox is done? (I have not much experience with this kind of programming yet) May I ask how did you get the "TJvXPCheckbox" and

Re: Simple thread-safe counter?

2005-04-02 Thread Tim Peters
[Paul Rubin] > I'm starting to believe the GIL covers up an awful lot of sloppiness > in Python. The GIL is highly exploitable, and much of CPython does exploit it. If you don't want to exploit it, that's fine: there was always an obvious approach using an explicit mutex here, and the only thing

Re: redundant imports

2005-04-02 Thread Mike Meyer
"max(01)*" <[EMAIL PROTECTED]> writes: > Peter Hansen wrote: >> max(01)* wrote: >> >>> hi everybody. >>> >>> suppose that code-1.py imports code-2.py and code-3.py (because it >>> uses names from both), and that code-2.py imports code-3.py. >>> >>> if python were c, code-1.c should only *include*

Re: Decorator Dissection

2005-04-02 Thread Bengt Richter
On Sat, 02 Apr 2005 21:04:57 +0200, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> I followed that part. The part that I'm having problems with is the >> first nested function get's the argument for the function name without >> a previous reference to the argument name in the outer frames. So,

Re: Performance issue

2005-04-02 Thread Steven Bethard
Marc 'BlackJack' Rintsch wrote: def make_anagram_map(words): anagram_map = dict() for word in imap(lambda w: w.strip().lower(), words): sorted_word = ''.join(sorted(list(word))) anagram_map.setdefault(sorted_word, list()).append(word) return dict(ifilter(lambda x: l

Re: Performance issue

2005-04-02 Thread Bengt Richter
On Sat, 02 Apr 2005 10:29:19 -0800, Shalabh Chaturvedi <[EMAIL PROTECTED]> wrote: >Tom Carrick wrote: >> Hi, >> >> In my attempted learning of python, I've decided to recode an old >> anagram solving program I made in C++. The C++ version runs in less >> than a second, while the python takes 30

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Andrà Malo
* Brian van den Broek wrote: > The relevant part of the validation method code looks like: > > # self.universe_files is a list of file paths > non_existent_files = [ x for x in self.universe_files if > not os.path.isfile(x) ] > if non_existen

Re: Docorator Disected

2005-04-02 Thread Bengt Richter
On Sat, 02 Apr 2005 14:29:08 GMT, Ron_Adam <[EMAIL PROTECTED]> wrote: > >I was having some difficulty figuring out just what was going on with >decorators. So after a considerable amount of experimenting I was >able to take one apart in a way. It required me to take a closer look >at function de

Re: Name of IDLE on Linux

2005-04-02 Thread Thomas Rast
Edward Diener <[EMAIL PROTECTED]> writes: > It is a pity the Python Linux binary installations do not > create folders on the desktop or in the Gnome menu system with links > to the Python to the documentation and a readme telling me what > executables were installed. Imagine they did, and the ot

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Tom Carrick wrote: > In my attempted learning of python, I've decided to recode an old > anagram solving program I made in C++. The C++ version runs in less > than a second, while the python takes 30 seconds. I'm not willing to > think it's just python being slow, so I was

Re: Decorator Dissection

2005-04-02 Thread Ron_Adam
On Sat, 02 Apr 2005 18:39:41 GMT, Ron_Adam <[EMAIL PROTECTED]> wrote: >>def foo(): >>a = 10 >>def bar(): >> return a*a >>return bar >> >>print foo()() <--- *Here* >> >> >>No decorator-specific magic here - just references kept to outer frames >>which form the scope

Re: Decorator Dissection

2005-04-02 Thread Ron_Adam
On Sat, 02 Apr 2005 21:04:57 +0200, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> I followed that part. The part that I'm having problems with is the >> first nested function get's the argument for the function name without >> a previous reference to the argument name in the outer frames. So,

testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Brian van den Broek
Hi all, I'm just starting to employ unit testing (I'm using doctest), and I am uncertain how to handle writing tests where the behaviour being tested is dependant on whether certain file paths point to actual files. I have a class which takes, in its __init__, a list of file paths to process. The

Re: Decorator Dissection

2005-04-02 Thread El Pitonero
Ron_Adam wrote: > On 2 Apr 2005 08:39:35 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> > wrote: > > >There is actually nothing mysterious about decorators. > > I've heard this quite a few times now, but *is* quite mysterious if > you are not already familiar with how they work. Or instead of > mysteri

Re: Simple thread-safe counter?

2005-04-02 Thread Paul Rubin
[EMAIL PROTECTED] (Aahz) writes: > This is one case where'd recommend using a plan RLock() instead of using > Queue -- the RLock() will be more efficient... I'm starting to believe the GIL covers up an awful lot of sloppiness in Python. I wonder if there could be a decorator approach: @synch

Re: Name of IDLE on Linux

2005-04-02 Thread Edward Diener
Jim Benson wrote: On Sat, 2 Apr 2005, Edward Diener wrote: What is the name of the IDLE program on Linux and where is it installed in a normal Linux distribution ? I have installed all the Python 2.3.5 RPMs on my Fedora 3 system but I have no idea where they are installed or what IDLE is called

Re: Pseudocode in the wikipedia

2005-04-02 Thread Ivan Van Laningham
Hi All-- Cameron Laird wrote: > > Welcome back, Ivan. Your follow-ups make one wonder about the > span of related topics clp has been missing in your absence. > Thanks for the welcome. Absence was more a consequence of working for idiots for four years (at 60-80 hours/week) than anything else.

Re: Suggesting methods with similar names

2005-04-02 Thread bearophileHUGS
Is that last idea so stupid? Still, I'd like to know if you know some little Python search engines for such purpose. Thank you, Bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator Dissection

2005-04-02 Thread Ron_Adam
On 2 Apr 2005 08:39:35 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: > >There is actually nothing mysterious about decorators. I've heard this quite a few times now, but *is* quite mysterious if you are not already familiar with how they work. Or instead of mysterious, you could say complex,

Re: How To Do It Faster?!?

2005-04-02 Thread Simo Melenius
[EMAIL PROTECTED] writes: > >$ find . -type f -printf "%T@ %u %s %p\n" > /yourserverroot/files.txt > That is a nice idea. I don't know very much about Unix, but I suppose that > on a ksh I can run this command (or a similar one) in order to obtain the > list I need. If anyone knows if that command

Re: Controling the ALU

2005-04-02 Thread Chris Smith
> "Cesar" == Cesar Andres Roldan Garcia <[EMAIL PROTECTED]> writes: Cesar> Hi How can I control an ALU from a PC using Python? Cesar> Thanks! Cesar> Hola... Cesar> Como puedo controlar la ALU de un PC usando Pyhton? Cesar> Gracias! Cesar> -- Atentamente, Cesa

Re: Pseudocode in the wikipedia

2005-04-02 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Ivan Van Laningham <[EMAIL PROTECTED]> wrote: . . . >> >>> 25 >> 25 >> >>> (_ | _) >> 25 >> >>> >> >> There's clearly some interesting biometrics research to be done here, >> although there is

Re: Decorator Dissection

2005-04-02 Thread Diez B. Roggisch
> I followed that part. The part that I'm having problems with is the > first nested function get's the argument for the function name without > a previous reference to the argument name in the outer frames. So, a > function call to it is being made with the function name as the > argument, and th

Re: Can I play too?

2005-04-02 Thread stelios xanthakis
Scott David Daniels wrote: if __name__ == '__main__': import sys main(sys.argv[1:] or ['anagrams.py']) This is *exactly* the kind of testcases I'm looking for to test the soon-to-be-released pyvm. Great! I'll be back with results. For now, a fast anagrams.py is ---

Re: Performance issue

2005-04-02 Thread Shalabh Chaturvedi
Tom Carrick wrote: Hi, In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. I'm not willing to think it's just python being slow, so I was hoping someone could find a f

Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-02 Thread Scott David Daniels
Donn Cave wrote: Quoth Scott David Daniels <[EMAIL PROTECTED]>: | Sunnan wrote: | > ...Because what is "boring"? The opposite of dense, tense, intense. Utterly | > predictable; it's like the combination of all my prejudices. Even before | > I knew, I thought "Bet Python separates statements from

Re: Decorator Dissection

2005-04-02 Thread Ron_Adam
On Sat, 02 Apr 2005 19:59:30 +0200, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> statements documenting the flow in a few minutes. I'm still a bit >> fuzzy on how the arguments are stored and passed. > >The arguments are part of the outer scope of the function returned, and thus >they ar kept

Re: Name of IDLE on Linux

2005-04-02 Thread Jim Benson
On Sat, 2 Apr 2005, Edward Diener wrote: > What is the name of the IDLE program on Linux and where is it installed > in a normal Linux distribution ? I have installed all the Python 2.3.5 > RPMs on my Fedora 3 system but I have no idea where they are installed > or what IDLE is called. I lloked

Re: Performance issue

2005-04-02 Thread Shalabh Chaturvedi
Tom Carrick wrote: Hi, In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. I'm not willing to think it's just python being slow, so I was hoping someone could find a f

Re: Decorater inside a function? Is there a way?

2005-04-02 Thread George Sakkis
It turns out it's not a "how to inflate tires with a hammer" request; I've actually written an optional type checking module using decorators. The implementation details are not easy to grok, but the usage is straightforward: from typecheck import * @returns(listOf(int, size=3)) @expects(x=str, y=

Can I play too?

2005-04-02 Thread Scott David Daniels
Thomas Rast wrote: Tom Carrick <[EMAIL PROTECTED]> writes: In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. Indeed, your program can be improved to run about ten ti

Name of IDLE on Linux

2005-04-02 Thread Edward Diener
What is the name of the IDLE program on Linux and where is it installed in a normal Linux distribution ? I have installed all the Python 2.3.5 RPMs on my Fedora 3 system but I have no idea where they are installed or what IDLE is called. I lloked in the Python web pages to try to find a list of

Re: Docorator Disected

2005-04-02 Thread Diez B. Roggisch
> statements documenting the flow in a few minutes. I'm still a bit > fuzzy on how the arguments are stored and passed. The arguments are part of the outer scope of the function returned, and thus they ar kept around. That's standart python,too: def foo(): a = 10 def bar(): return

Re: Simple thread-safe counter?

2005-04-02 Thread Aahz
In article <[EMAIL PROTECTED]>, Skip Montanaro <[EMAIL PROTECTED]> wrote: > >Obviously, if you want multiple counters for some reason a little >information hiding with a class would help (also untested): > >import Queue > >class Counter: >def __init__(self, start=0): >s

Re: Ternary Operator in Python

2005-04-02 Thread Steven Bethard
Scott David Daniels wrote: Roy Smith wrote: ... How our tools warp our thinking. That is what it means to be human. I can think of no better reason for a programmer to regularly learn languages: "our tools warp our thinking." A programmer is a professionally warped thinker. --Scott David Daniels

Re: Docorator Disected

2005-04-02 Thread Ron_Adam
On 2 Apr 2005 07:22:39 -0800, "El Pitonero" <[EMAIL PROTECTED]> wrote: >Is it possible that you mistakenly believe your @decorator() is being >executed at the line "func('Hello')"? > >Please add a print statement to your code: > >def decorator(d_arg): > def get_function(function): > pr

Re: Performance issue

2005-04-02 Thread Thomas Rast
Tom Carrick <[EMAIL PROTECTED]> writes: > In my attempted learning of python, I've decided to recode an old > anagram solving program I made in C++. The C++ version runs in less > than a second, while the python takes 30 seconds. Indeed, your program can be improved to run about ten times as fast

Re: Performance issue

2005-04-02 Thread vincent wehren
"Tom Carrick" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] | Hi, | | In my attempted learning of python, I've decided to recode an old | anagram solving program I made in C++. The C++ version runs in less | than a second, while the python takes 30 seconds. I'm not willing to |

Re: Docorator Disected

2005-04-02 Thread Kay Schluehr
Ron_Adam wrote: > def decorator(d_arg): # (7) Get 'Goodbye' off stack > > def get_function(function): # (8) Get func object off stack > > def wrapper(f_arg):# (9) Get 'Hello' off stack > > new_arg = f_arg+'-'+d_arg > result = function(new_arg) # (10

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Irmen de Jong wrote: >> words = file.splitlines() > > You can obtain this list without reading the file in its entirety, > by using the readlines method of file objects: > > words=open("words.txt").readlines() This leaves the newline characters at the end of each line wh

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Tom Carrick wrote: > [â] Also, I was wondering if there was a more > builtin, or just nicer way of converting a string to a list (or using > the sort function on a list) than making a function for it. Use the `list()` builtin on the string and *just* the `sort()` method::

Re: boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-02 Thread Aahz
In article <[EMAIL PROTECTED]>, Sunnan <[EMAIL PROTECTED]> wrote: >>> [Aahz] "The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death.

Re: Performance issue

2005-04-02 Thread Irmen de Jong
Tom Carrick wrote: > Hi, > > In my attempted learning of python, I've decided to recode an old > anagram solving program I made in C++. The C++ version runs in less > than a second, while the python takes 30 seconds. I'm not willing to > think it's just python being slow, so I was hoping someone c

Example Code : Shared Memory with Mutex (pywin32 and ctypes)

2005-04-02 Thread Srijit Kumar Bhadra
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with SharedMemAccess_Mutex_ctypes.py or SharedMemAccess_Mutex_win32all.py #~ a) Creates a shared memory #~ b) Creates or Opens

Re: instance name

2005-04-02 Thread max(01)*
Irmen de Jong wrote: max(01)* wrote: hi. is there a way to define a class method which prints the instance name? e.g.: class class_1: ... def myName(self): ... what should i do here ... instance_1 = class_1() instance_1.myName() 'instance_1' bye macs What should the following do, yo

Re: instance name

2005-04-02 Thread max(01)*
Andrew Koenig wrote: "max(01)*" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] is there a way to define a class method which prints the instance name? The term "the instance name" is misleading, because it assumes, without saying so explicitly, that every instance has a unique nam

Re: instance name

2005-04-02 Thread Irmen de Jong
max(01)* wrote: > hi. > > is there a way to define a class method which prints the instance name? > > e.g.: > class class_1: > ... def myName(self): > ... what should i do here > ... instance_1 = class_1() instance_1.myName() > 'instance_1' > > bye > > macs W

Re: instance name

2005-04-02 Thread Andrew Koenig
"max(01)*" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > is there a way to define a class method which prints the instance name? The term "the instance name" is misleading, because it assumes, without saying so explicitly, that every instance has a unique name. In fact, there i

instance name

2005-04-02 Thread max(01)*
hi. is there a way to define a class method which prints the instance name? e.g.: >>> class class_1: ... def myName(self): ... what should i do here ... >>> instance_1 = class_1() >>> instance_1.myName() 'instance_1' >>> bye macs -- http://mail.python.org/mailman/listinfo/python-list

Performance issue

2005-04-02 Thread Tom Carrick
Hi, In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. I'm not willing to think it's just python being slow, so I was hoping someone could find a faster way of doing

Re: redundant importr

2005-04-02 Thread max(01)*
Peter Hansen wrote: max(01)* wrote: Peter Hansen wrote: Not required except for performance reasons. If the .pyc files don't exist, the .py files are recompiled and the resulting bytecode is simply held in memory and not cached and the next startup will recompile all over again. but the other fil

Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-02 Thread Donn Cave
Quoth Scott David Daniels <[EMAIL PROTECTED]>: | Sunnan wrote: | > ...Because what is "boring"? The opposite of dense, tense, intense. Utterly | > predictable; it's like the combination of all my prejudices. Even before | > I knew, I thought "Bet Python separates statements from expressions". | |

Re: Simple thread-safe counter?

2005-04-02 Thread Artie Gold
Leif K-Brooks wrote: Artie Gold wrote: Skip Montanaro wrote: counter = Queue.Queue() def f(): i = counter.get() I think you need: i = counter.get(True) The default value for the "block" argument to Queue.get is True. Right. I misparsed the entry in the documentation: "If

Re: terminating an inactive process

2005-04-02 Thread fred.dixon
i use this to open/close netscape as it also doesnt like to close all the time. its a WMI script but easiely edited. check out script-o-matic from ms-downloads , it outputs python code as well as others. ## strComputer = "." Set o

Re: unittest vs py.test?

2005-04-02 Thread Peter Hansen
Raymond Hettinger wrote: [Peter Hansen] This is pretty, but I *want* my tests to be contained in separate functions or methods. In py.test, those would read: def test1(): assert a == b def test2(): raises(Error, func, args) Enclosing classes are optional. So basically py.test skips the imp

Re: unittest vs py.test?

2005-04-02 Thread Peter Hansen
Roy Smith wrote: Actually, I believe it does. I'm just starting to play with this, but it looks like you can do: py.test test_sample.py and it'll run a single test file. Well, my driver script can do that too. I just meant I could do "test_sample.py" and have it run the test any time, if I wa

Re: Docorator Disected

2005-04-02 Thread El Pitonero
Ron_Adam wrote: > > # (0) Read defined functions into memory > > def decorator(d_arg): # (7) Get 'Goodbye' off stack > > def get_function(function): # (8) Get func object off stack > > def wrapper(f_arg):# (9) Get 'Hello' off stack > > new_arg = f_arg+'-'+d_arg >

Re: Module subprocess: How to "communicate" more than once?

2005-04-02 Thread Peter Hansen
Edward C. Jones wrote: I have a program named "octave" (a Matlab clone). It runs in a terminal, types a prompt and waits for the user to type something. If I try # Run octave. oct = subprocess.Popen("octave", stdin=subprocess.PIPE) # Run an octave called "startup". oct.communicate("startup") # Ch

terminating an inactive process

2005-04-02 Thread Earl Eiland
I'm running a PyWin program that executes another program using subprocess.Popen(). Unfortunately, this other program isn't well behaved, and frequently terminates without terminating its process. After this happens enough times, all my memory is tied up, and the machine crashes. Using subproces

[EVALUATION] - E03 - jamLang Evaluation Case Applied to Python

2005-04-02 Thread Ilias Lazaridis
[EVALUATION] - E02 - Support for MinGW Open Source Compiler http://groups-beta.google.com/group/comp.lang.python/msg/f5cd74aa26617f17 - In comparison to the E02 thread, now a more practical one. - Here is a simple evaluation template (first part) which can be applied to the Python language: http:

Docorator Disected

2005-04-02 Thread Ron_Adam
I was having some difficulty figuring out just what was going on with decorators. So after a considerable amount of experimenting I was able to take one apart in a way. It required me to take a closer look at function def's and call's, which is something I tend to take for granted. I'm not sure

Re: __init__ method and raising exceptions

2005-04-02 Thread NavyJay
Or better yet, define your own string/class exception to catch your errors. In my code, things can break in more than a few ways. In each case I catch the exception(s) specific to that piece of code, print a warning message to the user at sys.stdout and raise a new exception to be caught by my "w

Re: unittest vs py.test?

2005-04-02 Thread Roy Smith
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Bengt Richter) > Is there a package that is accessible without svn? That seems to be its weak point right now. Fortunately, you can get pre-built svn clients for many platforms (http://subversion.tigris.org/project_packages.html#binary-packages

Re: Python plug-in Frameworks like Eclipse RCP...

2005-04-02 Thread Diez B. Roggisch
Jim Hargrave wrote: > Hum, maybe my question was too specific. What I would really like to > know is what is the best way to implement a Python application with a > pluggable architecture. In particular, I would like to use wxPython and > have plug ins automatically register themselves with the GU

Re: Lambda: the Ultimate Design Flaw

2005-04-02 Thread Ron_Adam
On Sat, 02 Apr 2005 00:40:15 -0500, Steve Holden <[EMAIL PROTECTED]> wrote: > >The danger in GOTO is that it allows the undisciplined programmer to >develop a badly-structured solution to a programming problem. A >disciplined programmer will write well-structured code with whatever >tools come

Re: Ternary Operator in Python

2005-04-02 Thread Scott David Daniels
Roy Smith wrote: ... How our tools warp our thinking. That is what it means to be human. I can think of no better reason for a programmer to regularly learn languages: "our tools warp our thinking." A programmer is a professionally warped thinker. --Scott David Daniels [EMAIL PROTECTED] -- http:

Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-02 Thread Scott David Daniels
Sunnan wrote: ...Because what is "boring"? The opposite of dense, tense, intense. Utterly predictable; it's like the combination of all my prejudices. Even before I knew, I thought "Bet Python separates statements from expressions". Python is for terse, pithy prose; Python is not for poetry. --Sc

How To Do It Faster?!?

2005-04-02 Thread andrea_gavana
Hello Simo & NG, >Correct me if I'm wrong but since it _seems_ that the listing doesn't >need to be up-to-date each minute/hour as the users will be looking >primarily for old/unused files, why not have a daily cronjob on the >Unix server to produce an appropriate file list on e.g. the root >direc

Re: pagecrawling websites with Python

2005-04-02 Thread Swaroop C H
On 1 Apr 2005 11:58:11 -0800, writeson <[EMAIL PROTECTED]> wrote: > We've got an application we wrote in Python called pagecrawler that > Does anyone have any insight if this is a reasonable approach to build web > pages, > or if we should look at another design? I don't have an answer to your p

  1   2   >