Can I have a class with property named "from"

Terry Reedy tjreedy at udel.edu
Sat Jun 6 10:48:34 EDT 2020


On 6/5/2020 6:59 PM, Ethan Furman wrote:
> On 06/05/2020 03:15 PM, MRAB wrote:
>> On 2020-06-05 22:50, Ethan Furman wrote:
> 
>>> There is no workaround that allows a keyword to be used except as a 
>>> keyword, other than making it a string.  When faced with this kind of 
>>> situation myself I use a synonym, like "since", or a translation, 
>>> like "desde".
>>>
>> The usual workaround is to append an underscore: 'from_'.
> 
> True, but ick.  ;-)  It's like a dangling preposition.

It is, in a sense, standard practice.  It is used, for instance, for 
tcl/tk names that are python keywords. The option / argument name 'in' 
is written 'in_' when written without quotes in a call.

f(in_='.') and f(**{'in':'.'}) have the same effect.


-- 
Terry Jan Reedy




More information about the Python-list mailing list