Seems like the whole series is heavily inspired by James Powell's talk about advanced Python concepts, which is certainly a good thing :) Really nice series, thanks! :)
This series was great! Can you do a tutorial on some of the more meta topics: how to use the logger? How to structure a project directory and why (eg are tests in their own folder or the main folder)?
They can be, but they don't have to be. You could also redirect the output stream of the print function inside a context and restore the default (sys.stdout) at exit. Generally this really can clean up code and helps to write Python code that looks like "weird english", not like code. Especially when you have a block of code that somehow should behave differently than it usually would.
Beautiful series, short, concise and clear. I've been using python for 10 yrs now and still neglected so many of the basic things you explained. Thank you, very usefull. How about one more video on the last bit you showed on accessing a variable from different resources at the same time? Also __future__ statement would be nice to know.
@3:50 You say the two do the exact same thing. But _dir(open)_ shows no ___enter___ or ___exit___ methods. Is it doing something hidden? Or maybe 'with' is overridden for use with 'open' ??
dir(open) will show you the attributes of the open-function itself. It returns a file-like object which likely (i havent checked the src code) implements __enter__ and __exit__ if it is written in python not c. So: dir(open('somefile', 'somemode')) Should show the dunder methods
Unfortunately type == Exception breaks the Liskov substitution principle & isinstance(Exception) probably catches the other error. What would be a good approach to this dilemma?
Hi Tim. I like the series a lot and learned much from it and from other videos in your channel. Keep teaching because you are great at it. Can you do a video about property?
Do we have any code in python or in Linux for shifting column to rows data like. Input file like Input.txt have below data Shyam 1 2 3 Shyam 7 2 Shyam X Y Z A Required output.txt have below data Shyam 1, 2, 3 Shyam 7, 2 Shyam X, Y, Z, A
This stock is currently unavailable for trading as it has been moved to the BZ series by NSE for violating SEBI guidelines Mari holding ma hai bhi Oder rejected ho raha hai
Use whatever you like for basic syntax and functionality, then write some programs. While doing that, you'll usually have to google a lot, so you learn what you actually need. After that you are at a confident beginner level and are ready to read source code of some projects (maybe a tool you use anyway). There you again will find interesting new things to read up about. Or you take a structured course (TH-cam, bootcamp, online course, book, whatever you like). I did the first and then later skipped through some free courses to see if they cover things I did not know yet. That's also why I follow this series.
My guess is, that a raised exception will be otherwisely catched by the wrapper-function of that generator. If you wanna go first, just include a try/except block within the generator body.
I have a nice context manager that chdir s to a remote directory to do work and write files, and always comes home no matter what. Not all dirs get good data every day
I think, in practice, it's not a big problem to leave files open after your program finishes. Because your OS allows each process a maximum number of open files. Every time you restart your program, it becomes a new process which has 0 open files. So that, you wont get too many open files error.
@@bobedgar6647 but it's not like you write code to open hundreds of files everyday. Of course close them in that case but other times, while it's a good habit to use context managers, really there's no harm at keeping a few files open.
@@aim2986 I’ve always worked near the hardware and have nearly always had to deal with running out of FDs if you just open and forget. Think packaging up software distributions or checking entire file distribution checksums, etc. It’s just bad practice to leave limited resources to rust, as it were. Just don’t do that. I’m probably a few years older than you are and can remember well the days of 1024 open file limits. Those get used up pretty fast if you’re not careful. Like not freeing memory when you’ve finished with it. The languages take care of most memory management these days. It wasn’t always thus
@@bobedgar6647 Of course you should close your files if you are doing something like checking checksums of lots of files. But that's not what I'm saying. Also, I'm not sure about what you mean by 1024 open file limit of "old times". Although you can increase it, there's a per process open file limit which is 1024 or 512 (may be different depending on the OS) by default even today. Maybe you mean total number of open files opened by all processes? If so, yes it'd be more problematic. But again, problems of past are the problems of past.
Learning "pythonic" ways not only to construct efficient code but also communicate with fellow developers with as few misunderstandings as possible. Improving time & space complexity is a totally different issue.
Im going to have to watch that a few more times and go back to #3 of the series first. Those methods didn't have to be called because they were defined as self, the "instance" of the class? I need to learn "with" also. Cant skip any of these.
yes, self (or whatever you call the 1st parameter in an instance method) is the instance, but the dunder enter/exit methods are called as part of the with...as statement.
No, you're wrong. __init__ is equivalent of constructor in C++. About destructor: In Python we don't have sth like destructors (there is garbage collector there) but we can define __del__ method which is ~similar to destructor in C++
Most comments show they liked the videos. I also liked the knowledge I got from it, but there's room for improvement on how the tutorials are presented. Since these are expert videos, I think it would be better to provide a use-case of the topic before actually teaching the topic. Most of your videos come with teaching the topic before mentioning the use-case. Maybe it's just how I learn.
A hidden way? Minus the bottom half of the ctx_mgr class being filled up with a bunch of ugly @** dunder methods. XD Also, I believe the os module has either a class or a method called semaphore. I've never used it, but in linux, a semaphore is a slightly advanced form of lock implemented in C. I would bet money that the Python version is just a wrapper around a C semaphore.
What features would you like to learn about next?! Let me know...
Socket programming series
multiprocessing
Tech With Tim cool threading stuff!
Cython please
Or maybe numba so I can learn to speed up complex calculations
Maybe cover the GIL?
Thanks Tim for providing free education. such a talented guy ❤
Hi Tim, nice video, this series just keeps getting better. An a video idea(or series idea) I would recommend is design patterns in Python.
Seems like the whole series is heavily inspired by James Powell's talk about advanced Python concepts, which is certainly a good thing :)
Really nice series, thanks! :)
This series was great! Can you do a tutorial on some of the more meta topics: how to use the logger? How to structure a project directory and why (eg are tests in their own folder or the main folder)?
Context managers are like error exceptions....
Very very useful.
💯💯💯
They can be, but they don't have to be. You could also redirect the output stream of the print function inside a context and restore the default (sys.stdout) at exit.
Generally this really can clean up code and helps to write Python code that looks like "weird english", not like code.
Especially when you have a block of code that somehow should behave differently than it usually would.
@@nmertsch8725
But, for this, we can usw Cython ( combinimg Python with C language )
Beautiful series, short, concise and clear. I've been using python for 10 yrs now and still neglected so many of the basic things you explained. Thank you, very usefull.
How about one more video on the last bit you showed on accessing a variable from different resources at the same time? Also __future__ statement would be nice to know.
Really enjoyed this playlist. Thanks!
Tim you are a godsend!
Definitely one of the more useful things to know. Great series, Tim.
@3:50 You say the two do the exact same thing. But _dir(open)_ shows no ___enter___ or ___exit___ methods. Is it doing something hidden? Or maybe 'with' is overridden for use with 'open' ??
dir(open) will show you the attributes of the open-function itself. It returns a file-like object which likely (i havent checked the src code) implements __enter__ and __exit__ if it is written in python not c.
So:
dir(open('somefile', 'somemode'))
Should show the dunder methods
Hey Tim! Love this series. Could you upload a video on python app development? Would love to see it.
Great series so far,Thanks
Wow...this is really cool. I'm totally new to Python....very cool feature.
Pls make a video explaining descriptor in detail ,
Btw Osm video ❤️
What if we do not give the parameter of filename and method for the file, it will still works right?
Can we left it empty here?
It was great, Thank you Tim :)
I was strugling to make a filemanager class but this tutorial helped very much thanks
This series makes concepts I always tried to push away very fun and useful. Amazing understanding and explaining, thank you so much.
Glad you enjoyed it!
Unfortunately type == Exception breaks the Liskov substitution principle & isinstance(Exception) probably catches the other error. What would be a good approach to this dilemma?
Amazing. Thank you.
Great series. Thank you very much.
Hi Tim. I like the series a lot and learned much from it and from other videos in your channel. Keep teaching because you are great at it. Can you do a video about property?
Such a smart and knowledgeable young man. I'm jealous
thank you so much for this channel
I had no idea you could use a try statement without an except block. My mind is blown.
Awesome video as usual 👌
Do we have any code in python or in Linux for shifting column to rows data like.
Input file like Input.txt have below data
Shyam
1
2
3
Shyam
7
2
Shyam
X
Y
Z
A
Required output.txt have below data
Shyam 1, 2, 3
Shyam 7, 2
Shyam X, Y, Z, A
This stock is currently unavailable for trading as it has been moved to the BZ series by NSE for violating SEBI guidelines
Mari holding ma hai bhi Oder rejected ho raha hai
from contextlib import contextmanager
@context manager
def file(filename, method):
print('enter')
file=open(filename, method)
yield file
file.close()
print("exit")
with file("text.txt", "w") as f:
print("middle")
f.write("hello")
Love your videos! Do you have any advice for learning a new programming language on your own? Please let me know👍
Read docs or find a good teacher
Use whatever you like for basic syntax and functionality, then write some programs. While doing that, you'll usually have to google a lot, so you learn what you actually need.
After that you are at a confident beginner level and are ready to read source code of some projects (maybe a tool you use anyway). There you again will find interesting new things to read up about.
Or you take a structured course (TH-cam, bootcamp, online course, book, whatever you like).
I did the first and then later skipped through some free courses to see if they cover things I did not know yet. That's also why I follow this series.
How would you handle exceptions in the generator version? Great video btw!
My guess is, that a raised exception will be otherwisely catched by the wrapper-function of that generator.
If you wanna go first, just include a try/except block within the generator body.
I would like to see a tutorial about typing.Concatenate use-cases and its limits.
i would love you to show us how to use the GEP gun for silent takedowns
thanks for the video!
Socket programming series please
Programmers like this if you also want
Great Series Tim, Thanks!
what is your IDE
pudny I think he’s using PyCharm
@@external111 He uses pycharm for big projects, but for this tuts he uses sublime text.
Can't wait to watch that memory lock video...
I have a nice context manager that chdir s to a remote directory to do work and write files, and always comes home no matter what. Not all dirs get good data every day
I like how you show how things wok in the background. Could you do that for other higher level things?
Thanks a lot~!
I think, in practice, it's not a big problem to leave files open after your program finishes. Because your OS allows each process a maximum number of open files. Every time you restart your program, it becomes a new process which has 0 open files. So that, you wont get too many open files error.
But if you open lots of files or do it in a loop you’ll rapidly run out of file descriptors. Close your files when you’ve finished with them.
@@bobedgar6647 but it's not like you write code to open hundreds of files everyday. Of course close them in that case but other times, while it's a good habit to use context managers, really there's no harm at keeping a few files open.
@@aim2986 I’ve always worked near the hardware and have nearly always had to deal with running out of FDs if you just open and forget. Think packaging up software distributions or checking entire file distribution checksums, etc. It’s just bad practice to leave limited resources to rust, as it were. Just don’t do that.
I’m probably a few years older than you are and can remember well the days of 1024 open file limits. Those get used up pretty fast if you’re not careful. Like not freeing memory when you’ve finished with it. The languages take care of most memory management these days. It wasn’t always thus
@@bobedgar6647 Of course you should close your files if you are doing something like checking checksums of lots of files. But that's not what I'm saying.
Also, I'm not sure about what you mean by 1024 open file limit of "old times". Although you can increase it, there's a per process open file limit which is 1024 or 512 (may be different depending on the OS) by default even today. Maybe you mean total number of open files opened by all processes? If so, yes it'd be more problematic. But again, problems of past are the problems of past.
@@aim2986I open hundreds, if not thousands of files, every day
nice vid
i dont understand the point of expert tutorials when will i use that is it faster or..?
dino krivic
I think the point is that you need some more advanced knowledge to understand what he is doing
Learning "pythonic" ways not only to construct efficient code but also communicate with fellow developers with as few misunderstandings as possible. Improving time & space complexity is a totally different issue.
Hey, I would like to know what font you use for pycharm. Thank you, great video!
you shouldn't call the parameter 'type' because it shadows the inbuilt type function, instead "exc_type, exc_val, exc_tb" are better names
It this really for expert ?
its just more advanced features, "expert" is subjective but this fits with the series
Tech With Tim no I’m joking you do good job thanks
Im going to have to watch that a few more times and go back to #3 of the series first. Those methods didn't have to be called because they were defined as self, the "instance" of the class? I need to learn "with" also. Cant skip any of these.
yes, self (or whatever you call the 1st parameter in an instance method) is the instance, but the dunder enter/exit methods are called as part of the with...as statement.
Similar to a constructor and destructor in C++ objects
No, you're wrong.
__init__ is equivalent of constructor in C++.
About destructor:
In Python we don't have sth like destructors (there is garbage collector there) but we can define __del__ method which is ~similar to destructor in C++
Most comments show they liked the videos. I also liked the knowledge I got from it, but there's room for improvement on how the tutorials are presented. Since these are expert videos, I think it would be better to provide a use-case of the topic before actually teaching the topic. Most of your videos come with teaching the topic before mentioning the use-case.
Maybe it's just how I learn.
make a video uploading or film uploading site using django and js
So instead of writing 2 lines of code to complete our task, we write 20 to do the same fuckin thing?
A hidden way? Minus the bottom half of the ctx_mgr class being filled up with a bunch of ugly @** dunder methods. XD
Also, I believe the os module has either a class or a method called semaphore. I've never used it, but in linux, a semaphore is a slightly advanced form of lock implemented in C. I would bet money that the Python version is just a wrapper around a C semaphore.
🖤
do you realize how horribly I am farting today?
more more more!!!!!!!!!!!!!!!!!!!!!!!!!!
Ma an expert tutorial on pygame!!!
ffs its E-xit with an E, not Ayxit.
No wonder you interned at Microsoft lol
eggzit
add more comment bruh
to many reply
Great tutorial! Thanks Tim!