[Tutor] OT: just venting

2010-08-23 Thread Justin Ezequiel
when some IS/IT--Management guy asks about " Eval() or compile on fly with object" and you try to talk him out of that bad idea, he replies, "...it's much more easier, but that's not the way i want it" LOL. typical management. ___ Tutor maillist - Tuto

Re: [Tutor] continuous running of a method

2010-08-23 Thread bob gailer
On 8/23/2010 1:00 AM, Greg Bair wrote: I have a method (I'll call it foo) that will either return None or an object depending on a random value generated. What I want to happen is that if I call foo(), i.e, f = foo() and it returns None, to re-call it until it returns something else. I would

[Tutor] Adding all numbers in a file or list

2010-08-23 Thread aug dawg
Is there a command or module that I can use to add all the items in a list? Alternatively, is there one I can use to add all the numbers in a file? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.o

Re: [Tutor] Adding all numbers in a file or list

2010-08-23 Thread Sander Sweers
On 23 August 2010 17:13, aug dawg wrote: > Is there a command or module that I can use to add all the items in a list? > Alternatively, is there one I can use to add all the numbers in a file? sum() is what you are looking for [1]. Greets Sander [1] http://docs.python.org/library/functions.html

Re: [Tutor] Elementtree and pretty printing in Python 2.7

2010-08-23 Thread Karim
Hello Jerry, Tricky solution using minidom (standard) Not tested: import ElementTree import minidom def prettyPrint(element): txt = ElementTree.tostring(element) print minidom.parseString(txt).toprettyxml() Regards Karim On 08/22/2010 04:51 PM, Jerry Hill wrote: On Fri, Aug 20, 2010

Re: [Tutor] Adding all numbers in a file or list

2010-08-23 Thread Sander Sweers
On 23 August 2010 17:24, aug dawg wrote: > So it's sum(list_name) ? Correct, but it is not limited to lists. Any itterable with ints/floats will do, for example a tuple is also accepted. Greets Sander PS: Please use reply to all so others on this list may benefit from the questions/answers ;-)

Re: [Tutor] Adding all numbers in a file or list

2010-08-23 Thread aug dawg
Oh okay, sorry about that. Thanks for the help! On Mon, Aug 23, 2010 at 11:33 AM, Sander Sweers wrote: > On 23 August 2010 17:24, aug dawg wrote: > > So it's sum(list_name) ? > > Correct, but it is not limited to lists. Any itterable with > ints/floats will do, for example a tuple is also acce

Re: [Tutor] design of Point class

2010-08-23 Thread Gregory, Matthew
Bob Gailer wrote: > class PointND(list): >def __init__(self, *a_list): > super(PointND, self).__init__(a_list) > >def getSet(ix): > def chklen(self): >if len(self) < ix + 1: > raise AttributeError > def get(self): >chklen(self) >return self[i

Re: [Tutor] design of Point class

2010-08-23 Thread Gregory, Matthew
Hi Steven, Steven D'Aprano wrote: > Every time you change the interface of inherited methods, you probably > shouldn't. > > Firstly, it probably breaks the Liskov Substitution Principle. The LSP > says, essentially, if you subclass A to make B, you should be able to > use a B anywhere you can use

Re: [Tutor] design of Point class

2010-08-23 Thread bob gailer
On 8/23/2010 1:09 PM, Gregory, Matthew wrote: Bob Gailer wrote: class PointND(list): def __init__(self, *a_list): super(PointND, self).__init__(a_list) def getSet(ix): def chklen(self): if len(self)< ix + 1: raise AttributeError def get(self):

Re: [Tutor] design of Point class

2010-08-23 Thread Gregory, Matthew
Steven D'Aprano wrote: > It would surprise me greatly if numpy didn't already have such a class. Yes, that is the first place I went looking, but I couldn't find such a class. I found one project using numpy for geometry objects (geometry-simple, http://code.google.com/p/geometry-simple/), but

Re: [Tutor] design of Point class

2010-08-23 Thread bob gailer
I am happier with this: class PointND(list, object): def __init__(self, *a_list): super(PointND, self).__init__(a_list) self.maxIndex = len(self) - 1 def getSet(ix, attName): msg = "'%s' object has no attribute '%s'" % (p.__class__.__name__, attName) def get(self):

Re: [Tutor] design of Point class

2010-08-23 Thread Steven
On Tue, 24 Aug 2010 04:36:31 am Gregory, Matthew wrote: > I'm curious as to why immutability would be an > advantage here (or maybe that's not what you're suggesting). Immutability is *always* an advantage for numeric types. You can use immutable objects as keys in dicts. You can (if you want)

Re: [Tutor] design of Point class

2010-08-23 Thread Alan Gauld
"Gregory, Matthew" wrote class Vehicle: def start(self, key): def go(self, key): class Truck(Vehicle): # add other truck-like methods class KeylessTruck(Truck): # Some military vehicles are designed to not require keys. Aside: Most modern high-end cars are keyless too! ;-)

Re: [Tutor] box drawing characters

2010-08-23 Thread Bill Allen
On Wed, Aug 18, 2010 at 2:13 PM, Bill Allen wrote: > > "Ewald Horn" wrote in message >> news:aanlktinmkzyxbd0t7rldyexhbanw1tnfzac5z2gee...@mail.gmail.com... >> >> Hi Bill, >>> >>> have you given UniCurses a spin? >>> >>> See http://pyunicurses.sourceforge.net/ for more information. >>> >>> >> T

Re: [Tutor] box drawing characters

2010-08-23 Thread M. Milanuk
On 8/23/2010 8:35 PM, Bill Allen wrote: > I did finally have a chance to give this a try. Seems to work as it > should. Users should read the installation instructions carefully, > particularly if installing on a Windows system as the additional > PDCurses library (pdcurses.dll) is also requir