PythoFF

Menu

Sign in:

read us on

What Can I Do With Python?

In this article, we offer several different projects, resources, and tutorials that you can use to start building things with Python.

home/2018/06/25/6cdbd70fdb74d33814df8f4ac580914931fa77d3.jpg

Каких дыр в безопасности надо бояться Python-разработчику

Писать безопасный и защищённый код сложно. Когда разрабатываете то или иное ПО, вы зачастую концентрируетесь на том, как оно должно применяться. Но в контексте безопасности в первую очередь надо думать о том, как ваше ПО может быть использовано не по назначению. Python не идеален — даже в стандартных библиотеках могут быть встроены некачественные методы.

home/2018/06/25/60f4a5fd52f8750d244b3eefc940f7117a29d567.jpg

PyDev of the Week: Mario Corchero

This week we welcome Mario Corchero (@mariocj89) as our PyDev of the Week! He is the chair of PyLondinium18, PyConES and PyCon Charlas, the Spanish track at this year’s PyCon US. Let’s spend some time learning more about Mario! Can you tell us a little about yourself (hobbies, education, etc.): I work at Bloomberg as a Senior Software Developer on the Python Infrastructure team, I’ve previously worked in other teams within Bloomberg’s Engineering department, like News Automation and News Search, where I used Python to automate the generation of content that we deliver to our clients in the form of news. This was quite an exciting project to be a part of. Before joining Bloomberg in London, I worked for Amadeus (Nice, France) and as an assistant researcher at my university in Spain, where I studied Computer Science and Software Development. My hobbies are travelling and tapas. For me, one of the greatest pleasures in life is to enjoy some drinks with small plates of food, while chatting with my friends. I cannot get used to “just drinking” as they do here in the UK ☺. When travelling, I hate taking photos, but I have a really bad memory, so I love to record videos, edit them and watch them later. In keeping with my enjoyment of travel, I also love going to Python conferences and meeting new people. It is a different experience from travelling for leisure, but I always come back happier after meeting someone new at a conference. I love when people approach me to talk, even if we haven’t met before! Also, I should also mention that my partner and I have guinea pig which you will always see included in the slides for all of my presentations. He is part of my family! Continue reading PyDev of the Week: Mario Corchero →

Создание management commands в Django

Management commands — команды, выполняемые из командной строки с помощью скрипта manage.py. Наиболее частые сферы применения — это действия, выполняемые разово или периодически, но для которых почему-либо недоступен запуск через планировщик. Например, отправка пользователям разовых сообщений, получение выборки данных из БД, проверка наличия необходимых файлов и папок перед накатыванием обновлений, быстрое создание объектов модели при разработке и т.д.

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

Operators and Expressions in Python

You'll see how calculations can be performed on objects in Python. By the end of this tutorial, you will be able to create complex expressions by combining Python objects and operators.

The Ultimate List of Python YouTube Channels

We couldn't find a good and updated list of Python developer or Python programming YouTube channels online. So we created our own list with the best and most Pythonic YouTubers.

home/2018/06/18/09f6830e371eb43010bc9f5f85382cc777d0a16d.jpg

ReportLab: PDF Publishing with Python is now Available!

My latest book, ReportLab: PDF Processing with Python is now available for purchase. ReportLab has been around since the year 2000 and has remained the primary package that Python developers use for creating reports in the PDF format. It is an extremely powerful package that works across all the major platforms. This book will also introduce the reader to other Python PDF packages. You can get the book at the following online retailers: Amazon (paperback and Kindle) Leanpub (mobi, epub and PDF) Gumroad (mobi, epub and PDF) Lulu (paperback)

PyDev of the Week: Qumisha Goss

This week we welcome Qumisha Goss as our PyDev of the Week. Q is a librarian from Detroit who gave one of the best keynotes I’ve ever seen at PyCon US this year. For some reason, the people who uploaded the Keynotes from that morning didn’t separate the keynotes from each other or from the morning’s lightning talks, so you have to seek about 2/3’s of the way through the official video to find Q’s keynote here: I personally think you should take a few moments and watch the video. But if you don’t have the time, you can still read this brief interview with this amazing person. Can you tell us a little about yourself (hobbies, education, etc): Qumisha Goss, I go by Q. I’m a Librarian at the Detroit Public Library. I studied History and Classical Studies at Calvin College. I was obsessed with Mythology and then with engineering of the Roman Empire. I wanted to Engineer and then an Archivist, and now I’m a librarian. Continue reading PyDev of the Week: Qumisha Goss →

