PythoFF

Menu

Sign in:

read us on

home/2018/09/28/0de10f74835a28e08bf4aca66fc2ede43364c49a.jpg

Image Segmentation Using Color Spaces in OpenCV + Python

In this introductory tutorial, you'll learn how to simply segment an object from an image based on color in Python using OpenCV. A popular computer vision library written in C/C++ with bindings for Python, OpenCV provides easy ways of manipulating color spaces.

home/2018/09/26/0de10f74835a28e08bf4aca66fc2ede43364c49a.jpg

Color Spaces and How to Use Them With OpenCV and Python

In this introductory tutorial, you'll learn how to simply segment an object from an image based on color in Python using OpenCV. A popular computer vision library written in C/C++ with bindings for Python, OpenCV provides easy ways of manipulating color spaces.

Python 101: Episode #26 – lambdas

In this screencast you will learn how to use lambdas in Python. You can read the chapter this screencast is based on here: http://python101.pythonlibrary.org/ or purchase the book on Leanpub

Creating Presentations with Jupyter Notebook

Jupyter Notebook can be turned into a slide presentation that is kind of like using Microsoft Powerpoint, except that you can run the slide’s code live! It’s really neat how well it works. The only con in my book is that there isn’t a lot of theming that can be applied to your slides, so they do end up looking a bit plain. In this article, we will look at two methods of creating a slideshow out of your Jupyter Notebook. The first method is by using Jupyter Notebook’s built-in slideshow capabilities. The second is by using a plug-in called RISE. Let’s get started! Note: This article assumes that you already have Jupyter Notebook installed. If you don’t, then you might want to go to their website and learn how to do so. Continue reading Creating Presentations with Jupyter Notebook →

home/2018/09/24/f762e382152e3bb6ad01aada0c2cd4b286b77ec4.jpg

Python Community Interview With Mahdi Yusuf

Mahdi Yusuf is one of the founders of Pycoder’s Weekly and the CTO of Gyroscope, the OS for the human body. In this interview, we talk about the importance of focusing on the value you can offer and not just the problems you can solve. He also has a controversial opinion about Batman!

PyDev of the Week: Hillel Wayne

This week we welcome Hillel Wayne (@Hillelogram) as our PyDev of the Week! Hillel is the author of “Learn TLA+” and is currently writing “Practical TLA+” with Apress. You should check out his website / blog as it is a good place to learn more about him. Hillel also recently spoke at PyCon US on testing. Let’s take a few moments to chat with Hillel! Can you tell us a little about yourself (hobbies, education, etc): I was planning on being a physicist for the longest time until my fourth year of college, when I suddenly switched to wanting to be a programmer. I spent a while as a fullstack in the Bay Area and a backend dev in Chicago, where I discovered a deep love of formal methods, or the practice of “mathematically” designing and building software. If you’ve read The Coming Software Apocalypse, that’s a really good introduction to the why and the what. I now do consulting and workshops, helping people with the how; these tools are way too powerful and useful to stay niche. Beyond formal methods, my interests in tech are as follows: Software Safety: where do bugs actually come from, and how we do make them less likely? Empirical Software Engineering: what do we actually know is true in software engineering, and what do we just think is true? Software History: how did we get where we are, and what can we learn from the past? Weird and interesting niche ideas, languages, techniques, etc. Outside of tech, I do a lot of juggling and cooking. I’m a super avid confectioner and chocolatier. There’s a place in Chicago that sells 10-pound bars of chocolate for 50 bucks and I usually go through about four bars a year. Continue reading PyDev of the Week: Hillel Wayne →

Return to editingPython 101: Episode #25 – Decorators

In this episode, you will learn the basics of Python decorators and what the are good for. You can read the chapter this screencast is based on here: http://python101.pythonlibrary.org/ or purchase the book on Leanpub You can also read about decorators in a couple of other articles on my blog: Python: All About Decorators Python 201: Decorators

home/2018/09/19/92e0b5c09d74ec8fae7e8b3daaf0d932949d5862.jpg

Absolute vs Relative Imports in Python

If you’ve worked on a Python project that has more than one file, chances are you’ve had to use an import statement before. In this tutorial, you’ll not only cover the pros and cons of absolute and relative imports but also learn about the best practices for writing import statements.

home/2018/09/18/5cc1afd13891ae2d4e3b606a7ab2dde65af872f1.jpg

