Re: [Tutor] Code to open a website

2013-02-10 Thread ALAN GAULD
>site.py adds the exit/quit Quitter instances to builtins (2.x >__builtin__). When called they raise SystemExit, like sys.exit does. So it does. You learn something new every day... When did that first happen? It was one of my biggest frustrations  with Python when I first started learning, that

Re: [Tutor] Code to open a website

2013-02-10 Thread Albert-Jan Roskam
> On Sat, Feb 9, 2013 at 8:33 PM, Alan Gauld > wrote: >> >> Where does exit() come from? Usually its from sys but you >> don't import from sys anywhere... > > site.py adds the exit/quit Quitter instances to builtins (2.x > __builtin__). When called they raise SystemExit, like sys.exit does

Re: [Tutor] Code to open a website

2013-02-10 Thread ALAN GAULD
> Maybe the OP meant to say 'quit()' ? That does not require an import. Ooh! another option I didn't know about! So many ways to get rid of Python and here's me been importing sys  or raising SystemExit all these years... :-) Alan G. ___ Tutor mailli

Re: [Tutor] Code to open a website

2013-02-10 Thread Peter Otten
ALAN GAULD wrote: >> Maybe the OP meant to say 'quit()' ? That does not require an import. > > > Ooh! another option I didn't know about! > So many ways to get rid of Python and here's me been importing sys > or raising SystemExit all these years... :-) I tend to use none of these and my script

Re: [Tutor] Code to open a website

2013-02-10 Thread eryksun
On Sun, Feb 10, 2013 at 3:39 AM, ALAN GAULD wrote: > So it does. You learn something new every day... > When did that first happen? It was one of my biggest frustrations > with Python when I first started learning, that you couldn't call exit > without first importing sys (v1.3). But I never notic

[Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Walter Prins
Hello, I have a program where I'm overriding the retrieval of items from a list. As background: The data held by the lists are calculated but then read potentially many times thereafter, so in order to prevent needless re-calculating the same value over and over, and to remove checking/caching co

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Dave Angel
On 02/10/2013 09:32 AM, Walter Prins wrote: Hello, I have a program where I'm overriding the retrieval of items from a list. As background: The data held by the lists are calculated but then read potentially many times thereafter, so in order to prevent needless re-calculating the same value o

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Steven D'Aprano
On 11/02/13 01:32, Walter Prins wrote: Hello, I have a program where I'm overriding the retrieval of items from a list. As background: [...snip interesting but irrelevant background...] Here's a test application that demonstrates the issue: [...snip overly complicated application...] Her

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Peter Otten
Walter Prins wrote: > Hello, > > I have a program where I'm overriding the retrieval of items from a list. > As background: The data held by the lists are calculated but then read > potentially many times thereafter, so in order to prevent needless > re-calculating the same value over and over,

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Dave Angel
On 02/10/2013 10:10 AM, Dave Angel wrote: On 02/10/2013 09:32 AM, Walter Prins wrote: Hello, I have a program where I'm overriding the retrieval of items from a list. As background: The data held by the lists are calculated but then read potentially many times thereafter, so in order to preve

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Peter Otten
Peter Otten wrote: > def __iter__(self): > for i in range(len(self)): > return self[i] That should of course be 'yield', not 'return' ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pytho

Re: [Tutor] Which pip for Ubuntu 12.04

2013-02-10 Thread Jim Byrnes
On 02/09/2013 05:46 AM, Albert-Jan Roskam wrote: - Original Message - From: Jim Byrnes To: tutor@python.org Cc: Sent: Saturday, February 9, 2013 3:02 AM Subject: [Tutor] Which pip for Ubuntu 12.04 How important is it to have the latest pip installed? Initially I want to use it to ins

[Tutor] AUTO: David J Pearson Is Attending An IBM Redbook residency (returning 19/02/2013)

2013-02-10 Thread David J Pearson
I am out of the office until 19/02/2013. I am attending an IBM Redbook residency in Raleigh, NC, USA ... and have limited access to my mail. My response to your email will be delayed during this time. Thanks David J Pearson MBCS CITP CEng MIET Technical Staff Member Solution Architect [Mobile,

Re: [Tutor] Which pip for Ubuntu 12.04

2013-02-10 Thread Timo
Op 10-02-13 17:01, Jim Byrnes schreef: On 02/09/2013 05:46 AM, Albert-Jan Roskam wrote: - Original Message - From: Jim Byrnes To: tutor@python.org Cc: Sent: Saturday, February 9, 2013 3:02 AM Subject: [Tutor] Which pip for Ubuntu 12.04 How important is it to have the latest pip insta

Re: [Tutor] Which pip for Ubuntu 12.04

2013-02-10 Thread Joel Goldstick
On Sun, Feb 10, 2013 at 1:53 PM, Timo wrote: > Op 10-02-13 17:01, Jim Byrnes schreef: > > On 02/09/2013 05:46 AM, Albert-Jan Roskam wrote: >> >>> - Original Message - >>> >>> From: Jim Byrnes To: tutor@python.org Cc: Sent: Saturday, February 9, 2013 3:02 AM Subject: [Tutor] Which

[Tutor] Additional help

2013-02-10 Thread Ghadir Ghasemi
Hi guys, I wondered if you knew what I could add to this code so that when the user enters 1 from the menu and then doesn't enter a valid binary number the program should ask them over and over again until valid binary number is entered. here is the code: def show_menu(): print("==

Re: [Tutor] Additional help

2013-02-10 Thread Brian van den Broek
On 10 February 2013 15:29, Ghadir Ghasemi wrote: > Hi guys, I wondered if you knew what I could add to this code so that when > the user enters 1 from the menu and then doesn't enter a valid binary number > the program should ask them over and over again until valid binary number is > entered.

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Oscar Benjamin
On 10 February 2013 14:32, Walter Prins wrote: [snip > > This worked mostly fine, however yesterday I ran into a slightly unexpected > problem when I found that when the list contents is iterated over and values > retrieved that way rather than via [], then __getitem__ is in fact *not* > called on

Re: [Tutor] Which pip for Ubuntu 12.04

2013-02-10 Thread James Reynolds
The bigger issue with mongo is the apt versions are old. Be sure to follow the instructions on mongos site. If you pip install pymongo with a ubunuto or mint build your gtg ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] binary - denary converter (was Additional help)

2013-02-10 Thread bob gailer
I am changing the subject line to one that is more explicit. On 2/10/2013 3:29 PM, Ghadir Ghasemi wrote: elif choice not in '1' or '2' or '3': print("Invalid input-try again!") This works, but not for the reasons you had in mind. For experiment, try: >>> '1' or '2' or '3' '1' >

Re: [Tutor] Code to open a website

2013-02-10 Thread Steven D'Aprano
On 10/02/13 20:25, ALAN GAULD wrote: Maybe the OP meant to say 'quit()' ? That does not require an import. Ooh! another option I didn't know about! So many ways to get rid of Python and here's me been importing sys or raising SystemExit all these years... :-) exit() and quit() (as added

Re: [Tutor] Which pip for Ubuntu 12.04

2013-02-10 Thread eryksun
On Sun, Feb 10, 2013 at 1:53 PM, Timo wrote: >> However, I still wonder if using the outdated pip from the repository will >> allow me to install the latest python packages? Will trying to use an >> outdated pip cause me problems? > > I doubt it will. Have a look at the pip changelog to see what h

Re: [Tutor] How to log process handles and GDI objects in python

2013-02-10 Thread Pai, Yogesh M
Hi Alan, Here are the additional details: Python version: 2.7.3 OS version: Windows 7 -64 bit I have an application that has a automation layer built in python. During every subsequent runs, I want to log the process threads and GDI objects ( the one you see in the Windows task manager) in my p

[Tutor] associating two objects without ORM and processing a text file

2013-02-10 Thread neubyr
I have a text file with each line in following format: Book Name, Author Name, Genre, Publication Date I would like to perform following queries on this file: * Get all books written by an author * Remove all books of an author * Get information about a book (pretty print matching line!) * Ge

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-10 Thread Mitya Sirenef
On 02/11/2013 12:14 AM, neubyr wrote: > I have a text file with each line in following format: > > Book Name, Author Name, Genre, Publication Date > > I would like to perform following queries on this file: > * Get all books written by an author > * Remove all books of an author > * Get informa

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-10 Thread Dave Angel
On 02/11/2013 12:14 AM, neubyr wrote: I have a text file with each line in following format: Book Name, Author Name, Genre, Publication Date I would like to perform following queries on this file: * Get all books written by an author * Remove all books of an author * Get information about