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
def get_mentions(text): | |
limits = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' | |
words = text.split() | |
mentions = [] | |
for word in words: | |
if word.endswith(('.', ',', '!', '?', ':', ';')): | |
word = word[:-1] | |
if word.endswith(')'): | |
word = word[:-1] | |
if word.startswith('('): |
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
# pip install progressbar2 | |
from progressbar import progressbar | |
def wallis(n): | |
pi = 2. | |
for i in progressbar(range(1, n)): | |
left = (2. * i) / (2. * i - 1.) | |
right = (2. * i) / (2. * i + 1.) | |
pi = pi * left * right |
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 Metaclass: | |
def asdict(self): | |
return self.__dict__ | |
def astuple(self): | |
return tuple(self.__dict__.values()) | |
def fields(self): | |
return list(self.__dict__.keys()) |
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
{ | |
"Afghanistan": [ | |
"Aibak", | |
"Andkhoy", | |
"Asadabad", | |
"Baghlan", | |
"Balkh", | |
"Bamyan", | |
"Baraki Barak", | |
"Bazarak", |
OlderNewer