I've been learning Ruby and Python concurrently and one of the things I noticed is that these 2 languages seem to treat scope differently. Here's an example of what I mean:
# Python
a = 5
def myfunc():
print a
myfunc() # => Successfully prints 5
# Ruby
a = 5
def myfunc
puts a
end
myfunc # => Throws a "NameError: undefined local variable or method `a' for main:Object"
It appears that def block can access variables declared outside of its immediate scope in Python but not in Ruby. Can someone confirm whether my understanding is correct? And if so, whether one of these ways of thinking of scope is more common in programming?