Sign in:

read us on

Новое в Python 3.7

Аннотации во благо

PyDev of the Week: Adrienne Tacke

This week we welcome Adrienne Tacke (@AdrienneTacke) as our PyDev of the Week! Adrienne is the author of Coding for Kids: Python: Learn to Code with 50 Awesome Games and Activities and her book came out earlier this year. You can see what Adrienne is up to on Instagram or via her website. Let’s take some time to get to know her better! Can you tell us a little about yourself (hobbies, education, etc): I’m a software engineer in Las Vegas and have a degree in Management Information Systems from UNLV. I’ve worked in the education and healthcare industries and now focus on building awesome things in the fintech space. I love learning new languages (spoken and programming), eating every dessert imaginable, traveling the world with my husband, and finding ways to encourage more young girls and women to try out a career as a software engineer. Continue reading PyDev of the Week: Adrienne Tacke →

Проверка типов в Питоне как реальность


Installing Python on Windows, macOS, and Linux

To get started working with Python, you'll need to have access to the Python interpreter. There are several common ways to accomplish this and in this course, you will learn how to install the latest version of Python on your computer.


Three Ways of Storing and Accessing Lots of Images in Python

In this tutorial, you'll cover three ways of storing and accessing lots of images in Python. You'll also see experimental evidence for the performance benefits and drawbacks of each one.


Writing Cleaner Python Code With PyLint

In this video series you'll see how to install and set up the PyLint code linter tool. You'll learn why you should use code linters like PyLint, Flake8, PyFlakes, or other static analysis tools—and how they can help you write cleaner and more Pythonic code.

How to Extract Build Info from Jenkins with Python

I work with continuous integration software as a part of my job. I use both Hudson and Jenkins in my role and occasionally need to interact with them programmatically. There are two Python packages you can use for this task: The Python Jenkins package JenkinsAPI The Python Jenkins package will work with both Hudson and Jenkins which JenkinsAPI only works with Jenkins. I usually use Python Jenkins because of this, although I have recently started looking to see which one works better with artifacts and I discovered that JenkinsAPI is actually better for that sort of thing. So you will need to evaluate both of these packages depending on what you need to do. Continue reading How to Extract Build Info from Jenkins with Python →


Playing and Recording Sound in Python

In this tutorial, you'll learn about libraries that can be used for playing and recording sound in Python, such as PyAudio and python-sounddevice. You'll also see code snippets for playing and recording sound files and arrays, as well as for converting between different sound file formats.

PyDev of the Week: Tania Allard

This week we welcome Tania Allard (@ixek) as our PyDev of the Week! Tania is a developer advocate at Microsoft. She is also a speaker at multiple conferences. If you’d like to learn more about her, you should check out her blog. She also has some of her projects up on Github for you to peruse. Let’s take a few moments to get to know Tania! Can you tell us a little about yourself (hobbies, education, etc): I am originally from Mexico but have lived in the USA and in the UK for the last 8 years. I have a bachelor’s in Mechatronic engineering and have also always been fascinated by technology and I can class myself as a lifelong learner. As such I got a PhD from the University of Manchester in Data science applied to Materials science, during which I discovered and fell in love with Python. Since completing my PhD I have worked as a research software engineer, research engineer, data engineer, and more recently could advocate. Apart from tech I love Olympic weightlifting, so I spend quite a good amount of time in the gym every week and I am already looking forward for this year’s competition season! I also love craft beer and recently joined the women in beer scene in Manchester, UK where I live. Continue reading PyDev of the Week: Tania Allard →

An Intro to StaticBox and StaticBoxSizers

There are many widgets that are included with the wxPython GUI toolkit. One of them is a fairly handy widget called wx.StaticBox. This widget accepts a string and then will draw a box with the string in the upper left-hand corned of the box. However this only works when you use it in conjunction with wx.StaticBoxSizer. Here is an example of what one might look like: Now let’s go ahead and write the code you would use to create the example above: Continue reading An Intro to StaticBox and StaticBoxSizers →


Creating GUI Applications with wxPython Now Available

My latest book, Creating GUI Applications with wxPython is now available for purchase. Creating GUI Applications with wxPython is a book that will teach you how to use wxPython to create applications by actually creating several mini-programs. I have found that while learning how the various widgets work in wxPython is valuable, it is even better to learn by creating a simple application that does something useful. In this book, you will be creating the following applications: A simple image viewer A database viewer A database editor Calculator An Archiving application (tar) PDF Merging application XML Editor File search utility Simple FTP application NASA Image downloader As you learn how to create these applications, you will also learn how wxPython works. You will go over how wxPython’s event system works, how to use threads in wxPython, make use of sizers and much, much more! The eBook version is on sale on Leanpub for $14.99 until May 15th. You can also purchase the book on Gumroad, or get the paperback or Kindle version on Amazon.


