adding all files done so far
This commit is contained in:
23
learning/class-and-object-orianted-python/lesson1.py
Normal file
23
learning/class-and-object-orianted-python/lesson1.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!~/.virtualenvs/learning/bin/python
|
||||
|
||||
|
||||
class Customer(object):
|
||||
"""example class defining a customer deposit and withdraw methods
|
||||
for a bank.
|
||||
|
||||
Attributes:
|
||||
name: A string represnting the customer's name
|
||||
balance: A float tracking the current balance of the customer."""
|
||||
|
||||
def __init__(self, name, balance, list):
|
||||
super(Customer, self).__init__()
|
||||
self.name = name
|
||||
self.balance = balance
|
||||
self.list = list
|
||||
print(self.name)
|
||||
print(self.balance)
|
||||
for i in range(len(self.list)):
|
||||
print(self.list[i])
|
||||
|
||||
|
||||
Customer('Homer', 200, ['100', '102', '103'])
|
||||
1
learning/class-and-object-orianted-python/links.txt
Normal file
1
learning/class-and-object-orianted-python/links.txt
Normal file
@@ -0,0 +1 @@
|
||||
https://jeffknupp.com/blog/2017/03/27/improve-your-python-python-classes-and-object-oriented-programming/
|
||||
0
learning/decorators/__init__.py
Normal file
0
learning/decorators/__init__.py
Normal file
BIN
learning/decorators/__pycache__/decorator.cpython-37.pyc
Normal file
BIN
learning/decorators/__pycache__/decorator.cpython-37.pyc
Normal file
Binary file not shown.
BIN
learning/decorators/__pycache__/decorators.cpython-37.pyc
Normal file
BIN
learning/decorators/__pycache__/decorators.cpython-37.pyc
Normal file
Binary file not shown.
BIN
learning/decorators/__pycache__/pathfix.cpython-37.pyc
Normal file
BIN
learning/decorators/__pycache__/pathfix.cpython-37.pyc
Normal file
Binary file not shown.
BIN
learning/decorators/__pycache__/script1.cpython-37.pyc
Normal file
BIN
learning/decorators/__pycache__/script1.cpython-37.pyc
Normal file
Binary file not shown.
61
learning/decorators/classes_decorater.py
Normal file
61
learning/decorators/classes_decorater.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
from decorator import timer, debug, repeatN, repeat_partial, count_calls, \
|
||||
Counter, Slow, slowDown
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
class TimeWaster(object):
|
||||
@debug
|
||||
def __init__(self, max_num: int):
|
||||
super(TimeWaster, self).__init__()
|
||||
self.max_num = max_num
|
||||
|
||||
@timer
|
||||
def waste_time(self, num_times: int):
|
||||
for _ in range(num_times):
|
||||
sum([i ** 2 for i in range(self.max_num)])
|
||||
|
||||
|
||||
@timer
|
||||
@dataclass
|
||||
class PlayingCard(object):
|
||||
rank: str
|
||||
suit: str
|
||||
|
||||
|
||||
@repeatN
|
||||
def say_hello(name: str):
|
||||
print(f'Hello, {name}.')
|
||||
|
||||
|
||||
@repeatN(num=5)
|
||||
def say_hi(name: str):
|
||||
print(f'Hi, {name}.')
|
||||
|
||||
|
||||
@repeat_partial(num=10)
|
||||
def say_yo(name: str):
|
||||
print(f'Yo, {name}!')
|
||||
|
||||
|
||||
@count_calls
|
||||
def say_whee():
|
||||
print('Whee!')
|
||||
|
||||
|
||||
@Counter
|
||||
def say_howdy():
|
||||
print('Howdy!')
|
||||
|
||||
|
||||
@slowDown()
|
||||
def count_down(num: int):
|
||||
if not isinstance(num, int):
|
||||
raise TypeError("Must input an integer.")
|
||||
if num >= 1:
|
||||
print(num)
|
||||
count_down(num - 1)
|
||||
else:
|
||||
print('Liftoff!')
|
||||
72
learning/decorators/classes_with_args.py
Normal file
72
learning/decorators/classes_with_args.py
Normal file
@@ -0,0 +1,72 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
import decorator
|
||||
from itertools import repeat
|
||||
|
||||
# @slowDown(1)
|
||||
# def count_down(num: int):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# count_down(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
|
||||
|
||||
# @Counter
|
||||
# def say_howdy():
|
||||
# print('Howdy!')
|
||||
|
||||
|
||||
class tester(object):
|
||||
@decorator.slowDown()
|
||||
def count(self, num):
|
||||
if not isinstance(num, int):
|
||||
raise TypeError("Must input an integer.")
|
||||
if num >= 1:
|
||||
print(num)
|
||||
self.count(num - 1)
|
||||
else:
|
||||
print('Liftoff!')
|
||||
|
||||
# print()
|
||||
# var = tester()
|
||||
# var.count(1)
|
||||
|
||||
|
||||
# @decorator.slowDown()
|
||||
# def count(num):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# count(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
|
||||
|
||||
# print()
|
||||
# count(3)
|
||||
|
||||
# @decorator.slowDown
|
||||
# def count(num):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# count(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
|
||||
|
||||
# @slowDown
|
||||
# def countme(num):
|
||||
# if not isinstance(num, int):
|
||||
# raise TypeError("Must input an integer.")
|
||||
# if num >= 1:
|
||||
# print(num)
|
||||
# countme(num - 1)
|
||||
# else:
|
||||
# print('Liftoff!')
|
||||
204
learning/decorators/decorator.py
Executable file
204
learning/decorators/decorator.py
Executable file
@@ -0,0 +1,204 @@
|
||||
import itertools
|
||||
import functools
|
||||
from time import perf_counter, sleep
|
||||
import sys
|
||||
|
||||
|
||||
def do_twice(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
for _ in itertools.repeat(None, 2):
|
||||
func(*args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
def timer(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper_timer(*args, **kwargs):
|
||||
start_time = perf_counter()
|
||||
value = func(*args, **kwargs)
|
||||
end_time = perf_counter()
|
||||
run_time = end_time - start_time
|
||||
print(f'Finished {func.__name__!r} in {run_time:.4f} secs')
|
||||
return value
|
||||
return wrapper_timer
|
||||
|
||||
|
||||
def debug(func):
|
||||
""" Print the function signature and return the value """
|
||||
@functools.wraps(func)
|
||||
def wrapper_debug(*args, **kwargs):
|
||||
args_repr = [repr(a) for a in args]
|
||||
kwargs_repr = [f'{k}={v!r}' for k, v in kwargs.items()]
|
||||
signature = ', '.join(args_repr + kwargs_repr)
|
||||
print(f'Calling {func.__name__}({signature})')
|
||||
value = func(*args, **kwargs)
|
||||
print(f'{func.__name__!r} returned {value!r}')
|
||||
return value
|
||||
return wrapper_debug
|
||||
|
||||
|
||||
def slow_down(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper_slow_down(*args, **kwargs):
|
||||
sleep(1)
|
||||
return func(*args, **kwargs)
|
||||
return wrapper_slow_down
|
||||
|
||||
|
||||
def repeat(num: int):
|
||||
def decorator_repeat(func: callable):
|
||||
@functools.wraps(func)
|
||||
def wrapper_repeat(*args: list, **kwargs: dict):
|
||||
for _ in range(num):
|
||||
value = func(*args, **kwargs)
|
||||
return value
|
||||
return wrapper_repeat
|
||||
return decorator_repeat
|
||||
|
||||
|
||||
def repeatN(_func=None, *, num=2):
|
||||
def decorator_repeatN(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper_repeatN(*args, **kwargs):
|
||||
for _ in range(num):
|
||||
value = func(*args, **kwargs)
|
||||
return value
|
||||
return wrapper_repeatN
|
||||
|
||||
if _func is None:
|
||||
return decorator_repeatN
|
||||
else:
|
||||
return decorator_repeatN(_func)
|
||||
|
||||
|
||||
def repeat_partial(func=None, *, num=2):
|
||||
if func is None:
|
||||
return functools.partial(repeat_partial, num=num)
|
||||
|
||||
@functools.wraps(func)
|
||||
def repeat_partial_wrapper(*args, **kwargs):
|
||||
for _ in range(num):
|
||||
value = func(*args, **kwargs)
|
||||
return value
|
||||
return repeat_partial_wrapper
|
||||
|
||||
|
||||
# def count_calls(func: callable):
|
||||
# @functools.wraps(func)
|
||||
# def wrapper_count_calls(*args, **kwargs):
|
||||
# wrapper_count_calls.num_calls += 1
|
||||
# print(f'Call {wrapper_count_calls.num_calls} of {func.__name__!r}')
|
||||
# return func(*args, **kwargs)
|
||||
# wrapper_count_calls.num_calls = 0
|
||||
# print(wrapper_count_calls.num_calls)
|
||||
# return wrapper_count_calls
|
||||
|
||||
|
||||
# def count_calls(func: callable):
|
||||
# num_calls = 0
|
||||
# print(num_calls)
|
||||
# @functools.wraps(func)
|
||||
# def wrapper_count_calls(*args, **kwargs):
|
||||
# nonlocal num_calls
|
||||
# num_calls += 1
|
||||
# print(f'Call {num_calls} of {func.__name__}')
|
||||
# return func(*args, **kwargs)
|
||||
# return wrapper_count_calls
|
||||
|
||||
|
||||
def count_calls(func=None, *, num=0):
|
||||
if func is None:
|
||||
return functools.partial(count_calls, num=num)
|
||||
|
||||
@functools.wraps(func)
|
||||
def wrapper_count_calls(*args, **kwargs):
|
||||
wrapper_count_calls.num += 1
|
||||
print(f'Call {wrapper_count_calls.num} of {func.__name__}')
|
||||
return func(*args, **kwargs)
|
||||
wrapper_count_calls.num = num
|
||||
return wrapper_count_calls
|
||||
|
||||
|
||||
class Counter(object):
|
||||
"""docstring for Counter"""
|
||||
def __init__(self, func):
|
||||
print('start init')
|
||||
super(Counter, self).__init__()
|
||||
functools.update_wrapper(self, func)
|
||||
self.func = func
|
||||
self.num_calls = 0
|
||||
print('finished init')
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
print('start call')
|
||||
self.num_calls += 1
|
||||
print(f'Call {self.num_calls} of {self.func.__name__!r}')
|
||||
print('finished call')
|
||||
return self.func(*args, **kwargs)
|
||||
|
||||
|
||||
# class slowDown(object):
|
||||
# """docstring for slowDown"""
|
||||
# def __init__(self, rate):
|
||||
# if callable(rate):
|
||||
# self.func = rate
|
||||
# self.rate = 1
|
||||
# else:
|
||||
# self.rate = rate
|
||||
|
||||
# def __get__(self, obj, type=None):
|
||||
# return functools.partial(self, obj)
|
||||
|
||||
# def __call__(self, *args, **kwargs):
|
||||
# if not hasattr(self, 'func'):
|
||||
# self.func = args[0]
|
||||
# return self
|
||||
# sleep(self.rate)
|
||||
# self.func(*args, **kwargs)
|
||||
|
||||
|
||||
class slowDown(object):
|
||||
"""docstring for Slow_Down"""
|
||||
def __init__(self, rate=1):
|
||||
print('init')
|
||||
self.rate = rate
|
||||
|
||||
def __call__(self, func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
print('wrapper')
|
||||
sleep(self.rate)
|
||||
func(*args, **kwargs)
|
||||
print('call finished')
|
||||
print(self, func)
|
||||
return wrapper
|
||||
|
||||
|
||||
# class slowDown(object):
|
||||
# """docstring for slowDown"""
|
||||
# def __init__(self, rate):
|
||||
# if callable(rate):
|
||||
# self.func = rate
|
||||
# self.rate = 1
|
||||
# print(f'no args, {locals()}, func={self.func}, rate={self.rate},\
|
||||
# self={self}')
|
||||
# else:
|
||||
# self.rate = rate
|
||||
# print(f'args set, rate={self.rate}')
|
||||
|
||||
# def __get__(self, obj, type=None):
|
||||
# print(f'get called, self={self}, obj={obj}, type={type}')
|
||||
# return functools.partial(self, obj)
|
||||
|
||||
# def __call__(self, *args, **kwargs):
|
||||
# print(f'call called, rate={self.rate}, args={args}'
|
||||
# f', kwargs={kwargs} ,self={self}')
|
||||
# print(f'locals = {locals()}')
|
||||
# if not hasattr(self, 'func'):
|
||||
# self.func = args[0]
|
||||
# print(f'args set, setting self.func to {self.func}')
|
||||
# return self
|
||||
# sleep(self.rate)
|
||||
# self.func(*args, **kwargs)
|
||||
58
learning/decorators/function_decorators.py
Normal file
58
learning/decorators/function_decorators.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
from decorator import timer, debug, slow_down
|
||||
import math
|
||||
import random
|
||||
|
||||
|
||||
PLUGINS = dict()
|
||||
|
||||
|
||||
@timer
|
||||
def waste_time(num):
|
||||
for _ in range(num):
|
||||
sum([i ** 2 for i in range(10000)])
|
||||
|
||||
|
||||
@debug
|
||||
def make_greeting(first_name, age: int):
|
||||
return f'Hello {first_name}, you are {age}!'
|
||||
|
||||
|
||||
math.factorial = debug(math.factorial)
|
||||
|
||||
|
||||
def approximate_e(terms):
|
||||
return sum(1 / math.factorial(n) for n in range(terms))
|
||||
|
||||
|
||||
@slow_down
|
||||
def countdown(num: int):
|
||||
if num < 1:
|
||||
print('Liftoff!')
|
||||
else:
|
||||
print(num)
|
||||
countdown(num - 1)
|
||||
|
||||
|
||||
def register(func):
|
||||
"""Register a function as a plug-in"""
|
||||
PLUGINS[func.__name__] = func
|
||||
return func
|
||||
|
||||
|
||||
@register
|
||||
def say_hello(name: str) -> str:
|
||||
return f'Hello {name}'
|
||||
|
||||
|
||||
@register
|
||||
def be_awesome(name: str) -> str:
|
||||
return f'Yo {name}, together we are awesome!'
|
||||
|
||||
|
||||
def randomly_greet(name):
|
||||
greeter, greeter_func = random.choice(list(PLUGINS.items()))
|
||||
print(f'Using {greeter!r}')
|
||||
return greeter_func(name)
|
||||
13
learning/decorators/test.py
Normal file
13
learning/decorators/test.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
import decorator
|
||||
import functools
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=4)
|
||||
@decorator.count_calls
|
||||
def fib(num):
|
||||
if num < 2:
|
||||
return num
|
||||
return fib(num - 1) + fib(num - 2)
|
||||
18
learning/descriptors/descriptors.py
Normal file
18
learning/descriptors/descriptors.py
Normal file
@@ -0,0 +1,18 @@
|
||||
class Person(object):
|
||||
"""docstring for Person"""
|
||||
def __init__(self, name, age):
|
||||
super(Person, self).__init__()
|
||||
self.name = name
|
||||
self.age = age
|
||||
|
||||
@property
|
||||
def age(self):
|
||||
print('old enough')
|
||||
return self.__age
|
||||
|
||||
@age.setter
|
||||
def age(self, value):
|
||||
if value < 21:
|
||||
raise Exception(f'{self.name} is not old enough.')
|
||||
else:
|
||||
self.__age = value
|
||||
37
learning/descriptors/descriptors2.py
Normal file
37
learning/descriptors/descriptors2.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from weakref import WeakKeyDictionary
|
||||
|
||||
|
||||
class Drinker:
|
||||
def __init__(self):
|
||||
self.req_age = 21
|
||||
self.age = dict()
|
||||
print('init')
|
||||
|
||||
def __get__(self, instance_obj, objtype):
|
||||
print(f'{instance_obj}, {objtype}, {self.age}')
|
||||
return self.age.get(instance_obj, self.req_age)
|
||||
|
||||
def __set__(self, instance, new_age):
|
||||
if new_age < 21:
|
||||
msg = '{name} is too young to legally imbibe'
|
||||
raise Exception(msg.format(name=instance.name))
|
||||
self.age[instance] = new_age
|
||||
print('{name} can legally drink in the USA'.format(
|
||||
name=instance.name))
|
||||
|
||||
def __delete__(self, instance):
|
||||
del self.age[instance]
|
||||
|
||||
|
||||
class Person:
|
||||
drinker_age = Drinker()
|
||||
|
||||
def __init__(self, name, age):
|
||||
self.name = name
|
||||
self.drinker_age = age
|
||||
|
||||
|
||||
p = Person('Miguel', 30)
|
||||
p1 = Person('Bob', 50)
|
||||
|
||||
p = Person('Niki', 13)
|
||||
16
learning/descriptors/test.py
Normal file
16
learning/descriptors/test.py
Normal file
@@ -0,0 +1,16 @@
|
||||
class P(object):
|
||||
def __init__(self, x):
|
||||
self._x = x
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return self._x
|
||||
|
||||
@x.setter
|
||||
def x(self, x):
|
||||
if x < 0:
|
||||
self._x = 0
|
||||
elif x > 1000:
|
||||
self._x = 1000
|
||||
else:
|
||||
self._x = x
|
||||
BIN
learning/import-args/__pycache__/script1.cpython-37.pyc
Normal file
BIN
learning/import-args/__pycache__/script1.cpython-37.pyc
Normal file
Binary file not shown.
BIN
learning/import-args/__pycache__/script2.cpython-37.pyc
Normal file
BIN
learning/import-args/__pycache__/script2.cpython-37.pyc
Normal file
Binary file not shown.
34
learning/import-args/netacea-blocking.log
Normal file
34
learning/import-args/netacea-blocking.log
Normal file
@@ -0,0 +1,34 @@
|
||||
2019-06-13 22:23:19,920 - CRITICAL - Critical message
|
||||
2019-06-13 22:26:08,285 - DEBUG - Critical message
|
||||
2019-06-13 22:26:12,263 - DEBUG - Critical message
|
||||
2019-06-13 22:26:13,688 - DEBUG - Critical message
|
||||
2019-06-13 22:26:14,120 - DEBUG - Critical message
|
||||
2019-06-13 22:26:14,499 - DEBUG - Critical message
|
||||
2019-06-13 22:26:14,990 - DEBUG - Critical message
|
||||
2019-06-13 22:26:15,361 - DEBUG - Critical message
|
||||
2019-06-13 22:27:00,510 - ERROR - Critical message
|
||||
2019-06-13 22:27:45,847 - ERROR - Critical message
|
||||
2019-06-13 22:27:46,242 - ERROR - Critical message
|
||||
2019-06-13 22:27:46,513 - ERROR - Critical message
|
||||
2019-06-13 22:27:46,770 - ERROR - Critical message
|
||||
2019-06-13 22:27:47,018 - ERROR - Critical message
|
||||
2019-06-13 22:27:47,534 - ERROR - Critical message
|
||||
2019-06-13 22:27:52,098 - CRITICAL - Critical message
|
||||
2019-06-13 22:27:52,678 - CRITICAL - Critical message
|
||||
2019-06-13 22:27:52,918 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:24,770 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:25,180 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:25,487 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:25,760 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:26,184 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:26,538 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:26,932 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:27,301 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:27,690 - CRITICAL - Critical message
|
||||
2019-06-13 22:28:33,666 - ERROR - Critical message
|
||||
2019-06-13 22:28:34,203 - ERROR - Critical message
|
||||
2019-06-13 22:28:34,414 - ERROR - Critical message
|
||||
2019-06-13 22:28:58,465 - ERROR - Critical message
|
||||
2019-06-13 22:28:58,917 - ERROR - Critical message
|
||||
2019-06-13 22:28:59,138 - ERROR - Critical message
|
||||
2019-06-13 22:29:02,335 - INFO - Critical message
|
||||
14
learning/import-args/script1.py
Normal file
14
learning/import-args/script1.py
Normal file
@@ -0,0 +1,14 @@
|
||||
def my_decorator(func):
|
||||
def wrapper():
|
||||
print('Something happening before the func is called.')
|
||||
func()
|
||||
print('Something happening after the func is called.')
|
||||
return wrapper
|
||||
|
||||
|
||||
@my_decorator
|
||||
def say_whee():
|
||||
print('Whee!')
|
||||
|
||||
|
||||
say_whee()
|
||||
23
learning/import-args/script2.py
Normal file
23
learning/import-args/script2.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import argparse
|
||||
|
||||
|
||||
def main(folder, *args, **kwargs):
|
||||
my_path = folder
|
||||
print(my_path)
|
||||
print(f"script2 kwargs {kwargs}")
|
||||
print('end of script2.py')
|
||||
|
||||
|
||||
def call():
|
||||
global arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--path', type=str, default='')
|
||||
parser.add_argument('--folder', type=str, default='test-folder')
|
||||
arguments = parser.parse_args()
|
||||
main(**vars(arguments))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = ''
|
||||
call()
|
||||
# print(f"final {arguments}")
|
||||
21
learning/import-args/script3.py
Normal file
21
learning/import-args/script3.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import script1
|
||||
import argparse
|
||||
|
||||
|
||||
def main(**kwargs):
|
||||
# print(vars(arguments))
|
||||
script1.main(**vars(arguments))
|
||||
|
||||
|
||||
def call():
|
||||
global arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--path', type=str, default='test-path')
|
||||
parser.add_argument('--folder', type=str, default='test-folder')
|
||||
arguments = parser.parse_args()
|
||||
main(**vars(arguments))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = ''
|
||||
call()
|
||||
839
learning/learning.sublime-workspace
Normal file
839
learning/learning.sublime-workspace
Normal file
@@ -0,0 +1,839 @@
|
||||
{
|
||||
"auto_complete":
|
||||
{
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"drin",
|
||||
"drinker_age"
|
||||
],
|
||||
[
|
||||
"x",
|
||||
"__x"
|
||||
],
|
||||
[
|
||||
"cla",
|
||||
"class\tNew Class"
|
||||
],
|
||||
[
|
||||
"ge",
|
||||
"get_x"
|
||||
],
|
||||
[
|
||||
"tester",
|
||||
"tester1"
|
||||
],
|
||||
[
|
||||
"clas",
|
||||
"class\tNew Class"
|
||||
],
|
||||
[
|
||||
"int",
|
||||
"int\tclass"
|
||||
],
|
||||
[
|
||||
"set",
|
||||
"setattr\tfunction"
|
||||
],
|
||||
[
|
||||
"st",
|
||||
"Standalone"
|
||||
],
|
||||
[
|
||||
"M",
|
||||
"MyClass\tclass"
|
||||
],
|
||||
[
|
||||
"m",
|
||||
"my_printer\tstatement"
|
||||
],
|
||||
[
|
||||
"from",
|
||||
"fromBirthYear\tfunction"
|
||||
],
|
||||
[
|
||||
"class",
|
||||
"classmethod\tclass"
|
||||
],
|
||||
[
|
||||
"par",
|
||||
"partialmethod\tclass"
|
||||
],
|
||||
[
|
||||
"db",
|
||||
"initialize_db"
|
||||
],
|
||||
[
|
||||
"get",
|
||||
"getattr\tfunction"
|
||||
],
|
||||
[
|
||||
"name",
|
||||
"__name__"
|
||||
],
|
||||
[
|
||||
"__get",
|
||||
"__getattribute__\tfunction"
|
||||
],
|
||||
[
|
||||
"kwargs",
|
||||
"kwargs"
|
||||
],
|
||||
[
|
||||
"func",
|
||||
"functools\tmodule"
|
||||
],
|
||||
[
|
||||
"wra",
|
||||
"wrapper_slow_down\tfunction"
|
||||
],
|
||||
[
|
||||
"slo",
|
||||
"slowDownDecorator\tclass"
|
||||
],
|
||||
[
|
||||
"slow",
|
||||
"slowDown\tclass"
|
||||
],
|
||||
[
|
||||
"init",
|
||||
"init"
|
||||
],
|
||||
[
|
||||
"call",
|
||||
"callable"
|
||||
],
|
||||
[
|
||||
"Slo",
|
||||
"Slow_Down_Decorator\tclass"
|
||||
],
|
||||
[
|
||||
"Slow",
|
||||
"Slow_Down\tclass"
|
||||
],
|
||||
[
|
||||
"partial",
|
||||
"partial\tclass"
|
||||
],
|
||||
[
|
||||
"coun",
|
||||
"count_down\tfunction"
|
||||
],
|
||||
[
|
||||
"num",
|
||||
"num_calls\tstatement"
|
||||
],
|
||||
[
|
||||
"sum",
|
||||
"sum_squares"
|
||||
],
|
||||
[
|
||||
"y",
|
||||
"y_total"
|
||||
],
|
||||
[
|
||||
"wrapper",
|
||||
"wrapper_count_calls\tfunction"
|
||||
],
|
||||
[
|
||||
"n",
|
||||
"num_calls"
|
||||
],
|
||||
[
|
||||
"str",
|
||||
"str\tclass"
|
||||
],
|
||||
[
|
||||
"repea",
|
||||
"repeat_partial\tfunction"
|
||||
],
|
||||
[
|
||||
"parti",
|
||||
"repeat_partial_wrapper"
|
||||
],
|
||||
[
|
||||
"repeat",
|
||||
"repeatN\tfunction"
|
||||
],
|
||||
[
|
||||
"dec",
|
||||
"decorator_repeatN\tfunction"
|
||||
],
|
||||
[
|
||||
"wrapper_rep",
|
||||
"wrapper_repeatN\tfunction"
|
||||
],
|
||||
[
|
||||
"de",
|
||||
"decorator_repeat\tfunction"
|
||||
],
|
||||
[
|
||||
"Call",
|
||||
"callable\tfunction"
|
||||
],
|
||||
[
|
||||
"R",
|
||||
"ReferenceError\tclass"
|
||||
],
|
||||
[
|
||||
"gree",
|
||||
"greeter_func\tstatement"
|
||||
],
|
||||
[
|
||||
"re",
|
||||
"return\tkeyword"
|
||||
],
|
||||
[
|
||||
"wrap",
|
||||
"wrapper_debug\tfunction"
|
||||
],
|
||||
[
|
||||
"__",
|
||||
"__name__"
|
||||
],
|
||||
[
|
||||
"kw",
|
||||
"kwargs_repr\tstatement"
|
||||
],
|
||||
[
|
||||
"args",
|
||||
"args_repr"
|
||||
],
|
||||
[
|
||||
"no",
|
||||
"not_during_the_night\tfunction"
|
||||
],
|
||||
[
|
||||
"ex",
|
||||
"executable\tinstance"
|
||||
],
|
||||
[
|
||||
"script",
|
||||
"script_file\tstatement"
|
||||
],
|
||||
[
|
||||
"sc",
|
||||
"script_file\tstatement"
|
||||
],
|
||||
[
|
||||
"Ke",
|
||||
"KeyError\tclass"
|
||||
],
|
||||
[
|
||||
"folder",
|
||||
"folder"
|
||||
],
|
||||
[
|
||||
"ar",
|
||||
"arguments\tstatement"
|
||||
],
|
||||
[
|
||||
"local",
|
||||
"locals_val\tstatement"
|
||||
],
|
||||
[
|
||||
"arguments",
|
||||
"arguments"
|
||||
],
|
||||
[
|
||||
"sctr",
|
||||
"script2_main\tfunction"
|
||||
],
|
||||
[
|
||||
"f",
|
||||
"f"
|
||||
],
|
||||
[
|
||||
"X",
|
||||
"X_train"
|
||||
],
|
||||
[
|
||||
"read_",
|
||||
"read_excel\tfunction"
|
||||
],
|
||||
[
|
||||
"read",
|
||||
"read_csv\tfunction"
|
||||
],
|
||||
[
|
||||
"is",
|
||||
"is_tasty"
|
||||
],
|
||||
[
|
||||
"li",
|
||||
"list_ingredients\tparam"
|
||||
],
|
||||
[
|
||||
"prin",
|
||||
"print_sound"
|
||||
],
|
||||
[
|
||||
"w",
|
||||
"wheels"
|
||||
],
|
||||
[
|
||||
"pr",
|
||||
"print_sound"
|
||||
],
|
||||
[
|
||||
"date",
|
||||
"datetime\tclass"
|
||||
],
|
||||
[
|
||||
"p",
|
||||
"print_wheels\tfunction"
|
||||
],
|
||||
[
|
||||
"File",
|
||||
"FileNotFoundError\tclass"
|
||||
],
|
||||
[
|
||||
"borg",
|
||||
"borg"
|
||||
],
|
||||
[
|
||||
"log",
|
||||
"log"
|
||||
],
|
||||
[
|
||||
"conver",
|
||||
"convert_to_uppercase\tfunction"
|
||||
],
|
||||
[
|
||||
"hell",
|
||||
"hellow_world\tstatement"
|
||||
],
|
||||
[
|
||||
"__m",
|
||||
"__name__\tinstance"
|
||||
],
|
||||
[
|
||||
"fu",
|
||||
"func\tparam"
|
||||
],
|
||||
[
|
||||
"fun",
|
||||
"functools\tmodule"
|
||||
],
|
||||
[
|
||||
"funct",
|
||||
"function_call\tfunction"
|
||||
],
|
||||
[
|
||||
"d",
|
||||
"double_volume\tfunction"
|
||||
],
|
||||
[
|
||||
"s",
|
||||
"surface_area\tfunction"
|
||||
],
|
||||
[
|
||||
"new",
|
||||
"new_length\tparam"
|
||||
],
|
||||
[
|
||||
"Cube",
|
||||
"Cube"
|
||||
],
|
||||
[
|
||||
"area",
|
||||
"area_2\tfunction"
|
||||
],
|
||||
[
|
||||
"tri",
|
||||
"tri_area\tfunction"
|
||||
],
|
||||
[
|
||||
"triangle",
|
||||
"triangle_area\tstatement"
|
||||
],
|
||||
[
|
||||
"bas",
|
||||
"base_area\tstatement"
|
||||
],
|
||||
[
|
||||
"r",
|
||||
"return_colour\tfunction"
|
||||
],
|
||||
[
|
||||
"sl",
|
||||
"slant_height\tparam"
|
||||
],
|
||||
[
|
||||
"heigh",
|
||||
"height_tripled\tfunction"
|
||||
],
|
||||
[
|
||||
"h",
|
||||
"height_doubled\tfunction"
|
||||
],
|
||||
[
|
||||
"__in",
|
||||
"__init__\tfunction"
|
||||
],
|
||||
[
|
||||
"ba",
|
||||
"base_area"
|
||||
],
|
||||
[
|
||||
"garb",
|
||||
"garbage_check\tfunction"
|
||||
],
|
||||
[
|
||||
"len",
|
||||
"length\tparam"
|
||||
],
|
||||
[
|
||||
"__init",
|
||||
"__init_subclass__\tfunction"
|
||||
],
|
||||
[
|
||||
"Square",
|
||||
"Square\tclass"
|
||||
],
|
||||
[
|
||||
"se",
|
||||
"self"
|
||||
],
|
||||
[
|
||||
"list",
|
||||
"list_of_ips\tstatement"
|
||||
],
|
||||
[
|
||||
"su",
|
||||
"sub_list\tstatement"
|
||||
],
|
||||
[
|
||||
"def",
|
||||
"def\tFunction"
|
||||
]
|
||||
]
|
||||
},
|
||||
"buffers":
|
||||
[
|
||||
],
|
||||
"build_system": "",
|
||||
"build_system_choices":
|
||||
[
|
||||
],
|
||||
"build_varint": "",
|
||||
"command_palette":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"replv",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repl v",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"virtualen",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"repl p",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repl py",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repel p",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"error",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"show",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"rep",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"python",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"virtual",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"python vi",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"repl python",
|
||||
"SublimeREPL: Python - virtualenv"
|
||||
],
|
||||
[
|
||||
"virtua",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"sublimerepl",
|
||||
"Virtualenv: SublimeREPL - Python"
|
||||
],
|
||||
[
|
||||
"install",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"virt",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"virtu",
|
||||
"Virtualenv: Activate"
|
||||
],
|
||||
[
|
||||
"packa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"vir",
|
||||
"Virtualenv: New (venv)"
|
||||
],
|
||||
[
|
||||
"install pa",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"insta",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ins",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"brow",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"browse",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"remove",
|
||||
"Package Control: Remove Package"
|
||||
],
|
||||
[
|
||||
"Snippet: ",
|
||||
"Snippet: For Loop"
|
||||
],
|
||||
[
|
||||
"remo",
|
||||
"Package Control: Remove Channel"
|
||||
],
|
||||
[
|
||||
"show all",
|
||||
"SublimeLinter: Show All Errors"
|
||||
],
|
||||
[
|
||||
"prefs",
|
||||
"Preferences: SublimeLinter Settings"
|
||||
],
|
||||
[
|
||||
"package in",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"install pack",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"ayu: Activate theme",
|
||||
"ayu: Activate theme"
|
||||
],
|
||||
[
|
||||
"Browse Pack",
|
||||
"Preferences: Browse Packages"
|
||||
],
|
||||
[
|
||||
"Package Control: insta",
|
||||
"Package Control: Install Package"
|
||||
]
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"console":
|
||||
{
|
||||
"height": 250.0,
|
||||
"history":
|
||||
[
|
||||
"sublime.cache_path()",
|
||||
"import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
|
||||
]
|
||||
},
|
||||
"distraction_free":
|
||||
{
|
||||
"menu_visible": true,
|
||||
"show_minimap": false,
|
||||
"show_open_files": false,
|
||||
"show_tabs": false,
|
||||
"side_bar_visible": false,
|
||||
"status_bar_visible": false
|
||||
},
|
||||
"expanded_folders":
|
||||
[
|
||||
"/home/dtomlinson/projects",
|
||||
"/home/dtomlinson/projects/learning",
|
||||
"/home/dtomlinson/projects/learning/descriptors"
|
||||
],
|
||||
"file_history":
|
||||
[
|
||||
"/home/dtomlinson/projects/learning/descriptors/test.py",
|
||||
"/home/dtomlinson/projects/learning/descriptors/descriptors.py",
|
||||
"/home/dtomlinson/projects/learning/descriptors/descriptors2.py",
|
||||
"/home/dtomlinson/projects/temp/temp_new.sublime-workspace",
|
||||
"/home/dtomlinson/sublime/base.sublime-project",
|
||||
"/home/dtomlinson/projects/learning/descriptors/test.py.join(",
|
||||
"/home/dtomlinson/projects/random_sampling/test.py",
|
||||
"/home/dtomlinson/projects/learning/property/property2.py",
|
||||
"/home/dtomlinson/projects/learning/property/property1.py",
|
||||
"/home/dtomlinson/projects/learning/property/property.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/decorator.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/classes_with_args.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/test.py",
|
||||
"/tmp/mozilla_dtomlinson0/borg-docker-plex-do.sh",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/SublimeREPL.sublime-settings",
|
||||
"/home/dtomlinson/projects/learning/learning.sublime-project",
|
||||
"/home/dtomlinson/projects/boto3/blocking_suggestions/.history.txt",
|
||||
"/home/dtomlinson/.bash_profile",
|
||||
"/home/dtomlinson/projects/learning/singletons/client_a.py",
|
||||
"/home/dtomlinson/projects/learning/singletons/client_b.py",
|
||||
"/home/dtomlinson/projects/learning/singletons/db.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/function_decorators.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/classes_decorater.py",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/SublimeREPL/SublimeREPL.sublime-settings",
|
||||
"/home/dtomlinson/projects/learning/decorators/script1.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/decorators.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/__init__.py",
|
||||
"/home/dtomlinson/projects/learning/decorators/pathfix.py",
|
||||
"/home/dtomlinson/projects/learning/import-args/script1.py",
|
||||
"/home/dtomlinson/projects/learning/super/class_1.py",
|
||||
"/home/dtomlinson/projects/learning/super/temp.py",
|
||||
"/home/dtomlinson/projects/learning/import-args/script2.py",
|
||||
"/home/dtomlinson/projects/learning/import-args/script3.py",
|
||||
"/home/dtomlinson/projects/bayes-learning/lesson1.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/core/series.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/io/api.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/io/excel.py",
|
||||
"/home/dtomlinson/docker-commands/bookstack-temp.txt",
|
||||
"/home/dtomlinson/projects/learning/super/triangle.py",
|
||||
"/home/dtomlinson/projects/learning/super/rectangle-square.py",
|
||||
"/home/dtomlinson/projects/learning/class-and-object-orianted-python/lesson1.py",
|
||||
"/usr/lib64/python3.7/datetime.py",
|
||||
"/home/dtomlinson/projects/bayes-learning/seaborn.py",
|
||||
"/home/dtomlinson/.virtualenvs/bayes-learning/lib/python3.7/site-packages/pandas/core/frame.py",
|
||||
"/home/dtomlinson/Downloads/borg-backup-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/borg-docker-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/tmp/borg-docker-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/tmp/borg-backup-plex-do.sh",
|
||||
"/home/dtomlinson/Downloads/borg-docker-plex-server.sh",
|
||||
"/home/dtomlinson/Downloads/borg-docker-plex-download.sh",
|
||||
"/home/dtomlinson/Downloads/borg-backup-plex-download.sh",
|
||||
"/home/dtomlinson/Downloads/borg-backup-plex-server.sh",
|
||||
"/home/dtomlinson/Downloads/credentials.csv",
|
||||
"/home/dtomlinson/requirements.txt",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/Anaconda/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Anaconda.sublime-settings",
|
||||
"/home/dtomlinson/projects/learning/test.py",
|
||||
"/home/dtomlinson/projects/temp/temp_1.py",
|
||||
"/home/dtomlinson/projects/temp/test.py",
|
||||
"/home/dtomlinson/projects/learning/class-and-object-orianted-python/links.txt",
|
||||
"/home/dtomlinson/projects/base/base.sublime-project",
|
||||
"/home/dtomlinson/projects/temp/temp_new.sublime-project",
|
||||
"/home/dtomlinson/projects/temp/temp.sublime-project",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-mirage.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/ayu-dark.sublime-theme",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/SideBarEnhancements/Side Bar.sublime-settings",
|
||||
"/home/dtomlinson/.config/sublime-text-3/Packages/User/Python.sublime-settings"
|
||||
],
|
||||
"find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"find_in_files":
|
||||
{
|
||||
"height": 0.0,
|
||||
"where_history":
|
||||
[
|
||||
]
|
||||
},
|
||||
"find_state":
|
||||
{
|
||||
"case_sensitive": false,
|
||||
"find_history":
|
||||
[
|
||||
"self.__age",
|
||||
"drinking_age",
|
||||
"name",
|
||||
"name ",
|
||||
"arg",
|
||||
"myobj",
|
||||
"arg",
|
||||
"return",
|
||||
"arg",
|
||||
"return",
|
||||
"__x",
|
||||
"arg",
|
||||
"fibonacci",
|
||||
"self",
|
||||
"decorator",
|
||||
"self"
|
||||
],
|
||||
"highlight": true,
|
||||
"in_selection": false,
|
||||
"preserve_case": false,
|
||||
"regex": false,
|
||||
"replace_history":
|
||||
[
|
||||
],
|
||||
"reverse": false,
|
||||
"show_context": true,
|
||||
"use_buffer2": true,
|
||||
"whole_word": true,
|
||||
"wrap": false
|
||||
},
|
||||
"groups":
|
||||
[
|
||||
{
|
||||
"sheets":
|
||||
[
|
||||
]
|
||||
},
|
||||
{
|
||||
"sheets":
|
||||
[
|
||||
]
|
||||
}
|
||||
],
|
||||
"incremental_find":
|
||||
{
|
||||
"height": 29.0
|
||||
},
|
||||
"input":
|
||||
{
|
||||
"height": 51.0
|
||||
},
|
||||
"layout":
|
||||
{
|
||||
"cells":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
],
|
||||
"cols":
|
||||
[
|
||||
0.0,
|
||||
0.5,
|
||||
1.0
|
||||
],
|
||||
"rows":
|
||||
[
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"menu_visible": true,
|
||||
"output.SublimeLinter":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"output.exec":
|
||||
{
|
||||
"height": 132.0
|
||||
},
|
||||
"output.find_results":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"pinned_build_system": "Packages/Virtualenv/Python + Virtualenv.sublime-build",
|
||||
"project": "/home/dtomlinson/sublime/base.sublime-project",
|
||||
"replace":
|
||||
{
|
||||
"height": 54.0
|
||||
},
|
||||
"save_all_on_build": true,
|
||||
"select_file":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"select_project":
|
||||
{
|
||||
"height": 500.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"",
|
||||
"~/projects/bayes-learning/seaborn.sublime-workspace"
|
||||
]
|
||||
],
|
||||
"width": 380.0
|
||||
},
|
||||
"select_symbol":
|
||||
{
|
||||
"height": 0.0,
|
||||
"last_filter": "",
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"selected_group": 0,
|
||||
"settings":
|
||||
{
|
||||
"last_automatic_layout":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
]
|
||||
},
|
||||
"show_minimap": true,
|
||||
"show_open_files": true,
|
||||
"show_tabs": true,
|
||||
"side_bar_visible": true,
|
||||
"side_bar_width": 221.0,
|
||||
"status_bar_visible": true,
|
||||
"template_settings":
|
||||
{
|
||||
"max_columns": 2
|
||||
}
|
||||
}
|
||||
13
learning/property/property.py
Normal file
13
learning/property/property.py
Normal file
@@ -0,0 +1,13 @@
|
||||
class Celsius(object):
|
||||
"""docstring for Celsius"""
|
||||
def __init__(self, temperature=0):
|
||||
super(Celsius, self).__init__()
|
||||
self.temperature = temperature
|
||||
|
||||
@classmethod
|
||||
def from_fahrenheit(cls, temperature=32):
|
||||
temperature = (temperature - 32) / (9 / 5)
|
||||
return cls(temperature)
|
||||
|
||||
def to_fahrenheit(self):
|
||||
return (self.temperature * 1.8) + 32
|
||||
26
learning/property/property1.py
Normal file
26
learning/property/property1.py
Normal file
@@ -0,0 +1,26 @@
|
||||
class P:
|
||||
|
||||
def __init__(self, x):
|
||||
print('init')
|
||||
self._x = x
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
print('get')
|
||||
return self._x
|
||||
|
||||
@x.setter
|
||||
def x(self, x):
|
||||
print('set')
|
||||
if x < 0:
|
||||
self._x = 0
|
||||
elif x > 1000:
|
||||
self._x = 1000
|
||||
else:
|
||||
self._x = x
|
||||
|
||||
def double(self):
|
||||
return self.x * 2
|
||||
|
||||
def overwrite(self):
|
||||
self.x = 20
|
||||
32
learning/property/property2.py
Normal file
32
learning/property/property2.py
Normal file
@@ -0,0 +1,32 @@
|
||||
class Robot:
|
||||
|
||||
def __init__(self, name, build_year, lk=0.5,
|
||||
lp=0.5):
|
||||
self.name = name
|
||||
self.build_year = build_year
|
||||
self.__potential_physical = lk
|
||||
self.__potential_psychic = lp
|
||||
|
||||
@property
|
||||
def condition(self):
|
||||
s = self.__potential_physical + self.__potential_psychic
|
||||
if s <= -1:
|
||||
return "I feel miserable!"
|
||||
elif s <= 0:
|
||||
return "I feel bad!"
|
||||
elif s <= 0.5:
|
||||
return "Could be worse!"
|
||||
elif s <= 1:
|
||||
return "Seems to be okay!"
|
||||
else:
|
||||
return "Great!"
|
||||
|
||||
def printer(self):
|
||||
return self.condition
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
return 'get'
|
||||
|
||||
|
||||
x = Robot("Marvin", 1979, 0.2, 0.4)
|
||||
y = Robot("Caliban", 1993, -0.4, 0.3)
|
||||
BIN
learning/singletons/__pycache__/db.cpython-37.pyc
Normal file
BIN
learning/singletons/__pycache__/db.cpython-37.pyc
Normal file
Binary file not shown.
6
learning/singletons/client_a.py
Normal file
6
learning/singletons/client_a.py
Normal file
@@ -0,0 +1,6 @@
|
||||
mygenerator = (x * x for x in range(3))
|
||||
for i in mygenerator:
|
||||
print(i)
|
||||
|
||||
for i in mygenerator:
|
||||
print(i)
|
||||
4
learning/singletons/client_b.py
Normal file
4
learning/singletons/client_b.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import db
|
||||
|
||||
if (db.db_name == 'mongo'):
|
||||
db.db_name = None
|
||||
19
learning/singletons/db.py
Normal file
19
learning/singletons/db.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
this = sys.modules[__name__]
|
||||
|
||||
print(this)
|
||||
|
||||
this.db_name = None
|
||||
|
||||
print(this.db_name)
|
||||
|
||||
|
||||
def initialize_db(name):
|
||||
if (this.db_name is None):
|
||||
this.db_name = name
|
||||
# db_name = "Local Variable"
|
||||
else:
|
||||
msg = f"Database is already initialized to {name}"
|
||||
raise RuntimeError(msg.format(this.db_name))
|
||||
32
learning/super/class_1.py
Normal file
32
learning/super/class_1.py
Normal file
@@ -0,0 +1,32 @@
|
||||
class Celsius:
|
||||
def __init__(self, temperature=0):
|
||||
print('initalising')
|
||||
self.temperature = temperature
|
||||
|
||||
def __repr__(self):
|
||||
return(f'current temperature is {self.temperature} degrees C')
|
||||
|
||||
def to_fahrenheit(self):
|
||||
return (self.temperature * 1.8) + 32
|
||||
|
||||
def get_temperature(self):
|
||||
print("Getting value")
|
||||
return self._temperature
|
||||
|
||||
def set_temperature(self, value):
|
||||
if value < -273:
|
||||
raise ValueError("Temperature below -273 is not possible")
|
||||
print("Setting value")
|
||||
self._temperature = value
|
||||
return value
|
||||
|
||||
temperature = property(get_temperature, set_temperature)
|
||||
|
||||
|
||||
# c = Celsius(20)
|
||||
# print(Celsius(20).get_temperature)
|
||||
|
||||
# print(Celsius(20).set_temperature(25))
|
||||
# Celsius(20).get_temperature()
|
||||
c = Celsius()
|
||||
print(c.to_fahrenheit())
|
||||
33
learning/super/notes.txt
Normal file
33
learning/super/notes.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
children precede their parents and the order of appearance in __bases__ is respected.
|
||||
|
||||
why not to use super in object classes: The problem with incompatible signatures https://www.artima.com/weblogs/viewpost.jsp?thread=281127
|
||||
|
||||
why (swap the print and super in each command)
|
||||
class First(object):
|
||||
def __init__(self):
|
||||
super(First, self).__init__()
|
||||
print("first")
|
||||
|
||||
class Second(object):
|
||||
def __init__(self):
|
||||
super(Second, self).__init__()
|
||||
print("second")
|
||||
|
||||
class Third(First, Second):
|
||||
def __init__(self):
|
||||
super(Third, self).__init__()
|
||||
print("third")
|
||||
|
||||
Third()
|
||||
print(Third.__mro__)
|
||||
|
||||
second
|
||||
first
|
||||
third
|
||||
(<class '__main__.Third'>, <class '__main__.First'>, <class '__main__.Second'>, <class 'object'>)
|
||||
[Finished in 0.0s]
|
||||
|
||||
|
||||
https://www.datacamp.com/community/data-science-cheatsheets
|
||||
|
||||
https://www.datacamp.com/community/tutorials/decorators-python - functions returning other functions?
|
||||
97
learning/super/rectangle-square.py
Normal file
97
learning/super/rectangle-square.py
Normal file
@@ -0,0 +1,97 @@
|
||||
#!~/.virtualenvs/learning/bin/python
|
||||
|
||||
|
||||
class Rectangle(object):
|
||||
"""calculates the area and perimeter of a rectangle"""
|
||||
|
||||
def __init__(self, length, width, **kwargs):
|
||||
super(Rectangle, self).__init__(**kwargs)
|
||||
self.length = length
|
||||
self.width = width
|
||||
|
||||
def area(self):
|
||||
return(self.length * self.width)
|
||||
|
||||
def perimeter(self):
|
||||
return(2 * self.length + 2 * self.width)
|
||||
|
||||
|
||||
# Here we can declare the superclass for the subclass Square
|
||||
|
||||
class Square(Rectangle):
|
||||
"""calculates the area and perimeter of a square"""
|
||||
|
||||
def __init__(self, length, **kwargs):
|
||||
super(Square, self).__init__(length=length, width=length, **kwargs)
|
||||
|
||||
|
||||
class Cube(Square):
|
||||
"""calculates the surface area and volume of a cube"""
|
||||
|
||||
def __init__(self, length, **kwargs):
|
||||
super(Cube, self).__init__(length=length, **kwargs)
|
||||
self.length = length
|
||||
|
||||
def surface_area(self):
|
||||
face_area = super(Cube, self).area()
|
||||
return(6 * face_area)
|
||||
|
||||
def volume(self):
|
||||
face_area = super(Cube, self).area()
|
||||
return(face_area * self.length)
|
||||
|
||||
def area(self):
|
||||
return(self.length * self.length + 1)
|
||||
# return(super(Cube, self))
|
||||
|
||||
|
||||
class Triangle(object):
|
||||
"""calculates the area of a triangle"""
|
||||
|
||||
def __init__(self, base, height, **kwargs):
|
||||
self.base = base
|
||||
self.height = height
|
||||
super(Triangle, self).__init__(**kwargs)
|
||||
|
||||
def tri_area(self):
|
||||
return 0.5 * self.base * self.height
|
||||
|
||||
|
||||
class RightPyramid(Square, Triangle):
|
||||
"""calculates the surface area of a right pyramid"""
|
||||
|
||||
def __init__(self, base, slant_height, **kwargs):
|
||||
kwargs['height'] = slant_height
|
||||
kwargs['length'] = base
|
||||
super(RightPyramid, self).__init__(base=base, **kwargs)
|
||||
self.base = base
|
||||
self.slant_height = slant_height
|
||||
|
||||
def area(self):
|
||||
base_area = super(RightPyramid, self).area()
|
||||
perimeter = super(RightPyramid, self).perimeter()
|
||||
return(0.5 * perimeter * self.slant_height + base_area)
|
||||
|
||||
def area_2(self):
|
||||
base_area = super(RightPyramid, self).area()
|
||||
triangle_area = super(RightPyramid, self).tri_area()
|
||||
return(triangle_area * 4 + base_area)
|
||||
|
||||
|
||||
class new_cube(Cube):
|
||||
"""docstring for new_cube"""
|
||||
def __init__(self, new_length):
|
||||
super(new_cube, self).__init__(length=new_length)
|
||||
self.new_length = new_length
|
||||
|
||||
|
||||
# print(RightPyramid.__mro__)
|
||||
pyramid = RightPyramid(2, 4)
|
||||
print(pyramid.area())
|
||||
print(pyramid.area_2())
|
||||
|
||||
nc = new_cube(4)
|
||||
print(nc.surface_area())
|
||||
|
||||
square = Square(3)
|
||||
print(square.perimeter())
|
||||
0
learning/super/temp.py
Normal file
0
learning/super/temp.py
Normal file
20
learning/super/triangle.py
Normal file
20
learning/super/triangle.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# ~/.virtualenvs/learning/python
|
||||
|
||||
|
||||
def convert_to_uppercase(function):
|
||||
""" will convert to uppercase """
|
||||
def wrapper():
|
||||
func = function()
|
||||
make_uppercase = func.upper()
|
||||
return make_uppercase
|
||||
|
||||
|
||||
# @convert_to_uppercase
|
||||
def hello():
|
||||
""" print hello world """
|
||||
return 'hello world'
|
||||
|
||||
|
||||
say_HELLO = convert_to_uppercase(hello)
|
||||
|
||||
print(say_HELLO())
|
||||
14
learning/test.py
Normal file
14
learning/test.py
Normal file
@@ -0,0 +1,14 @@
|
||||
replace_chars = ['[', ']', '\'', ',']
|
||||
list_of_ips = []
|
||||
new_list = []
|
||||
|
||||
|
||||
def split_ips(list):
|
||||
for sub_list in list:
|
||||
for ip in sub_list.split():
|
||||
for i in range(len(replace_chars)):
|
||||
ip = ip.replace(replace_chars[i], '')
|
||||
new_list.append(ip)
|
||||
|
||||
|
||||
split_ips(list_of_ips)
|
||||
Reference in New Issue
Block a user