This file contains hidden or 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
| #!/usr/bin/python3 -u | |
| # -*- coding: utf-8 -*- | |
| import sys, traceback | |
| def full_traceback(): | |
| """ | |
| Returns a full traceback to an exception | |
| :return: | |
| """ | |
| exc_type, exc_value, exc_traceback = sys.exc_info() |
This file contains hidden or 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 time | |
| import functools | |
| def timer(func): | |
| #Decorator function takes the decorated function as parameter | |
| @functools.wraps(func) | |
| def wrapper(*args, **kwargs): | |
| #the replacement function to be used |
This file contains hidden or 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 pluralizeRussian(number, nom_sing, gen_sing, gen_pl): | |
| s_last_digit = str(number)[-1] | |
| if int(str(number)[-2:]) in range(11,20): | |
| #11-19 | |
| return gen_pl | |
| elif s_last_digit == '1': | |
| #1 | |
| return nom_sing | |
| elif int(s_last_digit) in range(2,5): |
This file contains hidden or 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
| #!/usr/bin/python3 | |
| # -*- coding: utf-8 -*- | |
| from socket import AF_INET, SOCK_DGRAM | |
| import socket | |
| PORT = 9091 | |
| sock = socket.socket(AF_INET, SOCK_DGRAM) | |
| # assign socket to host (empty for any) and port (as tuple, not as two params!) |
NewerOlder