Planet Python

Subscribe to Planet Python feed
Planet Python - http://planetpython.org/
Updated: 22 hours 24 min ago

Real Python: The Real Python Podcast – Episode #196: Exploring Duck Typing in Python & Dynamics of Monkey Patching

Fri, 2024-03-15 08:00

What are the advantages of determining the type of an object by how it behaves? What coding circumstances are not a good fit for duck typing? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder's Weekly articles and projects.

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

PyCharm: Pytest vs. Unittest: Which Is Better?

Fri, 2024-03-15 06:47
Python, being a versatile and widely used programming language, offers several testing frameworks to facilitate the testing process. Two prominent choices are pytest and unittest, both of which come with their own sets of features and advantages. In this article, we’ll be covering the following sections: This will help you determine which testing framework is […]
Categories: FLOSS Project Planets

Paolo Melchiorre: Pybites Podcast #155

Thu, 2024-03-14 19:00

Episode 155 of Pybites podcast with the title “Django, Open Source & Pycon Conferences, Paolo Melchiorre’s Developer Odyssey”

Categories: FLOSS Project Planets

Python Does What?!: Wisdom for the ages

Thu, 2024-03-14 18:09
>>>type(type) is type True
Categories: FLOSS Project Planets

Peter Bengtsson: Leibniz formula for π in Python, JavaScript, and Ruby

Thu, 2024-03-14 16:24
Different ways to calculate the value of π using the Leibniz formula
Categories: FLOSS Project Planets

Mike Driscoll: Python 3.13 Allows Disabling of the GIL + subinterpreters

Thu, 2024-03-14 14:53

Python 3.13 adds the ability to remove the Global Interpreter Lock (GIL) per PEP 703. Just this past week, a PR was merged in that allows the disabling of the GIL using a command line flag or an environment variable in free-threaded builds. Note that Python must be built using the Py_GIL_DISABLED flag for this to work.

What is the GIL?

The Global Interpreter Lock makes threading easier in Python and prevents race conditions. It also makes running multiple threads per CPU core impossible. However, you can use the multiprocessing module to at least give you the ability to better utilize the cores on your CPU.

Removing the GIL

Removing the GIL will likely make Python buggy initially, so they are making the GIL-less version a build flag. That means that the GIL will still be on by default in Python 3.13 while they test the GIL-less version and find all the bugs the change causes. Hopefully, by 3.14 or so, they will know all the bugs and have them fixed to some degree or another.

Subinterpreters Are Coming

A related enhancement are subinterpreters, which Eric Snow has worked on for quite some time. PEP 554 and PEP 734 cover what subinterpreters are and how they are being exposed so you can use them.

Here’s the abstract from PEP 734 to give you an idea of what they are:

This PEP proposes to add a new module, interpreters, to support inspecting, creating, and running code in multiple interpreters in the current process. This includes Interpreter objects that represent the underlying interpreters. The module will also provide a basic Queue class for communication between interpreters. Finally, we will add a new concurrent.futures.InterpreterPoolExecutor based on the interpreters module.

Both of these enhancements have lots of potential for making Python code faster, more efficient, or both. Peter Sobot announced he tried out the GIL removal flag for the pedalboard package and got a 17x speed up for certain processes.

The post Python 3.13 Allows Disabling of the GIL + subinterpreters appeared first on Mouse Vs Python.

Categories: FLOSS Project Planets

Python Does What?!: sequence unpack a dict

Thu, 2024-03-14 08:45
>>> a, b = {"a": 1, "b": 2} >>> a 'a'
Categories: FLOSS Project Planets

Programiz: Python Program to Convert Bytes to a String

Thu, 2024-03-14 07:22
In this example, you will learn to convert bytes to a string.
Categories: FLOSS Project Planets

Programiz: Python Program to Count the Number of Occurrence of a Character in String

Thu, 2024-03-14 07:21
In this example, you will learn to count the number of occurrences of a character in a string.
Categories: FLOSS Project Planets

Programiz: Python Program to Check If Two Strings are Anagram

Thu, 2024-03-14 07:19
In this example, you will learn to check if two strings are anagram.
Categories: FLOSS Project Planets

Programiz: Python Program to Count the Number of Digits Present In a Number

Thu, 2024-03-14 07:19
In this example, you will learn to count the number of digits present in a number.
Categories: FLOSS Project Planets

Mike Driscoll: NEW COURSE: Python 101 Video Course on Udemy and TutorialsPoint

Wed, 2024-03-13 23:45

I recently put my Python 101 Video Course up on Udemy and TutorialsPoint.

There are one thousand free copies of the course available on Udemy by using the following link:

If you prefer TutorialsPoint, you can get a free copy here:

The Python 101 video course is also available on TeachMePython and my Gumroad store.

I am slowly adding quizzes to the Udemy version of the course and plan to add the same or similar quizzes on TeachMePython. Unfortunately, TutorialsPoint doesn’t support quizzes in the same way as they use a video quiz format, so that site won’t have any quizzes.

The post NEW COURSE: Python 101 Video Course on Udemy and TutorialsPoint appeared first on Mouse Vs Python.

Categories: FLOSS Project Planets

Spyder IDE: Reusable research Birds of a Feather session at Scipy 2023: Solutions and tools

Wed, 2024-03-13 22:30

The Spyder team and collaborators hosted a Birds of a Feather (BoF) session at SciPy 2023, focused on moving beyond just scripts and notebooks toward truly reproducible, reusable research. In Part 1 of this two-part series, we went over our motivation and goals for the session and the challenges that attendees brought up. Now, we’ll review the tips, strategies, tools and platforms (including Spyder!) that participants shared as ways to address these obstacles. We'd again like to thank Juanita Gomez for helping organize the BoF, Hari for his hard work compiling a summary of the outcomes, and everyone for attending and sharing such great ideas and insights!

Making notebooks more reusable

As far as reproducibility is concerned, it was brought up that it can be difficult to easily compare outputs between notebooks created by different researchers. In response, one participant mentioned that VSCode recently made an improvement to the notebook diff viewers to more easily show just the code changes. However, users stressed that it was critical to be able to diff the actual notebook output, not just its contents, and expressed a desire for a tool to cover that aspect.

In response to these concerns, others responded that notebooks should not be considered a unit of reproducible research, which should instead be a complete software project, including notebooks or scripts, an environment/requirements file and a record of commands to run there. They recommended the 8-levels of Reproducibility and Conda Project to help guide and implement this.

Additionally, attendees recommended Papermill, describing it as a very useful tool for parameterizing and executing notebooks programmatically. Others suggested Devcontainers, to allow collaborating with a lab group or team in a shared environment and seeing everything on their screen, as well as Live Share in VSCode.

Participants also expressed frustration that despite notebooks being intended to make programming more literate, this often does not happen in practice. Beginners like the interactivity in notebooks because they don't know how to use more advanced programming tools, but they don't always take advantage of their readability features. To address this, attendees stressed the importance of getting users accustomed to best practices that can also be helpful for reproducibility. A participant mentioned a nbflake8 tool to lint notebooks, though it could not be easily found online, and others wished for a Ruff implementation (which at the time of this writing is now complete).

Migrating notebooks to modules

As one participant put it, "I love notebooks, and also love modules, and love the flow of code from notebooks into modules once it approaches that point." They went on to describe modules as a key unit of documented, tested code, but which doesn't mean a lot on its own, whereas combined with a notebook, it gives them context and meaning. For communities that may be afraid of modules, the participant recommended trying to make creating and transitioning to them easier, so users have fully importable, reusable Python code. For students, notebooks often turn into a fancy scratch pad or script file, and once they get stuff that works, they can move that stuff out into modules, and then the notebooks start to morph into examples and the history of what the work was about that can be interpreted by other researchers.

Other attendees chimed in with similar stories, with a NIST researcher mentioning this is an area they'd been working on for 10 years, with their approach being putting the stuff they want to be modular in a regular Python module, and then have a Jupyter notebook that shows an example using the code, such as in their IPRPy project. To aid this process, participants suggested tools like the Autodocstring extension in VSCode and the docstring generator built into Spyder's editor as great ways to reduce the friction for students when writing documentation, as they just add the triple quotes and the IDE generates a pre-filled docstring for them.

An important reproducibility and reusability tool many cited for this was nbdev, which can allow users to develop their code and let it grow, and then eventually export the parts as modules at the end. According to attendees, its documentation mostly talks about everything as packages, but it can also be used for individual notebooks and modules. Some participants were initially hesitant to show it to their students since they're early Python programmers, but it was actually quite easy for them, only requiring as little as one line of code at the end. (Unfortunately as of this writing, it seems ndbdev development has stalled due to its expected commercial opportunities not materializing.) Others asked for more documentation resources for this, since they were still learning Python themselves and would like to learn more about this and teach it to their students. In addition to this very blog post and guide, one attendee brought up that they did a tutorial on that topic at SciPy, adding that the documentation is pretty intimidating but it would be great to have something more focused on smaller-scale usage.

As additional approaches, attendees mentioned they have their students use Jupytext, which helps the student to convert notebooks to Python files that can be committed to a Git repository. This allows the code to be committed as a Python file, while allowing Jupyter to open it as a notebook and continue working on it. Others brought up nb-convert, a command line tool that can convert notebooks to many different formats including a Python script, which is integrated into IDEs like Spyder, and that there is also a similar VSCode feature.

Enabling reusable Python packages

