Re: [Tutor] exceptions problem

2010-09-10 Thread Luke Paireepinart
Roleof, do you think you could stop sending HTML messages and use plaintext instead? I usually skip over your posts because your font is so small and hard to read that I don't even bother. If you send plain-text messages (which is the norm on programming mailing lists) then you leave it up to the

Re: [Tutor] Python social network / cms components?

2010-09-10 Thread Steven D'Aprano
On Fri, 10 Sep 2010 05:34:49 am Igor Choromanski wrote: > Hi, > > After much research, I've come up with a list of what I think might > be the best way of putting together a Python based social > network/cms, but have some questions about how some of these > components fit together. This does not

Re: [Tutor] smtp connection problem --- socket error 10061

2010-09-10 Thread goodh...@gmail.com
smtp_ssl does not work for python 2.5. can not even connect. not mention about starttls. On 2010/9/10 19:39, Evert Rol wrote: Do things work when you use SSL or TLS (through SMTP_SSL or using starttls, respectively)? Perhaps Vista is more strict in checking for this when connecting through a

Re: [Tutor] exceptions problem

2010-09-10 Thread bob gailer
On 9/10/2010 2:48 PM, Roelof Wobben wrote: Date: Fri, 10 Sep 2010 20:23:09 +0200 From: f...@libero.it To: tutor@python.org Subject: Re: [Tutor] exceptions problem On 10/09/2010 18.12, Roelof Wobben wrote: > ... > def readposint(): > x = raw_input("Please enter a positive integer :"

Re: [Tutor] smtp connection problem --- socket error 10061

2010-09-10 Thread Evert Rol
> I could not connect with gmail smtp server in Vista 32( worked ok in XP 32). > Both vista and xp have same anti-virus software. > smtplib.SMTP("smtp.gmail.com",587) > > Traceback (most recent call last): > File "", line 1, in >smtplib.SMTP("smtp.gmail.com",587) > File "C:\Program F

Re: [Tutor] Trapping HTTP Authentication Failure

2010-09-10 Thread Evert Rol
> My script to call a web service authenticates. Sorry, but where is the (full) script? I missed an attachment or (preferably) a link. > I would like to be > able to trap an exception if the authentication fails. The script > loops over a list of dates and I don't want it to retry for every

Re: [Tutor] changing list index start

2010-09-10 Thread Lie Ryan
On 09/11/10 07:36, Rance Hall wrote: > I'm using the following function style I found on the net to create > menus for a command line python script: > > It works well, but the first item is the list is item 0. This is > normal in most computing situations, but because this index is part of > the

Re: [Tutor] changing list index start

2010-09-10 Thread Luke Paireepinart
Yeah, just add 1 to it. When printing just do index+1 and when inputting the user's choice, subtract 1 and use it as the array index. Sent from my iPhone On Sep 10, 2010, at 4:36 PM, Rance Hall wrote: > I'm using the following function style I found on the net to create > menus for a command

[Tutor] changing list index start

2010-09-10 Thread Rance Hall
I'm using the following function style I found on the net to create menus for a command line python script: def mainmenu(): # the main menu todolist() mainmenuoptions = ['Clients','Jobs','Billing','Quotes','To Do Items','Employee','Exit'] mainmenucalls = [clientsmenu, jobsmenu, bil

Re: [Tutor] hashlib problems

2010-09-10 Thread Rance Hall
On Fri, Sep 10, 2010 at 3:12 PM, Luke Paireepinart wrote: > In general, you shouldn't even hint at the possibility of there being a bug > in the code unless you have test cases and a patch handy. Especially > something as widely used as hashlib. It  gives An air of arrogance about your > post,

Re: [Tutor] hashlib problems

2010-09-10 Thread Luke Paireepinart
In general, you shouldn't even hint at the possibility of there being a bug in the code unless you have test cases and a patch handy. Especially something as widely used as hashlib. It gives An air of arrogance about your post, whether you intend it or not. I think your issue got resolved alrea

Re: [Tutor] Random list exercise

2010-09-10 Thread lists
>  On 9/10/2010 5:22 AM, lists wrote: >>> >>> you could try random.shuffle and save a lot of time, it takes a mutable >>> sequence (like a list) and shuffles it >> >> Hey there, >> >> For the few exercises I've been doing, I think the author has been >> attempting to make the reader do things 'the

Re: [Tutor] Random list exercise

2010-09-10 Thread Chris King
On 9/10/2010 5:22 AM, lists wrote: you could try random.shuffle and save a lot of time, it takes a mutable sequence (like a list) and shuffles it Hey there, For the few exercises I've been doing, I think the author has been attempting to make the reader do things 'the difficult way' so that th

Re: [Tutor] Random list exercise

2010-09-10 Thread Chris King
On 9/10/2010 5:22 AM, lists wrote: you could try random.shuffle and save a lot of time, it takes a mutable sequence (like a list) and shuffles it Hey there, For the few exercises I've been doing, I think the author has been attempting to make the reader do things 'the difficult way' so that th

Re: [Tutor] hashlib problems

2010-09-10 Thread Dave Angel
On 2:59 PM, Rance Hall wrote: Im wanting to use the builtin hashlib functions to encrypt passwords before storing them in a database. According to documentation on the python.org site it should be as simple as import hashlib hashname = hashlib.sha234 (or whatever other hash method you want

[Tutor] Trapping HTTP Authentication Failure

2010-09-10 Thread Michael Powe
Hello, My script to call a web service authenticates. I would like to be able to trap an exception if the authentication fails. The script loops over a list of dates and I don't want it to retry for every element in the list. This could take a long time and be very annoying when, after the long

Re: [Tutor] exceptions problem

2010-09-10 Thread Roelof Wobben
Date: Fri, 10 Sep 2010 20:23:09 +0200 From: f...@libero.it To: tutor@python.org Subject: Re: [Tutor] exceptions problem On 10/09/2010 18.12, Roelof Wobben wrote: > ... > def readposint(): > x = raw_input("Please enter a positive integer :") > try: > if not (x == i

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 04:42:35PM +0200, Peter Otten wrote: > Michael Powe wrote: > > On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: > >> Michael Powe wrote: > >> > I can't work out how to suppress stacktrace printing when exceptions > >> > are thrown. > >> WRONG: > >> > >> >>>

Re: [Tutor] hashlib problems

2010-09-10 Thread Peter Otten
Rance Hall wrote: > Im wanting to use the builtin hashlib functions to encrypt passwords > before storing them in a database. > > According to documentation on the python.org site it should be as simple > as > > import hashlib > > hashname = hashlib.sha234 (or whatever other hash method you wa

Re: [Tutor] exceptions problem

2010-09-10 Thread Francesco Loffredo
On 10/09/2010 18.12, Roelof Wobben wrote: ... def readposint(): x = raw_input("Please enter a positive integer :") try: if not (x == int(x) and x< 0): raise(ValueError) except: print x , "is not a positive integer.Try again."

[Tutor] smtp connection problem --- socket error 10061

2010-09-10 Thread goodh...@gmail.com
I could not connect with gmail smtp server in Vista 32( worked ok in XP 32). Both vista and xp have same anti-virus software. smtplib.SMTP("smtp.gmail.com",587) Traceback (most recent call last): File "", line 1, in smtplib.SMTP("smtp.gmail.com",587) File "C:\Program Files\Python25\

[Tutor] hashlib problems

2010-09-10 Thread Rance Hall
Im wanting to use the builtin hashlib functions to encrypt passwords before storing them in a database. According to documentation on the python.org site it should be as simple as import hashlib hashname = hashlib.sha234 (or whatever other hash method you want like md5 or whatever) hashname.up

Re: [Tutor] exceptions problem

2010-09-10 Thread Roelof Wobben
From: rwob...@hotmail.com To: tutor@python.org Date: Fri, 10 Sep 2010 16:12:08 + Subject: Re: [Tutor] exceptions problem Date: Fri, 10 Sep 2010 18:07:13 +0200 From: f...@libero.it To: tutor@python.org Subject: Re: [Tutor] exceptions problem Oops, I sent this to Roelof... Ok, I mus

Re: [Tutor] exceptions problem

2010-09-10 Thread Roelof Wobben
Date: Fri, 10 Sep 2010 18:07:13 +0200 From: f...@libero.it To: tutor@python.org Subject: Re: [Tutor] exceptions problem Oops, I sent this to Roelof... Ok, I must amend it anyway... On 10/09/2010 17.13, Roelof Wobben wrote: > ... > def readposint(): > x = raw_input("Please enter a pos

Re: [Tutor] exceptions problem

2010-09-10 Thread Francesco Loffredo
Oops, I sent this to Roelof... Ok, I must amend it anyway... On 10/09/2010 17.13, Roelof Wobben wrote: ... def readposint(): x = raw_input("Please enter a positive integer :") try: x = int(x) and x> 0 except: print x , "is not a positive i

Re: [Tutor] exceptions problem

2010-09-10 Thread Dave Angel
On 2:59 PM, Roelof Wobben wrote: Now I thought this would work:def readposint(): x = raw_input("Please enter a positive integer :") try: x = int(x) and x> 0 except: print x , "is not a positive integer. Try again." return False return Truey = rea

[Tutor] exceptions problem

2010-09-10 Thread Roelof Wobben
Hello, I have this problem : Write a function named readposint that prompts the user for a positive integer and then checks the input to confirm that it meets the requirements. A sample session might look like this: >>> num = readposint() Please enter a positive integer: yes yes is not

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Peter Otten
Michael Powe wrote: > On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: >> Michael Powe wrote: >> >> > I can't work out how to suppress stacktrace printing when exceptions >> > are thrown. >> >> [snip rant] >> >> It might have been a good idea to read a tutorial like >> >> http://do

[Tutor] classmethod, staticmethod functions (decorator related)

2010-09-10 Thread Huy Ton That
I am reading the decorator section within Expert Python Programming and I am very confused in the first example, of a method that was done before decorators. It reads: class WhatFor(object): def it(cls): print 'work with %s' % cls it = classmethod(it) def uncommon(): pr

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 03:50:57PM +0200, Evert Rol wrote: > This is a bit of a guess, but as far as I know, you can catch exceptions like > that. > Try: > try: > data = opener.open(url) > except urllib2.URLError as msg: > print msg > sys.exit(1) > If you're using an older versio

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Evert Rol
>>> I can't work out how to suppress stacktrace printing when exceptions >>> are thrown. >> >> [snip rant] >> >> It might have been a good idea to read a tutorial like >> >> http://docs.python.org/tutorial/errors.html#handling-exceptions > >> or ask before you got annoyed enough to write that r

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: > Michael Powe wrote: > > > I can't work out how to suppress stacktrace printing when exceptions > > are thrown. > > [snip rant] > > It might have been a good idea to read a tutorial like > > http://docs.python.org/tutorial/errors.htm

Re: [Tutor] design question

2010-09-10 Thread Albert-Jan Roskam
Hi Jan, Here's a screendump of my program: http://nl.tinypic.com/r/2qtlojc/7 . This might make my description a little bit clearer. The beautiful sunset will in reality be a dull, handwritten form. ;-) Regarding the iterator pattern, I was referring to this: http://www.suttoncourtenay.org.uk/d

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Peter Otten
Michael Powe wrote: > I can't work out how to suppress stacktrace printing when exceptions > are thrown. [snip rant] It might have been a good idea to read a tutorial like http://docs.python.org/tutorial/errors.html#handling-exceptions or ask before you got annoyed enough to write that rant ;)

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Evert Rol
> I can't work out how to suppress stacktrace printing when exceptions > are thrown. > > I want the thrown exception to pass a message on the console, just > like Java does when I catch an exception and print e.getMessage(). > > I tried some of the examples of controlling traceback through the >

Re: [Tutor] design question

2010-09-10 Thread Knacktus
Am 10.09.2010 11:23, schrieb Albert-Jan Roskam: Hi, I've made a small data entry program where a picture of a hand-written, scanned form is shown next to several text entries. The design has been largely 'bottom up', although of course I started with a rough sketch. I started with the following

[Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
Hello, I can't work out how to suppress stacktrace printing when exceptions are thrown. I want the thrown exception to pass a message on the console, just like Java does when I catch an exception and print e.getMessage(). I tried some of the examples of controlling traceback through the tracebac

Re: [Tutor] recursive problem

2010-09-10 Thread Ewald Horn
On 10 September 2010 13:14, Roelof Wobben wrote: > Hello , > > So my book teach me the wrong principle. > But can everything programmed on Eafp. > > If you dont know if something is a list, a tuple or a string, you can get a > lot of nested try except think. > > Roelof > Hi Roelof, I don't thi

Re: [Tutor] recursive problem

2010-09-10 Thread Roelof Wobben
Hello , So my book teach me the wrong principle. But can everything programmed on Eafp. If you dont know if something is a list, a tuple or a string, you can get a lot of nested try except think. Roelof Subject: Re: [Tutor] recursive problem From: rabidpoob...@gmail.com Date:

[Tutor] Random list exercise

2010-09-10 Thread lists
Ooops, I forgot to send to the list too! -- Forwarded message -- From: lists Date: Fri, Sep 10, 2010 at 10:22 AM Subject: Re: [Tutor] Random list exercise To: Christopher King > you could try random.shuffle and save a lot of time, it takes a mutable > sequence (like a list) and

[Tutor] design question

2010-09-10 Thread Albert-Jan Roskam
Hi, I've made a small data entry program where a picture of a hand-written, scanned form is shown next to several text entries. The design has been largely 'bottom up', although of course I started with a rough sketch. I started with the following classes: Menu (responsible for the widget creat