1

I am relatively new to programming. I have seen lots of Github projects with python file that has functions like these:

def someFunction() -> type: ...

Is this a compiled or censored code? Any help will be very appreciated.

nleg
  • 11
  • 2
  • It might help if you could be more specific, but see https://stackoverflow.com/q/772124/3001761 – jonrsharpe Jan 29 '21 at 22:05
  • `...` is a literal, it evaluates to an `ellipses` object. Just like `1` evaluates to an `int` object. This is an idiom often used in different context when you want to define a method that isn't meant to be called – juanpa.arrivillaga Jan 29 '21 at 22:06
  • 1
    While the duplicate describes what an ellipsis is, it does not provide an explanation of what this particular usage of an ellipsis does. Voting to reopen. – Ivan Jan 29 '21 at 22:13
  • @Ivan, ...have you looked for other duplicates in the knowledge base that describe what this usage does? It's not like questions about type hinting are rare; I'd be happy to update the duplicate list if you provide a question you think is a better fit. – Charles Duffy Jan 29 '21 at 22:30
  • @Ivan, ...that said, https://stackoverflow.com/a/50661182/14122 (in the existing linked duplicate) does appear to cover it, to me. – Charles Duffy Jan 29 '21 at 22:31

1 Answers1

-1

Function annotations, both for parameters and return values, are completely optional. Below link explains it in detail.

https://www.geeksforgeeks.org/function-annotations-python/

Dharman
  • 30,962
  • 25
  • 85
  • 135
roshaga
  • 257
  • 3
  • 11