When it comes to overall workflow, all agreed that going from a script or notebook to a reusable, installable Python package could be a major challenge, especially for students and non-programmers. Attendees from NASA mentioned that for their projects everything has to be documented, and one of the things they've struggled with was converting a notebook to the type of report NASA is typically looking for. Others described their workflow being as simple and "old school" as writing a aaa_readme.txt file where they record a diary of what they were doing on that project so if they have a break working on it, they can go back to those notes and remind themselves.

To help address this, participants recommended a "really cool" tool called "Show Your Work" that comes out of the astrophysics community, which is primarily aimed at producing a paper at the end but also a Python package, and includes all the steps that show users' work along the way. It is built around a tool called Snakemake, which then sets up a template for both the Python package and the paper. Additionally, attendees described it as having a "really helpful" guide for getting started and ensuring all of a user's projects have the same structure. It was brought up that Azel Donath, maintainer of Gammapy and speaker at SciPy 2023, published their Gammapy paper by using this tool.

As a followup, participants asked how this differed from Quarto, to which the response was that Quarto is much more general, whereas Show Your Work was specifically built to allow users to produce a PDF in LaTeX at the end. Others mentioned Duecredit, a related tool for citing open source authors which looks at code and finds the authors (via Git commits) that wrote it.

Additionally, users expressed particular appreciation for the Cookiecutter template that Henry Schreiner III has for packaging. They mentioned that a lot of their workflows are just messing around with their data, and having something like a package structure from the get go helps make it easier to not miss things. As a followup, a nuclear engineer mentioned they often have two week projects leveraging Jupyter at their center, with a cookiecutter template that has Sphinx, and a directory structure, and metadata that looks familiar and has everything set up by default. They described how this particularly helps ensure that different colleagues and team members are on the same page with doing things. Finally, others suggested the data-driven Cookiecutter template, which provides an ordered structure for where things go, what they are named and how they are run.

Next steps

Now that we’ve gathered a wealth of community feedback, ideas and resources, we’re currently working to further translate these insights into an actionable guide (or series of such) on a community platform, to make it easier for everyone to apply them. Keep an eye out for that, and until then, happy Spydering!

Categories: FLOSS Project Planets

Wingware: Wing Python IDE Version 10.0.3 - March 15, 2024

Wed, 2024-03-13 21:00

Wing 10.0.3 adds more control over AI request context, improves keyboard navigability on Windows, fixes folding failures seen in Python files, avoids failure to show debug process output in Debug I/O, improves Diff/Merge for directories and files, fixes hanging while examining some types of debug data, solves several problems with setting up Poetry projects on Windows, and makes about 20 other improvements.

See the change log for details.

Download Wing 10 Now: Wing Pro | Wing Personal | Wing 101 | Compare Products


What's New in Wing 10

AI Assisted Development

Wing Pro 10 takes advantage of recent advances in the capabilities of generative AI to provide powerful AI assisted development, including AI code suggestion, AI driven code refactoring, description-driven development, and AI chat. You can ask Wing to use AI to (1) implement missing code at the current input position, (2) refactor, enhance, or extend existing code by describing the changes that you want to make, (3) write new code from a description of its functionality and design, or (4) chat in order to work through understanding and making changes to code.

Examples of requests you can make include:

"Add a docstring to this method" "Create unit tests for class SearchEngine" "Add a phone number field to the Person class" "Clean up this code" "Convert this into a Python generator" "Create an RPC server that exposes all the public methods in class BuildingManager" "Change this method to wait asynchronously for data and return the result with a callback" "Rewrite this threaded code to instead run asynchronously"

Yes, really!

Your role changes to one of directing an intelligent assistant capable of completing a wide range of programming tasks in relatively short periods of time. Instead of typing out code by hand every step of the way, you are essentially directing someone else to work through the details of manageable steps in the software development process.

Read More

Support for Python 3.12

Wing 10 adds support for Python 3.12, including (1) faster debugging with PEP 669 low impact monitoring API, (2) PEP 695 parameterized classes, functions and methods, (3) PEP 695 type statements, and (4) PEP 701 style f-strings.

Poetry Package Management

Wing Pro 10 adds support for Poetry package management in the New Project dialog and the Packages tool in the Tools menu. Poetry is an easy-to-use cross-platform dependency and package manager for Python, similar to pipenv.

Ruff Code Warnings & Reformatting

Wing Pro 10 adds support for Ruff as an external code checker in the Code Warnings tool, accessed from the Tools menu. Ruff can also be used as a code reformatter in the Source > Reformatting menu group. Ruff is an incredibly fast Python code checker that can replace or supplement flake8, pylint, pep8, and mypy.


Try Wing 10 Now!

Wing 10 is a ground-breaking new release in Wingware's Python IDE product line. Find out how Wing 10 can turbocharge your Python development by trying it today.

Downloads: Wing Pro | Wing Personal | Wing 101 | Compare Products

See Upgrading for details on upgrading from Wing 9 and earlier, and Migrating from Older Versions for a list of compatibility notes.

Categories: FLOSS Project Planets

