Changeset 3504:e9330a28a7f5 in livinglogic.python.xist

Show
Ignore:
Timestamp:
07/14/08 21:55:08 (11 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Add a get method to dictionaries in UL4.

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • NEWS.rst

    r3502 r3504  
     1Changes in 3.3.2 (released ??/??/2008) 
     2-------------------------------------- 
     3 
     4*   Dictionaries in UL4 have gained a new method ``get``. 
     5 
     6 
    17Changes in 3.3.1 (released 07/14/2008) 
    28-------------------------------------- 
     
    410*   Fixed a bug in the implementation of the "not" operator in UL4. 
    511 
    6 *   When the ``UL4`` compiler encounters unclosed blocks, it will now include 
     12*   When the UL4 compiler encounters unclosed blocks, it will now include 
    713    the start location of the block in the error message. 
    814 
  • docs/UL4.rst

    r3496 r3504  
    706706This string method replace has two arguments. It returns a new string where 
    707707each occurrence of the first argument is replaced by the second argument. 
     708 
     709 
     710``get`` 
     711::::::: 
     712 
     713``get`` is a dictionary method. ``d.get(k, v)`` returns ``d[k]`` if the key 
     714``k`` is in ``d``, else ``v`` is returned. 
  • setup.py

    r3502 r3504  
    211211args = dict( 
    212212    name="ll-xist", 
    213     version="3.3.1", 
     213    version="3.3.2", 
    214214    description="Extensible HTML/XML generator", 
    215215    long_description=descr, 
  • src/ll/ul4c.py

    r3502 r3504  
    990990                        raise UnknownMethodError(opcode.arg) 
    991991                elif opcode.code == "callmeth2": 
    992                     if opcode.arg in ("split", "rsplit", "find", "replace"): 
     992                    if opcode.arg in ("split", "rsplit", "find", "replace", "get"): 
    993993                        _code("reg%d = reg%d.%s(reg%d, reg%d)" % (opcode.r1, opcode.r2, opcode.arg, opcode.r3, opcode.r4)) 
    994994                    else: 
  • test/test_ul4.py

    r3502 r3504  
    817817 
    818818 
     819def test_method_get(): 
     820    check("42", "<?print {}.get('foo', 42)?>") 
     821    check("17", "<?print {'foo': 17}.get('foo', 42)?>") 
     822 
     823 
    819824def test_render(): 
    820825    t = ul4c.compile('<?print prefix?><?print data?><?print suffix?>')