Start Reading

#6 Python 3.6 is going to be awesome, Kite: your friendly co-developing AI

Ratings:
0 page

Summary

This is Python Bytes, Python headlines and news deliver directly to your earbuds: episode 6, recorded on Monday, December 12th. In this episode we discuss why Python 3.6 is going to be awesome, kite: your friendly co-developing AI, and more!

This episode was brought to you by Rollbar: they help you take the pain out of errors.

This is the last episode of 2016. Thank you everyone for a great launch. We’ll be back early January. ? Be sure to check out Talk Python and Test and Code if you want more Pythonic listening over the break.

News items

#1 Make your Python code more readable with custom exception classes


This is a 5 min video + text. Good introduction into why you should define your own exceptions instead of using the built in ones, and how to do it.

It makes errors from your code more readable.
Better communication between your code and the person using your code.
It allows you to give more context of the error to the caller of the function.
Remember to derive from Exception or from another builtin exception.

Do people create enough fine-grained exception types? I would say probably not.
This advice is good because it encourages EAFP (easier to ask for forgiveness than permission) style of programming which is generally Pythonic.
Allows for multiple except statements for different errors in one try block
Dan also featured our show in The ultimate list of Python Podcasts (thanks Dan!)
If you have a package that defines it’s own exceptions, please read another article.

The definitive guide to Python exceptions

Julien Danjou
https://julien.danjou.info/blog/2016/python-exceptions-guide
Covers having a common base exception for your package, organization within a package, and some examples of packages that organize their exceptions well, including requests




#2 Kite


Kite augments your coding environment with all the internet’s programming knowledge.
Is an AI pair programmer, or mentor really.
Contextual info for

language
packages
e.g. “import r” → shows list of popular packages
then detailed docs, examples, etc.
autocompletions… by global popularity
BYOE
even works on your code
be sure to watch the video

kite.com is implemented mostly in Go according to the founder Adam Smith.
Thanks Gilberto Diaz for sending this one to us.


#3 Tidy Data in Python (by Jean-Nicholas Hould)


This article caught my attention because of the notion that the data as you receive it might not be in a form that is ideal to use it. This I am used to. But the article give some attributes of what problems to look for in data sets, and how to transform the data into a more usable structure using pandas.
Great example of someone taking a good idea from someone else, summarizing it, and showing how to use it in Python.
Based on a paper named Tidy Data by Hadley Wickham

In this post, I will summarize some tidying examples Wickham uses in his paper
Will demonstrate how to do so using the Python pandas library

Tidy data has the following attributes:

Each variable forms a column and contains values
Each observation forms a row
Each type of observational unit forms a table

A few definitions:

Variable: A measurement or an attribute. Height, weight, sex, etc.
Value: The actual measurement or attribute. 152 cm, 80 kg, female, etc.
Observation: All values measure on the same unit. Each person.



#4 What's new in Python 3.6


By Brett Cannon

Works at Microsoft Azure Data Science team
Python core developer

16 PEPs in Py3.6 - more than any other release than Py 3.0
PEP 498 Formatted string literals

You learn about internals
That this is actually faster than str.format() because optimizations that can be done on the string itself (f””)
PEP 524: On Py 3.5 would fall back to unsecure. On Py 3.6 os.urandom() now blocks os.urandom() for cryptographically strong random numbers or os.getrandom() raises error if not enough randomness. Usually not a problem, but with things like containers and IoT, it has become one! Fix: use new secrets module.

Ther

Read on the Scribd mobile app

Download the free Scribd mobile app to read anytime, anywhere.