[Tutor] Automatic software performance meter

2006-03-10 Thread János Juhász
Hi All, is it any easy way to mesaure a windows software response time from python script ? I think about a small python script that can open a win32 application, insert a new order with sendkey, deliver the goods, do other things and create a small log file with the different split times. I w

[Tutor] Dynamically naming functions

2006-03-10 Thread Ed Singleton
How does one go about creating functions, classes, or callable objects when you don't know their name in advance? (For example you want to read their names in from a text file or database). I want to use this in a few different places. For example Faces, the Python Project Management Planner Tool

[Tutor] Problem handling utf-8 text

2006-03-10 Thread Ryan Ginstrom
I am just learning python, or trying to, and am having trouble handling utf-8 text. I want to take a utf-8 encoded web page, and feed it to Beautiful Soup (http://crummy.com/software/BeautifulSoup/). BeautifulSoup uses SGMLParser to parse text. But although I am able to read the utf-8 encoded Jap

Re: [Tutor] Python and unicode

2006-03-10 Thread Michael Lange
On Fri, 10 Mar 2006 08:55:35 +0100 Ferry Dave Jäckel <[EMAIL PROTECTED]> wrote: > Hello list, > > I try hard to understand python and unicode support, but don't get it > really. > > What I thought about this until yesterday :) > If I write my script in unicode encoding and put the magic # -*- c

Re: [Tutor] Python and unicode

2006-03-10 Thread Kent Johnson
Ferry Dave Jäckel wrote: > Hello list, > > I try hard to understand python and unicode support, but don't get it > really. > > What I thought about this until yesterday :) > If I write my script in unicode encoding and put the magic # -*- coding: > utf-8 -*- at its start, I can just use unicode

Re: [Tutor] Dynamically naming functions

2006-03-10 Thread Kent Johnson
Ed Singleton wrote: > How does one go about creating functions, classes, or callable objects > when you don't know their name in advance? (For example you want to > read their names in from a text file or database). > > I want to use this in a few different places. For example Faces, the > Python

Re: [Tutor] Dynamically naming functions

2006-03-10 Thread Alan Gauld
> How does one go about creating functions, classes, or callable objects > when you don't know their name in advance? (For example you want to > read their names in from a text file or database). First point, names of functions are no different to names of other things. def f(x): y = blah

Re: [Tutor] Problem handling utf-8 text

2006-03-10 Thread Kent Johnson
Ryan Ginstrom wrote: > I am just learning python, or trying to, and am having trouble handling utf-8 > text. > > I want to take a utf-8 encoded web page, and feed it to Beautiful Soup > (http://crummy.com/software/BeautifulSoup/). > BeautifulSoup uses SGMLParser to parse text. > > But although I

[Tutor] problems with numbers in my python code

2006-03-10 Thread sjw28
Basically, I have a code with is almost finished but I've having difficultly with the last stage of the process. I have a program that gets assigns different words with a different value via looking them up in a dictionary: eg if THE is in the writing, it assigns 0.965 and once the whole passag

[Tutor] *args consumption

2006-03-10 Thread Smith
I see that one way to use *arg in a function is to simply pass them on to another function that perhaps will unpack the arguments: ### def pass_along(func, *args): return func(*args) def adder(x,y): return x+y def suber(x,y): return x-y print pass_along(adder,1,2) print pass_along(su

Re: [Tutor] problems with numbers in my python code

2006-03-10 Thread Hugo González Monteverde
Hi, > However, I can't seem to get the program to treat the numbers as numbers. If > I put them in the dictionary as 'THE' = int(0.965) the program returns 1.0 > and if I put 'THE' = float(0.965) it returns 0.9655549 or something > similar. Neither of these are right! I basically need to acce

Re: [Tutor] problems with numbers in my python code

2006-03-10 Thread Anna Ravenscroft
On 3/10/06, sjw28 <[EMAIL PROTECTED]> wrote: Basically, I have a code with is almost finished but I've having difficultlywith the last stage of the process. I have a program that gets assignsdifferent words with a different value via looking them up in a dictionary: eg if THE is in the writing, it

[Tutor] Cannot Understand

2006-03-10 Thread Edgar Antonio Rodriguez Velazco
Hi,Could you please explain this code?.f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1Thanks,-- Edgar A. Rodriguez V. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Automatic software performance meter

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, [ISO-8859-1] J�nos Juh�sz wrote: > is it any easy way to mesaure a windows software response time from python > script ? > I think about a small python script that can open a win32 application, > insert a new order with sendkey, deliver the goods, do other things and > c

Re: [Tutor] Dynamically naming functions

2006-03-10 Thread Danny Yoo
> I want to use this in a few different places. For example Faces, the > Python Project Management Planner Tool Thingy, uses nested functions to > put tasks within a project: > > def MyProject(): > start = "2006-03-06" > resource = Me > > def Task1(): > start = "2006-03-13" > >

Re: [Tutor] Cannot Understand

2006-03-10 Thread Anna Ravenscroft
On 3/10/06, Edgar Antonio Rodriguez Velazco <[EMAIL PROTECTED]> wrote: Hi,Could you please explain this code?.f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 This is why lambdas are evil. Officially, they are for creating "anonymous functions"; usually they only succeed in creating obscure unreadabl

Re: [Tutor] *args consumption

2006-03-10 Thread Danny Yoo
> Am I missing some other usage where you wouldn't want to unpack the > *arg? If not, would the following "behind the scenes" behavior be > possible/preferred? > > ### > def foo(*arg): > pass > ### > > automatically does this > > ### > def foo(*arg): > if len(arg) == 1: > arg = arg[

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, Edgar Antonio Rodriguez Velazco wrote: > Could you please explain this code?. > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 Hi Edgar, This is terrible code. *grin* I know that this is the factorial function in disguise, but this is just Wrong. I don't think we sho

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
> The expression n-1 + abs(n-1) is always a true value... except in the > case where n is zero. Sorry, that's wrong of me, but you know what I mean. *grin* It zeros out when n-1 <= 0, that is, when n <= 1. ## >>> def test(n): ... return n-1 + abs(n-1) ... >>> for x in range(-5, 5): ...

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, Danny Yoo wrote: > > The expression n-1 + abs(n-1) is always a true value... except in the > > case where n is zero. > > Sorry, that's wrong of me, but you know what I mean. *grin* Ugh, the other thing I screwed up wrong was misreading: X and Y or Z and forgetting my

Re: [Tutor] Cannot Understand

2006-03-10 Thread Pawel Kraszewski
Dnia piątek, 10 marca 2006 19:31, Edgar Antonio Rodriguez Velazco napisał: > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 Oh God! This smells lispish! Haven't seen a jevel like this before, but I LOVE it! - First, let's cut that into pieces: R1 n-

[Tutor] Unicode and regexes

2006-03-10 Thread Michael Broe
Does Python support the Unicode-flavored class-specifications in regular expressions, e.g. \p{L} ? It doesn't work in the following code, any ideas? - #! /usr/local/bin/python """ usage: ./uni_read.py file """ import codecs import re text = codecs.open(sys.argv[1], mode='r', encoding='u

Re: [Tutor] Cannot Understand

2006-03-10 Thread Bob Gailer
Edgar Antonio Rodriguez Velazco wrote: > Hi, > Could you please explain this code?. > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 You've had 2 replies that dissect the "expression". I fear they might not make lambda itself clear, so I will add my explanation. lambda is a Python operator that

[Tutor] execute an OS command, get the output

2006-03-10 Thread Terry Carroll
I need to execute a command and capture the stdout output. I'm overwhelmed by the plethora of means that Python offers to do something like this, and don't know which, if any, is most applicable: 1) the os.system module 2a-d) os.popen, and popen2 popen3 and popen4 3) the popen2 module 4) the subp

