Showing posts with label compile. Show all posts
Showing posts with label compile. Show all posts

Tuesday, October 1, 2013

Sum a multidimensional list in python

How can i compute this :

[["toto", 3], ["titi", 10], ["toto", 2]]

to obtain this:

[["toto", 5], ["titi", 10]]

thanks

You can use collections.defaultdict

>>> from collections import defaultdict>>> d = defaultdict(list)>>> for i, j in L:...     d[i].append(j)... >>> [[i, sum(j)] for i, j in d.items()][['titi', 10], ['toto', 5]]

Thanks @raymonad for the alternate, cleaner, solution:

>>> d = defaultdict(int)>>> L = [["toto", 3], ["titi", 10], ["toto", 2]]>>> for i, j in L:...     d[i] += j... >>> d.items()[('titi', 10), ('toto', 5)]

Thursday, September 16, 2010

How to compile pseuwow under Linux

Pseuwow is widely known as a client emulator for mangos project, it allows you sent chat text to players in game through command line in console which is just like a bot. It officially announce it is 99% support Linux, however due to the author does not familiar with Linux, the Makefile become the 1% which is causes some minor problem.

Prepare

git clone http://github.com/fgenesis/pseuwow.gitmv  pseuwow/src/dep/include/openssl  pseuwow/src/dep/include/opensslx

You need to create a Makefile.am in pseuwow/src/dep/src/irrKlang/

INCLUDES = -I../../include/irrklang -I../../includelibdir=$(top_builddir)/src/dep/lib/linux-gccnoinst_LIBRARIES = libIrrKlang.alibIrrKlang_a_SOURCES = \irrKlang.cpp

and modify pseuwow/src/dep/src/Makefile.am

SUBDIRS = irrlicht zlib zthread irrKlangThen modify pseuwow/src/Client/Makefile.am

Fix the line

../dep/lib/linux-gcc/libIrrKlang.so\

to the correct path

Then

$aclocal$autoreconf$automake$./configure --prefix=/opt/pseuwow$make$make install

at last, you need to copy the entire “dep” direictory & “conf” directory to /opt/pseuwow/bin/

Pseuwow is widely known as a client emulator for mangos project, it allows you sent chat text to players in game through command line in console which is just like a bot. It officially announce it is 99% support Linux, however due to the author does not familiar with Linux, the Makefile become the 1% which is causes some minor problem.