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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:48:36+00:00 2026-06-02T18:48:36+00:00

Can please anyone help me with my problem. I am new to python and

  • 0

Can please anyone help me with my problem. I am new to python and I can not get how to pass an argument to a function in the following case:
In a separate file (sentiment_analysis) I have a dictionary and an array of objects:

positiveSentiments = dict() // here are some words related to each of the object
objects = ['Google', 'Apple', 'Motorola']

I need to display positive sentiments of each object:

def onButtonPosObject(p):
for key in sentiment_analysis.positiveSentiments.keys():
    if key == p:
        text.insert(END, sentiment_analysis.positiveSentiments[key])

submenu = Menu(text, tearoff=0)
for p in sentiment_analysis.objects:
   submenu.add_command(label=p, command = lambda : onButtonPosObject(p), underline=0)
textmenu.add_cascade(label='Display positive sentiments', menu=submenu, underline=0)

I think I have to pass a value of label (p) as a parameter of onButtonPosObject() function and I need to get a list of words from positiveSentiments dictionary for every object but I get empty value like [].
I would be very grateful for any recommendations!

  • 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-02T18:48:37+00:00Added an answer on June 2, 2026 at 6:48 pm

    You need to capture the current value of p in the lambda:

    submenu.add_command(label=p, command = lambda p=p: onButtonPosObject(p), underline=0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help me spot the problem on this PLEASE? I'm eternally grateful for
Can anyone please help me to work out how to achieve the following? I
Can anyone please help me with this...I'm not very good with regular expressions and
Can anyone please help. I'm following a tutorial found here as I have a
Please can anyone help me out with this problem? This code below works perfectly
Can anyone please help. Im following a tutorial on drawing primitives from the MSDN
Can anyone please help me to add video controls (play, pause, forward, seekbar) to
Can anyone please help me to understand how should i access json data in
Can anyone please help me how to convert string to date I have 3
Can we add image together with text in a picker view? Anyone please help!

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.