Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
damsel in distress
#2
Something perhaps like...
class Smith:
  lastname = "Smith"
  def say_hello(self):
    print(f"Hi, I'm {self.firstname} {self.lastname}!")

class John(Smith):
    firstname = "John"

class Jane(Smith):
    firstname = "Jane"


# not on the shirt but an example in action...
John().say_hello()
Jane().say_hello()
Output:
Hi, I'm John Smith! Hi, I'm Jane Smith!
Reply


Messages In This Thread
damsel in distress - by martav - Jun-06-2018, 08:41 PM
RE: damsel in distress - by micseydel - Jun-07-2018, 02:20 AM
RE: damsel in distress - by martav - Jun-09-2018, 06:26 AM
RE: damsel in distress - by Nwb - Jun-12-2018, 03:13 PM
RE: damsel in distress - by martav - Jun-13-2018, 05:42 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020