so I'm sort of in a fix. I'm using Google protocol buffers, and it just so happens that one of the fields in the schema is named "from". I'm using python, so everytime I try to access it, I get a syntax error. [ex - SomeClass.from -> Syntax error ]
Is there anyway to somehow access the field without using its identifier?
Maybe a way to escape reserved keywords in Python ? (One of the answers already says no, but...)
Or maybe some protobuf specific solution?
Thanks
After you pull your data, you can always save the from into from_ (the pythonic way of avoiding namespace clashes) by using the getattr(var, "from") statement; Ie
SomeClass # is a protocol-buffer
SomeClass.from_ = getattr(SomeClass, "from")
And then you an just use .from_ as you would otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With