Re: using names before they're defined

2006-07-27 Thread davehowey
> > Hiya, you might be interested in this alternative config parsing > > program: > > http://www.voidspace.org.uk/python/configobj.html > > Yes, I know it. But I don't like it. Either a simple ini file do the > trick, or I need a full blown app-specific DSL - which can be as simple > as a Python f

extender method

2006-07-26 Thread davehowey
'Learning Python' by Lutz and Ascher (excellent book by the way) explains that a subclass can call its superclass constructor as follows: class Super: def method(self): # do stuff class Extender(Super): def method(self): Super.method(self) # call the method in super # do more stu

Re: using names before they're defined

2006-07-26 Thread davehowey
> > > > do you mean 'configparser'? > > Yes. > > > Does it generate objects from the config file automatically? > > It generates a representation of the config file as a Python object > composed of sections and options. The documentation should get you started. Hiya, you might be interested in thi

Re: using names before they're defined

2006-07-24 Thread davehowey
> > First case is a little shorter but then you have to use a parser for it > > There's one builtin. do you mean 'configparser'? I'm just trying to figure out how this works. Does it generate objects from the config file automatically? Dave -- http://mail.python.org/mailman/listinfo/python-list

Re: using names before they're defined

2006-07-21 Thread davehowey
Hi > Also, I gave the example using Python code as 'config' format, but any > structured enough text format could do, ie JSON, XML, or even ini-like: > > # schema.ini > objects = turbine1, frobnicator2 > > [turbine1] > class=Turbine > upstream=frobnicator2 > downstream= > yes, I like the idea of

Re: using names before they're defined

2006-07-20 Thread davehowey
Hiya Could you just talk me through this... is it: > schema = {'turbine1': {'class': 'Turbine', >'upstream' : ('frobnicator2',), >'downstream' : () # nothing, >}, > 'frobnicator2' : {'class' : 'Frobnicator', >

Re: using names before they're defined

2006-07-20 Thread davehowey
Paddy, thanks for your mail. > In Digital electronics we have what are called netlists, (and also > component lists) yes, years back I did a 3rd year project on a 'logic simulator' which used the kind of thing you are talking about. I think spice does as well. Fortunately my problem is a little

Re: using names before they're defined

2006-07-19 Thread davehowey
> Even if you need to do something during attachment of components it is > more Pythonic to use properties. So you will write a method in your > class name something like _set_up(self,upstream_obj) an _get_up(self). > And then at the end of your class put up=property(_get_up, _set_up). > You can

Re: using names before they're defined

2006-07-19 Thread davehowey
Bruno, Thanks. An issue is that I need to be able to link multiple objects to a single object etc. Say for example using the previous wording, I might have compressor - multiple combustors - turbine this complicates things slightly. my current thought is to do a two stage initialisation 1. crea

Re: using names before they're defined

2006-07-19 Thread davehowey
Iain, thanks - very helpful. Really I'm trying to write a simulation program that goes through a number of objects that are linked to one another and does calculations at each object. The calculations might be backwards or fowards (i.e. starting at the supply or demand ends of the system and then

using names before they're defined

2006-07-19 Thread davehowey
I have a problem. I'm writing a simulation program with a number of mechanical components represented as objects. When I create instances of objects, I need to reference (link) each object to the objects upstream and downstream of it, i.e. supply = supply() compressor = compressor(downstream=combu