Skip to content

Instantly share code, notes, and snippets.

View pcote's full-sized avatar
🏠
Working from home

Emma Cote pcote

🏠
Working from home
View GitHub Profile
def fizzbuzz9(maxnum):
print((lambda mn: "\n".join("{}: {}".format(num,
(lambda n: ("" if n % 3 else "fizz") +
("" if n % 5 else "buzz") )(num))
for num in range(1, mn + 1)))(maxnum))
def fizzbuzz10(maxnum):
(lambda mn: print("\n".join("{}: {}".format(num,
(lambda n: ("" if n % 3 else "fizz") +
("" if n % 5 else "buzz") )(num))
for num in range(1, mn + 1))))(maxnum)
def fizzbuzz11(maxnum):
type("", (), {"__call__": lambda self, mn: print(
"\n".join("{}: {}".format(num,
(lambda n: ("" if n % 3 else "fizz") +
("" if n % 5 else "buzz") )(num))
for num in range(1, mn + 1)))})()(maxnum)
def fizzbuzz12(maxnum):
type("", (), {"__call__": staticmethod(lambda mn: print(
"\n".join("{:2}: {}".format(num,
(lambda n: ("" if n % 3 else "fizz") +
("" if n % 5 else "buzz") )(num))
for num in range(1, mn + 1))))})()(maxnum)
fizzbuzz12(50)
import os
def pyfiles():
base_dir = "/home/username/blender-2.76b-linux-glibc211-x86_64/2.76/scripts"
for dir_name, child_dirs, files in os.walk(base_dir):
for file_name in files:
if file_name.endswith(".py"):
full_path = "{}{}{}".format(dir_name, os.path.sep, file_name)
yield full_path
def pick_lines(file_name):
with open(file_name, "rt", encoding="utf-8") as fileob:
for line in fileob:
if line.strip().startswith("bl_region_type"):
yield line
for pyfile in pyfiles():
for line in pick_lines(pyfile):
pass
region_types = []
for pyfile in pyfiles():
for line in pick_lines(pyfile):
_, region_type = line.split("=")
region_type = region_type.replace("'", "")
region_type = region_type.replace("\"", "")
region_type = region_type.strip()
region_types.append(region_type)
from collections import Counter
counts = Counter(sorted(region_types))
for key, val in counts.items():
print("{}: {}".format(key, val))
import os
from collections import Counter
def pyfiles():
base_dir = "/home/username/blender-2.76b-linux-glibc211-x86_64/2.76/scripts"
for dir_name, child_dirs, files in os.walk(base_dir):
for file_name in files:
if file_name.endswith(".py"):
full_path = "{}{}{}".format(dir_name, os.path.sep, file_name)
yield full_path
conn = eng.connect()
resource_parm = bindparam("resource_id", type_=Integer)
now = datetime.now()
query = resource_deletion_table.insert()\
.values(resource_id=resource_parm, deletion_time=now)
conn.execute(query, resource_id=resource_id)