[Tutor] Python Assignment Expression and Callable Expression

Wang Lei (ERIAN) l.wang at ntu.edu.sg
Fri Sep 19 04:41:31 CEST 2014


Hi, everyone:

I really believe that python is a great language but assignment and callable are not flexible:

I wish that I can do this:

class matrixArray(list):

bla bla bla

    def __call__(self, rid, cid):

        return self.head[rid][cid]



Once I call mat(1,1), I can get a result. but I want it more a value not a reference.


Considering "mat(1,1) = 5" expression, I wish the parser can dynamically map "mat(1,1)" to reference of value of that "or anonymous reference" or reference defined in class. I don't want to modify the lexical parsing in C++ but failed after trying different method in pythonic ways:


decorator: fun -> object mapping, because it just substitute function name with new function and cannot read "self" object.


I wish python developers could think of an idea to update the lexical parsing method or simply provide us a tool to modify it in python context.


Regards,

Lei Wang


________________________________

CONFIDENTIALITY:This email is intended solely for the person(s) named and may be confidential and/or privileged.If you are not the intended recipient,please delete it,notify us and do not copy,use,or disclose its contents.

Towards a sustainable earth:Print only when necessary.Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140919/67992f19/attachment.html>


More information about the Tutor mailing list