Rafael Monteiro
Rafael Monteiro

Reputation: 355

how i fix SyntaxError: invalid syntax?

I'm writing a python code, and it's giving me a error, that says that an space is an invalid sytanx, look:

from './getinput.py' import getInput as getInput

and it says this error:

line 1
    from './getinput.py' import getInput as getInput
                       ^
SyntaxError: invalid syntax

i don't know what to do, could you guys give me some help? Here is some code if necessary, let's start with my main file:


def WhereDoIStart():
    print("Hi! How are you? Whats your name?")
    name = input()

    print('''Well, '''+name+''' i hope you're doing well! This here is not the text i have, but i can include it's features! it has somethings like this: "+", "-", "*", "/"''')
    getInput()

WhereDoIStart() 

here i have what's in getinput.py:

def getInput():
    Userinput = input(">: ")
    return Userinput

Upvotes: 0

Views: 2875

Answers (1)

Gustav Rasmussen
Gustav Rasmussen

Reputation: 3971

From the documentation of Python's import system

https://docs.python.org/3/reference/import.html

Section 5.4.2 Submodules, translated into your example: If there is the following folder structure

spam/
    __init__.py
    getinput.py

You could import the getinput module's function as follows:

from .getinput import getInput as getInput

Upvotes: 1

Related Questions