Skip to content

Instantly share code, notes, and snippets.

@andy47
Last active December 19, 2015 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andy47/5893615 to your computer and use it in GitHub Desktop.
Save andy47/5893615 to your computer and use it in GitHub Desktop.
Example code to show refactoring opportunity
class Portfolio(object):
...
def get_portfolio(self, portfolio_code):
...
stmt = """SELECT id FROM portfolios WHERE code=?"""
cursor.execute(stmt, (portfolio_code,))
portfolio_id = cursor.fetchone()[0]
...
def add_value(self, portfolio_code, ...):
...
stmt = """SELECT id FROM portfolios WHERE code=?"""
cursor.execute(stmt, (portfolio_code,))
portfolio_id = cursor.fetchone()[0]
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment