Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: updated to more modern Python

...

Python

Groovy

Code Block
repr(x)
Code Block
x.inspect(), x.dump()
Code Block
x.y andif x.y orelse None
Code Block
x?.y
Code Block
"%(foo)s" % locals()
Code Block
"${foo}"

...

Python

Groovy

Code Block
{}
Code Block
[:] // an empty map
Code Block
Depends:d      if used in:  for k in dlist(d) if list is neededd.[iter]keys() explicitly
Code Block
d.keySet()
Code Block
d.[iter]values()
Code Block
d.values()
Code Block
[k+1 for k,v in d.iteritems()]
Code Block
d.collect { k, v -> k+1 }
Code Block
d = dict(zip(k, v))
Code Block
k = 1..3
v = 'a'..'c'
d = [:]; k.eachWithIndex { it, i -> d[it] = v[i] }
println d // [1:"a", 2:"b", 3:"c"]

...