arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
484 stars 203 forks source link

AttributeError: module 'stdnum' has no attribute 'ca' #400

Closed RushikSantoki closed 1 year ago

RushikSantoki commented 1 year ago

I am trying to use

stdnum.ca.sin.validate()

For which I am getting an error AttributeError: module 'stdnum' has no attribute 'ca'

It is not able to find reference 'ca' in 'init.py', says the suggestion.

Following is the code I am implementing:

import stdnum
import random

def GenerateSin():
     numbers = random.randrange(100000000, 999999999)
     return numbers

def ValidateSin():
    tempsin=0
    while not std.ca.sin.valifate(tempsin):
        tempsin = GenerateSin()

    return tempsin

numbersin = ValidateSin()
print(number)
DimitriPapadopoulos commented 1 year ago
>>> import stdnum.ca.sin
>>> 
>>> stdnum.ca.sin.validate
<function validate at 0x7f0fa1fd8dc0>
>>> 
arthurdejong commented 1 year ago

Closing this now since the issue has been answered. It is probably not a good idea for python-stdnum to make all modules available through the toplevel module name because of performance reasons (all the modules would have to be loaded for simply an import stdnum statement).