Isn't there a better way?

rony steelandt bucodi at yahoo.fr
Fri Jul 21 12:49:01 EDT 2006


Le Fri, 21 Jul 2006 07:51:15 -0700, T a écrit :

> 
> I am using an optparse to get command line options, and then pass them
> to an instance of another class:
> 
> 
> 
> # Class that uses optparse.OptionParser
> foo = Parse_Option()
> 
> # Class that does the real work
> bar = Processor()
> 
> bar.index = foo.options.index
> bar.output  = foo.options.output
> bar.run()
> 
> 
> 
> This works, but it feels hokey or unnatural to "pass" data from one
> class to another.  Isn't there a better way???

I don't know what both classes do, but can this be a solution ?


class Processor(Parse_Option)
	self.index = self.option.index
	self.output = self.option.output

    def run(self):
	# code

bar.run()


Rony




More information about the Python-list mailing list