Home Download Buy Blog Forum Support

Python new format string highlight

Python new format string highlight

Postby tobia on Fri Nov 09, 2012 11:31 am

Hello

The new way of formatting strings in Python (which is actually the recommended one since Python 2.6 came out in 2008) is through the format() method.

The old way, by position or by name:

Code: Select all
'%s, %s' % ('Hello', 'World')

'%(greeting)s, %(recipient)s' % {'greeting':'Hello', 'recipient':'World'}

The new way, by position or by name:

Code: Select all
'{0}, {1}'.format('Hello', 'World')

'{greeting}, {recipient}'.format(greeting='Hello', recipient='World')

It would appear to me that ST2 only highlights the old percert-style placeholders in strings, not the newer curly bracket ones (which by the way can contain all sorts of characters, not just letters and numbers, up to the closing curly bracket, as the new format system is extensible.)

Is there a setting to enable it? A plugin? Is it planned for a future upgrade?
tobia
 
Posts: 10
Joined: Tue Oct 16, 2012 2:55 pm

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests