Skip to content

Instantly share code, notes, and snippets.

@halfnibble
Last active August 29, 2015 14:23
Show Gist options
  • Save halfnibble/e4b97cafa94a8ec09136 to your computer and use it in GitHub Desktop.
Save halfnibble/e4b97cafa94a8ec09136 to your computer and use it in GitHub Desktop.
Python Example
# Imports
import os
from decimal import Decimal
# Variables
my_name = 'Joshua D. Wedekind'
my_rate = Decimal('120.00')
current_dir = os.getcwd()
# Classes
class Person:
""" Excellent place to put a 'docstring' describing the class. """
def __init__(self, name=None):
if name is not None:
self.name = name
def first_name(self):
name_array = self.name.split()
return name_array[0]
def last_name(self):
name_array = self.name.split()
return name_array[-1]
me = Person(name=my_name)
print "My entire name is:", me.name
# '"My entire name is: Joshua D. Wedekind'
print "My first name is:", me.first_name()
# 'My first name is: Joshua'
print "My last name is:", me.last_name()
# 'My last name is: Wedekind'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment