Re: Doubt C and Python

2005-08-25 Thread Uwe Schmitt
> > On Tue, 23 Aug 2005 06:15:03 +0100, praba kar wrote: > > > Dear All, > >I want to know the link between c and python. > >Some people with C background use Python instead > > of programming in C.why? > > > > > > > > regards > > Prabahar > > > > > > > > >

Integrate C source in a Python project

2005-08-26 Thread Uwe Schmitt
> > Hi all. > I was wondering if it ispossible to integrate C source in a > python project. Yes it is. Which tool you use depends on your requirements: http://starship.python.net/crew/theller/ctypes/ ctypes allowes loading dlls/shared libs and calling functions in that lib. www.swig.org is a

py2exe can't compile this program

2005-08-30 Thread Uwe Schmitt
> > Hi all. I tried to compile this little source with py2exe: > http://pastebin.com/350143 > ...but once I execute the program I encount this error: > > C:\src\dist>sniffer.exe > Traceback (most recent call last): > File "sniffer.py", line 24, in ? > File "sniffer.py", line 18, in get_int >

strange behaviour of str()

2005-08-31 Thread Uwe Schmitt
> > Hello, > > I'm wondering about the following behaviour of str() with strings > containing non-ASCII characters: > > str(u'foo') returns 'foo' as expected. > > str('lää') returns 'lää' as expected. > > str(u'lää') raises UnicodeEncodeError > This does not work, because you need an encode

printing raw postscript data on windows

2006-07-14 Thread Uwe Schmitt
Hi, I am trying to print raw postscript data on windows. win32print should do the work like this: h=win32print.OpenPrinter(name) win32print.StartDocPrinter(h, 1, ("", "", "RAW")) win32print.WritePrinter(h, file("p.ps").read()) win32print.EndDocPrinter(h) win32print.ClosePrinter(h)

regular expressions ... slow

2008-11-17 Thread Uwe Schmitt
Hi, Is anobody aware of this post: http://swtch.com/~rsc/regexp/regexp1.html ? Are there any plans to speed up Pythons regular expression module ? Or is the example in this artricle too far from reality ??? Greetings, Uwe -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with exec and locals()

2008-07-10 Thread Uwe Schmitt
On 1 Jul., 15:15, Mel <[EMAIL PROTECTED]> wrote: > rocksportrockerwrote: > > > Hi, > > > the following code does not work until I ommit the "a=0" statement. > > >    def test(): > >        exec "a=3" in locals() > >        print a > >        a=0 > > >     test() > > > print raises: > >      Unbound

Re: How to create a timer/scheduler in Python?

2008-07-12 Thread Uwe Schmitt
On 12 Jul., 11:30, John Dann <[EMAIL PROTECTED]> wrote: > I need what I'd call (in .Net) a timer, ie I need to run a function eg > every 2 seconds - it doesn't need to be millisec accurate but it would > be nice if it wasn't eg every 4 seconds or something. > > Rather surprisingly, Core Python (Chu

Re: sending input to an embedded application

2008-07-12 Thread Uwe Schmitt
On 12 Jul., 09:08, George Oliver <[EMAIL PROTECTED]> wrote: > hi, I'm a novice programmer trying to better define a hobby project > I'm thinking of. > > What I would like to do is take a program and embed it or put it > within a Python-run GUI, using the GUI just to capture and send input > to the

Re: wxPython Tab

2008-07-13 Thread Uwe Schmitt
On Jul 13, 6:20 pm, Sparky <[EMAIL PROTECTED]> wrote: > Is there a way to get wxPython to change the visible tab in a notebook > (like I have tab 1 open but the computer will automatically change to > tab 2)? > > Thanks, > Sam look at http://docs.wxwidgets.org/stable/wx_wxnotebook.html#wxnotebooks

Re: Python embedding question.

2008-07-15 Thread Uwe Schmitt
On 15 Jul., 12:14, Thomas Troeger <[EMAIL PROTECTED]> wrote: > Kay Schluehr wrote: > > On 15 Jul., 11:51, Thomas Troeger <[EMAIL PROTECTED]> > > wrote: > > >> I've really looked at a lot of places but haven't found a suitable > >> solutions yet, so I'm asking here in hope that someone has experienc

Re: storing references instead of copies in a dictionary

