This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Don't worry, that value is only wrong half of the time | |
| The unit test doesn't cover that eventuality | |
| There was too little data to bother with the extra functionality at the time | |
| I thought you signed off on that? | |
| The program has never collected that information | |
| That's interesting, how did you manage to make it do that? | |
| Your browser must be caching the old content | |
| Our internet connection must not be working | |
| I couldn't find any examples of how that can be done anywhere online | |
| I thought I fixed that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import sys | |
| import bs4 | |
| found_excuses = set() | |
| duplicate_counter = 0 | |
| while True: | |
| page = requests.get("http://programmingexcuses.com/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if sys.platform.startswith('linux'): | |
| if os.geteuid() == 0: | |
| print 'DO. NOT. RUN. AS. ROOT.' | |
| sys.exit() | |
| else: | |
| print 'Welcome to Contrl, Linux user!' | |
| elif sys.platform.startswith('darwin'): | |
| if os.geteuid() == 0: | |
| print 'DO. NOT. RUN. AS. ROOT.' | |
| sys.exit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| testomg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> print band.members.all().query | |
| SELECT "test_m2m_artist"."id", "test_m2m_artist"."name" FROM "test_m2m_artist" INNER JOIN "test_m2m_band_members" ON ("test_m2m_artist"."id" = "test_m2m_band_members"."artist_id") WHERE "test_m2m_band_members"."band_id" = 1 | |
| >>> print artist.bands.all().query | |
| SELECT "test_m2m_band"."id", "test_m2m_band"."name" FROM "test_m2m_band" INNER JOIN "test_m2m_band_members" ON ("test_m2m_band"."id" = "test_m2m_band_members"."band_id") WHERE "test_m2m_band_members"."artist_id" = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Artist(models.Model): | |
| name = models.CharField(max_length=100) | |
| class Band(models.Model): | |
| name = models.CharField(max_length=100) | |
| members = models.ManyToManyField(Artist, related_name="bands") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 2306 function calls (2297 primitive calls) in 0.003 seconds | |
| Ordered by: call count | |
| ncalls tottime percall cumtime percall filename:lineno(function) | |
| 497 0.000 0.000 0.000 0.000 {isinstance} | |
| 143 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} | |
| 125 0.000 0.000 0.000 0.000 {getattr} | |
| 95 0.000 0.000 0.000 0.000 __init__.py:50(__getattr__) | |
| 87 0.000 0.000 0.000 0.000 {hasattr} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #models.py | |
| from sqlalchemy import Column, String, Integer, create_engine, Table, ForeignKey | |
| from sqlalchemy.dialects import postgresql | |
| from sqlalchemy.orm import sessionmaker, ScopedSession | |
| from sqlalchemy.ext.declarative import declarative_base | |
| engine = create_engine("postgresql+psycopg2://arraybench:password@localhost:5432/arraybench", echo=False) | |
| Base = declarative_base() | |
| Session = ScopedSession(sessionmaker(bind=engine)) |
NewerOlder