"Martin v. Loewis" wrote: > > > 2) The addition of sys.path[0] is changed to an earlier > > time so it occurs before any imports; so sys.path[0] > > works the same as sys.path[1:]. Currently it is added > > after some imports have occurred. > > I still try to finding the same mental picture for this as you > apparently have. I understand "changed to an earlier time". > > What I don't understand is the effect that you associate with it: > sys.path[0] is a string, sys.path[1:] is a list. In what sense do they > "work the same"? They work the same in that imports are satisfied from the items. sys.path[0] is the first directory string, sys.path[1:] are the remaining strings. Imports are satisfied from sys.path. The timing is currently as follows: 1) Create an initial sys.path but without its first item. 2) Import site, os, sitecustomize, etc. 3) Insert a new item as sys.path[0]. Therefore the new sys.path[0] will not be used to satisfy an import of the os module because it has already been imported. The new timing would be: 1) Create all items in sys.path. 2) Import site, os, sitecustomize, etc. Therefore the new sys.path[0] will be available to satisfy an import of the os module. JimA
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4