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 :)
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?
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.
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.
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 :/
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.
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
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.
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 :)
I really like your talk. Thank you!
That was a dmn cool presentation.
Excellent talk!
+= 1
a hit topic
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?
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.
Absolutely Amazing!!!!!
Slides: www.slideshare.net/nnja/elegant-solutions-for-everyday-python-problems-pycon-2018
Nice with great reference !!
very useful, thank you.
great! great!
Some good tips there!
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.
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 :/
Brava 👏👏👏😃
Great presentation. Which font is used for code?
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.
Manuel Barkhau
I already have.
Monospaced font is not Inconsolata.
Boris Đurkan well, what is it then?
Manuel Barkhau
I don’t know.
Most similar is IBM Plex Mono.
Thanks!
there are no slider at the github link, and no slides at speakerdeck either
Interesting terminology used for partial 18:00
usually it is called something like en.wikipedia.org/wiki/Currying
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
I mix up words just like she does
basic python101 come man - cool hair girl...
I don't think that *intermediate* programmers wouldn't know most (if not all) of this stuff
20:02 cringe af
problem?
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.