Begin forwarded message:

From: Joseph Quigley <[EMAIL PROTECTED]>
Date: April 29, 2005 17:16:22 BST
To: Max Noel <[EMAIL PROTECTED]>
Subject: Re: [Tutor] cPickle (Joseph Q.)

I tried that and it doesn't work!
I type the name and it just sits there!

Here's the code:

# variables
name = "JOTEX "
versn = "0.1"
# end variables

print name + versn


def intro():
print """JOTEX is a very simple command based text editor with a maximum of
6 lines (counting up though). Similar to early version of TEX."""


def commands():
    print """\nThe following commands are:
    \jn$ for a new line.
        Ex: Hello!\jn$  then Hi again! returns:
            Hello!
            Hi again!

    \jq$ for quiting the program at any prompt.

    \js$ for saving (feature not currently available)

No more commands.
"""
    main()

def l6():
    l6 = raw_input("")
    print
    print
    save()
    main()
def l5():
    l5 = raw_input("")
    l6()
def l4():
    l4 = raw_input("")
    l5()
def l3():
    l3 = raw_input("")
    l4()
def l2():
    l2 = raw_input("")
    l3()
def l1():
    l1 = raw_input("")
    l2()


def main():
intro()
print "\nYou may want to see the commands. Type \jhc for commands.\nPress\
'Enter' (Return) to begin a document"
prompt = raw_input(">>> ")
if "\jhc$" in prompt:
commands()
elif "\jq$" in prompt:
raise SystemExit
else:
print "\n\n\n"
l1()
def save():
import cPickle as p
file_name = "test.txt"
f = file(file_name, 'w')
all = [l1(), l2(), l3(), l4(), l5(), l6()]
p.dump(all, f)
f.close()
main()


main()



At 09:44 AM 4/29/2005, you wrote:

On Apr 29, 2005, at 04:48, Joseph Quigley wrote:

Hi all,
How could I have the user name his file? I learned that I type file_name = "foo.bar"
How could I make it that the use could name it "hello.hi"?


Thanks,
        Joe

Well, all you have to do is have the user input a string, and use this string as the name of the file. The raw_input function should allow you to do that.


-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?"


--
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?"


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to