equal
deleted
inserted
replaced
1 Creating a tuple:\\ |
1 See where python searches for modules:\\ |
2 {\ex \lstinline| t = (1, "hello", 2.5)|} |
2 {\ex \lstinline| sys.path|} |
3 |
3 |
4 Accessing elements of tuples:\\ |
4 Include our own path in PYTHONPATH:\\ |
5 {\ex \lstinline| t[index] Ex: t[2]|} |
5 {\ex \lstinline| sys.path.append(our_path)|} |
6 |
6 |
7 Accessing slices of tuples:\\ |
7 Run certian code only if executed and not if imported:\\ |
8 {\ex \lstinline| t[start:stop:step]|} |
8 {\ex \lstinline| if __name__=="__main__": #do something|} |
9 |
9 |
10 Swapping values:\\ |
|
11 {\ex \lstinline| a, b = b, a|} |
|