osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need to pass a class instance to a gettext fallback


Hi Peter

>> language = kwargs['language']
>> del kwargs['language']
>
>Not really important, but there's a method for that:
>
>language = kwargs.pop("language")
Thanks, this looks better and I indeed think it is important. The "del ..." line looks ugly.

>>   def __init__(self, *args, **kwargs):
>>     language = kwargs['language']
>>     del kwargs['language']
>
>In Python 3 this can also be spelt with a keyword-only language argument:
>
>def __init__(self, *args, language, **kwargs):
>    ...  # no pop() or del
I'm using Python 2.7.10, but this also works there, so, I replace it with your suggestion.

And before you tell me that python 2.7 is old, the thing is that I'm writing a pluging for Gimp and this is the version they distribute :-(

Thanks for your valuable help

Best regards
Josef