How do I recognise strings and numbers

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

Join Date: Mar 2007
Posts: 110
Reputation: solsteel is on a distinguished road 
Solved Threads: 31
solsteel solsteel is offline Offline
Junior Poster

Re: How do I recognise strings and numbers

 
1
  #11
Sep 14th, 2008
obj[:3] is a slice of the time.struct_time object. The asterisk preceding the list returned by the slice expands the list into individual elements. Example:
  1. >>> d = time.strptime('16/06/2010', '%d/%m/%Y')
  2. >>> d
  3. (2010, 6, 16, 0, 0, 0, 2, 167, -1)
  4. >>> [d[0],d[1],d[2]]
  5. [2010, 6, 16]
  6. >>> datetime.date(d[0],d[1],d[2])
  7. datetime.date(2010, 6, 16)
  8. >>> datetime.date(*d[:3])
  9. datetime.date(2010, 6, 16)
  10. >>> d[:3]
  11. (2010, 6, 16)
  12. >>>
The DeprecationWarning you are seeing is unrelated to the code we are discussing, but originates in the pyXLWriter module. Warnings can be suppressed or turned into exceptions with a call to filterwarnings(), which adds an entry to the warning filter. See Python documentation.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC