r/pythontips • u/pylenin • Jan 19 '21
Python3_Specific Python String Formatting - A definitive guide
Last week, I finished blogging about Python Strings.
Alot of topics were covered. But my fav is the String Formatting Guide. It covers 4 different ways of String Formatting nand a comparison of their execution times. Check out the guide here.
3
1
1
u/Ritterlichkeit Jan 19 '21
Great work! I appreciate the way you explained each one. Very easy to understand, Thanks!
1
1
1
u/TM_Quest Jan 22 '21
Great work! The difference between the find method and the index method in Python is something I can never remember.
When writing conditionals, does anyone have a preference between:
if s2.count(s1) == 0:
and
if s2.find(s1) == -1:
5
u/rothbart_brb Jan 19 '21
If this could be formatted into a PDF of 1-2 pages, this would make a great cheat sheet document to have tacked up on the wall for occasional glances, or laminated and sitting in a pile for reference. I tend to gather well made cheat sheets. Many look good and don't have great content, or have great content and don't especially look good or use the space well, but when one does both, it's almost like a piece of art. My guess is that most programmers will tend to stick to one or two types of string formatting and won't have them all committed to memory. Nice job!