Отдал бы и ползарплаты! Войти !bnw Сегодня Клубы
## module M1.py
a = 'First Message'
def printer(): print 'Hello from M1:', a

>>> import M1
>>> M1pr = M1.printer
>>> M1pr()

Hello from M1: First Message
>>> # Change printer and message ...
>>> reload(M1)

<module 'M1' from 'M1.py'>
>>> M1pr() # still using old printer

Hello from M1: Second Message # surprise message is changed
>>> M1pr = M1.printer
>>> M1pr()

Hello from second printer: Second Message # as expected
>>> M1.a = 'Third Message'
>>> M1pr()

Hello from second printer: Third Message

The surprise here is that we didn&#39;t expect any changes after the reload, because we are still using the old M1pr(). The reason we get a new message in this case is that the old printer(), which is defined in module M1, implicitly uses M1.a as its message, and M1.a is updated with a reload of M1. To say this in another way, when printer() is defined in module M1, it points to the name a in the M1 dictionary, not to an object in memory. When M1.a is redefined, the old printer function gets the new message. The third test above makes this clear.

http://www2.engr.arizona.edu/~edatools/Python/Reload.htm
// заебался вчера искать, почему один дочерний класс не видит изменений переменной класса родителя, сделанных другим дочерним класом; оказалось, что после релоада они начинают ссылаться на разные классы с одинаковым названием

Рекомендовали: @windowsadmin
#5R5DRF / @kogda / 2892 дня назад

нахуй тебе релоад? ты хоть понимаешь, что ты делаешь?
#5R5DRF/7TK / @anonymous / 2891 день назад

@anonymous >Since the IDE does not reload the modules while running a script each time, if you are changing imported scripts while they are in use, you have to use the Jython’s reload() function
сикули (сорь) // не бей, лучше обоссы

#5R5DRF/A8D / @kogda --> #5R5DRF/7TK / 2891 день назад
@kogda так перезапускай свою программу полностью
#5R5DRF/4NE / @anonymous --> #5R5DRF/A8D / 2891 день назад

@anonymous sikuli.org (сорь) - иде на джаве, которая не перезапускает свой жыдон между запусками скриптов, поэтому либо делать релоады, как они рекомендуют в документации, либо перезапускать всю иде полностью, да // inb4: нахуй тебе эта иде

#5R5DRF/HJX / @kogda --> #5R5DRF/4NE / 2891 день назад
ipv6 ready BnW для ведрофона BnW на Реформале Викивач Котятки

Цоперайт © 2010-2016 @stiletto.