私のコード(pip3と一緒にインストールされた)のライブラリモジュールとしてhttps://github.com/sciunto/python-bibtexparserを使用しています。したがって、私はモジュールへの書き込みアクセス権を持っていません。モジュールに定義されているpython3セットにアクセスして更新します。
standard_types
で定義されているように、使用するセットはかなり限定されています。https://github.com/sciunto/python-bibtexparser/blob/master/bibtexparser/bibdatabase.pyです。
呼び出しコードからセットを再定義/追加することは可能ですか?例えば
#foo.py
import bibtexparser
#redefine standard_types
bibtexparser.STANDARD_TYPES = set([the complete set I need])
#or append the standard_types
bibtexparser.STANDARD_TYPES.update = set([append to the set])
?
更新:実際には、変数STANDARD_TYPESにアクセスできません。私がやろうとしています:降伏さ
from bibtexparser import bibdatabase as bd
class Window(Gtk.ApplicationWindow):
def __init__(self, application, giofile=None):
Gtk.ApplicationWindow.__init__(self,
application=application,
default_width=1000,
default_height=200,
border_width=5)
print(bd)
print(bd.STANDARD_TYPES)
を:
<module 'bibtexparser.bibdatabase' from '/usr/lib/python3.5/site-packages/bibtexparser/bibdatabase.py'>
......
print(bd.STANDARD_TYPES)
AttributeError: module 'bibtexparser.bibdatabase' has no attribute 'STANDARD_TYPES'
おそらく。それを試してみてください!追加するには '| ='演算子を使います。 – wim