Python Community Interview With Bob and Julian of PyBites

Bob Belderbos and Julian Sequeira are the co-founders of PyBites. In this interview, we discuss how PyBites got started and what they have in store for its future. We’ll also look into Bob’s secret love of drawing and Julian’s not so secret love of a good pint!


Python Context Managers and the "with" Statement

In this course you'll learn how context managers and the "with" statement work in Python, including the difference between class-based and function-based context managers.


How to Use sorted() and sort() in Python

In this step-by-step tutorial, you’ll learn how to sort in Python. You'll know how to sort various types of data in different data structures, customize the order, and work with two different ways of sorting in Python.

PyDev of the Week: Joel Grus

This week we welcome Joel Grus (@joelgrus) as our PyDev of the Week! Joel is the author of Data Science From Scratch: First Principles with Python from O’Reilly. You can catch up with Joel on his website or on Github. Let’s take some time to get to know Joel better! Can you tell us a little about yourself (hobbies, education, etc): In school I studied math and economics. I started my career doing quantitative finance (options pricing, financial risk, and stuff like that). I got very, very good at Excel, and I learned a tiny amount of SQL. But I kind of hated working in finance (and also I got laid off), so I joined an online travel startup as a “data analyst” doing BI stuff (lots of spreadsheets, lots of SQL, some very light scripting). That startup got acquired by Microsoft, who at the time had basically no idea what to do with my more-than-a-financial-analyst-less-than-a-software-engineer skillset. (Nor did I, really.) Then in 2011 I saw that the winds were blowing toward “data science”, so I sort of BS-ed my way into a data scientist job at a tiny startup. I took a bunch of Coursera courses to fill in gaps in my knowledge, and then I learned to write (ugly) production code and discovered I really enjoyed building software. Through doing well in coding competitions I had the opportunity to interview for a software engineer job at Google, so I spent 6 really hectic weeks cramming computer science and then somehow passed the interview. I spent a couple of years at Google, and then I found I missed doing data and ML stuff, and so now I’m at the Allen Institute for Artificial Intelligence, where I build deep learning tools for NLP researchers. My current job is right at the intersection of deep learning and Python library design, which is a pretty great match for my interests. I don’t really have time for hobbies 😢. I have an 8-year-old daughter, and I spend a lot of my free time with her, and then I keep agreeing and/or volunteering to write things and give talks and make livecoding videos, which takes up most of the rest. And then I have a podcast and a Twitter to stay on top of. I have long-term hobby goals of (1) learning jazz piano and (2) writing a novel, but I’m not really making much progress on either. Why did you start using Python? A long, long time ago I was taking a “Probability Modeling” class that was taught using Matlab. The site license for Matlab was only valid on-campus, which meant I couldn’t work on the assignments at my apartment, which was where I preferred to work. I discovered that there was a Python library called Numeric (the predecessor of NumPy) that would allow me to do the numerical-simulation things I needed to do, so I learned just enough Python to be able to do my assignments. Several years after that I had a job, and I inherited a bunch of Perl scripts, and I really didn’t want to maintain Perl code, so I started migrating them to Python, and the rest is history. What other programming languages do you know and which is your favorite? About 10-15% of my job involves writing JavaScript / React, which I actually really enjoy. (I might enjoy it less if it were 100% of my job.) The first year I was at AI2 I worked mostly in Scala, and after that I briefly worked on a project that was in Go. At Google I wrote primarily C++. The startup I was at before that used F#. For fun I used to write Haskell and PureScript. Part of me still dreams of having a Haskell / PureScript job, but at this point I’m so comfortable working in Python (and Python has so deeply entrenched itself as the language for doing machine learning) that it seems unlikely I’ll ever make the switch. What projects are you working on now? In my day job I’m a core developer on AllenNLP, which is an open-source deep-learning library for NLP researchers. I just finished the second edition of Data Science from Scratch, should be available any time now. In April I’m giving a keynote talk at about modern NLP. This month I’m giving a talk at the “Reproducible ML” workshop at ICLR, and a comedic banquet keynote at the ASA Symposium on Statistics and Data Science, which means I need to write a 30+-minute standup routine about data science and statistics. Does this sound like too much to be working on? It’s way too much to be working on. But each of these projects is individually exciting, and I can’t imagine which one I would have said no to. (I have a lot of trouble saying no to things.) Which Python libraries are your favorite (core or 3rd party)? I think PyTorch is great. (AllenNLP is built on top of it.) I am pretty much the world’s biggest proponent of type annotations, and (accordingly) I’m a huge fan of mypy and also the typing module. There’s a lot of fun stuff in itertools, and you can really level up your Python by learning it. I also really like Flask — knowing how to prototype tiny Flask + React apps is a minor superpower for data scientists. tqdm (progress bars for iterables) comes in handy surprisingly often. How did you end up writing a book on data science and Python? I felt like an impostor compared to all the “famous” data scientists, so I thought that if I wrote a book I might feel less like an impostor. I cold-emailed O’Reilly with my proposal (which was originally way too ambitious), and they were very skeptical, so I kept sending them sample chapters, and then eventually they asked me “if we keep being indecisive are you going to eventually send us the whole book?” and I said probably, and then they said OK we’ll publish it, and then I spent basically all my free time for the next year writing it. Now that it’s 2019, I feel extremely guilty that there is a Python 2.7 book out there with my name on it, so I proposed a second edition where the code is upgraded to 3.6 (with type annotations), and I took the opportunity to make the code cleaner and freshen up the jokes and add some new material on things like deep learning and NLP and data ethics. What lessons did you learn in writing a book? The primary lesson I learned was that all the things I thought I understood I didn’t actually understand. For example, I thought I understood hypothesis testing, but when I started trying to *explain* it I discovered that I didn’t understand it at all, and then I had to *actually* learn it before I could write the chapter. Many of the topics in the book were similarly humbling. When you’re coding it’s easy to get overly clever, and writing a book is a good way to disabuse yourself of that habit. I tried very hard to make the code examples in the book as *clear* as possible, and that’s a practice that’s really spilled over into all the code I write. Another lesson is that you’re not going to please everyone. There are a lot of people who really like my book (which is extremely gratifying!), but also there are some people who hate it. That can be really dispiriting. A good book is deeply personal, which means that when you publish it you’re really putting yourself out there for judgment. That’s a tough thing to do. For example, in the second edition I used type annotations everywhere. I deeply believe it was the right choice (both morally and pedagogically), but also I know that some people are going to absolutely *hate* the type annotations, and I’m still steeling myself for those reactions. Is there anything else you’d like to say? Buy the 2nd edition of Data Science from Scratch when it comes out! 😇 Read other people’s code and get them to read your code. It’s one of the best ways to improve as a coder. I’ve had quite a few people tell me they’ve started using type annotations or NamedTuples or asserts or various other things because they saw me using them and how they made my code better. That’s one of the best feelings for me, when someone tells me that they’re a better coder or a better data scientist on account of my book or my blog or one of my videos. Finally, don’t use mutable objects (e.g. lists) as default values for function arguments! Everyone makes this mistake at least once, and it’s always a pain in the ass to figure out what you did wrong. Thanks for doing the interview!

