Pythonic indenting `with` statement blocks Python doesn't remove the variables once a scope is closed (if there's such a thing as scope in Python, I'm not sure). I mean, once I finish a for variable in range(1, 100), the variable is still there, with a value (99 in this case).

Now I usually indent a whole block when I use the with ... as statement. But should I close the file and end the indentation as soon as I'm done with it? I mean, should I write:

with open('somefile', 'r') as f:
    newvar = f.read()

newvar.replace('a', 'b') # and etc


Instead of:

with open('somefile', 'r') as f:
    newvar = f.read()    
    newvar.replace('a', 'b') # and etc
Yes, ideally, you close the with block as soon as possible, that way the file gets closed quickly - which means you are not (potentially) blocking access to it, having less file handles in use, etc...

Python does have scoping, it just doesn't make new scopes very often - only for functions and classes (and some other smaller cases, like list comprehensions and cousins in 3.x and above).

Unlike in Java, Python doesn't take the approach that every block is a scope, therefore loops, as you say in your question, don't introduce a new one.