Skip to content
Snippets Groups Projects
Verified Commit d57f1519 authored by Toby Hodges's avatar Toby Hodges
Browse files

merge and reorganise

parents bfdb76b4 82977ee2
No related branches found
No related tags found
No related merge requests found
Showing
with 279 additions and 1 deletion
%% Cell type:code id: tags:
``` python
# this can be a shortcut to assign None to multiple variables
x = y = z = None
z = 1
print(x,y,z)
```
%% Output
(None, None, 1)
%% Cell type:code id: tags:
``` python
## assert
mylist = ['a', 'c', 'f']
assert 'b' in mylist, "b wasn't in there!"
```
%% Output
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-5-a791a4bf8f4c> in <module>()
1 ## assert
2 mylist = ['a', 'c', 'f']
----> 3 assert 'b' in mylist, "b wasn't in there!"
AssertionError: b wasn't in there!
%% Cell type:code id: tags:
``` python
# BAD: this is probably not what you wanted
u, i, o = []
o.append("x")
print(u,i,o)
```
%% Output
(['x'], ['x'], ['x'])
%% Cell type:code id: tags:
``` python
# BAD: the original list you pass to the method will get updated!
def my_method(mutable_list=[]):
mutable_list.append('x')
return mutable_list
# a list out of the my_method scope
a_list = ['a']
b_list = my_method(mutable_list=a_list)
# a_list get modified!
print( a_list == b_list, a_list, b_list )
```
%% Output
(True, ['a', 'x'], ['a', 'x'])
%% Cell type:markdown id: tags:
Whats wrong here...
```bash
conda create -n giphy python=3
conda install Flask
(..)
Package plan for installation in environment /Users/scholtal/anaconda:
(..)
The following packages will be UPDATED:
(..)
The following packages will be DOWNGRADED due to dependency conflicts:
(..)
```
Spot the missing ``source activate giphy``....
%% Cell type:code id: tags:
``` python
from collections import defaultdict
d = defaultdict(list)
d["a"] = [1]
d["a"].append(2)
print(d)
```
%% Output
defaultdict(<class 'list'>, {'a': [1, 2]})
%% Cell type:code id: tags:
``` python
d = defaultdict(int)
d["a"] += 1
d["a"] += 2
print(d)
```
%% Output
defaultdict(<class 'int'>, {'a': 3})
%% Cell type:code id: tags:
``` python
## without using deafaultdict
e = {}
e.setdefault("newkey", []).append(1)
e.setdefault("newkey1", []).append(2)
e
```
%% Output
{'newkey': [1], 'newkey1': [2]}
%% Cell type:code id: tags:
``` python
f = dict(newkey=[1])
f["newkey"].append(2)
f
```
%% Output
{'newkey': [1, 2]}
%% Cell type:code id: tags:
``` python
f
```
File moved
File moved
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
A group of people at EMBL Heidelberg, who share an interest in the Python programming language. You can contact the group by sending email to [python@embl.de](mailto:python@embl.de). The mailing list is managed by [Toby Hodges](mailto:toby.hodges@embl.de), [Malvika Sharan](mailto:malvika.sharan@embl.de), and [Marc Gouw](mailto:gouw@embl.de) - to join us, send an email to one of them. Meetings usually take place fortnightly, on Wednesdays at 17:00, in the Biocomputing Seminar Room (100). A group of people at EMBL Heidelberg, who share an interest in the Python programming language. You can contact the group by sending email to [python@embl.de](mailto:python@embl.de). The mailing list is managed by [Toby Hodges](mailto:toby.hodges@embl.de), [Malvika Sharan](mailto:malvika.sharan@embl.de), and [Marc Gouw](mailto:gouw@embl.de) - to join us, send an email to one of them. Meetings usually take place fortnightly, on Wednesdays at 17:00, in the Biocomputing Seminar Room (100).
#### Ideas/suggestions for future meetings ## Ideas/suggestions for future meetings
Please add to this list, or email one of the mailing list managers above, to suggest/request/volunteer a topic for discussion. Please add to this list, or email one of the mailing list managers above, to suggest/request/volunteer a topic for discussion.
...@@ -10,3 +10,16 @@ Please add to this list, or email one of the mailing list managers above, to sug ...@@ -10,3 +10,16 @@ Please add to this list, or email one of the mailing list managers above, to sug
- super() - super()
- .py -> .ipynb - .py -> .ipynb
- matplotlib 2.0 - matplotlib 2.0
## Jupyter Notebooks
For some meetings you may find Jupyter notebooks that have been used in the meetings demonstrating/documenting discussions.
## Getting Started
```
conda create -n epug python=3 jupyter
source activate epug
jupyter notebook
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment