Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Leonhard Vogt
Why I've personally stopped using it: I've always had the impression that decorators were intended to provide a convenient and obvious way of augmenting functions. Having one that automatically executes the function at definition just runs counter to the behaviour I expect from a decorator. Espe

Re: How to create functors?

2009-08-18 Thread Leonhard Vogt
The example I gave earlier is a bit contrived, the real example fundamentally requires a lambda since I am actually passing in local variables into the functions the lambda is wrapping. Example: def MyFunction(): localVariable = 20 CreateTask( lambda: SomeOtherFunction( localVariable ) ) #

Tkinter Entry blocked by tkFileDialog

2008-10-02 Thread Leonhard Vogt
Hello I have the following problem in Python 2.5 on Windows XP. On Ubuntu I do not see the problem. I have a Tkinter application as in the following example The entry-widget is somehow blocked (i cannot type characters into it) when I call askopenfilename before I create the widget. Calling asko

Re: Writing to ms excel

2008-08-30 Thread Leonhard Vogt
Marin Brkic schrieb: I'm trying to find a way to write data to excel cells (or to be more specific to an .xls file), let's say for the sake of argument, data readen from a file (although it will be calculated in the process). I've been searching, but couldn't find any examples which allows that.

Customizing code.InteractiveConsole

2008-08-30 Thread Leonhard Vogt
Hello I have subclassed code.InteractiveInterpreter for testing an "interpreter" i have written myself. The interpreter is a function (evaluate) that can raise MyError exceptions. I want these to be reported with an indication of the position (^) as in the python interactive interpreter. The co

Re: How can I check nbr of cores of computer?

2008-07-30 Thread Leonhard Vogt
defn noob schrieb: How can I check how many cores my computer has? Is it possible to do this in a Python-app? processing (http://pyprocessing.berlios.de/) has an utility function processing.cpuCount(). Leo -- http://mail.python.org/mailman/listinfo/python-list

Re: subexpressions (OT: math)

2007-06-03 Thread Leonhard Vogt
>> Yes, I understand that, but what is the geometrical >> meaning of the square root of an arc length? > > That's a different question to your original question, which was asking > about the square root of an angle. > >> And what would the units be? > > Angles are a ratio of two lengths, and

Re: Logging output from python

2006-12-09 Thread Leonhard Vogt
Cameron Walsh schrieb: > > If it's on linux you can just redirect the screen output to a file: > > python initialfile.py 1>stdout.txt 2>stderr.txt > As for windows, I'll test it now... > > It turns out you can at least redirect the output to a file, I'm not > sure what it does with standard er

Re: String Replace only if whole word?

2006-11-19 Thread Leonhard Vogt
Michael Yanowitz schrieb: > Yeah, I am operating this on a Python script. However, I am working off > a requirement that the script be pre-processed and the strings replaced > before executing the script and that if there are any remaining (not > replaced) > names that I don't execute the script

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 7)

2006-11-07 Thread Leonhard Vogt
John Salerno schrieb: > Cameron Laird wrote: > >> Fredrik Lundh collects pyidioms: >> http://effbot.org/zone/python-lists.htm > > Not working? Try http://effbot.org/zone/python-list.htm Leonhard -- http://mail.python.org/mailman/listinfo/python-list

Re: unexpected behaviour of lambda expression

2006-10-09 Thread leonhard . vogt
Fredrik Lundh schrieb: > [EMAIL PROTECTED] wrote: > > > Please consider that example: > > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] > > on win32 > > Type "help", "copyright", "credits" or "license" for more information. > s = 'foo' > f = lambda x: s > f(N

unexpected behaviour of lambda expression

2006-10-09 Thread leonhard . vogt
Please consider that example: Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> s = 'foo' >>> f = lambda x: s >>> f(None) 'foo' >>> s = 'bar' >>> f(None) 'bar' >>> del(s) >>> f(None) Traceback (m

Re: Escapeism

2006-09-30 Thread Leonhard Vogt
> But there is some ambiguity due to the the fact that applying '\7' to > rawform() yields r'\a' and not r'\7'. So one needs more specification > for disambiguation using e.g. an extra parameter. > >>> '\a'=='\7' True The two are actually the same thing, so how could a function decide whether to

Re: time.clock() or time.time()

2005-08-02 Thread Leonhard Vogt
[EMAIL PROTECTED] schrieb: > What's the difference between time.clock() and time.time() > (and please don't say clock() is the CPU clock and time() is the actual > time because that doesn't help me at all :) clock (depending on the platform ?) measures the time spent by your program. Time gives y