mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-17 20:11:57 +02:00
Add python3 class notes (#2479)
* explain that you can place the human and bat classes into seperate files * explain how to import specific functions from other files
This commit is contained in:
@@ -765,8 +765,13 @@ if __name__ == '__main__':
|
|||||||
print(b.say('hello'))
|
print(b.say('hello'))
|
||||||
print(b.fly)
|
print(b.fly)
|
||||||
|
|
||||||
|
# To take advantage of modularization by file you could place the classes above in their own files,
|
||||||
|
# say, human.py and bat.py
|
||||||
|
|
||||||
|
# to import functions from other files use the following format
|
||||||
# from "filename-without-extension" import "function-or-class"
|
# from "filename-without-extension" import "function-or-class"
|
||||||
|
|
||||||
|
# superhero.py
|
||||||
from human import Human
|
from human import Human
|
||||||
from bat import Bat
|
from bat import Bat
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user