A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-August/091482.html below:

[Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

[Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to? [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?Michael Foord fuzzyman at voidspace.org.uk
Mon Aug 31 15:27:25 CEST 2009
Nick Coghlan wrote:
> Antoine Pitrou wrote:
>   
>> Brett Cannon <brett <at> python.org> writes:
>>     
>>> Now I can't change
>>> co_filename from Python as it's a read-only attribute and thus can't
>>> match this functionality in importlib w/o creating some custom code to
>>> allow me to specify the co_filename somewhere
>>>       
>> Why can't we simply make co_filename a writable attribute instead of inventing
>> some complicated API?
>>     
>
> I thought of that question as well, but the later exchange between Guido
> and Brett made me realise that a lot more than the top level module code
> object is affected here - the adjustment also needs to be propagated to
> the code objects created by the module for functions and generators and
> so forth.
>
>   

Even if it is not necessary or sufficient it still sounds like a useful 
change. When writing tools that generate modules or manipulate code 
objects these read-only attributes are a great nuisance.

Michael

> Cheers,
> Nick.
>
>   


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


More information about the Python-Dev mailing list

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