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: | |
def __init__(self, func): | |
self.age = 10 | |
self.talent = func | |
def bark(self): | |
print("Bark !!!") | |
@Dog | |
def dog_can_pee(): |
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
import time | |
def print_func_name(time): | |
def decorator(func): | |
def wrap(): | |
print("Now use function '{}'".format(func.__name__)) | |
print("Now Unix time is {}.".format(int(time))) | |
func() |
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 print_func_name(func): | |
def warp_1(): | |
print("Now use function '{}'".format(func.__name__)) | |
func() | |
return warp_1 | |
def print_time(func): | |
import time | |
def warp_2(): |
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 print_func_name(func): | |
def warp_1(): | |
print("Now use function '{}'".format(func.__name__)) | |
func() | |
return warp_1 | |
def print_time(func): | |
import time | |
def warp_2(): |
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 print_func_name(func): | |
def warp(): | |
print("Now use function '{}'".format(func.__name__)) | |
func() | |
return warp | |
@print_func_name | |
def dog_bark(): | |
print("Bark !!!") |
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 print_func_name(func): | |
def wrap(): | |
print("Now use function '{}'".format(func.__name__)) | |
func() | |
return wrap | |
def dog_bark(): | |
print("Bark !!!") |
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 solution(input, k): | |
storage_dict = dict() | |
storage_dict[0] = [len(input) - 1] | |
current_index, prev_index = 0, None | |
input.append(-float("inf")) | |
for i in range(k - 1): | |
left_index = (current_index + 1) * 2 - 1 | |
right_index = left_index + 1 |
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
import abc | |
class Dog(metaclass=abc.ABCMeta): | |
base = "Animal" | |
@abc.abstractmethod | |
def eat_shit(self): | |
return NotImplemented |
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
import abc | |
class Dog(metaclass=abc.ABCMeta): | |
@abc.abstractmethod | |
def eat_shit(self): | |
return NotImplemented | |
@abc.abstractmethod | |
def pee(self): |
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
import abc | |
class Dog(metaclass=abc.ABCMeta): | |
@abc.abstractmethod | |
def eat_shit(self): | |
return NotImplemented | |
class Shiba(Dog): |