Comparing lists ...

2007-02-13 Thread Loic
I would like to know if it is possible, and how to do this with Python:

I want to design a function to compare lists and return True only if 
both lists are equal considering memory location of the list.
I suppose it would be the equivalent of comparing 2 pointers in c++

lets call this function check(a, b)
and define a few lists:

 >>> l0 = [1, 2, 3, 4]
 >>> l1 = [1, 2, 3, 4]
 >>> l2 = l0

I want it to have the following behaviour:

 >>> check(l1, l0)
False

 >>> check(l2, l0)
True

 >>> check(l1, l2)
False


Any idea how to do this with Python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Print a text at a specific location on the page

2013-12-04 Thread loic . espern
Hi all

This is my first post on this list :-)

I have a web-application (developped using a python framework). In this 
web-app, I would like to print certificates for some courses.

The principle :
The course teacher has a "default" certificates, with placeholders for the 
name, and the certification name. ("Congratulations ___ you successfully 
passed the __ course")
He puts the certificate in his printer, and my app prints the name, and the 
certification on a specific location, to fill the placeholders.

I looked at ReportLab, and Pod. They seems powerfull to build complex reports, 
but I wonder if it exists a simpler solution just to print a text at a specific 
place on the page...

Thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Compiling python2.5 on IBM AIX

2007-07-16 Thread bravo . loic
hi,

I'm trying to make a local install of python 2.5 on AIX and I'm
getting some trouble with _curses.

Here is how I tried to compile it :


export BASE=/usr/local/python251

cd Python.2.5.1
./configure --prefix=${BASE}/\
LDFLAGS="-L\${BASE}/lib/"\
PPFLAGS="-I\${BASE}/include/"\

make
make test
make altinstall

and the compilation stop with the following pb :

ld: 0711-317 ERROR: Undefined symbol: _unctrl
ld: 0711-317 ERROR: Undefined symbol: .__fixsfsi
ld: 0711-317 ERROR: Undefined symbol: .setsyx
ld: 0711-317 ERROR: Undefined symbol: ._setqiflush
ld: 0711-317 ERROR: Undefined symbol: .initscr32
ld: 0711-317 ERROR: Undefined symbol: wacs_map
ld: 0711-317 ERROR: Undefined symbol: ._getsyx
ld: 0711-317 ERROR: Undefined symbol: .getattrs
ld: 0711-317 ERROR: Undefined symbol: .w32attrset
ld: 0711-317 ERROR: Undefined symbol: .w32insch
ld: 0711-317 ERROR: Undefined symbol: .p32echochar
ld: 0711-317 ERROR: Undefined symbol: .w32echochar
ld: 0711-317 ERROR: Undefined symbol: .box32
ld: 0711-317 ERROR: Undefined symbol: .w32addch
ld: 0711-317 ERROR: Undefined symbol: .w32attroff
ld: 0711-317 ERROR: Undefined symbol: .w32attron
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
*** WARNING: renaming "_curses" since importing it failed: No such
file or directory
error: No such file or directory
make: 1254-004 The error code from the last command is 1.


Stop.

I've compiled ncurses-5.6 in ${BASE}/lib but this haven't solved the
pb.

Any clue ?

Best regards

--

BL

-- 
http://mail.python.org/mailman/listinfo/python-list


Bug with make altinstall ?

2007-07-16 Thread bravo . loic
I've made a local installation of Python2.5 with the following
instruction :

export BASE=/usr/local/python251

cd Python.2.5.1
./configure --prefix=${BASE}/\
LDFLAGS="-L\${BASE}/lib/"\
PPFLAGS="-I\${BASE}/include/"\

make
make test
make altinstall

It works fine on Linux except this little inconsistency :
-
% /usr/local/python251/bin/idle
zsh: ./idle: bad interpreter: /usr/local/python25/bin/python: aucun
fich ier ou répertoire de ce type
zsh: exit 127   ./idle


Indeed, the make altinstall instruction does not make the link from
python2.5 to python, but idle contains the following code :
-
%  more idle
#!/usr/local/python251/bin/python

from idlelib.PyShell import main
if __name__ == '__main__':
main()
-

Shouldn't the shebang be replaced with #!/usr/local/python251/bin/
python2.5 ?
This pb doesn't appear with pydoc and pycolor, so it  smells like a
bug to me

Bests,

--
BL

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling python2.5 on IBM AIX

2007-07-17 Thread bravo . loic
> I haven't compiled it myself, but I'm told that the installation I
> work with was compiled with:
>
> export PATH=$PATH:/usr/vacpp/bin:/usr/vacpp/lib
> ./configure --with-gcc="xlc_r -q64" --with-cxx="xlC_r -q64" --disable-
> ipv6 AR="ar -X64"
> make
> make install

I've tried with the followong configuration :
--
export PATH=$PATH:/usr/vacpp/bin:/usr/vacpp/lib
./configure --prefix=${BASE} --with-gcc="xlc_r -q64" --with-cxx="xlC_r
-q64" --disable-ipv6 AR="ar -X64" LDFLAGS="-L\${BASE}/lib/" PPFLAGS="-I
\${BASE}/include/"

make
-

but it doesn't compile either :

make
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Modules/python.o ./Modules/python.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Modules/_typesmodule.o Modules/_typesmodule.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/acceler.o Parser/acceler.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/grammar1.o Parser/grammar1.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/listnode.o Parser/listnode.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/node.o Parser/node.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/parser.o Parser/parser.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/parsetok.o Parser/parsetok.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/bitset.o Parser/bitset.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/metagrammar.o Parser/metagrammar.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/firstsets.o Parser/firstsets.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/grammar.o Parser/grammar.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/pgen.o Parser/pgen.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/myreadline.o Parser/myreadline.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Parser/tokenizer.o Parser/tokenizer.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Objects/abstract.o Objects/abstract.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Objects/boolobject.o Objects/boolobject.c
xlc_r -q64 -c  -DNDEBUG -O  -I. -I./Include   -DPy_BUILD_CORE -
o Objects/bufferobject.o Objects/bufferobject.c
"Objects/bufferobject.c", line 22.15: 1506-275 (S) Unexpected text ','
encountered.
make: 1254-004 The error code from the last command is 1.

any idea ?

thanks

--
BL

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to implement function like this?

2007-10-23 Thread Loic Mahe
even shorter:

def funcA(tarray):
 s = min(len(tarray), 3)
 return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to implement function like this?

2007-10-23 Thread Loic Mahe
Marc 'BlackJack' Rintsch a écrit :
> On Tue, 23 Oct 2007 11:48:08 +0200, Loic Mahe wrote:
> 
>> even shorter:
>>
>> def funcA(tarray):
>>  s = min(len(tarray), 3)
>>  return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]]
> 
> Why the list comprehension!?
> 
> Ciao,
>   Marc 'Blackjack' Rintsch

