Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 833cc7d

Browse files
__init__ constructor
1 parent f988008 commit 833cc7d

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

‎Class-Attributes/class-attributes-1.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2.7
1+
22

33
# class-attributes-1.py
44

@@ -17,9 +17,9 @@ def set_val(self):
1717

1818

1919
dd = YourClass()
20-
dd.classy # This will fetch the class attribute 10.
20+
print(dd.classy) #10 # This will fetch the class attribute 10.
2121
dd.set_val()
22-
dd.insty # This will fetch the instance attribute 100.
22+
print(dd.insty) #100 # This will fetch the instance attribute 100.
2323

2424
# Once `dd` is instantiated, we can access both the class and instance
2525
# attributes, ie.. dd.classy and dd.insty.

‎init-constructor/init_constructor-1.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python
2-
31
# init_constructor.py
42

53
# __init__() is a constructor method which helps to

‎init-constructor/init_constructor-2.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python
2-
31
# init_constructor-2.py
42

53
# We add a test in the __init__() constructor to check

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /