This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DogMeta(type): | |
def __new__(cls, name, bases, dct): | |
print(f">> DogMeta __new__: {name}") | |
print(f">> DogMeta __new__: {bases}") | |
print(f">> DogMeta __new__: {dct}") | |
x = super().__new__(cls, name, bases, dct) | |
x.race = "Dog" | |
return x | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog(object): | |
def init(self, name): | |
self.name = name | |
def bark(self): | |
print("Wooof! " + self.name) | |
def walk(self): | |
print("Hey! I'm walking!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bark(self): | |
print("Wooof! " + self.name) | |
def walk(self): | |
print("Hey! I'm walking!") | |
def init(self, name): | |
self.name = name | |
Dog = type("Dog", (object,), {"bark": bark, "walk": walk, "init": init}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
mail "github.com/xhit/go-simple-mail/v2" | |
) | |
var htmlBody = ` | |
<html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getClient(config *oauth2.Config) *http.Client { | |
tokFile := "token.json" | |
tok, err := loadToken(tokFile) | |
if err != nil { | |
tok = getTokenFromWeb(config) | |
saveToken(tokFile, tok) | |
} | |
return config.Client(context.Background(), tok) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass: | |
def __repr__(self) -> str: | |
return 'My Class Repr' | |
def __str__(self) -> str: | |
return 'My Super Class' | |
def __format__(self, __format_spec: str) -> str: | |
return 'My Formatted Class' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iv := make([]byte, block.BlockSize()) | |
msgLen := fi.Size() - int64(len(iv)) | |
_, err = infile.ReadAt(iv, msgLen) | |
if err != nil { | |
log.Fatal(err) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> x = 10 | |
>>> a = 'some string' | |
>>> class V: | |
... pass | |
... | |
>>> type(x) | |
<class 'int'> | |
>>> type(a) | |
<class 'str'> | |
>>> type(V) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> class V: | |
... pass | |
... | |
>>> dir(V) | |
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', | |
'__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', | |
'__init__', '__init_subclass__', '__le__', '__lt__', '__module__', | |
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', | |
'__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__'] | |
>>> V.__name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def add_one(x): | |
... return x + 1 | |
... | |
>>> dir(add_one) | |
['__annotations__', '__builtins__', '__call__', '__class__', '__closure__', '__code__', | |
'__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', | |
'__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', | |
'__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', | |
'__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', | |
'__str__', '__subclasshook__'] |
NewerOlder