Fantastic, thank you. I never knew this. I learn something new from you almost every video. As a beginner I can already see this making my debugging so much better and easier.
There should be caveat that this should only be used for quick debugging. Otherwise, you're in for a world of hurt. Logging is what should be used for debugging as it can disable it with a single change.
If you create an object, my_object, from your own class, and try to print it with print(f"{my_object = }") you may not see what you expect. For it to work properly your class MUST implement __repr__. It will not work if you only implement __str__
That's awesome. Didn't know, but it should save key and eye strokes writing str n repr functions. Great for for debugging too. Smarter way of doing it especially if your tracking a lot of text output. 🖖😎👍 p.s. I'm not going back to rewrite all of those I wrote naively, but I might clean a few up as I go along. 😉
Interesting thing to know but I kind of don't recommend it for debugging. also it is not working for me. Maybe there's more to this than just putting those equal sign
If you want print string anything like -+_()/\{}[]=*$% operators. Backslash etc, aur if you fetch string from internet and you don't know what is inside that string, For example myText = r"\{}[]=$%_-+()/*, myDer()" The output will be some what is inside myText r"value, method, etc literally anything" r is a Raw String, it will print as it
Great! It also works with format specification, e.g. print(f'{value = :.3f}')
Fantastic, thank you. I never knew this. I learn something new from you almost every video. As a beginner I can already see this making my debugging so much better and easier.
There should be caveat that this should only be used for quick debugging. Otherwise, you're in for a world of hurt. Logging is what should be used for debugging as it can disable it with a single change.
This equal feature is added and works from version 3.8
I did a lot of print("response", reponse). Now on I could do print(f"{response = }")
Thumb up for more F string tips, and thanks.
If you create an object, my_object, from your own class, and try to print it with print(f"{my_object = }") you may not see what you expect. For it to work properly your class MUST implement __repr__. It will not work if you only implement __str__
That's awesome. Didn't know, but it should save key and eye strokes writing str n repr functions. Great for for debugging too. Smarter way of doing it especially if your tracking a lot of text output.
🖖😎👍
p.s. I'm not going back to rewrite all of those I wrote naively, but I might clean a few up as I go along. 😉
Great Man , Thank for sharing your knowledge !!!
Nice tip Fanks!!
Love your work mate. Great tip
Very good! Keep going with your channel
thanks for this video, this is really helpful!
Interesting thing to know but I kind of don't recommend it for debugging.
also it is not working for me. Maybe there's more to this than just putting those equal sign
thank you man!
Great tips. Great content!
Great video. Thank you!
Good job !
If you want print string anything like -+_()/\{}[]=*$% operators. Backslash etc, aur if you fetch string from internet and you don't know what is inside that string,
For example
myText = r"\{}[]=$%_-+()/*, myDer()"
The output will be some what is inside myText
r"value, method, etc literally anything"
r is a Raw String, it will print as it
Good tip.
Nice!
This is huge!
Is this a feature of some later Python release?
I use 3.6.9 and got a syntax error when tried it out.
It works in version 3.8 and above
How I never knew about it. So useful
This is cool. Thanks.
nice!
most people dont know this in python? thats like a must in javascript xd
my hero.
very useful
so good
WHAT THE F IS THIS IN STRINGS? ...could've been an alternative thumb description😅
Nooooo... Please don't encourage the use of the f'string ... it's almost as bad a the programming language bf. (ref. en.wikipedia.org/wiki/Brainfuck)