This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients pitrou, vstinner
Date 2008-08-21.10:16:39
SpamBayes Score 0.0017293107
Marked as misclassified No
Message-id <1219313802.53.0.306626140885.issue3630@psf.upfronthosting.co.za>
In-reply-to
Content
With immutable types, you must use __new__ instead. Passing the
arguments to __init__ is too late since the object is immutable and it
has already been built in memory, thus you can't initialize it with
another value.

>>> class B(bytes):
...  def __new__(cls, *args, **kargs):
...   print(args)
...   return bytes.__new__(cls, *args, **kargs)
...
>>> b = B(b"foo")
(b'foo',)
>>> b
b'foo'
>>> type(b)
<class '__main__.B'>
History
Date User Action Args
2008-08-21 10:16:42pitrousetrecipients: + pitrou, vstinner
2008-08-21 10:16:42pitrousetmessageid: <1219313802.53.0.306626140885.issue3630@psf.upfronthosting.co.za>
2008-08-21 10:16:40pitroulinkissue3630 messages
2008-08-21 10:16:39pitroucreate