[Tutor] Program Questions
Lloyd Kvam
pythonTutor at venix.com
Fri Jul 16 21:42:42 CEST 2004
(I failed to send this to the list earlier)
I saved the original email as a file so that I could examine it
directly.
The quotes in the original email are 0x91 and 0x92 characters and
apparently came from a word processing program. My email program
(evolution) simply dropped them. They are in the latin-1 control
character range (0x80 - 0x9f) and are not encodings of displayable
characters. Presumably they originated from a Windows Cp1252 encoding.
The tabs and spaces are inconsistent. I assume the tab stops were set
to half inch or something like that within a word processing program.
The bottom line is that programs should be edited with a program editor
rather than a word processor. On Windows, notepad will work in a pinch,
but idle or pythonwin are MUCH better free options. I suppose this is a
drawback with Python if you are using the wrong tools to edit your
code. With most languages the blocks are marked with clearly visible
characters.
On Thu, 2004-07-15 at 21:24, Adelein and Jeremy wrote:
> --- Lloyd Kvam <pythonTutor at venix.com> wrote:
> > print "\n"
> > print "TRANSACTION COMPLETED"
> >
> > You need quotes around string literals, pieces of text that were
> > never assigned a name.
> >
>
> She did have quotes.
> This is what you apparently saw:
>
> > > def MenuOption(self, option, Account):
> > > if option == 1:
> > > print \n
> > > Account.deposit(input(Deposit amount: $))
> > > print \n
> > > print TRANSACTION COMPLETED
> > > print \n
> > > elif option == 2:
> > > print \n
> > > Account.withdraw(input(Withdraw amount: $))
> > > print \n
> > > print TRANSACTION COMPLETED
> > > print \n
> > > elif option == 3:
> > > print \n
> > > Account.trans()
> > > print \n
> > > print QUERY COMPLETED
> > > print \n
>
> This is what I saw (there are single quotes around each string
> literal):
>
> def MenuOption(self, option, Account):
> if option == 1:
> print \n
> Account.deposit(input(Deposit amount: $))
> print \n
> print TRANSACTION COMPLETED
> print \n
> elif option == 2:
> print \n
> Account.withdraw(input(Withdraw amount: $))
> print \n
> print TRANSACTION COMPLETED
> print \n
> elif option == 3:
> print \n
> Account.trans()
> print \n
> print QUERY COMPLETED
> print \n
>
> > I suspect the elif problems come from using a mix of tabs and
> > spaces in
> > lining things up. Python uses 8 spaces per tab, but your editor
> > could
> > be different. If your editor was using tab stops of four spaces,
> > you
> > could mix tabs and spaces in a way that looked reasonable in your
> > editor, but looks unreasonable to the Python compiler.
>
> If indeed that is the problem, then this is also the problem with the
> print statement. I see no other error - could be missing something
> though.
>
> HTH
> Jeremy
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice: 603-653-8139
fax: 801-459-9582
More information about the Tutor
mailing list