next alpha sequence value from var pointing to array

Peter Otten __peter__ at web.de
Thu Jun 7 10:03:05 EDT 2012


jdmorgan wrote:

> Hi Peter,
> 
> Thanks for you feedback. I have the next_alpha function you have
> provided.  But, am still getting the same result.
> The actual value I am passing in is "btl".  But, as I mentioned I am
> getting it from an array value.  

Note that what you are calling an array is (somewhat confusingly) called 
"list" in Python. Still, it doesn't matter where you get it from if you are 
actually passing the string "btl" to next_alpha() the result should be 
"btm".

> Here is my actual code.

There seems to be missing something at the end of the function...

> I am reading a comma separated file, getting the last item and trying to
> get the next alpha.  Thanks again.
> 
> 
> def getNRTLid(layerName):
>      lids_seen = []
>      lyrs_seen = []
>      last_lid = ""
>      f = open("NRTLayerLID.csv", "r");
>      for line in f:
>          sp = line.split(',')
>          lyrs_seen.append(sp[0])
>          lids_seen.append(sp[1])
>      f.close();
>      sorted_array = sorted(lids_seen)
>      sorted_array.reverse()
>      print "highest lid is %s" % sorted_array[0]

Change %s to %r in the above. There may be whitespace characters at the end 
of the string which you can detect that way. 

       print "highest lid is %r" % sorted_array[0] # what does that print?

>      highest_lid = sorted_array[0]
>      test = highest_lid.lower()
>      nl = next_alpha(test)

       print repr(nl) # what does that print?






More information about the Python-list mailing list