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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:39:28+00:00 2026-06-11T15:39:28+00:00

On a Python assignment, I had to make the following two functions: move(board, move)

  • 0

On a Python assignment, I had to make the following two functions:

move(board, move)
undomove(board, move)

Having an argument with the same name as the function seems like a bad practice to me. I already contacted the professor to change it, but out of curiosity, is it possible to call the move function from inside the undomove, or to use recursion on the move? Inside these functions, move refers to the argument.

(Python 3, if it matters)

  • 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-11T15:39:30+00:00Added an answer on June 11, 2026 at 3:39 pm

    You can get a handle on move (the function), however it will require some additional gymnastics.

    def move(move):
        print(move,"inside move")
    
    def undomove(move):
        print (move,"inside undomove")
        this_mod =__import__(__name__)
        this_mod.move(move)
    
    if __name__ == '__main__':
        move(1)
        undomove(2)
    

    Generally though, I would definitely avoid naming a local variable with the same name as a function that I will need in that function.

    As far as style is concerned, creating a function def move(move): ... is definitely a little weird, and it would make the casual reader think that you’re trying to write a recursive function, so I would definitely avoid that. Writing undomove(move) when move is already defined in the module scope as a function is a little less weird, but it still might cause confusion at a quick glance (is it a local variable? is it the function?) so I would probably avoid that one as well.

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

Sidebar

Related Questions

I am new to python and am having difficulties with an assignment for a
I'm writing a chat server in Python for an assignment. However, I am having
In Python, I'm getting the following error: UnboundLocalError: local variable 'total' referenced before assignment
I have been asked to write a program using python for an assignment. I
As part of the last assignment in a beginner python programing class, I have
Hi I am new to Python and as a part of my assignment I
(Python) Given two numbers A and B. I need to find all nested groups
Possible Duplicate: Python conditional assignment operator Apologies for such a simple question, but googling
Is there a way to do a variable assignment inside a function call in
My understanding was that Python strings are immutable. I tried the following code: a

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.