caseless dictionary howto ?

stef s.mientki at id.umcn.nl
Wed Jun 20 05:14:41 EDT 2007


Stefan Behnel wrote:
> Stef Mientki wrote:
>   
>> I need to search a piece of text and make all words that are equal
>> (except their case) also equal in their case, based on the first
>> occurrence.
>> So I'm using a dictionary to store names and attributes of objects.
>> As as I need to search on the caseless name (so I've choosen lowercase),
>> My dictionairy looks like this:
>>
>>     self.procs [ "serial_hw_read"  ] = ( "Serial_HW_Read", "F", "++", T)
>>     
>
> I have no idea what the "F", "++", "T" means at the end (if it's some kind of
> flags or attributes,
This makes part of a simulation of a JAL (a Pascal like language for 
micros),
and this dictionary builds up the namespace,
used in translation JAL to pure Python.

Serial_HW_Read = the name of a function
"F" = the type of that function (procedure / function / pseudo variable 
/ interrupt /..)
"++" = the direction of each parameters, (input / output / input+output )
T = a tupple, containing the type of each of the parameters (bit / byte/ 
sbyte / word / ...)
>  maybe a class to hold them would look better),
maybe, but no human is looking at it ;-)
>  but that's
> a good solution to the problem IMHO.
>   
Seeing the other solution,
I indeed tend to stick to this solution,
because it's the most simple one
(certainly if you realize that the dictionary is generated by the 
program itself)

cheers,
Stef Mientki
> Stefan
>   



More information about the Python-list mailing list