Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesYou are notlogged in. Your edit will be placed in a queue until it ispeer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
'{type_names} [a-z]{{2}}'.format(type_names='triangle|square'). It's like saying.format() can help when using strings which already contain a percent character. Sure. You have to escape them then."One situation where % may help is when you are formatting regex expressions." Specifically, assumea=r"[a-z]{2}" is a regex chunk that you will be used in two different final expressions (e.g.c1 = b + a andc2 = a). Assume thatc1 needs to beformated (e.g.b needs to be formatted runtime), butc2 does not. Then you needa=r"[a-z]{2}" forc2 anda=r"[a-z]{{2}}" forc1.format(...).`like _so_`A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
If your question is primarily about a topic for which you can't find a tag: