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 collections.abc import MutableSequence | |
from itertools import islice | |
from functools import reduce | |
class List(MutableSequence): | |
def __init__(self, seq): | |
self._d = list(seq) | |
def __delitem__(self, pos): |
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
""" | |
Auxilio a pergunta feita no facebook. | |
https://www.facebook.com/groups/python.brasil/permalink/1289629901141877/ | |
""" | |
class Stack(object): | |
def __init__(self): | |
"""Inicializa a pilha vazia.""" | |
self.p = [] # Aqui P vai ser a lista interna |
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
""" | |
Minhas considerações a pergunta no facebook: | |
https://www.facebook.com/groups/python.brasil/permalink/1296198200485047/ | |
""" | |
def is_digit(func): | |
def inner(string): | |
if string.isdigit(): | |
return func(string) | |
return False |
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
""" | |
Gist para rapidinha #5: https://youtu.be/95_tm5jh5Gc | |
""" | |
from io import StringIO | |
from unittest import main, TestCase | |
from unittest.mock import patch | |
def stdout(string): | |
print(string) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# copied from: | |
# https://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons | |
class Singleton: | |
""" | |
A non-thread-safe helper class to ease implementing singletons. | |
This should be used as a decorator -- not a metaclass -- to the | |
class that should be a singleton. | |
The decorated class can define one `__init__` function that |
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
"""Exemplo agendas. | |
Não mencionar PEP8, feito em 5m | |
""" | |
from re import sub | |
from bs4 import BeautifulSoup as bs | |
from selenium import webdriver | |
from requests import get | |
browser = webdriver.Firefox() |
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
""" | |
Exemplo para ajudar a responder o problema de aninhamento em https://gist.github.com/AndersonFirmino/b0300923094a5a8450018c5bd32c9de8 | |
""" | |
from itertools import filterfalse | |
from functools import partial | |
from random import choice, random | |
def pipe(*funcs): | |
def inner(data, funcs=funcs): | |
result = data |
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 bottle import Bottle | |
app = Bottle() | |
@app.get('/api/v1/test_route1') | |
def get_route1(): | |
return '42' |
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
""" | |
Minha contribuição ao buzzfizz funcional. | |
https://www.facebook.com/groups/python.brasil/permalink/1411831415588391/ | |
""" | |
from functools import partial | |
from operator import mod, eq | |
def pipeline(*funcs): |