Difference between revisions of "Classes"

From wikieduonline
Jump to navigation Jump to search
Line 8: Line 8:
 
  <code>[[global]]</code>
 
  <code>[[global]]</code>
 
  <code>[[nonlocal]]</code>
 
  <code>[[nonlocal]]</code>
 +
 +
 +
class Dog:
 +
    kind = 'canine'        # class variable shared by all instances
 +
    def __init__(self, name):
 +
        self.name = name    # instance variable unique to each instance
 +
 +
  
 
== Related ==
 
== Related ==

Revision as of 08:22, 3 March 2022

Advertising: