User will be inputing file path

I require the user to input path of file, from which i will be reading marker coordinate. So as raw_input function is unsupported in python, is there any other function or way to achieve this.

user_input = raw_input("Enter the path of your file: ")
filepath = str(user_input)

The above code incurs errors at python interactor, so let me know ,the way around it.
Thanks in advance!!!

@abatpool

You can use the replacement input function which exists in Python 3

filepath = input("Enter the path of your file: ")

The input built-in function returns a string type so you don’t need additional casting.

Best,
Andinet

oh yes. thank you @Andinet_Enquobahrie . Have a great day ahead!!

Dear slicers, thank you for this post.
I have a similar problem: I want the user to specify some inputs from the python interactor. You can copy the following code into the python interactor to figure out what my problem is:

while(True):
  a = input("Insert a character or press 'q' to quit: ")
  print('Your character: ', a)
  if a == 'q':
    break

Before writing the second input, I have to press the down key to avoid messing with the input and output lines.
It is possible to avoid this and make the input and output lines follow each other neatly?

Do you mean that within Slicer application, you would want user to type input in the Python interactor instead of using graphical user interface (in your module GUI, in a popup window, etc.)?

Dear @lassoan thank you for your activity in this forum: your answers have been helpful to me in several occasions.
My goal is to create a debugging mode for my module so that I can pause code execution at certain points to observe partial results. The solution I found is to wait for a user input in the python interactor which would then allow the execution to proceed or pause.
Would you suggest putting “continue” and “stop” buttons in the GUI? Where can I find examples?

For interactive debugging, you can attach a debugger and there you can do anything. Inspect variables, change variable values, run any commands, etc. See step-by-step instructions here.