Re: [Tutor] A little Tkinter question

2004-12-15 Thread Gregor Lingl
Gregor Lingl schrieb: Marilyn Davis schrieb: Hi Tutors, I'm reviewing GUIs and wondering: When you pack a component, and you specify fill = BOTH, how is this different from expand = YES? Hi Marilyn, This is a bit tricky and hard to explain, so I recommend playing around with this little program

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Liam Clarke
Alright, so that was a quick example, but >return not x % 2 A light dawns. On Thu, 16 Dec 2004 15:58:38 +0900, Guillermo Fernandez Castellanos <[EMAIL PROTECTED]> wrote: > Well... > > > I find multiple returns to be rather useful > > def isOdd(x): > > if not x % 2: return False > >

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Liam Clarke
I find multiple returns to be rather useful - def isOdd(x): if not x % 2: return False return True On Thu, 16 Dec 2004 01:06:58 -0500, Brian van den Broek <[EMAIL PROTECTED]> wrote: > [Brian van den Broek] > > complicated with:> > > >>import datetime > >>def is_leap_year(year): > >>'''

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Brian van den Broek
[Brian van den Broek] import datetime def is_leap_year(year): '''-> boolean Returns True or False as year is, or is not, a leap year. ''' is_leap = True try: datetime.date(year, 2, 29) except ValueError: is_leap = False return is_leap Kent Johnson said unto the

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Bob Gailer
At 09:14 PM 12/15/2004, Tim Peters wrote: [Brian van den Broek] > in Marc's check_range thread, I had proposed: > > def check_in_range(value): > > in_range = False > if 9 < value < 90: > in_range = True > return in_range > > and DogWalker suggested the better: > > def check_in_r

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Tim Peters
[Brian van den Broek] > in Marc's check_range thread, I had proposed: > > def check_in_range(value): > > in_range = False > if 9 < value < 90: > in_range = True > return in_range > > and DogWalker suggested the better: > > def check_in_range(value): > return 9 < value < 90

Re: [Tutor] AttributeError: instance has no __call__ method

2004-12-15 Thread Marc Gartler
That did it. Thanks, Max. On Wednesday, December 15, 2004, at 09:28 PM, Max Noel wrote: On Dec 16, 2004, at 04:20, Max Noel wrote: def glass_type(glasstype): if glasstype == 'Red': myglass = RedGlassCost() elif glasstype == 'Blue': myglass = BlueGla

Re: [Tutor] AttributeError: instance has no __call__ method

2004-12-15 Thread Marc Gartler
# --superclass-- class FrameCost: def __init__(self): self.width = int(0) self.length = int(0) # Calculate cost per square foot def Cost_per_sqft(self, cost): return (((self.width) * (self.length) / 144.00) * (cost)) # Calculate cost per linear foot def Cost_per_ft(self, cost): r

Re: [Tutor] AttributeError: instance has no __call__ method

2004-12-15 Thread Max Noel
On Dec 16, 2004, at 04:20, Max Noel wrote: def glass_type(glasstype): if glasstype == 'Red': myglass = RedGlassCost() elif glasstype == 'Blue': myglass = BlueGlassCost() elif glasstype == 'Yellow': myglass = YellowGlassCost()

Re: [Tutor] AttributeError: instance has no __call__ method

2004-12-15 Thread Max Noel
On Dec 16, 2004, at 03:56, Marc Gartler wrote: Hi everybody, Prior to this chunk of code 'glass' has been chosen from a list of colors via user input, and I now want to have that choice connect to one of several possible classes: def glass_type(glasstype): if glasstype == 'Red':

Re: [Tutor] AttributeError: instance has no __call__ method

2004-12-15 Thread Terry Carroll
On Wed, 15 Dec 2004, Marc Gartler wrote: > Hi everybody, > > Prior to this chunk of code 'glass' has been chosen from a list of > colors via user input, and I now want to have that choice connect to > one of several possible classes: > > def glass_type(glasstype): > if glasstype == 'Red'

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread Orri Ganel
On Wed, 15 Dec 2004 20:40:40 -0500, R. Alan Monroe <[EMAIL PROTECTED]> wrote: > > print "0x%0X" % 12345 > > > displays > > 0x3039 > > > instead of 0x03039 > > > >>> "%05x" % (12345,) > '03039' > > >>> "0x%05x" % (12345,) > '0x03039' > > ___ > Tutor

Re: [Tutor] Complex roots

2004-12-15 Thread Dick Moores
Alan Gauld wrote at 09:25 12/12/2004: > Are these "numerical approximation methods" pythonically possible? > Yes and that's how they are normally found - not necessarily with Python, but by applying computer simulations of the equations. Generally you calculate values in ever decreasing increments

[Tutor] AttributeError: instance has no __call__ method

2004-12-15 Thread Marc Gartler
Hi everybody, Prior to this chunk of code 'glass' has been chosen from a list of colors via user input, and I now want to have that choice connect to one of several possible classes: def glass_type(glasstype): if glasstype == 'Red': myglass = RedGlassCost() elif g

Re: [Tutor] dbcp module

2004-12-15 Thread Kent Johnson
Googling for 'python dbcp' turns up this recipe, is this what you are looking for? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81189 Kent Rene Bourgoin wrote: Anyone know where I can download the dbcp module for Python ___ No banners. N

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread Bob Gailer
At 06:47 PM 12/15/2004, Tony Cappellini wrote: I'm trying to get Python to automatically print a leading 0 for hex numbers, but it only seems to work for for decimal numbers. Oh? print "%0d" % 12345 gives me 12345 - no leading 0 print "0x%0X" % 12345 displays 0x3039 which it should instead of 0x030

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread Orri Ganel
On Wed, 15 Dec 2004 17:47:58 -0800 (PST), Tony Cappellini <[EMAIL PROTECTED]> wrote: > > I'm trying to get Python to automatically print a leading 0 for hex > numbers, but it only > seems to work for for decimal numbers. > > print "0x%0X" % 12345 > > displays > 0x3039 > > instead of 0x03039 >

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread R. Alan Monroe
> print "0x%0X" % 12345 > displays > 0x3039 > instead of 0x03039 >>> "%05x" % (12345,) '03039' >>> "0x%05x" % (12345,) '0x03039' ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] OT?: how to google just the 2.4 tutorial?

2004-12-15 Thread Dick Moores
Just got this reply from [EMAIL PROTECTED] --Dick Regrettably, we don't currently offer a way to limit your search to a specific section of a site. We really appreciate your thoughtful feedback, and we'll keep it in mind as we work to improve Google. Regards, The Google Team Dick Moores wrote at

[Tutor] Leading zero for hex numbers

2004-12-15 Thread Tony Cappellini
I'm trying to get Python to automatically print a leading 0 for hex numbers, but it only seems to work for for decimal numbers. print "0x%0X" % 12345 displays 0x3039 instead of 0x03039 The Python docs state The conversion will be zero padded for numeric values, when a 0 is used as a flag betw

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Kent Johnson
Brian van den Broek wrote: I've begun to wonder if I am overlooking a improvement similar to that in DogWalker's suggestion. As an example of the sort of thing I have been doing: import datetime def is_leap_year(year): '''-> boolean Returns True or False as year is, or is not, a leap yea

[Tutor] dbcp module

2004-12-15 Thread Rene Bourgoin
Anyone know where I can download the dbcp module for Python ___ No banners. No pop-ups. No kidding. Make My Way your home on the Web - http://www.myway.com ___ Tutor maillist - [EMAIL PROTECTED] htt

[Tutor] am I missing another simpler structure?

2004-12-15 Thread Brian van den Broek
Hi all, in Marc's check_range thread, I had proposed: def check_in_range(value): in_range = False if 9 < value < 90: in_range = True return in_range and DogWalker suggested the better: def check_in_range(value): return 9 < value < 90 As I mentioned, I feel as though I have a

[Tutor] Python structure advice ?

2004-12-15 Thread Dave S
Im sorry to bang on about Python structure, but I do struggle with it, having in the past got into very bad habits with loads of BASIC where everything was global, and Forth, and hand coded 8031, 8051, 6502 I cant get my head round how you guys handle a modern structured language :-) (PS

Re: [Tutor] A little Tkinter question

2004-12-15 Thread Gregor Lingl
Marilyn Davis schrieb: Hi Tutors, I'm reviewing GUIs and wondering: When you pack a component, and you specify fill = BOTH, how is this different from expand = YES? Hi Marilyn, This is a bit tricky and hard to explain, so I recommend playing around with this little program from John Grayson's Tki

[Tutor] A little Tkinter question

2004-12-15 Thread Marilyn Davis
Hi Tutors, I'm reviewing GUIs and wondering: When you pack a component, and you specify fill = BOTH, how is this different from expand = YES? Thank you for any insight. Marilyn Davis ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/ma

RE: [Tutor] turning a number into a formated string

2004-12-15 Thread Ertl, John
Very elegant, It makes me feel like "I should have thought of that". Thanks for the help and the reminder to think of the simplistic approach. John -Original Message- From: Tim Peters [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 15, 2004 12:15 To: Ertl, John Cc: tutor-list (Pytho

Re: [Tutor] turning a number into a formated string

2004-12-15 Thread Marilyn Davis
On Wed, 15 Dec 2004, Tim Peters wrote: > ... return ("%09.4f" % n).replace('.', '') Totally cool. Marilyn ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] turning a number into a formated string

2004-12-15 Thread Tim Peters
[Ertl, John] > I need to take a number and turn it into a formatted string. > The final output needs to look like when the X is the > integer part padded on the left and Y is the decimal part padded > on the right. > I figured I could split the number at "." and then use zfill or > some

Re: [Tutor] turning a number into a formated string

2004-12-15 Thread Marilyn Davis
Here's one way: left, right = str(number).split('.') output = "%04d%d" % (int(left), int(right)) + (4 - len(right)) * '0' Maybe someone has a more elegant way. Hope it helps, Marilyn Davis On Wed, 15 Dec 2004, Ertl, John wrote: > I need to take a number and turn it into a formatted string.

[Tutor] turning a number into a formated string

2004-12-15 Thread Ertl, John
I need to take a number and turn it into a formatted string. The final output needs to look like when the X is the integer part padded on the left and Y is the decimal part padded on the right. I figured I could split the number at "." and then use zfill or something like this (LEVEL

Re: [Tutor] check_range

2004-12-15 Thread Juan Shen
I agree with Kent's opinion. A boolean statement, like 9>> ( 9 < value ) and ( value < 90 ) , maybe a good sense of boolean type will be made, because 'and' operation is always associating with boolean. Juan Shen 在 2004-12-15三的 07:43 -0500,Kent Johnson写道: > Brian van den Broek

Re: [Tutor] check_range

2004-12-15 Thread Liam Clarke
I'll second this - > In general, Python's flexibility with boolean values is a strength of the > language and I recommend > you try to get comfortable with it. If you come across something, and you're not sure if it'll evaluate true or false, fire up IDLE or similar intepreter, and test it! I'

Re: [Tutor] check_range

2004-12-15 Thread Kent Johnson
Brian van den Broek wrote: DogWalker said unto the world upon 2004-12-15 00:32: "Brian van den Broek" <[EMAIL PROTECTED]> said: I have a some style suggestions for you, too. Try it this way: def check_in_range(value): in_range = False if 9 < value < 90: in_range = True

Re: [Tutor] check_range

2004-12-15 Thread Brian van den Broek
DogWalker said unto the world upon 2004-12-15 00:32: "Brian van den Broek" <[EMAIL PROTECTED]> said: Marc Gartler said unto the world upon 2004-12-14 18:12: Hi all, I am fairly new to both Python & programming, and am attempting to create a function that will test whether some user input is an int