pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/patrickwolf/python-tutorial/commit/74ffc6fbca818ae412e4684bed90af89f2f427e2

link crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0bd78641c0a1f3e0.css" /> Code Camp LA 2014 updates · patrickwolf/python-tutorial@74ffc6f · GitHub
Skip to content

Commit 74ffc6f

Browse files
committed
Code Camp LA 2014 updates
1 parent 6235249 commit 74ffc6f

File tree

27 files changed

+304
-57
lines changed

27 files changed

+304
-57
lines changed

intro/__init__.py

Whitespace-only changes.

intro/k_references.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
print "\n--- numbers ---"
1010
aint = 5
1111
bint = aint
12-
print "%s,%s | id %s,%s" % (aint, bint, id(aint), id(bint)) # result 6 - 5
12+
print "%s,%s | id %s,%s" % (aint, bint, id(aint), id(bint)) # result 5 - 5
1313
aint = 6
1414
print "%s,%s | id %s,%s" % (aint, bint, id(aint), id(bint)) # result 6 - 5
1515

intro/o_control_structures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# else:
1111
# statements
1212
# ----------------------
13+
1314
print "\n--- if ---"
14-
if ((10 == 5 + 5 or 20 == 10 + 10) and
15-
True):
15+
if ((10 == 5 + 5 or 20 == 10 + 10) and True):
1616
print "correct"
1717
elif 10 == 20:
1818
print "this is wrong"

intro/t_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def add(aint, bint=0, cint=None):
2121
print "\n--- add ---"
2222
print add.__doc__
2323
print add(4)
24+
print add(4, 2, 5)
2425
print add(3, bint=1, cint=15)
2526
print add(10, cint=25)
2627
# ---------------------------

intro/u_classes.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ class Vehicle(object):
99

1010
def __init__(self, name):
1111
self.name = name
12+
13+
def __str__(self, *args, **kwargs):
14+
return "Vehicle class" + self.name
15+
# return object.__str__(self, *args, **kwargs)
1216

13-
def move(self, distance = 1):
17+
def move(self, distance=1):
1418
raise NotImplementedError()
1519

1620
def capabilities(self):
17-
return ["moveable",]
21+
return ["moveable", ]
1822

1923
# ---------------------------
2024
# inheritance
@@ -23,23 +27,24 @@ def capabilities(self):
2327
class Car(Vehicle):
2428

2529
def __init__(self, make, name):
26-
#Call base class constructor
30+
# Call base class constructor
2731
Vehicle.__init__(self, name)
2832
self.make = make
2933

30-
def move(self, distance = 1): # overriding base class method
34+
def move(self, distance=1): # overriding base class method
3135
print "%s-%s moved %d feet" % (self.make, self.name, distance)
3236

3337
def capabilities(self):
34-
parent_capabilities = Vehicle.capabilities(self) # super method call
35-
my_capabilities =["fuel-using","transporter"]
38+
parent_capabilities = Vehicle.capabilities(self) # super method call
39+
my_capabilities = ["fuel-using", "transporter"]
3640
return parent_capabilities + my_capabilities
3741

3842

3943
# ---------------------------
4044
# Instantiate no new needed
4145
# ---------------------------
4246
car = Car("Mercedes", "SL500")
47+
print car
4348

4449
# ---------------------------
4550
# access methods with . notation
@@ -50,4 +55,4 @@ def capabilities(self):
5055
# ---------------------------
5156
# access properties with . notation
5257
# ---------------------------
53-
print car.name
58+
print car.name

intro/x_modules/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''
22
@summary: Python Intro - Modules
33
namespace, reuse
4-
pkg_tools is a package which is compare able to a self contained library with its own name space
4+
pkg_tools is a package which is compareable to a self contained library with its own name space
55
'''
66
from pprint import pprint
77

@@ -14,7 +14,7 @@
1414
pprint (sys.path)
1515

1616
import os
17-
# this path is always added to the sys.path search list
17+
# this path is always adds to the sys.path search list
1818
print os.environ["PYTHONPATH"]
1919

2020
# ---------------------------
@@ -34,7 +34,7 @@
3434
# different ways to import a package into the namespace
3535
# ---------------------------
3636
print "\n--- namespace packages ---"
37-
lst = [1,2,3,1,2,3,4]
37+
lst = [1, 2, 3, 1, 2, 3, 4]
3838
import pkg_tools.mod_lists
3939
print pkg_tools.mod_lists.get_unique_list(lst)
4040

@@ -48,5 +48,6 @@
4848
print getunique(lst)
4949

5050

51+
# Only exectued when this is the startup script
5152
if __name__ == '__main__':
52-
pass
53+
pass

intro/y_packages/__init__.py

Whitespace-only changes.

intro/y_packages/file1.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'''
2+
@summary: Python Intro - Importing Packages
3+
'''
4+
5+
import package.module1
6+
package.module1.Module1()
7+
8+
from package.module1 import Module1
9+
Module1()
10+
11+
from package.subpackage.submodule1 import SubModule1
12+
SubModule1()
13+
14+
from package import *
15+
module1.Module1()
16+
module2.Module2()
17+
18+
if __name__ == '__main__':
19+
pass
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# To expose multiple submodules when * is used
2+
# "from package.subpackage import *"
3+
4+
__all__ = ['module1', 'module2']
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'''
2+
Created on Nov 15, 2014
3+
4+
@author: patrick
5+
'''
6+
7+
class Module1(object):
8+
'''
9+
classdocs
10+
'''
11+
12+
def __init__(self):
13+
'''
14+
Constructor
15+
'''
16+
print __name__

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy