Thanks, Fred, for bringing it in. Despite heavy using Path for files for a long time, I personally severely underestimated how convenient Path actually is for URLs. Way better instead of: good_url = '/' + some_url.strip('/') + '/myendpoint' to say: good_url = Path('/') / Path(some_url).name / 'myendpoint' Not much of being shorter but way more visually pleasant.
Agreed, though often I do not have the Path module loaded in my app at all, and I'll then use f-strings to build up a URL rather than load the module : root = some_url.strip('/') good_url = f"/{root}/myendpoint"
Thanks Fred, another great and comprehensive video. I really enjoy your in-depth discussions of individual modules, either from the standard library or third-party libraries! Would love a similar video about the `re` module with some regex magic :) Worthy additions are two of my favorite `pathlib` methods: `.read_text()` and `.write_text()`. When starting out with Python it was really puzzling to me why I had to write two lines and a context manager to read a simple text file. With `pathlib` it is as simple as `p.read_text(file)` instead of the usual `with p.open() as f: f.read()`
Thanks, glad you like the videos. As far as using a context manager for opening files, one major advantage over read_text() (or write_text() for that matter) is that you can read/write a large file in chunks, as opposed to reading it all in memory at once. That way you can read/write files that are very large with little to no impact on your memory/swap file.
Think of Pathlib as class based higher level alternative to os.path. Think of the difference between the time and datetime modules. You can certainly completely ignore the datetime module and do everything with the lower-level functionality available in the time module, but datetime makes it easier to manipulate dates and times. Same with PathLib. For a more thorough rationale and explanation behind the PathLib module see this pep: peps.python.org/pep-0428/
Fred, thanks for the videos. As a person from math background i enjoy learning from your videos. I would like to ask you if you could create an introductory video about the whole set of software engineering. Let Swe= { {fron end}, {back end}, {data bases} and etc …}. I am transitioning from math, but i cant find a video explaining about the whole industry. It would be nice if we had that video which tells us what knowledge is necessary for each subset and amount of knowledge necessary for different experience levels in that subset. As of know i dont even know what path to choose, what material to learn, how far to study before applying for a job. If you were starting today (0 cs knowledge, heavy in math) what path would you choose in swe, and what material necessary to learn for that path? It would help a lot.
Dude you don't know how long I've looked for a good video on this module. Thank you so so much and may you keep up the good work
Glad it helped!
I'm a huge fan of Dr. Fred. I've found him on Udemy, from where I just finished the Deep Dive Part 2 of the course series... going forward to Part 3 😅
Thanks, Fred, for bringing it in. Despite heavy using Path for files for a long time, I personally severely underestimated how convenient Path actually is for URLs. Way better instead of:
good_url = '/' + some_url.strip('/') + '/myendpoint'
to say:
good_url = Path('/') / Path(some_url).name / 'myendpoint'
Not much of being shorter but way more visually pleasant.
Agreed, though often I do not have the Path module loaded in my app at all, and I'll then use f-strings to build up a URL rather than load the module :
root = some_url.strip('/')
good_url = f"/{root}/myendpoint"
Thanks, Fred! Clear and detailed explainations!
You're very welcome!
The best channel to learn python
Glad you like it!
not as much to learn as to advance in...
Thanks Fred, another great and comprehensive video. I really enjoy your in-depth discussions of individual modules, either from the standard library or third-party libraries! Would love a similar video about the `re` module with some regex magic :)
Worthy additions are two of my favorite `pathlib` methods: `.read_text()` and `.write_text()`. When starting out with Python it was really puzzling to me why I had to write two lines and a context manager to read a simple text file.
With `pathlib` it is as simple as `p.read_text(file)` instead of the usual `with p.open() as f: f.read()`
Thanks, glad you like the videos.
As far as using a context manager for opening files, one major advantage over read_text() (or write_text() for that matter) is that you can read/write a large file in chunks, as opposed to reading it all in memory at once. That way you can read/write files that are very large with little to no impact on your memory/swap file.
@@mathbyteacademy That is a very good point! Thanks for pointing it out.
Thank you so much Fred!!! I have learned so much useful/in-depth things from your videos.
Glad it was helpful!
Thanks Fred,
I would like to see something about os library, and how os.path differs from this and the pros and cons of each
Think of Pathlib as class based higher level alternative to os.path. Think of the difference between the time and datetime modules. You can certainly completely ignore the datetime module and do everything with the lower-level functionality available in the time module, but datetime makes it easier to manipulate dates and times. Same with PathLib.
For a more thorough rationale and explanation behind the PathLib module see this pep: peps.python.org/pep-0428/
@@mathbyteacademy
Thanks for your reply and explanation, as always clear and understandable.
Fred, thanks for the videos. As a person from math background i enjoy learning from your videos. I would like to ask you if you could create an introductory video about the whole set of software engineering. Let Swe= { {fron end}, {back end}, {data bases} and etc …}.
I am transitioning from math, but i cant find a video explaining about the whole industry. It would be nice if we had that video which tells us what knowledge is necessary for each subset and amount of knowledge necessary for different experience levels in that subset.
As of know i dont even know what path to choose, what material to learn, how far to study before applying for a job. If you were starting today (0 cs knowledge, heavy in math) what path would you choose in swe, and what material necessary to learn for that path? It would help a lot.
th-cam.com/video/SzJ46YA_RaA/w-d-xo.html
Thanks 😊
You're welcome!