home/2018/06/16/ab724b377f493b97ff235d2a79b647553fecf04f.jpg

Релиз неофициального MTProto прокси на Python, особенности протокола

Недавно разработчики Telegram выложили исходные тексты прокси-сервера, работающего по протоколу MTProto. На хабре вышли статьи об особенностях его сборки и перепаковке докер-контейнера с ним. Официальный прокси сервер, написанный на С, удивляет объемом кода — примерно 23 тысячи строк. Одновременно с этим, а иногда и чуть раньше, вышло несколько альтернативных реализаций, но ни одна из них не поддерживала возможность рекламы своего канала. В данной статье хотелось бы, во-первых, рассказать о малоизвестных особенностях протокола общения прокси-сервера с внешними серверами и, во-вторых, рассказать о собственной разработке — реализации прокси-сервера на Python, которая только что достигла релиза и доступна всем желающим под свободной лицензией MIT.

home/2018/06/16/c175277a8529fd7e8f1cf96ca8598b270dfb31d0.jpg

Configure Python 3, Flask and Gunicorn on Ubuntu 18.04 LTS

Ubuntu Linux's latest Long Term Support (LTS) operating system version is 18.04 and was released in April 2018. The 18.04 update is code named "Bionic Beaver" and it includes Python 3 by default.... (read more)

home/2018/06/13/71bc003147dde8f3af0ff4da6b6944393e53dbf4.jpg

Anaconda Data Science Survey Results

Anaconda announced the results of their first “state of data science” survey today. Out of the 4,218 responses, 26% were from students, 16% were from data scientists, 15% were academics and 15% were software developers. The key takeaways according to Anaconda are as follows: 99% of respondents use Anaconda for Python Docker and Kubernetes is beating out Hadoop / Spark. Google Cloud data services beat out Amazon Web Services and Microsoft’s Azure Matplotlib is still the top package for visualization. However “Plotly, Tableau, Microsoft Power BI and Tibco Spotfire are all strong commercial competitors to Matplotlib and other open source projects like ggplot, Bokeh, D3 and Altair.” 14% of respondents do machine learning with Anaconda The fact that Anaconda is free was ranked as its most important attribute while the fact that it has open source licensing was second to last. That last bullet point kind of bothers me, but I guess students don’t understand the importance of open source. Regardless, this is a really interesting survey on one of the top alternative versions of the Python distribution. You can read the full announcement here.

wxPython: Set Which Display the Frame is on

The other day, I saw an interesting question in the wxPython IRC channel. They were asking if there was a way to set which display their application would appear on. Robin Dunn, the creator of wxPython, gave the questioner some pointers, but I decided to go ahead and write up a quick tutorial on the topic. The wxPython toolkit actually has all the bits and pieces you need for this sort of thing. The first step is getting the combined screen size. What I mean by this is asking wxPython what it thinks is the total size of the screen. This would be the total width and height of all your displays combined. You can get this by calling wx.DisplaySize(), which returns a tuple. If you would like to get individual display resolutions, then you have to call wx.Display and pass in the index of the display. So if you have two displays, then the first display’s resolution could be acquired like this: index = 0 display = wx.Display(index) geo = display.GetGeometry() Let’s write up a quick little application that has a single button that will just switch which display the application is on. Continue reading wxPython: Set Which Display the Frame is on →

Variables in Python

Learn how every item of data in a Python program can be described by the abstract term object, and how to manipulate objects using symbolic names called "variables."

Python 3 – Assignment Expressions

I recently came across PEP 572, which is a proposal for adding assignment expressions to Python 3.8 from Chris Angelico, Tim Peters and Guido van Rossum himself! I decided to check it out and see what an assignment expression was. The idea is actually quite simple. The Python core developers want a way to assign variables within an expression using the following notation: NAME := expr This topic has had a LOT of arguments about it and you can read the details on the Python-Dev Google group if you want to. I personally found that reading through the various pros and cons put forth by Python’s core development community to be very insightful. Regardless, let’s look at some of the examples from PEP 572 to see if we can figure out how you might use an assignment expression yourself. # Handle a matched regex if (match := pattern.search(data)) is not None: ...   # A more explicit alternative to the 2-arg form of iter() invocation while (value := read_next_item()) is not None: ...   # Share a subexpression between a comprehension filter clause and its output filtered_data = [y for x in data if (y := f(x)) is not None] In these 3 examples, we are creating a variable in the expression statement itself. The first example creates the variable, match, by assigning it the result of the regex pattern search. The second example assigns the variable, value, to the result of calling a function in the while loop’s expression. Finally we assign the result of calling f(x) to the variable y inside of a list comprehension. One of the most interesting features of assignment expressions (to me at least), is that they can be used in contexts that an assignment statement cannot, such as in a lambda or the previously mentioned comprehension. However they also do NOT support some things that assignment statements can do. For example, you cannot to multiple target assignment: x = y = z = 0 # Equivalent: (x := (y := (z := 0))) You can see a full list of differences in the PEP There is a lot more information in the PEP that covers a few other examples, talks about rejected alternatives and scope. Related Reading PEP 572 — Assignment Expressions Reddit: Accidentally override local variables Reddit on PEP 572

Python 101 – Assignment Expressions

I recently came across PEP 572, which is a proposal for adding assignment expressions to Python 3.8 from Chris Angelico, Tim Peters and Guido van Rossum himself! I decided to check it out and see what an assignment expression was. The idea is actually quite simple. The Python core developers want a way to assign variables within an expression using the following notation: NAME := expr This topic has had a LOT of arguments about it and you can read the details on the Python-Dev Google group if you want to. I personally found that reading through the various pros and cons put forth by Python’s core development community to be very insightful. Regardless, let’s look at some of the examples from PEP 572 to see if we can figure out how you might use an assignment expression yourself. # Handle a matched regex if (match := pattern.search(data)) is not None: ...   # A more explicit alternative to the 2-arg form of iter() invocation while (value := read_next_item()) is not None: ...   # Share a subexpression between a comprehension filter clause and its output filtered_data = [y for x in data if (y := f(x)) is not None] In these 3 examples, we are creating a variable in the expression statement itself. The first example creates the variable, match, by assigning it the result of the regex pattern search. The second example assigns the variable, value, to the result of calling a function in the while loop’s expression. Finally we assign the result of calling f(x) to the variable y inside of a list comprehension. One of the most interesting features of assignment expressions (to me at least), is that they can be used in contexts that an assignment statement cannot, such as in a lambda or the previously mentioned comprehension. However they also do NOT support some things that assignment statements can do. For example, you cannot to multiple target assignment: x = y = z = 0 # Equivalent: (x := (y := (z := 0))) You can see a full list of differences in the PEP There is a lot more information in the PEP that covers a few other examples, talks about rejected alternatives and scope. Related Reading PEP 572 — Assignment Expressions Reddit: Accidentally override local variables Reddit on PEP 572

Building and Documenting Python REST APIs With Flask and Connexion

Creating a REST API with Flask and Connexion

Trio: Асинхронная конкурентность для простых смертных

PyDev of the Week: Naomi Ceder

