Skip to content

Commit

Permalink
Merge branch 'main' of github.com:bbelderbos/bobcodesit
Browse files Browse the repository at this point in the history
  • Loading branch information
pybob committed Dec 13, 2023
2 parents c8a0e0c + 7885599 commit fe3154f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
15 changes: 9 additions & 6 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ This file gets generated by [this script](index.py).
- [Make a class callable](notes/20220909090435.md)
- [Method chaining](notes/20220921175826.md)

## Codecs

- [How to capture the zen of python (and redirect standard output)?](notes/20231207123339.md)

## Collections

- [Collections.deque](notes/20220906154334.md)
Expand Down Expand Up @@ -76,7 +80,6 @@ This file gets generated by [this script](index.py).

## Contextmanager

- [How to capture the zen of python (and redirect standard output)?](notes/20231207123339.md)
- [The power of context managers](notes/20231212064259.md)

## Dataclasses
Expand Down Expand Up @@ -156,6 +159,10 @@ This file gets generated by [this script](index.py).
- [F-string debugging technique](notes/20220904165337.md)
- [Zfill](notes/20220914144334.md)

## Format

- [How to capture the zen of python (and redirect standard output)?](notes/20231207123339.md)

## Functions

- [Avoid mutable default arguments](notes/20220910100519.md)
Expand Down Expand Up @@ -322,7 +329,6 @@ This file gets generated by [this script](index.py).
## Stringformatting

- [5 things you might not know f-strings can do 💡 🧵](notes/20230829122531.md)
- [How to capture the zen of python (and redirect standard output)?](notes/20231207123339.md)

## Strings

Expand Down Expand Up @@ -376,13 +382,10 @@ This file gets generated by [this script](index.py).

- [Urlencode()](notes/20221125164329.md)

## Withstatement

- [The power of context managers](notes/20231212064259.md)

## Zen

- [How to capture the zen of python (and redirect standard output)?](notes/20231207123339.md)
- [Sparse is better than dense.](notes/20231212143456.md)
- [Zip() got a strict keyword arg](notes/20220908171538.md)

## Zlib
Expand Down
2 changes: 1 addition & 1 deletion notes/20231207123339.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ for i, title in enumerate(import_this_output.splitlines()[2:], start=1):

I love how expressive Python is! 🐍 😍

#contextmanager #contextlib #zen #enumerate #stringformatting
#contextlib #codecs #zen #enumerate #format
2 changes: 1 addition & 1 deletion notes/20231212064259.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ Note there are two ways to define Python context managers:

• Function-Based: Utilize contextlib module's @contextmanager decorator and write a function with a yield statement. More lightweight and straightforward for simpler tasks.

#contextmanager #contextlib #withstatement
#contextmanager #contextlib
27 changes: 27 additions & 0 deletions notes/20231212143456.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Sparse is better than dense.

Just by using more space (e.g. characters + newlines) your code will be much more pleasant / readable.

```
# dense
def generate_xmas_tree(rows=10):
width, output = rows*2, []
for i in range(1, width+1, 2):
row = "*"*i
output.append(row.center(width, " "))
return "\n".join(output)
# sparse
def generate_xmas_tree(rows=10):
width = rows * 2
output = []
for i in range(1, width + 1, 2):
row = "*" * i
output.append(row.center(width, " "))
return "\n".join(output)
```

#zen

0 comments on commit fe3154f

Please sign in to comment.