Объяснение алгоритмов сортировки с примерами на Python

В этой статье будут рассмотрены популярные алгоритмы, принципы их работы и реализация на Python. А ещё сравним, как быстро они сортируют элементы в списке.

Шпаргалка по OpenCV — Python

Библиотека компьютерного зрения и машинного обучения с открытым исходным кодом. В неё входят более 2500 алгоритмов, в которых есть как классические, так и современные алгоритмы для компьютерного зрения и машинного обучения. Эта библиотека имеет интерфейсы на различных языках, среди которых есть Python (в этой статье используем его), Java, C++ и Matlab.


Books on Sale for PyCon 2019

In honor of PyCon 2019 that is starting this week, I am putting three of my books on sale. You can get any of the following books for $9.99 through May 6th by clicking on the links: Python 201: Intermediate Python ReportLab – PDF Processing with Python Jupyter Notebook 101 Python 201 is a fun book for those of you who would be interested in learning intermediate and advanced topics in Python. My ReportLab book covers how to create PDFs using Python and ReportLab. It also covers many other topics related to PDFs, such as splitting, merging and overlaying PDFs to name a few. Finally my Jupyter Notebook 101 book is a good way for you to learn about the Jupyter Notebook and many of its capabilities.


Defining Main Functions in Python

In this step-by-step tutorial, you'll learn how Python main functions are used and some best practices to organize your code so it can be executed as a script and imported from another module.


How to Get the Most Out of PyCon

In this article, you'll learn how you can get the most out of PyCon. Whether you're a first-timer or a seasoned attendee, this guide will help you get ready to have a great PyCon.

PyDev of the Week: Neil Muller

