Re: sort of a beginner question about globals

2005-04-16 Thread fred.dixon
just read the ne stuuf. i went to DIP right after work anf found in nice intro to unittest. not to bad (i thinK) now that I can see it work) -- http://mail.python.org/mailman/listinfo/python-list

Re: sort of a beginner question about globals

2005-04-15 Thread Thomas Heller
fred.dixon [EMAIL PROTECTED] writes: :) unit test is something on my to-learn list. seems involved and i haven't seen any straight forward tutorials yet. as yet i still consider myself a hobbyist at best. I would recommend Test Driven Development by Kent Beck (Addison-Wesley). Thomas --

Re: sort of a beginner question about globals

2005-04-15 Thread Duncan Booth
fred.dixon wrote: :) unit test is something on my to-learn list. seems involved and i haven't seen any straight forward tutorials yet. as yet i still consider myself a hobbyist at best. Hmm, I believe you are right. I can't see any straight-forward tutorials which use Python. I found a

Re: sort of a beginner question about globals

2005-04-15 Thread Scott David Daniels
Duncan Booth wrote: fred.dixon wrote: :) unit test is something on my to-learn list. seems involved and i haven't seen any straight forward tutorials yet. as yet i still consider myself a hobbyist at best. Hmm, I believe you are right. I can't see any straight-forward tutorials which use Python.

Re: sort of a beginner question about globals

2005-04-15 Thread alex23
Duncan Booth wrote: Hmm, I believe you are right. I can't see any straight-forward tutorials which use Python. I found a tutorial at onlamp.com, but it doesn't seem to me to explain TDD at all clearly. Mark Pilgrim's 'Dive Into Python' (http://diveintopython.org/) has a couple of chapters on

Re: sort of a beginner question about globals

2005-04-14 Thread fred.dixon
when i am roughing out my functions and classes i out a pass statement as my first line just as a place holder and a convenient place to put a break when i am testing. no other good reason. -- http://mail.python.org/mailman/listinfo/python-list

Re: sort of a beginner question about globals

2005-04-14 Thread Duncan Booth
fred.dixon wrote: when i am roughing out my functions and classes i out a pass statement as my first line just as a place holder and a convenient place to put a break when i am testing. no other good reason. A better idea when roughing out functions and classes is to insert a docstring

Re: sort of a beginner question about globals

2005-04-13 Thread fred.dixon
I want to use OPTIONS as a global var. In this particular case I am trying to set a global debug constant so I can have some debug logging happen when my program is run with a -debug option. what will actuall end up in OPTIONS is OPTIONS.debug = True as i am using optparse module. --

Re: sort of a beginner question about globals

2005-04-13 Thread Steven Bethard
fred.dixon wrote: I want to use OPTIONS as a global var. In this particular case I am trying to set a global debug constant so I can have some debug logging happen when my program is run with a -debug option. what will actuall end up in OPTIONS is OPTIONS.debug = True as i am using optparse

Re: sort of a beginner question about globals

2005-04-13 Thread fred.dixon
how would i use the following if OPTIONS was in a module ? --- from optparse import OptionParser usage = usage: %prog [options] arg parser = OptionParser(usage) parser.add_option(-d, --debug, ction=store_true, dest=verbose) (OPTIONS = parser.parse_args() ps Im not anywhere

Re: sort of a beginner question about globals

2005-04-13 Thread Steven Bethard
fred.dixon wrote: how would i use the following if OPTIONS was in a module ? --- from optparse import OptionParser usage = usage: %prog [options] arg parser = OptionParser(usage) parser.add_option(-d, --debug, ction=store_true, dest=verbose) (OPTIONS = parser.parse_args() Just

Re: sort of a beginner question about globals

2005-04-13 Thread fred.dixon
ok I'm sorry, I'm not sure what your doing there. if i have to guess it looks like yo might me modifying the imported modules dict with another dict. isn't there a way i can just assign to a var and have it seen no matter what part of the code is currently executing ? --

Re: sort of a beginner question about globals

2005-04-13 Thread fred.dixon
it seems that i can import __main__ where i set the global and then access the var from my local func. is ther any gotcha's involveld in this ? -- http://mail.python.org/mailman/listinfo/python-list

Re: sort of a beginner question about globals

2005-04-13 Thread Steven Bethard
fred.dixon wrote: ok I'm sorry, I'm not sure what your doing there. if i have to guess it looks like yo might me modifying the imported modules dict with another dict. Yes, this takes all the atrributes of the options object and sets them as attributes of the module. If you're afraid of

Re: sort of a beginner question about globals

2005-04-13 Thread fred.dixon
this is what i am using to test with. my program is not much more involved just longer and with a GUI. I did test it and everything works, just wondered if there was something evil and bad about importing main. # #global1.py import global2 import

Re: sort of a beginner question about globals

2005-04-13 Thread Steven Bethard
fred.dixon wrote: #global1.py import global2 import global3 import sys constant = 'dumb' option = sys.argv[1:] pass #global2.func1() a=global2.class1() a.func1() print newvar #global2.py import __main__ pass class class1: def func1(self): __main__.newvar = string pass The other

sort of a beginner question about globals

2005-04-12 Thread fred.dixon
i have read the book and searched the group too -- im not gettin it. i want to read a global (OPTIONS) from file1 from a class method (func1) in file2 i want to understand how this works. -- #file1.py import

Re: sort of a beginner question about globals

2005-04-12 Thread Steven Bethard
fred.dixon wrote: i have read the book and searched the group too -- im not gettin it. i want to read a global (OPTIONS) from file1 from a class method (func1) in file2 i want to understand how this works. --