[Tutor] Newby Still Lost with GUI!!!

Alan Gauld alan.gauld at blueyonder.co.uk
Sun Mar 7 19:52:40 EST 2004


> I am trying inhance my program to create a GUI
> interface instead of my current one. However I am
> coming up with "amount" and "self" are not defined. I
> thought I did this earlier. 

You did it inside the class definition, but you are trying to 
use them outside the class - check the indentation...

> class AccountTransaction(object):
>     def __init__(self, amount, time):
>         self.amount = amount
>         self.time = time
> 
>     def __repr__(self):
>     def __self__(self, initial):

End of class definition because while is not indented to right level
incidentally what does __self__ do, thats a new one on me...

> while 1:
>     print '''

            Welcome to the Bank
            1. Deposite
            2. Withdraw
            3. Getbalance
            9. Quit
'''

Triple quoted strings save a lot of typing of print statements...

      choice = int(raw_input('Enter your choice: '))
>     if choice == 1:
>         amount = raw_input ('Amount: ')
>     elif amount < 0:
>         raise ValueError, 'Deposites must be positive'
>     elif self.balance - amount < 0:

This is not part of the class so self doesn't exist...

HTH,

Alan G.



More information about the Tutor mailing list