The key to making anything a habit, including learning a program, is to make it fun.
That's exactly what Annalena Pupkes did with her 100 Days of Code Challenge.
She created a magical universe where Python-derived creatures and castles live.
Join us on this episode as we explore some of the Python concepts she encountered on her journey,
as well as how she made her way to Microsoft Research in the UK, where she's doing an AI residency.
This is Talk Python to Me, episode 186, recorded November 13th, 2018.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy.
Follow me on Twitter, where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
This episode is brought to you by Coder.com and us at Talk Python Training.
Annalena, welcome to Talk Python.
Hi. Nice to meet you.
Nice to meet you, as well. It's so great to have you here.
And I'm really looking forward to our topics.
We're going to talk about your 100 Days of Code project and its interesting angle.
And then a little bit about what you're doing with machine learning as well, because I think that's super interesting.
But before we get to the stories, let's start with yours.
How did you get into programming in Python?
So I got into programming way too late, in my opinion.
So I was studying cognitive science in my undergraduate degree in order to become a neuroscientist.
And at the very end of the program, I attended an intro to machine learning lecture.
And I became so fascinated by the idea that you could have algorithms that are able to learn from data and detect patterns and then even make predictions on data that I decided to switch fields.
So I looked for a computer science graduate program that would allow me to focus on machine learning.
And of course, I had to start programming.
So I looked for a suitable programming language.
And when I tried out Python, I knew that it was the perfect choice.
So I really liked that it was so easy to get started with, that it has such a nice syntax.
And it's, yeah, it's just so readable.
Yeah, it's, I think it's very approachable for beginners because it doesn't have all those symbols that look super scary, right?
You're like star, star, you know, void, star, star.
You're like, whoa, what is this crazy stuff, right?
I agree.
Yeah.
And since then, I've been working with Python almost all the time.
So it's really nice.
Yeah, that's great.
I think, I don't know if you were just very smart or very lucky, but having chosen Python is perfect for machine learning, right?
I mean, it's exactly where most of the action is these days, right?
What other languages were you considering?
Oh, that's a good question.
I don't even remember.
My brain is like a thief sometimes.
So I'm sorry for that.
I think I did my research and there were quite a, I think I looked into R for a while, which was popular for data science.
But Python is just like a general purpose programming language.
And I just liked it a lot.
So I decided to stick with it.
Yeah, I think that's a really great choice.
So you were studying cognitive science previously.
And then you decided to just jump into programming.
How hard was that transition?
Really hard?
Was it scary?
Well, yeah, it was really scary since I started the computer science graduate degree, which is usually not intended for people who have no idea about coding.
I would think of a computer science graduate degree.
Yes, exactly.
So I was lucky that I found a graduate program that you could do without a corresponding undergraduate degree.
But in the beginning, I had to do so many things at my classes.
And I had all the assignments that required coding, but I had to study the coding part at the same time.
So I basically just left out all the classes that weren't using Python and just used the ones such that I could focus on studying one programming language.
But it was hard.
But it was definitely worth it.
So it was the perfect decision for me.
I'm really happy right now.
Oh, that's awesome.
Yeah, and you're doing such cool stuff, which we'll get to in detail later.
But I think it's really admirable that you were able to do that.
Like you saw what you wanted and you just took a turn.
I think there's a real fear when you get really good at something or you're about to get your degree in something or you're even a professional in it to make a change.
Because maybe you think you'll like that thing more, but you don't want to give up what you've earned in terms of knowledge.
Exactly.
It can be quite scary, especially when you spend quite a few years on learning about all the other stuff.
So how much does the cognitive science, neuroscience stuff still factor into what you're doing?
I think it factors in indirectly sometimes so that I think when I see the algorithms, I sometimes think about, hey, how is that implemented in the brain?
Or do we even know whether there is an equivalent thing in the brain?
And I still study or read articles on cognitive science since I'm just really fascinated by how the whole power of the way, where the power of the brain comes from and how the brain is working.
So, yeah, many machine learning algorithms are actually based on the brain, for example, like neural networks.
Right.
At least the original ones.
Yeah.
They've gone a long way since then, right?
You've got deep learning models and all that.
But it is very similar.
You know, I work for my first programming job was at a company that was a startup that was a spinoff from a cognitive science research lab in California.
And it was just such a cool place to be there.
A bunch of cognitive science PhDs and a couple of programmers.
And we were just building fun software to explore and test some of these ideas.
And I think cognitive science doesn't get enough credit in terms of how much programming and technology happens there.
Yeah.
It's a very, very fascinating subject.
Yeah, it definitely is.
So, I remember good times there as well.
Okay.
So, speaking of machine learning and neural networks, what are you doing today?
So, I'm currently at Microsoft Research in Cambridge in the UK.
And I'm an artificial intelligence resident.
So, that's like an educational program.
We're about 20 people.
And the overall goal of the program, I would say, is to teach us all the necessary skills to become great research engineers.
So, I work on a project that is based on applying Bayesian learning to healthcare data.
But, of course, there are lots of projects within Microsoft here in Cambridge that work on lots of different stuff.
So, yeah, during the day, I usually try to understand how the algorithms are working and try to figure out the math to actually implement them afterwards.
That sounds so interesting.
You know, I think I was really surprised to learn about Microsoft Research and how many PhDs they have there and how much research is actually happening at Microsoft Research.
So, this lab here in Cambridge is really a research lab.
Microsoft does a lot of work on customer projects and so on and products, of course.
But this research lab here is about 200, 250 people, of which I think 150 are really working for Microsoft Research in Cambridge.
They're always temporary people, interns, and so on.
And I think, or I don't know how many of those are really researchers, but there are also, of course, a lot of software engineers and research engineers and maybe about 80 researchers.
But that's just a guess.
I would have to ask about the number.
And that's just Cambridge, right?
Yes.
Yeah, that's just Cambridge.
So, I think I saw a presentation somewhere where they were saying Microsoft has more PhD researchers than Stanford or something insane like that.
You know, it's just like –
Yeah.
It's really –
Yeah, they are huge.
It's really huge.
And so, there's a lot of stuff going on.
I'm sure that's a super exciting place to work and AI as well as a big research area.
I didn't know that Microsoft was doing so much research in AI before I started the program.
So, I was surprised, too, that they were so active and had so many interesting projects going on.
Yeah.
So, when you were doing your cognitive science stuff before you got into programming, did you see your career, or at least at the moment, being working at Microsoft?
No.
Not at all.
I never thought about myself getting into computer science.
That was really so far from what I had planned.
Yeah.
I think it's really cool, though, that you were able to find your path into it.
Yeah.
Okay.
So, let's talk a little bit about this 100 Days project.
I think – you know, I first saw about it because people were talking about it on Reddit.
And it was just so – you know, it was such a unique take on it, and people were so excited about it.
So, it started out as 100 Days of Code with a Harry Potter theme.
But it turned out you had to cancel the Harry Potter part, right?
Yes.
Regrettably, I had – like, Harry Potter is so heavily copyrighted, and there are so many licenses and so on that it wasn't a safe thing to do to stick to the Harry Potter one and use all the names and places and so on.
So, now you have a Harry Potter-inspired 100 Days of Code project.
Exactly.
Yes.
So, I came up with my own little magical universe, which was actually quite a lot of fun, too.
I bet it was.
Instead of just copying what they got, right?
You're like, forget it.
I'm going to make my own space.
You could spend time on researching names and what they mean.
And, yeah, there's so much stuff on the internet.
It's amazing.
Yeah.
That's great.
So, let's start with 100 Days of Code.
Just what is it?
I know some people know it.
Many people have probably seen it go by on Twitter because that seems to be where people put all of their – I'm on day 92 and this is what I did, which is great.
But maybe they don't know the real history and details.
Tell us about it.
I think you might be the expert on the real history behind it.
But I heard on it on your podcast for the first time.
So, that you basically spent 100 days each day on learning about new coding stuff and really spent every day.
I think the original one was 30 minutes coding.
I adapted it to 15 to fit my needs.
Yeah.
And, yeah, and then really spent the time, those 100 days, to learn a lot of new cool stuff.
I think it's such a cool idea.
Just, you know, you're going to spend some time every day.
And I think – I don't know if this was conscious as part of it, but I think one of the underlying ideas here is that we often overestimate what we can do in a couple of days or a week.
We think we can do a bunch and not really.
But we really underestimate what we can do in the long term in three months or six months in a year.
You can make way more progress.
And I think the underlying idea of 100 days of code is you put in the time and you build the sort of the habit of doing that for over three months.
And by the end, you're like, wow, look what I did.
Yeah.
Yeah, the habit building is a big part of it.
Yeah, and you also said when you first started writing about it that there was this sort of no more procrastination thing going on on Reddit.
What's the story of that?
Yeah.
So, actually, I had two things that I combined.
I found this awesome post called The X Effect on the subreddit that is called Get Disciplined.
And it's basically about how you can create a new habit.
It's a very easy strategy like that you just have a card and you draw lines on the card such that you get small squares.
And then every day that you spend on working on your habit, you can cross out one of the squares with a big fat X.
Not a light one.
A big fat one that makes it really obvious like you've done it right.
So it feels good.
Yeah.
And it's quite a lot of fun to visually track your progress.
Yeah, I'm sure it is.
It sounds great.
So I'll link to the Get Disciplined post on Reddit.
And I didn't know about that subreddit, although I'm interested in it now.
That's cool.
Yeah, you can find a lot of interesting stuff on it.
Yeah, I bet you can.
Where were you in your journey into programming and machine learning when you started the 100 Days of Code?
I just started an internship at Bosch, the Center of Artificial Intelligence.
So I was about, so I had applied a few machine learning algorithms already to data sets and so on.
But I had not spent so much time really on Python and all its advanced features.
I looked at Dan Bader's book a little bit.
I don't remember the name at the moment, but it's a pretty good.
Python tricks.
Yes, exactly.
I can definitely recommend it.
But yeah, I wanted to spend a bit more time on Python and all the advanced features.
Since I think that with Python, at some point you get to a stage where you feel comfortable and you can write code.
But you miss out on all the great features that Python has to offer.
So I wanted to bridge that gap somewhat.
Yeah, that's cool.
I think that's one of the challenges of Python actually is many people learn,
just enough to solve their problem.
And because it's so simple, you can kind of just learn a little bit and live in that space.
But you're not really taking full advantage of everything that's possible, right?
I agree.
It was the same for me.
Yeah.
This portion of talk by Python to me is brought to you by Coder.com.
Coder.com has really nailed the idea of developer tools in the cloud.
Have you heard about how amazing Visual Studio Code is lately?
How would you like to have VS Code in the cloud on powerful infrastructure?
I don't mean something similar to Visual Studio Code, but the full actual VS Code with built-in collaboration and instant access to massive Linux-based computing resources.
Whether you're working on Windows but developing for Linux, running local Linux but need way more computing power, or even if you want to do development on a Chromebook or iPad, Coder.com has a full browser-based instance of VS Code just waiting for you.
One annoying thing about cloud-based dev tools is you don't control the platform.
You can't install or configure anything.
With Coder.com, you get full root access to a Docker container with a gig of RAM and 3 gigs of disk space, and that's just with the free account.
On top of that, you have fast time for when you have serious computing to do.
You'll get access to 96 CPU cores to crunch that Python code fast.
Finally, we know that Google Docs has made online collaboration enjoyable and an important part of many people's daily work.
Coder.com brings this type of collaboration to your software projects.
That makes them perfect for interviews, teaching, and teamwork.
After just a couple of minutes of using Coder.com, you'll forget that you're even using a browser.
It's the Visual Studio Code experience you love, just with way more power and available everywhere.
Visit talkpython.fm/coder to get started for free.
So let's talk about some of the things you covered in your 100 days of code that were...
You had a different world you created called Castle Kilmer.
Is that right?
Yes.
Yeah, exactly.
Because Hogwarts wasn't an option.
So Castle Kilmer.
And let's talk about some of the things you created there.
So your 100 days of code didn't cover 100 days of the Castle Kilmer characters.
It was sort of half-half, right?
Yes.
So I started out with this magical universe, but I decided that I would stop when I wouldn't find anything else to really look at.
Not to keep working on it just because it was there.
I really wanted to have blog posts of high quality and interesting things.
And there was also so much other stuff I wanted to take a look at, which was not necessarily related to this concept of the magical universe.
So I basically split it in half.
Yeah, that makes sense.
Sometimes it's hard to cram some feature into a program that just doesn't make sense.
Yes.
So all of your code is on GitHub.
And I'll link to that, right?
And you also...
Did you blog every day on this?
No.
I created one blog post for each big concept.
So for example, I spent several days on abstract base classes.
But of course, I created one blog post about abstract base classes and not several ones for each day.
But each big concept or each big thing has its own blog post with details and the examples.
And then there's also the full version of the code for each day.
Yeah.
Okay.
Yeah.
Very cool.
All right.
So let's go through a couple of items that are pretty interesting that you covered.
that were in the Castle Kilmer world.
So you started out with object-oriented programming as one of them.
Why were you thinking about that?
I had used classes before.
And what I wasn't so used to using object-oriented programming.
So I really wanted to take advantage of this project and turn it into one that was based on object-oriented programming.
So I started looking at the very basics again, which I really liked.
It turned out to be a great choice in the end.
Yeah.
Just looked at what is object-oriented programming.
How does it work in Python that you have classes?
And what are classes?
Namely, that they act as like blueprints for creating objects.
And that these classes then define how objects are structured, what attributes they have, what kind of behavior, so what methods, what functionality.
And then I started out with my first class since all of the members of my universe or the universe was based on this Castle Kilmer.
And I created the first class called Castle Kilmer member.
And then I went on to inheritance.
All right.
So what are some of the ones that you covered in inheritance?
Like, so you have this member.
This is like anything that can be a human in this world or a character in this world, right?
Yeah.
It can be any character, like any member of the class.
Of course, within the school, you have the students, you have the professors, you have the ghosts, you have lots of other people.
And I wanted to have different classes for them.
So I created one for the pupils.
I created one for the professors and extended the universe over the course of the next days.
Yeah.
Nice.
You even have a ghost.
I like it.
Yes.
Yeah, I do.
Of course.
Yeah.
Of course.
You got to, right?
And so I think one of the things I like about this is when people are learning programming, it's a real, it's easy to connect with the way the characters fit.
But, you know, and if you sort of model it back to Harry Potter and your mind, right, it's pretty easy to think, okay, I can see how we have all these students and all the professors and they're kind of all magicians.
And it really does make it pretty approachable to learn objects and classes and inheritance, I think.
Yeah, that's why I went for this magical universe.
I really wanted to have something that makes it fun for me to sit down every day.
And originally the project wasn't even attended to be public.
So I really started it for myself and to have a theme that spans through the entire thing and makes everyday fun.
And it really was a lot of fun for me.
Yeah, I'm sure it was.
It looks really interesting.
And I still remember back to some of the programs that I first wrote when I was learning programming.
And it's the sort of weird ones that you force yourself to do that are not just homework assignments or whatever that really, you know, stand out, right?
Yeah.
Yeah, for sure.
Okay.
So another concept that you covered, which I think is still quite confusing to many folks, is different types of methods on classes.
So functions on classes are called methods.
And then you have instance methods, class methods, static methods.
And then we'll even see some more variations, right?
So maybe tell people your take on that and maybe what they are.
Yeah.
So I started out using instance methods most of the time, which I think everyone is using most of the time.
Yeah, I agree.
And they have this self parameter, at least the self parameter as an input.
And when I started out working on the types of class methods, days of code, I really had no idea that there was something else and how it might be useful.
So yeah, for the instance methods and the self parameter points towards when you call a method, it points towards an instance of the class or really an actual object.
So these instance methods are quite powerful because they can modify both the object state and the class state.
And I had my example was that the Castle Kilmear members were able to say something.
So they had a say function and then a certain object.
So a certain member was able to say a few words.
And they'd have to use some of their properties, right?
Like their name or other thing or what type they are, right?
The professor, whatever says such and such, right?
Yes.
Yeah, and that's pretty standard.
And then you get into class and static methods.
And I think the existence of either a class method or a static method makes a lot of sense.
But the existence of both is like, wait, why are there two of these?
Why are there two ways to do this?
Yes, that was also what I thought.
Right now, I really like class methods.
And I even used a few static methods now at work.
And they can be very useful, especially if you want to communicate your intentions when you write your code.
And it makes it much more readable.
But only, of course, if the other people also know about class methods.
Right.
What I used class methods for a lot was to create alternative constructors for a class.
Yeah, to really create different members of the universe.
So what I understood about class methods is that instead of the self parameter, you have the CLS, which points towards the class, not a particular object.
So a class method is restricted in some sense that it can only modify class state, but not the object state.
So what I had as class methods for, for example, their use as alternative constructors.
So I could create lots of different members of the universe without always having to write out all the names and birth years and so on over and over again.
Yeah, I think that's a great use of it.
And, you know, we don't talk about design patterns and stuff like that in Python as often as other languages.
But it's kind of a factory pattern or something like that where you don't have to know how to create the thing.
You just say, hey, type, make one of yourself.
And it can put all the pieces together.
I think that's cool.
Yes, I like that a lot.
Yeah, I do too.
And honestly, with the static methods and class methods, I know the difference.
I know the class method has the type available so it can work with it.
And the static one doesn't.
The class method kind of knows what level it's on in terms of if there's inheritance, which type you've called it on.
The static method doesn't necessarily.
But beyond that, I honestly don't really know when I would use static over class.
I guess if I don't feel like dealing with a class parameter, I'd use static.
But I don't have a great recommendation either there.
Static methods are a little weird, I guess.
But I don't remember the use case now.
I had at work for static methods.
But I came across a use case and I was like, wow, I can use a static method.
I know what it's for.
It really makes sense to use it.
Yeah.
I do find that I like having sometimes you have a class and then you want some functions that, you know, work with it, but they don't work with instances of it.
So either having a class or a static method is nice just for the grouping together.
It's like all on this thing.
Right.
So if you import the class, you don't have to also import the functions, for example, to work with it.
It's a little more obvious, I think.
Yeah.
It's good to communicate that it really somewhat is related to the class, even if it's independent in a sense.
Yeah.
So another interesting thing you covered was some of the magic methods or the Python data model with the repper and the stir and things like that, right?
Yes.
Of course, I wanted to get a nice representation of my pupils and my professors and so on.
So when you print an object, you usually don't get a very useful representation, but you get, I guess, the class name and then the ID, which is basically the memory address, if I'm correct.
I looked into the adunder methods you have for that.
And there are actually two ones.
That was also interesting for me to realize.
I had never implemented them myself.
And I only learned then that they have different purposes.
So one should rather function as a debugging aid for developers.
So the output should be as unambiguous as possible.
But then there's also the other one where the output should really be readable so that you as a human can read it.
Right.
So the repper is the more developer debugging side of things.
Yes.
And the stir is sort of the print curly bracket.
What goes in there.
Yeah.
Exactly.
I think it's definitely interesting.
that's a nice trick as well, just for working on Python projects is if you're using a debugger or anything like that, or even, you know, stack trace type stuff.
Go and write a specialized repper for your classes.
Because if you're like pausing a debugger or you're showing a list, you know, it'll put that information there instead of just this type at that address, this type at that address.
It's like, oh, here's the description.
And it can really be helpful.
And it doesn't take that much time.
No.
So, yeah, I agree.
It's really useful.
Yeah.
I agree.
And with data classes right now, you even get that implemented for you, right?
Yeah.
I think you do with data classes.
That's right.
Yeah.
3.7.
Very nice.
Data classes are really sort of simplify a lot of the stuff that we're talking about.
Yeah, yeah, yeah.
Yeah.
I like them.
Another one that takes a while for people to get.
And sometimes I don't know that people ever get to creating their own just because, you know, so we talked about stopping once your problem is solved and not digging all the way.
The decorators, right?
Those can be kind of mind-blowing, right?
Yeah, absolutely.
So, it was a big challenge to wrap my head around how they work.
And I think I understood how they work now.
But, yeah, don't test me on it.
No test.
But looking at your project, it looks pretty nice.
So, in your world, in your Castle Killmere world, you could have characters that say things and then you create a whisper decorator.
And if you put the whisper decorator onto that, it'll make it say it more quietly, right?
Yes, exactly.
Since, of course, there are also the mean people in my universe.
They are called the Dark Army.
And they have the leader, which is Lord Odin.
And when they take over the school, of course, the people are not walking around anymore and just talk to each other and make jokes.
But they would only be whispering.
So, I had my application for creating a decorator that turns this saying function into a whispering function.
But, of course, what is important about decorators, I guess, to understand it, is that they only modify the behavior of the function when you decorate it.
They don't really permanently change the function itself.
Right.
And you've got to put the decorator on.
And if you don't, it's not like somehow importing it is going to sort of patch and rewrite all the functions.
Yeah.
Yes.
Yeah.
So, with decorators, you've got this sort of, you take a function and its job is to take another function.
And then it can add behavior before, after, and then, you know, hopefully at some point call that function.
And all of that takes a little bit of interesting juggling with like star args, star star KW args.
And I think that's probably why decorators are challenging because you've got to learn the decorators.
You've got to learn like some of the closure data capture stuff in there.
And you've got to learn all these, how to, you know, juggle star args and star star KW args all at the same time.
So, that's all a little bit crazy.
But you also talked about not losing the metadata.
So, if, you know, there's either a crash or you want to ask what is this function that I'm calling, right?
A regular sort of unsophisticated decorator would say the function is the decorator function, not the internal wrapped function, right?
So, you also had some work on that.
Yeah.
So, I only learned about it then, too, that there's actually when you apply a decorator, the metadata of the function is replaced by, for example, the name, the doc string, and so on by the wrapper function.
So, when you want to look at the doc string, you don't actually get the doc string off your function anymore.
Right.
Which is not so nice.
You get help on the decorator or something, right?
Yeah.
Which is usually not so useful.
So, of course, that's also what I learned during the 100 days of code.
There are packages for almost anything.
I'm not sure whether there are many things left that haven't been solved or at least there were attempts to solve it.
Yeah.
So, there's the functools module.
And then there is the functools.wrap wrapper that you can apply to the wrapper function.
That sounds confusing now.
But that carries over the name and the doc string.
It's very easy to use.
And, yeah, I think it should be, you should use it by default to make sure that you don't lose the information related to your original function.
Yeah.
That's a really nice touch and, you know, makes it sort of a proper decorator for sure.
This portion of Talk Python to Me is brought to you by us.
Have you heard that Python is not good for concurrent programming problems?
Whoever told you that is living in the past because it's prime time for Python's asynchronous features.
With the widespread adoption of async methods and the async and await keywords, Python's ecosystem has a ton of new and exciting frameworks based on async and await.
That's why we created a course for anyone who wants to learn all of Python's async capabilities.
Async techniques and examples in Python.
Just visit talkpython.fm/async and watch the intro video to see if this course is for you.
It's only $49 and you own it forever.
No subscriptions.
And there are discounts for teams as well.
You talked earlier about data classes and how there are these sort of simple little containers, but they implement things like the wrapper function.
The thing that predates data classes really was named tuples, right?
Yeah.
So you spent some time on that as well.
And I'm a big fan of named tuples because...
Me too, yes.
They're so much nicer than...
What is the third thing in this tuple?
Is that the right one?
You know, the string representation is not that helpful, right?
And also you get confused so easily with like usual normal tuples with assigning the fields with the order.
When you have more fields, it gets so confusing.
Yeah, it definitely does.
So maybe tell us how named tuples appeared in Castle Kilmere.
Kilmere.
Yeah.
So I talked about these dark army members before.
And of course, once you switch to the dark side, there's no way back.
Either you get killed by the leader or you just stick with it.
So that was perfect since tuples are immutable and named tuples are basically an extension of tuples.
So I created my dark army member class as a named tuple so that once you create a dark army member, it is definitely going to be a dark army member at all times.
That's really cool.
I love it.
That's a really creative use of it.
Interpretation of the immutability of named tuples.
Another area that you covered was abstract base classes.
And I feel like that's a pretty advanced topic as well.
What did you find to use abstract base classes for in your universe?
So, of course, I found a great thing again, namely spells.
That was also something I learned that there are actually many different kinds of spells.
You have a curse, you have a jinx, you have a hex, you have a charm, a transfiguration, and so on and so on.
But all of them are, of course, spells.
And abstract base classes are very useful when you have classes that all belong to one base class.
And all of these subclasses should implement certain methods from the base class.
But you don't want to be able to instantiate this base class itself.
So for the spell, each spell should have a name and then an incantation and a certain effect.
And I also added a defining features, for example, that a curse should make people suffer or it should harm people.
Yeah, it sounds mean, but that's what curses are for, right?
That's right.
It's a tough world.
Yeah.
So I had the abstract base class for a spell.
And then you flag all the methods that must be implemented by the subclasses with the abstract method decorator, which was nice to know about decorators at that point.
Then I had all these different subclasses like curse, transfiguration, and so on.
Yeah.
And one of the things I think is really powerful about that is when you have regular inheritance, if you had, say, a charm that was derived from a spell, right?
There's no normal way to say it has to do its own version of cast and its own version of defining features.
But if you make it an abstract base class, you can say those abstract methods.
It makes sure that you implement them or you just can't use the charm, right?
So that's a really nice way to make that work.
Yeah.
I agree.
Absolutely.
Yeah.
That's something I don't see that often in Python, but I do like it.
It's very cool.
And then you've got to test your universe once you build it, right?
Yes.
So that was quite nice since I hadn't spent a lot of time on testing.
Although that's so important.
I just realized it then and now that I'm working at Microsoft, how important it is to really test your code from the beginning and how much it can tell you about your code and really think about,
well, how can this function be broken by a user or what kind of silly inputs could you put in there?
Yeah.
It's all the bad inputs and things you don't check for.
It's easy to put in the right number or the right value and go, oh, that worked.
But it's everything else, right?
And once you created the test, you can always rerun them.
So if you completely change your code base and run your tests, you at least can be sure that most of this functionality is still working.
Yeah.
I think it's great.
It's probably a little extra challenging in your day job compared to Castle Kilmer.
Yeah.
Because machine learning seems kind of hard to understand.
It's a little opaque.
And it's just hard to think about, I think.
Do you find it to be challenging?
Yeah, absolutely.
But it was also very useful to start looking at it with such a more simple example like My Magical Universe since it got me started with pytest.
And right now, I know all the basics of pytest, and I can make sure that I use the more advanced features.
And yeah, pytest is just so powerful.
I didn't really realize that before.
You can do so many things with it.
Yeah, it's amazing.
Yeah, it really is amazing.
It's great.
And I think there's a good lesson here in the learn the one thing at a time, right?
Learn testing in a simple space where you understand the other stuff, the stuff you're testing.
And then you can apply it to things that are more challenging like machine learning.
Yeah, absolutely.
Yeah, cool.
And it was also nice to look at like how to write proper test functions.
I think that's also a big part of it.
Yeah, I think a lot of times people don't put enough attention to writing proper test functions,
and they just throw something together, and then it becomes hard to work with because it didn't get the same attention the other part of your program did.
Yes.
And then the testing gets hard, and then you stop doing it, and then you have bugs, and it's not good.
Yeah.
So that pretty much covers the magical universe side of things.
But there's a few other areas maybe worth just touching on really quick.
One is if Dunder name equals Dunder main, right?
That's always confusing, isn't it?
Yeah.
It was actually one of my favorite blog posts since before that I used that line so many times, but I never thought about what is actually happening here.
Yeah.
Yeah, yeah.
Yeah.
And when I started looking at it, I was first so confused, but then I broke it down into individual steps.
And right now, when I see it, I really know what is happening, and that is nice.
Yeah.
I think this is the first place when I first encountered it where I realized that there were, like, special variables or things that were set, like, Dunder name.
I'm like, oh, wait, there's a Dunder name?
Where does that come from?
Yeah.
But there's also Dunder file and other stuff, right, that you can, like, oh, there's other things like this that I can, you know, work with if I need them.
Yeah, you usually don't know about them if you never, like, took a look at the different things.
Yeah, it's pretty cool.
So, it's not super hard once you learn, right?
Like, if you run the program directly and you print out Dunder name, you'll see main, you know, Dunder main.
But if you import it, you'll see whatever the name of the module was, right?
And you can kind of work your way through, and it's not super confusing.
It's just when you first see it, you don't know where it comes from, right?
Yeah, and it looks, for me, it looked quite scary with all these Dunders and the, yeah, I was really confused.
What is all this?
Why are these symbols back in my Python?
What's going on?
Yeah, yeah, for sure.
I don't know.
Some languages have, like, a convention that if a function is called this and you run that module, then it will just run that function.
Like, C has its main and C# has a main, a static void main sort of thing.
I don't know.
Maybe it's worth adding something like that to Python.
Because once you learn it, it's fine.
But as a beginner, I think it's one of the things that you have to encounter pretty soon that just looks weird and out of place.
I agree.
Yeah.
It's used a lot of times, even in the beginning, without knowing what it's actually doing.
Yeah.
Right.
Exactly.
Yeah.
I think probably the two big confusing starting points are this Thunder name thing and then virtual environments.
Right.
Both of those can get you right away when you're not really ready to think about them.
Yeah.
Absolutely.
Yeah.
And I guess also maybe just underscores, right?
You talked a bit about how underscores are serving so many purposes.
Yeah.
That was also a really nice thing.
I really liked spending time on it.
Since I think when you don't know about the naming conventions in Python and how to use underscores appropriately and you're used to some different programming language.
For example, I came across code once of a colleague that I think he was programming in C before.
And he named all the magic, his methods with Dunder name and another double underscore.
And I was like, you shouldn't do that in Python.
Like, that has a special meaning.
That's not good.
And he had just no idea about it since he never looked at the different underscore patterns, which can be.
Yeah.
They are just different sometimes.
Yeah.
There's you have at least five listed here and there maybe are even more.
Yeah.
There's a lot of different uses for the underscore.
So Python is a language without too many symbols, but they love the underscore for sure.
They do.
Absolutely.
That's definitely one that shows up.
All right.
So, yeah, I think you had a really interesting take on this 100 days of code and I really like how you created your magical universe and that's great.
So what are your main takeaways from this whole experience?
So one of the main takeaways was that it can be extremely rewarding to share your work with others and get feedback from other people, especially when it's something that can be useful also for other people.
And it's really, really, really useful if you directly apply what you learn.
So if you learn about decorators, but never try to build your own decorator, you never actually, I think, fully understand what is going on.
So that is a really important thing.
Yeah.
It's one thing to learn something, but if you don't try to use it, at least in programming, it's not going to it's not really going to stick.
You're not going to internalize it.
Yeah.
Were you surprised at how popular your post on Reddit became?
Oh, absolutely.
Absolutely.
I was so surprised.
I really just put it up there after, I don't know, maybe I spent a week on it and then I thought, oh, this is just so much fun.
Maybe it's also fun for others to learn about the features by using magic.
And then so many people liked it so much.
It was a great, great experience.
Yeah.
That must have felt really good to see so many people enjoying it.
And it also motivates you to go on and keep working on it.
I'm sure you're like, well, now I have to do this.
Yes.
Do you think it made you a better developer going through this process?
Yeah, I think so.
So, for example, it introduced me to many advanced concepts.
And I think most of them I didn't even know before or I never fully understood them.
And now with working in this AI residency, I could apply quite a few of them already.
For example, I used abstract base classes, which I never heard of before.
Yeah, definitely.
It made me a better developer.
Yeah.
But there's still a long way to go, I guess.
There's always a long way to go.
It's like an infinite path.
But I think you do get to really dig into some of these things that you maybe use, but you don't really worry too much about.
Like, I put a little at symbol, then something goes here, and then it works differently.
But you don't really think about the decorators and the funk tools and just all the layers.
Yeah.
But when you've got to write about it and the purpose is to study that, then it's different.
Yeah.
All right.
Well, let's talk a little bit about where you are working now and where you're going.
So you're a big fan of machine learning, I can tell.
You talked about how you actually changed your career, basically, because of machine learning, which is really great.
So you have another cool GitHub project called Machine Learning Basics.
Do you want to tell people about that?
Yeah.
So in general, I really like working on projects that benefit many people or at least have the potential to benefit many people.
So I started this machine learning repository when I was preparing for interviews.
And when preparing for interviews and machine learning, you usually have to know about the basic machine learning algorithms,
like K-Means, which is a clustering algorithm, or linear regression, logistic regression, and so on.
But you really have to know how they work.
So it won't work if you just use scikit-learn and then the implementation of them.
I call this function.
I give it these numbers and then magic.
Yeah.
But that's what many people do, actually.
Yeah.
I'm sure.
Yeah.
And it's very useful.
It can be very useful.
But it's also really nice to just understand what's going on.
So that was also a project I started just for me when I was preparing.
And I created Jupyter Notebooks with first all the theoretical, most important theoretical basics about the algorithms with formulas and so on,
and have everything in one consistent notation.
And then I implemented them without using any of these scikit-learn methods and so on, but just Python and NumPy.
And yeah, when I was applying to these different residency programs and other things, at some point I thought, oh, well, other people are applying too to these programs, so they can probably use that.
And it became also way more popular than I ever expected.
Yeah.
I'm looking at the repository, and it has 2,000, almost 2,600 GitHub stars, 400 forks.
I mean, this is really, really cool.
And I think, one, I think it's a fantastic way to learn.
Two, I think, I don't know, I'll ask you, like, how were people's impressions when they said, well, what do you know about this?
Did you share, like, your GitHub account name with them and stuff like that when you applied to jobs?
Yes, that's, like, you usually do that.
I think when I applied, I didn't even have that.
It wasn't even public.
So at that point, it didn't help me much.
Right now, it would probably help a lot.
It probably would, yeah.
But it was really just to teach myself how these algorithms worked.
And only at that point, I really realized, do I really know how linear regression works?
Do I really know how k-means works, like, the underlying structure?
It was really, really good to take a detailed look at the algorithms again.
Yeah, I'm sure.
I think, you know, there's so many machine learning libraries that you can use.
But like you said, if you don't know the foundations, you know, you put numbers in, you get numbers out, and you kind of just have to trust them.
You can't reason about whether, does this make sense?
Is this working right?
So I think this is really great.
And I'm sure a lot of people out there will be happy to hear about it, be able to use it.
Hopefully, yes.
Yeah.
You seem to have a real knack for creating things that become quickly popular.
Yeah, yeah.
It seems like that.
Yeah, it's nice.
It's nice.
All right.
So maybe we could talk a little bit about the project that you're working on, at least not necessarily the project.
It might be not public or anything, but just the general area of machine learning and healthcare.
Yeah.
So that's basically my main focus or what I want to focus on, namely apply machine learning algorithms to healthcare problems.
Since I think there is, yeah, most healthcare applications just promise so many and huge improvements for so many people.
There is already, I think, a lot of algorithms on detecting cancer, for example, from images.
Yeah.
That is quite popular.
Yeah, there have been some amazing research projects or research challenges, I guess, around looking at various scans or mammogram type things and automatically detecting cancer.
And those machine learning algorithms are getting as good or better than doctors, right?
Yes.
And with healthcare, the thing is that you have tons of data lying around in the hospitals.
It's just amazing how much data they collect without ever using it.
It's just lying there.
And with machine learning, you can take advantage of it and create great things.
I think there's a lot of possible applications there.
Yeah, absolutely.
I definitely think there are.
I think the challenge with healthcare is people are so protective of the privacy, understandably.
I wonder if there'll be, you know, there's big healthcare organizations.
And within those organizations, they're allowed to share the information with, say, their doctors, the different doctors and specialists.
I wonder if there'll be these healthcare organizations who create machine learning algorithms based on only their own data.
And it becomes like an advantage of that organization at some point in the future.
I'm not sure that's a good thing, but I wonder if that's something that will happen because of the privacy.
Yeah.
What do you think?
I agree.
Yeah, that might really happen.
It's very good that healthcare data is so heavily protected.
But a lot of times people also don't realize how much good you could do with using the data if you have proper rules how to use it.
Right.
If we could all live 10 years longer or the last 10 years much more healthy, maybe we wouldn't want as much privacy.
We might make that trade off.
I mean, we'd trade our privacy to Facebook for, you know, a little like, right?
Maybe we could live better.
We could make better trade offs.
I don't know.
So your master's thesis was in this area, right?
Yeah.
So I really liked working on my master's thesis.
It was a project together with the German University Hospital and their radiological department.
And they said, well, we have tons of radiological reports lying around here.
So these reports are whenever a radiologist looks at an image, he has to, in Germany, create a report and write down, I see this, I see that.
This has changed from last time.
And so on and so on.
But he or she doesn't have to write the report.
But there has to be another radiologist that checks the report.
And this just takes massive amounts of time, which could be used in way more useful ways.
So they said that they would like to have some kind of auto-completion for the doctors so that when they write the reports, it would basically complete the sentence or at least make suggestions to speed up the whole process.
But of course, it was German data.
And I think for English, there's already a lot of stuff there.
But in general, the medical language is very complex.
So there are a lot of terms for some types of cancers.
You have five names that all mean the same thing.
Then you have all the synonyms.
Sometimes you can write something with a K, sometimes with a C.
And it can be really complicated.
So I worked on a recurrent neural network for processing these reports and then really using it in the hospital.
And right now we are at the stage.
It takes quite a while for them to really incorporate it in their system and try it out, evaluate it, so on.
But hopefully then it can be used at some point and really be used by the doctors there to save time.
I think that's a really meaningful project.
That sounds super cool.
And it's way more fun to work on projects like that where you can see the end application.
Oh, I'm sure it is.
Yeah.
One of the really sad things is to work on a project and then see nobody uses it.
Right.
Yeah.
That doesn't feel good.
I can certainly see as a programmer how much autocomplete helps, right?
Like I know as I'm typing, if it just, you know, you type a few characters and it, you know, completes the next 10, it's super helpful.
And I don't know if it happens for you, but at least in the States, the Gmail has started autocompleting sentences in the Gmail editor.
Oh, that is interesting.
No, I've never used it.
Yeah.
So it actually studies your email chain and then it will propose, you know, maybe the next five or six words in a sentence.
So I'll be like, I'm excited to have, and it'll say you on the podcast.
I'm like, whoa, you know, and then you just hit tab and it autocompletes it and off it goes.
So I think these ideas are starting to make their way into normal life, right?
Outside of programming and super structured words.
So I think it would have a huge value.
Although the danger is if Gmail gets it slightly wrong, whatever, right?
You made a silly mistake.
We're all used to autocorrect on our phone, messing up stuff.
But if it says that for a cancer diagnosis, then that is a whole different type of problem, right?
So the stakes are very high.
Yes, absolutely.
Yes.
You would definitely still have the check, I guess, from a different radiologist.
Yeah, but just the creation of it much, much more quickly, I think is really powerful.
So when you think of the tons of reports they create every day, absolutely.
Yeah, you think, you know, a lot of times they're being doctors, but their day-to-day stuff is actually to sit down and write reports, not to go see patients or work with people, right?
It's their bog down.
I have some friends and neighbors who are doctors and they just talk about the reports and the bureaucracy.
And just it's really frustrating to them.
Absolutely.
Yeah.
Okay.
So I think, yeah, this just sounds super cool.
What else are you interested in studying in machine learning?
I think there are way too many things to be interested in.
There's so much going on.
It's early days, right?
It's, you know, the last five years, it feels like machine learning has gone from this science fiction to science, right?
Like it really has come into a thing, right?
Yeah.
It became quite popular.
So I really like what we talked about earlier so that you combine cognitive science and machine learning and that you spend more time on that and maybe try to become, learn more about the human brain and use its power to create new machine learning algorithms.
I think that's a very, very interesting field.
Yeah, absolutely.
I think we're just at the beginning and I don't really know where it goes, but it's going to be very interesting.
What happens to jobs?
What happens to society?
What becomes possible?
What becomes scary?
And so on.
Yeah.
I guess one thing just in the scary space that I saw recently is apparently China, some either group or the government, I don't remember which, has come up with a way to identify people by their way they walk.
Oh, that is scary.
Instead of facial recognition, just their gait, the way they walk.
Wow.
I thought, whoa, that is something, right?
Yeah.
So, yeah, pretty, pretty crazy.
Yeah.
I also heard about recently about also that was a company in China that tracked their employees the entire day through cameras and they read your facial expressions.
So they would know your mood all the time when you went to the bathroom, when you were at your desk.
And then they have this big database of where they save all the information about all the people all the time.
And yeah, when I read the article, I was like, oh, I never want to live in China.
This is just so scary.
There's some amazing stuff in China, but that sounds so scary for sure.
I would not want to work at that place at all.
Interesting.
So I guess, you know, maybe that brings us to sort of my last few questions here is what do you think the big promises of machine learning and AI are?
And what do you think the big challenges or dangers are?
I think the big promises are that you can make life better for so many people.
Like healthcare is just one of the applications where it can hugely improve our daily life.
Dangerous and challenges.
Like dangerous, I see so many dangers since you can never stop people.
There will always be people who want to use AI to do bad things.
And since there is such a lot of such big number of projects at the moment going on and governments have different ideas and different ways of treating people, there will also be bad things.
Especially when you look at general AI.
When you, I think that could be a whole podcast.
Yes, it could.
Yeah, there's just so much to, you can be scared about there.
So maybe define that for folks.
Like there's the focused AIs like Alexa or the thing that can say cancer or not cancer by looking at a picture.
But what's general AI?
Yeah, so there's this difference between general and specific AI, just as you just said.
So specific AI means that your artificial intelligence is good at doing one thing, like predicting sentences or speech recognition.
But it has just one thing.
But we as humans, we have more general AI.
We can dance, we can talk, we can like find faces in a crowd and so on.
And the idea of general AI is to have more like a human level AI that has all these different kinds of intelligence.
So social intelligence, but also that it can perform lots of different tasks equally well.
Do you think that will happen?
Do you think somebody will come up with it?
You think so?
I think definitely at some point it will happen because there are too many people who want it to happen.
And you can't stop people from researching and working on it.
And even if there are people who want to restrict it, there will always be labs who just, I think that's just human nature.
Yeah.
It has to be solved globally or at least addressed globally, right?
Like no one government.
It's not like the EU can say, well, we're not doing it.
Well, okay.
You know, maybe Uruguay is going to become the next place that does, you know, creates it, right?
Because they're not subject to the rules and they see it as an advantage.
I have no idea about Uruguay.
But, you know, just if it's not dealt with on a global level, like it can't even be addressed.
But then you have even bad actors amongst places that agree, right?
Yeah.
It's so important that this issue is, becomes more, like people become more aware of how present it is and how important it is to talk about it.
And to really understand what is going on and what might happen in the future.
So we can start a global discussion on how we want to handle these things.
Do you think politicians should discuss these things?
Do you think they should be part of like prime minister political debates and things like that?
I think they should be a part of it.
Yes.
But I definitely think that you should talk to the experts most of the time and that they should at least have equal rights in talking about it and making decisions.
So it must really be, I guess, representative of all kinds of people.
But the experts are those that really understand what can be done and what is currently being worked on.
Yeah.
So, yeah, I feel like, you know, at least I can speak from the U.S. perspective.
I feel like there's a lot of pushback against immigration or outsourcing or other stuff.
But I think the reality is a lot of it is the AI and the robots are changing people's jobs and careers much more than any of the other effects that people are arguing and screaming and yelling about, you know?
So many people don't realize that, I guess, how much influence AI will have on their jobs.
And they just stick to what they're doing right now.
And they think, oh, yeah, I can use my smartphone.
It's so cool to have Siri and my phone and so on.
But they don't think about the long-term changes that will come.
Yeah.
It's going to be very interesting in all sorts of ways in the next 10, 20 years.
I agree.
Yeah.
Interesting.
Yeah.
I think there's great potential for very much good.
And I think there's also a potential for lots of disruption.
So it's going to be a mixed bag, but it's going to be interesting to watch it play out for sure.
I absolutely agree.
And Python and Scikit-learn will be at the foundation somewhere, I'm sure.
Yeah.
Cool.
All right.
Well, this is a super interesting project.
And thanks for sharing your journey with us.
It was my pleasure.
Yeah.
So before you get out of here, though, I got the two questions, final questions for you.
When you're writing your Python code, what editor do you use?
I use Vim.
Vim.
Right on.
Yeah.
My fiance convinced me to start using it about two years ago.
And I think I can't switch to anything else anymore.
Once you learn something, yeah, it's just tough.
Do you also use Jupyter notebooks?
Yes.
Yes, I do use them.
But I get really annoyed with not having all the keyboard shortcuts.
I know.
So yeah, I usually use them for like most of the time.
Yeah, that's cool.
And then notable PyPI packages.
What ones do you think people should learn about?
Yeah.
So one I think many people know about already, but it was so useful for me at the point when
I started programming was IPDB.
So the IPython debugger.
It made life so much easier for me.
So that I think it's a great package.
And then I heard about Black on the podcast a few months ago.
I think it was the podcast on coverage, wasn't it?
Oh, yes, I think it was.
Yeah.
Ned Batchelder.
Yeah.
It's a Python code formatter.
And I tried it a few times and it looks really, really good.
So I will definitely spend more time on learning about Black.
Yeah.
Black is cool.
There's been linters that will tell you how you formatted your code wrong, but Black goes
farther and fixes it for you, which is really nice.
I really like that.
Yeah, that's cool.
All right.
So people are excited about having this magical universe where they can try out their 100 days
of code and get better at Python and stuff.
What do you say for them?
Like what resources you have?
How should they get started?
I think the most important thing is just to find a topic that is interesting for yourself
and that really motivates you to sit down every day and that you make it fun for yourself.
And that will make it way easier.
Yeah.
I think fun is a super key part.
And I'll link to your blog posts and to your GitHub repository and all that.
Yeah, please.
Yeah.
Yeah, definitely.
All right.
Annalena, thank you so much for being on the show.
It was really interesting and fun to chat with you.
You too.
Thank you.
Bye.
This has been another episode of Talk Python to Me.
Our guest on this episode was Annalena Popkas, and it's been brought to you by Coder.com
and Talk Python Training.
Coder.com brings full Visual Studio Code and cloud computing to every device.
Create your free Coder.com account and start collaborating on code today.
Visit talkpython.fm/coder to create your free account.
Want to level up your Python?
If you're just getting started, try my Python jumpstart by building 10 apps or our brand new
100 days of code in Python.
And if you're interested in more than one course, be sure to check out the everything bundle.
It's like a subscription that never expires.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, Google Play feed at /play, and
direct RSS feed at /rss on talkpython.fm.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
I'll see you next time.
Thank you.