您对 Python 使用哪些重构工具? [英] What refactoring tools do you use for Python?

查看:38
本文介绍了您对 Python 使用哪些重构工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆要重命名的类.其中一些名称很小,并且该名称在其他类名称中重复使用,我不希望更改该名称.其中大部分存在于 Python 代码中,但我们也有一些引用类名的 XML 代码.

I have a bunch of classes I want to rename. Some of them have names that are small and that name is reused in other class names, where I don't want that name changed. Most of this lives in Python code, but we also have some XML code that references class names.

简单的搜索和替换只能让我到此为止.就我而言,我想将 AdminAction 重命名为 AdminActionPlug,将 AdminActionLogger 重命名为 AdminActionLoggerPlug,因此第一个的搜索和替换也会错误地命中第二个.

Simple search and replace only gets me so far. In my case, I want to rename AdminAction to AdminActionPlug and AdminActionLogger to AdminActionLoggerPlug, so the first one's search-and-replace would also hit the second, wrongly.

有人有使用 Python 重构工具的经验吗?如果他们也能修复 XML 文档中的类名,那就加分.

Does anyone have experience with Python refactoring tools ? Bonus points if they can fix class names in the XML documents too.

推荐答案

同时,我尝试了两种与 vim 有某种集成的工具.

In the meantime, I've tried it two tools that have some sort of integration with vim.

第一个是 Rope,一个带有 Vim(和 emacs)的 Python 重构库插入.我尝试了几次重命名,这确实按预期工作.它允许我将重构预览为差异,这很好.它有点文字驱动,但对我来说没关系,只是需要更长的时间来学习.

The first is Rope, a python refactoring library that comes with a Vim (and emacs) plug-in. I tried it for a few renames, and that definitely worked as expected. It allowed me to preview the refactoring as a diff, which is nice. It is a bit text-driven, but that's alright for me, just takes longer to learn.

第二个是 Bicycle Repair Man 我猜它在名字上赢得了分数.还可以插入 vim 和 emacs.还没有玩过它,但我记得很久以前尝试过.

The second is Bicycle Repair Man which I guess wins points on name. Also plugs into vim and emacs. Haven't played much with it yet, but I remember trying it a long time ago.

两者都还没有玩够,或者尝试了更多类型的重构,但我会用它们做更多的黑客攻击.

Haven't played with both enough yet, or tried more types of refactoring, but I will do some more hacking with them.

这篇关于您对 Python 使用哪些重构工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