Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7436245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:12:36+00:00 2026-05-29T10:12:36+00:00

I have built a function to create a dictionary and return it. This function

  • 0

I have built a function to create a dictionary and return it. This function is called get_values, and is structured as follows:

def initiate_values(directory):
    for file in glob.glob(os.path.join(directory, '*.[xX][lL][sS]')):
        title = os.path.basename(file).lower()
        if title == 'etc.xls':
            wb = xlrd.open_workbook(file)
            wb = wb.sheet_by_name(u'Sheet1')
            get_values(file, wb)    

def get_values():
    info_from_etc = dict()
    # build dict
    return info_from_etc    

It works, in that it creates the dictionary and then when I try and print it, it prints the correct values. However, when I try and call this get_values function from another function, the dictionary returns as “None”. This is my function to call get_values –

def packager():
    info_from_etc = initiate_values()
    print info_from_etc # this prints "None"

What am I doing incorrectly here, and how would I return the proper dictionary here — that is, a dictionary that is not None.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:12:37+00:00Added an answer on May 29, 2026 at 10:12 am

    You need to return the dictionary from initiate_values:

    def initiate_values(directory):
        for file in glob.glob(os.path.join(directory, '*.[xX][lL][sS]')):
            title = os.path.basename(file).lower()
            if title == 'etc.xls':
                wb = xlrd.open_workbook(file)
                wb = wb.sheet_by_name(u'Sheet1')
                return get_values(file, wb)  # added `return'
        return {} # or some other value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does Actionscript have a built-in function that accepts a number and can return a
I have the following function CREATE FUNCTION GetIdentity() RETURNS INT AS BEGIN RETURN (IDENT_CURRENT('tblTempPo'))
Does .NET have some type of built in function that allows filtering on Gridviews?
If I have two byte[] arrays, is there a built-in function to compare them
I have a string that looks like this: Name1=Value1;Name2=Value2;Name3=Value3 Is there a built-in class/function
I have a javascript function that is being built to animate the collapse of
I originally intended to use MATLAB to tackle this problem but the in-built function
i have created a function: CREATE FUNCTION FindDistrictId (@param XML) RETURNS INT (...) which
I am familiar with the built-in sum() function for lists and have used it
I have created simple function create function TRIM(@data varchar(20)) returns varchar(100) as begin declare

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.