def myFun(a='def', b='def', bla='def', blo='def'): if a == b: return print str(a) + ' IS NOT ' + str(b) print 'bla: ' + bla print 'blo: ' + blo def myFun2(): print 'myFun2' def myFun3(j, k): print 'j: ' + str(j) print 'k: ' + str(k) #myFun(4, 4) #myFun(3, 2) def funWithCb(a, callback, *args, **keywords): print 'Doing stuff..' print 'a is ' + str(a) callback(*args, **keywords) def funWithCbWrapper(a, callback, *args, **keywords): funWithCb(a, callback, *args, **keywords) def funWithCb2(a=0, b=0, c=0, callback=0, *args, **keywords): print 'Doing stuff..' print 'a is ' + str(a) callback(*args, **keywords) #funWithCbWrapper(a=80, callback=myFun3, j=12, k=213) funWithCb2(a=80, callback=myFun3, j=43, k=33) #funWithCbWrapper(5, myFun, 2, 8, bla='so', blo='suade') #funWithCbWrapper(3, myFun, 4, 55) #funWithCbWrapper(3, myFun2) for item in ['a', 'asd', 'c', 'd', 'e']: print item flag = False if flag: print '1' flag = True if flag: print '2' dict = {} #a = dict['a'] #print a if 'a' not in dict: print 'a is not there' else: print 'a missing' dict[23] = {} dict[23]['1'] = 'great' if 23 in dict and '1' in dict[23]: print dict[23]['1'] if 22 in dict and '1' in dict[22]: print dict[22]['1'] if False or (True and True): print 'Very good'
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question