Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Any way to declare constant parameters?

I have a method:

def foo(bar):
   # ...

Is there a way to mark bar as constant? Such as "The value in bar cannot change" or "The object pointed to by bar cannot change".

like image 816
Nick Heiner Avatar asked Jun 21 '10 00:06

Nick Heiner


1 Answers

If bar is an inmutable object, bar won't change during the function.

You can also create your own constant object. The recipe here.

like image 174
razpeitia Avatar answered Oct 22 '22 11:10

razpeitia