Thank you, I was doing this: def encode_id(id): ... number = id charset = string.letters + string.digits base = len(charset) count = 0 while number: digit = number % base ...
and kept getting an error, when I did this: id = row[0] encode_id(id) I didn't realize that the L stood for long, anyhow this works: id = int(row[0] encode_id(id) On Sep 30, 7:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-09-30 at 15:08 -0700, Merrick wrote: > > If I run the following query on psql: > > > SELECT nextval('redirect_link_id_seq'); > > > it returns an integer, say 5 > > > when I do the following with the django shell I get a different > > result: > > > >>> def get_next_id(): > > ... cursor = connection.cursor() > > ... cursor.execute("SELECT nextval('redirect_link_id_seq');") > > ... next_id = cursor.fetchone() > > ... return next_id > > >>> row = get_next_id() > > >>> row[0] > > 5L > > > Of course I can cast to an integer > > >>> int(row[0]) > > 5 > > > But I was hoping someone could let me know why my return value is 5L > > and not 5, sorry for such a noob question. > > Because that's what the db wrapper returns. In practice it makes > effectively no difference. Historically, Python use to distinguish > between longs and integers, but even in those days you could almost > always just work with them as "numbers". Today, that's particularly > true. Just use the value returned. Why do you need to it to have type > "int" instead of type "long"? > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---