Changeset 3505:456384842e58 in livinglogic.python.xist

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

Add support for calling get() with one argument.

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • docs/UL4.rst

    r3504 r3505  
    712712 
    713713``get`` is a dictionary method. ``d.get(k, v)`` returns ``d[k]`` if the key 
    714 ``k`` is in ``d``, else ``v`` is returned. 
     714``k`` is in ``d``, else ``v`` is returned. If ``v`` is not given, it defaults 
     715to ``None``. 
  • src/ll/ul4c.py

    r3504 r3505  
    983983                        raise UnknownMethodError(opcode.arg) 
    984984                elif opcode.code == "callmeth1": 
    985                     if opcode.arg in ("split", "rsplit", "strip", "lstrip", "rstrip", "startswith", "endswith", "find"): 
     985                    if opcode.arg in ("split", "rsplit", "strip", "lstrip", "rstrip", "startswith", "endswith", "find", "get"): 
    986986                        _code("reg%d = reg%d.%s(reg%d)" % (opcode.r1, opcode.r2, opcode.arg, opcode.r3)) 
    987987                    elif opcode.arg == "format": 
  • test/test_ul4.py

    r3504 r3505  
    820820    check("42", "<?print {}.get('foo', 42)?>") 
    821821    check("17", "<?print {'foo': 17}.get('foo', 42)?>") 
     822    check("", "<?print {}.get('foo')?>") 
     823    check("17", "<?print {'foo': 17}.get('foo')?>") 
    822824 
    823825