
import os
import sys

# Load problem file as
def load_file_as_module(file):
    """
    Load problem file as a module.

    :param file: The full path to the problem file

    returns a module represented by the problem file
    """

    # Create a new module to hold the seed variable so
    # the loaded module can reference the seed variable

    if sys.version_info[0] == 2:
        import imp
        problem_module = imp.load_source('prob_module',file)

    if sys.version_info[0] == 3:
        import importlib.machinery
        problem_module = importlib.machinery \
                                  .SourceFileLoader("prob_module",file) \
                                  .load_module()

    try:
        problem_module.answers
    except AttributeError:
        raise AttributeError('Problem file has no \'answers\' attribute')

    return problem_module



import os
import sys

# Load problem file as
def load_file_as_module(file_path):
    """
    Load problem file as a module.

    :param file: The full path to the problem file

    returns a module represented by the problem file
    """

    # Create a new module to hold the seed variable so
    # the loaded module can reference the seed variable

    if sys.version_info[0] == 2:
        import imp
        problem_module = imp.load_source('prob_mod_pkg',file_path)

    if sys.version_info[0] == 3:
        import importlib.machinery
        problem_module = importlib.machinery \
                                  .SourceFileLoader('prob_mod_pkg',file_path) \
                                  .load_module()

    try:
        problem_module.answers
    except AttributeError:
        raise AttributeError('Problem file has no \'answers\' attribute')

    return problem_module


Change package name in loadmodule call
Change package name in loadmodule call

Not much reason to do this. It just happened.

  
  import os
  import sys
  
  # Load problem file as
- def load_file_as_module(file):
+ def load_file_as_module(file_path):
      """
      Load problem file as a module.
  
      :param file: The full path to the problem file
  
      returns a module represented by the problem file
      """
  
      # Create a new module to hold the seed variable so
      # the loaded module can reference the seed variable
  
      if sys.version_info[0] == 2:
          import imp
-         problem_module = imp.load_source('prob_module',file)
+         problem_module = imp.load_source('prob_mod_pkg',file_path)
  
      if sys.version_info[0] == 3:
          import importlib.machinery
          problem_module = importlib.machinery \
-                                   .SourceFileLoader("prob_module",file) \
+                                   .SourceFileLoader('prob_mod_pkg',file_path) \
                                    .load_module()
  
      try:
          problem_module.answers
      except AttributeError:
          raise AttributeError('Problem file has no \'answers\' attribute')
  
      return problem_module
  
  
Change package name in loadmodule call
## Code Before:

import os
import sys

# Load problem file as
def load_file_as_module(file):
    """
    Load problem file as a module.

    :param file: The full path to the problem file

    returns a module represented by the problem file
    """

    # Create a new module to hold the seed variable so
    # the loaded module can reference the seed variable

    if sys.version_info[0] == 2:
        import imp
        problem_module = imp.load_source('prob_module',file)

    if sys.version_info[0] == 3:
        import importlib.machinery
        problem_module = importlib.machinery \
                                  .SourceFileLoader("prob_module",file) \
                                  .load_module()

    try:
        problem_module.answers
    except AttributeError:
        raise AttributeError('Problem file has no \'answers\' attribute')

    return problem_module


## Instruction:
Change package name in loadmodule call
## Code After:

import os
import sys

# Load problem file as
def load_file_as_module(file_path):
    """
    Load problem file as a module.

    :param file: The full path to the problem file

    returns a module represented by the problem file
    """

    # Create a new module to hold the seed variable so
    # the loaded module can reference the seed variable

    if sys.version_info[0] == 2:
        import imp
        problem_module = imp.load_source('prob_mod_pkg',file_path)

    if sys.version_info[0] == 3:
        import importlib.machinery
        problem_module = importlib.machinery \
                                  .SourceFileLoader('prob_mod_pkg',file_path) \
                                  .load_module()

    try:
        problem_module.answers
    except AttributeError:
        raise AttributeError('Problem file has no \'answers\' attribute')

    return problem_module

