[ create a new paste ] login | about

Link: http://codepad.org/MV3k10AU    [ raw code | output | fork ]

Python, pasted on May 31:
la=['0','1','2']; lb=['one','two','three']; lc=['0%','50%','100%','120%']
a=['native',la]; 
b=['native',lb]; 
c=['native',lc]
print a; print b; print c
""" -*- output: utf-8 -*-
['native', ['0', '1', '2']]
['native', ['one', 'two', 'three']]
['native', ['0%', '50%', '100%', '120%']]
""";print

def conjunction(a,b,c):
  number = a[1]; name = b[1]; size = c[1]
  flag = a[0]==b[0]==c[0]
  if flag:
    for e in zip(number, name, size):
      print e

conjunction(a,b,c)
""" -*- output: utf-8 -*-
('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')
""";print

def conjunction(a,b,c):
  flag = a[0]==b[0]==c[0]
  if flag:
    for e in zip(a[1], b[1], c[1]):
      print e

conjunction(a,b,c)
""" -*- output: utf-8 -*-
('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')
""";print

# i want to write like this one
def conjunction(number=a[1],name=b[1],size=c[1]):
  flag = a[0]==b[0]==c[0]
  if flag:
    for e in zip(number,name,size):
      print e

conjunction(a,b,c)
""" -*- output: utf-8 -*-
['native', ['0', '1', '2']]
('native', 'native', 'native')
(['0', '1', '2'], ['one', 'two', 'three'], ['0%', '50%', '100%', '120%'])
>>> a
['native', ['0', '1', '2']]
""";print

# but i don't know that solution
# 
def conjunction(a,b,c,**attr):
  flag = a[0]==b[0]==c[0]
  if flag:
    for e in zip(attr['number'],attr['name'],attr['size']):
      print e

conjunction(a,b,c,number=a[1],name=b[1],size=c[1])
""" -*- output: utf-8 -*-
('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')
"""


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
['native', ['0', '1', '2']]
['native', ['one', 'two', 'three']]
['native', ['0%', '50%', '100%', '120%']]

('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')

('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')

('native', 'native', 'native')
(['0', '1', '2'], ['one', 'two', 'three'], ['0%', '50%', '100%', '120%'])

('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')


Create a new paste based on this one


Comments: