<p>Sponsored by us! Support our work through:</p> <ul> <li>Our <a href="https://training.talkpython.fm/"><strong>courses at Talk Python Training</strong></a></li> <li><a href="https://pragprog.com/titles/bopytest/python-testing-with-pytest/"><strong>pytest book</strong></a></li> <li><a href="https://www.patreon.com/pythonbytes"><strong>Patreon Supporters</strong></a></li> </ul> <p>Special guest: <strong>Jennifer Stark</strong> - <a href="https://twitter.com/_JAStark"><strong>@_JAStark</strong></a> & guest on <a href="https://talkpython.fm/259"><strong>talkpython.fm/259</strong></a></p> <a href='https://www.youtube.com/watch?v=LAdksPSd6ZA' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>Brian #1:</strong> <strong>Do you really need a virtualenv?</strong></p> <ul> <li>Frost Ming doesn’t think so, based on the article <a href="https://frostming.com/2021/01-22/introducing-pdm/"><strong>You don't really need a virtualenv</strong></a></li> <li>The link slug is “introducing-pdm”, which I think would be a better title, but the first did work to get people to talk about it. Also, “Try PEP 582 today” may have been appropriate.</li> <li>Teaching new people is a problem: <ul> <li>Telling them to first type <code>python -m venv venv</code></li> <li>Then type <code>source venv/bin/activate</code> or <code>. venv/bin/activate</code></li> <li>Unless you’re on windows, then type <code>venv\scripts\activate.bat</code></li> <li>Then type <code>pip install -r requirements.txt</code></li> <li>Yeah. It’s not pretty, not fun, and good luck not having anyone ask questions about why this is necessary.</li> </ul></li> <li>Also the Python version is specified in the venv. So if you upgrade Python versions, what happens to existing venvs? </li> <li>The article also discusses levels of venvs, and global tools that maybe you want not tied to each venv. But we have <code>pipx</code> for that, so I don’t think that’s a real issue.</li> <li>Enter <a href="https://www.python.org/dev/peps/pep-0582/">PEP 582</a>, still in draft mode. <ul> <li>Instead of a venv directory, your project has a <code>__pypackage__</code> directory. If you <code>python -m pip install</code> in your project directory, stuff just goes there instead of to the global Python.</li> <li>So it kinda acts like a venv for local packages, it just doesn’t include local copies of the Python executables, and such.</li> <li>This is probably a horrible description of 582, but oh well. Something like that.</li> </ul></li> <li><a href="https://pdm.fming.dev/">pdm</a> supports 582 today <ul> <li>PDM stands for Python Development Master</li> <li>“It installs and manages packages in a similar way to <code>npm</code> that doesn't need to create a virtualenv at all!”</li> <li>Has a workflow that reminds me of Poetry, but doesn’t use a venv, uses a package directory instead.</li> </ul></li> <li>Conclusion: <ul> <li>Huge props to Frost for this. It’s cool to see a tool that supports 582 and glimpse a possible Python future.</li> <li>However, this doesn’t solve the “teaching Python” problem. The setup is more complex than venv.</li> <li>I’m personally sticking with venv, well virtualenv, until (and if) 582 is supported by Python and pip.</li> </ul></li> </ul> <p><strong>Michael #2:</strong> <a href="https://github.com/copier-org/copier"><strong>Copier - like cookiecutter</strong></a></p> <ul> <li>A library for rendering project templates.</li> <li>Works with <strong>local</strong> paths and <strong>git URLs</strong>.</li> <li>Your project can include any file and <code>Copier</code> can dynamically replace values in any kind of text file.</li> <li>It generates a beautiful output and takes care of not overwrite existing files unless instructed to do so.</li> <li>To use as a CLI app: <code>pipx install copier</code></li> <li>To use as a library: <code>pip install copier</code></li> <li>Has a simple Python API</li> <li>Main advantage: Can update existing projects</li> <li>Runs from basic YAML files</li> </ul> <p><strong>Jennifer #3: <a href="https://github.com/nalepae/pandarallel/tree/v1.5.1">Pandarallel - run pandas apply in parallel!</a></strong></p> <ul> <li>simple install `pip install pandarallel [--upgrade] [--user]``</li> <li>import <code>from pandarallel import pandarallel</code></li> <li>initialise <code>pandarallel.initialize()</code>, set progress bar BOOL, set number of workers … (defaults to all cores)</li> <li>just use <code>parallel_apply</code> where you’d usually put <code>apply</code> </li> </ul> <p><strong>Brian #4:</strong> <a href="https://towardsdatascience.com/stop-using-print-to-debug-in-python-use-icecream-instead-79e17b963fcc"><strong>Stop Using Print to Debug in Python. Use icecream Instead</strong></a></p> <ul> <li>Khuyen Tran</li> <li><code>print(f``"``{x=}``"``)</code> is better than <code>print(f``"``x: {x}``"``)</code> but it’s still a lot of typing.</li> <li>With <a href="https://github.com/gruns/icecream">icecream</a>, you can type <code>ic(x)</code> insted and git this nice output: <code>ic| x: 5</code></li> <li>It’s less typing and just as nice. </li> <li>There’s more. <ul> <li><code>ic()</code> with no arguments logs the file, function, line number when it’s hit. Easy program flow tracing without a debugger.</li> <li>You can configure it to do this cool context thing even if you do pass in a value to print.</li> <li>You can configure custom prefix formatting with a callback function, so you can include the time or the user that’s logged in, or whatever else state you want to track.</li> <li>Since all output is prefixed with <code>ic|</code>, you can see it easily</li> <li>Writes to stderr by default, so it doesn’t muck up stdout stuff</li> <li>Clean it out of your code by searching for <code>ic()</code> statements. If you have normal <code>print</code> statements in your code, you don’t want to use <code>print</code> for debugging also.</li> </ul></li> </ul> <p><strong>Michael #5:</strong> <a href="https://htmx.org/"><strong>HTMX: Dynamic and live HTML without JavaScript</strong></a></p> <ul> <li>htmx allows you to access <a href="https://htmx.org/docs#ajax">AJAX</a>, <a href="https://htmx.org/docs#css_transitions">CSS Transitions</a>, <a href="https://htmx.org/docs#websockets">WebSockets</a> and <a href="https://htmx.org/docs#sse">Server Sent Events</a> directly in HTM</li> <li>Best seen <a href="https://htmx.org/examples/"><strong>via the examples section</strong></a> - try some out live on their site</li> <li>Has a cool Server Requests pane for seeing what’s happening in the example</li> </ul> <p><strong>Jennifer #6: <a href="https://pyldavis.readthedocs.io/en/latest/readme.html">PyLDAvis - Interactive Topic Model Visualisation</a></strong> </p> <ul> <li>Port of LDAvis R package (does this mean PyLDAvis is a wrapper? A translation?) by Carson Sievert and Kenny Shirley</li> <li>User calls pyLDAvis with fitted model made with your favourite library (eg Gensim, sklearn, GraphLab)</li> <li>Outputs include: <ul> <li>term frequency within topic bar chart</li> <li>term frequency within whole corpus bar chart</li> <li>next to each bar is a word. You hover over the word and the topic circles adjust size to reflect representation of that term in that topic. </li> <li>topic circles - one for each topic, whose areas are setto be proportional to the proportions of the topics across the N total tokens in the corpus</li> <li>term-topic circles, with area proportional to the frequencies with which a given term is estimated to have been generated by the topics of whole corpus</li> <li>slider to adjust relevance metric (0 = terms very specific to currently selected topic; 1 = terms frequently seen in many topics).</li> </ul></li> </ul> <p>Extras:</p> <p>Brian:</p> <ul> <li>I’m also speaking to a group of NOAA people next week.</li> <li>I’m speaking the <a href="https://ti.to/code-the-city/aberdeen-python-user-group-feb-2021/en">Aberdeen Python User Group</a> on the 10th of Feb. It’s virtual, so everyone can come.</li> <li>Excited about both. My kids are more impressed with the NOAA thing. It’s fun to impress your kids.</li> </ul> <p>Michael: </p> <ul> <li>Jet Brain’s fifth annual <a href="https://blog.jetbrains.com/blog/2021/01/27/take-part-in-the-developer-ecosystem-2021-survey/"><strong>Developer Ecosystem survey</strong></a></li> </ul> <p>Joke:</p> <p><strong>Engineer helping a designer</strong></p> <p><img src="https://ift.tt/3jhFw4g" alt="" /></p> <p><a href="https://twitter.com/EduardoOrochena/status/1306944019268861953">https://twitter.com/EduardoOrochena/status/1306944019268861953</a></p>
from Planet Python
via read more
Subscribe to:
Post Comments (Atom)
TestDriven.io: Working with Static and Media Files in Django
This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...
-
Podcasts are a great way to immerse yourself in an industry, especially when it comes to data science. The field moves extremely quickly, an...
-
Graph traversal algorithms are used to perform various operations on a graph data structure. In this article, we will use the breadth-first ...
-
In an earlier tutorial we've already covered how to open dialog windows. These are special windows which (by default) grab the focus o...
No comments:
Post a Comment