场景:在我离开办公室之前的本地回购
$ hg status
M important/update1
M another/important/update2
M work/in/progress
Run Code Online (Sandbox Code Playgroud)
我想提交并推送重要的/ update1和important/update2,因为当我回到家时,我想将这些文件拉到我的本地仓库.我还没准备好投入工作/进展.实际上它甚至没有正确解析.该文件在我的IDE中打开,我只是想保持原样.
现在我做:(赶紧,电车三分钟后离开)
$ hg commit important/update1 another/important/update2
$ hg push
pushing to https://**censored**
searching for changes
abort: push creates new remote heads on branch 'default'!
(did you forget to merge? use push -f to force)
Run Code Online (Sandbox Code Playgroud)
好.同事推了一些东西......(电车在两分钟后离开...)
$ hg pull (really important update!)
$ hg update
abort: outstanding uncommitted changes
Run Code Online (Sandbox Code Playgroud)
废话.我需要同事的更新,但我不会提交工作/进展/进展,更不用说推动了!我只是错过了我的电车......
你怎么处理这个?
我想使用接口,但我的一些实现依赖于魔术方法,如__invoke和__call.我必须从界面中删除可能被神奇地(在任何实现中)调用的方法的签名.这导致反模式空接口(是的,我刚刚做到了).
如何在PHP中结合接口和魔术方法?
我有一个对象子类,它__ iter __
使用缓存生成器实现动态调度(我还有一个使iter缓存无效的方法),如下所示:
def __iter__(self):
print("iter called")
if self.__iter_cache is None:
iter_seen = {}
iter_cache = []
for name in self.__slots:
value = self.__slots[name]
iter_seen[name] = True
item = (name, value)
iter_cache.append(item)
yield item
for d in self.__dc_list:
for name, value in iter(d):
if name not in iter_seen:
iter_seen[name] = True
item = (name, value)
iter_cache.append(item)
yield item
self.__iter_cache = iter_cache
else:
print("iter cache hit")
for item in self.__iter_cache:
yield item
Run Code Online (Sandbox Code Playgroud)
它似乎工作......有没有我可能不知道的陷阱?我做的事情有多荒谬吗?
通过仔细阅读http://php.net/manual/en/function.set-include-path.php上的评论,在
我看来,'.'或者更确切地说basename(__FILE__)
,总是隐式地添加到PHP的包含路径中.是否可以绕过这条路?
在我的工作中,我使用自己的包装器和类加载器,我想控制PHP的include()的行为.我的包装器曾用于强制执行绝对路径,但我认为这实际上过于严格,我不想再回到原点.如果可能的话,我想使用PHP的include_path.
看来,atan2(0,0)
在C定义这种方式。Python只是将常见的三角函数委托给底层的C实现,对吗?