Skapa modul av classer
2 svar · 423 visningar · startad av ps
Öh... om du har en modul som heter personer.py, som ser ut så här...
class Person:
def __init__(self, name, hobby):
self.name = name
self.hobby = hobby
... så importeras den så här...
import personer
kalle = personer.Person("Kalle", "ölhävning")
Detta förutsätter att personer.py finns i en katalog som finns i din PYTHONPATH, eller att den ligger i samma katalog som koden som importerar den körs ifrån.
------------------
These are the cries of the carrots, the cries of the carrots! You see, Reverend Maynard, tomorrow is harvest day and to them it is the holocaust.