Ejemplo n.º 1
0
except Spam as err:
    p()


try:
    f()
except Spam:
    g()
except Eggs:
    h()
except (Vikings+Marmalade) as err:
    i()

try:
    a()
except Spam: b()
except Spam2: c()
finally: g()

try:
    a()
except:
    b()
else:
    c()

try: a()
except: b()
else: c()
finally: d()
Ejemplo n.º 2
0
def install(mname, m):
    import sys
    sys.modules[mname] = m
    del sys

def generate(parent, mname, attrs):
    m = create(mname, attrs)
    # if parent isn't in sys.modules, this won't work...
    install(parent + '.' + mname, m)
    return m
    
# this is just a set of random examples, really
if __name__ == '__main__':
    m = create('a', {'b': lambda x: x})

    import sys
    sys.modules['a'] = m

    print m.b(1)

    import a
    print a.b(2)

    def zoink(x):
        print x

    generate('__main__', 'bar', {'baz': zoink})
    from __main__.bar import baz
    baz(3)
Ejemplo n.º 3
0
  pass

  del a

  print a

  def f():
    return a

  def g():
    yield a

  try:
    raise e
  except E as a:
    b()
  except:
    c()
  else:
    d()

  for a in aa:
    if c:
      continue
    elif d:
      e()
    else:
      break
  else:
    g()
Ejemplo n.º 4
0
    pass

    del a

    print a

    def f():
        return a

    def g():
        yield a

    try:
        raise e
    except E as a:
        b()
    except:
        c()
    else:
        d()

    for a in aa:
        if c:
            continue
        elif d:
            e()
        else:
            break
    else:
        g()
Ejemplo n.º 5
0
from a import b, c

greetings = b("Ornib")
print(greetings)