String flags - redundant?

Alexandru Palade alexandru.palade at sellerengine.com
Tue Jul 15 11:14:15 EDT 2008


Hi to everyone,

I'm rather a Python newbie, so I've put myself a question. Are these two 
statements (performance-wise) equal?

r""" Text """
and
""" Text """

I mean using the raw flag speeds up things because the interpreter 
doesn't need to look after escape sequences? Or it's rather optimized? 
I'm asking you this because I want to know how my """-style comments 
should be written in order not to affect the performance.

And another short question... Are there any flags to specify variables 
intercalation in a string? I mean "I have x apples", how can i specify 
for the interpreter to substitute x with it's value? (in case *x* is a 
variable). And if this flag exists is it better to use "I have " + x + " 
apples" or the above mentioned way?

Thank you for your time,
Alex.



More information about the Python-list mailing list