py3k concerns. An example

Ross Ridge rridge at caffeine.csclub.uwaterloo.ca
Mon Apr 21 15:42:41 EDT 2008


Carl Banks <pavlovevide... at gmail.com> wrote:
> If you don't like Python 3, DON'T USE IT.

That's the plan.  

Paul McGuire  <ptmcg at austin.rr.com> wrote:
>I've read this position a number of times in this and related threads,
>and it overlooks one constituency of Python developers - those who
>develop and support modules for use by other Python users.  As the
>supporter of pyparsing, I really can't just "not use" Py3 - ignoring
>Py3 means shutting out/holding back those of my users who do want to
>use it, and pretty much consigning my module to eventual dustbin
>status. 

Eh.  You can ingore it until your users start asking for it.

>Ideally, I can implement some form of cross-compatible code
>so that I need maintain only a single code base, and I have managed to
>do so on a number of fronts (with the help of Robert A. Clark):
>- add support for both __bool__ and __nonzero__ (__nonzero__ calls
>__bool__, so that upgrading to Py3 actually saves a function call)

Doing sometthing like the following would save the function call in
both cases:

	class C(object):
		def __bool__(self):
			return False

		__nonzero__ = __bool__

>- convert isinstance(x,basestring) to isinstance(x,__BASESTRING__) and
>dynamically set __BASESTRING__ to basestring or str
>- similar treatment for sys.maxint/maxsize -> __MAX_INT__

I don't thiink using double underscores here is appropriate.  It suggests
it's part of the language.  Since "basestring" is no longer part of the
language, you could do:

	if "basestring" not in globals():
		basestring = str


>Overall, I think I'm getting off pretty easy, but then pyparsing is a
>small module with very limited use of the standard lib. 

Has the standard library changed that much?  I thought was it mainly the
deletion of old seldom used modules that happens in new releases anyways.

>[...] And as much as we all love Python-the-language, language features
>alone do not help a language and its community of users to grow
>and proliferate.  I think most would agree that it is the cornucopia
>of libraries that really make Python an environment for developing
>production applications.

Definately.  

					Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge at csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  



More information about the Python-list mailing list