Nov. 3rd, 2015

dememax: (коварство)
Сайт мероприятия: http://www.mithedemarseille.com/
Сегодня был второй раз (первый - год назад, по-моему).
Соревнуются команды, состоящие из пяти человек.
Сейчас, вот, сражались Mésopotamiens и Troyens.
Велосипед мой не украли, я спокойно вернулся домой! :-)
И даже ремонтные работы на Ронд пуэн дё Прадо (перекрёсток полностью перекрыт) - мне не помешали! Read more... )
dememax: (Hacker Emblem)
Блин, вляпался таки! Всеми лапками! Помните дети!
Эти значения - вычисляются и потом эти изменяемые значения продолжают передаваться в том же виде в последующих вызовах. Читаем The Python Language Reference / 8. Compound statements / 8.6. Function definitions:

Default parameter values are evaluated from left to right when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that the same “pre-computed” value is used for each call. This is especially important to understand when a default parameter is a mutable object, such as a list or a dictionary: if the function modifies the object (e.g. by appending an item to a list), the default value is in effect modified. This is generally not what was intended. A way around this is to use None as the default, and explicitly test for it in the body of the function, e.g.:

def whats_on_the_telly(penguin=None):
    if penguin is None:
        penguin = []
    penguin.append("property of the zoo")
    return penguin

Profile

dememax

May 2023

S M T W T F S
 123456
78910111213
14151617181920
21 2223 24252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 11th, 2025 09:32 pm
Powered by Dreamwidth Studios