[Python-Dev] SyntaxError: can't assign to function call (original) (raw)

James Y Knight foom at fuhm.net
Thu Aug 10 18:19:22 CEST 2006


On Aug 10, 2006, at 12:01 PM, Josiah Carlson wrote:

"Michael Urman" <murman at gmail.com> wrote:

On 8/9/06, Michael Hudson <mwh at python.net> wrote: The question doesn't make sense: in Python, you assign to a name, an attribute or a subscript, and that's it. Just to play devil's advocate here, why not to a function call via a new setcall? I'm not saying there's the use case to justify it, but I don't see anything that makes it a clear abomination or impossible with python's syntax. Describe the syntax and semantics. Every time I try to work them out, I end up with a construct that makes less than no sense, to be used in cases I have never seen. Further, if you want to call a method setcall_ on an object just created, you can use 'x()._setcall (y)'. There is no reason to muck up Python's syntax.

It makes just as much sense as assigning to an array access, and the
semantics would be pretty similar. There's similarly "no reason" to
allow x[5] = True. You can just spell that x.setitem(5, True).

x(*args, **kwargs) = val could translate into x.setcall(val,
*args, **kwargs). x(5) = True could translate into x.setcall(True, 5)

Please note I'm actually arguing for this proposal. Just agreeing
that it is not a completely nonsensical idea.

James



More information about the Python-Dev mailing list