On 02/23/2013 09:15 AM, Eli Bendersky wrote:
  Hmm, constants such as os.SEEK_* which serve as *inputs* to stdlib rather 
than outputs can actually be a good
candidate for enum without worrying about backwards compatibility.

The reason I make the *input* vs. *output* distinction, is that for stdlib code 
that returns values, the user may rely
on their numeric values and if we switch to enum code will break. However, for 
os.SEEK_* this is not the case. Thee can
be aliases for enums:

class SeekKind(Enum):
   SEEK_SET = 0
   SEEK_CUR = 1
   SEEK_END = 2

SEEK_SET = SeekKind.SEEK_SET
...

lseek() can be changed to call 'int' on its input, and now os.SEEK_* gain 
useful string representations when printed.

Thoughts?

If that particular enum is int based, you don't have to

    a) make the distinction between input/output

    b) call 'int' on its input

and you /still/ get the useful string repr.  ;)

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to