I cannot seem to get Reportlab's 4 state bar code to work. I keep getting "NameError: name 'USPS_4State' is not defined", yet if I 'dir' the module it's clearly loaded;

dir(usps4s)
arcode', 'USPS_4State', '__all__', '__builtins__', '__doc__', '__file__', '__
e__', '__package__', '__version__', '_crc11', '_initNof13Table', '_ru13', '_t

The usage is correct as far as I know, I copied the example from the Docs:

print USPS_4State('1234987654321', '01234567891').barcodes

What am I doing wrong?, I'm relatively new to Python, but not programming.

Edited 6 Years Ago by Tommymac501: n/a

You should probably write

print usps4s.USPS_4State('1234987654321', '01234567891').barcodes

or

from usps4s import USPS_4State
print USPS_4State('1234987654321', '01234567891').barcodes

You should probably write

print usps4s.USPS_4State('1234987654321', '01234567891').barcodes

or

from usps4s import USPS_4State
print USPS_4State('1234987654321', '01234567891').barcodes

I was able to get it to work pointing at it directly; 'reportlab.graphics.barcode.usps4s.USPS_4State("012345678901234", "0123456")', but it seems to me I shouldn't have to?..

try

from reportlab.graphics.barcode.usps4s import USPS_4State
print USPS_4State('1234987654321', '01234567891').barcodes

try

from reportlab.graphics.barcode.usps4s import USPS_4State
print USPS_4State('1234987654321', '01234567891').barcodes

That works!... I guess I wasn't going to the moudule level, I assumed that if I imported 'usps4s', I would get 'USPS_4State'...

Thanks a bunch!

Edited 6 Years Ago by Tommymac501: n/a

This question has already been answered. Start a new discussion instead.