简体   繁体   中英

Python def function title

I want to make a function but in the title it won't let me add a fullstop,

For Example:

 def system.do():

But it won't let have the full stop so how can I get it so it does?

Thanks For The Help!

You can't define a normal function like that, as . is not allowed in an identifier.

From docs :

identifier ::=  (letter|"_") (letter | digit | "_")*
letter     ::=  lowercase | uppercase
lowercase  ::=  "a"..."z"
uppercase  ::=  "A"..."Z"
digit      ::=  "0"..."9"

The only way you can create such function is by defining a static method named do in a class named system .

class system:
    @staticmethod
    def do():
        pass
print system.do()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM