Re: How to sort this without 'cmp=' in python 3?

2023-10-24 Thread Mike H via Python-list
On Saturday, October 15, 2016 at 12:27:42 AM UTC-7, Peter Otten wrote: > 38016...@gmail.com wrote: > > > nums=['3','30','34','32','9','5'] > > I need to sort the list in order to get the largest number string: > > '953433230' > > > > nums.sort(cmp=lambda a,b: cmp(a+b, b+a), reverse=True) > >

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread Mike H
k, I'd appreciate it. Thanks, On Sat, Apr 11, 2009 at 4:18 PM, George Sakkis wrote: > On Apr 11, 3:03 pm, Mike H wrote: > >> Can I not use the cursor.execute command to pass variables that aren't >> immediately next to each other? If so, is there a better way to go >&

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread Mike H
ht syntax to use near ''name', 'fileno', 'size') VALUES ('Test', 'AAA-000', 7)' at line 1") Can I not use the cursor.execute command to pass variables that aren't immediately next to each other? If so, is there a better way to go a

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread Mike H
Well, I'm an idiot. Obviously, the line "VALUES (%s, %s, %s);" needs to be modified to adapt for the number of arguments in the list. But otherwise On Sat, Apr 11, 2009 at 11:28 AM, Mike H wrote: > Ok, thanks again to everyone for their suggestions, even if it appears >

Re: Unsupported operand types in if/else list comprehension

2009-04-11 Thread Mike H
Lcmd="INSERT INTO " + myTable + " (%s) " % ", ".join(myFields) SQLcmd=SQLcmd + "VALUES (%s,%s,%s);" cursor.execute(SQLcmd, (myValues)) #sets and returns SQL variable. SQLcmd="select " + myReturnKey + ":=last_insert_id();" c

Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Mike H
, 1, 'two'] and have a function correct the list for me, rather than calling the function with a strangely quoted list e.g. ['"'test'"', 1, '"'two'"']. Again, thanks. On Fri, Apr 10, 2009 at 5:18 PM, John Yeung wrote: > On

Unsupported operand types in if/else list comprehension

2009-04-10 Thread Mike H
Hello all, I have a question about the if/else aspect of list comprehension: I would like to go through a list and place quotes around an item if it is a string, and keep the item the same if it's anything else: e.g.['a',9,'8b'] --> ['"a"', 9, '"8b"'] I understand that if/else list comprehension