Skip to content

Commit 408c7e4

Browse files
committed
Fixed Sha-Bang; Tweaks to docstrings
1 parent 176a654 commit 408c7e4

8 files changed

+22
-19
lines changed

class_attributes_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

33
"""Using class attributes
44

class_instance_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

33
"""Instantiating classes in Python
44

class_sample.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

3-
"""Sample class
3+
"""Sample classes
44
55
This script is just a sample for using classes in Python.
66
@@ -30,12 +30,16 @@ def __init__(self, name=None):
3030
self['name'] = name
3131

3232
class SampleEasyDict(dict):
33+
3334
"""Sample descendant class with passed object type"""
35+
3436
def __init__(self, name=None):
3537
self['name'] = name
3638

3739
class SampleCounter(dict):
40+
3841
"""Sample descendant class with passed object type and class attributes"""
42+
3943
count = 0
4044
def __init__(self):
4145
self.__class__.count += 1
@@ -44,3 +48,4 @@ def __init__(self):
4448
except KeyError:
4549
self['instance_count'] = 0
4650
self['instance_count'] += 1
51+

conf-sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

33
"""Read and write configuration files
44

csv2qif.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

33
"""Convert CSV data to QIF
44

mysql-sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

33
"""Read from MySQL Database
44

mysqldb_class_instance_sample.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

33
"""Sample instantiation of db class
44
@@ -29,8 +29,6 @@
2929
from mysqldb_class_sample import GeneralDBCmd
3030

3131
if __name__ == '__main__':
32-
print '__name__: ', __name__
33-
3432
dbhost = '127.0.0.1'
3533
dbuser = 'pyuser'
3634
dbpwd = 'pyt3ster'

mysqldb_class_sample.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env python
1+
#!/usr/bin/env python
22

33
"""Sample database class for MySQL
44
@@ -12,7 +12,7 @@
1212

1313
class GeneralDBCmd:
1414

15-
""" Provide general database commands. """
15+
"""Provide general database commands."""
1616

1717
def __init__(self, dbcon, tbl):
1818
self.dbcon = dbcon
@@ -25,26 +25,26 @@ def __getitem__(self, item):
2525
''' % (self.tbl, item))
2626
return self.dbcur.fetchone()
2727
def _query(self, q):
28-
""" Display the query in debug mode and execute it. """
28+
"""Display the query in debug mode and execute it."""
2929
if self.debug: print 'Query: %s' % (q)
3030
self.dbcur.execute(q)
3131
def __iter__(self):
32-
""" Create a data set and return an iterator (self). """
33-
q = """
32+
"""Create a data set and return an iterator (self)."""
33+
q ="""
3434
SELECT * FROM %s
35-
""" % (self.tbl)
35+
"""% (self.tbl)
3636
self._query(q)
3737
# return iterator object with 'next()' method
3838
return self
3939
def next(self):
40-
""" Return the next item in dataset or tell Python to stop. """
40+
"""Return the next item in dataset or tell Python to stop."""
4141
r = self.dbcur.fetchone()
4242
if not r:
4343
raise StopIteration
4444
return r
4545
def get_mysql_version(self):
46-
"""Return the MySQL version of the server"""
47-
q = """
46+
"""Return the MySQL version of the server."""
47+
q ="""
4848
SELECT VERSION();
4949
"""
5050
self._query(q)

0 commit comments

Comments
 (0)