Write Pythonic Code Like a Seasoned Developer Transcripts
Chapter: Python for Humans
Lecture: Human Python as a stand in for packages in general
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Let's round out the course with a little bit of Python for Humans,
0:03
and that's a bit of a play in words from some of the most popular
0:07
open source projects that really add power to Python.
0:11
This section we are going to look at two separate external packages
0:15
and how simple and lovely they make it to work with certain types of data
0:19
and we are going to do this because it really is meant to be a stand-in
0:22
for look at open source, look at PyPi and look to the community
0:27
and ecosystem before you start working on your project
0:31
for all the things that you can build your project from.
0:34
There is an amazing set of lego blocks out there
0:36
all you have to do is know to reach for them.
0:38
So if you find yourself thinking "hm, how am I going to
0:41
implement this bit?" of whatever subsystem you are working on in Python,
0:45
stop and do a little research first.
0:47
For example, if you are going to work with user accounts,
0:50
and you need to store user names and passwords,
0:53
you hopefully know that you should hash those passwords.
0:57
Did you know you should use separate salt per user
1:00
to go into hashing their password?
1:02
Did you know that you should fold that hashing over and over and over again
1:05
to make it computationally difficult?
1:08
Not five times or ten times but something like a hundred thousand times.
1:11
So if you are thinking oh my gosh, this is going to be a lot of work,
1:14
that's one way to think about it, the other one could be "oh,
1:17
there is a really great library for exactly that thing called passlib", go grab that, OK?
1:21
So when we look at these two packages yes,
1:24
it's great that you know about them,
1:25
but the most important takeaway is not the details of the two packages
1:29
we are going to focus on, but really the concept of there are so much out there
1:33
to work from you really should start there.
1:37
Right, so the first place to look is probably PyPi,
1:39
the Python package index and you can see at the time of this recording,
1:43
there is 82 000+ packages there, so about 300 new unique packages a day,
1:49
and the power of what's available here really is the main reason
1:53
why Python is popular.
1:54
Another really important place to look for Python libraries and tools is of course GitHub.
2:00
So there is this really cool site called GitHut.info, let's check that out quickly.
2:05
So here you can see, these are all the popular languages on GitHub,
2:10
and here is their active repositories, the total number of pushes, number of forks,
2:14
how recent it was, what year it appeared and you can actually hover over these
2:17
and it tells you all sorts of things,
2:19
so for example we could compare say Python to C#, to Ruby
2:25
and you can see that Python is more popular than Ruby, way more popular than C#,
2:30
anyway, GitHub is such a central part of modern software development
2:33
and look where Python lives, we have Python,
2:36
we have Java, and we have Javascript.
2:39
Now, my interpretation of this data is that Javascript is not really earning its position here,
2:45
I think this counts the Javascript that are in the Java websites, the Python websites,
2:50
the PHP websites, the Ruby websites, the C# websites, and so on,
2:54
so I think Javascript is being over counted here, so either way,
2:57
Python is either 3 or 2 on this list, so certainly, look to GitHub,
3:01
look to PyPi for your packages and your features
3:05
before you just write the whole thing from scratch,
3:08
remember, Python comes with batteries included,
3:10
these two places are often where you find those batteries.