简体   繁体   中英

Change global variable of a package

I am using the functionality from the following script of the gensim package: https://github.com/RaRe-Technologies/gensim/blob/3.8.0/gensim/summarization/keywords.py

How can I change the global variables WINDOW_SIZE , etc. before invoking the function keywords()

Try this:

from gensim.summarization.keywords import WINDOW_SIZE, keywords

WINDOW_SIZE = <whatever value you want>

k = keywords(...)

Import the module with a name, then re-assign it in the module object:

import gensim.summarization.keywords as kw

kw.WINDOW_SIZE = new_value
kw.keywords()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM