Skip to content

Instantly share code, notes, and snippets.

View orf's full-sized avatar

Tom Forbes orf

View GitHub Profile
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
import requests
import sys
import bs4
found_excuses = set()
duplicate_counter = 0
while True:
page = requests.get("http://programmingexcuses.com/")
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()
testomg
abc
>>> 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
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")
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}
#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))