staticmethod example 3
This commit is contained in:
parent
bef5decfb9
commit
f6d3145a2e
12
python-temel/staticmethod.3.py
Normal file
12
python-temel/staticmethod.3.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
class Sample:
|
||||
def foo(self):
|
||||
print('foo')
|
||||
|
||||
@staticmethod
|
||||
def bar(self):
|
||||
print('bar')
|
||||
|
||||
s = Sample()
|
||||
s.foo() # Sample.foo(s)
|
||||
s.bar(10) # geçerli, 10 burada self'e atanacak
|
||||
#s.bar() # exception, çünkü self sıradan bir parametre
|
15
python-temel/staticmethod.3.py~
Normal file
15
python-temel/staticmethod.3.py~
Normal file
|
@ -0,0 +1,15 @@
|
|||
class Sample:
|
||||
def foo(self):
|
||||
print('foo')
|
||||
|
||||
@staticmethod
|
||||
def bar(self):
|
||||
print('bar')
|
||||
|
||||
s = Sample()
|
||||
s.foo()
|
||||
# Sample.foo(s)
|
||||
s.bar(10)
|
||||
# geçerli, 10 burada self'e atanacak
|
||||
s.bar()
|
||||
# exception, çünkü self sıradan bir parametre
|
Loading…
Reference in New Issue
Block a user