Re: [Tutor] eval and exec

2004-12-04 Thread Alan Gauld
I'm having trouble understanding the difference between eval and exec. eval evaluates an *expression* - that is something that returns a value. exec executes a piece of code, it need not return a value. eval is slightly safer than exec (but not much). Some examples: print 'hello' # use

Re: [Tutor] eval and exec

2004-12-04 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2004-12-04 04:28: Marilyn Davis said unto the world upon 2004-12-04 01:37: Hello Tutors, I'm having trouble understanding the difference between eval and exec. Can anyone explain it to me please? Marilyn Davis Hi Marilyn, does this help? SNIP Darn. I

Re: [Tutor] Global presets ?

2004-12-04 Thread Kent Johnson
You are on the right track. Put your common definitions in a configuration module like this: # Config.py arch_data_dir='/home/dave/mygg/gg1.3/arch_data' data_dir='/home/dave/mygg/gg1.3/data' Then in client code, import Config. When you use the names defined in Config you have to prefix them with

Re: [Tutor] Global presets ?

2004-12-04 Thread Dave S
Thanks Guys, They are both good ways of getting round my problem, I appreciate your input will have a play. Cheers Dave :-) :-) :-) :-) ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Simple RPN calculator

2004-12-04 Thread Kent Johnson
I didn't get the attachment, can you try again? Thanks, Kent Just Incase wrote: Hi Tutors, I am new to programming and so don't know anything much, yet. I am having problem with implementing a simple RPN calculator in python. I have tried editing some other programs I have been referenced to

[Tutor] OT: test

2004-12-04 Thread Eri Mendz
sorry it seems like my email address is mangled in my earlier post. resending new message with address in sig. -- Using PC-Pine 4.61 email: erimendz_at_bluebottle.com reply to: erimendz_at_fastmail.fm ___ Tutor maillist - [EMAIL PROTECTED]

Re: [Tutor] Address book sort of

2004-12-04 Thread Rick Muller
Couldn't tell if this got sent, so I'm re-sending. Apologies for duplicates: Well, one option is to use pickle (or cPickle, preferrably) to dump the python objects to a file: from cPickle import load, dump def save(fname,addressbook): file = open(filename,'w') dump(addressbook,file)

Re: [Tutor] Global presets ?

2004-12-04 Thread Dave S
Alan Gauld wrote: have you considered making the root directory an environment variable? That way you can read the value (os.getenv) at the start of the script. And if you ever need to move the structure you can simply change the environment value. It also means different users can use their own

[Tutor] Broblem with exiting a Tkinter app

2004-12-04 Thread Mark Kels
Hi all , I got 2 questions for you guys. The fist question: I wrote small Tkinter app while laerning about the Radiobutton widget, and I added a Quit button, like this: bb=Button(root, text=Quit, fg=BLUE, command=root.quit).pack() When I pressed the button the app crashed and I got an error

Re: [Tutor] Accuracy of time.sleep()

2004-12-04 Thread Tim Peters
[Dave S [EMAIL PROTECTED]] OK I may be pushing it, ;-) Yup wink. I need a script to sleep from any point to 8:05AM when in needs to re-start. So I calculate the number of seconds with the following def secs_till_805(): # Returns the number of seconds till 8:05AM

Re: [Tutor] eval and exec

2004-12-04 Thread Bill Campbell
On Sat, Dec 04, 2004, Alan Gauld wrote: I'm having trouble understanding the difference between eval and exec. eval evaluates an *expression* - that is something that returns a value. ... Both are extremely dangerous functions from a security and maintenance/reliability pouint of view and

Re: [Tutor] Broblem with exiting a Tkinter app

2004-12-04 Thread Mark Kels
On Sat, 04 Dec 2004 14:38:06 -0500, Kent Johnson [EMAIL PROTECTED] wrote: Mark Kels wrote: Hi all , I got 2 questions for you guys. The fist question: I wrote small Tkinter app while laerning about the Radiobutton widget, and I added a Quit button, like this: bb=Button(root,

Re: [Tutor] Simple RPN calculator

2004-12-04 Thread Alan Gauld
I am new to programming and so don't know anything much, yet. I am having problem with implementing a simple RPN calculator in python. I'm not surprised. While an RPN vcalculator is one of the easier calculators to build its not exactly trivial. It sounds like the kind of thing an ambitious

Re: [Tutor] Accuracy of time.sleep()

2004-12-04 Thread Alan Gauld
It must be cummulative error over 10s of thousands of seconds. Just so, and depends on howm many other processes are running, how busy the CPU is etc. bodge ( cron or at are better) but I suppose I could calculate seconds to 8:05 sleep(seconds*0.95), re calculate secs to 8:05 sleep(seconds)

Re: [Tutor] hello.py: line 1: print: command not found

2004-12-04 Thread Cullen Newsom
Max, Thanks for your reply. I have already tried to set my shebang to /usr/bin/env python. But for everyone's benefit. I've tried it again, and the same behavior persists. As another confirmation that this is not a file permission problem, I should say that I can run hello.py as root,