On Thu, Dec 12, 2019 at 02:14:09PM -0500, Ricky Teachey wrote: > 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): ...
`__new__` is normally written with `cls` as the first argument, since it receives the class as first argument, not self (which doesn't exist yet). > t = (1,2,3) > tuple(t) # returns (1,2,3) tuple(t) isn't the same as tuple(1, 2, 3). Try it and see. tuple(t) passes a single argument to the tuple() constructor, which in the event that the argument is already tuple, returns it unchanged. > MyWeirdTuple(t) # is t the first argument, or is 1 the first argument? t is unambiguously the first argument. -- Steven _______________________________________________ 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/TJVREORJOXSJSSM7AH5A3JJP6WUFFD5K/ Code of Conduct: http://python.org/psf/codeofconduct/