[melbourne-pug] mapping strings to class attributes/operators etc.
Tennessee Leeuwenburg
tennessee at tennessee.id.au
Sun Jan 8 01:31:07 CET 2006
Justin Warren wrote:
>On Fri, 2006-01-06 at 00:13 +1100, lemeia wrote:
>
>
>>Hi all,
>>
>>I'm a new member so hello everyone. I'm also a very new Python programmer.
>>I'm really impressed with how quick it was to pick up Python. I've only really explored it as an option once I moved to the Linux platform from Windows.
>>
>>There's several things I'd like to do with Python as an all purpose utility language, but right now I would like to ask some advice on something in particular.
>>
>>I've got a program I use to read in large files of data which I use to create temporary objects and apply various comparisons and criteria against the objects I create and write to different output files and increment various statistic attributes in my application object for later reporting.
>>
>>The problem is that this isn't a fixed operation at all. It would be much better for these comparisons and actions to be very dynamic and prevent me from constantly changing the code and rerunning it.
>>
>>I was thinking I would like to develop some sort of mini-query language. Very simplified and fairly specific to the objects I am creating during my run.
>>
>>Is there a way in Python (using Dictionaries or something) to map strings to attributes, operators, functions etc...
>>
>>So if I wanted to say
>>object: dimensions
>>condition: height < 8.4 action: writeReject(height) exception: none
>>
>>then the application would parse it into a statement like:
>>if dimension.height < 8.4:
>> self.writeReject(height)
>>
>>In this way, I could save various conditions and even build them into a string of conditions called a criteria system (for example). I could also use the same mechanism to design reports based on alterable (and storable) conditions that the user specifies.
>>
>>
Could you please explain the actual task with a little more detail? I
can think of a number of options, and have done similar things myself
before using Java, but I don't know exactly what you're trying to do.
Cheers,
-T
More information about the melbourne-pug
mailing list