On 06/05/2020 02:36 PM, zljubi...@gmail.com wrote:

class abc:

     def __init__(self):
         self._from = None

     @property
     def from(self):
         return self._from

     @from.setter
     def from(self, value):
         self._from = value


I get the error SyntaxError: invalid syntax because of the property named from.
Looks like in python from is a keyword that cannot be used as a property name.

I have to create a python object from a complex (nested) json object that has many keys 
with name "from" and value of date in string format.

As I would like to keep property names as they are in the json file... is there 
a workaround?

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".

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to