2008-07-17 Thread Uwe Schmitt
On 17 Jul., 13:45, mk <[EMAIL PROTECTED]> wrote: > Hello everyone, > > I'm storing functions in a dictionary (this is basically for cooking up > my own fancy schmancy callback scheme, mainly for learning purpose): > >  >>> def f2(arg): > ...     return "f2 " + arg > ... >  >>> >  >>> def f1(arg): >

Re: singletons

2008-07-17 Thread Uwe Schmitt
On 17 Jul., 00:20, Craig Allen <[EMAIL PROTECTED]> wrote: > > I have several classes in our system which need to act like > singletons, they are libraries of data classifications, and other such > libraries of configurations for the system which need to be global. > ... > > Is it pythonic? My appr

Re: How to process a very large (4Gb) tarfile from python?

2008-07-17 Thread Uwe Schmitt
On 17 Jul., 10:01, Terry Carroll <[EMAIL PROTECTED]> wrote: > I am trying to do something with a very large tarfile from within > Python, and am running into memory constraints.  The tarfile in > question is a 4-gigabyte datafile from > freedb.org,http://ftp.freedb.org/pub/freedb/, and has about 2

Re: How to process a very large (4Gb) tarfile from python?

2008-07-17 Thread Uwe Schmitt
On 17 Jul., 17:55, Terry Carroll <[EMAIL PROTECTED]> wrote: > On Thu, 17 Jul 2008 06:14:45 -0700 (PDT), Uwe Schmitt > > <[EMAIL PROTECTED]> wrote: > >I had a look at tarfile.py in my current Python 2.5 installations > >lib path. The iterator caches TarInfo objects

Re: How to process a very large (4Gb) tarfile from python?

2008-07-17 Thread Uwe Schmitt
On 17 Jul., 22:21, Lars Gustäbel <[EMAIL PROTECTED]> wrote: > > > Maybe we should post this issue to python-dev mailing list. > > Parsing large tar-files is not uncommon. > > This issue is known and was fixed for Python 3.0, > seehttp://bugs.python.org/issue2058. The proposed patch does not avoid

Re: How to process a very large (4Gb) tarfile from python?

2008-07-18 Thread Uwe Schmitt
Due to the discussion above I wrote a python module for scanning of large tarfiles. You can get it from http://www.procoders.net/wp-content/tarfile_scanner.zip Greetings, Uwe -- http://mail.python.org/mailman/listinfo/python-list

Re: fromfile error on windows, not mac

