Python Bytes - #36 Craft Your Python Like Poetry and Other Musings
Episode Date: July 28, 2017Topics covered in this episode: Craft Your Python Like Poetry The Fedora Python Classroom Lab How a VC-funded company is undermining the open-source community Newspaper Python Package IEEE Spectrum...: The Top Programming Languages 2017 SciPy 2017 videos are out Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/36
Transcript
Discussion (0)
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 36, recorded July 26, 2017.
I'm Michael Kennedy.
And I'm Brian Ocken.
And we've got some great stuff lined up for you.
Very cool news in the Python space.
Before we get to it, I just want to say Rollbar is sponsoring this episode.
They've got a really great offer for you at pythonbytes.fm slash roll bar tell you more about that later right now brian i would like you to tell me
some poetry read me something beautiful so it's poetry hour at python bytes no
i started out at community college and then i switched to a university of oregon to start the
computer science program and one of the first classes I was in, before we got into like actually the technical stuff, my professor said, you need to
think about your code like poetry. It should be pretty to look at. And it's kind of stuck with me.
I like that lesson. This article, there's an article by Trey Hunter, and it's called
craft your Python like poetry. Just some decent advice. Your,
your code shouldn't really look like, um, prose from a novel. It should look more like poetry
and be, and it's not just pretty for pretty sake. It's more readable when, when it's visually
appealing, I think. And he brings up a line length is important, although shorter is more readable.
But, man, he recommends 55-character line lengths, and that's pretty short.
I think there's a real tension in this one, although I do agree that line length matters,
and I prefer to have shorter is better in some ways.
However, one of the real tensions I find here is another good practice is to have descriptive variable names.
And sometimes that means longer than X, Y, and Z for your variable names.
And if you start doing expressions involving those like this times that past this, that can get them huge really quickly just by virtue of putting long function names alongside long variable names.
Yeah.
There is some tension there. And also, in like, working with data and tables and stuff, I do find tables that look like tables instead of looking like,
crammed all the way to the left hand side are more visually readable. Anyway, getting over the line
length thing. He does have a lot of good comments about like when when you do have to continue a line to make it shorter like do a line break where you do it is makes a big difference
and he has some examples to make making a line break or broken comprehensions and more readable
and function call parameters and then one of the things i think maybe this is a functional
programming thing but uh chained function calls I probably just don't do that very much.
But the dot alignment he noted looks pretty nice. The last one that I saw, which I kind of do
anyway, I didn't realize that some people don't do this, is dictionary literals. So if you set up a
dictionary that's kind of like an enum list, it's a basically just
a predefined dictionary literal, having one element per line makes it a lot more readable.
But then there's, you know, there's always trade offs. There's a, if you've got a really large one,
there's vertical, vertical length is important as well. And having a super long program
might not be as easy to read as a shorter one.
I don't know.
Yeah, I'm with you on that.
Let me throw in one more that I don't think is covered in here.
Maybe I just missed it.
It's function length, right?
Just the idea of breaking your program into little tiny bits, little small, reasonable, easily understandable pieces, you know, kind of like a haiku, I guess, rather than a long, flowing poem.
Right, and also, I guess on that, it doesn't talk about white space too much,
but there's white space even within a function,
breaking up the different parts of when you're working with setting up the data
versus other things to break it up by white space,
similar to how long poems are broken into little stanzas or something.
Yeah, you know, thinking about this, one of the things that strikes me is the way that your code looks and breaking it down like this
and kind of thinking about it this way,
it's a big sign of sort of professional developer versus somebody just learning,
somebody just poking around who's not really a developer.
Like professional developer's code looks like these types of things.
It's clearly structured beyond just what the language requires.
And a lot of times people are new.
They just kind of mush it all together.
So if you're looking to come across better with your code, I guess,
think about that as well.
Yeah.
Okay.
Yeah. Okay.
Yeah.
So I want to bring everyone's attention to this thing called Fedora Python Classroom Lab.
Okay.
So the idea is Fedora, it's a Linux distribution, really nice one. And what they've built is basically Python and data science, Python-based data science in a box.
Or rather, in an ISO.
What you can do is you can get just the ISO DVD image of this Fedora Python classroom.
You can mount it and literally just boot straight to this thing.
It fires up Fedora, and you can log in without even installing it. Log in, you have access to NumPy, SciPy, IPython, Matplotlib, requests,
all the various most common packages, and it's just up and ready to go.
So that's really sweet.
You have the GUI GNOME-based version, or you have a Docker or Vagrant, no UI variant.
So all sorts of stuff is just set up and ready to go.
So if you're going to teach Python
and you're thinking of maybe using Linux to do it anyway,
here's a really nice thing you can hand out to the students
and just say, boot from this DVD or this image
or create a virtual machine based off of it,
and you're ready to roll.
Oh, that's cool.
Yeah, I originally thought this was a thing I downloaded inside Fedora
and logged into Fedora.
I'm like, wait, where's all this stuff?
Oh, it's actually its own copy of Fedora.
So this is its own Linux plus pre-configured Python stuff.
Wow.
Yeah, that's pretty cool, right?
Yeah, everything, including talks in there.
Nice.
Yeah.
It's all ready to roll.
Multiple versions of Python, everything.
So you have some less than amazing news for what's up next.
So we previously talked about this really cool concept called Kite, which it would take your code and it would take a lot of stuff you would do as a developer on your system and it would add smart, right?
It would add auto-completion even where there wasn't.
And these types of things.
But it turns out there was a few drawbacks just conceptually around it. But there's also a bit of a toss-up about actually their behavior.
What's up with this?
Yeah.
So I was, especially because we had covered it,
my reluctance to this product to start with was that they would,
it's all cloud-based stuff so they would
send your code in order to give you hints and stuff it would send your code to their their
company and then uh and you just kind of have to trust that they're not going to do anything evil
with it yeah i was a little reluctant at that as well like if when i was playing with it i put it
on a section you can say this subset of your hard drive it can like interact with.
And I gave it a section where I didn't have like things that had, you know, API keys and stuff.
It was just like me playing around.
But still, it is a bit of a hesitation.
But that's not really what we're talking about, is it?
No, what we're talking about, there's an article that came out on, I'd never seen this site before, theoutline.com, which is an article called
How a VC-Funded Company is Undermining the Open Source Community.
And it's about some underhanded, or at least some accusations of underhanded tactics by
Kite.
So the story is, it's about two add-ons to Atom, the text editor Atom.
And one of them is Minimap, which is supposedly downloaded over three and a half million times, so it's well used.
And it's developed by one person.
And I'm guessing Minimap is similar to the map feature in Sublime or something. But the one developer, Abe33, was hired by Kite. And then after being hired by Kite, inserted a or updated the plugin with a Kite promotion feature.
That was actually the Git commit log was added Kite promotion feature or something like this, right?
Yeah. feature was to insert web links or links back to articles on the kite website related to the
content of a user's code so read the code figure out which article would be relevant and put links
i'm guessing the links go in the mini map and not actually inserted in your code hopefully but the
users uh were rightfully kind of ticked about this
and said, this isn't a feature.
This is just blatant advertising.
Well, I think there's two levels here.
On one hand, the person who added that feature
was the creator of the product, right?
So that's not great.
If some other random person had come along
and inserted this promo stuff
into someone else's open source project, that would have been flat out terrible.
This is, let's say, a little shady, I would say, in the spectrum in my mind.
This is like, it's not, there's no point, well, there's very small points where this is actually going to benefit the users other than the one user who is kite. Yeah. Now, if it was possibly suggesting
lots of different articles from different websites, it still would be weird. It's a
completely unrelated thing, feature of it. I don't know. The next one is, I had to look it up,
but it's another Atom add-on, which is Autocomplete Python.
So that definitely relates to Python.
But it didn't insert advertising.
But what it did do was it had the Autocomplete was done using a local engine on the user's computer called Jedi.
And it got switched at one point to default to the Kite engine, which is a cloud-based engine.
So it would send all your code to Kite.
Kind of, if somebody updated that plugin, I don't think they would know that that was going on.
Yeah, how would you even know, right?
I mean, look, the autocomplete's still working.
Oh, wait, it's because my code's no longer on my machine.
How strange.
And apparently this wasn't done by, I'm not sure who put that feature in, but the article suggests
that instead of a purchase of the, or a hire by Kite, it was just a bunch of Kite people were
working on the plugin also and added this. Again, users aren't, a lot of users weren't exactly
supportive of that change. And it is a bit weird.
And basically, I think the point of this article is to point out that we've got a lot of open source projects that are used by a lot of people, like a whole lot of people. person, core person to be corrupted or influenced to basically make the package benefit a single
company instead of the rest of the world, which, yeah, it's problematic and interesting.
Yeah, it definitely raises some interesting moral issues around open source.
And what does it mean to make these types of changes when there's 3 million people already using your product,
especially if those changes are invisible,
if that means like privacy changes,
like your code is now going and being analyzed
outside of your control
rather than when you thought it wasn't, things like that.
Yeah, like that autocomplete thing,
what I guess I would have expected as an open source user
is I don't care really if a company has a has an open
source projects that that they're maintaining that benefit their company we're kind of used to that
and and that's not terrible but it's very out in the open so I would kind of would have expected
them to like fork that project and have a different autocomplete project that would go to the kite
instead of using Jedi,
that would have made more sense to me. Right. Then you opt in. Yeah. If you opt into it,
you get better autocomplete. You might make that trade off, right? Yeah. But anyway. Yeah. Anyway.
All right. Well, there it is. Everyone else, everyone can read it for themselves. It's a
pretty interesting article there. So something I am much more comfortable with using on my projects is Rollbar.
So you guys probably heard us talk about Rollbar before. It's super easy to integrate into your
system. You just pip install Rollbar and plug in your account key and you're basically ready to go.
The idea is it will look at your code, especially your web apps while it's running. And if there
are any errors, it will capture all the details about the errors send it up to the cloud send you
notifications like to slack or you can get like emails things like that and
usually don't even have to debug your code you can just log in see all the
variables past the whole call you know call stack things like that and just go
and fix it so half the time it's really important to be notified right away
when an error is happening rather than letting it go on for hours
and finally somebody will vaguely send you a message like,
this button doesn't work anymore.
What do you mean it doesn't work?
So pip install Rollbar and you'll be ready to roll.
Check them out at pythonbytes.fm slash Rollbar
and use it on pythonbytes.fm and other sites. It's great. So thanks, Rollbar. Thankm slash rollbar. And it's, I use it on Pythonbytes.fm and the other sites.
It's great.
So thanks, Rollbar.
Thank you, Rollbar.
You know, the news has been,
journalism in general has been more interesting
in the last six months, I would say,
than it traditionally has.
Yes.
And the thing that I want to talk about is like,
let's say maybe a specialized screen scraping
type of library called newspaper.
So this is a Python package, pip install newspaper type of thing. And the idea is you can point this
at a URL for say like CNN or MSNBC or New York Times or something like that. And it will give you
very detailed information that you might care about for news articles.
Have you heard about this, Brian?
I haven't.
Yeah, this is really slick.
So I'll just give you like a little sense of the code
because there's just a few steps.
You're like, wow, that's sweet.
So you create this article object
and you pass it the URL to like some news item.
You can download it and it'll just give you the content.
You can parse it and then you can ask you the content. You can parse it.
And then you can ask it things like, who were the authors?
And it will just give you a list that are just the names of the authors that already discovered.
You can ask it when it was published.
You can do NLP, natural language processing on it.
Just that's a function, call that.
And then you can ask, what are the keywords?
Give me the summary of this article.
What is the cover image of this article?
All sorts of stuff like that.
This is really cool if you work with news-type data.
Yeah, this is great.
Isn't that cool?
Yeah, especially if you tie it to other ways,
you're going to get different news articles to be able to parse some of this as a little service.
It'd be cool.
Yeah, and I don't remember where you pointed to to get started,
but you can also say,
what are all of the articles on this new site?
And then go ask these questions about each article
and things like that.
So it's pretty slick.
I like it.
Yeah, it's a little bit of that import anti-gravity type thing.
That's right.
Definitely.
I typed a few lines and it's rolling.
Speaking of that, that might be...
But before we move on, the code example you talked about,
you put it up on our show notes,
and it really is just like 17 lines of code.
It's pretty short.
Yeah, and like half of that is like showing you what's printed out.
Yeah.
Or maybe not half, but some of that.
So this sort of really, this ability to grab these packages
and do amazing stuff in a few lines of code, maybe that's why Python's popular.
What do you think?
Yeah, I think so.
And we've gotten, there's an article from IEEE Spectrum called the top programming languages of 2017.
And big surprise, we're number one.
Yay.
We're number one.
Woohoo.
Yeah, it's really cool.
And it's number one in a lot of interesting ways.
There's actually five measures, four of which mean anything to me.
One measure is the IEEE spectrum ranking.
One is trending.
One is jobs.
And one is open.
And so it's kind of, you can go over this like interactive thing.
The IEEE spectrum rating is all around.
Trending is languages that are growing rapidly.
Jobs are languages that are in demand by employers.
And open is popular on open source hubs.
Yeah.
You can also dig into it by embedded devices and things like that.
And it even, this is an interactive thing.
You can even like customize your ranking for what's important for you which is kind of fun right like
i care about enterprise development and jobs or something like this and you can like narrow that
down it's definitely interactive so let me give you the let me give you the numbers brian so for
trending number one is python close behind a c and c plus plus and then java so and swift is there as
well and then for jobs actually Python is number three,
but just like by 0.7%.
So it goes Java, C, and then Python.
And then for openness, Python is way back on top.
And then custom, whatever that means.
Let's make your own.
Yeah.
Yeah, and my comment, I think that the reason why there's more Java jobs
is because there's a whole bunch of Java programmers shifting to Python.
Right.
Like there used to be a lot of COBOL jobs.
But now COBOL's growing.
It's because people got to keep that stuff going.
COBOL's still on the list.
Wow.
It's 24th in jobs.
Yeah.
Man, that puppy's hanging in there.
Poor people.
Yeah.
But assembly is like 11th.
Wow.
Okay.
Anyway.
Interesting.
Yeah. yeah but assembly is like 11th wow okay anyway interesting yeah so there's all these different all these different measures and rankings and they all take different things into account so
you got to take that with a bit of a grain of salt but the one trend that seems to appear across all
of these is python is very high on the list and is growing more popular higher up on the list so
that's great thing for betting your career your next bit of career and your energy on focusing on Python, I think.
Yep. And also IEEE is respected by a lot of people,
but they also right here openly show you
what they used for their methodology of how they rank things.
And it's nothing surprising,
combination of Stack Overflow and Trans and Twitter,
and including articles in their IEEE Explore digital library.
So that's not surprising, but it's cool that they just show you what all those are.
Right. So when they say it's popular in jobs, that means because they're crawling Stack Overflow jobs,
probably CareerBuilder, Dice, those types.
Yeah, I didn't know Dice was still around.
But no offense to all the dice
myspace is still around myspace
aol is still around okay so last thing i want to share with you guys is recently the sci-fi
2017 conference happened in seattle here in the u. And like many of these conferences, the videos and tutorials
were recorded, put on YouTube, and you can go check them out. So there's a ton of tutorials,
if you want to get into data science, the keynote was something I haven't had a chance to watch it
yet. But it sounds really interesting coding for science and innovation, like who wouldn't want to
do that? That sounds awesome. Yeah, then we've've got dash which we've talked about you've talked about before a new framework for building
yours user interface and technical computing stuff and then similar spelling totally different
thing is dask for like parallelized processing data pipelines we've got scientific analysis
at scale a comparison of five Systems with Jake VanderPlas,
and Academic Open Source,
which I think is pretty cool for groups,
people in that area.
So tons and tons of videos.
These are just a few I grabbed to give you guys a flavor of what's out there.
Yeah, that was in Seattle.
Man, I wish I would have gone.
Yeah, I know.
I was planning on going,
but I couldn't quite make it.
Yeah, I'm glad the-
A little too hectic at the time.
I'm glad the videos are out there.
I'll have to check some of those out.
Yep.
And I think I just got a notice
that PyCon Canada call for proposals
opened today or yesterday.
So speaking of conferences,
if you want to speak at the other major,
major Python conference in North America,
it's time to submit the proposals.
Do you know which Canada it is?
The left Canada or the right Canada?
I think it's the right Canada. It's in Montreal.
Okay.
Alright, well that's it for our news, Brian.
Anything else you want to share
with everyone? I am
closingly done, almost done
with the book. I wanted to try to get it
done last night at midnight, but I've
got a few hours left, but I I'm super excited to get the Python testing book wanted to try to get it done last night at midnight, but I've got a few hours left, but I
I'm super excited to get the Python
testing book out to everybody.
Yeah, and that's been a
big success. People are responding well to it,
so congratulations. Thanks. Yeah.
How about you? Nothing too new, just
cranking along. Yeah.
Bunch of stuff's going on. Enjoying summer.
Enjoying working on Python stuff,
but nothing specific.
Speaking of summer, you've got a vacation coming up.
I do.
I have a semi-work-travel vacation, more vacation-ish stuff.
So I'm going to be out for four weeks.
Probably not next week, but the week after.
So we're going to see what we can do about lining up some guest co-hosts.
Keep the show rolling.
No concrete details there, but well at the very there may be yeah
at the very least we'll have one more episode and there may be a gap but we're going to try to not
have a gap we're going to try not to have a gap that's right well we'll see what we can do about
recording either on the road or or um wrangling some people into uh being a co-host so we'll see
we'll keep it rolling as best we can all All right. All right. Well, thanks, Brian.
Thanks, everyone, for listening.
Yep.
Bye.
Thank you for listening to Python Bytes.
Follow the show on Twitter via at Python Bytes.
That's Python Bytes as in B-Y-T-E-S.
And get the full show notes at PythonBytes.fm.
If you have a news item you want featured, just visit PythonBytes.fm and send it our way.
We're always on the lookout for sharing something cool.
On behalf of myself and Brian Auchin, this is Michael Kennedy.
Thank you for listening and sharing this podcast with your friends and colleagues.