Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the name of the ord() function stand for?

The official Python documentation explains ord(c)

ord(c):
Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('€') (Euro sign) returns 8364. This is the inverse of chr().

It does not specify the meaning of ord, google searches are not helpful.

What's the origin of it?

like image 648
AbstProcDo Avatar asked May 13 '18 08:05

AbstProcDo


People also ask

What does ORD () stand for in Python?

The ord() function returns the number representing the unicode code of a specified character.

What does ORD mean on computer science?

Ord is a function (short of ordinal) which returns an integer representing the character passed to it. It means every character has some integer value; these characters cannot be read by computer directly; it first converts every character into the ASCII code.

What is use of Ord () and CHR () functions?

Python ord() and chr() are built-in functions. They are used to convert a character to an int and vice versa. Python ord() and chr() functions are exactly opposite of each other.

What does the name of the CHR () function stand for?

The chr() function returns the character that represents the specified unicode.


2 Answers

It stands for "ordinal".

The earliest use of ord that I remember was in Pascal. There, ord() returned the ordinal value of its argument. For characters this was defined as the ASCII code.

The same convention was also used in Modula-2.

Later, Python (as well as PHP, some dialects of SQL etc) followed this convention, except that these days they're more likely to use Unicode rather than ASCII.

It could well be that the origins of the term (and the function name) go back further than Pascal.

like image 61
NPE Avatar answered Nov 03 '22 16:11

NPE


Return the integer ordinal of a one-character string.

I took this from ord.doc in python command line. ord meaning ordinal of a one character.

like image 33
Karthik Avatar answered Nov 03 '22 14:11

Karthik