if else
name = 'alice'
if name == 'bob':
num = 1
elif name == 'alice':
num = 2
else:
num = 3
if else
name = 'alice'
if name == 'bob':
num = 1
elif name == 'alice':
num = 2
else:
num = 3
>>> import openpyxl | |
>>> import glob | |
>>> | |
>>> update_files = glob.glob('*.xlsx') | |
>>> for i in update_files: | |
... wb = load_workbook(filename=i) | |
... sheet = wb['Sheet1'] | |
... for row in sheet.iter_rows(): | |
... if row[3].value=='4XL' and row[4].value=='8572533': |
MONSTER - Daydream In Blue | |
Blonde Redhead - For the Damaged Coda | |
While My Guitar Gently Weeps - Regina Spektor | |
Caravan Palace - Lone Digger | |
The Dead South - In Hell I'll Be In Good Company | |
twenty one pilots - Stressed Out | |
twenty one pilots - Chlorine | |
Tame Impala - Feels Like We Only Go Backwards | |
alt-J - Left Hand Free | |
Chet Faker - Gold |
ermine jose 1 month ago
Add 150 ml oil ( preferably sunflower)
Add 50 ml ghee
Add garam masala ( spices )
Add 400 g onion fry till golden brown (25 to 30 mins
Add ginger garlic past ( 110 g ginger and 80 g garlic, turn the heat to sim now as they get burnt , fry for 10 to 15 mins )
Add 100 ml curd, 1 tablespoon lemon juice, 35 g salt, 2 tablespoon chilli powder, 4 green chillis, tomatoes and mint and coriander leaves ( stir for 10 mins )
>>> from functools import partial | |
>>> | |
>>> def foo(a,b): | |
... return a+b | |
... | |
>>> bar = partial(foo, a=1) # equivalent to: foo(a=1, b) | |
>>> bar(b=10) | |
11 | |
>>> bar(a=101, b=10) | |
111 |
>>> class mytype(type): | |
... def __new__(meta, clsname, bases, methods): | |
... print('Creating: ', clsname) | |
... return super().__new__(meta, clsname, bases, methods) | |
... | |
>>> class Spam(metaclass=mytype): | |
... def __init__(self, y): | |
... self.y = y | |
... def bar(self): | |
... print('bar') |
>>> class Foo(object): | |
... def __init__(self, x): | |
... self.x = x | |
... def spam(self): | |
... print('spam') | |
... | |
>>> f = Foo(2) | |
>>> f.x | |
2 | |
>>> f.spam() |
>>> class Spam: | |
... def __init__(self, value): | |
... self.value = value | |
... def yow(self): | |
... print('Yow!') | |
... def grok(self): | |
... print('Grok!') | |
... | |
>>> vars(Spam) | |
mappingproxy({'__module__': '__main__', '__init__': <function Spam.__init__ at 0x7f95b61a0d08>, 'yow': <function Spam.yow at 0x7f95b61a0d90>, 'grok': <function Spam.grok at 0x7f95b61b0048>, '__dict__': <attribute '__dict__' of 'Spam' objects>, '__weakref__': <attribute '__weakref__' of 'Spam' objects>, '__doc__': None}) |
>>> def boo_what(fmt): | |
... def boo(func): | |
... def wrapper(*args, **kwargs): | |
... print(f'BOO {fmt}') | |
... return func(*args, **kwargs) | |
... return wrapper | |
... return boo | |
... | |
>>> @boo_what('hello') | |
... def add(x, y): |