> > But what would happen if you call a user-defined class with a tuple as
> an argument?
> >
> > class MyWeirdTuple(tuple):
> >     def __new__(self, tup, *args): ...
> >
> > t = (1,2,3)
> > tuple(t)  # returns (1,2,3)
> > MyWeirdTuple(t)  # is t the first argument, or is 1 the first argument?
>
> That’s not even about subscripting syntax, it’s about calling syntax, and
> I can’t see why you’d want to change that (or change how type.__call__
> delegates to __new__ and __init__, or give tuple a weird metaclass that
> overrides that, or anything else relevant) just because you changed
> subscripting.
>
> So t would be the first argument, the same as always. If you want 1 to be
> the first argument, you have to write MyWeirdTuple(*t).
>
>
Yes, of course. tuple() and () aren't the same animal. Apologies. I used to
make that mistake a lot as a beginner and it still gets me from time to
time.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/NZTIU4JPG7RVI5QWBOSTFLYFLC4QQWZH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to