我有gedit配置为git core.editor.
git config --global core.editor "gedit"
Run Code Online (Sandbox Code Playgroud)
除非已打开gedit窗口,否则此工作正常.在这种情况下,COMMIT_EDITMSG在现有窗口中打开,gedit立即返回.Git以空提交消息结束并失败.
这个网站(http://fabianschuiki.wordpress.com/2012/05/20/use-gedit-as-git-editor/)建议使用"gedit -s -w",但我没有这些选项(和--new-window不起作用):
$ gedit -V
gedit - Version 2.28.4
$ gedit --help
Usage:
gedit [OPTION...] [FILE...] - Edit text files
Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options
--help-sm-client Show session management options
Application Options:
-V, --version Show the application's version
--encoding=ENCODING Set the character encoding to be used to open the files listed on the command line
--list-encodings Display list …Run Code Online (Sandbox Code Playgroud) 我试图将一个__dict__成员添加到由namedtuple生成的类.(__dict__存在于python 2.7.3中,但在2.7.5中删除.请参阅http://bugs.python.org/issue15535.它存在并记录在python 3.3中.)我的代码使用vars(nametuple_object),这是基于__dict__.我想在需要时补课.
这是我尝试过的:
# Applies to Python 2.7.5 +
C = namedtuple('C', ['x', 'y'])
if not hasattr(C, '__dict__'):
C.__dict__ = property(C._asdict)
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为C继承了a __dict__,因此hasattr始终为true并且(强制时)属性赋值返回:
Traceback (most recent call last):
File "namedtuple_dict.py", line 8, in <module>
C.__dict__ = property(C._asdict)
AttributeError: attribute '__dict__' of 'type' objects is not writable
Run Code Online (Sandbox Code Playgroud)
也许,有没有办法引用不继承的C成员?
解
这是我的namedtuple包装器,它使用rdb建议只继承namedtuple类而不是尝试修改它:
def namedtuple_with_dict(typename, field_names, **kwargs):
C = CBase = namedtuple(typename, field_names, **kwargs)
if 0x02070500 <= sys.hexversion < 0x03000000:
C = type(typename, (CBase,), …Run Code Online (Sandbox Code Playgroud)