我有一个来自下面粘贴的boto框架的代码文件,所有的print语句都是我的,并且注释掉的行也是我的,所有其他属于属性作者.
我的问题是实例化一个类时python中实例化和分配的顺序是什么?下面作者的代码假设在创建类的一个实例时会存在'DefaultDomainName'(例如调用__init __()),但这似乎不是这种情况,至少在我的python 2.5测试中OS X.
在类Manager __init __()方法中,我的print语句显示为"None".并且在设置Manager.DefaultDomainName之前,全局函数set_domain()中的print语句向下显示"None",并在赋值后显示"test_domain"的预期值.但是在调用set_domain()之后再次创建Manager实例时,__ init __()方法仍显示"None".
任何人都可以帮助我,并解释这里发生了什么.这将不胜感激.谢谢.
# Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom …Run Code Online (Sandbox Code Playgroud) python ×1