#23399: Update int_to_base36 -------------------------------------+------------------------------------- Reporter: liminspace | Owner: Type: | liminspace Cleanup/optimization | Status: new Component: Utilities | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Has patch: 0 | Unreviewed Needs tests: 0 | Needs documentation: 0 Easy pickings: 0 | Patch needs improvement: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by liminspace): kezabelle, try this: {{{ def int_to_base36(n): if n < 0: raise ValueError("Negative base36 conversion input.") if six.PY2: if not isinstance(n, six.integer_types): raise TypeError("Non-integer base36 conversion input.") if n > sys.maxint: raise ValueError("Base36 conversion input too large.") c = '0123456789abcdefghijklmnopqrstuvwxyz' if 0 <= n < 36: return c[n] b36 = '' while n != 0: n, i = divmod(n, 36) b36 = c[i] + b36 return b36 }}} -- Ticket URL: <https://code.djangoproject.com/ticket/23399#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.4d58ae1cccb7477602b2cf8326c27afc%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.