[Tutor] Create file and input text
dyoo at cs.wpi.edu
Sun Jun 29 05:18:33 CEST 2008
> > import os
> > filename = raw_input('Enter the filename: ')
> > fobj = open(filename, 'w')
> > yourname = raw_input('What is your name: ')
> > fobj.write(yourname)
> > fobj.close()
> > It seems to work Ok, I was shocked! Is it OK?
The first line, the import of the 'os' module, is superfluous: it's
not being used.
> welcome to Python! ummmm, yes, it is ok. your syntax is perfect, and
> it should've done exactly what you wanted. and yes, Python is *that*
> intuitive and that easy. you're gonna *love* programming with it. :-)
Python won't let you break any laws of gravity. But there are a lot
of good people here on Tutor who will be happy to be of assistance
when the programs get harder to write.
More information about the Tutor