Wiki

Changes between Version 2 and Version 3 of MultiArgAssign

Show
Ignore:
Timestamp:
11/22/10 19:59:36 (14 years ago)
Author:
todd.a
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MultiArgAssign

    v2 v3  
    33Cobra supports multi variable or multi target assignment 
    44{{{ 
     5#!cobra 
    56a, b, c = 10, 20, 30  # comma separated list of expressions 
    67 
     
    1920target and source lists were unrolled and each assignment done individually 
    2021{{{ 
     22#!cobra 
    2123a = 10 
    2224b = 20 
     
    3840 
    3941{{{ 
     42#!cobra 
    4043# unusual but acceptable - dict keyed by int in range 
    4144dict = {1:'aye', 2:'bee'} 
     
    6669 
    6770{{{ 
     71#!cobra 
    6872dict = {'x':'aye', 'y':'bee'} 
    6973for k, v in dict 
     
    7680the same size as the list of targets for each step of the enumeration 
    7781{{{ 
     82#!cobra 
    7883for i, j in [1, 2, 3, 4]    # error 
    7984    pass 
     
    8893[wiki:EnumForExpr for expression] 
    8994{{{ 
     95#!cobra 
    9096i, j = for x in [1, 2, 3, 4] get x 
    9197