Jupyter Notebook 101: Writing Update

I don’t usually write about my book writing while the book is in progress on my blog, but I know some readers probably wonder why there are times where I am not writing blog posts as regularly as I usually do. The reason is usually because I am deep into writing chapters for a book and if the book’s chapters don’t translate into good blog articles, then the blog itself doesn’t get a lot of new content. Anyway, as you may know, I am currently working on a book called Jupyter Notebook 101 which I am currently planning to release in November. I have 7 of the planned 11 chapters finished, although I plan to go over the entire book and check it for errors once it’s done. I am hoping to get the other chapters done early so I can write a few bonus chapters too, but we will see how the writing goes. On the plus side, these latter chapters will make good blog fodder, so you can expect to see some interesting articles on the Jupyter Notebook appearing on this blog in the near future. If you’re interested in checking out the book, you can download a sample from Leanpub.

home/2018/09/17/0981de2080573484780e1ee313a87598ab3f401d.jpg

Top 10 Must-Watch PyCon Talks

Get the inside scoop on the top 10 must-watch PyCon talks for both beginners and advanced Python developers. There's something for everyone in this list of informative videos!

PyDev of the Week: Younggun Kim

This week we welcome Younggun Kim (@scari_net) as our PyDev of the Week! Younggun has been on the board of directors for the Python Software Foundation and is the founder of PyCon Korea. He has translated several programming books into Korean. You can get the full list on his website. You can also check his Github to see some of the projects he has worked on. Now let’s take a few moments to get to know him better! Can you tell us a little about yourself (hobbies, education, etc): I’m a Pythonista based in Seoul, Korea and leading engineering department in a video streaming company. I’m also actively involved in our community, especially in the East Asia region. I have served as a board director of the PSF for the 2016/17 term with nomination by Carol Willing. I started PyCon Korea for the first time in 2014 with several local community members here. I travel for 5 or 6 PyCons in a year with a nice PSF conference kit. I’m serving on the PSF Grants working group now. Continue reading PyDev of the Week: Younggun Kim →

Рефакторим код на Python с помощью тестов

В статье описан пошаговый рефакторинг кода с помощью тестов. Рефакторинг опасен при работе с непротестированным или устаревшим кодом, но тестирование поможет уменьшить количество внедряемых багов и при определённой доле везения избежать их вовсе.

home/2018/09/13/ff3bbf64e2064481faf164899f53b9bc01b783c6.jpg

Подкасты о Python: вот все, что мы нашли

Запрос “Алиса, что послушать о Python”, заданный Гуглу, скорее всего приведет вас в ступор, на статьи многолетней давности, которые не очень актуальны, либо на давно закрытые темы, которые просто нельзя (или некому) обновить. Так и родилась идея сделать список тематических аудио-видео-кастов и постараться поддерживать его в актуальном виде. Хотя бы год. Если вы читаете это в 2020-м, тоже стучитесь в личку или пишите о своем подкасте в комментарии — добавим.

Настраиваем Web Push Notifications использованием pywebpush шаг за шагом

Зачем еще одно руководство? Когда передо мной поставили задачу сделать черновой вариант push notifications, быстрый поиск показал, что на хабре уже есть много статей по настройке push notifications. Вот наиболее, на мой взгляд, годные: Как работает JS: веб push-уведомления Web PUSH Notifications быстро и просто924/ Service Workers. Web Push и где они обитают Это все прекрасно, но лично мне очень не хватало простого и понятного руководства, которое позволило бы сразу, практически методом копипаста сделать так, чтобы все сразу заработало. Ну и кроме того среди руководств нет адаптированного под бек на питоне. Настройка уведомлений в итоге заняла три дня и мне кажется, что это несколько многовато. Надеюсь, моя статья поможет кому-то настроить push notifications за три часа вместо трех дней. Проект, на котором я работаю, реализован на Django и описывать ход работы я буду применительно к этому фреймворку, но желающие легко адаптируют его к Flask или чему либо еще. Итак, погнали.

home/2018/09/13/42c2e14b224a9a8c7ee0dae5fde163b5e982208e.jpg

Python тоже частично отказывается от терминов master/slave

Политкорректность учитывается даже в языках программирования. На прошлой неделе Python-разработчик Виктор Стиннер (Victor Stinner) из Red Hat прислал четыре пул-реквеста на переименование потенциально оскорбительных терминов master/slave (хозяин/раб) в документации и коде Python. Автор предложил заменить их социально нейтральными словами, не оскорбляющими людей, чьи предки были настоящими рабами. В качестве возможной альтернативы есть термины parent/worker. Предлагаемое изменение — не какая-то прихоть одного разработчика, а общая тенденция для разных языков программирования и технологий. Стиннер привёл примеры аналогичных изменений в Redis, Drupal, CouchDB и Django. Так, Django и CouchDB заменили термины master/slave на leader/follower. При этом Стиннер высказал мнение, что «рабовладельческую» терминологию всё-таки можно оставить для некоторых терминов, таких как ветка master в Git, веб-мастер и postmaster. Развернулась жаркая дискуссия.

home/2018/09/12/e48c31799e847a0b93d0ae2e37afeb9ec8aaac8e.jpg

Logging in Python

Learn why and how to get started with Python's powerful logging module to meet the needs of beginners and enterprise teams alike.

home/2018/09/11/05027274acc5ed303adcf74a7a63d7ec8daf7a84.jpg

The Best Python Books

Find the right books to help you get started with Python or take your coding to the next level with this detailed guide to the best Python books out there.

PyDev of the Week: Oliver Bestwalter

This week we welcome Oliver Bestwalter (@obestwalter) as our PyDev of the Week! He is one of the core developers of the tox automation project and the pytest package. He is also a speaker at several Python related conferences. You can learn more about Oliver on his website or on Github. Let’s take a few moment to learn more about Oliver! Can you tell us a little about yourself? I was born in West Germany on Star Wars day the year the last man set foot on the moon. I took on my first job as a Software Developer when I was 39, right after earning my B.Sc. in Computer Engineering (in German: Technische Informatik). Although I fell in love with computering in my early teens and with the idea of free software in my early twenties, back then I was more into music, literature and sports. In school I was led to believe that I was “not good at maths”, so studying Computer Science or anything technical was not an option. Composing and playing music dominated my teens and twenties. I played several instruments (bass, guitar and keyboards – mainly self-taught) alone, and in different bands. A few recordings from that time are online on Soundcloud. When I was 28 I had a nasty skateboarding accident and broke my hand and elbow. This rendered me incapable of playing any instrument for over a year. I didn’t cope with that very well and descended into a deep crisis that led me to drop music and my whole social life which had revolved around it. At that point I was pretty isolated without any kind of formal education and honestly didn’t know what to do with my life. I took on a soul-crushingly boring job in the backend (read: loud and dirty part) of a semiconductor fabrication plant. Life wasn’t that great, but in my spare time I picked up my other passion again (computering) and used it to co-found and nurture a web based, not-for-profit support board. My co-founder happened to be a wonderful woman who later became my wife. So you never know what something is good for, I guess. I tend to turn my hobbies into my job as I did with music back then and with computering now. Good food & drink has occasionally passed my lips, which might be called a hobby, when it is not purely imbibed for sustenance. Enjoying modern art, mostly in the form of films, books, and (very seldom nowadays) computer games are also part of my recreational activities. I am more an indoor enthusiast, but I also might go for a walk now and then. Being more on the introvert spectrum, I need a lot of alone time to recharge, but I also like to hang out with my family and my cat (it might be more appropriate to say that the cat sometimes likes to hang out with us, because she adopted us and definitely is the one calling the shots). Continue reading PyDev of the Week: Oliver Bestwalter →

Python 101: Episode #24 – Debugging with pdb

Learn the basics of using Python’s built-in debugger, pdb. Note that this screencast was recorded before Python 3.6 and 3.7 so it does not cover some of the new enhancements in the debugger. You can read the chapter this screencast is based on here: http://python101.pythonlibrary.org/chapter24_debugging.html

wxPython 101: Creating a Splash Screen