Real Python: Visualizing Data in Python With Seaborn

Wed, 2024-03-13 10:00

If you have some experience using Python for data analysis, chances are you’ve produced some data plots to explain your analysis to other people. Most likely you’ll have used a library such as Matplotlib to produce these. If you want to take your statistical visualizations to the next level, you should master the Python seaborn library to produce impressive statistical analysis plots that will display your data.

In this tutorial, you’ll learn how to:

  • Make an informed judgment as to whether or not seaborn meets your data visualization needs
  • Understand the principles of seaborn’s classic Python functional interface
  • Understand the principles of seaborn’s more contemporary Python objects interface
  • Create Python plots using seaborn’s functions
  • Create Python plots using seaborn’s objects

Before you start, you should familiarize yourself with the Jupyter Notebook data analysis tool available in JupyterLab. Although you can follow along with this seaborn tutorial using your favorite Python environment, Jupyter Notebook is preferred. You might also like to learn how a pandas DataFrame stores its data. Knowing the difference between a pandas DataFrame and Series will also prove useful.

So now it’s time for you to dive right in and learn how to use seaborn to produce your Python plots.

Free Bonus: Click here to download the free code that you can experiment with in Python seaborn.

Getting Started With Python seaborn

Before you use seaborn, you must install it. Open a Jupyter Notebook and type !python -m pip install seaborn into a new code cell. When you run the cell, seaborn will install. If you’re working at the command line, use the same command, only without the exclamation point (!). Once seaborn is installed, Matplotlib, pandas, and NumPy will also be available. This is handy because sometimes you need them to enhance your Python seaborn plots.

Before you can create a plot, you do, of course, need data. Later, you’ll create several plots using different publicly available datasets containing real-world data. To begin with, you’ll work with some sample data provided for you by the creators of seaborn. More specifically, you’ll work with their tips dataset. This dataset contains data about each tip that a particular restaurant waiter received over a few months.

Creating a Bar Plot With seaborn

Suppose you wanted to see a bar plot showing the average amount of tips received by the waiter each day. You could write some Python seaborn code to do this:

Python In [1]: import matplotlib.pyplot as plt ...: import seaborn as sns ...: ...: tips = sns.load_dataset("tips") ...: ...: ( ...: sns.barplot( ...: data=tips, x="day", y="tip", ...: estimator="mean", errorbar=None, ...: ) ...: .set(title="Daily Tips ($)") ...: ) ...: ...: plt.show() Copied!

First, you import seaborn into your Python code. By convention, you import it as sns. Although you can use any alias you like, sns is a nod to the fictional character the library was named after.

To work with data in seaborn, you usually load it into a pandas DataFrame, although other data structures can also be used. The usual way of loading data is to use the pandas read_csv() function to read data from a file on disk. You’ll see how to do this later.

To begin with, because you’re working with one of the seaborn sample datasets, seaborn allows you online access to these using its load_dataset() function. You can see a list of the freely available files on their GitHub repository. To obtain the one you want, all you need to do is pass load_dataset() a string telling it the name of the file containing the dataset you’re interested in, and it’ll be loaded into a pandas DataFrame for you to use.

The actual bar plot is created using seaborn’s barplot() function. You’ll learn more about the different plotting functions later, but for now, you’ve specified data=tips as the DataFrame you wish to use and also told the function to plot the day and tip columns from it. These contain the day the tip was received and the tip amount, respectively.

The important point you should notice here is that the seaborn barplot() function, like all seaborn plotting functions, can understand pandas DataFrames instinctively. To specify a column of data for them to use, you pass its column name as a string. There’s no need to write pandas code to identify each Series to be plotted.

The estimator="mean" parameter tells seaborn to plot the mean y values for each category of x. This means your plot will show the average tip for each day. You can quickly customize this to instead use common statistical functions such as sum, max, min, and median, but estimator="mean" is the default. The plot will also show error bars by default. By setting errorbar=None, you can suppress them.

The barplot() function will produce a plot using the parameters you pass to it, and it’ll label each axis using the column name of the data that you want to see. Once barplot() is finished, it returns a matplotlib Axes object containing the plot. To give the plot a title, you need to call the Axes object’s .set() method and pass it the title you want. Notice that this was all done from within seaborn directly, and not Matplotlib.

Note: You may be wondering why the barplot() function is encapsulated within a pair of parentheses (...). This is a coding style often used in seaborn code because it frequently uses method chaining. These extra brackets allow you to horizontally align method calls, starting each with its dot notation. Alternatively, you could use the backslash (\) for line continuation, although that is discouraged.

If you take another look at the code, the alignment of .set() is only possible because of these extra encasing brackets. You’ll see this coding style used throughout this tutorial, as well as when you read the seaborn documentation.

