On Tuesday, March 1, 2016 at 12:23:02 PM UTC+5:30, Terry Reedy wrote: > On 2/29/2016 7:42 AM, Rustom Mody wrote: > > > Is import needed at all when trying out in Idle? > ... > > So it does appear that > > 1. import not necessary with(in) idle > > 2. However import and f5 (ie is run as main) are different > > > > May some idle experts elaborate on this? Whats the idle idiom of import-ing? > > Rustom, since I know that you are not a rank beginner, I have trouble > understanding what you are asking.
Heh! I know some things; dont know many things > F5 when editing foo.py is equivalent > to running "python -i foo.py" on a command line while 'in' the directory > containing foo.py. In both cases, foo.py is run as a main module, with > __name__ == '__main__'. The difference is that F5 runs foo.py under > IDLE supervision, with results going into and interactive inputs coming > from IDLE shell instead of the console interpreter. > > Imports are used in a module to access objects within the imported module. Let me try to explain again There is import and import. There is the formal meaning of the import keyword in python -- call it import-f There is the informal expectation and need of programmers to 'pull something into python' -- call it import-i That there is some cognitive dissonance between import-f and import-i is seen in the OP's question itself; also Chris' "I dont believe the language should be changed" So the question is around: What is the best practice for doing import-i in python? As the OP finds import-f works once and fails thereafter In idle one can get the desired result of import-i with F5 Is that right? Also in general is there good usecases for import-f at that interpreter prompt in idle? I think not but not sure of it -- https://mail.python.org/mailman/listinfo/python-list