Before I begin, I just wan't to clarify that I am aware that variables obviously make programming easier; this is just a question concerning the nature of how foo() is assigned to var_bar, not why.
For example, say I have a file I wish to read, I would do the following:
>>> r=open('Foobar.py')
>>> r.readline()
'Foo'
>>> r.readline()
'bar'
>>> r.readline()
'\n'
What I used to do, which didn't work, was this:
>>> open('Foobar.py').readline()
'Foo'
>>> open('Foobar.py').readline()
'Foo'
Back then I simply used alt+p to bring up the previous line, I was using IDLE by the way.
Anyway, Similarly, if I use count() in the itertools module, I have to assign the function count to a variable as such:
c = itertools.count(10,1)
>>> for i in range(0,50):
next(c)
10
12
14
...
if I simply did the following:
for i in range(0,50):
next(itertools.count(10,1))
10
10
10
10
...
Why is it then, that when I am (seemingly) using the exact same code, there are different outputs dependent on how that code is expressed (of course though, it's not the same code as something is happening behind the scenes).
I know that if list1=list2, and list2 is modified, than list1 is also modified as their aliased, in that not only is the second referring to the first, but is the first (list2 is list1 returns True), so I would expect the same behavior when the expressions that the variables c and l refer to is used in isolation.
Thanks for any help, it shall be much appreciated as this, as am sure you know, is a massive obstacle for any beginner like myself, so some reading materials in regards to, whatever this is, would be very well utilized.