Python Forum
want better option name for a conversion function - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: want better option name for a conversion function (/thread-20210.html)



want better option name for a conversion function - Skaperen - Jul-31-2019

i have a function that converts ints to strings, given the int value, the sequence of digits to convert with, the minimum width of the result, the prefix to pad the result with if it is shorter than the minimum width. the name "digits" for the sequence of digits to convert with, just doesn't seem quite right to me. is there a better name i can use? the len() of this string will be the default base, and the maximum base if the caller specifies a base.


RE: want better option name for a conversion function - cvsae - Jul-31-2019

Hello Skaperen, variable names can be any combination of characters, it is good practice to use names that imply their content, making the program easier to read and understand. digitsis preferable to use the field name for the corresponding variable, than a name consisting of a single letter such as a or b or any random name that does not reflect the actual content of the variable such as Value.


RE: want better option name for a conversion function - Skaperen - Aug-01-2019

but what name would describe in a meanigful way? to make it is understood, this is the string that the conversion gets digits from,indexed by the digit value. something not too long is preferred.