News for hackers. Stuff that matters.
Re:Python Is Eating the World by ben509 on Monday August 12, 2019 @12:41PM (#20677108)
It has nothing to do with static vs. dynamic. There's no reason that being an early-binding language that a string has to be iterable itself, and the proposal to change this was only rejected as it broke too many things[1] and couldn't be automatically fixed.

Point in the GP's favor: Fixing it would definitely not be a problem with an early-binding language! In fact, the nigh-impossibility of automated refactoring puts lie to the notion that late-binding languages are more "agile."

It's a design flaw, in the same way Python 2's allowing comparisons between different types was a flaw, e.g. "a" < 3 succeeds. Python 3 now, correctly, throws a TypeError because there's no sensible ordering between the two things.

(While I'm griping: Another design flaw is conflating iterables and iterators, which makes generators almost useless. Say a generator is pass to a function expecting an iterable. If the function uses it twice, the second time it silently returns nothing!)

> This isn't what Python would do, if the variable was undefined Python will throw an error

I think GP must have assigned to the name, in which case Python will create a lexically bound name.

Python's rules for naming can make perfect sense or be quite surprising:

    try:
        x = four()
    except Thing:
        x = 5
    print(x)  # 4 or 5

    for a in [1, 2, 3]:
        pass
    print(a)  # 3 ?!
[1]: https://mail.python.org/pipermail/python-3000/2006-April/000...
Re:Python Is Eating the World by karmakaze on Monday August 12, 2019 @09:36PM (#20682014)
It's only surprising if you expect it to behave like another language. Python variables are function (not block) scoped.
Re:Python Is Eating the World by nabdab on Monday August 12, 2019 @02:16PM (#20678255)
What’s supposed to be the surprising thing? Are you confusing pass and break and expecting it to print 1?
Re:Python Is Eating the World by ben509 on Monday August 12, 2019 @02:26PM (#20678342)
What's surprising, for people used to block semantics, is that `a` survives outside the for loop at all.