Logo
Explore Help
Register Sign In
fengqi/lv_micropython
1
0
Fork 0
You've already forked lv_micropython
Code Issues Pull Requests 1 Actions Packages Projects Releases Wiki Activity
lv_micropython/tests/basics/class_new.py

28 lines
416 B
Python
Raw Normal View History

py: Initial attempts to actually allow implementing __new__ in Python. Caveat is that __new__ should recurse to base class __new__, and ultimately, object.__new__ is what handles instance allocation.
2014-05-22 00:32:00 +03:00
class A:
def __new__(cls):
print("A.__new__")
return super(cls, A).__new__(cls)
def __init__(self):
pass
def meth(self):
py: Automatically ake __new__ a staticmethod. Addresses issue #622.
2014-07-05 05:55:00 +01:00
print('A.meth')
py: Initial attempts to actually allow implementing __new__ in Python. Caveat is that __new__ should recurse to base class __new__, and ultimately, object.__new__ is what handles instance allocation.
2014-05-22 00:32:00 +03:00
#print(A.__new__)
#print(A.__init__)
a = A()
py: Automatically ake __new__ a staticmethod. Addresses issue #622.
2014-07-05 05:55:00 +01:00
a.meth()
a = A.__new__(A)
a.meth()
py: Initial attempts to actually allow implementing __new__ in Python. Caveat is that __new__ should recurse to base class __new__, and ultimately, object.__new__ is what handles instance allocation.
2014-05-22 00:32:00 +03:00
#print(a.meth)
#print(a.__init__)
#print(a.__new__)
py: Automatically ake __new__ a staticmethod. Addresses issue #622.
2014-07-05 05:55:00 +01:00
# __new__ should automatically be a staticmethod, so this should work
a = a.__new__(A)
a.meth()
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 49ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API