Skip to content

Instantly share code, notes, and snippets.

@liuyix
Last active December 30, 2015 16:09
Show Gist options
  • Select an option

  • Save liuyix/7853143 to your computer and use it in GitHub Desktop.

Select an option

Save liuyix/7853143 to your computer and use it in GitHub Desktop.
python best practise!

Python Tips

建立class的最佳实践

credit:http://stackoverflow.com/a/62680

class Foo(object):
    #...

这样的建立方式,可以是Foo类自带__dict__,其中包含了所有类成员的字典,因此可以使用下面的语句: pack_info = dict((key, p.__dict__[key]) for key in Package.json_members) 实现字典的部分拷贝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment