GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.python.org — 5.2.6 String conversions

Previous Page Up One Level Next Page Python Reference Manual Contents Index
Previous: 5.2.5 Dictionary displays Up: 5.2 Atoms Next: 5.3 Primaries


5.2.6 String conversions

A string conversion is an expression list enclosed in reverse (a.k.a. backward) quotes:

string_conversion: "`" expression_list "`"

A string conversion evaluates the contained expression list and converts the resulting object into a string according to rules specific to its type.

If the object is a string, a number, None, or a tuple, list or dictionary containing only objects whose type is one of these, the resulting string is a valid Python expression which can be passed to the built-in function eval() to yield an expression with the same value (or an approximation, if floating point numbers are involved).

(In particular, converting a string adds quotes around it and converts ``funny'' characters to escape sequences that are safe to print.)

It is illegal to attempt to convert recursive objects (e.g., lists or dictionaries that contain a reference to themselves, directly or indirectly.)

The built-in function repr() performs exactly the same conversion in its argument as enclosing it in parentheses and reverse quotes does. The built-in function str() performs a similar but more user-friendly conversion.


Previous Page Up One Level Next Page Python Reference Manual Contents Index
Previous: 5.2.5 Dictionary displays Up: 5.2 Atoms Next: 5.3 Primaries

See About this document... for information on suggesting changes.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.