Re: [Tutor] Inherit from int?

2007-05-12 Thread jim stockford
the problem is in the return. if you append a print statement to the class function such as print "number is ",number # (properly indented, of course) you'll get 8 On May 12, 2007, at 5:11 PM, John Fouhy wrote: > On 13/05/07, Marilyn Davis <[EMAIL PROTECTED]> wrote: >> #!/usr/bin/env python

Re: [Tutor] Inherit from int?

2007-05-12 Thread John Fouhy
On 13/05/07, Marilyn Davis <[EMAIL PROTECTED]> wrote: > #!/usr/bin/env python > '''An Under10 class, just to fiddle with inheriting from int.''' > > class Under10(int): > > def __init__(self, number): > number %= 10 > int.__init__(self, number) Subclassing int and other types i

[Tutor] Inherit from int?

2007-05-12 Thread Marilyn Davis
Hello Tutors, I'm stumped. This silly bit of code doesn't work. I expect the output to be 8, not 18. What am I missing? #!/usr/bin/env python '''An Under10 class, just to fiddle with inheriting from int.''' class Under10(int): def __init__(self, number): number %= 10 int.

Re: [Tutor] Checking/Debugging tools

2007-05-12 Thread Kent Johnson
Alan Gilfoy wrote: > Quoting Kent Johnson <[EMAIL PROTECTED]>: >> - A debugger lets you step through the code and see how it behaves. >> winpdb is a pretty nice GUI-based Python debugger and some Python >> development tools have built-in debuggers. >> http://www.digitalpeers.com/pythondebugger/ >

Re: [Tutor] Running and passing variables to/from Fortran

2007-05-12 Thread John Washakie
WAY too large a project I'm afraid. Yes, that would be the one which would make me an 'expert' in Python ;) Too bad there's just no time right now... On 5/10/07, Bob Gailer <[EMAIL PROTECTED]> wrote: > John Washakie wrote: > > I have access to the source code. > Did you tell us why you want to ke

Re: [Tutor] Loop-checking question

2007-05-12 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote > I'm not really sure what you expect this view to look like. I don't > know > of any tool that will let you dynamically watch a program as it > executes. Not particularly relevant but there are some commercial tools that do this kind of thing, they are

[Tutor] Checking/Debugging tools

2007-05-12 Thread Alan Gilfoy
Quoting Kent Johnson <[EMAIL PROTECTED]>: > Alan Gilfoy wrote: >> My programs often have long, detailed loops in them, and would like >>to, as I'm executing the loop, view what part of the loop Python >> is currently processing. >> >> Thus, if my program gets stuck in one part of the lo

Re: [Tutor] (no subject)

2007-05-12 Thread Rolando Pereira
adam urbas escreveu: Hi,I just started python today and I would like a few pointers, if you don't mind. I tried using a tutorial, but was only able to get the correct results for the most basic problems. # Area calculation programprint “Welcome to the Area calculation program”print “

Re: [Tutor] Loop-checking question

2007-05-12 Thread Kent Johnson
Alan Gilfoy wrote: > My programs often have long, detailed loops in them, and would like > to, as I'm executing the loop, view what part of the loop Python is > currently processing. > > Thus, if my program gets stuck in one part of the loop, I would see that. > Thus, if one part of my loop is

Re: [Tutor] Python fast enough for ad server?

2007-05-12 Thread Eric Walstad
Hi OkaMthembo, Again, are you sure you need it? Have you done any benchmarking yet? It looks like you have to run Psyco on 32 bit x86 architecture. That may limit other parts of your system design that you want to speed up by running on x86-64, for example. OTOH, it's easy to add/remove psyco (

Re: [Tutor] Repeating an action

2007-05-12 Thread Andre Engels
2007/5/12, Alan Gilfoy <[EMAIL PROTECTED]>: > How do you 'tell' Python to repeat a certain action X amount of times, > and then stop. > > I could use a 'counter' (see below), but that seems kind of clunky. > > > > counter = 0 > example = True > while example: > > print "Do something" > co

Re: [Tutor] Repeating an action

2007-05-12 Thread F.Lee
On 5/12/07, Alan Gilfoy <[EMAIL PROTECTED]> wrote: > How do you 'tell' Python to repeat a certain action X amount of times, > and then stop. > > I could use a 'counter' (see below), but that seems kind of clunky. > > > > counter = 0 > example = True > while example: > > print "Do something" >

[Tutor] Repeating an action

2007-05-12 Thread Alan Gilfoy
How do you 'tell' Python to repeat a certain action X amount of times, and then stop. I could use a 'counter' (see below), but that seems kind of clunky. counter = 0 example = True while example: print "Do something" counter += 1 if counter == 100: example = False __

[Tutor] Loop-checking question

2007-05-12 Thread Alan Gilfoy
My programs often have long, detailed loops in them, and would like to, as I'm executing the loop, view what part of the loop Python is currently processing. Thus, if my program gets stuck in one part of the loop, I would see that. Thus, if one part of my loop is never triggered, I would see t

Re: [Tutor] newb - Problem reading binary files

2007-05-12 Thread Kent Johnson
Elizabeth Finn wrote: > I need to read a file that is in binary format, and then convert some of > the values into integer values. These values can range from 1 to 4 bytes. > > First question – is there an easy way to do this? I finally wrote my own > little utility to handle multi-byte integer

Re: [Tutor] Why don't I see anything when I run this program?

2007-05-12 Thread Alan Gauld
"Bob Gailer" <[EMAIL PROTECTED]> wrote >> print “Welcome to the Area calculation program” > > I guess you used a word processor to write the program, And in case you missed Bob's point - don't do that! Use a text editor like Notepad, or better still IDLE or Pythonwin or any other editor designe