[Tutor] help

2006-01-16 Thread james middendorff
I am trying to do some AGI scripting with python and asterisk, I read the book, Asterisk the Future of Telephony, which has an example of AGI + python. I have found that none of the example seems to work. My question is I have figured out how to play a recorded message sys.stdout.write('EXEC PLAYBA

Re: [Tutor] Python debugger bummer

2006-01-16 Thread Victor Bouffier
Thanks Alan. As always, you are very helpful. Victor On Mon, 2006-01-16 at 23:35 +, Alan Gauld wrote: > > I was going through the Python library documentation and I found > > something I never saw before. > > > > $ python -m pdb myscript.py > > I was just about to suggest loading pdb... >

Re: [Tutor] __iter__

2006-01-16 Thread Danny Yoo
On Mon, 16 Jan 2006, Christopher Spears wrote: > I'm not sure if I understand __iter__. You use it to create an object > that iterates through itself using a next menthod ? Hi Chris, Yes, that's one application. But __iter__() doesn't necessarily have to return 'self'. For example, here's

Re: [Tutor] PIL, fonts and making images

2006-01-16 Thread Danny Yoo
> Want I want though is to do this with MARRFONT.TTF. That is a (free) font > that has chesspieces inside. (can be downloaded here: > http://antraxja-fonts.iweb.pl/pobierz.php?font=3903 ) Hi Rinzwind, You might want to contact the folks who make that font: according to the Fontbook on my Mac OS X

Re: [Tutor] Design suggestion - is a cookie the answer?

2006-01-16 Thread Danny Yoo
> On 16/01/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > > No. JavaScript is an event driven paradigm and it only picks up the > > explicit events you register with it(*). One of the problems of using > > CGI is the ese of frigging it. I assume you are using GET instead of > > POST? GET is the defaul

Re: [Tutor] Design suggestion - is a cookie the answer?

2006-01-16 Thread John Fouhy
On 16/01/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > No. JavaScript is an event driven paradigm and it only > picks up the explicit events you register with it(*). One of > the problems of using CGI is the ese of frigging it. I assume > you are using GET instead of POST? GET is the default > submis

Re: [Tutor] Design suggestion - is a cookie the answer?

2006-01-16 Thread Python
On Mon, 2006-01-16 at 01:12 +, Alan Gauld wrote: > > I'm sure this is implied in Alan's post, but I'm going to point it > out > ... > > To avoid further cheating you might want to sure there is no way to > > submit the form without javascript turned on. E.g. Don't have a > submit > > button and

Re: [Tutor] __getitem__

2006-01-16 Thread Alan Gauld
> Sorry! > > X = stepper() > X.data = "Spam" Aha! The fog in my brain clears. >> > >>> class stepper: >> >... def __getitem__(self, i): >> >... return self.data[i] >> >... >> > >>> 'p' in X >> >True >> > >> >What does 'in' have to do with indexing? To find out if 'p' is in X Python

Re: [Tutor] __getitem__

2006-01-16 Thread Alan Gauld
> map calls, list comprehension, etc. For loops, etc. > work by indexing a sequences from zero to a higher > index until out-of-bounds is reached. What makes you think that? So far as I know for loops work by calling next on an iterator until nothing gets returned, no indexes involved.(At le

Re: [Tutor] Python debugger bummer

2006-01-16 Thread Alan Gauld
> I was going through the Python library documentation and I found > something I never saw before. > > $ python -m pdb myscript.py I was just about to suggest loading pdb... And of course there is also a graphical debugger in IDLE as well as PythonWin. The paper version of my book contains a c

Re: [Tutor] __iter__

2006-01-16 Thread Kent Johnson
Christopher Spears wrote: > I'm not sure if I understand __iter__. You use it to > create an object that iterates through itself using a > next menthod ? Yes, you seem to have it right. Your code is fine IMO. In many cases it's easier to use a generator than an iterator class. If you are using

Re: [Tutor] __getitem__

2006-01-16 Thread Kent Johnson
Christopher Spears wrote: > I understand that you can use __getitem__ as a hook to > modify indexing behavoir in a class. That's why > __getitem__ not only affects [] but also for loops, > map calls, list comprehension, etc. For loops, etc. > work by indexing a sequences from zero to a higher >

Re: [Tutor] setuptools question

2006-01-16 Thread Shuying
I think I tried python2.4 /usr/bin/easy_install -U setuptools and directly the #! line in easy_install to use python2.4. On 1/16/06, Liam Clarke <[EMAIL PROTECTED]> wrote: > How were you calling easy_install? > > On 1/16/06, Shuying <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'm not sure where's t

[Tutor] __iter__

2006-01-16 Thread Christopher Spears
I'm not sure if I understand __iter__. You use it to create an object that iterates through itself using a next menthod ? class Squares: def __init__(self, start, stop): self.value = start - 1 self.stop = stop def __iter__(self): ret

Re: [Tutor] __getitem__

2006-01-16 Thread Christopher Spears
Sorry! X = stepper() X.data = "Spam" --- bob <[EMAIL PROTECTED]> wrote: > At 12:12 PM 1/16/2006, Christopher Spears wrote: > >I understand that you can use __getitem__ as a hook > to > >modify indexing behavoir in a class. That's why > >__getitem__ not only affects [] but also for loops, > >map

Re: [Tutor] __getitem__

2006-01-16 Thread bob
At 12:12 PM 1/16/2006, Christopher Spears wrote: >I understand that you can use __getitem__ as a hook to >modify indexing behavoir in a class. That's why >__getitem__ not only affects [] but also for loops, >map calls, list comprehension, etc. For loops, etc. >work by indexing a sequences from z

[Tutor] __getitem__

2006-01-16 Thread Christopher Spears
I understand that you can use __getitem__ as a hook to modify indexing behavoir in a class. That's why __getitem__ not only affects [] but also for loops, map calls, list comprehension, etc. For loops, etc. work by indexing a sequences from zero to a higher index until out-of-bounds is reached.

Re: [Tutor] Python debugger bummer

2006-01-16 Thread Victor Bouffier
Hi again, I was going through the Python library documentation and I found something I never saw before. $ python -m pdb myscript.py This is what I was looking for! Great help. Any further reference could of course help a lot. I never was able to get the hang of it until now. Victor On Mon,

[Tutor] Python debugger bummer

2006-01-16 Thread Victor Bouffier
Hi to all, I tried to look for a reference to this issue in the ASPN archive, but I can't seem to find an answer. I currently work under Linux and have never been able to properly use the Python debugger. Coming from a Perl background, I fail to find a similar simple way to step through my code t

Re: [Tutor] timeout

2006-01-16 Thread Alan Gauld
> how can I break a loop after a certain amount of time has passed? > with timeout of 60sec: I assume you want the loop to do somerthing until the timeout? If so then the logic is: timeout = now() + 60 while now() < timeout: do something. Using the time module you can easily calculate timeo

Re: [Tutor] tutorials

2006-01-16 Thread Alan Gauld
> Has anyone got an easy way of printing the Python documentation in PDF > format. Its all in HTML and is time consuming to print. You can buy it in paper book form. It's a lot cheaper than trying to print the online stuff page by page! Of course someone else may be paying for the paper in whic

Re: [Tutor] timeout

2006-01-16 Thread Hugo González Monteverde
Hi Frank, > how can I break a loop after a certain amount of time has passed? > If the loop actually does something, I've used time.time() in the past: start_time = time.time() timeout = 60 #seconds while True: do_something() if time.time() - start_time >= timeout: break

Re: [Tutor] tutorials

2006-01-16 Thread Brian van den Broek
catherine curley said unto the world upon 16/01/06 08:26 AM: > Hi > > Has anyone got an easy way of printing the Python documentation in PDF > format. Its all in HTML and is time consuming to print. > > Catherine pdf format is available here: . Best, Bria

[Tutor] PIL, fonts and making images

2006-01-16 Thread Rinzwind
I've been using python wih PIL to create some buttons (automatically inside my program). The following code works and creates a PNG 70x70 with the letter 'p' inside.#!/usr/bin/pythonimport os, sysimport Image, ImageFont, ImageDraw image = Image.new('RGBA',(70,70),(0,0,0))ifo = ImageFont.truetype("a

[Tutor] tutorials

2006-01-16 Thread catherine curley
Hi   Has anyone got an easy way of printing the Python documentation in PDF format.  Its all in HTML and is time consuming to print.   Catherine ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] timeout

2006-01-16 Thread Kent Johnson
If you just want a delay, as your empty loop pseudocode seems to do, use time.sleep() as Wim suggested. If you are processing in a loop and you want to stop processing after a certain amount of time, you could check time.time() each time through the loop and end when the allotted time has elaps

Re: [Tutor] timeout

2006-01-16 Thread Rinzwind
Hello,With the time module and sleep(60)?http://www.python.org/doc/2.3.5/lib/module-datetime.html sleep( secs) Suspend execution for the given number of seconds. The argument may be a floating point number to indicate a more precise sleep time. The actual suspension time may be less than that re

Re: [Tutor] timeout

2006-01-16 Thread frank h.
Hello how can I break a loop after a certain amount of time has passed? pseudocode: with timeout of 60sec: while True: pass is there a simple way? without resorting to queues etc. (this is a bit over my head) thanks for any insight you might have -frank On 1/16/06, frank h. <[E

[Tutor] timeout

2006-01-16 Thread frank h.
Hello how can I break a loop after a certain amount of time has passed? pseudocode: with timeout of 60sec: ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] setuptools question

2006-01-16 Thread Liam Clarke
How were you calling easy_install? On 1/16/06, Shuying <[EMAIL PROTECTED]> wrote: > Hi, > > I'm not sure where's the best place to ask so I thought I'd try it > here. I've got python2.3 and python2.4 installed on my machine and > I'm trying to upgrade setuptools for both versions of python. So I'

Re: [Tutor] Complete programming newbie requires tutorial. (Chris Andrew)

2006-01-16 Thread Liam Clarke
I also highly recommand Alan Gauld's tutorial - http://www.freenetpages.co.uk/hp/alan.gauld/ On 1/16/06, Ron Sheely <[EMAIL PROTECTED]> wrote: > Two things. > > First, I've been watching this list for several weeks now. I wanted to > respond to Chris Andrew's question regarding Python tutorials (