Commits

Jonathan Eunice  committed 100edc8

now tested agasint all late model Pythons

  • Participants
  • Parent commits 9dfd52e

Comments (0)

Files changed (5)

     from say import say, fmt
     
     x = 12
-    nums = range(4)
+    nums = list(range(4))
     
     say("There are {x} things.")
     say("Nums has {len(nums)} items: {nums}")
 Good options for the separator might be be '-', '=', or parts of the `Unicode 
 box drawing character set <http://en.wikipedia.org/wiki/Box-drawing_character>`_.
 
-Python 3 RSN
-============
+Python 3
+========
 
-``say`` is intended to work across late-model versions of Python 2. It
-passes all tests under Python 2.6 and 2.7, but not yet Python 3.  
-
-When that does work...
-One benefit of having a printing function that isn't defined as a statement in
-Python 2 but a function in Python 3, and that doesn't require ``from __future__
-import`` statements that only work in Python 2 is better cross-version
-compatibility without the "what version am I working in?!" tests and setup.
+Say works the same way in both Python 2 and Python 3. This can simplify 
+software that should work across the versions, without all the ``from __future__
+import`` hassle.
 
 ``say`` attempts to mask some of the quirky compexities of the 2-to-3 divide,
 such as string encodings and codec use.
    gratuitous. Simpler::
    
       say("Hello, {name}!")
-    
 
 Notes
 =====
    All tests pass under 2.6.7. Automated multi-version testing using
    ``py.test`` and ``tox`` has commenced.
 
+Notes
+=====
+
+ *  Automated multi-version testing with the wonderful
+   `pytest <http://pypi.python.org/pypi/pytest>`_
+   and `tox <http://pypi.python.org/pypi/tox>`_ modules has commenced. ``say`` is now
+   successfully packaged for, and tested against, all late-model verions of
+   Python: 2.6, 2.7, 3.2, and 3.3.
+ 
+ * The author, `Jonathan Eunice <mailto:jonathan.eunice@gmail.com>`_ or
+   `@jeunice on Twitter <http://twitter.com/jeunice>`_
+   welcomes your comments and suggestions.
+
 Installation
 ============
 
 ::
 
     pip install say
+
+To ``easy_install`` under a specific Python version (3.3 in this example)::
+
+    python3.3 -m easy_install say
     
-(You may need to prefix this with "sudo " to authorize installation.)
+(You may need to prefix these with "sudo " to authorize installation.)
 if six.PY3:
     from codecs import getencoder
 
+### Convenience and compatibility functions and names
+
 stdout = sys.stdout
 stderr = sys.stderr
 
-### Convenience and compatibility functions and names
-
 def is_string(v):
     """
     Is the value v a string? Useful especially in making a test that works on
             return eval(s, caller.f_globals, localvars)
         except SyntaxError:
             raise SyntaxError("syntax error when formatting '{}'".format(s))
-        except StandardError as se:
-            raise se
+
 
     if is_string(arg):
         parts = []
         for (literal_text, field_name, format_spec, conversion) in sformatter.parse(arg):
             parts.append(literal_text)
             if field_name is not None:
-                format_str = six.u("{0exit") + ("!" + conversion if conversion else "") + \
+                format_str = six.u("{0") + ("!" + conversion if conversion else "") + \
                                           (":" + format_spec if format_spec else "") + "}"
                 field_value = seval(field_name)
                 formatted = format_str.format(field_value)
 
 ### Core Say class
 
+DEFAULT_FILES = [ stdout]
+
 class Say(object):
     """
     Say encapsulates printing functions. Instances are configurable, and callable.
         encoding=None if six.PY3 else 'utf-8',
                             # character encoding for output (needed on Python 2, not 3)
         encoded=None,       # character encoding to return
-        files=stdout,       # where is output headed? a list of write() able objects
+        files=None,         # where is output headed? a list of write() able objects
+                            # NB Set to [stdout] but in way that gets around stuf bug
         sep=' ',            # separate args with this (Python print function compatible)
         end='\n',           # end output with this (Python print function compatible)
         silent=False,       # do the formatting and return the result, but don't write the output
         retvalue=False,     # should return the value of the formatted string?
         _callframe=None,    # frome from which the caller was calling
     )
+    options.files = DEFAULT_FILES
   
     def __init__(self, **kwargs):
         """
         """
         Write s to all associated file objects. 
         """
+        # print(opts)
         for f in opts.files:
             f.write(s)
 
 
 setup(
     name='say',
-    version=verno("0.198"),
+    version=verno("0.301"),
     author='Jonathan Eunice',
     author_email='jonathan.eunice@gmail.com',
     description='Simple formatted printing with templates',
         Programming Language :: Python
         Programming Language :: Python :: 2.6
         Programming Language :: Python :: 2.7
+        Programming Language :: Python :: 3.2
+        Programming Language :: Python :: 3.3
         Topic :: Software Development :: Libraries :: Python Modules
     """)
 )

File test/test.py

     setup()
     
     x = 12
-    nums = range(4)
+    nums = list(range(4))
         
     assert say("There are {x} things.") == "There are 12 things."
     assert say("Nums has {len(nums)} items: {nums}") == "Nums has 4 items: [0, 1, 2, 3]"
 [tox]
-envlist = py26, py27, py33
+envlist = py26, py27, py32, py33
 
 [testenv]
 changedir=test