From babba04ae075be8285943f23d65e359cc8c7bb86 Mon Sep 17 00:00:00 2001
From: Habiba Sorour
class Dog:
- """ A simple Dog class definition. """
+ """ A simple Dog class definition. """
def __init__(self, name, breed, fur_color):
# constructor method to create a Dog object
self.name = name
@@ -175,7 +175,7 @@
-
+
def main():
print("Hello World!")
@@ -184,7 +184,11 @@
- Remember that we can define this program right at the Python command line and then run it as per .
+ Remember that we can define this program right at the Python command line and then run it with main() Try it in .
+
+
+
+ The command line interface of the program is shown in .
@@ -494,7 +498,7 @@ System.
-
+
class Hello(object):
@staticmethod
@@ -506,21 +510,25 @@ class Hello(object):
Notice that we used the decorator @staticmethod to tell the Python interpreter that main is going to be a static method.
- The impact of this is that we don’t have to, indeed we should not, use self as the first parameter of the main method! Using this definition we can call the main method in a Python session like .
+ The impact of this is that we don’t have to, indeed we should not, use self as the first parameter of the main method! Using this definition we can call the main method in a Python session with Hello.main("") . Try it in .
+
+ The command line interface of the program is shown in .
+
>>> Hello.main("")
Hello World!
->>>
+
+
Summary & Reading Questions