On Thu, Jan 14, 2010 at 10:13 AM, Stefan Behnel wrote:
>
> Note that this won't work in Py3, where the "cmp" parameter is gone.
>
> Stefan
And he's right again. I should've checked for that. Well, that makes a
CmpInt class the only other solution:
class CmpInt(int):
def __lt__(self, other):
Lie Ryan, 14.01.2010 01:47:
On 01/14/10 06:56, Hugo Arts wrote:
On Wed, Jan 13, 2010 at 8:21 PM, Stefan Behnel wrote:
Hugo Arts, 13.01.2010 15:25:
Here is my solution for the general case:
from itertools import groupby
def alphanum_key(string):
t = []
for isdigit, group in groupby(stri
On Thu, Jan 14, 2010 at 1:47 AM, Lie Ryan wrote:
> On 01/14/10 06:56, Hugo Arts wrote:
>> On Wed, Jan 13, 2010 at 8:21 PM, Stefan Behnel wrote:
>>> Hugo Arts, 13.01.2010 15:25:
Here is my solution for the general case:
from itertools import groupby
def alphanum_key(string
On 01/14/10 06:56, Hugo Arts wrote:
> On Wed, Jan 13, 2010 at 8:21 PM, Stefan Behnel wrote:
>> Hugo Arts, 13.01.2010 15:25:
>>>
>>> Here is my solution for the general case:
>>>
>>> from itertools import groupby
>>> def alphanum_key(string):
>>>t = []
>>>for isdigit, group in groupby(strin
On Wed, Jan 13, 2010 at 2:21 PM, Stefan Behnel wrote:
> Hugo Arts, 13.01.2010 15:25:
>>
>> Here is my solution for the general case:
>>
>> from itertools import groupby
>> def alphanum_key(string):
>> t = []
>> for isdigit, group in groupby(string, str.isdigit):
>> group = ''.join(gro
On Wed, Jan 13, 2010 at 8:21 PM, Stefan Behnel wrote:
> Hugo Arts, 13.01.2010 15:25:
>>
>> Here is my solution for the general case:
>>
>> from itertools import groupby
>> def alphanum_key(string):
>> t = []
>> for isdigit, group in groupby(string, str.isdigit):
>> group = ''.join(gro
Hugo Arts, 13.01.2010 15:25:
Here is my solution for the general case:
from itertools import groupby
def alphanum_key(string):
t = []
for isdigit, group in groupby(string, str.isdigit):
group = ''.join(group)
t.append(int(group) if isdigit else group)
return t
Note
fore 'a2'.
now with alphanumeric sort:
>>> a.sort(key=alphanum_key)
>>> a
['0a', '1a', '10a', 'a1', 'a2', 'a10', 'a11', 'b2', 'b3', 'b20']
Hugo
On Wed, Jan 13, 2010 at 2:
Wed, 1/13/10, Sander Sweers wrote:
From: Sander Sweers
Subject: Re: [Tutor] samples on sort method of sequence object.
To: "Albert-Jan Roskam"
Cc: "*tutor python"
Date: Wednesday, January 13, 2010, 2:14 PM
2010/1/13 Albert-Jan Roskam
>
> Interesting. Can this also
2010/1/13 Albert-Jan Roskam
>
> Interesting. Can this also be used to make sorting of alphanumerical list
> items in a 'numerical' way easier?
> >>> x
> ['var_0', 'var_13', 'var_11', 'var_9', 'var_4', 'var_1', 'var_5', 'var_6',
> 'var_7', 'var_14', 'var_2', 'var_3', 'var_8', 'var_10', 'var_12']
Albert-Jan Roskam, 13.01.2010 13:51:
Interesting. Can this also be used to make sorting of alphanumerical list items
in a 'numerical' way easier? E.g.:
x
['var_0', 'var_13', 'var_11', 'var_9', 'var_4', 'var_1', 'var_5', 'var_6',
'var_7', 'var_14', 'var_2', 'var_3', 'var_8', 'var_10', 'var_12'
are zfilled versions of the list items (e.g.
var_01, etc), then sort the keys, get the dictionary values in the right order,
etc. It seemed a cumbersome way. Isn't there an easier way to sort x?
Cheers!!
Albert-Jan
~~
In the face of am
On Tue, Jan 12, 2010 at 9:39 AM, Make Twilight wrote:
> I can understand how to use parameters of cmp and reverse,except the
> key parameter...
> Would anyone give me an example of using sort method with key parameter?
http://personalpages.tds.net/~kent37/kk/7.html
Kent
___
On Tue, Jan 12, 2010 at 3:39 PM, Make Twilight wrote:
> Hi,there:
> The document of
> Python.org[http://docs.python.org/library/stdtypes.html] says that:
>
>
>
> I can understand how to use parameters of cmp and reverse,except the
> key parameter...
> Would anyone give me an example of using s
Hi,there:
The document of
Python.org[http://docs.python.org/library/stdtypes.html] says that:
--
s.sort([cmp[, key[, reverse]]])
8. The sort() method takes optional arguments fo
D. Hartley gmail.com> writes:
> code, but it's made up of 46 different .py files, none of which seem
> to be the "main" game (lots of little modules, like an input box, a
> high score list, etc). It's a lot harder for someone new to
> programming to read.
Identify the main file (the one that y
> What I *am* looking for, if you have it or know of anyone who does,
is
> *simple* source code files (preferrably the entire game's code is in
> one .py file),
Thats unlikely to happen because its very bad practice and
Python tries to make it easy NOT to do that. Breaking code
into modules makes
D. Hartley wrote:
> Does anyone have any little "gamelets" like these, or know of
> well-documented comparable examples? I'd particularly love some
> bejeweled examples, but really, the more "little examples" I can look
> through and play with the better off I am. (And yes, I have checked
> and
Hello, everyone!
I hope this isnt the wrong place to post this, but the internet has
not been very helpful to me on this point.
I am looking for several (open-source, obviously) clones of Bejeweled
(the pop cap game) or something like it. There is one listed at
pygame (and that same one is refer
19 matches
Mail list logo