*args and **kwargs in Python

Python accepts a list or a dictionary as arguments in function. This is very useful. Look at this code example:

def TestArgs(titleid, typename, *args, **kwargs):
    print titleid,typename
    print "**************"
    for val in args:
         print val

    for k,v in kwargs.iteritems():
        print k,v

if __name__ == '__main__':
    TestArgs(69,"ps4", 1,"2","6")

The output is:
69 ps4

Continue reading *args and **kwargs in Python

__init__.py in Python module

Python provides modules for complicate application. This modules can locate in any directory or even sub-directories. Project structure can create  like this:


Continue reading __init__.py in Python module

UTF8 Encoding

In normal, if current language in game is English, since the range is 0-127, ASCII is good enough to cover all characters and symbols. The advantage of using ASCII is saving space for its one byte usage.

Unicode is a standard table set that mapping all over the world language character. To adapting other complicate character, it uses two bytes to cover massive possibility of character encoding. For example, for letter “A”, the Unicode is 0x0041, for Chinese “严”, the Unicode is 0x4E25. Continue reading UTF8 Encoding