SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы
НазадМетки: python
You can turn a list into function arguments using *:
def f(a,b,c): print a, b, c x = [1,2,3] f(*x) f(*(1,2,3))
You can compose classes using import. Here’s a method that can be reused by multiple classes:
# PythonForProgrammers/utility.py
def f(self): print “utility.f()!!!”
Here’s how you compose that method into a class:
# PythonForProgrammers/compose.py
class Compose:
from utility import f
Compose().f()
Note
Suggest Further Topics for inclusion in the introductory chapter