Комментарии:
Really helpful. Thanks for the video. One question. Is there any performance loss in this approach ?
ОтветитьOMG, use an IDE for crying out loud
Ответитьtks, it helps a lot
Ответитьthe video image is too poor, you need to fix it more
Ответитьthanks!
Ответитьyield versus return. what is the difference?
Ответитьhow do you get terminal code prompts and suggestions like in the video? could it do that on pycharm terminal and console?
Ответить2021 still the best explanation on the web.
Ответить2 years of programming in Python and I continue to find things that keep surprising me. Thank you Guido!
Nice video, I love Real Python, always the best and most clear explanations.
I am now going to write context managed classes for connection objects. Love this!
Note: one can write code to open a file, then read/write a file, but may or may not remember to close the file, and even if they do close the file, it's less likely to be done in a 'finally:' clause, so there is no guarantee it will be closed.
The point is, try/finally wouldn't even get used for open/close (because people can write bad code, and it still seems to 'work'). This is why we have a context manager: to make python play nice with the OS.
Also, I think the contextmanager decorator code communicates what it is better than the class code, even to someone who may not well understand decorators and generators.
with Much(love):
me.thank(you)
Thanks bro
ОтветитьGreat explanation, with the user defined class and all. Thank you!
Ответитьwhich code editor is this??
ОтветитьThe only generators I like, are those who generate money........
Ответитьwith explaind as very return well # (It's very pythonic!)
ОтветитьWhich REPL are you using in the video? It looks awesome, is it ptpython?
ОтветитьThis saved me a whole line of code, and for that I'm grateful <3
ОтветитьExcellent!!! Nice and clear
ОтветитьThanks...
ОтветитьWow, I'm really thankful for your explanation!
ОтветитьWhat is the point of "f"?
Ответить17 March 2020 - One word, Amazing and thanks!
ОтветитьMaybe you should close the video by saying: "Use the 'with open' syntax to optimize your file opening code realizing what's going on structurally within python"
ОтветитьNicely explained sir. I'm ur new subscriber. Thanks a lot for this vedio.
ОтветитьVery interesting! I got a little confused on the last example though xD
Is not the decorator already closing the file, making the f.close() inside managed_file function a little redundant?
really excellent. one of the clearest technical explanations i've seen
ОтветитьWhat do you mean by "leak resources" by not using with?
Ответить2019 still best explanation on the web.
ОтветитьIn my case, the program sometimes RANDOMLY outputs the keys with the ASCII table form.
Ex: "\x08" pressed
sometimes it works ok. anyone knows why
This video stucks after few seconds. Doesn't move after about 40sec. Kindly upload again.
ОтветитьRandomly I ended up here found this too good. Now I am gonna watch all of these.
ОтветитьCould you please tell me how the ,, exit file " would work after that I have written "printed" an output to a text file ?
Thanks in forward :)
I was just wondering about this the other day. Super clear explanation. Thanks!
ОтветитьNice video, thanks!
ОтветитьThis is the best god damn video on the "with" statement I have ever seen.
ОтветитьThank you so much!
ОтветитьHey, nice one.
ОтветитьNoob question -- can I use my own function in the statement and it operates normally?
Like,
def my_function( ):
complex junk here
with open('file') as fileObj:
my_function( )
I believe you should put the line where you open the file outside of the try statement. Otherwise, if the file doesn't exist, an error is raised, and in addition in finally you call the close on the file handler var which wasn't created. As a result, 2 errors raised.
ОтветитьBeautifully done. Do the mugs on your site support you?
ОтветитьHi, thank you very much. Your videos are really helpful. Well explained! Kudos to you.
ОтветитьThis is way more helpful than the stack overflow page. Thanks
ОтветитьHi Dan,
do you plan to release a printed version of your book in the future?
I enjoy your videos and I will be looking for your book(s).
Ответить