Diez B. Roggisch wrote:
> ctypes is for C. Where it is great to use.
if you need simple wrappers then swig and ctypes are both good since
they can generate it for you
pyrex is also good for wrapping and for writing c extension code
> If you need C++-wrapping, I recommend SIP.
i recommend py++
Russ wrote:
> Is it possible to compile python code into a library (on unix), then
> link to it and call it from C/C++? If so, where can I learn how.
> Thanks.
not really but you may want to look into these:
http://codespeak.net/pypy
http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
http:
Steve Howell wrote:
> --- Georg Brandl <[EMAIL PROTECTED]> wrote:
> > >>
> > >> 15 small programs here:
> > >>
> > >> http://wiki.python.org/moin/SimplePrograms
> > >>
> > >
> > > IMHO a few python goodies are missing there.
> >
> > "It's a Wiki." ;)
> >
>
> Yes indeed. Please feel free to add to
Cameron Laird wrote:
> In article <[EMAIL PROTECTED]>,
> Mathias Panzenboeck <[EMAIL PROTECTED]> wrote:
>def fib():
>generation, parent_rabbits, baby_rabbits = 1, 1, 1
>while True:
>yield generation, baby_rabbits
>generation += 1
>parent_rab
[EMAIL PROTECTED] wrote:
> just wondering are there any snippets out there where you can convert
> a url to an image using python
you mean render a webpage as an image?
does not sound a simple task
maybe you can use oss web rendering engines like gecco, khtml or
webcore
--
http://mail.python.or
Viewer T. wrote:
> Is there a python module anywhere out there that can plot straight
> line graphs, curves (quadratic, etc). If anyone knows where I can
> download one, please let me know.
http://matplotlib.sourceforge.net/
--
http://mail.python.org/mailman/listinfo/python-list
Joe Riopel wrote:
> Using camel case instead of the under_score means less typing. I am lazy.
>
> fooBar
> foo_bar
camel case makes source code extremely ugly in weird disturbing way
YMMV
--
http://mail.python.org/mailman/listinfo/python-list
John DeRosa wrote:
> +1 QOTW
>
> >Hey, did you hear about the object-oriented version of COBOL? They call it
> >"ADD ONE TO COBOL".
actually it is "ADD 1 TO COBOL GIVING COBOL"
http://en.wikipedia.org/wiki/COBOL#Aphorisms_and_humor_about_COBOL
--
http://mail.python.org/mailman/listinfo/python
[EMAIL PROTECTED] wrote:
> as i understand there are two ways to write data to a file: using
> f.write("foo") and print >>f, "foo".
well print will add a '\n' or ' ' if you use ',' after it
> what i want to know is which one is faster (if there is any difference
there shouldn't be any noticable d
> Is there a way I could code the base (core) code in Python and have
> PHP call it? I've really liked using SQLAlchemy and there are other
* quick and dirty solution:
in a shell:
$ python yourscript.py pipe_out
in the php script:
fwrite(pipe_in, input_data);
results = fread(pipe_out, size
> Well, pyogre has few problems with maintenance, and new bindings to
> Ogre engine was
> created using Boost.Python( http://www.ogre3d.org/wiki/index.php/PyOgre )
oh
last time i played with pyogre they made a transition from boost to
swig :)
so they are back again at boost
(the problem with boos
> - A c++ program receives a 2D-matrix from python as input and gives a
> 2D-matrix as output back to python.
pyogre uses swig
ogre is a 3d realtime rendering engine written in c++ so there are
many matrix manipulation there and also pyogre does not modify the
original code
cgkit is a computer g
> It would be much better to be able to specify an additional
> variabel to the Dialect class and change csv.
no it wouldn't
this is a locale specific problem so it should be handled there
--
http://mail.python.org/mailman/listinfo/python-list
> For that purpose I have used the good deque that you can find in
> collections in the standard library. It's very good for queues, and
> it's a bit faster than regular lists for stacks too.
you mean *much* faster (since a list is a reference array so pop(0) is
O(n) operation)
never use a list a
> Well, just as an idea, there is a portable C library for this at
> http://laurikari.net/tre/ released under LGPL. If one is willing to
> give up PCRE extensions for speed, it might be worth the work to
> wrap this library using SWIG.
actually there is a python binding in the tre source with an
[EMAIL PROTECTED] wrote:
> Hi,
> I have a program which literately finds the object that overlapping a
> point. The horizontal and vertical search are called recursively from
> inside each other.
> ...
in case you ever need deeply nested recursion:
one solution is to use the already mentioned sy
Sergey Dorofeev wrote:
> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> (1,)+[1]
> Traceback (most recent call last):
> File "", line 1, in
> TypeError: can only concatenate tupl
azrael wrote:
> Since i'm new on this forum, and first time meeting a python comunity,
> i wanted to ask you for your python editors.
>
> Im looking for some good python editor, with integrated run function,
> without having to set it up manualy like komodo.
> I found the pyscripter, and it has al
> ^was(is)^may one day be, but probably not,^
>
> From the quoted page:
>
> """The project is in an early development phase and as of January 2007,
> no significant progress was being made due to lack of developer time.[5]"""
well actually i managed to boot unununium in qemu so it _is_ an os
but
> Now what would be interesting (and *really* crazy) would be Linux (or
> BSD or whatever) distro written almost entirely *in* Python, with the
> goal of eliminating as much bash/sh as possible.
>
> That would be fun.
actually there was(is) an os whitch is written "almost entirely *in*
Python":
h
Srikanth wrote:
> Yes,
>
> All I need is a good IDE, I can't find something like Eclipse (JDT).
> Eclipse has a Python IDE plug-in but it's not that great. Please
> recommend.
>
> Thanks,
> Srikanth
try pida
http://pida.co.uk/index.php/Main_Page
--
http://mail.python.org/mailman/listinfo/python
Marco wrote:
> The following code is my test program for control mplayer.
> in movies/ there are about 20 movies, the code plays them in circle,
> but mplayer will crash silently after a circle, the "sliently" means I
> can handle popen2 without except, but no movie.
i had some problem with mplay
> based on concepts my boss had. To do this I needed to represent C++
> code structure in Python somehow. I read the docs for Yapps, pyparsing
> and other stuff like those, then I came up with a very simple idea. I
> realized that bracketed code is almost like a Python list, except I
> have to repl
Paul Rubin wrote:
> "George Sakkis" <[EMAIL PROTECTED]> writes:
> > > What does "batteries included" mean to you? To me, it means you don't
> > > have to install add-ons.
> >
> > So let's make a 500MB executable and add Numpy, Zope, Django, PIL,
> > pretty much everything actually. Even better, m
johnny wrote:
> What is **kwargs mean in python? When you put double **, does it mean
> passing by reference?
here's a little example:
>>> def f(a, *args, **kw):
... print 'a:',a
... print 'args:',args
... print 'kw:',kw
...
>>> f(1,2,3,x=4)
a: 1
args: (2, 3)
kw: {'x': 4}
>>> f(a=1,
> Hurray for yaml! A perfect fit for my need! And a swell tool!
> Thanks a lot!
i warn you against yaml
it looks nice, but the underlying format is imho too complex (just
look at their spec.)
you said you don't want python source because that's too complex for
the users.
i must say that yaml i
> The lazy way to do this: have modules that initialize bunches of
> objects, attributes holding the data: the object is somehow the row of
> the "table", attribute names being the column. This is the way I
> proceeded up to now.
> Data input this way are almost "configuration data", with 2 big
> d
[EMAIL PROTECTED] wrote:
> Hi;
> How can I know the Key c and Ctrl on the keyboard are pressed? Or how
> to let the program press the
>
> key Ctrl+c automatically? I just want to use python to develop a
> script program.
> gear
depends on where you got your input from and what do you exactly want
Brian Visel wrote:
> ipython is probably what you're looking for.
or
http://sourceforge.net/projects/pyshell
--
http://mail.python.org/mailman/listinfo/python-list
> I believe the only thing stopping me from doing a deepcopy is the
> function references, but I'm not sure. If so is there any way to
> transform a string into a function reference(w/o eval or exec)?
what's your python version?
for me deepcopy(lambda:1) does not work in py2.4 but it works in py2
> any pointers to a 2.3 module ref?
also look at:
http://rgruet.free.fr/PQR2.3.html#OtherModules
when coding for different python versions i can reccommend this quick
ref:
http://rgruet.free.fr/
(every language feature is colorcoded according to the version when it
was included)
--
http://m
> It seems that the vertices iterator creates new vertex objects every
> time instead of iterating over the existing ones. This essentially
i don't know much about bgl, but this is possible since vertices are
most likely not stored as python objects inside boost
> prevents, among other things, s
> while
> 1:i=__import__;print''.join(i('random').choice(i('string').letters
> +'1234567890')for x in range(8)),;raw_input()
>
while
1:i=__import__;r='random';print''.join(i(r).choice(i('string').letters
+'1234567890')for x in`r`),;raw_input()
even shorter:
range -> `'random'`
:)
--
http://m
> If you really want a hack, here it is:
>
> while 1:print
> ''.join(__import__('random').choice(__import__('string').letters+'1234567890')
> for x in xrange(8)),;n=raw_input()
>
> This is a one-liner (though mail transmission may split it up), no
> import statements. If someone can come up with an
> Is os.urandom cryptographically strong on all platforms?
http://docs.python.org/lib/os-miscfunc.html
"The returned data should be unpredictable enough for cryptographic
applications, though its exact quality depends on the OS
implementation."
--
http://mail.python.org/mailman/listinfo/pyth
> If you don't mind possibly getting a few nonalphanumeric characters:
>
> import os,binascii
> print binascii.b2a_base64(os.urandom(6))
what about
file('/dev/urandom').read(6).encode('base64')
(oneliner and without import as op requested)
--
http://mail.python.org/mailman/listinfo/python-list
> If you don't mind possibly getting a few nonalphanumeric characters:
>
> import os,binascii
> print binascii.b2a_base64(os.urandom(6))
what about
file('/dev/urandom').read(6).encode('base64')
(oneliner and without import sa op requested)
--
http://mail.python.org/mailman/listinfo/python-list
i haven't read your code, but there are many graph implementations in
python.
in case you haven't found these yet:
http://wiki.python.org/moin/PythonGraphApi
if you only want to do some analysis i think you need this one (as it's
pretty complete and simple):
https://networkx.lanl.gov/
i also reco
I've just seen that gopherlib is deprecated in python 2.5
http://docs.python.org/lib/module-gopherlib.html
we still use this protocol (though there are only few working gopher
servers are left on the net)
My friend just wrote a standard compliant gopher server (pygopherd had
some problems oslt) a
python subprocess module docs:
http://docs.python.org/dev/lib/node517.html
--
http://mail.python.org/mailman/listinfo/python-list
ide unification effort:
http://pyxides.stani.be/
(there are some useful links and it's more recent than the python.org
wiki)
--
http://mail.python.org/mailman/listinfo/python-list
pida is a great ide as well:
http://pida.vm.bytemark.co.uk/projects/pida
--
http://mail.python.org/mailman/listinfo/python-list
eg.: .dds (compressed texture file format) widely used in 3d games but
not accessible in pil
--
http://mail.python.org/mailman/listinfo/python-list
use subprocess module
from subprocess import call
call(['cmd', 'arg1', 'arg2'], stdin='...', stdout='...')
eg:
call(['ls', '-l'])
--
http://mail.python.org/mailman/listinfo/python-list
LOL
a .py program is a module, you can import it:
if it is in the sys.path (import modulename).
if it sits in a directory that is in the sys.path and the directory
also has a __init__.py file (import dirname.modulename / from dirname
import modulname).
if there is a modulename.pth file in the sys.
/usr/lib/python2.4/site-packages ?
--
http://mail.python.org/mailman/listinfo/python-list
what about params='some data'.decode('utf8').encode('1250') ?
--
http://mail.python.org/mailman/listinfo/python-list
thank you
(it's so obvious i don't know how i could misunderstand)
--
http://mail.python.org/mailman/listinfo/python-list
the unicodedata manual sais:
"
name( unichr[, default])
Returns the name assigned to the Unicode character unichr as a
string. If no name is defined, default is returned, or, if not given,
ValueError is raised.
"
what is the difference between "no name defined" and "not given"?
eg. '\n' why g
> Basically all I need is vectors and 3x3 matrices.
hmm
is numpy really efficient for 3x3 (or 4x4) matrices and vectors?
IMHO an optimized matrix4x4 class can be much faster (i'm just guessing
here)
eg cgtypes is a simple c++ implementation with boost-python wrapper:
http://cgkit.sourceforge.ne
> Is this possible?
yes: movable python
http://www.voidspace.org.uk/python/movpy/introduction.html
--
http://mail.python.org/mailman/listinfo/python-list
i would love to see a nice, clear syntax instead of
for i in xrange(start, stop, step): ...
because xrange is ugly and iteration over int sequences are important.
we don't need a range() alternative ( [0:10] or [0..10] )
(because no one would ever use range() if there were a nice
integer-for-loop)
> Thanks. I'll write my own split().
do you want to split character by character?
then use
list(u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32')
--
http://mail.python.org/mailman/listinfo/python-list
> There are so many varieties of iterator that it's probably not workable
> to alter the iterator API for all of the them.
i always wondered if it can be implemented:
there are iterators which has length:
>>> i = iter([1,2,3])
>>> len(i)
3
now isn't there a way to make this length inheritible?
e
> There are so many varieties of iterator that it's probably not workable
> to alter the iterator API for all of the them.
i always wondered if it can be implemented:
there are iterators which has length:
>>> i = iter([1,2,3])
>>> len(i)
3
now isn't there a way to make this length inheritible?
e
> But is there a way / a variable that contains the current file in
> memory ?
yes: import __main__
you can do:
import inspect
import __main__
print inspect.getsource(__main__)
or simply:
print open(__file__).read()
nsz
--
http://mail.python.org/mailman/listinfo/python-list
Hello
Thanks for trypython, it's a cool idea
I got TryPythonError after an IdentationError and i could not get rid
of it (other than refreshing the page):
Python 2.4.2 (#3, Dec 16 2005, 23:54:20)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits", or "license" for mor
my two solutions (well I wasn't so clever to encode everything in
strings instead of numbers, but at least it won't give warnings about
non ascii characters):
128:
j,seven_seg=''.join,lambda s:j(j(' |_ |'[i>>3*int(c)&b]for c in s for b
in(4,2,1))+'\n'for i in(306775170,1060861645,524130191))
122:
for i in range(0,10):
if f!=1: break
...
i=0
while i<10 and f==1:
...
i+=1
--
http://mail.python.org/mailman/listinfo/python-list
>> identation
>
>Feh. A red herring. At best, syntactic sugar. At worst, something for
>potential adopters to get hung up about.
i always ident my code, but in python i don't need to bother with the
{} and the ; (which is redundant if i ident anyway) so i like it
because i need to type less, an
it's a very common question here. try to search for an answer
http://groups.google.com/group/comp.lang.python/search?q=python+ide&start=0&scoring=d&;
also see
http://wiki.python.org/moin/PythonEditors
and
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
--
http://mail.python.org/mai
i don't know if they are unique, but my favourite features are:
readable and short code (consistent syntax, few keywords)
iterpreter (very useful for learning)
dir(obj) / vars(obj) (very useful for learning)
identation
dynamic typing
lightweight oo (no public/protected/private)
built-in types (lis
have you tried gtk.MessageDialog ?
http://www.pygtk.org/pygtk2reference/class-gtkmessagedialog.html
--
http://mail.python.org/mailman/listinfo/python-list
charset, modulo, japh = " .JPacehknorstuy", 17, ""
s =
69859911049503515105680510599913390885187193231927247909305172858127641629
for n in xrange(2,):
if s%n==0:
japh += charset[(n - 1) % modulo]
s /= n
if s==1:
break
print japh
--
http://mail.python.org/mailma
> which feature of python do you like most?
i cannot chose one but here is my list:
iterpreter (i can try out things at once)
dir(obj) (using dir() i can learn a new library quickly)
identation (code is readable, no need for {} and ;)
dynamictyping (no type declaration -> less code to write)
light
use pil for image processing in python
(http://www.pythonware.com/products/pil/)
if pil is not installed then i don't think you can process png files
(well at least there is a pure python jpeg decoder:
http://davidf.sjsoft.com/files/pyjpeg/)
--
http://mail.python.org/mailman/listinfo/python-list
python script crashed and you want to debug it?
if no trace back provided with the line number where the exception
raised, then the crash caused by an extension module (most likely
written in C), i don't know howto debug it, but at least you can find
the place where the crash occures by adding lot
python creates bytecode (like java classes)
you cannot translate python directly to c or machine code, but there
are some projects you probably want to look into
Pypy is a python implemetation in python and it can be used to
translate a python scrip to c or llvm code. (large project, work in
pr
if u just want to browse the code online then use this:
http://fisheye.cenqua.com/viewrep/python/python/dist/src
*much* nicer than sourceforge cvs viewer
nsz
--
http://mail.python.org/mailman/listinfo/python-list
IMO sorted dict implementation can be useful, eg. one can get an
interval:
L = D['A' : 'K']
other useful data types:
linkedlist
queue, stack (well deque can do it efficiently in py 2.4)
prioritydict (for graph algorithms)
multimap, multiset (i've never used it but it's in the c++ stl)
mutable stri
nice interface, but with 3d apps i prefer cgkit's approach, which has
vec3, vec4, mat3, mat4 and quat types with lots of useful functions for
3d graphics (like mat4.looakAt(pos, target, up) or mat3.toEulerXYZ())
there are other libs with similar types and functions:
cgkit (http://cgkit.sourceforge
with the current syntax L[i:i+1] returns [L[i]], with nxlist it returns
L[i+1] if i<0.
L=range(10)
L[1:2]==[L[1]]==[1]
L[-2:-1]==[L[-2]]==[8]
L=nxlist(range(10))
L[1:2]==[L[1]]==[1]
L[-2:-1]==[L[-1]]==[9] # not [L[-2]]
IMHO in this case current list slicing is more consistent.
--
http://mail.p
I don't think stdlib offers anything like that
The problem with python is it's white space sensible and html is not.
However there are some nice solutions:
http://www.webwareforpython.org/Papers/Templates/
my favourite is not listed here:
http://karrigell.sourceforge.net/
For web development wi
I have to measure the time of a while loop, but with time.clock i
always get 0.0s, although python manual sais:
"this is the function to use for benchmarking Python or timing
algorithms"
So i tested timer functions capabilities with a short script:
import time
import os
def test_timer_func(func)
you cannot use | with two dict (dict has no .__or__ method)
what are you trying to do?
--
http://mail.python.org/mailman/listinfo/python-list
i found case sensitivity very useful
1. variables can be stored in a dict (think about __dict__, globals())
and dict type should be case sensitive
2. It's necessary when i write short scripts and i use one letter
names. (eg. when i playing with linear algebra i always use a,b,c for
vectors and A
I forgot to mention in my previous post that the best thing in wxPython
is the wxPython demo. It helped me a lot. Browsing through the examples
usually faster than browsing through the api doc.
About XRCed:
I put every static components of the window layout in an xml file with
XRCed
(not static co
it's not quite true since the latest stable release (2.6.0.0)
see the new wx doc (it's generated with epydoc so it's not for C++):
http://www.wxpython.org/docs/api/
i used wxPython with XRCed a few times and i liked the way it works
(worked under linux and win as well for me)
nsz
--
http://mai
have a look at eclipse + pyDev
http://pydev.sourceforge.net/
probably it works as you wish
--
http://mail.python.org/mailman/listinfo/python-list
hello
nice benchmarks
some time ago i've also done some benchmarking
i sorted 10 random int with differrent heap implementations, bisect
module and with list.sort()
I know that heaps are not for sorting, but i tested their performance
with sorting back then.
my results (sorting algo / time):
80 matches
Mail list logo