From 560b4207b1490a7d0cbf70cfbeba7daf2082e5be Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 27 Nov 2014 02:41:27 +0200 Subject: Removed redundant numbered parameters from str.format(). Since Python 2.7 and 3.1, "{0} {1}" is equivalent to "{} {}". --- docs/howto/outputting-csv.txt | 2 +- docs/intro/contributing.txt | 4 ++-- docs/ref/contrib/admin/index.txt | 6 +++--- docs/ref/utils.txt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/howto/outputting-csv.txt b/docs/howto/outputting-csv.txt index d1a778db47..71cb5db036 100644 --- a/docs/howto/outputting-csv.txt +++ b/docs/howto/outputting-csv.txt @@ -106,7 +106,7 @@ the assembly and transmission of a large CSV file:: # Generate a sequence of rows. The range is based on the maximum number of # rows that can be handled by a single sheet in most spreadsheet # applications. - rows = (["Row {0}".format(idx), str(idx)] for idx in range(65536)) + rows = (["Row {}".format(idx), str(idx)] for idx in range(65536)) pseudo_buffer = Echo() writer = csv.writer(pseudo_buffer) response = StreamingHttpResponse((writer.writerow(row) for row in rows), diff --git a/docs/intro/contributing.txt b/docs/intro/contributing.txt index b1fb7b0ef6..d305a8bb91 100644 --- a/docs/intro/contributing.txt +++ b/docs/intro/contributing.txt @@ -325,7 +325,7 @@ the following ``render`` method after the existing ``__init__`` method:: value = force_text(self._format_value(value)) final_attrs = {'href': mark_safe(smart_urlquote(value))} html = format_html( - '

{0} {2}
{3} {4}

', + '

{} {}
{} {}

', _('Currently:'), flatatt(final_attrs), value, _('Change:'), html ) @@ -443,7 +443,7 @@ This patch file contains all your changes and should look this: + value = force_text(self._format_value(value)) + final_attrs = {'href': mark_safe(smart_urlquote(value))} + html = format_html( - + '

{0} {2}
{3} {4}

', + + '

{} {}
{} {}

', + _('Currently:'), flatatt(final_attrs), value, + _('Change:'), html + ) diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index a85993cd2e..fd6d8f5f3a 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -590,7 +590,7 @@ subclass:: color_code = models.CharField(max_length=6) def colored_name(self): - return format_html('{1} {2}', + return format_html('{} {}', self.color_code, self.first_name, self.last_name) @@ -647,7 +647,7 @@ subclass:: color_code = models.CharField(max_length=6) def colored_first_name(self): - return format_html('{1}', + return format_html('{}', self.color_code, self.first_name) @@ -1060,7 +1060,7 @@ subclass:: # line by a linebreak return format_html_join( mark_safe('
'), - '{0}', + '{}', ((line,) for line in instance.get_full_address()), ) or "I can't determine this address." diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index b32f0a838b..56e9fb7dce 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -605,7 +605,7 @@ escaping HTML. You should instead use:: - format_html("{0} {1} {2}", + format_html("{} {} {}", mark_safe(some_html), some_text, some_other_text) This has the advantage that you don't need to apply :func:`escape` to each @@ -627,7 +627,7 @@ escaping HTML. ``args_generator`` should be an iterator that returns the sequence of ``args`` that will be passed to :func:`format_html`. For example:: - format_html_join('\n', "
  • {0} {1}
  • ", ((u.first_name, u.last_name) + format_html_join('\n', "
  • {} {}
  • ", ((u.first_name, u.last_name) for u in users)) .. function:: strip_tags(value) -- cgit v1.3