0

This is my part of the code:

import functions
def assign_tasks(operators, requests, current_time):
    sort_requests(requests)
    print(requests)

The error is:

NameError: name 'sort_requests' is not defined

The function module has the following functions:

def sort_requests(requests):
   requests.sort(key=operator.itemgetter(3),reverse=True)
   return requests 
def sort_operators_hours(operators):
   operators.sort(key=operator.itemgetter(4))
   return operators
1
  • 1
    You have to use the function calling the module name first: functions.sort_request(requests) or change your import line: from functions import sort_requests Commented Dec 7, 2017 at 15:10

2 Answers 2

1

add from functions import sort_requests or replace sort_requests(requests) by functions.sort_requests(requests)

Sign up to request clarification or add additional context in comments.

Comments

0

First : Check your import statement. Is it function or functions.IT should be the name of your python file name.

Second : your function sort_requests has a return statement. U need to store the returned output.Try this

import functions
def assign_tasks(operators, requests, current_time):
    requests = sort_requests(requests)
    print(requests)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.