[Tutor] conditionally defining classes

Tony Cappellini tony at tcapp.com
Thu Sep 30 03:47:33 CEST 2004


I've read some posts from Guido (I think) about defining a class within a
class. From what I remember this was frowned upon, but I would expect
arguments on both sides.

Going off in another direction- is it Pythonic to conditionally define a
class as in ..

import sys

OSVer= sys.getwindowsversion()[0]

if OSVer == 5:
   class OSWinXp(object):
	def __init__(self):
		# XP specific code goes here
elif OSVer == 4:
   class OsWin98(object):
	def __init__(self):
		# W98 specifc code goes here




More information about the Tutor mailing list