2008-07-22 Thread Uwe Schmitt
jadamwil schrieb: > Hello, > I am using the numpy fromfile function to read binary data from a file > on disk. The problem is that the program runs fine on a Mac, but gives > an error or warning on windows when trying to read the data. I use it > like this: > > Signal = zeros((N, 16), dtype=float

Re: Python embedding question (2).

2008-07-22 Thread Uwe Schmitt
On 22 Jul., 14:07, Thomas Troeger <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > On Jul 17, 9:57 am, Thomas Troeger <[EMAIL PROTECTED]> > > wrote: > >>> I'd say that PyGame could be a solution. > >>> Or otherwise you could do your own audio/graphics programming (you don't > >>> tell us which OS

Re: Using variables across modules

2008-07-23 Thread Uwe Schmitt
Aaron Scott schrieb: > I'm having some trouble understanding how Python handles variables > across multiple modules. I've dug through the documentation, but I > still find myself at a loss. > > When you import a module, are you creating an instance of the > variables within? For instance, if I ha

Re: Interconvert a ctypes.Structure to/from a binary string?

2008-08-02 Thread Uwe Schmitt
On 2 Aug., 08:35, Andrew Lentvorski <[EMAIL PROTECTED]> wrote: > Basically, I'd like to use the ctypes module as a much more descriptive > "struct" module. > > Is there a way to take a ctypes.Structure-based class and convert it > to/from a binary string? > > Thanks, > -a My first idea was : f

Re: Wrapping C with Python

2008-08-05 Thread Uwe Schmitt
On 4 Aug., 15:14, brad <[EMAIL PROTECTED]> wrote: > RPM1 wrote: > > ... > > > Basically you just compile your C code as a regular C code dll.  ctypes > > then allows you to access the functions in the dll very easily. > > Does that work with C++ code too or just C? It works if the interface of the

Re: Python Substitute for PHP GD, Resizing an image on the client side

2008-08-18 Thread Uwe Schmitt
On 19 Aug., 08:32, brahmaforces <[EMAIL PROTECTED]> wrote: > Hi Folks, > > I am using cherrypy and python. I am trying to get a user profile > image to resize on the client side before uploading to the server. PHP > has a gd library that does it it seems. php works on the client side ?? are you su

Re: Negative integers

2008-08-21 Thread Uwe Schmitt
On 20 Aug., 23:38, johnewing <[EMAIL PROTECTED]> wrote: > I am trying to figure out how to test if two numbers are of the same > sign (both positive or both negative).  I have tried > > abs(x) / x == abs(y) / y > > but that fails when one of the numbers is 0.  I'm sure that there is > an easy way t

Re: What's your first choice if you have to write a C module for python?

2008-08-26 Thread Uwe Schmitt
On 26 Aug., 14:19, 一首诗 <[EMAIL PROTECTED]> wrote: > Hi all, > > I read this interesting post comparing Boost.Python with Pyd: > > http://pyd.dsource.org/vsboost.html > > What's your opinion about it? > > What's your first choice when you have write a C/C++ module for Python? I prefer ctypes or f2p

Re: ctypes: loading .so file on Linux

2008-08-27 Thread Uwe Schmitt
On 27 Aug., 07:03, Paddy <[EMAIL PROTECTED]> wrote: > On Aug 23, 2:33 pm, Paddy <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > I am am falling at the first hurdle when trying to access a library > > using ctypes. > > > I have a file libucdb.so which the file command says is shared object, > > but I c

Re: How to write verbose scripts

2008-09-03 Thread Uwe Schmitt
On 2 Sep., 18:55, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I find myself writing command line tools in Python where I wish to > include "verbose" output to stdout. > > I start with a helper function: > > def print_(obj, level=0): >     if _verbosity >= level: >         print

Re: installing matplotlib with numpy and scipy for Python in Cygwin

2008-09-03 Thread Uwe Schmitt
On 3 Sep., 11:42, "chapagainanish" <[EMAIL PROTECTED]> wrote: > Hi!! > I'm having installation problem for installing numpy and scipy in > Cygwin for Python, and am obstruct in madway for project, i followed > scipy.org guidelines but there's few error thrown as >         failed..with exit status 1

Re: F2PY changing integers to arrays???

2008-09-09 Thread Uwe Schmitt
On 9 Sep., 18:41, john <[EMAIL PROTECTED]> wrote: > I have a simple module which performs basic operations on plot3d files > (below).  I wrapped like: > > f2py --fcompiler=gfortran -m plot3d -c prec.f90 plot3d.f90 > > That seems to work fine, but i get some unexpected results... > > >>> from plot3d

Re: Extracing data from webpage

2008-09-11 Thread Uwe Schmitt
On 11 Sep., 11:55, srinivasan srinivas <[EMAIL PROTECTED]> wrote: > Hi, > I am trying to download data from a webpage. I use mechanize python module. > Could someone tell me how to set/pass an agent like Mozilla or IE that we do > in perl's WWW::Mechanize?? > > Thanks, > Srini > http://wwwsearch.

Re: Use Python to solve equations?

2008-09-11 Thread Uwe Schmitt
On 11 Sep., 09:09, Kelie <[EMAIL PROTECTED]> wrote: > Hello group, > > Is there any packages in Python that will help me solve functions > similar to this: > > x = a*(1+bx)**2.5-c where a, b, c is known and the task to solve x? > > Thank you, > > Kelie look at www.sagemath.com . it is great. gree

Re: I want to use a C++ library from Python

2008-09-11 Thread Uwe Schmitt
On 10 Sep., 09:57, Anders Eriksson <[EMAIL PROTECTED]> wrote: > Hello, > > I have a C++ library compiled as Windows DLL's. It consists of 32 .h and 1 > .lib and 1 .dll files. I don't have the source code. > > How can I create a Python module from these files? Do you need the full library including

Automated Build System ?

2008-09-18 Thread Uwe Schmitt
Hi, I'm working on a python Package which includes some extension modules and unit tests. I want to automate some tasks like "build extsion module, then copy xxx.pyd to folder yyy and run all unit tests from folder ". I used google but found no hints to existing solutions. Can anybody help me

lxml question

2008-09-26 Thread Uwe Schmitt
Hi, I have to parse some text which pretends to be XML. lxml does not want to parse it, because it lacks a root element. I think that this situation is not unusual, so: is there a way to force lxml to parse it ? My work around is wrapping the text with "..." before feeding lxmls parser. Greeting