[Tutor] pgdb and console output

Alan Gauld alan.gauld at btinternet.com
Wed Mar 10 01:52:02 CET 2010


"pylist1" <pylist1 at gmail.com> wrote

>> sys.stdout.write(str(i))
>
> Yes that does indeed work like this:
>
> But it leaves formatting issues with leaving the command prompt in the 
> middle of the screen. That's not an issue at the moment.

Yes, stdout.write has no formatting if you need spaces or newlines you
have to explicitly provide them. That's why mosty folks use print
combined with a format string to get formatted output.

> I found after my initial email your pdf book you had wrote.  ...
>   Thanks for writing the book.

You're welcome but the web pages are more up top date than
the pdf file. I only generate the pdf after major updates but the
html files get updates fairly regularly. The zip files get updates
somewhere in between

> One last thing is your using "raw_input".  What's the differenct between 
> that and "str input"?  If the OS is using UTF-8 and the databse is UTF-8 
> should it really matter? So raw_input could mean any type of input?

I don;t know what "str input" refers to but raw_input is the standard
method in Python v2 of reading characters from stdin.  Its called raw
because it reads the raw characters, it does not try to interpret them.
Thus if you know its a number you use int() to convert the string to
an integer value

In Python v3 raw_input has been renamed to input()

See the Talking to the User topic in my tutorial for more detail on the
differences.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list