Discover this podcast and so much more

Podcasts are free to enjoy without a subscription. We also offer ebooks, audiobooks, and so much more for just $11.99/month.

Unavailable#135 macOS deprecates Python 2, will stop shipping it (eventually)
Currently unavailable

#135 macOS deprecates Python 2, will stop shipping it (eventually)

FromPython Bytes


Currently unavailable

#135 macOS deprecates Python 2, will stop shipping it (eventually)

FromPython Bytes

ratings:
Length:
32 minutes
Released:
Jun 20, 2019
Format:
Podcast episode

Description

Sponsored by DigitalOcean: pythonbytes.fm/digitalocean

Special guest Max Sklar

Brian #1: Why do Python lists let you += a tuple, when you can’t + a tuple?


Reuven Lerner


>>> x = [1, 2, 3]
>>> b = (4, 5, 6)
>>> x + b
Traceback (most recent call last):
File "[HTML_REMOVED]", line 1, in [HTML_REMOVED]
TypeError: can only concatenate list (not "tuple") to list
>>> x += b
>>> x
[1, 2, 3, 4, 5, 6]



Huh??
“It turns out that the implementation of list.__iadd__ (in place add) takes the second (right-hand side) argument and adds it, one element at a time, to the list. It does this internally, so that you don’t need to execute any assignment after. The second argument to “+=” must be iterable.”


Max #2: R vs Python, R is out of top 20 languages despite statistical boom


Subtitle: is R declining because of Python?
First of all, this article is about an index on the popularity of programming languages from an organization TIOBE. They have an index on the popularity of programming languages. Obviously it’s a combination of many different scores, and that could be controversial, but I’m going to assume that they put some thought into how the rankings are calculated, and that it’s as good as any.
A few stories here: first Python hit at all time high in their ranking at number 3, beating out c++ I believe for the first time, and only Java and C are above it.
The other story is that the statistical language R dipped below 20 to number 21, and the speculation is that Python has sort of taken over as the preferred statistical language to R.
Personally, I got into Python much sooner, because I started as a software engineer, and moved into data science and machine learning. So after taking CS, and programming in Java and C for a few years, python came much more naturally.
But still - a lot of people who are data-science first (and they have an additional skills to the kind of hybrid that I am) like and prefer R, and they can use it in a specialized way and get good results.
Personally, I’m going to stick with python, because there’s so many statistical libraries yet to learn, and it’s served me well thus far.
The language I’ve used most in recent years, Scala, is surprisingly down at 31 - not even close!
related: https://www.zdnet.com/article/programming-languages-python-predicted-to-overtake-c-and-java-in-next-4-years/


Michael #3: macOS deprecates Python 2, will stop shipping it (eventually)


via Dan Bader, on the heels of WWDC 2019
“Future versions of macOS won’t include scripting language runtimes by default”
Contrast this with Windows just now starting to ship with Python 3
In the same announcement:
“Use of Python 2.7 isn’t recommended as this version is included in macOS for compatibility with legacy software. Future versions of macOS won’t include Python 2.7. Instead, it’s recommended that you run python3 from within Terminal. (51097165)”
Also has impact wider than “us”. E.g. No Ruby or Perl, means home brew doesn’t install easily which is how we get Python 3!


Brian #4: Pythonic Ways to Use Dictionaries


Al Sweigart
A few pythonic uses of dictionaries that are not obvious to new people.
Use get() and setdefault() with Dictionaries

get(key, default=[HTML_REMOVED]) allows you to read a key without checking for it’s existence beforehand.
setdefault(key, default=[HTML_REMOVED]) is a bit of a strange duck but still useful. Set the value of something if it doesn’t exist yet.

Python Uses Dictionaries Instead of a Switch Statement

Just do it a few times to get the hang of it. Then it becomes natural.

Michael's switch addition for Python: https://github.com/mikeckennedy/python-switch


Max #5: Things you are probably not using in Python 3 But Should


This is from Datawhatnow.com
This is particularly relevant for me, since I used python legacy at Foursquare for many years, and now coming back to it taking another look at python v3.
One that looks very useful is f-Strings where you can put the variable name in braces in a string and
Released:
Jun 20, 2019
Format:
Podcast episode