A common UI element that you used to see a lot of was the Splash Screen. A splash screen is just a dialog with a logo or art on it that sometimes includes a message about how far along the application has loaded. Some developers use splash screens as a way to tell the user that the application is loading so they don’t try to open it multiple times. wxPython has support for creating splash screens. In versions of wxPython prior to version 4, you could find the splash screen widget in wx.SplashScreen. However in wxPython’s latest version, it has been moved to wx.adv.SplashScreen. Let’s look at a simple example of the Splash Screen: import wx import wx.adv   class MyFrame(wx.Frame):   def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial", size=(500,500))   bitmap = wx.Bitmap('py_logo.png') splash = wx.adv.SplashScreen( bitmap, wx.adv.SPLASH_CENTER_ON_SCREEN|wx.adv.SPLASH_TIMEOUT, 5000, self) splash.Show()   self.Show()     # Run the program if __name__ == "__main__": app = wx.App(False) frame = MyFrame() app.MainLoop() Here we create a subclass of wx.Frame and we load up an image using wx.Bitmap. You will note that wx.Bitmap does not actually require you to only load bitmaps as I am using a PNG here. Anyway, the next line instantiates our splash screen instance. Here we pass it the bitmap we want to show, a flag to tell it how to position itself, a timeout in milliseconds for how long the splash screen should show itself and what its parent should be. These are all required arguments. There are also three additional arguments that the splash screen widget can accept: pos, size and style. You will note that in this example we tell the splash screen to center itself onscreen. We could also tell it to center on its parent via SPLASH_CENTRE_ON_PARENT. You will, of course, need to modify this example to use an image of your own. Wrapping Up The splash screen is actually pretty useful if you have an application that takes a long time to load. You can easily use it to distract the user and give the illusion that your application is still responsive even when it hasn’t fully loaded yet. Give it a try and see what you think. Related Reading The wxPython SplashScreen widget documentation The original wxPython wiki page on the topic (uses the old widget) An old tutorial from Geeks with Attitude on the splash screen (also using the old version of the widget)

26 полезных приёмов и хитростей Python

Python — один из самых популярных и востребованных языков программирования. На это есть несколько причин:

Python 101: Episode #23 – Working with XML

Learn the basics of Python’s built-in XML modules, minidom and ElementTree. You can read the chapter this is based on here: http://python101.pythonlibrary.org/chapter23_xml.html or get the book from Leanpub: https://leanpub.com/python_101

home/2018/09/05/92e0b5c09d74ec8fae7e8b3daaf0d932949d5862.jpg

Conditional Statements in Python

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

Конференция PyCon Russia 2018: видео всех докладов и презентации

22-23 июля прошла шестая конференция для python-программистов PyCon Russia. Под катом — много видео, презентации и фотографии. А еще посмотрите отчетный ролик — в нем коротко о том, как прошел PyConRu-2018.

home/2018/09/04/92e0b5c09d74ec8fae7e8b3daaf0d932949d5862.jpg

Structuring Python Programs

In this tutorial you'll dig deeper into Python's lexical structure and start arranging code into more complex groupings. You'll learn about the syntactic elements that comprise statements, the basic units that make up a Python program.

PyDev of the Week: Aisha Bello

This week we welcome Aisha Bello (@AishaXBello) as our PyDev of the Week! Aisha is the founder of PyLadies Nigeria and is passionate about STEM in developing countries. She is also an organizer for DjangoGirls in Africa. Aisha has gone around the world speaking talking about Python at EuroPython, DjangoCon, Python Brasil and the PyData conferences. Let’s take a few moments to get to know her better! Can you tell us a little about yourself (hobbies, education, etc): Currently I work as a Virtual Systems Engineer in the Data Center and Virtualisation practice for Cisco, Nigeria. I completed a Masters in Information Technology from Cardiff Metropolitan, where I worked on a Data Science project for the hospitality industry. I am very passionate about women empowerment and tech education in developing countries. When I am not working you would catch me watching a movie, going for a gym class or exploring new places. Continue reading PyDev of the Week: Aisha Bello →

Пишем низкоуровневый отладчик под Linux на Python

Существуют отличные отладчики вроде GDB и LLDB. И хотя их можно настраивать с помощью скриптов, порой хочется иметь больше контроля над работой отладчика. В этой серии статей мы попробуем создать свой отладчик с помощью библиотек python-ptrace, pyelftools и distorm3.

Интересности и полезности python

Я уже несколько лет программирую на python, однако, недавно осознал, что множество полезных приёмов и интересных моментов прошли мимо меня, возможно, я не один такой, поэтому решил перечислить их здесь, надеюсь, данные приёмы пригодятся кому-то в работе или побудят познакомиться с этим языком поближе.

home/2018/09/01/5408c5335196b1e14186c34d8551773dba89b337.jpg

We're Celebrating 1 Million Page Views per Month!

Today we're celebrating reaching 1,000,000 monthly page views on realpython.com. We are so thankful to you and the rest of the Python community for helping us reach this milestone!