calling a function from another file
<p>I'm writing a code on python where I must import a function from other file. I write <code>import filename</code> and <code>filename.functionname</code> and while I'm writing the first letter of the function name a window pops up on PyCharm showing me the full name of the function, so I guess Python knows that the file has the function I need. When I try it on console it works. But when I run the same thing on my code it gives an error: <code>'module' object has no attribute 'get_ecc'</code>. what could be the problem? The only import part is the last function, <code>make_qr_code</code>.</p>

<pre><code> """ Create QR error correction codes from binary data, according to the
 standards laid out at http://www.swetake.com/qr/qr1_en.html. Assumes the
 following when making the codes:
- alphanumeric text
- level Q error-checking
 Size is determined by version, where Version 1 is 21x21, and each version up
 to 40 is 4 more on each dimension than the previous version.
 """

import qrcode

class Polynomial(object):
""" Generator polynomials for error correction.
"""

# The following tables are constants, associated with the *class* itself
# instead of with any particular object-- so they are shared across all
# objects from this class.
# We break style guides slightly (no space following ':') to make the
# tables easier to read by organizing the items in lines of 8.


def get_ecc(binary_string, version, ec_mode):
    """ Create the error-correction code for the binary string provided, for
    the QR version specified (in the range 1-9).  Assumes that the length of
    binary_string is a multiple of 8, and that the ec_mode is one of 'L', 'M',
    'Q' or 'H'.
    """

    # Create the generator polynomial.
    generator_coeffs = get_coefficients(SIZE_TABLE[version, ec_mode][1])
    generator_exps = range(len(generator_coeffs) - 1, -1, -1)
    generator_poly = Polynomial(generator_coeffs, generator_exps)

    # Create the message polynomial.
    message_coeffs = []
    while binary_string:
        message_coeffs.append(qrcode.convert_to_decimal(binary_string[:8]))
        binary_string = binary_string[8:]
    message_max = len(message_coeffs) - 1 + len(generator_coeffs) - 1
    message_exps = range(message_max, message_max - len(message_coeffs), -1)
    message_poly = Polynomial(message_coeffs, message_exps)

    # Keep dividing the message polynomial as much as possible, leaving the
    # remainder in the resulting polynomial.
    while message_poly.exps[-1] &gt; 0:
        message_poly.divide_by(generator_poly)

    # Turn the error-correcting code back into binary.
    ecc_string = ""
    for item in message_poly.coeffs:
        ecc_string += qrcode.convert_to_binary(item, 8)
    return ecc_string
</code></pre>
