Compare commits
39 Commits
28d6d03315
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf3161ca00 | ||
|
|
8c8c08170a | ||
|
|
162dbadbe5 | ||
|
|
cf99650007 | ||
|
|
ec03da74ca | ||
|
|
5b743b5bd7 | ||
|
|
648e9f6394 | ||
|
|
cc4e26c67a | ||
|
|
c5490b1569 | ||
|
|
3d5588b75e | ||
|
|
1bd4b1e7be | ||
|
|
612c145ac9 | ||
|
|
ab8a774924 | ||
|
|
802c353075 | ||
|
|
243a02b766 | ||
|
|
e06a925d2f | ||
|
|
74c52779b4 | ||
|
|
a4aea64dd1 | ||
|
|
bfedc4d6e6 | ||
|
|
41866ada97 | ||
|
|
68de220bd1 | ||
|
|
8e911b19be | ||
|
|
f355aa37ed | ||
|
|
d14c7bed18 | ||
|
|
1b44dfaf11 | ||
|
|
74ee1d4915 | ||
|
|
1907aea700 | ||
|
|
dfb8fce86e | ||
|
|
abc03e728d | ||
|
|
e7ecb9cff0 | ||
|
|
7b13f5b8fd | ||
|
|
e7c182d027 | ||
|
|
567f3529e3 | ||
|
|
166a388ac8 | ||
|
|
51055887dd | ||
|
|
d3309f03e8 | ||
|
|
3f9c89554a | ||
|
|
d00908d553 | ||
|
|
08230737cc |
@@ -482,7 +482,7 @@
|
|||||||
" self.y = y\n",
|
" self.y = y\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __repr__(self):\n",
|
" def __repr__(self):\n",
|
||||||
" return 'Vector(%r, %r)' % (self.x, self.y)\n",
|
" return f'Vector({self.x!r}, {self.y!r})'\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __abs__(self):\n",
|
" def __abs__(self):\n",
|
||||||
" return math.hypot(self.x, self.y)\n",
|
" return math.hypot(self.x, self.y)\n",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
python3 -m doctest bisect_demo.py
|
python3 -m doctest bisect_demo.py
|
||||||
python3 -m doctest metro_lat_long.py
|
python3 -m doctest metro_lat_lon.py
|
||||||
pytest -q --nbval
|
pytest -q --nbval
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Sample code for Chapter 8 - "Object references, mutability and recycling"
|
Sample code for Chapter 6 - "Object references, mutability and recycling"
|
||||||
|
|
||||||
From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
|
From the book "Fluent Python" by Luciano Ramalho (O'Reilly, 2015)
|
||||||
http://shop.oreilly.com/product/0636920032519.do
|
http://shop.oreilly.com/product/0636920032519.do
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
geolib==1.0.7
|
geolib==1.0.7
|
||||||
future==0.18.2
|
future==0.18.3
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ def columnize(
|
|||||||
) -> Iterator[tuple[str, ...]]: # <1>
|
) -> Iterator[tuple[str, ...]]: # <1>
|
||||||
if num_columns == 0:
|
if num_columns == 0:
|
||||||
num_columns = round(len(sequence) ** 0.5)
|
num_columns = round(len(sequence) ** 0.5)
|
||||||
num_rows, reminder = divmod(len(sequence), num_columns)
|
num_rows, remainder = divmod(len(sequence), num_columns)
|
||||||
num_rows += bool(reminder)
|
num_rows += bool(remainder)
|
||||||
return (tuple(sequence[i::num_rows]) for i in range(num_rows)) # <2>
|
return (tuple(sequence[i::num_rows]) for i in range(num_rows)) # <2>
|
||||||
# end::COLUMNIZE[]
|
# end::COLUMNIZE[]
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ async def supervisor(cc_list: list[str],
|
|||||||
error = exc # <10>
|
error = exc # <10>
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
error = None
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
status = DownloadStatus.ERROR # <11>
|
status = DownloadStatus.ERROR # <11>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
anyio==3.3.2
|
anyio==3.3.2
|
||||||
certifi==2021.5.30
|
certifi==2024.7.4
|
||||||
charset-normalizer==2.0.6
|
charset-normalizer==2.0.6
|
||||||
h11==0.12.0
|
h11==0.16.0
|
||||||
httpcore==0.13.7
|
httpcore==0.13.7
|
||||||
httpx==1.0.0b0
|
httpx==1.0.0b0
|
||||||
idna==3.2
|
idna==3.7
|
||||||
rfc3986==1.5.0
|
rfc3986==1.5.0
|
||||||
sniffio==1.2.0
|
sniffio==1.2.0
|
||||||
tqdm==4.62.3
|
tqdm==4.66.3
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
click==7.1.2
|
click==7.1.2
|
||||||
fastapi==0.65.2
|
fastapi==0.65.2
|
||||||
h11==0.12.0
|
h11==0.16.0
|
||||||
pydantic==1.8.2
|
pydantic==1.10.13
|
||||||
starlette==0.13.6
|
starlette==0.40.0
|
||||||
typing-extensions==3.7.4.3
|
typing-extensions==3.7.4.3
|
||||||
uvicorn==0.13.4
|
uvicorn==0.13.4
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
# to recreate or update this file:
|
||||||
|
# $ cat custom.htaccess short.htaccess > FPY.LI.htaccess
|
||||||
|
|
||||||
ErrorDocument 404 /404.html
|
ErrorDocument 404 /404.html
|
||||||
|
|
||||||
# main resources
|
# main resources
|
||||||
@@ -1070,3 +1073,17 @@ RedirectTemp /24-27 https://docs.python.org/3/library/functools.html#functools.t
|
|||||||
RedirectTemp /24-28 https://www.python.org/download/releases/2.2.3/descrintro/
|
RedirectTemp /24-28 https://www.python.org/download/releases/2.2.3/descrintro/
|
||||||
RedirectTemp /24-29 https://github.com/lihaoyi/macropy
|
RedirectTemp /24-29 https://github.com/lihaoyi/macropy
|
||||||
RedirectTemp /24-30 https://people.eecs.berkeley.edu/~bh/ss-toc2.html
|
RedirectTemp /24-30 https://people.eecs.berkeley.edu/~bh/ss-toc2.html
|
||||||
|
# content of short.htaccess file created and managed by short.py
|
||||||
|
|
||||||
|
# appended: 2025-05-23 15:12:13
|
||||||
|
RedirectTemp /22 https://pythonfluente.com/2/#pattern_matching_case_study_sec
|
||||||
|
RedirectTemp /23 https://pythonfluente.com/2/#how_slicing_works
|
||||||
|
RedirectTemp /24 https://pythonfluente.com/2/#sliceable_sequence
|
||||||
|
RedirectTemp /25 https://pythonfluente.com/2/#virtual_subclass_sec
|
||||||
|
RedirectTemp /26 https://pythonfluente.com/2/#environment_class_ex
|
||||||
|
RedirectTemp /27 https://pythonfluente.com/2/#subclass_builtin_woes
|
||||||
|
RedirectTemp /28 https://pythonfluente.com/2/#slots_section
|
||||||
|
RedirectTemp /29 https://pythonfluente.com/2/#typeddict_sec
|
||||||
|
RedirectTemp /2a https://pythonfluente.com/2/#problems_annot_runtime_sec
|
||||||
|
RedirectTemp /2b https://pythonfluente.com/2/#legacy_deprecated_typing_box
|
||||||
|
RedirectTemp /2c https://pythonfluente.com/2/#positional_pattern_implement_sec
|
||||||
|
|||||||
@@ -1,40 +1,6 @@
|
|||||||
# Short links for URLs in the book
|
This file is deployed as `.htaccess` to the FPY.LI domain
|
||||||
|
to map short URLs in Fluent Python to the original URLs.
|
||||||
|
|
||||||
## Problem: link rot
|
To update it, I use tools in this other repo:
|
||||||
|
|
||||||
_Fluent Python, Second Edition_ has more than 1000 links to external resources.
|
https://github.com/pythonfluente/pythonfluente2e
|
||||||
Inevitably, some of those links will rot as time passes.
|
|
||||||
But I can't change the URLs in the print book...
|
|
||||||
|
|
||||||
## Solution: indirection
|
|
||||||
|
|
||||||
I replaced almost all URLs in the book with shortened versions that go through the `fpy.li` site which I control.
|
|
||||||
The site has an `.htaccess` file with *temporary* redirects.
|
|
||||||
|
|
||||||
When I find out a link is stale, I can thange the redirect in `.htaccess` to a new target,
|
|
||||||
which may be a link to copy in the Internet Archive's
|
|
||||||
[Wayback Machine](https://archive.org/web/)
|
|
||||||
o the link in the book is back in service through the updated redirect.
|
|
||||||
|
|
||||||
|
|
||||||
## Help wanted
|
|
||||||
|
|
||||||
Please report broken links as bugs in the [`FPY.LI.htaccess`](FPY.LI.htaccess) file.
|
|
||||||
Also, feel free to send pull requests with fixes to that file.
|
|
||||||
When I accept a PR, I will redeploy it to `fpy.li/.htaccess`.
|
|
||||||
|
|
||||||
## Details
|
|
||||||
|
|
||||||
Almost all URLs in the book are replaced with shortened versions like
|
|
||||||
[`http://fpy.li/1-3`](http://fpy.li/1-3)—for chapter 1, link #3.
|
|
||||||
|
|
||||||
There are also custom short URLs like
|
|
||||||
[`https://fpy.li/code`](https://fpy.li/code) which redirects to the example code repository.
|
|
||||||
I used custom short URLs for URLs with 3 or more mentions, or links to PEPs.
|
|
||||||
|
|
||||||
Exceptions:
|
|
||||||
|
|
||||||
- URLs with `oreilly` in them are unchanged;
|
|
||||||
- `fluentpython.com` URL (with no path) is unchanged;
|
|
||||||
|
|
||||||
The `FPY.LI.htaccess` is deployed at the root folder in `http://fpy.li`.
|
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
ErrorDocument 404 /404.html
|
|
||||||
|
|
||||||
# main resources
|
|
||||||
RedirectTemp /book https://www.oreilly.com/library/view/fluent-python-2nd/9781492056348/
|
|
||||||
RedirectTemp /code https://github.com/fluentpython/example-code-2e
|
|
||||||
RedirectTemp /home https://www.fluentpython.com/
|
|
||||||
|
|
||||||
# URLs mentioned at least three times
|
|
||||||
RedirectTemp /bisect https://www.fluentpython.com/extra/ordered-sequences-with-bisect/
|
|
||||||
RedirectTemp /cardxvi https://www.python.org/dev/peps/pep-0484/#the-numeric-tower
|
|
||||||
RedirectTemp /collec https://docs.python.org/3/library/collections.html
|
|
||||||
RedirectTemp /dask https://dask.org/
|
|
||||||
RedirectTemp /dtmodel https://docs.python.org/3/reference/datamodel.html
|
|
||||||
RedirectTemp /descr101 https://www.python.org/download/releases/2.2.3/descrintro/
|
|
||||||
RedirectTemp /descrhow https://docs.python.org/3/howto/descriptor.html
|
|
||||||
RedirectTemp /doctest https://docs.python.org/3/library/doctest.html
|
|
||||||
RedirectTemp /effectpy https://effectivepython.com/
|
|
||||||
RedirectTemp /fmtspec https://docs.python.org/3/library/string.html#formatspec
|
|
||||||
RedirectTemp /gunicorn https://gunicorn.org/
|
|
||||||
RedirectTemp /hashint https://www.fluentpython.com/extra/internals-of-sets-and-dicts/
|
|
||||||
RedirectTemp /hattingh https://www.oreilly.com/library/view/using-asyncio-in/9781492075325/
|
|
||||||
RedirectTemp /httpx https://www.python-httpx.org/
|
|
||||||
RedirectTemp /initvar https://docs.python.org/3/library/dataclasses.html#init-only-variables
|
|
||||||
RedirectTemp /mypy https://mypy.readthedocs.io/en/stable/
|
|
||||||
RedirectTemp /norvigdp http://norvig.com/design-patterns/
|
|
||||||
RedirectTemp /nsphere https://en.wikipedia.org/wiki/N-sphere
|
|
||||||
RedirectTemp /oldcoro https://www.fluentpython.com/extra/classic-coroutines/
|
|
||||||
RedirectTemp /pandas https://pandas.pydata.org/
|
|
||||||
RedirectTemp /pycook3 https://www.oreilly.com/library/view/python-cookbook-3rd/9781449357337/
|
|
||||||
RedirectTemp /pynut3 https://www.oreilly.com/library/view/python-in-a/9781491913833/
|
|
||||||
RedirectTemp /pypydif https://doc.pypy.org/en/latest/cpython_differences.html#subclasses-of-built-in-types
|
|
||||||
RedirectTemp /shed4051 https://github.com/python/typeshed/issues/4051
|
|
||||||
RedirectTemp /specattr https://docs.python.org/3/library/stdtypes.html#special-attributes
|
|
||||||
RedirectTemp /typecoro https://docs.python.org/3.10/library/typing.html#typing.Coroutine
|
|
||||||
RedirectTemp /typing https://docs.python.org/3/library/typing.html
|
|
||||||
RedirectTemp /weakref https://www.fluentpython.com/extra/weak-references/
|
|
||||||
|
|
||||||
# URL added during QA of the Second Edition
|
|
||||||
RedirectTemp /bdfl https://www.artima.com/weblogs/viewpost.jsp?thread=235725
|
|
||||||
|
|
||||||
# Python Enhancement Proposals
|
|
||||||
RedirectTemp /pep218 https://www.python.org/dev/peps/pep-0218/
|
|
||||||
RedirectTemp /pep227 https://www.python.org/dev/peps/pep-0227/
|
|
||||||
RedirectTemp /pep255 https://www.python.org/dev/peps/pep-0255/
|
|
||||||
RedirectTemp /pep342 https://www.python.org/dev/peps/pep-0342/
|
|
||||||
RedirectTemp /pep343 https://www.python.org/dev/peps/pep-0343/
|
|
||||||
RedirectTemp /pep357 https://www.python.org/dev/peps/pep-0357/
|
|
||||||
RedirectTemp /pep362 https://www.python.org/dev/peps/pep-0362/
|
|
||||||
RedirectTemp /pep371 https://www.python.org/dev/peps/pep-0371/
|
|
||||||
RedirectTemp /pep380 https://www.python.org/dev/peps/pep-0380/
|
|
||||||
RedirectTemp /pep393 https://www.python.org/dev/peps/pep-0393/
|
|
||||||
RedirectTemp /pep412 https://www.python.org/dev/peps/pep-0412/
|
|
||||||
RedirectTemp /pep442 https://www.python.org/dev/peps/pep-0442/
|
|
||||||
RedirectTemp /pep443 https://www.python.org/dev/peps/pep-0443/
|
|
||||||
RedirectTemp /pep448 https://www.python.org/dev/peps/pep-0448/
|
|
||||||
RedirectTemp /pep455 https://www.python.org/dev/peps/pep-0455/
|
|
||||||
RedirectTemp /pep456 https://www.python.org/dev/peps/pep-0456/
|
|
||||||
RedirectTemp /pep461 https://www.python.org/dev/peps/pep-0461/
|
|
||||||
RedirectTemp /pep465 https://www.python.org/dev/peps/pep-0465/
|
|
||||||
RedirectTemp /pep467 https://www.python.org/dev/peps/pep-0467/
|
|
||||||
RedirectTemp /pep482 https://www.python.org/dev/peps/pep-0482/
|
|
||||||
RedirectTemp /pep483 https://www.python.org/dev/peps/pep-0483/
|
|
||||||
RedirectTemp /pep484 https://www.python.org/dev/peps/pep-0484/
|
|
||||||
RedirectTemp /pep487 https://www.python.org/dev/peps/pep-0487/
|
|
||||||
RedirectTemp /pep492 https://www.python.org/dev/peps/pep-0492/
|
|
||||||
RedirectTemp /pep519 https://www.python.org/dev/peps/pep-0519/
|
|
||||||
RedirectTemp /pep525 https://www.python.org/dev/peps/pep-0525/
|
|
||||||
RedirectTemp /pep526 https://www.python.org/dev/peps/pep-0526/
|
|
||||||
RedirectTemp /pep528 https://www.python.org/dev/peps/pep-0528/
|
|
||||||
RedirectTemp /pep529 https://www.python.org/dev/peps/pep-0529/
|
|
||||||
RedirectTemp /pep530 https://www.python.org/dev/peps/pep-0530/
|
|
||||||
RedirectTemp /pep544 https://www.python.org/dev/peps/pep-0544/
|
|
||||||
RedirectTemp /pep554 https://www.python.org/dev/peps/pep-0554/
|
|
||||||
RedirectTemp /pep557 https://www.python.org/dev/peps/pep-0557/
|
|
||||||
RedirectTemp /pep560 https://www.python.org/dev/peps/pep-0560/
|
|
||||||
RedirectTemp /pep561 https://www.python.org/dev/peps/pep-0561/
|
|
||||||
RedirectTemp /pep563 https://www.python.org/dev/peps/pep-0563/
|
|
||||||
RedirectTemp /pep570 https://www.python.org/dev/peps/pep-0570/
|
|
||||||
RedirectTemp /pep572 https://www.python.org/dev/peps/pep-0572/
|
|
||||||
RedirectTemp /pep584 https://www.python.org/dev/peps/pep-0584/
|
|
||||||
RedirectTemp /pep585 https://www.python.org/dev/peps/pep-0585/
|
|
||||||
RedirectTemp /pep586 https://www.python.org/dev/peps/pep-0586/
|
|
||||||
RedirectTemp /pep589 https://www.python.org/dev/peps/pep-0589/
|
|
||||||
RedirectTemp /pep591 https://www.python.org/dev/peps/pep-0591/
|
|
||||||
RedirectTemp /pep593 https://www.python.org/dev/peps/pep-0593/
|
|
||||||
RedirectTemp /pep604 https://www.python.org/dev/peps/pep-0604/
|
|
||||||
RedirectTemp /pep612 https://www.python.org/dev/peps/pep-0612/
|
|
||||||
RedirectTemp /pep613 https://www.python.org/dev/peps/pep-0613/
|
|
||||||
RedirectTemp /pep616 https://www.python.org/dev/peps/pep-0616/
|
|
||||||
RedirectTemp /pep617 https://www.python.org/dev/peps/pep-0617/
|
|
||||||
RedirectTemp /pep618 https://www.python.org/dev/peps/pep-0618/
|
|
||||||
RedirectTemp /pep634 https://www.python.org/dev/peps/pep-0634/
|
|
||||||
RedirectTemp /pep635 https://www.python.org/dev/peps/pep-0635/
|
|
||||||
RedirectTemp /pep636 https://www.python.org/dev/peps/pep-0636/
|
|
||||||
RedirectTemp /pep638 https://www.python.org/dev/peps/pep-0638/
|
|
||||||
RedirectTemp /pep645 https://www.python.org/dev/peps/pep-0645/
|
|
||||||
RedirectTemp /pep646 https://www.python.org/dev/peps/pep-0646/
|
|
||||||
RedirectTemp /pep647 https://www.python.org/dev/peps/pep-0647/
|
|
||||||
RedirectTemp /pep649 https://www.python.org/dev/peps/pep-0649/
|
|
||||||
RedirectTemp /pep654 https://www.python.org/dev/peps/pep-0654/
|
|
||||||
RedirectTemp /pep655 https://www.python.org/dev/peps/pep-0655/
|
|
||||||
RedirectTemp /pep661 https://www.python.org/dev/peps/pep-0661/
|
|
||||||
RedirectTemp /pep3099 https://www.python.org/dev/peps/pep-3099/
|
|
||||||
RedirectTemp /pep3102 https://www.python.org/dev/peps/pep-3102/
|
|
||||||
RedirectTemp /pep3104 https://www.python.org/dev/peps/pep-3104/
|
|
||||||
RedirectTemp /pep3106 https://www.python.org/dev/peps/pep-3106/
|
|
||||||
RedirectTemp /pep3107 https://www.python.org/dev/peps/pep-3107/
|
|
||||||
RedirectTemp /pep3115 https://www.python.org/dev/peps/pep-3115/
|
|
||||||
RedirectTemp /pep3118 https://www.python.org/dev/peps/pep-3118/
|
|
||||||
RedirectTemp /pep3119 https://www.python.org/dev/peps/pep-3119/
|
|
||||||
RedirectTemp /pep3129 https://www.python.org/dev/peps/pep-3129/
|
|
||||||
RedirectTemp /pep3132 https://www.python.org/dev/peps/pep-3132/
|
|
||||||
RedirectTemp /pep3141 https://www.python.org/dev/peps/pep-3141/
|
|
||||||
RedirectTemp /pep3148 https://www.python.org/dev/peps/pep-3148/
|
|
||||||
RedirectTemp /pep3155 https://www.python.org/dev/peps/pep-3155/
|
|
||||||
RedirectTemp /pep3333 https://www.python.org/dev/peps/pep-3333/
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
scp FPY.LI.htaccess dh_i4p2ka@fpy.li:~/fpy.li/.htaccess
|
|
||||||
Reference in New Issue
Block a user