https://github.com/jcsalterego/py3k-atsign
https://github.com/jcsalterego/py3k-atsign
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jcsalterego/py3k-atsign
- Owner: jcsalterego
- Created: 2009-06-20T00:35:15.000Z (almost 17 years ago)
- Default Branch: master
- Last Pushed: 2009-06-21T10:08:56.000Z (almost 17 years ago)
- Last Synced: 2025-01-17T16:37:32.094Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 12.8 MB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
Abstract
This PEP proposes the overloading of the '@' operator for use of
the string formatting system introduced in Python 3000.
Contents
This repository holds a subversion checkout of the latest Python
3000 trunk which is updated using the 'subversion' git branch.
Updates are then merged back to the 'master' git branch, to keep
official repository code changes from changes made for this PEP.
When/if appropriate, a simple 'svn diff' will create the necessary
patch needed for integration.
Installation
$ cd py3k && ./configure && make
$ ./python.exe ../tests/simple.py
Rationale
The new string formatting system [1] introduced in Python 3000 and
later backported to the 2.x series provides a far more versatile
mechanism than the original '%' operator, the latter of which is
deprecated and slated for removal.
Part of the design specifically addressed the binary operator
dilemma, which forced a choice between non-named items (string or
tuples, for example) versus named items (dictionaries).
This PEP attempts to reintroduce a binary operator as an optional
syntactical alternative to a direct function call, and to propose
a convention which may address the issues of its predecessor.
Examples
>>> "Simple test with {} {} via tuples" @ ("unnamed", "args")
'Simple test with unnamed args via tuples'
>>> "Simple test with {foo} args via dicts" @ {"foo": "named"}
'Simple test with named args via dicts'
>>> "Mix of {foo} and {} args" @ ("unnamed", dict("foo"="named"))
'Mix of named and unnamed args'
>>> "No, really a {}" @ ({"literal":"dictionary"}, {})
"No, really a {'literal': 'dictionary'}"