Create Class Object / Save 2 File
# --- Objects, Classses, ----
# As with other Ojects in Programming:
# Ojbect
# - Class
# -- Properties (Data Members)
# -- Methods (Functions)
# -- Attributes (Variables)
# - Dotted Access Notation
# - Example Class.Property
# --- Decalre Object Class ---
class myface:
# Set Properties
nosedata='my nose is real.'
eyesdata='my eyes are round.'
# Create Method (Function)
def nose (info):
return(info + ' said, my face is special.\n')
# Create Method (Function)
def eyes (info):
return(info + ', my eyes are blue.\n')
Call From File
# --- Import Class Object and Call Methods ---
from Class_Face import *
# --- Call Objects Method and Populate Argument
nose_var=(myface.nose('Scotty'))
eyes_var=(myface.eyes('Yes'))
# --- Print Object Methods Results to Screen
print(nose_var)
print(eyes_var)
# --- Pull a Object Class Property Print & Format String
print (myface.nosedata.title())
print (myface.eyesdata.upper())
Output Results
# Output
Scotty said, my face is special.
Yes, my eyes are blue.
My Nose Is Real.
MY EYES ARE ROUND.