Saturday, July 4, 2020

Python Bytes: #188 Will there be a "switch" in Python the language?

<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://t.co/AKfVKcveg6?amp=1"><strong>Brian’s pytest book</strong></a></li> </ul> <p><strong>Michael #1:</strong> <a href="https://medium.com/@MattGosden/tutorial-using-pythons-unsync-library-to-make-an-asynchronous-trading-bot-9ee2ae881272"><strong>Making a trading bot asynchronous using Python’s “unsync” library</strong></a></p> <ul> <li>by <a href="https://twitter.com/MattGosden/status/1272222637851377666">Matt Gosden</a></li> <li><strong>The older way</strong> — using the <strong>threading</strong> and <strong>multiprocessing</strong> libraries</li> <li><strong>The newer way</strong> — using <code>async</code> and <code>await</code> from the <strong>asyncio</strong> library embedded into core Python from 3.7 onwards</li> <li><strong>The easier way (I think)</strong>— using the <code>@unsync</code> decorator from the Python <strong>unsync</strong> library</li> <li>Somewhat realistic example worth looking at.</li> <li>Could discuss scalability more</li> <li>Also, proper def async and asyncio.sleep() for those playing at home</li> <li>But its absence kind shows unsync winning anyway. 🙂 It does work, right?</li> </ul> <p><strong>Brian #2:</strong> <strong><em>*<a href="https://fberriman.com/2020/01/22/fruit-salad-a-scrum-estimation-scale/"></strong>Fruit salad scrum estimation scale</em>*</a></p> <ul> <li>From twitter question by Lacy Henschel, answered by Kathleen Jones</li> <li>Fruit related to work <ul> <li>how easy</li> <li>potential for mess </li> <li>how many seeds, possible problems</li> <li>does it need divided</li> </ul></li> <li>The scale <ul> <li>1 - grape - trivial</li> <li>2 - apple - may take a bit of time but everyone knows how to divide it</li> <li>3 - cherry - easy but with some unknowns (what do you do with the pit?)</li> <li>5 - pineapple - somewhat undefined, no major unknowns, still a lot of work (lots of opinions on how to cut it)</li> <li>8 - watermelon - lots of work, some unknowns, messy (don’t know what you are getting into until you cut it open)</li> <li>?? - tomato - unknown task, needs more info before estimating (doesn’t belong in a fruit salad)</li> <li>?? - avacado - not scopable, probably urgent (goes bad quickly)</li> </ul></li> </ul> <p><strong>Michael #3:</strong> <a href="https://mathtocode.com/"><strong>Math to Code</strong></a></p> <ul> <li><strong>Math to Code</strong> is an interactive Python tutorial to teach engineers how to read and implement math using the NumPy library.</li> <li>by <a href="https://thommeret.com/">vernon thommeret</a></li> <li>Nice flashcard style of learning the building blocks of np for standard math</li> <li>Give it a try, solutions if you get stuck</li> <li>Python and NP together</li> <li><a href="https://github.com/vthommeret/mathtocode">Source at github</a></li> <li>Interesting building blocks</li> <li><a href="https://github.com/skulpt/skulpt">Skulpt</a> for interpreting Python</li> <li><a href="https://github.com/ebertmi/skulpt_numpy">Skulpt NumPy</a> for a subset of NumPy</li> <li><a href="https://github.com/KaTeX/KaTeX">KaTex</a> for rendering LaTeX</li> <li><a href="https://github.com/vercel/next.js">Next.js</a> for frontend framework</li> <li><a href="https://github.com/tailwindcss/tailwindcss">Tailwind CSS</a> for styling</li> <li><a href="https://github.com/remarkjs/remark">remark</a> for rendering Markdown questions</li> <li><a href="https://github.com/jonschlinkert/gray-matter">gray-matter</a> for extracting Markdown frontmatter</li> <li><a href="https://realfavicongenerator.net/">RealFavIconGenerator</a> for generating favicons</li> </ul> <p><strong>Brian #4:</strong> <a href="https://www.python.org/dev/peps/pep-0622/"><strong>PEP 622 -- Structural Pattern Matching</strong></a></p> <ul> <li>Draft status, targeted for Python 3.10</li> <li>Syntax looks similar to switch/case statement, even though two switch PEPs were rejected earlier</li> <li>Designed not only to optimize if/elif/else statements but also to focus on sequence, mapping, and object destructuring. </li> <li>match/case statement with many allowed patterns: <ul> <li>literal pattern: would then act similar to a switch/case statement</li> <li>name pattern: assigns expression to new variable if previous case doesn’t succeed</li> <li>constant value pattern: enums, similar to literal</li> <li>sequence pattern: works like unpacking assignment</li> <li>mapping pattern: like sequence unpacking, but for mappings, like dictionaries</li> <li>class pattern: create objects for each case and call <code>__match__()</code></li> <li>combining patterns: <code>|</code> for multiple patterns. including binding patterns like name</li> <li>guards: <code>if expression</code> to further clarify a case</li> <li>named sub-patterns: ok. still getting my head around this</li> </ul></li> </ul> <p><strong>Michael #5:</strong> <a href="https://aws.amazon.com/about-aws/whats-new/2020/06/introducing-aws-codeartifact-a-fully-managed-software-artifact-repository-service/"><strong>CodeArtifact from AWS</strong></a></p> <ul> <li>via Tormod Macleod</li> <li>AWS CodeArtifact is a fully managed software artifact repository service that makes it easy for organizations of any size to securely store, publish, and share packages used in their software development process</li> <li>AWS CodeArtifact works with commonly used package managers and build tools such as Maven and Gradle (Java), npm and yarn (JavaScript), pip and twine (Python), making it easy to integrate CodeArtifact into your existing development workflows.</li> <li>Can be configured to automatically fetch software packages from public artifact repositories such as npm public registry, Maven Central, and Python Package Index (PyPI), ensuring teams have reliable access to the most up-to-date packages.</li> </ul> <p><strong>Brian #6:</strong> <a href="https://www.pyinvoke.org/"><strong>invoke</strong></a></p> <ul> <li>suggested by Joreg Benesch</li> <li>replacement for Makefiles</li> <li>Confusion: <ul> <li>documentation is at <a href="http://pyinvoke.org">pyinvoke.org</a></li> <li>install with <code>pip install invoke</code></li> <li>there’s also another pypi package, called <code>pyinvoke</code>, which is NOT what we are talking about.</li> </ul></li> <li>invoke: <ul> <li>task execution library</li> <li>Write <code>tasks.py</code> files in Python for Makefile like things</li> <li>tasks are Python functions decorated with <code>@task</code>, like</li> </ul></li> </ul> <p>``<code> @task def build(c, clean=False): if clean: print("Cleaning!") print("Building!") - invoke tasks with</code>invoke<code> $ invoke build -c $ invoke build --clean - you can - run shell commands with</code>c.run()` - declare pre-tasks, tasks that need to run before this one. like “build” requires “clean”, etc. - namespaces with multiple files - tool intended for building documentation, but could probably run lots of stuff with it, like deployment, testing, etc.</p> <p>Extras:</p> <p>Brian:</p> <ul> <li><p>Michael:</p></li> <li><p><a href="https://twitter.com/gvanrossum/status/1270487300099551232">From Guido</a>: Python 3.9.0 beta 3 is out now, for your immediate testing. Wait, what happened to beta 2? Interesting story. </p></li> <li>The next pre-release, the fourth beta release of Python 3.9, will be 3.9.0b4. It is currently scheduled for 2020-06-29.</li> </ul> <p>Joke:</p> <ul> <li><a href="http://geek-and-poke.com/geekandpoke/2012/11/28/parenting-a-geek.html"><strong>Parenting a geek</strong></a> <img src="https://ift.tt/2Buu3Ng" alt="" /></li> </ul>

from Planet Python
via read more

No comments:

Post a Comment

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...