Message414599
In my environment I installed the following two libraries:
```
pip install rapidfuzz
pip install python-Levenshtein
```
Those two libraries have the following structures:
rapidfuzz
|-distance
|- __init__.py (from . import Levenshtein)
|- Levenshtein.*.so
|-__init__.py (from rapidfuzz import distance)
Levenshtein
|-__init__.py
When importing Levenshtein first everything behaves as expected:
```
>>> import Levenshtein
>>> Levenshtein.
Levenshtein.apply_edit( Levenshtein.jaro_winkler( Levenshtein.ratio(
Levenshtein.distance( Levenshtein.matching_blocks( Levenshtein.seqratio(
Levenshtein.editops( Levenshtein.median( Levenshtein.setmedian(
Levenshtein.hamming( Levenshtein.median_improve( Levenshtein.setratio(
Levenshtein.inverse( Levenshtein.opcodes( Levenshtein.subtract_edit(
Levenshtein.jaro( Levenshtein.quickmedian(
>>> import rapidfuzz
>>> Levenshtein.
Levenshtein.apply_edit( Levenshtein.jaro_winkler( Levenshtein.ratio(
Levenshtein.distance( Levenshtein.matching_blocks( Levenshtein.seqratio(
Levenshtein.editops( Levenshtein.median( Levenshtein.setmedian(
Levenshtein.hamming( Levenshtein.median_improve( Levenshtein.setratio(
Levenshtein.inverse( Levenshtein.opcodes( Levenshtein.subtract_edit(
Levenshtein.jaro( Levenshtein.quickmedian(
```
However when importing rapidfuzz first it import `rapidfuzz.distance.Levenshtein` when running `import Levenshtein`
```
>>> import rapidfuzz
>>> Levenshtein
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Levenshtein' is not defined
>>> import Levenshtein
>>> Levenshtein.
Levenshtein.array( Levenshtein.normalized_distance( Levenshtein.similarity(
Levenshtein.distance( Levenshtein.normalized_similarity(
Levenshtein.editops( Levenshtein.opcodes(
```
My expectation was that in both cases `import Levenshtein` should import the `Levenshtein` module. I could reproduce this behavior on all Python versions I had available (Python3.8 - Python3.10) on Ubuntu and Fedora. |
|
Date |
User |
Action |
Args |
2022-03-05 22:26:32 | maxbachmann | set | recipients:
+ maxbachmann |
2022-03-05 22:26:32 | maxbachmann | set | messageid: <1646519192.38.0.0729050305481.issue46935@roundup.psfhosted.org> |
2022-03-05 22:26:32 | maxbachmann | link | issue46935 messages |
2022-03-05 22:26:32 | maxbachmann | create | |
|