(环境:pycharm 5.0.2,interpreter:python 2.7与osx 10.10捆绑)
嘿,伙计们,
我一直不知道如何让Pycharm允许我对静态方法执行移动重构。是否支持?我找不到任何证明文件。
特定行为
我建立了一个全新的工作区,并把它归档。
class MyGreatDemonstratorClass(object):
@staticmethod
def some_static_method():
print "static hey"
@classmethod
def some_class_method(cls):
print "class hey"
def some_instance_method(self):
print "instance hey"
def unbound_method():
print "unbound hey"
我右键单击
some_static_method
,将鼠标悬停在“重构”上,单击“移动”红色文本弹出“无法使用选定元素执行重构”(img)
(这同样适用于
some_class_method
和some_instance_method
,尽管这对我来说很有意义;重构绑定方法很困难。)在
unbound_method
上重复1,它应该可以工作。所以我的问题是
pycharm中是否支持重构@staticmethod?
如果没有,建议的方法是什么?Rope?
最佳答案
试试这个
正在执行移动重构
要执行移动重构,请执行以下常规步骤:
选择要移动的符号,然后执行以下操作之一:
在重构菜单或上下文菜单上,选择移动。
按F6。
在“项目工具”窗口中,将符号拖动到新目标。
打开的对话框取决于所选符号的类型。
根据要移动的项的类型指定移动选项。请参见“移动”对话框参考中的选项说明。
预览并应用更改。
关于python - PyCharm:无法移动Refactor静态方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34405687/