anomaly

Chris Angelico rosuav at gmail.com
Sun May 10 22:20:26 EDT 2015


On Mon, May 11, 2015 at 12:12 PM, Rustom Mody <rustompmody at gmail.com> wrote:
> On Monday, May 11, 2015 at 7:23:44 AM UTC+5:30, Chris Angelico wrote:
>> And I still don't see how this has anything to do with your confusion
>> about shadowing the name 'int'.
>
> Speaking as a compiler-writer -- everything :-)
>
> In C 'int' is tagged off as different from 'myvar' earlier than say
> 'myvar' is different from 'printf'. The "define" in "#define" even earlier
>
> Python sure has different rules of such 'tagging-off'
> However all programming languages are the same in that you cant 'do semantics'
> until you have finished 'doing syntax'
> And name resolution is in a fuzzy area between the two --
> Ask a theoretician about 'type-checking' and you will  hear: "This is just
> context-sensitive syntax"
> Ask a compiler-writer and you get: "Part of the semantic analysis module"

Right, I understand that 'int' may be a keyword... but that would mean
it's impossible to run the OP's code anyway. If "class int(str): pass"
works, it can't really do anything other than redefine the name "int"
to indicate a null subclass of "str" - or is there something else I've
missed?

ChrisA



More information about the Python-list mailing list