Stef Mientki <[EMAIL PROTECTED]> wrote in news:182cf
[EMAIL PROTECTED]:

>>> class Power_Supply(device):
>>>      pinlist = {
>>>          0: ('GND', _DIG_OUT, _par2),
>>>          1: ('VCC', _DIG_OUT, _par33)
>>>          }
>> 
>> I may be confused about what you're after, but wouldn't 
something 
>> like this work? (I don't know what a _par2 object is; I've 
named 
>> it something here.)
> _par2, is just (a reference to) a constant
>> 
>> class Power_Supply(device):
>>     def __init__(self):
>>         self.pin = {
>>             0:dict(Name='GND',Value=_DIG_OUT,something=_par2),
>>             1:dict(Name='VCC',Value=_DIG_OUT,something=_par33),
>>         }
> Why so complex, I need 10 or more parameters (or empty),
> and then this becomes completely unreadable.
> As this is part of the "user interface",
> (I want that completely unknown with Python people,
> write these lines),
> I think my "pinlist" is much easier.
> 

Whatever works for you. In your original example, you first 
created "pinlist" (which is actually a Python dict), and then used 
it to place values in an unspecified type named "pin" (which I 
took to be another dict). I just combined the two steps.

You talk about the "pinlist" being easier ... I'm not sure what 
you mean. Easier to create? Maybe. But if you are then going to 
assign the values to names, then it doesn't strike me as easier to 
go through the two-step process. But as I said, I may be confused 
about what you are really trying to do.

> 
>>         for k in self.pin.keys():
>>             self.__dict__[self.pin[k]['Name']] = self.pin[k]
> thanks "rzed" ?,
> that is exactly what I was looking for:
>                self.__dict__[self.pinlist[k][0]] = self.pin[k]

I'm glad it helped.

-- 
rzed
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to