Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
To further document some points. This comes from PEP 8 (http://www.python.org/dev/peps/pep-0008/) For those who need "authority" : Author: Guido van Rossum , Barry Warsaw """ With this in mind, here are the Pythonic guidelines: - Public attributes should have no leading underscores.

Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
Tiger12506 wrote: >>> This is all fine and dandy, but the video game is pretty worthless unless >>> it >>> can show us what the score is. There are two ways to go about this. A) >>> Give >>> the video game a display which it updates, or B) Tear open the case of >>> the >>> video game and look at

Re: [Tutor] Closing file objects when object is garbage collected?

2008-02-12 Thread Tiger12506
> I'm having issues when I test my software on XP, but not Linux. When I > run the progam it fails after running for a while but not at exactly > the same point each time. It fails in one of two ways, the user > interface either completely disappears, or gives a OS error message > unhanded exceptio

Re: [Tutor] designing POOP

2008-02-12 Thread Tiger12506
>> This is all fine and dandy, but the video game is pretty worthless unless >> it >> can show us what the score is. There are two ways to go about this. A) >> Give >> the video game a display which it updates, or B) Tear open the case of >> the >> video game and look at the actual gears that in

Re: [Tutor] opening a pipe?

2008-02-12 Thread Poor Yorick
> From: James Hartley <> > Subject: [Tutor] opening a pipe? > Sent: 2008-02-12 09:24 > > A Perl script can easily serve as a filter within a pipe as seen in > the following: > > use strict; > use warnings; > > open(IN, 'cat hello.txt |') or die 'unable to open file'; > while () { >

[Tutor] Mail revisited

2008-02-12 Thread Ricardo Aráoz
Ok, so I've started the path to put a GUI to the "MandarMails.py" program. For starters I've included a progress bar. Any enhancements you may suggest will be appreciated. Note: not tested yet ## ### MandarMails.py ### ## #!/usr/bin/env python import time

Re: [Tutor] Closing file objects when object is garbage collected?

2008-02-12 Thread Michael Langford
> How do I ensure that when an object is deleted by the garbage > collector that the file objects contained within the object are > closed, or collected by the garbage collector? __del__ is called after the reference count gets to zero for an object. You can explicitly call close on the file there

Re: [Tutor] How to Set python path

2008-02-12 Thread Michael Langford
Show us both path statements, then we might be able to fix it. --Michael On Feb 12, 2008 2:01 AM, Narain <[EMAIL PROTECTED]> wrote: > > > Hi, > > Iam facing problems in Environment variables for python path as > follows > >Iam using Windows XP operating system in system v

Re: [Tutor] How to Set python path

2008-02-12 Thread Narain
Hi, Iam facing problems in Environment variables for python path as follows >Iam using Windows XP operating system in system variable iam appending two path,in this case only first path is working but second path is not working,if i remove first path means second path is w

Re: [Tutor] opening a pipe?

2008-02-12 Thread Thomas Pani
The subprocess module is what you're looking for. Your example would look like %< import subprocess p = subprocess.Popen('cat hi.txt', shell=True, stdout=subprocess.PIPE) for line in p.stdout: print line %< I ass

Re: [Tutor] Closing file objects when object is garbage collected?

2008-02-12 Thread bob gailer
Wesley Brooks wrote: > Dear Python Users, > > How do I ensure that when an object is deleted by the garbage > collector that the file objects contained within the object are > closed, or collected by the garbage collector? > When there are no more references to a file object the file is closed.

Re: [Tutor] designing POOP

2008-02-12 Thread bhaaluu
On Feb 12, 2008 7:19 AM, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: > > Did we think about REUSABILITY? What if in some other application I want > to USE the score, not just display it? What if I want to display it in a > different form (multiplying it by 100)? Then you are back to our > original opt

Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
Tiger12506 wrote: > This is all fine and dandy, but the video game is pretty worthless unless it > can show us what the score is. There are two ways to go about this. A) Give > the video game a display which it updates, or B) Tear open the case of the > video game and look at the actual gears t

Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
Tiger12506 wrote: > This is all fine and dandy, but the video game is pretty worthless unless it > can show us what the score is. There are two ways to go about this. A) Give > the video game a display which it updates, or B) Tear open the case of the > video game and look at the actual gears t

Re: [Tutor] Change dictionary value depending on a conditional statement.

2008-02-12 Thread Norman Khine
Thank you all, very nice. Steve Willoughby wrote: > Kent Johnson wrote: >> Try >>list.append({'id': 'name', 'link': ('YY','XX')[total > 0]}) > > I'd caution against that, though. It's clever and cute, sure, but the > meaning of it is obfuscated enough to be unpythonic because [total > 0] >

[Tutor] opening a pipe?

2008-02-12 Thread James Hartley
A Perl script can easily serve as a filter within a pipe as seen in the following: use strict; use warnings; open(IN, 'cat hello.txt |') or die 'unable to open file'; while () { print; } close(IN); Can I do the same within Python? Thanks. Jim ___

Re: [Tutor] designing POOP

2008-02-12 Thread Alan Gauld
"Tiger12506" <[EMAIL PROTECTED]> wrote > Well, I don't know if this whole email was of use, but it makes the > crux of > the argument make sense to me. I thought it was pretty clear. And it highlights that the choices are like anything else in the world of engineering - a compromise. And the be

[Tutor] Closing file objects when object is garbage collected?

2008-02-12 Thread Wesley Brooks
Dear Python Users, How do I ensure that when an object is deleted by the garbage collector that the file objects contained within the object are closed, or collected by the garbage collector? I'd like to avoid having to read the whole file object into a string and close the file immediately becau