User Tools

Site Tools


programming:python:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
programming:python:start [2018/12/06 01:15]
dwheele [Data types]
programming:python:start [2026/02/07 19:28] (current)
dwheele [Class]
Line 70: Line 70:
 else: else:
    print 'no'    print 'no'
 +</code>
 +
 +===== Class =====
 +
 +<code python>
 +class Boy()
 +    def setName(self, n):
 +       self.name = n
 +    def getName(self):
 +       return self.name
 +</code>
 +
 +self is like *this* in Java. If you don't provide "self," you are referring to the global variable.
 +
 +<code python>
 +b = Boy()
 +b.setName("bob")
 +</code>
 +
 +===== Display =====
 +
 +(Don't forget the parentheses.)
 +
 +<code python>
 +print ("Hello, world!")
 </code> </code>
  
  
programming/python/start.1544058905.txt.gz ยท Last modified: 2018/12/06 01:15 by dwheele