newb question

lordkaos at my-deja.com lordkaos at my-deja.com
Tue Jul 18 20:15:42 EDT 2000


Is the user inputting whatever variables he wants, or are you presenting
the user with some variables that he assigns values to?

e.g.

>>>yourscript.py
Input var,val pairs, separated by semicolons: cow=milk;pig=pork;red=1
Thank you

(where the user keeps entering any/whatever variables and values they
want,

or like this...)

>>>yourscript.py
Give a value for 'cow':milk
Give a value for 'pig':pork
Give a value for 'red':1
Thank you.

(that's all they get to set values for... whatever cow, pig, red you
specifically program)

Both scenarios are not too hard to implement, but they are different
enough that you should distinguish between what you want to do... This
will help me answer your question.

--Jared

In article <3bRfYe$jTl at openbazaar.net>,
  gee308 at mediaone.net.bbs@openbazaar.net (Toy) wrote:
> Do you need to use classes?  I'm a newb and I'm just writing a
> "read-down"script with one or 2 functions.  What do you mean by
raw_input
> and read() and write()?  Thanks for th help.
> Jason Toy
>
> lordkaos at my-deja.com wrote:
>
> > In article <3973EE1B.15B0B32E at mediaone.net>,
> >   Toy <gee308 at mediaone.net> wrote:
> > > what is a simple way I can save variables that people enter in
from
> > > 'raw_input' ?  That way, someone enters the variables they want,
then
> > > when the script is booted up everytime the machine starts, it will
> > grab
> > > the variables from somewhere.  Thanks.
> > > Jason Toy
> > > toyboy at toy.eyep.net
> > >
> > >
> > The tutorial at <a href="http://www.python.org/current/tut">Python's
> > website</a> tells a simple and easy way to do exactly what you're
> > saying. If you can get the variables into a class (read section 9,
in
> > particular 9.3) then it is easy to read and write a big set of vars
all
> > together in one operation by using the 'pickle' command (read about
> > this and easy file creation/opening in section 7.2). I just read
over
> > this and it should answer your question. Come to think of it,
raw_input
> > stores your input as a string, so you can just read() and write() in
> > one swipe to do the same thing (This would be much easier).
> >
> > --Jared
> >
> > Sent via Deja.com http://www.deja.com/
> > Before


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list