sorry I just read too fast
and thought he worked with lists ...
anyway 'e for e in' and so list comprehension was useless here

def funcA(tarray):
  s = min(len(tarray), 3)
  return (2, 3, 4,)[0:s] + funcB(3-s)[0:3-s]

this is ok if funcB(...) returns a tuple ...
if it returns a list just add: tuple(funcB(...))

note: list comprehension transforms a tuple into a list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Loic Mahe
Frank Samuelson a écrit :
> foo = function(x,y) x+y*2   # Example S language code
> bar = foo
> bar(3,4)
> m = lapply( s, foo )
> bb = lapply(s, function(t) t[3]*4 )

Here you want all functions to be lambda functions:

you can get something very close to what you want,
just like this:

foo = lambda x,y: x+y*2
bar = foo
bar(3,4)

you would only need to extend existing lambda:
  * support all python keywords/expressions in lambda
  * multiline lambda
  * multi return value lambda
  * and possibility to map 'function' name to be equivalent to 'lambda'


Loic
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some "pythonic" suggestions for Python

2007-11-12 Thread Loic Mahe
Chris M write :
> Multi-return value lambda? Just so you know, there is no concept of
> returning more than one value from a function.

I wrote:
 > * multi return value lambda

I meant: multiple return statement, not return multiple values

pseudo code here:

lambda x: if A return B, if C return D, if E return F ...

it could be nice if ou could write normal functions ... as lambda ones
and not being limited to a subset of the kewords ...

at least it would fit Frank Samuleson needs/wishes better...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Equivalent of TCL's "subst" ?

2007-11-14 Thread Loic Mahe
gamename a écrit :
> Hi,
> 
> In TCL, you can do things like:
> set foobar "HI!"
> set x foo
> set y bar
> subst $$x$y
> HI!
> 
> Is there a way to do this type of evaluation in python?
> 
> TIA,
> -T
> 

you can also try using eval:

 >>> foobar = "HI!"
 >>> x = 'foo'
 >>> y = 'bar'
 >>> print eval(x+y)
HI!



Loic
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert some Python code to C++

2007-11-14 Thread Loic Mahe
[EMAIL PROTECTED] a écrit :
> For those that understand algorithms and can talk Python, I want to
> convert the Python code in the section "Reading out all LCSs" into C++
> code but I don't understand some of the syntax.  Can anyone give me a
> hand?
> 
> def backTrackAll(C, X, Y, i, j):
> if i == 0 or j == 0:
> return set([""])
> elif X[i-1] == Y[j-1]:
> return set([Z + X[i-1] for Z in backTrackAll(C, X, Y, i-1,
> j-1)])
> else:
> R = set()
> if C[i][j-1] >= C[i-1][j]:
> R.update(backTrackAll(C, X, Y, i, j-1))
> if C[i-1][j] >= C[i][j-1]:
> R.update(backTrackAll(C, X, Y, i-1, j))
> return R
> 
> Thanks!
> 

just have a look at this tutorial: and look for Lists and Sets
http://docs.python.org/tut/tut.html

and look in the reference index for set() and list() in
http://docs.python.org/lib/genindex.html


or just pick the algo in another language in the url you give

or tell us precisely what part of the python algo you do not understant!
-- 
http://mail.python.org/mailman/listinfo/python-list