In some environments like IPython and PyCharm, you may need to use Matplotlib’s show() function to display your plot, meaning you must import Matplotlib into Python as well. If you’re using a Jupyter notebook, then using plt.show() isn’t necessary, but using it removes some unwanted text above your plot. Placing a semicolon (;) at the end of barplot() will also do this for you.

When you run the code, the resulting plot will look like this:

As you can see, the waiter’s daily average tips rise slightly on the weekends. It looks as though people tip more when they’re relaxed.

Note: One thing you should be aware of is that load_dataset(), unlike read_csv(), will automatically convert string columns into the pandas Categorical data type for you. You use this where your data contains a limited, fixed number of possible values. In this case, the day column of data will be treated as a Categorical data type containing the days of the week. You can see this by using tips["day"] to view the column:

Python In [2]: tips["day"] Out[2]: 0 Sun 1 Sun 2 Sun 3 Sun 4 Sun ... 239 Sat 240 Sat 241 Sat 242 Sat 243 Thur Name: day, Length: 244, dtype: category Categories (4, object): ['Thur', 'Fri', 'Sat', 'Sun'] Copied!

As you can see, your day column has a data type of category. Note, also, that while your original data starts with Sun, the first entry in the category is Thur. In creating the category, the days have been interpreted for you in the correct order. The read_csv() function doesn’t do this.

Read the full article at https://realpython.com/python-seaborn/ »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Talk Python to Me: #453: uv - The Next Evolution in Python Packages?

Wed, 2024-03-13 04:00
Have you ever been wait around for pip to do its thing while installing packages or syncing a virtual environment or through some higher level tool such as pip-tools? Then you'll be very excited to hear about the tool just announced from Astral called uv. It's like pip, but 100x faster. Charlie Marsh from Ruff fame and founder of Astral is here to dive in. Let's go.<br/> <br/> <strong>Episode sponsors</strong><br/> <br/> <a href='https://talkpython.fm/neo4j-notes'>Neo4j</a><br> <a href='https://talkpython.fm/training'>Talk Python Courses</a><br/> <br/> <strong>Links from the show</strong><br/> <br/> <div><b>Charlie Marsh on Twitter</b>: <a href="https://twitter.com/charliermarsh" target="_blank" rel="noopener">@charliermarsh</a><br/> <b>Charlie Marsh on Mastodon</b>: <a href="https://hachyderm.io/@charliermarsh" target="_blank" rel="noopener">@charliermarsh</a><br/> <b>Astral</b>: <a href="https://astral.sh" target="_blank" rel="noopener">astral.sh</a><br/> <b>uv</b>: <a href="https://github.com/astral-sh/uv" target="_blank" rel="noopener">github.com</a><br/> <b>Ruff</b>: <a href="https://github.com/astral-sh/ruff" target="_blank" rel="noopener">github.com</a><br/> <b>Ruff Rules</b>: <a href="https://docs.astral.sh/ruff/rules/" target="_blank" rel="noopener">docs.astral.sh</a><br/> <b>When "Everything" Becomes Too Much: The npm Package Chaos of 2024</b>: <a href="https://socket.dev/blog/when-everything-becomes-too-much" target="_blank" rel="noopener">socket.dev</a><br/> <br/> <b>Talk Python's free Audio AI Course</b>: <a href="https://training.talkpython.fm/courses/build-an-audio-ai-app-with-python-and-assemblyai?ref=talkpython" target="_blank" rel="noopener">training.talkpython.fm</a><br/> <b>Watch this episode on YouTube</b>: <a href="https://www.youtube.com/watch?v=g5RWwvzfs0I" target="_blank" rel="noopener">youtube.com</a><br/> <b>Episode transcripts</b>: <a href="https://talkpython.fm/episodes/transcript/453/uv-the-next-evolution-in-python-packages" target="_blank" rel="noopener">talkpython.fm</a><br/> <br/> <b>--- Stay in touch with us ---</b><br/> <b>Subscribe to us on YouTube</b>: <a href="https://talkpython.fm/youtube" target="_blank" rel="noopener">youtube.com</a><br/> <b>Follow Talk Python on Mastodon</b>: <a href="https://fosstodon.org/web/@talkpython" target="_blank" rel="noopener"><i class="fa-brands fa-mastodon"></i>talkpython</a><br/> <b>Follow Michael on Mastodon</b>: <a href="https://fosstodon.org/web/@mkennedy" target="_blank" rel="noopener"><i class="fa-brands fa-mastodon"></i>mkennedy</a><br/></div>
Categories: FLOSS Project Planets

Python Insider: Python 3.13.0 alpha 5 is now available

Tue, 2024-03-12 16:01

 

Python 3.13.0 alpha 5 is now available:

https://www.python.org/downloads/release/python-3130a5/

This is an early developer preview of Python 3.13

Major new features of the 3.13 series, compared to 3.12

Python 3.13 is still in development. This release, 3.13.0a5, is the fifth of six planned alpha releases.

Alpha releases are intended to make it easier to test the current state of new features and bug fixes and to test the release process.

During the alpha phase, features may be added up until the start of the beta phase (2024-05-07) and, if necessary, may be modified or deleted up until the release candidate phase (2024-07-30). Please keep in mind that this is a preview release and its use is not recommended for production environments.

Many new features for Python 3.13 are still being planned and written. Work continues apace on both the work to remove the Global Interpeter Lock , and to improve Python performance. The most notable changes so far:

(Hey, fellow core developer, if a feature you find important is missing from this list, let Thomas know.)

The next pre-release of Python 3.13 will be 3.13.0a6, currently scheduled for 2024-04-09.

 More resources  Enjoy the new releases

Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation.

Regards from wet and chilly Amsterdam,

Your release team,
Thomas Wouters
Ned Deily
Steve Dower
Łukasz Langa
Categories: FLOSS Project Planets

PyCoder’s Weekly: Issue #620 (March 12, 2024)

Tue, 2024-03-12 15:30

#620 – MARCH 12, 2024
View in Browser »

Creating Asynchronous Tasks With Celery and Django

In this video course, you’ll learn how to integrate Celery and Django using Redis as a message broker. You’ll refactor the synchronous email sending functionality of an existing Django app into an asynchronous task that you’ll run with Celery instead.
REAL PYTHON course

Understanding Context Manager and Its Syntactic Sugar

The Context Manager is gets used for all kind of interesting things around blocks of code. This article gives a background about the origins of the context manager, which problem it solves and how to use it.
BJÖRN RICKS • Shared by Björn Ricks

🚀 Sentry Launch Week: Making Debugging Fun

If you’ve ever been curious about Sentry or application performance monitoring, Launch Week is for you. Tune in from March 18-22 to get the scoop on new products, new features, and a bunch of other cool stuff. You can get a sneak peek (and win free swag) if you RSVP. It’s a win-win →
SENTRY sponsor

The Ultimate Guide to Data Wrangling With Python

This comprehensive user guide equips you with the skills required to use Python Polars Data Frames effectively for financial and supply chain data science analytics.
AMIT SHUKLA • Shared by Amit Shukla

GIL Disable Added to Main Branch of Python Project

GITHUB

Django Security Releases Issued: 5.0.3, 4.2.11, and 3.2.25

DJANGO SOFTWARE FOUNDATION

PyCon US 2024 Talk Schedule Announced

PYCON US

Articles & Tutorials Building a Healthy Developer Mindset While Learning Python

How do you get yourself unstuck when facing a programming problem? How do you develop a positive developer mindset while learning Python? This week on the show, Bob Belderbos from Pybites is here to talk about learning Python and building healthy developer habits.
REAL PYTHON podcast

Asyncio Patterns in Python

This post talks about how to go from a slow, synchronous process, to a highly concurrent and lightning fast asyncio process. This article starts from the problem in it’s most basic form and incrementally shows you how to move towards concurrency with Asyncio in Python.
SKYLER LEWIS • Shared by CHernandez

Master Python: 250 Actionable Tips Await You

Elevate your Python skills with our FREE ebook containing 250 Bulletproof Python Tips. Ideal for developers eager to refine their coding prowess with practical, instantly applicable advice. Transform your Python code and join a thriving community of Python enthusiasts today →
PYBITES sponsor

Tag-Based Python CI/CD Pipeline

This article walks you through setting up a CI/CD pipeline using Github Actions for Python projects, that trigger on git tag pushes. It also includes a way of handling CI pipeline errors for any point of failure.
DHRUV AHUJA • Shared by Dhruv Ahuja

Python’s __all__: Packages, Modules, and Wildcard Imports

In this tutorial, you’ll learn about wildcard imports and the __all__ variable in Python. With __all__, you can prepare your packages and modules for wildcard imports, which are a quick way to import everything.
REAL PYTHON

Don’t Mock Machine Learning Models in Unit Tests

How you unit test machine learning code differs from typical software practices and simply using mock often doesn’t cut it. This post covers alternative ways of testing your ML software.
EUGENE YAN

Styling Excel Cells With OpenPyXL and Python

Many Python libraries that deal with Excel only handle data, but OpenPyXL gives you the ability to style your cells in many different ways. Learn how to give your spreadsheets pizazz!
MIKE DRISCOLL

Neat Parallel Output in Python

Max adapts some StackOverflow code to handle multiple output streams in parallel, giving you a quick way to handle the output from concurrent processes at the same time.
MAX BERNSTEIN

Python Deque Tutorial With 7 Example Use Cases

This tutorial teaches the mechanics of the data structure collections.deque, using seven example use cases where deque simplifies the implementation of a function.
RODRIGO GIRÃO SERRÃO • Shared by Rodrigo Girão Serrão

Improving Django Testing With Seed Database

A seed database is one with initial data for your project. They can be useful when testing and in CI/CD pipelines. This article shows you how to create them in Django.
KARL FREDRIK HAUGHLAND

Datetimes With Timezones in Python

The article shows examples of using timezones with datetime objects, using the zoneinfo module added in the standard library in Python 3.9.
MARKKU LEINIÖ • Shared by Markku Leiniö

Speed Up AI Development With Open Source Code Snippets

Save time and resources by building on top of our open-source sample apps. Get a headstart on development and deploy your AI apps faster with Intel’s OpenVINO toolkit.
INTEL CORPORATION sponsor

Python Dependencies Are Fixable

Dependency management can be a hurdle for newcomers to Python, and this article argues that better defaults would be the right answer.
MAT DUGGAN

Generic Functions and Generic Classes in Python

Python does have generics! Learn how to use typing TypeVar and Generic to reuse code with proper typing.
GUI LATROVA • Shared by Gui Latrova

Projects & Code django-simple-menu: Code-Based Menus for Django

GITHUB.COM/JAZZBAND

poltergeist: Rust-Like Error Handling in Python

GITHUB.COM/ALEXANDERMALYGA

whenever: Strict, Predictable, and Typed Datetimes

GITHUB.COM/ARIEBOVENBERG

PyprojectX: Make Reproducible Builds

GITHUB.COM/PYPROJECTX • Shared by Ivo Houbrechts

modguard: Enforce a Decoupled Architecture

GITHUB.COM/NEVER-OVER

Events What’s New in Wagtail CMS Webinar

March 12 to March 13, 2024
WAGTAIL.ORG • Shared by Thibaud Colas

Weekly Real Python Office Hours Q&A (Virtual)

March 13, 2024
REALPYTHON.COM

Python Atlanta

March 14 to March 15, 2024
MEETUP.COM

PyCon SK 2024

March 15 to March 18, 2024
PYCON.SK

Django Girls Eket Workshop

March 15 to March 17, 2024
DJANGOGIRLS.ORG

Chattanooga Python User Group

March 15 to March 16, 2024
MEETUP.COM

Happy Pythoning!
This was PyCoder’s Weekly Issue #620.
View in Browser »

[ Subscribe to 🐍 PyCoder’s Weekly 💌 – Get the best Python news, articles, and tutorials delivered to your inbox once a week >> Click here to learn more ]

Categories: FLOSS Project Planets

Real Python: Python Basics Exercises: Dictionaries

Tue, 2024-03-12 10:00

In plain English, a dictionary is a book containing the definitions of words. Each entry in a dictionary has two parts: the word being defined, and its definition.

Python dictionaries, like lists and tuples, store a collection of objects. However, instead of storing objects in a sequence, dictionaries hold information in pairs of data called key-value pairs. That is, each object in a dictionary has two parts: a key and a value. Each key is assigned a single value, which defines the relationship between the two sets.

In this video course, you’ll practice:

  • What a dictionary is and how it’s structured
  • How dictionaries differ from other data structures
  • How to define and use dictionaries in your own code

This video course is part of the Python Basics series, which accompanies Python Basics: A Practical Introduction to Python 3. You can also check out the other Python Basics courses.

Note that you’ll be using IDLE to interact with Python throughout this course.

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Python Engineering at Microsoft: Data Science Day 2024 – Schedule Announcement

