Importing variables non-deterministic?

Chris Angelico rosuav at gmail.com
Mon Aug 19 17:04:08 CEST 2013


On Mon, Aug 19, 2013 at 3:55 PM, Antoon Pardon
<antoon.pardon at rece.vub.ac.be> wrote:
> Pity enough they chose a
> way that didn't allow programmers to protect names they thought
> important enough to do so too.

As of Python 3, we can redefine something that used to be a keyword,
which is even stronger than a constant.

def print(*args,print=print,**kw):
	print("##",*args,**kw)

What easier way to tag all your print calls? And this is why it helps
to have nothing technically constant. You should be able to do the
same with anything, without having to go and edit someone else's code
to remove the 'const' keyword.

ChrisA



More information about the Python-list mailing list