[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 as simple
as a
[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, you might 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 file with
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 this
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
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 from XML
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
[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
exploring a
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
[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()
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 using .ini
[EMAIL PROTECTED] wrote:
Hi
(snip)
def get_class_by_name(name):
return globals()[name]
QD 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 that confuses me is
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:
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
[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 or
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:
(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(...)
Hiya
Could you just talk me through this... is it:
schema = {'turbine1': {'class': 'Turbine',
'upstream' : ('frobnicator2',),
'downstream' : () # nothing,
},
'frobnicator2' : {'class' : 'Frobnicator',
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
[EMAIL PROTECTED] a écrit :
Hiya
Could you just talk me through this... is it:
schema = {'turbine1': {'class': 'Turbine',
'upstream' : ('frobnicator2',),
'downstream' : () # nothing,
},
'frobnicator2' : {'class'
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 =
[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()
[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
[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()
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()
NB :
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
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.
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
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 =
[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(_get_up,
[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()
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, i.e.
[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
35 matches
Mail list logo