- Source:
Methods
(static) inherits()
Code taken from goog.inherits
Newer versions of the closure library add a "base"attribute, which we don't want/need. So, this code is the remainder of the goog.inherits function.
- Source:
(static) iter(obj) → {Object}
Get the iterator for a Python object This iterator could be one of the following. This is the preferred mechanism for consistently getting the correct iterator. You should not just use tp$iter because that could lead to incorrect behavior of a user created class.
- tp$iter
- A user defined
__iter__
method - A user defined
__getitem__
method
Parameters:
Name | Type | Description |
---|---|---|
obj |
- Source:
Throws:
Returns:
- Type
- Object
(static) lookupSpecial() → {null|Object}
Special method look up. First try getting the method via internal dict and getattr. If getattr is not present (builtins) try if method is defined on the object itself
- Source:
Returns:
Return null if not found or the function
- Type
- null | Object
(static) markUnhashable(thisClass) → {undefined}
Mark a class as unhashable and prevent its __hash__
function from being called.
Parameters:
Name | Type | Description |
---|---|---|
thisClass |
* | The class to mark as unhashable. |
- Source:
Returns:
- Type
- undefined
(static) sequenceContains(seq, ob, canSuspendopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
seq |
* | ||
ob |
* | ||
canSuspend |
boolean |
<optional> |
- Source:
(static) setUpInheritance(childName, child, parent) → {undefined}
Set up inheritance between two Python classes. This allows only for single inheritance -- multiple inheritance is not supported by Javascript.
Javascript's inheritance is prototypal. This means that properties must be defined on the superclass' prototype in order for subclasses to inherit them.
Sk.superclass.myProperty # will NOT be inherited
Sk.superclass.prototype.myProperty # will be inherited
In order for a class to be subclassable, it must (directly or indirectly) inherit from Sk.builtin.object so that it will be properly initialized in Sk.doOneTimeInitialization (in src/import.js). Further, all Python builtins should inherit from Sk.builtin.object.
Parameters:
Name | Type | Description |
---|---|---|
childName |
string | The Python name of the child (subclass). |
child |
* | The subclass. |
parent |
* | The superclass. |
- Source:
Returns:
- Type
- undefined
(static) superConstructor(thisClass, self, …args) → {undefined}
Call the super constructor of the provided class, with the object self
as
the this
value of that constructor. Any arguments passed to this function
after self
will be passed as-is to the constructor.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
thisClass |
* | The subclass. |
|
self |
Object | The instance of the subclas. |
|
args |
? |
<repeatable> |
Arguments to pass to the constructor. |
- Source:
Returns:
- Type
- undefined