Exemple #1
0
#!/usr/bin/env python3
#
#  Copyright (c) 2014 Paul Gerrard
#  This program is free software.
#  license: GNU General Public License version 3
#
#  This code is an example from `Lean Python`: http://leanpy.com/
#
import mod1 as m1

m1.hello()
print('written by', m1.writtenby)

greet = m1.greeting()
greet.morning()
greet.evening()
Exemple #2
0
#!/usr/bin/env python3
#
#  Copyright (c) 2014 Paul Gerrard
#  This program is free software.
#  license: GNU General Public License version 3
#
#  This code is an example from `Lean Python`: http://leanpy.com/
#
from mod1 import greeting, hello, writtenby

hello()
hello.writtenby = 'xxx'
print('written by', hello.writtenby)
print(writtenby)

greet = greeting()
greet.morning()
greet.evening()
Exemple #3
0
import mod1

mod1.hello()
print("Name of module2 = ",__name__)
Exemple #4
0
import mod1


class Person:
    def __init__(self, first_name="", last_name=""):
        self.first_name = first_name
        self.last_name = last_name

    def get_name(self):
        return self.first_name + " " + self.last_name

    def __str__(self):
        return self.last_name + ", " + self.first_name


person1 = Person("John", "Smith")
print(person1.first_name, person1.last_name)
print(person1.get_name())
print(person1)

print(mod1.hello())