[EMAIL PROTECTED] a écrit :
>>>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
> > 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
[EMAIL PROTECTED] wrote:
>>>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
Suppose I have inherited the structure
PackageFolder/
__init__.py
mod1.py
SubPackageFolder/
__init__.py
mod2.py
mod3.py
When mod1 is run as a script,
I desire to import either mod2 or mod3 but not both
conditional on an option detected b
> >
> > 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
[EMAIL PROTECTED] a écrit :
>>>First case is a little shorter but then you have to use a parser for it
>>
>>There's one builtin.
>
>
> do you mean 'configparser'?
Yes.
> I'm just trying to figure out how this
> works.
One nice thing with Python is the interactive python shell. It makes
expl
> > 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
Nick Vatamaniuc wrote:
> Dave,
>
> Sometimes generating classes from .ini or XML files is not the best
> way. You are just translating one language into another and are making
> bigger headaches for your self. It is certainly cool and bragable to
> say that "my classes get generated on the fly fro
[EMAIL PROTECTED] wrote:
> 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()
> c
Dave,
Sometimes generating classes from .ini or XML files is not the best
way. You are just translating one language into another and are making
bigger headaches for your self. It is certainly cool and bragable to
say that "my classes get generated on the fly from XML" but Python is
terse and rea
[EMAIL PROTECTED] wrote:
> Hi
>
>
(snip)
>
def get_class_by_name(name):
return globals()[name]
>>>
>>Q&D way to retrieve the class object (Python's classes are themselves
>>objects) known by it's name (as a string).
>
>
> ok, so it actually returns the class object itself.
> One thing
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
[EMAIL PROTECTED] a écrit :
> Hiya
>
> Could you just talk me through this... is it:
>
>
>>schema = {'turbine1': {'class': 'Turbine',
>> 'upstream' : ('frobnicator2',),
>> 'downstream' : () # nothing,
>> },
>> 'frobnicato
I don't know if you saw my earlier post but something like
this has worked for me.
What about something like:
supply = supply()
compressor = compressor(supply)
combuster1= combuster(compressor)
combuster2= combuster(compressor)
compressor.append(combuster1)
compressor.append(combuster2)
or perha
Hiya
Could you just talk me through this... is it:
> schema = {'turbine1': {'class': 'Turbine',
>'upstream' : ('frobnicator2',),
>'downstream' : () # nothing,
>},
> 'frobnicator2' : {'class' : 'Frobnicator',
>
[EMAIL PROTECTED] wrote:
(snip)
> brings me onto another question that has been bugging me, which is, if
> I want to create components (as object instances) at run time (rather
> than through a python code imported in), how do I do this? i.e. if I
> hardcoded something like
> turbine1 = turbine(...
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
[EMAIL PROTECTED] wrote:
> 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 o
[EMAIL PROTECTED] wrote:
> Steve Holden wrote:
>
>>[EMAIL PROTECTED] wrote:
>>
>>>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
>>>ups
Dave,
Python properties allow you to get rid of methods like c.getAttr(),
c.setAttr(v), c.delAttr() and replace them with simple constructs like
c.attr, c.attr=v and del c.attr.
If you have been using Java or C++ you know that as soon as you code
your class you have to start filling in the get()
[EMAIL PROTECTED] wrote:
> I have a problem. I'm writing a simulation program with a number of
> mechanical components represented as objects.
Have you looked at SimPy? This may simplify much of your data
structure anguish (probably only need forward refs, without the back
refs), plus it will do
Steve Holden wrote:
> [EMAIL PROTECTED] wrote:
> > 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,
[EMAIL PROTECTED] wrote:
> 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()
> c
[EMAIL PROTECTED] a écrit :
>>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(_
Iain King wrote in news:1153323649.171612.74510
@s13g2000cwa.googlegroups.com in comp.lang.python:
>
> [EMAIL PROTECTED] wrote:
>> [...] I need to reference (link) each object to the objects
>> upstream and downstream of it, i.e.
>>
>> supply = supply()
>> compressor = compressor(downs
> 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
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
Your can of course initialize the components first:
compr=Compressor(...),
comb=Combuster(...),
sup=Supply(...) ,
tur=Turbine(...).
Then do:
compr.up, compr.down =sup, comb
comb.up, comb.down =compr, tur
Even if you need to do something during attachment of components it is
more Pythonic to
[EMAIL PROTECTED] wrote:
> 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()
NB
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
[EMAIL PROTECTED] wrote:
> 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()
>
What about something like:
supply = supply()
compressor = compressor(supply)
combuster = combuster(compressor)
compressor.append(combuster)
turbine = turbine(combuster)
combuster.append(turbine)
-Larry Bates
[EMAIL PROTECTED] wrote:
> I have a problem. I'm writing a simulation program with a n
[EMAIL PROTECTED] wrote:
> 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()
> c
[EMAIL PROTECTED] wrote:
> 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()
> c
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
35 matches
Mail list logo