This file contains 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 collections | |
import importlib | |
import inspect | |
import sys | |
from stdlib_list import stdlib_list | |
MODULES = stdlib_list("3.8") | |
def gettype(x): | |
if inspect.ismodule(x): return "module" |
This file contains 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
from urllib.request import urlopen, Request | |
from bs4 import BeautifulSoup | |
rootlink = 'https://www.transfermarkt.pl' # root link of website | |
link = 'https://www.transfermarkt.pl/schnellsuche/ergebnis/schnellsuche?query=' # our link, as you know | |
def create_request(url): # let me explain it below | |
req = Request( # we are creating a Request instance | |
url, # giving our 'url' | |
data=None, # this is not important for now :D |
This file contains 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
from timeit import timeit as _timeit | |
uzunluk = 10000 | |
orta = int(uzunluk / 2) | |
s_number = uzunluk | |
l_number = uzunluk | |
timeit = lambda code, number = 1000: _timeit(code, globals = globals(), number = number) |
This file contains 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 math | |
############## | |
def ebob(x,y): | |
while y: | |
r, x = x, y | |
y=r%y | |
return x |
This file contains 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 ast | |
with open("module.py", "r") as f: # we will analysis this file | |
data = f.read() | |
tree = ast.parse(data) | |
classes = {} # {class: [parents]} | |
for i in tree.body: |
This file contains 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 json | |
import socket | |
from struct import Struct, calcsize | |
from select import select | |
__all__ = ("Server", "Client", "localhostname", "localhost", "LAN", "WAN") | |
_int = "H" # 0 <= number <= 65535 == 2 ** 16 -1 | |
_size = calcsize(_int) | |
_struct = Struct("!" + _int) |
This file contains 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
digit = ['sıfır', 'bir', 'iki', 'üç', 'dört', 'beş', 'altı', 'yedi', 'sekiz', 'dokuz'] | |
digit2 = ['', 'on', 'yirmi', 'otuz', 'kırk', 'elli', 'altmış', 'yetmiş', 'seksen', 'doksan'] | |
digit3 = ['milyon', 'milyar', 'trilyon', 'katrilyon', 'kentilyon', 'sekstilyon', 'septilyon', 'oktilyon', 'nonilyon', 'desilyon', 'andesilyon', 'dodesilyon', 'tredesilyon', 'katordesilyon', 'kendesilyon', 'seksdesilyon', 'septendesilyon', 'oktodesilyon', 'novemdesilyon', 'vicintilyon', 'anvicintilyon', 'dovicintilyon', 'trevicintilyon', 'katorvicintilyon', 'kenkavicintilyon', 'sesvicintilyon', 'septemvicintilyon', 'oktovicintilyon', 'novemvicintilyon', 'tricintilyon', 'antricintilyon'] | |
onluk = lambda i: (digit[i] if i<10 else digit2[i // 10] + " " + digit[i % 10]) if i%10 else digit2[i // 10] | |
yüzlük = lambda i: onluk(i) if i < 100 else ("yüz " + onluk(i - 100) if i-100 else "yüz") if i < 200 else digit[i // 100] + " yüz " + onluk(i % 100) if i%100 else digit[i // 100] + " yüz" | |
binlik = lambda i: ("bin" if i == 1 else yüzlük(i) + " |
This file contains 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 MyEnum(): | |
(ONE, | |
TWO, | |
THREE, | |
FOUR, | |
FIVE) = range(5) |
This file contains 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
from functools import reduce, partial | |
import itertools as it | |
from operator import itemgetter, methodcaller | |
def reversed_partial(f, *args, **kwargs): | |
def wrapper(*_args, **_kwargs): | |
f(*_args, *args, **_kwargs, **kwargs) | |
return wrapper | |
def unpack(iterable): |
This file contains 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 EnumMetaDict(dict): | |
def __init__(self): | |
self.n = -1 | |
def __getitem__(self, item): | |
if item.isupper(): | |
self.n += 1 | |
self[item] = self.n | |
return self.n |
OlderNewer