[CentralOH] chr()/ord() Ugliness
William McVey
wam at cisco.com
Mon Nov 11 16:02:41 CET 2013
On 11/11/2013 09:51 AM, jep200404 at columbus.rr.com wrote:
> What is a better way of accomplishing the following?
> chr(ord('A') + i)
You've listed a method of accomplishing something, but you didn't really
specify specifically what you're looking to do. Assuming you want to
iterate over each of the uppercase letters or pull letters out by
offset, I would probably utilizing indexing or iteration rather than
chr/ord conversions, ala:
import string
string.upper[i]
for letter in string.upper:
do_something_with_letter(letter)
Keep in mind though, this all has a very "ASCII-centric" code smell to
it. If you reply back with more details on what you're trying to
accomplish, we might be able to give you a more general purpose solution.
-- William
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20131111/e3312786/attachment.html>
More information about the CentralOH
mailing list