Skip to content

Instantly share code, notes, and snippets.

@erlnby
erlnby / staticmethod vs classmethod
Last active June 4, 2020 06:26
The obvious difference between @staticmethod and @classmethod in Python
class A:
a = 123
@staticmethod
def sF():
print(A.a)
@classmethod
def cF(cls):
print(cls.a)
import array as ar
old = ar.array('u', 'itmathrepetitor')
new = ar.array('u', 'silence')
line = input()
a = ar.array('u', line)
for i in range(len(line) - len(old) + 1):
if a[i:i + len(old)] == old:
a[i:i + len(old)] = new
class ValA:
def __init__(self, obj):
self.obj = obj
def get(self):
return self.obj
def set(self, obj):
self.obj = obj
override fun compareTo(other: Vertex): Int {
if (this.distance == other.distance) {
return this.index - other.index
} else {
return this.distance - other.distance
}
}