Re: [Tutor] Cannot Understand

2006-03-10 Thread Alan Gauld
>> Could you please explain this code?. >> >> f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 > > This is why lambdas are evil. It's not the lambda thats evil its the need in Python to limit them to a single expression. If we write def f(n): return n-1 + abs(n-1) and f(n-1)*n or 1 its just

Re: [Tutor] Cannot Understand

2006-03-10 Thread Alan Gauld
>> Could you please explain this code?. >> >> f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 > > >This is why lambdas are evil. I meant to add to my last post that even using lambdas this is a weird attempt at a factorial fiunction. Here's the equivalent from my web tutor on functional program

Re: [Tutor] Cannot Understand

2006-03-10 Thread Anna Ravenscroft
On 3/10/06, Alan Gauld <[EMAIL PROTECTED]> wrote: >> Could you please explain this code?. f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1>>>This is why lambdas are evil.I meant to add to my last post that even using lambdas this is a weird attempt at a factorial fiunction.Here's the equivalent f

Re: [Tutor] Cannot Understand

2006-03-10 Thread Liam Clarke
On 3/11/06, Pawel Kraszewski <[EMAIL PROTECTED]> wrote: > Dnia piątek, 10 marca 2006 19:31, Edgar Antonio Rodriguez Velazco napisał: > > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 > > Oh God! This smells lispish! Haven't seen a jevel like this before, but I LOVE > it! Haha, hey, I've been le

Re: [Tutor] Cannot Understand

2006-03-10 Thread Anna Ravenscroft
On 3/10/06, Alan Gauld <[EMAIL PROTECTED]> wrote: >> Could you please explain this code?. f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1>> This is why lambdas are evil.It's not the lambda thats evil its the need in Python to limit them to a single _expression_.If we writedef f(n):   return n-1

Re: [Tutor] execute an OS command, get the output

2006-03-10 Thread Hugo González Monteverde
Hi Terry, > abc = executeit(commandline)or > executeit(commandline, abc) > Looks like you are looking for the commands module, it provides: getstatusoutput( cmd) getoutput( cmd) getstatus( file) Which do exactly what tou want. Take a look at the docs at: http://python.active-ve

[Tutor] i have a question

2006-03-10 Thread Tom Bachik
ok say u want python to ask the user to type a username then password for a game account thats easy but how do u get the information they typed back to you? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] execute an OS command, get the output

2006-03-10 Thread Terry Carroll
On Fri, 10 Mar 2006, [ISO-8859-1] Hugo Gonz?lez Monteverde wrote: > Looks like you are looking for the commands module, it provides: > > getstatusoutput( cmd) > > getoutput( cmd) > > getstatus( file) > > > Which do exactly what tou want. Take a look at the docs at: > > http://python.active-v

[Tutor] weighted choices from among many lists

2006-03-10 Thread kevin parks
I have several lists... and i would like to some times chose from one list and for a while choose from a different list, etc... so i cooked this up and it almost works so that i can get colors 50% of the time, doggies 25%, beer 10%, and guitars 100% (if i was real smart i would make my index th

[Tutor] activestate

2006-03-10 Thread kevin parks
I noticed a couple days ago that the active state archive seems to have ceased. Is it going away? cheers, kevin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor