I have 2 questions. 1. Is there a way to do a reverse and a normal sort at the same time? I have a list of tuples (there are more than 2 elements in the tuples but I only want to sort by the first two). I want to sort in reverse for the first element (int) and in order for the second element (string).
Example: [ (1,3) (5, 2), (5, 1), (1, 1) ]. The output should be:[ (5,1), (5,2), (1,1), (1,3) ] I can create a hack for this by sorting both values in order but it is a hack and not a "Good" solution (untested): >>> sorted( lst, key=lambda x: (9999999999-x[0],x[1]) ) 2. How would you programmatically get a variable when there is no class involved? If I was in a class I could do something like >>> programmatically_determined_variable = getattr( self, var_basename + >>> str(number) ) How would I do this from a module function or directly in the module? And is the solution "safe"? Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to European legal entities. _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