Mon, 2024-03-11 18:05
.badge1 { background-color: #4a7cb5; color: white; padding: 4px 8px; text-align: center; border-radius: 5px; font-size:small; } .badge2 { background-color: #9180ed; color: white; padding: 4px 8px; text-align: center; border-radius: 5px; font-size:small; } .badge3 { background-color: #56c6b9; color: white; padding: 4px 8px; text-align: center; border-radius: 5px; font-size:small; } .badge4 { background-color: #002b98; color: white; padding: 4px 8px; text-align: center; border-radius: 5px; font-size:small; } .badge5 { background-color: #d0c493; color: black; padding: 4px 8px; text-align: center; border-radius: 5px; font-size:small; }

 

 

We are thrilled to announce Python Data Science Day will be taking place March 14th, 2024; a “PyDay” on Pi Day: 3.14 . If you’re a Python developer, entrepreneur, data scientist, student, or researcher working on projects from hobbyist and start up to enterprise level, you’ll find solutions to modernize your data pipelines and answer complex queries with data.

Save the date!

During the event, you will hear directly from the experts, community members and Python and Data Science Microsoft MVPs, about the latest in Python Data Science. Whether you’re a beginner or an experienced Python Data Scientist, this event is for you.

We’ll cover three main areas:

  • The latest in Data Science with Python
    • New packages and research
    • Teaching Data Science with Python
    • Interesting new Data Sets and sources for data
  • Tools for Data Science
    • Code editors and developer tools
    • Tool chains/platforms for analysis
    • AI tools for Data Science
    • Microsoft tools (Fabric, Synapse, Azure AI/ML, VS Code)
  • Scaling Data Science to the Cloud
    • Databases + Data ingestion
    • Cloud-based computation and collaboration
    • Cloud resource management + DevOps
Agenda Session Title Theme Audience Speaker Time Pacific Type Welcome All Dawn Wages & Hosts! 9:00AM From Data to Insights: Data Science with Microsoft Fabric Data Science Tools Beginner; Intermediate Jasmine Greennaway, Ismaël Mejía 9:10AM 5 – 10 minute Lightning Talk Revolutionizing Data Science Workflows: Unleashing the Potential of Microsoft Visual Studio Code Data Science Tools Beginner; Student; Hobbyist;Research; Sumukh M G 9:20AM 5 – 10 minute Lightning Talk RAG using Semantic Kernel with Azure OpenAI and Azure Cosmos DB for MongoDB vCore Data Science Tools Scaling to the Cloud Intermediate; Advanced; Start Up; Student; Hobbyist; John Aziz 9:30AM 25 minute session Simplifying Data Analysis & Visualization (for non-Python devs) with AI Data Science Tools Beginner; Intermediate; Student; Research; Hobbyist; Nitya Narasimhan, PhD 10:00AM 25 minute session Getting started with Python using Data Wrangler in Microsoft Fabric Data Science Tools Get started with Data Science Beginner; Intermediate; Sandeep Pawar 10:35AM 5 – 10 minute Lightning Talk Buddy Driven Development Latest in Data Science Beginner; Intermediate; Bethany Jepchumba 10:45AM 5 – 10 minute Lightning Talk Supercharging your Data Science projects with GitHub tools Data Science Tools Intermediate; Start Up; Enterprise; Student; Carlotta Castelluccio 10:55AM 25 minute session Streamlining Data Preparation with Pydantic: A 25-Minute Guide Data Science Tools Latest in Data Science Intermediate; Hasan Özdemir 11:25AM 25 minute session Level Up Your ML Game: Building Models like a Pro with Microsoft Fabric’s Synapse Data Science Tools Latest in Data Science Beginner; Intermediate; Start Up; Enterprise;Student; Vinayak Gavariya 11:55AM 5 – 10 minute Lightning Talk Python Data Science Skilling – Cloud Skills Challenge Data Science Tools Latest in Data Science Get started with Data Science Beginner;Intermediate; Advanced; Start Up; Student; Research; Hobbyist; Aaron Stark 12:05PM 5 – 10 minute Lightning Talk Unleash The Power of Deep Learning: Build A Dog vs Cat Image Classifer Using CNN With TensorFlow Keras Latest in Data Science Intermediate; Student; Research; Jyothi Swaroop Makena 12:15PM 25 minute session Serverless Jupyter Notebook Functions Latest in Data Science Scaling to the Cloud Intermediate; Student; Research; — 12:45PM 25 minute session Beyond Keywords: Image similarity search in Azure Cosmos DB for PostgreSQL Data Science Tools Intermediate; Foteini Savvidou 1:20PM 5 – 10 minute Lightening Talk Python at Microsoft All Levels Dawn Wages 1:30PM 5 – 10 minute Lightning Talk Microsoft Fabric for Python Developers Data Science ToolsLatest in Data Science Beginner; Intermediate; Eren Orbey 1:40PM 25 minute session Data Science: The Bear* Necessities Data Science Tools Get started with Data Science Beginner; Student; Hobbyist; Renee Noble 2:10PM 25 minute session Surprise Guest! TBA Beginner; Student; Hobbyist; TBA 2:40PM 5 – 10 minute Lightning Talk Surprise Guest! TBA Beginner; Student; Hobbyist; TBA 2:50PM 5 – 10 minute Lightning Talk Empowering Data-Driven Innovation: A Journey through Real-World Applications Latest in Data Science Intermediate; Abdullah Awan 3:30PM 25 minute session Breaking Data Silos With Semantic Link In Microsoft Fabric Data Science Tools Latest in Data Science Intermediate; Sandeep Pawar 4:05PM 25 minute session More ways to engage with all the Data Science fun:
  • Join the Microsoft Fabric Global AI Hack Together on February 15th to March 4th, 2024. Fabric is an end-to-end AI-powered analytics platform that unites your data and services, including data science and data lakes. Register for the event to participate in live streams every week and solve real-world problems with guidance and a community.
  • Read our 14 Days of Python Data Science series where for fourteen days leading up to Python Data Science Day, we will drop cool articles and recipes for using Data Science on Microsoft tools. #14DaysOfDataScience
  • Check out the Data Science Cloud Skills Challenge if you want to go through some self-paced learning! This challenge is active until April 15th, 2024.
  • Join us on Discord at https://aka.ms/python-discord
More Data Science at Microsoft…

The post Data Science Day 2024 – Schedule Announcement appeared first on Python.

Categories: FLOSS Project Planets

Pages