Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are unicode identifiers in python bad practice?

I am getting into machine learning, and to document my code, I will write LaTeX math versions of my functions, right next to the code in an Jupyter/IPython notebook. The mathematical definitions include many Greek symbols, so I thought that I might as well use the Greek symbols in function and variable names, since that's possible in python. Would this be bad practice?


1 Answers

It seems a good use case under these assumptions:

  • the audience is mathematically versed,
  • you make use of a lot of Jupyter Notebook features such as inline plotting and table display (e.g. pandas) so that the use of your code outside a notebook is unlikely,
  • it is application code rather than a library that others will use.

Hint: Entering Greek letters in the notebook is simple. Just type the LaTeX math notation and TAB. For example, type:

\pi

and then the TAB key to get a π.

like image 103
Mike Müller Avatar answered Oct 16 '25 21:10

Mike Müller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!