10000 Implement py.None and NoneType · go-python/gpython@c305f37 · GitHub
[go: up one dir, main page]

Skip to content

Commit c305f37

Browse files
committed
Implement py.None and NoneType
1 parent 8ad766a commit c305f37

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

py/none.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// None objects
2+
3+
package py
4+
5+
type NoneType struct{}
6+
7+
var (
8+
NoneTypeType = NewType("NoneType", "")
9+
// And the ubiquitous
10+
None = NoneType(struct{}{})
11+
)
12+
13+
// Type of this object
14+
func (s NoneType) Type() *Type {
15+
return NoneTypeType
16+
}
17+
18+
func (a NoneType) M__bool__() Object {
19+
return False
20+
}
21+
22+
// Check interface is satisfied
23+
var _ I__bool__ = None

py/py.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Object interface {
88

99
// Some well known objects
1010
var (
11-
None, Elipsis Object
11+
Ellipsis Object
1212
)
1313

1414
// Called to create a new instance of class cls. __new__() is a static method (special-cased so you need not declare it as such) that takes the class of which an instance was requested as its first argument. The remaining arguments are those passed to the object constructor expression (the call to the class). The return value of __new__() should be the new object instance (usually an instance of cls).

0 commit comments

Comments
 (0)
0