[Python-ideas] Policy for altering sys.path

Chris Angelico rosuav at gmail.com
Thu May 7 06:13:05 CEST 2015


On Thu, May 7, 2015 at 2:07 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 7 May 2015 at 01:11, Chris Angelico <rosuav at gmail.com> wrote:
>> On Thu, May 7, 2015 at 12:05 AM, Thomas Güttler
>> <guettliml at thomas-guettler.de> wrote:
>>> We run a custom sub class of list in sys.path. We set it in sitecustomize.py
>>>
>>> This instance get replace by a common list in lines like this:
>>>
>>> sys.path = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path
>>
>> Forgive the obtuse question, but wouldn't an __radd__ method resolve
>> this for you?
>
> If the custom subclass is implemented in Python or otherwise
> implements the C level nb_add slot, yes, if it's implemented in C and
> only provides sq_concat without nb_add, no (courtesy of
> http://bugs.python.org/issue11477, which gets the operand precedence
> dance wrong for sequence types that only implement the sequence
> methods and not the corresponding numeric ones)

Okay, so it mightn't be quite as simple as I thought, but it should
still be in the control of the author of the subclass, right? That
ought to be easier than trying to stop everyone else from mutating
sys.path.

ChrisA


More information about the Python-ideas mailing list