Transforming Code into Beautiful, Idiomatic Python

  Рет қаралды 1,061,762

Next Day Video

Next Day Video

Күн бұрын

Raymond Hettinger
Learn to take better advantage of Python's best features and improve existing code through a series of code transformations, "When you see this, do that instead."

Пікірлер: 662
@rafehqazi8539
@rafehqazi8539 8 жыл бұрын
Note to Python 3 Users: - izip is just zip - d.iteritems() is just d.items() - To use defaultdict: You have to do the following --> from collections import defaultdict
@suburbanmoscow9067
@suburbanmoscow9067 7 жыл бұрын
Rafeh Qazi thx for the additional info
@CleverProgrammer
@CleverProgrammer 7 жыл бұрын
Woah, did not notice my comment was sitting at 65 likes haha. I now have my own computer programming KZfaq channel! Thanks for commenting Suburban and making me see this!
@suburbanmoscow9067
@suburbanmoscow9067 7 жыл бұрын
You are welcome. I will check out your channel as well! Cheers
@javierRC82857
@javierRC82857 7 жыл бұрын
Rafeh Qazi but in Python 2.7 zip is an iterator? izip,zip or range,xrange why not use iterator for everything and let the programmer choose if he want expand the list?
@nmertsch8725
@nmertsch8725 7 жыл бұрын
Javier I'm not sure if this is what you asked for, but you can use "list(range(x))" or "list(zip(x,y))", if you really want to have a list instead of an iterable object.
@jeffkirchoff14
@jeffkirchoff14 2 жыл бұрын
Man YT recommended it after 8 yrs In search of gold I found diamond
@gromilla1990
@gromilla1990 7 жыл бұрын
"If you are mutating something while you are iterating over it, you are living in a state of sin and you deserve whatever happens to you" :D loled so hard on this one! 20:20
@Michael-jq1hl
@Michael-jq1hl 4 жыл бұрын
Hi I have recently started studying python, what is that arrow in print i,'-->',color?
@burakozdamar
@burakozdamar 4 жыл бұрын
​@@Michael-jq1hl it's not a special character or something. he just wanted to print an arrow, that's it. the characters in single or double quotation marks are interpreted as string. so this statement prints 1 --> greens for example.
@Michael-jq1hl
@Michael-jq1hl 4 жыл бұрын
@@burakozdamar I see, many thanks, I never found the answer to that and now that I see the quotes makes more sense :)
@godfather7339
@godfather7339 2 жыл бұрын
@@Michael-jq1hl it's been a year, hope you are doing with python.
@Michael-jq1hl
@Michael-jq1hl 2 жыл бұрын
@@godfather7339 hey, kind of. I decided that instead of developing I could recruit Python Devs, so that is how I am using the little skill I have acquired. Unfortunately, most Devs think I am like any other recruiter and ignore me xD
@juliushinze5177
@juliushinze5177 7 жыл бұрын
10:20 Beautiful syntax highlighting
@jonty3551
@jonty3551 4 жыл бұрын
Lol
@nickbarss1693
@nickbarss1693 4 жыл бұрын
I remember my prof for C++ and OOP had every other word/letter in his notes/code highlighted with no common theme whatsoever.
@PedroTeixeira
@PedroTeixeira 5 жыл бұрын
I’ve been using Python for over a decade (informally trained) and haven’t learned so many great tidbits so quickly in a long time. Awesome talk!
@qg4091
@qg4091 7 жыл бұрын
This guy is seriously amazing, love his style of teaching
@johncherry108
@johncherry108 5 жыл бұрын
Pity his ego needs to be continuously stroked with applause.
@Pulsar77
@Pulsar77 5 жыл бұрын
John Cherry Oh FFS, it's a joke. First rule of becoming a Python programmer: have a sense of humor.
@heinzguderian9980
@heinzguderian9980 5 жыл бұрын
He reminds me a bit too much of a pastor for me to be completely comfortable, (like from a Pentecostal church or something). Or an unctuous salesman telling us about his schemes. Material was great, though.
@DimitrisK5
@DimitrisK5 5 жыл бұрын
@@johncherry108 It's one of his techniques to keep the audience engaged. He is an excellent speaker and he obviously does that on purpose. You might also notice that he asks the audience all the time if they learnt something new, or how many knew that, or what's the problem with this piece of code, etc.. On top of that, he makes me (and I assume other people, too) feel like we are part of the Python family; the core team seems close and approachable and I get a feeling of belonging to this line of developers who transformed the way we think about human programming forever.
@KurzedMetal
@KurzedMetal 4 жыл бұрын
No wonder why Python is awesome, they have awesome devs :)
@Decessus117
@Decessus117 9 жыл бұрын
"There's two kinds of people in the world: people who've mastered dictionaries and total goobers." - Raymond Hettinger
@dontbetoxic4387
@dontbetoxic4387 3 жыл бұрын
Isn’t there are correct?
@brotherlui5956
@brotherlui5956 5 жыл бұрын
6 years old but still good advice. Raymond is a great teacher.
@GroundZero_US
@GroundZero_US 11 ай бұрын
@@cirogarcia8958 10 years old, your statement of his statement still stands.
@stijnvandensande3579
@stijnvandensande3579 6 ай бұрын
@@GroundZero_US almost 11 now
@GroundZero_US
@GroundZero_US 6 ай бұрын
@@stijnvandensande3579 • and still holds up
@Achrononmaster
@Achrononmaster 5 жыл бұрын
The ignored() idiom exists in Python 3.4+ but is called suppress(): # NEW WAY in Python 3.4+: from contextlib import suppress with suppress(OSError): os.remove('foo.txt')
@locanix
@locanix 4 жыл бұрын
Thanks! I was wondering why I couldn't find it
@rusca8
@rusca8 2 жыл бұрын
+
@merlin2600
@merlin2600 5 жыл бұрын
At 44:00, The `with ignored(OSError)` has been renamed to `with suppress(OSError)` and is from the contextlib package.
@sandeshgowdru8869
@sandeshgowdru8869 Жыл бұрын
10 years old video, and it is gold.
@chrstfer2452
@chrstfer2452 11 ай бұрын
Some minor differences, izip is just zip now i guess
@stasbovanenko
@stasbovanenko 4 жыл бұрын
Amazing talk ! Probably best I've heard in all 26 year I'm coding. A handful of smiles and headful of HQ knowledge. Thank you, Raymond !
@torgeirlaurvik8195
@torgeirlaurvik8195 3 жыл бұрын
This video was the video that got me interested in writing ideomatic Python and iterators. I've revisited it now and then ever since 1. year at uni. Amazing lecturer.
@matthewwatts9693
@matthewwatts9693 10 жыл бұрын
This is a must see video for an python developer. Fantastic!
@MrTigerstyle80
@MrTigerstyle80 6 жыл бұрын
Dude’s kind of a colossal badass. Not even mad at the Casey Kasem vibe at all. He’s a beast.
@shushens
@shushens 9 жыл бұрын
Love this guy. I was quite disappointed when it ended. I was so expecting a much much longer video :D
@ceestimmerman9785
@ceestimmerman9785 7 жыл бұрын
You could read the "What's New" articles instead: docs.python.org/3/whatsnew/index.html
@jacobschmidt
@jacobschmidt 4 жыл бұрын
@@ceestimmerman9785 it's not quite the same!
@MrTigerstyle80
@MrTigerstyle80 9 жыл бұрын
This dude is off the hook smart.
@borgonzalezusach9263
@borgonzalezusach9263 10 жыл бұрын
This man is technically brilliant and hilarious. Not something you see everyday. Thanks for the nice speech!!
@MrCoolnamehuh
@MrCoolnamehuh 11 жыл бұрын
Found this to be one of the most useful python talks thus yet on youtube.
@VibeWithSingh
@VibeWithSingh 8 жыл бұрын
This presentation is simply awesome !! hands down !!
@richieKostenko
@richieKostenko 9 жыл бұрын
This is probably the best presented programming video I've ever seen. Thanks!
@joedempseysr.3376
@joedempseysr.3376 6 жыл бұрын
I thoroughly enjoyed your presentation! Take the old-fashioned, ugly, slow way of doing things and instead do the new-fangled, beautiful, fast way. I love it!
@thatguy1000001
@thatguy1000001 10 жыл бұрын
I literally just watched this a second time for the entertainment value! Raymond Hettinger is hilarious! Not only was watching this a lot of fun, but super-informative and efficient. I'm going to go check out some of his other talks. If I'm gonna learn python, it might as well be from this dude!
@tdao9741
@tdao9741 2 жыл бұрын
And how’s yours python 7 years later?
@guhkunpatata3150
@guhkunpatata3150 2 жыл бұрын
Where have I been All this time only to find this GEM right now ??? This video is very great and a MUST WATCH for any pythonista
@VladimirSanchez
@VladimirSanchez 10 жыл бұрын
I can listen to Mr Hettinger all the time!!! Thanks for the presentation and your contributions.
@eduardoherrera3696
@eduardoherrera3696 4 жыл бұрын
Thank you so much for this wonderful lecture. I think this insight might be helpful . As a Novice programer I had a few issues understanding how some of core functions in Python worked and what was because the people who taught me where using derived language examples. Phrases like "if you've code an another language....". But I haven't well time passed I learned the hard way later got to this video and inevitably think that things would been a lot easier for me if this lecture was around.
@mpgovinda
@mpgovinda 4 жыл бұрын
Just one video and learned more things worth years... great tips!
@DmitriiGlandarius
@DmitriiGlandarius 7 жыл бұрын
Very nice. In just 50 minutes I learned moe then in the last month.
@kumarc634
@kumarc634 8 жыл бұрын
at 7:22 it should not for i, color in enumerate(colors): print i,'--->',color[i] but for i, color in enumerate(colors): print i,'--->',color may be printing mistake
@mByyurt
@mByyurt 7 жыл бұрын
I was here to write that. Nice catch.
@a8lg6p
@a8lg6p 7 жыл бұрын
I was about to make that comment. Either way works the same, but it's exactly what he's been telling us not to do, so clearly a mistake.
@adelkhafizova
@adelkhafizova 7 жыл бұрын
Also stopped the video to see if someone has pointed this out already)
@aikimark1955
@aikimark1955 7 жыл бұрын
Do you think that Raymond is reading these comments?
@EyeIn_The_Sky
@EyeIn_The_Sky 6 жыл бұрын
I think you do have to have the: print(i,'-->', color [i]) otherwise you will just get all the colours beside each index in a row repeated 4 times. Unless this is just in Python 3?
@hoanghaipham4318
@hoanghaipham4318 3 жыл бұрын
What amazing techniques! Why I haven't seen this sooner. Thank you a lots
@espeon91
@espeon91 9 жыл бұрын
Really insightful video. Didn't even notice the time fly by. Already feel better as a Python programmer.
@jasonstapley6822
@jasonstapley6822 5 жыл бұрын
That talk was amazing. Will need to watch this video a few times.
@CraigPerry
@CraigPerry 10 жыл бұрын
Raymond's an entertaining, engaging presenter. Good mix of material here, definitely came away richer for the experience.
@77aHeB
@77aHeB 2 жыл бұрын
First - this is an awesome piece, I didn't knew Raymond Hettinger was to be blamed for so many iterators in python, and I truthfully love this guy now that I know what he did for most of my days! :) There is a small bug in 15:58 onwards due to the missing tgt variable, but the more important thing is that it can get even more beautiful (IMHO) from: def find(seq, target): for i, value in enumerate(seq): if value == target: break else: return -1 return i to this: def find(seq, target): for i, value in enumerate(seq): if value == target: return i return -1 not that the for/else is not nice in some other cases, this was probably just not the right example for it.
@mattralston4969
@mattralston4969 4 жыл бұрын
Thank you for the lecture, sir. I appreciate the review of some critical "dos and don'ts" for beginners.
@toomuchtruth
@toomuchtruth 6 жыл бұрын
"Start open source contributions to project by going in and placing doc strings". This is a brilliant idea! I've wanted to start contributing for so long but didn't feel I have the skills, I'm gonna do this!!!
@bonbonpony
@bonbonpony 5 жыл бұрын
Yes, do it. There's a lot of extremely crappy documentation for Python modules :q
@fintohaps
@fintohaps 9 жыл бұрын
Amazing stuff! Love the functional style entering Python
@Krazness
@Krazness 7 жыл бұрын
this may be the best python video I've seen online
@bonbonpony
@bonbonpony 5 жыл бұрын
Yeah, there should be a video like this one for every language out there. One can learn much more about how to write clean code from such videos than from any crappy tutorial.
@3ombieautopilot
@3ombieautopilot 10 жыл бұрын
This is priceless! Thanks for the upload.
@snowblindu
@snowblindu 8 жыл бұрын
I wish this guy was my teacher
@hdggoyo7423
@hdggoyo7423 8 жыл бұрын
+snowblindu he's cocky and not interesting at all
@PhilGerb93
@PhilGerb93 8 жыл бұрын
+hd ggoyo pffft, hater. I wish he was my teacher too!
@jfolz
@jfolz 8 жыл бұрын
+hd ggoyo He added a lot of the cool stuff to Python so he gets to be cocky.
@hdggoyo7423
@hdggoyo7423 8 жыл бұрын
+riDDimann i was just joking, he looks like a cool dude, chill guys
@AlfredEssa
@AlfredEssa 6 жыл бұрын
He is cocky, but he knows his shit. If you are going to be a hater, prove your chops.
@darkopz
@darkopz 5 жыл бұрын
Initially I refuse to believe any developer wouldn’t know what “in” semantically means, but then I’m reminded of all the code I’ve seen.
@bonbonpony
@bonbonpony 5 жыл бұрын
Most programmers nowadays have just learnt to parrot other people's code without any actual in-depth understanding of what it does or why is its syntax the way it is. Mostly "thanks to" online tutorials, like those on Udemy or alike where blind lead the blind :q I still have people giving me weird looks when I write C++ code like this: if (a == b) do_something(); else do_something_else(); instead of wrapping the functions into braces, because they think that those braces are part of the syntaxt and have to be there. Or if I write something like this: cout
@mingosutu
@mingosutu 4 жыл бұрын
In python you make your video with audience, clapping, laughing and commenting. Python is fantastic.
@sudiptochatterjee
@sudiptochatterjee 6 жыл бұрын
Thanks a lot for this video. Raymond is an awesome guy.
@derekeden1163
@derekeden1163 5 жыл бұрын
probably best python video ive ever seen
@manojbisht7018
@manojbisht7018 7 жыл бұрын
Documented version gist.github.com/JeffPaine/6213790
@blabnfriends
@blabnfriends 7 жыл бұрын
gratzi
@ciscohdz
@ciscohdz 7 жыл бұрын
hero, that is you
@mountainhobo
@mountainhobo 10 жыл бұрын
Love Raymond's presentation style.
@michaelfresco2769
@michaelfresco2769 7 жыл бұрын
Yes! It's very entertaining.
@anAlokDubey
@anAlokDubey 3 жыл бұрын
I m watching 7 years old video and leaning lots of amazing things.... :-) you are really great.
@dpo357
@dpo357 9 жыл бұрын
I learned a LOT with this video, Kudos Raymond Hettinger 15:52 for/else, I've always wanted this. For a long time now, I've replicated this behavior in Java enclosing the for inside try/catch and throwing a custom exception of the kind 'BrokenLoop', which looks waaay better, despite feeling forced and inappropriate. Huge like.
@rusca8
@rusca8 2 жыл бұрын
Man, this is awesome.
@GraficaObscura
@GraficaObscura 11 жыл бұрын
Wow - amazing talk - informative, concise, immediately useful. Thank you.
@anubhav9476
@anubhav9476 3 жыл бұрын
Man even though this is not quite as relevant to me today, I really love his presentation style
@defined_user
@defined_user 4 жыл бұрын
Such a great video! Many thanks!
@Alex_Khouri
@Alex_Khouri 7 жыл бұрын
Amazing video - thank you so much!
@AhmedBalfaqih
@AhmedBalfaqih 9 жыл бұрын
I kept smiling. Thank you.
@JamesSKim
@JamesSKim 11 жыл бұрын
This lecture is very nice to learn advanced Python programming. After I watched this video, I realize that I have used Python almost like using C. I have used C and C++ as well as Matlab. Hence, I thought that many approaches in Python will be not much different from the conventional languages except specialized keywords. However, I realize that grammars in Python can be different from that in C.
@SvenSiegmund
@SvenSiegmund 10 жыл бұрын
I love the people who make Python! Thanks for this most enlightening talk.
@wasikhan7741
@wasikhan7741 Жыл бұрын
are you a python ninja by now?
@SvenSiegmund
@SvenSiegmund Жыл бұрын
@@wasikhan7741 I sure am 😏
@MacroAggressor
@MacroAggressor 4 жыл бұрын
This is great! I have a *much* better understanding of iterators and their purpose now. Thanks, Mr. Hettinger. edit: How did I not know about dictionary comprehensions?!? (21:05) That is AWESOME!!
@dgh25
@dgh25 Жыл бұрын
idk, kinda standard stuff in CS
@RichardGrigonis
@RichardGrigonis 2 жыл бұрын
I'm so glad that he said we should rename For as ForEach. I suggested that online some years ago, and boy did I get lambasted by everybody!
@RanjitKrishnanNair
@RanjitKrishnanNair 4 жыл бұрын
This was amazing!
@SeqMod
@SeqMod 9 жыл бұрын
this guy is really helpful. BLESS
@miguelvasquez9849
@miguelvasquez9849 Жыл бұрын
this is why i love python, the ways to write clean code.
@AbdelazizYakout
@AbdelazizYakout 9 жыл бұрын
great lesson and great presenting style!!
@purplecrayon7281
@purplecrayon7281 2 жыл бұрын
I love this man! He should write a book on clean Python code, if he hasn't already.
@jakykong
@jakykong 4 жыл бұрын
He even said I would fight him on this, but haha, oh man, the comparison functions are something I absolutely *miss*, even if I really agree with almost everything else he said and have been writing idiomatic Python for ages. I ran into a real problem the other day where comparisons were a much cleaner solution than the less obvious and potentially much slower multi-pass sorting: Sorting on multiple keys with independent ascending or descending orders. You can sort a plain tuple without any fuss if you don't mind that every key is ascending or every key is descending. But if you want to mix those, you have to do it in multiple passes, starting from the least significant key to the most significant key, and rely on timsort's stability to get the job done -- or, IMO, cleaner -- if this were Python 2, I could have expressed the comparison function with appropriate ascending/descending signs in a simple if/elif/else return 0 chain, and rapidly expressed both the intent and the functional result quickly. Python 3 even provides a conversion utility that creates wrapper objects on the fly to facilitate this need, which is a bizarrely convoluted way to accomplish what simply allowing either key function or comparison function would have.
@EdwardBriggler
@EdwardBriggler 11 жыл бұрын
brilliant talk, thanks for sharing!
@uthoshantm
@uthoshantm 5 жыл бұрын
Note that these functional constructs are now in every mainstream language such as C# and Java. So, it's not that Python has a specific capability, but experienced Python programmers do encourage the use functional constructs. This video is an example.
@nishankbani3257
@nishankbani3257 6 жыл бұрын
Excellent presentation on Python code writing.
@BryanChance
@BryanChance 2 жыл бұрын
Amazing talk..more professors like him. :) I'm starting to appreciate Python now. EDIT: Wow
@TheXutraks
@TheXutraks 10 жыл бұрын
Amazing video, really good video and tips, thanks
@dmknght8946
@dmknght8946 5 жыл бұрын
Many thanks! It is still useful for me!
@movax20h
@movax20h 4 жыл бұрын
"with ignored(OSError)". So cool. TIL. In Python 3, it is called "with suppress(...)". You can list multiple exception types too.
@jnuxadrian
@jnuxadrian 9 жыл бұрын
I think that 'return newfunc(*args)' on line 6 must be replaced by 'return saved[args]' at 41:12
@lucasfcnunes
@lucasfcnunes 5 жыл бұрын
yep. infinite loop
@DanielCallejasSevilla
@DanielCallejasSevilla 4 жыл бұрын
@@lucasfcnunes Stack overflow ;-)
@erik7726
@erik7726 9 жыл бұрын
Very good video, helps writing efficient and clean Python!
@yuli3873
@yuli3873 2 жыл бұрын
So this man made enumerate()? I love him from now on!
@bigtallslim
@bigtallslim 11 жыл бұрын
Great presentation!
@orkoxy
@orkoxy 10 жыл бұрын
At 7:26, it should be for i, color in enumerate(colors): print i, '-->', color
@Michael-jq1hl
@Michael-jq1hl 4 жыл бұрын
Hi I have recently started studying python, what is that arrow in print i,'-->',color?
@2adamast
@2adamast 4 жыл бұрын
Michael the arrow is a string
@mesbahiali4586
@mesbahiali4586 10 жыл бұрын
What a great lecture :D
@DeMurker
@DeMurker 8 жыл бұрын
Great explanations. And even 3 years late still very useful. One thing though, he says that generator expressions make things faster but when I timeit I get this: ~$ python -m timeit "sum(i**2 for i in xrange(10))" 100000 loops, best of 3: 1.74 usec per loop ~$ python -m timeit "sum([i**2 for i in xrange(10)])" 1000000 loops, best of 3: 1.39 usec per loop
@benburrill
@benburrill 8 жыл бұрын
+DeMurker Not reproducible: I got 2.57 for generator and 2.77 for list. But in any case, as you go beyond a 10 element list, you are going to get increasingly large memory and speed problems.
@Shaddycls
@Shaddycls 8 жыл бұрын
The reason beyond containers over generators affects only at memory level: using zip(iterator1, iterator2) produces a single big object which contains the sum of both containers, since when you use a generator, it only produces an element on each iteration, so you will never have the entire sum of both containers in memory, which is an optimization and faster.
@deidyomega
@deidyomega 7 жыл бұрын
Do it again, but xrange(1000000) ;-)
@AJ-et3vf
@AJ-et3vf Жыл бұрын
great video. thank you
@AliSattarBarani
@AliSattarBarani 4 жыл бұрын
Amazing Slideshow
@BillTubbs
@BillTubbs 8 жыл бұрын
There's an error on the slide at 7:13 titled 'Looping over a collection and indices'. Last line should be: print i, '-->', color
@vanshdeep91
@vanshdeep91 7 жыл бұрын
Bill Tubbs both have the same meaning brother be it color or colors [i]
@BillTubbs
@BillTubbs 7 жыл бұрын
Both have the same result but using the color iterator that enumerate creates is 'faster and beautiful' as he points out.
@VoicelessRabbit
@VoicelessRabbit 5 жыл бұрын
OMG... I have been doing hacks in python for loops trying to do what enumerate does... THANK YOU!!!
@blenderpanzi
@blenderpanzi 9 жыл бұрын
27:50 I think doing this is so common, there should be a group_by(sequence, keyfunc). You could then call it with group_by(names, len). There should also be an index_by(sequence, keyfunc). These functions would be trivial to implement, but nevertheless they are common and useful enough to be put in some standard lib (collections?).
@anonvigil628
@anonvigil628 4 жыл бұрын
This needs updated for Python 3 - I have to go hunting for which of his recommendations are still valid. The video could at least have footnotes that say which still applies in Py3.
@llewgibson
@llewgibson 6 жыл бұрын
Just stumbled across your video mate, really love the content. Liked straight away, We should connect!
@jaashutosh
@jaashutosh 7 жыл бұрын
Great Presentation.
@MrWorshipMe
@MrWorshipMe 5 жыл бұрын
Whenever you have a break in the for loop, just wrap that loop inside a function and return instead of break. If you want to return something else in case the for loop didn't break, just return after that loop. No need for else on the for. A for loop with a break and an else is not as readable as a function which just returns from the loop and after it.
@bonbonpony
@bonbonpony 5 жыл бұрын
Agreed. However it's not always that easy. For example, if you rely on a lot of state variables inside a complex loop: although factoring it into a function would seem as a great thing to have, it would also mean that you would have to find some way to carry on all that complicated context along with it :q
@MrWorshipMe
@MrWorshipMe 5 жыл бұрын
@@bonbonpony This is exactly what classes are for. Encapsulate all that context inside one class, and have that for loop as a private function. Or if that context is shared, have it inside a named tuple and pass it to the function.
@bonbonpony
@bonbonpony 5 жыл бұрын
But that's the problem: then you have to PASS it around all the time. And it's not that _all_ of that context is needed _all_ the time. Suppose the loop uses only 50% of it. Then you have to pass the other unneeded 50% of the clutter too. And it will be a mess. (Inb4 you say passing objects is cheap by reference: but it's still a mess.) Classes? No, that's not what classes are for. Classes are not just "big ol' bags for data and functions" (unfortunately, many people think of them that way.) They are means to model real-life objects as new data types, by defining their interfaces. What you meant is more like a _namespace_ or _module_ , but still it doesn't solve the problem - it just moves it somewhere else. Because all that state will now have to be shared between several functions and, as I said, not _every_ function requires _every_ piece of that state at the same time.
@user-or7ji5hv8y
@user-or7ji5hv8y 5 жыл бұрын
Do we need to add a certain python library? Some codes don't seem to work, just with Python 3.6.
@Achrononmaster
@Achrononmaster 5 жыл бұрын
izip() in Python2 is zip() in Python3. Also, you can loop over the longer of the lists. So, import itertools colors = ['red','green,'blue','purple']; shapes =['circle,'triangle','square'] for col, shp in zip_longest(colors,shapes): print( col, '--->', shp) >>> red ---> circle green ---> triangle blue ---> square
@PramodL
@PramodL 10 жыл бұрын
Can't recommend this talk enough. Must watch to take your python chops to the next level.
@rdoetjes
@rdoetjes 10 жыл бұрын
I learned a lot! Then again I don't use Py3 because I use Jython which only 2.7 is stable and a compositing suite that has 2.7 also. The problem with functional programming is (and this video proves it) is that you need to know the function names and what to look for. This means actually bothering to read lots of papers and documentation and then you need to remember them. People aren't very good in remembering things especially non-descriptive. So only people who really dedicated in a language will know these things but Python is an awesome language but it's not a core programming language for most. Which is Java, C# or C++ and there you don't have a lot of functional functions. I love C because it has very few keywords, STL is great but I ALWAYS need to to reread who it works. Functionally very powerful but it's even less descriptive than these functions. So now that I know these situations explained by Raymond I will look them back here and read the docs apply them several times and probably by the 7th or 9th time I will remember it. That is until I don't use Python for 2 years again and forgotten all about them :D
@palpytine
@palpytine 5 жыл бұрын
Many (if not most) FP languages offer some sort of modules or namespaces to handle this exact problem of discovery, it's definitely not an issue with the paradigm in general.
@gibbostooth
@gibbostooth 5 жыл бұрын
43:47 "ignored" is now called "suppress" and it's part of "contextlib" library.
@andik70
@andik70 7 жыл бұрын
7:13 isnt the enumerate example 'wrong'. Shouldnt colors[i] be replaced by color?
@vineetbhargava4141
@vineetbhargava4141 19 күн бұрын
At 41:09 - in the cache decorator definition - line 6: if we return newfunc(*args) wouldn't it cause infinite calls?
@RiptheJacker
@RiptheJacker 10 жыл бұрын
Really good video. Starts off as a video for python beginners but is insightful for experienced developers as well.
@MakrandGuravM
@MakrandGuravM 10 жыл бұрын
Akhil Gopi u in python development?
@RiptheJacker
@RiptheJacker 10 жыл бұрын
yes :)
@MakrandGuravM
@MakrandGuravM 10 жыл бұрын
cool
@safeTmeeting
@safeTmeeting 3 жыл бұрын
hi, new to python. when he prints on the first slide(i**2). thats exponential right? 0^2, 1^2, 2^2, right? or is that doing something else?
@johnjohnson5814
@johnjohnson5814 4 жыл бұрын
Is there a list sorting function with a key for frequency of occurrences?
@eskays9840
@eskays9840 7 жыл бұрын
very much required for a beginner like and why would someone dislike this ....
@bonbonpony
@bonbonpony 5 жыл бұрын
Maybe they code in C ;)
@SanteeRocks
@SanteeRocks 3 жыл бұрын
This guy is a legend
@johncongerton7046
@johncongerton7046 Жыл бұрын
Most enlightening talk
Python's Class Development Toolkit
45:56
Next Day Video
Рет қаралды 237 М.
Stop Writing Classes
27:29
Next Day Video
Рет қаралды 932 М.
Пранк пошел не по плану…🥲
00:59
Саша Квашеная
Рет қаралды 7 МЛН
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 107 МЛН
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 7 МЛН
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 56 М.
When Python Practices Go Wrong - Brandon Rhodes - code::dive 2019
1:00:51
code::dive conference
Рет қаралды 95 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 190 М.
Python 3 Metaprogramming
3:00:24
Next Day Video
Рет қаралды 244 М.
The Mental Game of Python - Raymond Hettinger
1:10:00
SF Python
Рет қаралды 123 М.
Raymond Hettinger, Keynote on Concurrency, PyBay 2017
1:13:53
SF Python
Рет қаралды 150 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
Loop like a native: while, for, iterators, generators
29:15
Next Day Video
Рет қаралды 117 М.