This week we welcome Naomi Ceder (@NaomiCeder) as our PyDev of the Week. Naomi has been a long-time member of the Python community and is the author of The Quick Python Book. Naomi is the current chair of the board of directors for the Python Software Foundation and is a regular speaker at programming conferences. Let’s take a few moments to get to know Naomi better! Can you tell us a little about yourself (hobbies, education, etc): Well, a lot of people know that I’m currently chair of the PSF, and many have heard me speak about my journey involving gender. People seem to be surprised to find out that I have a PhD in Classics (from the U of Wisconsin, Madison) – Ancient Greek, Latin, and historical Linguistics, with some Sanskrit and Egyptian Hieroglyphs thrown in. So I’ve been interested in different human languages and how they work for a long time and I think that’s helped me learn and think about computer languages. It certainly helps me read languages like Portuguese, Spanish, and French. Sadly, it doesn’t do much to help me speak those languages so I end up understanding a fair bit of what I read or hear, but then being tongue tied and looking like a dolt when I try to have a conversation. My other odd claim to fame is that I was a competitive dog obedience trainer and judge (I even wrote a humor column for the national obedience training magazine) for several years, taking my first dog through all the levels of AKC and UKC obedience. That’s a pretty time-consuming hobby, and I retired from it a few years ago. Our current dog knows some obedience stuff, but she also knows that I’m no longer the stickler that I was when we were competing, and she takes advantage of that. But she’s cute and she knows how to work that, so who am I to nitpick? All of our dogs so far have been Australian shepherds – smart, reasonably athletic and energetic, but usually with a bit more of a sense of humor than you’d find in border collies. Anyone who knows the breed will understand what I mean. Finally, since I started my current job leading a team for Dick Blick Art Materials, I’ve started drawing, something I’d always wanted to do. Like a lot of people, I think, I’d always wanted to capture some of the scenes around me, but I just felt it was beyond me. I guess the lure of using my employee discount, combined with thinking and talking about the tools and materials every day, overcame my reluctance and I started studying/practicing about a year and a half ago. In particular, I’m interested in what’s called “urban sketching”, quick sketches capturing city scenes, since I’ve always been fascinated by the scenes and shapes of cities. After PyCon I shared a sketch I did of the Rock and Roll Hall of Fame on Twitter, which was the first time I’ve done that. I don’t claim to be good, but I am getting better, and I do enjoy it. Continue reading PyDev of the Week: Naomi Ceder →

home/2018/06/09/bf12755cc4af13048c8c049029431ecaf283471b.jpg

Предварительная программа PyConRu-2018: три Python Core Developer’а, докладчики из Google, Yelp, Red Hat, Яндекса

Привет, Хабр! 22-23 июля в 95 км. от Москвы пройдет шестая российская конференция для python-программистов PYCON RUSSIA 2018. Уже в программе: Юрий Селиванов (Python Core Developer, EgdeDB, Канада), Андрей Светлов (Python Core Developer, Украина), Christian Heimes (Python Core Developer, Red Hat, Германия), Melanie Warrick (Google, США), Stephan Jaensch (Yelp, Германия), Kate Heddleston (Shift, США), Alejandro Saucedo (Eigen Technologies, Великобритания), Вадим Пуштаев (Mail.Ru), Марина Камалова (Яндекс). Если вы хотите присоединиться в качестве спикера, есть еще несколько дней, чтобы заявиться с докладом. Под катом — подробности программы. Если вы не знаете, что такое PyConRu, вот маленький ролик о том, как прошла прошлогодняя конференция

An Intro to PyPDF2

The PyPDF2 package is a pure-Python PDF library that you can use for splitting, merging, cropping and transforming pages in your PDFs. According to the PyPDF2 website, you can also use PyPDF2 to add data, viewing options and passwords to the PDFs too. Finally you can use PyPDF2 to extract text and metadata from your PDFs. PyPDF2 is actually a fork of the original pyPdf which was written by Mathiew Fenniak and released in 2005. However, the original pyPdf’s last release was in 2014. A company called Phaseit, Inc spoke with Mathieu and ended up sponsoring PyPDF2 as a fork of pyPdf At the time of writing this book, the PyPDF2 package hasn’t had a release since 2016. However it is still a solid and useful package that is worth your time to learn. The following lists what we will be learning in this article: Extracting metadata Splitting documents Merging 2 PDF files into 1 Rotating pages Overlaying / Watermarking Pages Encrypting / decrypting Let’s start by learning how to install PyPDF2! Installation PyPDF2 is a pure Python package, so you can install it using pip (assuming pip is in your system’s path): python -m pip install pypdf2 As usual, you should install 3rd party Python packages to a Python virtual environment to make sure that it works the way you want it to. Continue reading An Intro to PyPDF2 →

Creating and Manipulating PDFs with pdfrw

Patrick Maupin created a package he called pdfrw and released it back in 2012. The pdfrw package is a pure-Python library that you can use to read and write PDF files. At the time of writing, pdfrw was at version 0.4. With that version, it supports subsetting, merging, rotating and modifying data in PDFs. The pdfrw package has been used by the rst2pdf package (see chapter 18) since 2010 because pdfrw can “faithfully reproduce vector formats without rasterization”. You can also use pdfrw in conjunction with ReportLab to re-use potions of existing PDFs in new PDFs that you create with ReportLab. In this article, we will learn how to do the following: Extract certain types of information from a PDF Splitting PDFs Merging / Concatenating PDFs Rotating pages Creating overlays or watermarks Scaling pages Combining the use of pdfrw and ReportLab Let’s get started! Continue reading Creating and Manipulating PDFs with pdfrw →

