Nina Zakharenko - Elegant Solutions For Everyday Python Problems - PyCon 2018

  Рет қаралды 73,419

PyCon 2018

PyCon 2018

Күн бұрын

Speaker: Nina Zakharenko
Are you an intermediate python developer looking to level up? Luckily, python provides us with a unique set of tools to make our code more elegant and readable by providing language features that make your code more intuitive and cut down on repetition. In this talk, I’ll share practical pythonic solutions for supercharging your code.
Specifically, I'll cover:
- What magic methods are, and show you how to use them in your own code.
- When and how to use partial methods.
- An explanation of ContextManagers and Decorators, as well as multiple techniques for implementing them.
- How to effectively use `NamedTuples`, and even subclass and extend them!
Lastly, I'll go over some example code that ties many of these techniques together in a cohesive way. You'll leave this talk feeling confident about using these tools and techniques in your next python project!
Slides can be found at: speakerdeck.com/pycon2018 and github.com/PyCon/2018-slides

Пікірлер: 38
@rickylim4910
@rickylim4910 5 жыл бұрын
I really like your talk. Thank you!
@DJCronixx
@DJCronixx 5 жыл бұрын
Absolutely Amazing!!!!!
@lbbc33
@lbbc33 5 жыл бұрын
great presentation, really pythonic and useful! Just one remark, it might be better to use the the format string or even better, the new literal string instead of the old-style string :)
@RoushanSingh07492
@RoushanSingh07492 6 жыл бұрын
Nice with great reference !!
@michaelthomheadley
@michaelthomheadley 5 жыл бұрын
Excellent talk!
@user-od8co1ud1f
@user-od8co1ud1f 5 жыл бұрын
very useful, thank you.
@not_a_human_being
@not_a_human_being 5 жыл бұрын
Some good tips there!
@mitoliang8950
@mitoliang8950 4 жыл бұрын
great! great!
@qu4ku
@qu4ku 6 жыл бұрын
That was a dmn cool presentation.
@theprogrammingshuttle2975
@theprogrammingshuttle2975 6 жыл бұрын
+= 1 a hit topic
@plato4ek
@plato4ek 3 жыл бұрын
there are no slider at the github link, and no slides at speakerdeck either
@LouisMaddox
@LouisMaddox 3 жыл бұрын
Brava 👏👏👏😃
@borisurkan2223
@borisurkan2223 6 жыл бұрын
Great presentation. Which font is used for code?
@ManuelBTC21
@ManuelBTC21 6 жыл бұрын
Found the slide deck. www.slideshare.net/nnja/elegant-solutions-for-everyday-python-problems-nina-zakharenko The pdf has embedded "WorkSans" and "Inconsolata". Edit: Unfortunately it seems that this is an older version of the presentation and neither of these are the one used here.
@borisurkan2223
@borisurkan2223 6 жыл бұрын
Manuel Barkhau I already have. Monospaced font is not Inconsolata.
@ManuelBTC21
@ManuelBTC21 6 жыл бұрын
Boris Đurkan well, what is it then?
@borisurkan2223
@borisurkan2223 6 жыл бұрын
Manuel Barkhau I don’t know. Most similar is IBM Plex Mono.
@borisurkan2223
@borisurkan2223 6 жыл бұрын
Thanks!
@420_gunna
@420_gunna 2 жыл бұрын
I think this is just a misspeak, but at 9:21 she says a class is an iterator because it implements __iter__. That actually makes it an ITERABLE. An iterable who, when you call __iter__ via iter(MY_ITERABLE), you receive back an object (called an iterator) which, in this case, is the _same_ object. To be an iterator, you have to support next() via a __next__ method! So as far as I understand it, this class is both an iterable AND an iterator. But it's an iterable because it implements __iter__, and an iterator because it implements __next__. Can anyone confirm this?
@AsherMindenWebb
@AsherMindenWebb Жыл бұрын
Yes, but it's not a great example, very bug-prone design. Unless you're intentionally trying to share iteration state across calls to iter(), generally want your iterator to be an object with its own state. E.g. I'd expect this to make a Cartesian product [(x, y) for x in A for y in A] But if the iterator produced by "for x in A" has the same state as the one produced by "for y in A", you'll only get one value for x before the iterator is exhausted (by y), and y will never get the value that x used up.
@drd105
@drd105 5 жыл бұрын
This is really rushed. It's a good overview of some of the unique language features, but I had troubles following it even though I knew all the features. One thing that I did notice is that you yield without a try/finally inside of contextmanager. Not sure if this idiom has changed, but I am used to always see and write it as try: #do some setup yield finally: #teardown This way if the code using the contextmanager raises an exception, it will still get its exception, but the resource will be released. This makes sense because the exception will actually be caught outside of the `with` block.
@gJonii
@gJonii 4 жыл бұрын
I'm not great coder but I saw similar problems with many of her examples. Which is a real shame since I really hoped to get some good practices type code examples out of this, but with incomplete examples I'm now really hesitant to actually use any of this stuff :/
@RamezAshraf
@RamezAshraf Жыл бұрын
Slides: www.slideshare.net/nnja/elegant-solutions-for-everyday-python-problems-pycon-2018
@GlukAlex
@GlukAlex 6 жыл бұрын
Interesting terminology used for partial 18:00 usually it is called something like en.wikipedia.org/wiki/Currying
@safuya1833
@safuya1833 5 жыл бұрын
Partials and currying are subtly different. Currying allows you to convert a function with more than one argument, and make it into chained function calls that each take one argument (making your functions easier to pipe together with other functions). add = lambda a, b: a + b add(1, 2) 3 becomes add = lambda a: lambda b: a + b add(1)(2) 3 Partials take a fixed value for one of the arguments. So you could create an add5 function. It's a way of taking generic functions and applying them to a more specific field. add = lambda a, b: a + b add5 = partial(add, b=5) add5(2) 7
@nxxxxzn
@nxxxxzn 5 жыл бұрын
I mix up words just like she does
@superjerkk
@superjerkk 3 жыл бұрын
"explicit is better than implicit" ... "It's done for us implicitly!" Zen of uhhh python, yeah
@malayagr
@malayagr 3 жыл бұрын
Would you prefer this instead? >> 1.__add__(3) 4 Or: >> "Hello, ".__add__("superjerkk") "Hello, superjerkk" Because you can use that if you want to. :)
@scientia8442
@scientia8442 2 жыл бұрын
but Zen also said "beautiful is better than ugly" :) It's a tradeoff...
@dev.cl0ne
@dev.cl0ne 4 жыл бұрын
I don't think that *intermediate* programmers wouldn't know most (if not all) of this stuff
@riosdellacueva6482
@riosdellacueva6482 3 жыл бұрын
basic python101 come man - cool hair girl...
@ThunderAppeal
@ThunderAppeal 3 жыл бұрын
Great presentation. But I hate that she follows the same formula as all the others, one of the very few presenters who present something useful but the goofy examples that everyone uses to cater to the lowest common denominator is beneath her.
@gsb22
@gsb22 3 жыл бұрын
20:02 cringe af
@Mogwai88
@Mogwai88 2 жыл бұрын
problem?
Carl Meyer - Type-checked Python in the real world - PyCon 2018
32:10
Clown takes blame for missing candy 🍬🤣 #shorts
00:49
Yoeslan
Рет қаралды 42 МЛН
No empty
00:35
Mamasoboliha
Рет қаралды 6 МЛН
Женская драка в Кызылорде
00:53
AIRAN
Рет қаралды 484 М.
НЫСАНА КОНЦЕРТ 2024
2:26:34
Нысана театры
Рет қаралды 1 МЛН
Reuven M. Lerner - Practical decorators - PyCon 2019
29:12
PyCon 2019
Рет қаралды 41 М.
Jack Diederich - HOWTO Write a Function - PyCon 2018
41:31
PyCon 2018
Рет қаралды 68 М.
Transforming Code into Beautiful, Idiomatic Python
48:51
Next Day Video
Рет қаралды 1 МЛН
Loop like a native: while, for, iterators, generators
29:15
Next Day Video
Рет қаралды 117 М.
Clown takes blame for missing candy 🍬🤣 #shorts
00:49
Yoeslan
Рет қаралды 42 МЛН