proj.ios : Done! proj.android : Done! proj.win32 : Done! proj.mac : Done! proj.linux : Done! New project has been created in this path: /Users/davidzhang/Downloads/ios/cocos2d/cocos2d-x-3.0alpha0/projects/walker Have Fun!
try: a = b b = c except: info = sys.exc_info() print info print info[0] print info[1]
输出:
1 2 3 4 5
(<type'exceptions.UnboundLocalError'>, UnboundLocalError("local variable 'b' referenced before assignment",), <traceback object at 0x00D243F0>) <type'exceptions.UnboundLocalError'> local variable 'b' referenced before assignment
davidzhang@192:/Library$ python Python 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin Type "help", "copyright", "credits" or "license"for more information. >>> import ftplib >>> reload(ftplib) <module 'ftplib' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py'> >>>
jQuery.foo = function() { alert('This is a test. This is only a test.'); };
1.2 增加多个全局函数
添加多个全局函数,可采用如下定义:
1 2 3 4 5 6
jQuery.foo = function() { alert('This is a test. This is only a test.'); }; jQuery.bar = function(param) { alert('This function takes a parameter, which is "' + param + '".'); };
jQuery.extend({ foo: function() { alert('This is a test. This is only a test.'); }, bar: function(param) { alert('This function takes a parameter, which is "' + param +'".'); } });
jQuery.myPlugin = { foo:function() { alert('This is a test. This is only a test.'); }, bar:function(param) { alert('This function takes a parameter, which is "' + param + '".'); } };
// plugin definition $.fn.hilight = function(options) { // Extend our default options with those provided. // Note that the first arg to extend is an empty object - // this is to keep from overriding our "defaults" object. var opts = $.extend({}, $.fn.hilight.defaults, options); // Our plugin implementation code goes here. }; // plugin defaults - added as a property on our plugin function $.fn.hilight.defaults = { foreground: 'red', background: 'yellow' } };
$.fn.hilight = function(options) { // ... // build main options before element iteration var opts = $.extend({}, $.fn.hilight.defaults, options); returnthis.each(function() { var $this = $(this); // build element specific options var o = $.meta ? $.extend({}, opts, $this.data()) : opts; //... }); }