This:
import os
class A(object):
os_sep = os.sep
_silentSkipsStart = {u'a dir%s' % os_sep}
def _refreshBasic(self,os_sep=os_sep, skips_start=tuple(
x.replace(os_sep, u'') for x in _silentSkipsStart)):
pass
Fails with:
Traceback (most recent call last):
File "C:/Users/MrD/.PyCharm50/config/scratches/scratch", line 3, in <module>
class A(object):
File "C:/Users/MrD/.PyCharm50/config/scratches/scratch", line 9, in A
x.replace(os_sep, u'') for x in _silentSkipsStart)):
File "C:/Users/MrD/.PyCharm50/config/scratches/scratch", line 9, in <genexpr>
x.replace(os_sep, u'') for x in _silentSkipsStart)):
NameError: global name 'os_sep' is not defined
I guess that bringing os_sep = os.sep
to global scope should cure that (and I probably should from a design point of view) - but here I am not getting python scoping rules: why is os_sep
resolved alright in the other cases and not in genexpr
?