Skip to content

Commit

Permalink
{% highlight %} is no longer supported
Browse files Browse the repository at this point in the history
  • Loading branch information
kichik committed Aug 19, 2017
1 parent 252dcc2 commit 9fef408
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ A simple website with a bunch of code samples that should help convince you to s

Create a pull request that adds a new file to `_posts` folder. The file name format is `YYYY-MM-DD-title.md` and its contentts should be based on the following template.

```yaml
````yaml
---
title: Some title
repl: https://repl.it/XXXX # upload same code sample to repl.it and put link here
---
{% highlight python %}
```python
# insert code here
{% endhighlight %}
```
````
4 changes: 2 additions & 2 deletions _posts/2017-08-09-enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Enum
repl: https://repl.it/KDQ3/17
---
{% highlight python %}
```python
# enumerations are fully supported
# you longer need to create your own conversion and comparison methods

Expand All @@ -18,4 +18,4 @@ print(Color(2)) # Color.green

print(Color.red == 1) # False
print(Color.red.value == 1) # True
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-ipaddress.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: ipaddress
repl: https://repl.it/KDQ3/18
---
{% highlight python %}
```python
# built-in ipaddress module that helps you easily deal with IP addresses
# check type, compare, check against subnets and more with both IPv4 and IPv6

Expand All @@ -19,4 +19,4 @@ print('is multicast', ip6.is_multicast)
net = ip_network('192.168.0.0/24')
print(f'{ip4} in {net} =', ip4 in net)
print(f'{ip6} in {net} =', ip6 in net)
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-keyword.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Keyword only arguments
repl: https://repl.it/KDQ3/19
---
{% highlight python %}
```python
# avoid accidental passing of keyword arguments

a, b, *rest = range(10)
Expand All @@ -13,4 +13,4 @@ def f(a, b, *args, option=True):
f(a, b, False)
# in both python 2 and 3 this explictly passes option=False
f(a, b, option=False)
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-lru.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: LRU decorator
repl: https://repl.it/KDQ3/7
---
{% highlight python %}
```python
# built-in Last Recently Used cache decorator
# useful for caching expensive function most-used results

Expand All @@ -24,4 +24,4 @@ print(get_something(2)) # 3
print(get_something(3)) # 4
print(get_something(4)) # 5
print(get_something(0)) # 6
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-pathlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: pathlib
repl: https://repl.it/KDQ3/9
---
{% highlight python %}
```python
# easy path manipulation library
# no more os.path.join() and os.path.is* everywhere

Expand All @@ -13,4 +13,4 @@ filepath = directory / "test_file.txt"

if not filepath.exists():
Path("/tmp/some/folder/somewhere").mkdir(parents=True)
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: secrets
repl: https://repl.it/KDQ3/10
---
{% highlight python %}
```python
# useful helpers for generating random and *secure* data of all types

import secrets
Expand All @@ -11,4 +11,4 @@ print(secrets.token_bytes(16))
print(secrets.token_hex(16))
print(secrets.token_urlsafe(16))
print(secrets.randbelow(10))
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-suppress.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Suppress exceptions
repl: https://repl.it/KDQ3/2
---
{% highlight python %}
```python
from contextlib import suppress

d = {1: 'one', 2: 'two'}
Expand All @@ -15,4 +15,4 @@ try:
print(d[3])
except KeyError:
pass
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-unpacking.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Advanced unpacking
repl: https://repl.it/KDQ3/20
---
{% highlight python %}
```python
# easily split lists or iterators into variables

a, b, *rest = range(10)
Expand All @@ -21,4 +21,4 @@ l = list(range(10))
a = l[0]
rest = l[1:-1]
b = l[-1]
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-09-yield.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: yield from generator
repl: https://repl.it/KDQ3/5
---
{% highlight python %}
```python
# easy way to use iterators in your generator

def weird_range():
Expand All @@ -19,4 +19,4 @@ def python2_weird_range():
yield i
for i in range(5):
yield i
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-11-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Annotations
repl: https://repl.it/KGI3/2
---
{% highlight python %}
```python
# add type annotations to variables, arguments and functions
# you can later access those programmatically

Expand All @@ -14,4 +14,4 @@ def my_add(a: int, b: int) -> int:

print(my_add(40, 2)) # 42
print(my_add.__annotations__) # {'a': <class 'int'>, 'b': <class 'int'>, 'return': <class 'int'>}
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-11-fstrings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
title: fstrings
repl: https://repl.it/KDQ3/15
---
{% highlight python %}
```python
# easy string formatting
# no more '%{name}s' % {'name': name}
name = 'Alice'
print(f'My name is {name}.') # prints "My name is Alice"
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-11-numeric-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
title: Numeric literals
repl: https://repl.it/KGI3
---
{% highlight python %}
```python
# underscores can be used to make numbers easier to read in code
big_number = 100_000_000_000

print(big_number) # 100000000000
{% endhighlight %}
```
4 changes: 2 additions & 2 deletions _posts/2017-08-11-super.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Automatic super
repl: https://repl.it/KDQ3/21
---
{% highlight python %}
```python
# super() no longer requires passing the class name and self

class A:
Expand All @@ -17,4 +17,4 @@ class B(A):

b = B()
print(b.arg) # hello
{% endhighlight %}
```

0 comments on commit 9fef408

Please sign in to comment.