[python-win32] Welcome to the "python-win32" mailing list

Joshua Lim joshua__lim at hotmail.com
Tue Dec 30 17:46:40 CET 2008


Thanks Mike, it didn't occur to me that indentations are required.  :o C:\Python25\pyrad\example>c:\python25\python server.pyTraceback (most recent call last):  File "server.py", line 3, in <module>    from pyrad import dictionary, packet, server  File "C:\Python25\pyrad\example\server.py", line 259, in <module>NameError: name 'self' is not defined Now a new error.  Line 259 refers to "fdi = select.select( self._fdmap.keys(), [], [] )[0]" > Date: Tue, 30 Dec 2008 08:13:38 -0600> From: mike at pythonlibrary.org> To: joshua__lim at hotmail.com; python-win32 at python.org> Subject: Re: [python-win32] Welcome to the "python-win32" mailing list> > Joshua Lim wrote:> > Hi Tim,> >> > Thanks for helping.> >> > I replaced your code from def Run( self ): onwards, but got an error:> >> > C:\Python25\pyrad\example>c:\python25\python server.py> > Traceback (most recent call last):> > File "server.py", line 3, in <module>> > from pyrad import dictionary, packet, server> > File> > "c:\python25\lib\site-packages\pyrad-1.1-py2.5.egg\pyrad\server.py", line> > 259> > fdi = select.select( self._fdmap.keys(), [], [] )[0]> > ^> > IndentationError: expected an indented block> >> > Rgds,> > Joshua> >> > > When copying and pasting code from a mail reader, the indents can get> messed up. Just fix them yourself.> > Mike> > > > > >> > > Date: Mon, 29 Dec 2008 10:47:15 -0800> > > From: timr at probo.com> > > To: python-win32 at python.org> > > Subject: Re: [python-win32] Welcome to the "python-win32" mailing list> > >> > > Tim Roberts wrote:> > > > Well, "select" is not just a drop-in replacement for "poll",> > although it> > > > can serve the same function. Without looking at the rest of the> > source,> > > > you probably want something like this:> > > >> > > > def Run( self ):> > > > self._fdmap = {}> > > > self._PrepareSockets()> > > > while 1:> > > > fdi = select.select( self._fdmap, [], [] )[0]> > > >> > >> > > I just realized this is not correct. _fdmap is a dictionary, and it> > > needs to be a list of FDs. _fdmap probably contains the list of read> > > FDs, write FDs, and other FDs -- exactly the way select.select wants> > > them -- but you'll have to look inside _PrepareSockets to know how to> > > pull ou t the three individual lists.> > >> > > OK, after looking at the source, I think the list of fds is actually the> > > keys of the dictionary, so we need two small changes:> > >> > > def Run( self ):> > > self._fdmap = {}> > > self._PrepareSockets()> > > while 1:> > > fdi = select.select( self._fdmap.keys(), [], [] )[0]> > > if fdi:> > > self._ProcessInput( self._fdmap[fdi[0]] )> > > else:> > > logger.error( "select returned empty." )> > >> > > --> > > Tim Roberts, timr at probo.com> > > Providenza & Boekelheide, Inc.> > >> > > _______________________________________________> > > python-win32 mailing list> > > python-win32 at python.org> > > http://mail.python.org/mailman/listinfo/python-win32> >> >> > ------------------------------------------------------------------------> > Make the most of what you can do on your PC and the Web, just the way> > you want. Windows Live <http://www.get.live.com/wl/all>> 
_________________________________________________________________
NEW! Get Windows Live FREE.
http://www.get.live.com/wl/all
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20081230/5810437a/attachment.htm>


More information about the python-win32 mailing list