Test modules.
This commit is contained in:
parent
8fc8c48ff3
commit
d6c6b781d5
BIN
__pycache__/mymodule.cpython-39.pyc
Normal file
BIN
__pycache__/mymodule.cpython-39.pyc
Normal file
Binary file not shown.
32
main.py
32
main.py
@ -1,24 +1,8 @@
|
|||||||
#Iteration test
|
#Module test
|
||||||
a = (1, 2, 3)
|
import mymodule as m
|
||||||
b = iter(a)
|
from mymodule import foo as bar
|
||||||
print(next(b))
|
m.greeting(m.author)
|
||||||
print(next(b))
|
import platform as plat
|
||||||
print(next(b))
|
print(plat.system())
|
||||||
|
print(dir(plat))
|
||||||
class A:
|
print(bar())
|
||||||
def __init__(self):
|
|
||||||
self.n = 0
|
|
||||||
def __init__(self, n):
|
|
||||||
self.n = n
|
|
||||||
def __iter__(self):
|
|
||||||
self.i = 0
|
|
||||||
return self
|
|
||||||
def __next__(self):
|
|
||||||
if self.i > 100 or self.i < -100: raise StopIteration
|
|
||||||
z = self.i
|
|
||||||
self.i -= self.n
|
|
||||||
return z
|
|
||||||
c = A(2)
|
|
||||||
d = iter(c)
|
|
||||||
for x in d:
|
|
||||||
print(x)
|
|
||||||
|
6
mymodule.py
Normal file
6
mymodule.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
def greeting(inpt):
|
||||||
|
print(f"Hello {inpt}!")
|
||||||
|
author = "Alfred"
|
||||||
|
def foo():
|
||||||
|
print("Foo Fighters!")
|
||||||
|
return "Bar"
|
Loading…
Reference in New Issue
Block a user