Special Method Protocols
__getnewargs__() — serialization protocol
Supply positional arguments to __new__ during reconstruction under pickle protocols 2 and newer. If __getnewargs_ex__ is present, it takes precedence. State restoration is separate; __init__ is not generally called.
Formal Syntax & Structure
python syntaxpython
def __getnewargs__(self):Return Value
tuple
Positional construction arguments.
Working Example
Example Snippetpython
import copyclass Label(str): def __new__(cls, value): return super().__new__(cls,value.upper()) def __getnewargs__(self): return (str(self),)print(str(copy.copy(Label("ready"))))