This week we welcome Neil Muller as our PyDev of the Week! Neil is an organizer for Cape Town Python User Group and PyCon ZA. He also speaks at conferences! You can learn more about his open source projects over on Github. Let’s take a few moments to get to know Neil better! Can you tell us a little about yourself (hobbies, education, etc): I’m an Applied Mathematician with interests in image processing and numerical computation, currently living and working in the Cape Town area, South Africa. I followed an interest in facial recognition into a PhD from the University of Stellenbosch, and that led to working on a variety of image processing and numerical modelling problems at iThemba LABS. These days I split my working time between iThemba LABS and Praelexis, a machine learning company (mainly using Python) in Stellenbosch. In my spare time, I am obsessed with board and card games, especially Vampire: The Eternal Struggle. Continue reading PyDev of the Week: Neil Muller →


Conditional Statements in Python (if/elif/else)

In this step-by-step tutorial you'll learn how to work with conditional ("if") statements in Python. Master if-statements step-by-step and see how to write complex decision making code in your programs.


Python KeyError Exceptions and How to Handle Them

In this tutorial, you'll learn how to handle Python KeyError exceptions. They are often caused by a bad key lookup in a dictionary, but there are a few other situations when a KeyError can be raised as well. Knowing how to handle these exceptions is essential to writing good Python code.


A Beginner’s Guide to the Python time Module

In this tutorial, you'll learn how to use the Python time module to represent dates and times in your application, manage code execution, and measure performance.

PyDev of the Week: Dane Hillard

This week we welcome Dane Hillard (@easyaspython) as our PyDev of the Week! Dane is the author Practices of the Python Pro, an upcoming book from Manning. He is also a blogger and web developer. Let’s take some time to get to know Dane! Can you tell us a little about yourself (hobbies, education, etc): I’m a creative type, so many of my interests are in art and music. I’ve been a competitive ballroom dancer, and I’m a published musician and photographer. I’m proud of those accomplishments, but I’m driven to do most of this stuff for personal fulfillment more than anything! I enjoy sharing and discussing what I learn with others, too. When I have some time my next project is to start exploring foodways, which is this idea of exploring food and its cultural impact through written history. I’ve loved cooking (and food in general) for a long time and I want to get to know its origins better, which I think is something this generation is demanding more from industries as a whole. Should be fun! Continue reading PyDev of the Week: Dane Hillard →

Mozilla Announces Pyodide – Python in the Browser

Mozilla announced a new project called Pyodide earlier this week. The aim of Pyodide is to bring Python’s scientific stack into the browser. The Pyodide project will give you a full, standard Python interpreter that runs in your browser and also give you access to the browsers Web APIs. Currently, Pyodide does not support threading or networking sockets. Python is also quite a bit slower to run in the browser, although it is usable for interactive exploration. The article mentions other projects, such as Brython and Skulpt. These projects are rewrites of Python’s interpreter in Javascript. Their disadvantage to Pyodide is that they cannot use Python extensions that were written in C, such as Numpy or Pandas. Pyodide overcomes this issue. Anyway, this sounds like a really interesting project. I always thought the demos I used to see of Python running in Silverlight in the browser were cool. That project is basically dead at this point, but Pyodide sounds like a really interesting new hack at getting Python into the browser. Hopefully it will go somewhere.

Creating a GUI Application for NASA’s API with wxPython

Growing up, I have always found the universe and space in general to be exciting. It is fun to dream about what worlds remain unexplored. I also enjoy seeing photos from other worlds or thinking about the vastness of space. What does this have to do with Python though? Well, the National Aeronautics and Space Administration (NASA) has a web API that allows you to search their image library. You can read all about it on their website. The NASA website recommends getting an Application Programming Interface (API) key. If you go to that website, the form that you will fill out is nice and short. Technically, you do not need an API key to make requests against NASA’s services. However they do have rate limiting in place for developers who access their site without an API key. Even with a key, you are limited to a default of 1000 requests per hour. If you go over your allocation, you will be temporarily blocked from making requests. You can contact NASA to request a higher rate limit though. Interestingly, the documentation doesn’t really say how many requests you can make without an API key. The API documentation disagrees with NASA’s Image API documentation about which endpoints to hit, which makes working with their website a bit confusing. For example, you will see the API documentation talking about this URL: But in the Image API documentation, the API root is: For the purposes of this tutorial, you will be using the latter. Continue reading Creating a GUI Application for NASA’s API with wxPython →


Immutability in Python

In Python, immutable vs mutable data types and objects types can cause some confusion—and weird bugs. With this course you'll see what the difference between mutable and immutable data types is in Python, and how you can use it to your advantage in your own programs.


How to Work With a PDF in Python

In this step-by-step tutorial, you'll learn how to work with a PDF in Python. You'll see how to extract metadata from preexisting PDFs . You'll also learn how to merge, split, watermark, and rotate pages in PDFs using Python and PyPDF4.

Older Posts