CodeHappy
CodeHappy

Reputation: 81

Python methods do not show up in user defined functions

When creating a user defined function the built-in methods do not pop up as options.

In the main body of the file the methods show up without issue. It's only when you create a function that they do not show up.

def strip_punctuation(astring):
    #punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']
    astring.replace()
    return (astring)

# Main file
my_string = "Word's!"
my_string.replace()

I'd expect the same behavior in VS Code in both a user defined function as well as outside the function.

Upvotes: 1

Views: 68

Answers (1)

Brett Cannon
Brett Cannon

Reputation: 16080

If you rewrote your code with type annotations you should get what you want:

def strip_punctuation(astring: str) -> str:
    astring.replace()
    return astring

Upvotes: 1

Related Questions