Python Forum
calling a function and argument in an input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calling a function and argument in an input
#2
Your description is very limited, but i assume you mean this:

somewhere in your app you have:
Quote:def rotate(angle):
....do_something
rotate is a function and angle the argument.
Elsewhere you have an input() statement for the user,
and you want him/her to be able to type ">rotate(6)".
The simplest way would be to have two inputs:
a = input("What angle do you need ? ") -> convert that to int()
c = input("What command should I execute? ")
For the variable c you will have to construct some logic that says:
if it's "r" do rotate, if its "x" do something else.
My 2 cts,
Paul
Reply


Messages In This Thread
RE: calling a function and argument in an input - by DPaul - Oct-24-2020, 07:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 1,047 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  mutable argument in function definition akbarza 1 494 Dec-15-2023, 02:00 PM
Last Post: deanhystad
  calling external function with arguments Wimpy_Wellington 7 1,461 Jul-05-2023, 06:33 PM
Last Post: deanhystad
  Calling a function (which accesses a library) from another file mouse9095 4 835 Jun-07-2023, 08:55 PM
Last Post: deanhystad
  pyscript index error while calling input from html form pyscript_dude 2 999 May-21-2023, 08:17 AM
Last Post: snippsat
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,109 Dec-25-2022, 03:00 PM
Last Post: askfriends
  i want to use type= as a function/method keyword argument Skaperen 9 1,910 Nov-06-2022, 04:28 AM
Last Post: Skaperen
  Showing an empty chart, then input data via function kgall89 0 986 Jun-02-2022, 01:53 AM
Last Post: kgall89
Sad Iterate randint() multiple times when calling a function Jake123 2 2,065 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  input function question barryjo 12 2,739 Jan-18-2022, 12:11 AM
Last Post: barryjo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020