Newbie: Problems with File IO

Shaun Laughey shaun at
Sun Feb 17 16:40:28 EST 2002

If you want to remember them forever (sic) then use cookies.

If you want to remember them from post to post during the same "session"
then use a session object (a temporary cookie in effect) or encode a
unique session into the url (not as easy).

pyweblib.session contains all the functions you need.

Then you would simply

User connects
Do they have a session?
No - generate one.
Do they have a username?
No - ask for it and store in session username
Call the clean up function periodically to clear out old sessions.
On your page display the session username.

Remember to use try: or has_key or else you will get errors if there is
no username key in the session object.

For pyweblib see

Documentation isn't a strong point but the library should give you a

Hope this helps
Shaun Laughey,

-----Original Message-----
From: python-list-admin at [mailto:python-list-admin at]
On Behalf Of Flavian Hardcastle
Sent: 17 February 2002 02:25
To: python-list at
Subject: Re: Newbie: Problems with File IO

Chris Liechti <cliechti at> wrote in 
news:Xns91B81F8828230cliechtigmxnet at

> Flavian Hardcastle <deathtospam43423 at> wrote in 
> news:Xns91B873A49D077AusYourStandingInIt at
>> out_file = open("log.txt", "w")
> mode 'a' does append (thats the one you want), 'w' starts a new file 
> for writing, adding a plus 'a+' or 'w+' opens for read/write

Thanx! That's got me a bit further. What part of the standard Python
(the html one you get at would that be under?

Also, if you could give me a hint as to how I might get the script to 
remember people's usernames everytime they post, that'd be good.

"You can tell whether a man is clever by his answers. You can tell
a man is wise by his questions."  Naguib Mahfouz

netvegetable at

More information about the Python-list mailing list