Python-list digest, Vol 1 #4292 - 14 msgs

Marco Soeima msoeima at netcabo.pt
Wed Dec 20 15:11:29 EST 2000


* python-list-request at python.org (python-list-request at python.org) [20/12/00 20:11]:

Content-Description: Masthead (Python-list digest, Vol 1 #4292)
> Send Python-list mailing list submissions to
> 	python-list at python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
> 	python-list-request at python.org
> 
> You can reach the person managing the list at
> 	python-list-admin at python.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
> 

Content-Description: Today's Topics (14 msgs)
> Today's Topics:
> 
>    1. ANNOUNCE: soundex.py (Skip Montanaro)
>    2. DCOracle-1.3.2 makefile problem .er. opportunity? (tim at 2wave.net)
>    3. Re: Problems compiling on Sunos5 (Andreas Jung)
>    4. RE: while true: !!! (Tim Peters)
>    5. Re: dynamic function call (Steve Holden)
>    6. Python in embedded systems? (Grant Edwards)
>    7. object deletion order question (howard at eegsoftware.com)
>    8. Running pdflatex from Python (Brian Elmegaard)
>    9. Re: Catching Database Exceptions (Sybase) (Thomas Gagne)
>   10. Import problem (David Allen)
>   11. Re: Q: dynamic function call (Robert Roy)
>   12. Threads - Newbie Questions (David Lees)
>   13. Re: Running pdflatex from Python (Fredrik Lundh)
>   14. Re: object deletion order question (Fredrik Lundh)

> From: Skip Montanaro <skip at mojam.com>
> Reply-To: skip at mojam.com (Skip Montanaro)
> To: python-list at python.org, python-announce-list at python.org
> Subject: ANNOUNCE: soundex.py
> Date: Wed, 20 Dec 2000 12:44:58 -0600 (CST)
> Message-ID: <14912.65066.958523.18862 at beluga.mojam.com>
> 
> Python 2.0 no longer ships with a soundex module.  Sometime ago, Tim Peters
> and Fred Drake each cooked up replacements written in Python.  I merged them
> together into a single module which is available from 
> 
>     http://musi-cal.mojam.com/~skip/python/
> 
> If you have any questions or comments on the module, please send them my
> way.
> 
> -- 
> Skip Montanaro (skip at mojam.com)
> Support the Mojam.com Affiliates Program: http://www.mojam.com/affl/
> (847)971-7098
> 

> From: tim at 2wave.net
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: DCOracle-1.3.2 makefile problem .er. opportunity?
> Date: Wed, 20 Dec 2000 18:22:14 GMT
> Message-ID: <91qtcd$dic$1 at nnrp1.deja.com>
> Organization: Deja.com
> 
> Hi
> 
> I'm no makefile expert, I'm afraid, and am trying to build DCOracle-
> 1.3.2 in Linux 7 (for Oracle 8.1.6), and not succeeding :-(. I've
> followed the makefile instructions provided, and get to the problem
> below. I haven't found any references to others having this problem on
> comp.lang.python, so I wonder if any of you who have been down this
> path before recognise the error - and point me in directions which
> might overcome it!
> 
> ------------------------------
> root> makefile -f Makefile.pre.in boot
> rm -f *.o *~
> rm -f *.a tags TAGS config.c Makefile.pre python sedscript
> rm -f *.so *.sl so_locations
> VERSION=`python -c "import sys; print sys.version[:3]"`;
> installdir=`python -c "import sys; print sys.prefix"`;
> exec_installdir=`python -c "import sys; print sys.exec_prefix"`;
> make -f ./Makefile.pre.in VPATH=. srcdir=.
>      VERSION=$VERSION
>      installdir=$installdir
>      exec_installdir=$exec_installdir
>      Makefile
> make[1]: Entering directory `/home/tim/rpms/DCOracle-1.3.2/src'
> make[1]: *** No rule to make target'/usr/lib/python1.5/config/Makefile'
> needed by 'sedscript'. Stop.
> make[1]: Leaving directory `/home/tim/rpms/DCOracle-1.3.2/src'
> 
> ------------------------------------------------
> 
> Thanks
> 
> Tim
> 
> 
> Sent via Deja.com
> http://www.deja.com/

> From: Andreas Jung <andreas at andreas-jung.com>
> Reply-To: Andreas Jung <andreas at andreas-jung.com>
> To: Venkatesh Prasad Ranganath <rvprasad at cis.ksu.edu>
> Cc: python-list at python.org
> Subject: Re: Problems compiling on Sunos5
> Date: Wed, 20 Dec 2000 20:02:34 +0100
> Message-ID: <20001220200234.A5081 at yetix.sz-sb.de>
> User-Agent: Mutt/1.3.12i
> 
> On Wed, Dec 20, 2000 at 11:34:15AM -0600, Venkatesh Prasad Ranganath wrote:
> > Hi,
> > 
> > I am trying to compile Python 2.0 on Sunos 5.  I am able to compile but many
> > functions are not being supported.  When I execute configure, the list of
> > functions checked by configure are reported as not supported but all those
> > functions are available.  For example, strftime() is reported as not available.
> > 
> > Is this a problem with the configure script or something I have to specify when
> > configuring.  My configure command was as follows
> > 
> > configure --with-threads=/usr/lib --with-cycle-gc --without-libdb
> 
> Usually you should not care about the functions available or not. When
> "make" works correctly  and you have a running Python interpreter
> after the termination of "make" ...be happy...and "make install".
> I have never seen any real problems with the installation of Python
> under Solaris.
> 
> Andreas
>  
> 

> From: "Tim Peters" <tim.one at home.com>
> To: <python-list at python.org>
> Subject: RE: while true: !!!
> Date: Wed, 20 Dec 2000 14:11:55 -0500
> Message-ID: <LNBBLJKPBEHFEDALKOLCCEMMIEAA.tim.one at home.com>
> 
> [gbreed at cix.compulink.co.uk]
> > ...
> > If you want to empty a sequence, but preserve the type, try
> > filter(lambda x:0, asequence).
> 
> Picking a nit:  that returns an empty list, regardless of type(asequence).
> To get an empty sequence of the same type, do
> 
>     asequence[:0]
> 
> or even
> 
>     asequence * 0
> 
> there's-only-one-way-to-do-it-ly y'rs  - tim
> 
> 

> From: "Steve Holden" <sholden at holdenweb.com>
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Re: dynamic function call
> Date: Wed, 20 Dec 2000 14:10:39 -0500
> Message-ID: <Fw706.1805$WA2.28069 at e420r-atl2.usenetserver.com>
> Organization: WebUseNet Corp  http://www.usenetserver.com - Home of the fastest NNTP servers on the Net.
> 
> Hwanjo Yu <hwanjoyu at uiuc.edu> wrote in message
> news:Ko606.141$G66.2664 at vixen.cso.uiuc.edu...
> > Hi,
> >
> > Is there any way to bind a function name at runtime ?
> > For instance, we don't know the function name to call, but we know the
> > function name is saved in a variable, "fname".
> > How to call it in this case ?
> > Thanks in advance.
> >
> You just use the variable fname instead of the function name!  For example:
> 
> >>> def myfun(x):
> ...  print "x is", x
> ...
> >>> yourfun = myfun
> >>> yourfun('This is cool')
> x is This is cool
> 
> The "def" statement simply binds the function name to its compiled code
> body.  If you "assign" the functin to another variable, the same call
> mechanism can be used on that binding too.
> 
> regards
>  Steve
> 
> 
> 
> 

> From: grante at visi.com (Grant Edwards)
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Python in embedded systems?
> Date: Wed, 20 Dec 2000 19:12:58 GMT
> Message-ID: <_w706.11237$TU6.1069571 at ptah.visi.com>
> User-Agent: slrn/0.9.6.2 (Linux)
> 
> Has anybody heard of a Python interpreter being used in an
> embedded system to provide user scripting capabilities?
> 
> At some point in the future, I might be looking for a small,
> safe, interpreted langauge to put into an embedded system. It
> needs to be something easy for a non EE/CS to grasp.
> Resource-wise, Forth would be a good choice except I think it's
> a difficult first language for non programmers.
> 
> I'd love to use Python, but I don't know if it will fit into
> the embedded system environment -- I probably can't allocate
> more than about 1MB of memory for the scripting feature.
> 
> I've seen some nice compact Scheme implimentations, but that
> too is probably not a good choice for something that will be
> used by somebody with no CS background.
> 
> I'm really hoping to avoid using some sort of BASIC, the Web
> server I'm running as a JavaScript subset interpreter, so maybe
> I can figure out how to use that for non-web stuff.
> 
> -- 
> Grant Edwards                   grante             Yow!  Are we on STRIKE yet?
>                                   at               
>                                visi.com            

> From: howard at eegsoftware.com
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: object deletion order question
> Date: Wed, 20 Dec 2000 19:13:40 GMT
> Message-ID: <3a41016d.3397213 at news-server.socal.rr.com>
> Organization: Road Runner
> 
> While locating a crash in a Windows Python extension I am working on
>     ( a Python wrap around a DirectX game library called CDX)
> I discovered my problem as being the order in which Python objects
> were being deleted.  
> 
> In this case, I had created a Sound object and a series of SoundBuffer
> objects.  INSIDE DirectX, deleting the Sound object implicitly
> releases the SoundBuffer objects.  When Python terminated (or at other
> deletions), it called the delete method of the SoundBuffer  objects
> after deleting the Sound objects, leaving DirectX calling into unknown
> data space (I know..it's a Microsoft tradition).
> 
> I patched around this problem by managing a list of buffer objects
> attached to a Sound object (explicitly specifying such objects) and
> deleting them explicitly.
> 
> However, that led my to question:
>         What ordering does Python use for object deletions? 
> 
> I somehow *assumed* that deletion was the reverse order of creation
> (in a global sense) but clearly my problem was a case of
> first-created, first-deleted.  Of course, I realize (now) I should not
> have *assumed* ANY deletion order.  
> 
> For a "good" fix, I will probably have to build some linkage between
> the two 'independent' classes in the C++ code rather than rely on
> working around the problem in Python code.
> Howard Lightstone
> EEGSoftware
> howard at eegsoftware.com

> From: Brian Elmegaard <be at et.dtu.dk>
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Running pdflatex from Python
> Date: Wed, 20 Dec 2000 21:13:17 +0100
> Message-ID: <3A4112DD.E8B59F3F at et.dtu.dk>
> Organization: Department of Energy Engineering, Technical University of Denmark
> 
> This is posted to comp.lang.python and miktex at dsts.dk
> 
> When I try to run pdflatex (miktex 1.20e) from a Python script with
> popen("pdflatex "+filename) under win98 SE I get a fault in kernel32.dll. 
> 
> This does not happen for pure latex.
> 
> I would like to know if this also happens on other machines or only on mine.
> 
> 
> 
> -- 
> Brian Elmegaard (be at et.dtu.dk) http://www.et.dtu.dk/energysystems 
> Dept. of Energy Engineering, Technical University of Denmark, 
> Phone +45 4525 4169  Fax +45 4593 5215
> :) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug

> From: Thomas Gagne <tgagne at ix.netcom.com>
> Newsgroups: comp.lang.python
> Reply-To: tgagne at eFinNet.com
> To: python-list at python.org
> CC: Dave Cole <djc at object-craft.com.au>
> Subject: Re: Catching Database Exceptions (Sybase)
> Date: Wed, 20 Dec 2000 13:21:28 -0500
> Message-ID: <3A40F8A8.8CD9A563 at ix.netcom.com>
> Organization: eFinNet, Corp.
> 
> Just to keep checking..
> 
> .. I deliberately used a procedure I know didn't exist.  This time it seems as
> though it tried to test the exceptions:
> 
> Traceback (innermost last):
>   File ".//floater.py", line 50, in ?
>     except Warning, env:
> NameError: Warning
> 
> The DB API 2.0 documentation suggested that all database warnings and errors
> should be subclasses of Error and Warning.  Is there something I'm supposed to
> be importing to make this work, or to define these objects?
> 
> --
> .tom
> 
> 
> 

> From: "David Allen" <s2mdalle at titan.vcu.edu>
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Import problem
> Date: Wed, 20 Dec 2000 09:24:23 +0500
> Message-ID: <91r1j3$94h$1 at bob.news.rcn.net>
> Organization: Souls, Unlimited
> User-Agent:  Pan/0.9.1 (Unix)
> 
> I have a module that uses a particular object.  So
> at the top of the file, I import that object.  But
> for some reason, trying to create instances of that
> object always fails with a NameError.  Here's the
> error message:
> 
> Unhandled exception in thread:
> Traceback (innermost last):
>   File "./TkGui.py", line 285, in downloadThread
>     contentKey = self.createContentFrame(request)
>   File "./TkGui.py", line 350, in createContentFrame
>     resp = conn.getResource(resource, self.messageBar)
>   File "./GopherConnection.py", line 79, in getResource
>     resp = GopherResponse()
> NameError: GopherResponse
> 
> Now, to verify that I'm not smoking crack, here
> are the first few lines of GopherConnection.py:
> 
> from GopherResponse      import *
> from GopherResource      import *
> from ResourceInformation import *
> 
> And just in case you think I'm crazy and that
> GopherResponse isn't defined in GopherResponse.py,
> here are the first few lines of that file:
> 
> 
> from GopherObject        import *
> from GopherResource      import *
> from ResourceInformation import *
> 
> class GopherResponse(GopherObject):
> 	... code ...
> 
> So here's the issue - I'm importing a module, but
> things in its namespace aren't coming in.
> 
> As far as I can come up with, the only idea I have
> on why this might be happening is because many of
> the objects use each other, so you get a situation
> where many things import many other things, and you
> may be getting a chicken and egg situation with
> the importer.  But I thought python's importer was
> brigher than that.
> 
> What else can cause this?  How is it that you can
> from modulename import * and then NOT have access
> to the things in that namespace?  Alternatively,
> why does this case not work, when, say, I can use
> module X in module Y and it works fine?  
> 
> Any help on figuring this out would be much appreciated.
> -- 
> David Allen
> http://opop.nols.com/
> ----------------------------------------
> It's 5:50 AM...do you know where your stack pointer is?

> From: Robert Roy <rjroy at NO-SPAM.magma.ca>
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Re: Q: dynamic function call
> Date: Wed, 20 Dec 2000 19:34:30 GMT
> Message-ID: <e1124tgv39ria0drqf3c76c5sr2g2ekg26 at 4ax.com>
> Organization: Excite at Home - The Leader in Broadband http://home.com/faster
> 
> On Wed, 20 Dec 2000 11:56:28 -0600, "Hwanjo Yu" <hwanjoyu at uiuc.edu>
> wrote:
> 
> >Hi,
> >
> >Is there any way to bind a function name at runtime ?
> >For instance, we don't know the function name to call, but we know the
> >function name is saved in a variable, "fname".
> >How to call it in this case ?
> >Thanks in advance.
> >
> Functions are first-class objects in python so it is no big deal to
> assign them to other names and then call them. There are also several
> ways to resolve names at runtime. Here are few quick examples of how
> this could be done.
> 
> Bob
> #########
> # this is the function we will play with
> def cb(name):
>     print 'callback:', name
>     
> # this gets passed the function
> def foo(name, callback):
>     callback(name)
> 
> #this gets passed the function name
> def bar(name, callbackname):
>     globals()[callbackname](name)
> 
> # call foo 
> foo('joe',cb)
> 
> #bind cb to c and call
> c=cb
> c('ralph')
> 
> # use eval to run from function name
> eval('cb')('called from eval')
> 
> # find the function in the locals dictionary
> locals()['cb']('called from locals')
> 
> #find the function in the globals dictionary
> globals()['cb']('called from globals')
> 
> # call bar
> bar('cb called from globals in function', 'cb')
> # note that we bound to c earlier so can call it as well
> bar('c called from globals in function', 'c')
> 
> 
> 

> From: David Lees <DavidL at NONOraqiaMAPS.com>
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Threads - Newbie Questions
> Date: Wed, 20 Dec 2000 14:42:41 -0500
> Message-ID: <3A410BB1.AAB6BE3C at NONOraqiaMAPS.com>
> Organization: HarvardNET
> 
> I am now starting to play with Python threads.  Could someone refer me
> to documentation other than the Library reference for some simple
> examples?
> 
> My specific questions are:
> 1. I am passing the lock as an argument to each thread.  Is this the
> proper way to do it?
> 
> 2. What is the 'kwargs' - optional keyword arguments refered to in the
> Library Reference for start_new_thread?
> 
> Python is definitely cool.  I am starting to get the hang of it, with a
> lot of help from this group.
> 
> Thanks in advance.
> 
> david lees
> 
> Here is my initial code:
> 
> import time, thread
> 
> def TestProcess(x,n,lk):
>     print 'Process %d is starting' % n
>     #time.sleep(1)
>     lk.acquire()
>     print 'Acquired process %d ' % n
>     lk.release()
>     
> lx=thread.allocate_lock()
> lx.acquire()
> 
> for i in range(100):
>     thread.start_new(TestProcess,(0,i,lx))
> 
> time.sleep(3)
> 
> print 'Threads started, about to release lock'
> lx.release()

> From: "Fredrik Lundh" <fredrik at effbot.org>
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Re: Running pdflatex from Python
> Date: Wed, 20 Dec 2000 19:45:20 GMT
> Message-ID: <k%706.701$AH6.70148 at newsc.telia.net>
> Organization: Telia Internet
> 
> Brian Elmegaard wrote:
> > This is posted to comp.lang.python and miktex at dsts.dk
> >
> > When I try to run pdflatex (miktex 1.20e) from a Python script with
> > popen("pdflatex "+filename) under win98 SE I get a fault in kernel32.dll.
> >
> > This does not happen for pure latex.
> 
> perhaps you're using an evil version of Norton Antivirus 2000?
> 
>     http://www.python.org/2.0/
> 
>     "Incompatibility warning: Norton Antivirus 2000 can cause blue
>     screen crashes on Windows 98 when a function in the os.popen*()
>     family is invoked. To prevent this problem, disable Norton Antivirus
>     when using Python. (Confirmed on Windows 98 Second Edition with
>     Norton Antivirus version 6.10.20. The same Norton Antivirus version
>     doesn't have this problem on Windows 2000. Norton Antivirus
>     version 5 on Windows 98SE doesn't have this problem either.)"
> 
> </F>
> 
> 

> From: "Fredrik Lundh" <fredrik at effbot.org>
> Newsgroups: comp.lang.python
> To: python-list at python.org
> Subject: Re: object deletion order question
> Date: Wed, 20 Dec 2000 19:45:19 GMT
> Message-ID: <j%706.700$AH6.70137 at newsc.telia.net>
> Organization: Telia Internet
> 
> howard at eegsoftware.com wrote:
> > However, that led my to question:
> >         What ordering does Python use for object deletions?
> 
> any order it likes.  it may remove an object as soon as
> possible, or never at all.
> 
> > When Python terminated (or at other deletions), it called the
> > delete method of the SoundBuffer  objects after deleting the
> > Sound objects, leaving DirectX calling into unknown data space
> > (I know..it's a Microsoft tradition).
> 
> Direct X uses reference counting just like Python.  if you mess
> up the reference count in Python, it'll crash as well.
> 
> avoiding this is easy, of course.  just make sure you keep the
> reference counts in sync:
> 
> -- use Python wrappers for all reference-counted Direct X
>    objects (e.g. SoundObject, SoundBufferObject)
> 
> -- only access Direct X objects via the Python wrappers
>    (e.g. through an LPDIRECTSOUND member in the Sound
>    object class)
> 
> -- add a PyObject (or better, SoundObject) pointer to the
>    SoundBuffer wrapper class, and make it point to the Sound
>    object when you create the buffer (don't forget to call
>    Py_INCREF on it)
> 
> -- only destroy Direct X objects in the Python wrapper's
>    dealloc method.  in the SoundBuffer wrapper, make sure
>    you decrement the pointer to the Sound object.
> 
> if you do this, the sound object will never be destroyed before
> any of its sound buffers.
> 
> > Of course, I realize (now) I should not have *assumed* ANY
> > deletion order.
> 
> why are you asking when you've already figured it out ;-)
> 
> </F>
> 
> 
> 
> 


Content-Description: Digest Footer
> -- 
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list