[Tutor] Naive Questions

Yann Le Du yann.ledu@noos.fr
Sun Dec 1 19:36:01 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 1 Dec 2002, Michael Powe wrote:

> a couple questions to which i haven't been able to find answers.
> 
> i don't seem to find a python equivalent to the "rewind" file operation
> in C -- that is, i read through a file and i want to go back to the
> beginning and read again.  is the only option to close & reopen?

No. You can use :

f.seek(0,0)   # to go back at file's beginning

see http://diveintopython.org/fileinfo_files.html for more.

> 
> and just from curiosity, why are there no increment/decrement operators,
> and nothing equivalent to += & its friends?  i'd have thought this
> would be a faq, but don't find anything about it there.
> 
> the first item actually relates to something i'm working on.  the second,
> just that i'm lazy & find having to always type out i = i+1 annoying.  ;-)

These things work in the Python I use, i.e. 2.2

Y

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: For info see http://quantumlab.net/pine_privacy_guard/

iD8DBQE96qq3t4mG++uo5yQRArjqAKCTgw/jgW001xizAAVkNtmrakX/VACgjHd5
9tDqkh2RkZpBTuhb+7nd17o=
=7Imm
-----END PGP SIGNATURE-----