newb: Print ids, you get 1L, what is L?

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2007
Posts: 58
Reputation: jobs is an unknown quantity at this point 
Solved Threads: 0
jobs jobs is offline Offline
Junior Poster in Training

newb: Print ids, you get 1L, what is L?

 
0
  #1
Sep 14th, 2007
When I execute the following sql,select id from people, inside python and print the result, I get this:

((11L,), (12L,), (13L,), (14L,), (15L,), (16L,), (17L,), (18L,), (19L,), (20L,))

Why does python print L beside the numbers. Just to indicate Long type?
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 150
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: newb: Print ids, you get 1L, what is L?

 
0
  #2
Sep 14th, 2007
Apparently so. You can check it:

  1. >>> a = ((11L,), (12L,), (13L,), (14L,), (15L,), (16L,), (17L,), (18L,), (19L,), (20L,))
  2. >>> print a[0]
  3. (11L,)
  4. >>> print a[0][0]
  5. 11
  6. >>> print type(a[0][0])
  7. <type 'long'>
  8. >>>

Jeff
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 33
Reputation: paddy3118 is an unknown quantity at this point 
Solved Threads: 8
paddy3118 paddy3118 is offline Offline
Light Poster

Re: newb: Print ids, you get 1L, what is L?

 
0
  #3
Sep 15th, 2007
If you are returning longs you can selectively turn them into integers using int() e.g:
  1. >>> a = ((11L,), (12L,), (13L,), (14L,), (15L,), (166666666666L,))
  2. >>> b = tuple((int(i[0]),) for i in a)
  3. >>> b
  4. ((11,), (12,), (13,), (14,), (15,), (166666666666L,))
  5. >>>
- Paddy.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum


Views: 1761 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC