summaryrefslogtreecommitdiff
path: root/Technology/Python.md
blob: f1e78e1b7536802b9f9dd7cd8fbb4b183eb114ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Python does not have a classpath and unless you are root, you can't install new pkg for the whole system

# pip installs in

.local/lib/


virtualenv - solution to pkg management? - isolated space with own instance of python

virtualenv TESTENV -p python
source TESTENV/bin/activate
# to get out of env
deactivate

** exponant

x = 'Mark'
len(x) - function
x.upper() - method

dir() - built it give directory of an object (all methods available)
super() - goes trought inheritance chain and return the class that is after the one passed as the function first argument. Can by used to bypass modification made by earlier classes.


# Data containers

list()  - []
dict()  - {}
tuple() - ()
set()   - set()



__ init__  - where to assign instance specific attributes when object first constructed
__ str__ - control how object is printed
__ repr__ - object output when interactive shell
__ eq__ - uniquely identify all created object


1st time you import a modules python execute the code inside it.
2nd time will not re-run the code. (usefull when import multiples modules that import all the same modules)
importlib if want to reload modules so run more than once

When importing a module you can use it's defined functions, classes, constants etc...
Access those thing by putting the module name as prefix before the function