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 8873279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:25:33+00:00 2026-06-14T18:25:33+00:00

Code: def user(repo, language, page): # import pdb;pdb.set_trace() dictionary = {‘language_search’: language, ‘page’: page,

  • 0

Code:

def user(repo, language, page):
  # import pdb;pdb.set_trace()
  dictionary = {'language_search': language, 'page': page, 'followers': repo['followers'], 'github_repo': repo['name'],'forked?': repo['fork'], 'forks': repo['forks'], 'github_owner': repo['owner'], 'language': repo['language'], 'created_at': repo['created_at'], 'forks': repo['forks'], 'watchers': repo['watchers'], 'username': user['login'], 'type': user['type'], 'public_repos': user['public_repos'], 'followers': user['followers']}
  fields_user = ['blog', 'company', 'location', 'name']
  fields_repo = ['description']
  if user.get('email'):
    dictionary_2 = {'email': user['email']}
    for key in fields_user:
      if user.has_key(key):
        dictionary[key] = user[key]
    for key in fields_repo:
    if repo.has_key(key):
      dictionary[key] = repo[key]
    shelf[dictionary_2['email']] = dictionary
    shelf.sync()
    return dictionary_2['email']
    print dictionary_2['email']

For some reason I keep getting this error:

<ipython-input-40-98ec5463ecbd> in user(repo, language, page)
  1 def user(repo, language, page): #returns email address to pass into rapportive
  2   # import pdb;pdb.set_trace()
----> 3   dictionary = {'language_search': language, 'page': page, 'followers': repo['followers'], 'github_repo': repo['name'],'forked?': repo['fork'], 'forks': repo['forks'], 'github_owner': repo['owner'], 'language': repo['language'], 'created_at': repo['created_at'], 'forks': repo['forks'], 'followers': user['followers']}
  4   # dictionary = {, , 'watchers': repo['watchers'], 'username': user['login']} , 'type': user['type'], , 'public_repos': user['public_repos']
  5   fields_user = ['blog', 'company', 'location', 'name']

TypeError: 'function' object is not subscriptable

And I don’t understand why. I just want to write more key:value pairs to dictionary. But for some reason, this keeps throwing off this error.

  • 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-06-14T18:25:34+00:00Added an answer on June 14, 2026 at 6:25 pm

    user is a function:

    def user(repo, language, page):
    

    but within that function you are trying to use it as a dictionary instead:

     user['followers']
    

    on the line where you define dictionary:

    dictionary = {'language_search': language, 'page': page, 'followers': repo['followers'], 'github_repo': repo['name'],'forked?': repo['fork'], 'forks': repo['forks'], 'github_owner': repo['owner'], 'language': repo['language'], 'created_at': repo['created_at'], 'forks': repo['forks'], 'followers': user['followers']}
    

    You can split that line up over several to make it more readable and debuggable:

    dictionary = {
        'language_search': language, 
        'page': page,
        'followers': repo['followers'],
        'github_repo': repo['name'],
        'forked?': repo['fork'],
        'forks': repo['forks'],
        'github_owner': repo['owner'],
        'language': repo['language'],
        'created_at': repo['created_at'],
        'forks': repo['forks'],
        'followers': user['followers']  # `user` is a function, what did you mean instead?
    }
    

    You seem to expect there to be a user dictionary in your function throughout:

      if user.get('email'):    # Will also throw the error
        dictionary_2 = {'email': user['email']}  # as will this
        for key in fields_user:
          if user.has_key(key):                  # and this
            dictionary[key] = user[key]          # and here
    

    Perhaps you have a global named user that is a dictionary? You cannot have both a dictionary and a function with the same name in your module. Rename one or the other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: def create @user = User.new(params[:user]) simp_ = User.new(params[:user]) if
I have the following code: def analytics @user_registrations = User.count(:conditions => [created_at >= ?,
I have the following lines of code: def edit = { if (session.user.id !=
This is my session's controller code def create user = User.authenticate(params[:login], params[:password]) if user
In my Groovy script I have this code: def username = System.getenv()['USER'] def password
there is my code in controller def new @user = User.new end and there
I have this code: def display(self): print self.doc.toprettyxml(indent= ) strigName ='/Users/my_user/Desktop/python/' + str(datetime.datetime.now()) +
My Controller (User Controller) def reset_password @user = User.find_by_reset_code(params[:reset_code]) unless params[:reset_code].nil? if request.post? if
My Controller (User Controller) def reset_password @user = User.find_by_reset_code(params[:reset_code]) unless params[:reset_code].nil? if request.post? if
model: User has_one :beta_invite before_save :beta_code_must_exist def beta_code_must_exist if beta_invite_id == beta_invite.find_by_name(beta_invite.id) user else

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.