Pyta = Python + Beta
Inspired by: http://www.cs.utah.edu/plt/publications/oopsla04-gff.pdf
Usage
Inner dispatch is used to guarantee pre- and post-conditions without using auxiliary methods. An external dispatch results in the lowest method that calls inner being called. An inner(cls, self) call calls the next highest method that has an inner call, or the highest method if there is no higher inner method. super works the same as before, but take care not to cause an infinite loop.
Full example:
from pyta import inner, BetaMetaclass
class A(object):
def foo(self):
print "world!"
class B(A): # Can inherit from regular classes
# The lowest class in the hierarchy that uses `inner` needs the metaclass
__metaclass__ = BetaMetaclass
def foo(self):
inner(B, self).foo() # Calls C.foo
super(B, self).foo() # Calls A.foo
class C(B):
def foo(self):
print "Hello, "
obj = C()
obj.foo() # External dispatch; calls B.foo
Caveats
Because using inner in a superclass completely changes which method an external dispatch resolves to (it’s no longer the most-overriding method) the metaclass is required to inspect the source of the methods and sprinkle some magic to make it all work.
In order for everything to work properly, you must call inner(cls, self) lexically. In other words, it won’t work if you do this:
bar = inner bar(cls, self).foo()
Or this:
from pyta import inner as bar bar(cls, self).foo()
Currently, the implementation doesn’t distinguish between strings vs. actual method calls, so if your method contains a string like "text inner( moretext", it’ll break everything.
Metadata
Release files for pyta 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyta-0.1.1.zip | 4.7 kB | Without provenance | Details for pyta-0.1.1.zip |
Release files / pyta-0.1.1.zip
| Download URL | pyta-0.1.1.zip |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf9d22b2ae1d5593e661f1ca106b7716127de07b12e2411ed8a6f953a1d36716
|
|
BLAKE2b-256 checksum How to use checksums |
c60a3344369bb8f96f13a3448896f70cdf8705b4b75f21c6201b89d3a0feb122
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyta 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.