From 82fabbe5e63ff1affd7fa4bb06c8a4dbe5edf577 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Sat, 26 Feb 2022 17:59:05 +0800 Subject: [PATCH 4/4] Make lee_corpus_list initialised on first access. Uses PEP 562 module __getattr__ and requires Python 3.7 or later. See-also: https://www.python.org/dev/peps/pep-0562/ --- gensim/test/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gensim/test/utils.py b/gensim/test/utils.py index 9453b448..c610c06e 100644 --- a/gensim/test/utils.py +++ b/gensim/test/utils.py @@ -218,4 +218,9 @@ class LeeCorpus: yield simple_preprocess(line) -lee_corpus_list = list(LeeCorpus()) +def __getattr__(name): + if name == 'lee_corpus_list': + global lee_corpus_list + lee_corpus_list = list(LeeCorpus()) + return lee_corpus_list + raise AttributeError(f"module {__name__} has no attribute {name}") -- 2.36.0