python: what is `__file__`? (beginner - intermediate) anthony explains #375

preview_player
Показать описание
today I show `__file__` and how you can use it to find files relative to python scripts / modules!

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

nice topic. awesome explanations. Really helpful. Thank you for everything you do!

pythoff
Автор

Awesome solution to a common problem, thanks Anthony. Don't know why this made me think of this, but would you be interested in covering the topic of relative imports? Maybe you already did but it was a topic that bugged me quite a bit. Merry Christmas!

AZIARGROUS
Автор

Super handy trick. I almost always just pass __file__ directly into pathlib.Path, is there any danger in that. I had no idea that the absolute / relative path difference existed.

WaylonWalker
Автор

Wow, flask.__file__ is super useful, I wish I knew it before, it would've saved me a lot of annoying mouse clicks : }
Thank you for the video, Anthony!

dddsa
Автор

Thank you for your lessons!
Question . For what do you use PWD in python $PWD/t.py?

RuslanSkiraUkraine
Автор

Merry Christmas Anthony,
Can you go over interprocess calls where a code like this (below)
can be used to control the stdin and stdout of the debugger from the parent process

process = Popen(['python', '-m', 'pdb', 'sample.py'], stdin=stdin, stdout=stdout) #Custom debugger that writes (n, s, l, p) and also reads output
Thanks

lm