The use of __main__.py
to create executables
myprojectfolder/
|_ __main__.py
|_ __init__.py
Being __main__.py
:
print("Hello")
import copy | |
from cerberus import Validator | |
from cerberus import errors | |
from collections import Mapping, Sequence | |
class ObjectValidator(Validator): | |
def __init__(self, *args, **kwargs): |
from itertools import tee | |
def lazy_sort(v, key=lambda x: x): | |
v = iter(v) | |
try: | |
pivot = next(v) | |
except StopIteration: | |
return | |
v_pre, v_pos = tee(v) | |
yield from lazy_sort((item for item in v_pre if key(item) < key(pivot)), key) |
Moved to | |
https://github.com/romannurik/android-swipetodismiss |
import concurrent.futures | |
import os | |
import re | |
from timeit import timeit | |
import requests | |
from tqdm import tqdm | |
URLS = 'urls' |
from events import Events # Note you must pip install events | |
class Person: | |
def __init__(self, name: str, age: int, city: str): | |
self.__events = Events(('on_name_changed', 'on_age_changed', 'on_location_changed')) | |
self.on_name_changed = self.__events.on_name_changed | |
self.on_age_changed = self.__events.on_age_changed | |
self.on_location_changed = self.__events.on_location_changed |
# maybe.py - a Pythonic implementation of the Maybe monad | |
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# |
class MyClass { | |
static final MyClass _singleton = new MyClass._internal(); | |
factory MyClass() { | |
return _singleton; | |
} | |
MyClass._internal() { | |
... // initialization logic here | |
} |
#!/usr/bin/env python | |
""" | |
Django SECRET_KEY generator. | |
""" | |
from django.utils.crypto import get_random_string | |
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' | |
print(get_random_string(50, chars)) |
The use of __main__.py
to create executables
myprojectfolder/
|_ __main__.py
|_ __init__.py
Being __main__.py
:
print("Hello")