home/2018/06/05/f2c45cd2ef811235666952d27da8dd967eb07b1c.jpg

Running Bottle Apps in Docker Containers on macOS

It can be confusing to figure out how to use Docker containers in your Python and Bottle development environment workflow. This tutorial will quickly show you the exact steps to get Docker up and running on... (read more)

home/2018/06/05/a25c9bf2dca56bdc5fc1ac019e2f39340c28c191.jpg

Пишем свой BitTorrent-клиент на Python

Когда-нибудь думали о том, чтобы написать свой BitTorrent-клиент с блекджеком и без рекламы? Пока вы думали, кто-то уже написал. Перевели статью автора клиента Pieces, в которой он рассказывает, как устроен сам протокол и клиент. К слову, проект доступен под лицензией Apache 2, так что вы можете спокойно делать с этим клиентом что угодно.

home/2018/06/05/0698da73a03fb3e161fa1253e970f976401ea7c6.jpg

Basic Data Types in Python

Learn the basic data types that are built into Python, like numbers, strings, and Booleans. You'll also get an overview of Python's built-in functions.

Creating PDFs with PyFPDF and Python

ReportLab is the primary toolkit that I use for generating PDFs from scratch. However I have found that there is another one called PyFPDF or FPDF for Python. The PyFPDF package is actually a port of the “Free”-PDF package that was written in PHP. There hasn’t been a release of this project in a few years, but there have been commits to its Github repository so there is still some work being done on the project. The PyFPDF package supports Python 2.7 and Python 3.4+. This article will not be exhaustive in its coverage of the PyFPDF package. However it will cover more than enough for you to get started using it effectively. Note that there is a short book on PyFPDF called “Python does PDF: pyFPDF” by Edwood Ocasio on Leanpub if you would like to learn more about the library than what is covered in this chapter or the package’s documentation. Installation Installing PyFPDF is easy since it was designed to work with pip. Here’s how: python -m pip install fpdf At the time of writing, this command installed version 1.7.2 on Python 3.6 with no problems whatsoever. You will notice when you are installing this package that it has no dependencies, which is nice. Continue reading Creating PDFs with PyFPDF and Python →

home/2018/06/04/f2c45cd2ef811235666952d27da8dd967eb07b1c.jpg

First Steps with Bottle Apps in Docker Containers on macOS

It can be confusing to figure out how to use Docker containers in your Python and Bottle development environment workflow. This tutorial will quickly show you the exact steps to get Docker up and running on... (read more)

home/2018/06/04/37e66d0b46098458c12edaf1cce836d9a3be7f13.jpg

Python Application Layouts: A Reference

A reference guide to common Python application layouts and project structures for command-line applications, web applications, and more.

PyDev of the Week: Maria Camila Remolina Gutiérrez

This week we welcome Maria Camila Remolina Gutiérrez (@holamariacamila) as our PyDev of the Week! Maria recently gave a talk at PyCon USA in their new PyCon Charlas track last month. You can learn more about Maria on her website or you can check out her Github profile to see what she has been doing in the open source world. Let’s take a few minutes to get to know her better! Can you tell us a little about yourself (hobbies, education, etc): My name is Maria Camila. I am a 23 year old colombian. I am a Physicist and soon to be Systems and Computing Engineer (I will graduate in June 2018). I am studying at Universidad de los Andes in Bogotá, Colombia. My main area of research so far is computational astrophysics, especially simulations. I am very interested in the topics of infrastructure, high performance computing and security. Regarding my hobbies, I love pottery and ceramics, I have been doing it for 1.5 years so far. Also, I’ve been trying to learn bongo drums in my spare time. Finally, I love learning new languages, especially because it is binded to the culture of the countries that speak them, so it allows you to discover the world in a different way. Continue reading PyDev of the Week: Maria Camila Remolina Gutiérrez →

Type-checked Python in the real world

Older Posts