Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...super actually become a keyword? Closed Issues super used with __call__ attributes Reference Implementation Alternative Proposals No Changes Dynamic attribute on super type super(__this_class__, self) self.__super__.foo(*args) super(self, *args) or __super__(self, *args) super.foo(self, *args) super or super() super(*p, **kw) History References Copyright Numbering Note This PEP has been renumbered to PEP 3135. The text below is the last version submitted under the old number. Abstr...
...super actually become a keyword? super used with __call__ attributes Alternative Proposals No Changes Dynamic attribute on super type self.__super__.foo(*args) super(self, *args) or __super__(self, *args) super.foo(self, *args) super(*p, **kw) History References Copyright Numbering Note This PEP started its life as PEP 367. Since it is now targeted for Python 3000, it has been moved into the 3xxx space. Abstract This PEP proposes syntactic sugar for use of the super type to automatical...
...super__ An earlier version of this PEP used the following static method on classes: def __getattribute_super__(cls, name, object, owner): pass This method performed name lookup as well as invoking descriptors and was necessarily limited to working only with super.__getattribute__. Reuse tp_getattro It would be nice to avoid adding a new slot, thus keeping the API simpler and easier to understand. A comment on Issue 18181 asked about reusing the tp_getattro slot, that is super could call the...
...super.m() B._B__super = super(B) class C(A): def m(self): "save C's data"; self.__super.m() C._C__super = super(C) class D(B, C): def m(self): "save D's data"; self.__super.m() D._D__super = super(D) Part of the trick is in the use of the name __super, which (through the name mangling transformation) contains the class name. This ensures that self.__super means something different in each class (as long as the class names differ; unfortunately,...
...super.m() B._B__super = super(B) class C(A): def m(self): "save C's data"; self.__super.m() C._C__super = super(C) class D(B, C): def m(self): "save D's data"; self.__super.m() D._D__super = super(D) Part of the trick is in the use of the name __super, which (through the name mangling transformation) contains the class name. This ensures that self.__super means something different in each class (as long as the class names differ; unfortunately, it is possible in Python t...
...super(C, self).meth() # Hope C is never rebound. class D(C): def meth(self): # ?!? issubclass(D,C), so it "works": super(C, self).meth() Proposal: Add a __class__ keyword which refers to the class currently being defined (executed). (But see open issues.) class C(B): def meth(self): super(__class__, self).meth() Note that super calls may be further simplified by the "New Super" PEP (Spealman). The __class__ (or __this_class__) attribute came up in attempts ...
...super().__new__(cls, *args) name, bases, ns = args init = ns.get('__init_subclass__') if isinstance(init, types.FunctionType): ns['__init_subclass__'] = classmethod(init) self = super().__new__(cls, name, bases, ns) for k, v in self.__dict__.items(): func = getattr(v, '__set_name__', None) if func is not None: func(self, k) super(self, self).__init_subclass__(**kwargs) return self def...
...super() cannot be used to call methods (e.g., super(Example, cls) wouldn't work in the example above). However, the zero argument form of super() works as expected, since the __class__ reference is already initialised. This general proposal is not a new idea (it was first suggested for inclusion in the language definition more than 10 years ago, and a similar mechanism has long been supported by Zope's ExtensionClass), but the situation has changed sufficiently in recent years that the idea is w...
...super happy to now support Python core development and Python Packaging in new ways: Core Development: In July 2021, the PSF hired its inaugural Developer-in-Residence, Łukasz Langa. Łukasz works full-time (one year term) to assist CPython maintainers and the Python Steering Council. Areas of responsibility include analytical research to understand the project's volunteer hours, investigating project priorities and tasks as we advance, and working on those priorities. Packaging: In August 20...
...super() - Now support instances whose type() is not equal to their __class__. (New in 2.3a2.) As of 2.3b1, super() no longer ignores data descriptors, except for __class__. raw_input() - can now return Unicode objects (if sys.stdin is Unicode-capable). (New in 2.3a2.) slice() and buffer() - these are now types rather than functions. The constructors have the same signature as the functions in the past. PyThreadState_SetAsyncEnc() - A new API (deliberately accessible only from C) to interrupt...
...super majority of Python developers vote "no confidence", the GUIDO is recalled. A second vote is then conducted to select the new GUIDO, in accordance with the procedures for initial section of this office holder. During the time in which there is no GUIDO, major decisions are put on hold, but normal Python operations may of course continue. Day-to-day operations The GUIDO is not needed for all -- or even most -- decisions. Python developers already have plenty of opportunity for delegatio...
...Super Bowls are counted with Roman numerals, and many older movies have copyright dates in Roman numerals. Further, LISP provides a Roman numerals literal package, so adding Roman numerals to Python will help ease the LISP-envy sometimes seen in comp.lang.python. Besides, the author thinks this is the easiest way to get his name on a PEP. Syntax for Roman literals Roman numeral literals will consist of the characters M, D, C, L, X, V and I, and only those characters. They must be in upper c...
...super-classes (class invariants are ANDed with super-class invariants). These invariants are checked in method-resolution order. A method's post-conditions also include all overridden post-conditions (method post-conditions are ANDed with all overridden method post-conditions). An overridden method's pre-conditions can be ignored if the overriding method's pre-conditions are met. However, if the overriding method's pre-conditions fail, all of the overridden method's pre-conditions must also fa...
...super-instructions and other optimizations enabled by quickening. Further increases in the benefits of other optimizations, as they can exploit, or be exploited by specialization. Implementation Overview Once any instruction in a code object has executed a few times, that code object will be "quickened" by allocating a new array for the bytecode that can be modified at runtime, and is not constrained as the code.co_code object is. From that point onwards, whenever any instruction in that co...
...Super?) # true A new dunder method will need to be implemented to allow the ? operator to be overloaded for other functionality. Backwards Compatibility ? is currently unused in Python syntax, therefore this PEP is fully backwards compatible. Reference Implementation A reference implementation can be found here [5]. Rejected Ideas Discussed alternatives were The ~ operator was considered in place of ?. A prefix operator (?int). References [2]Use of Optional Annotations in Open Sour...
...super-majority of core developers who are in favor of the change. This strongly suggests the change should not be made in the shape described by the PEP. New core developer nomination requires there to be no votes cast against it. Votes of no confidence require a super-majority of at least 2/3rds of the non-dormant core developer population to explicitly vote in favor of the motion. Omissions This document deliberately omits listing possible areas of interest within the project. It also do...
...super().__new__(mcls, name, bases, dct) def __init__(cls, name, bases, dct, **kwargs): return super().__init__(name, bases, dct) class Foo(metaclass=FooMeta): def __init__(self, spam:int=42): self.spam = spam def __call__(self, a, b, *, c) -> tuple: return a, b, c @classmethod def spam(cls, a): return a def shared_vars(*shared_args): """Decorator factory that defines shared variables that are passed to every invocation of t...
...superset of ECMAScript. It supports inferfaces and strong runtime-checked static typing. Compilation supports a “strict dialect” where type mismatches are reported at compile-time. Example code with types: package { import flash.events.Event; public class BounceEvent extends Event { public static const BOUNCE:String = "bounce"; private var _side:String = "none"; public function get side():String { return _side; } public function BounceEvent(type:String, side:S...