Коллекции Python: пошаговое руководство

Python –∏–º–µ–µ—Ç —á–µ—Ç—ã—Ä–µ —Ç–∏–ø–∞ —Å–±–æ—Ä–∞ –¥–∞–Ω–Ω—ã—Ö: —Å–ø–∏—Å–∫–∏, –∫–æ—Ä—Ç–µ–∂–∏, –Ω–∞–±–æ—Ä—ã –∏ —Å–ª–æ–≤–∞—Ä–∏. –ú–æ–¥—É–ª—å Python –∫–æ–ª–ª–µ–∫—Ü–∏–π –ø—Ä–µ–¥–æ—Å—Ç–∞–≤–ª—è–µ—Ç –¥–æ–ø–æ–ª–Ω–∏—Ç–µ–ª—å–Ω—ã–µ –ø–∞—Ä–∞–º–µ—Ç—Ä—ã, –≤–∫–ª—é—á–∞—è namedtuple , Counter , defaultdict –∏ ChainMap .

Python –ø—Ä–µ–¥–ª–∞–≥–∞–µ—Ç —á–µ—Ç—ã—Ä–µ —Ç–∏–ø–∞ –¥–∞–Ω–Ω—ã—Ö –∫–æ–ª–ª–µ–∫—Ü–∏–π: —Å–ø–∏—Å–∫–∏, –∫–æ—Ä—Ç–µ–∂–∏, –Ω–∞–±–æ—Ä—ã –∏ —Å–ª–æ–≤–∞—Ä–∏. –ö–∞–∂–¥—ã–π –∏–∑ —ç—Ç–∏—Ö —Ç–∏–ø–æ–≤ –¥–∞–Ω–Ω—ã—Ö –ø–æ–ª–µ–∑–µ–Ω –≤ –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã—Ö —Å–∏—Ç—É–∞—Ü–∏—è—Ö. & Nbsp;

–ù–∞–ø—Ä–∏–º–µ—Ä, –ø–æ—Å–∫–æ–ª—å–∫—É —Å–ø–∏—Å–∫–∏ –º–æ–∂–Ω–æ –∏–∑–º–µ–Ω—è—Ç—å, –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –∏—Ö –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è –ø–æ—Å—Ç–æ—è–Ω–Ω–æ –º–µ–Ω—è—é—â–µ–≥–æ—Å—è —Å–ø–∏—Å–∫–∞ –∏–º–µ–Ω —É—á–∞—â–∏—Ö—Å—è. –ò–ª–∏ –ø—Ä–µ–¥–ø–æ–ª–æ–∂–∏–º, —á—Ç–æ –≤—ã —Ö–æ—Ç–∏—Ç–µ —Å–æ—Ö—Ä–∞–Ω–∏—Ç—å —Å–ø–∏—Å–æ–∫ –≤–∫—É—Å–æ–≤ –º–æ—Ä–æ–∂–µ–Ω–æ–≥–æ, –∫–æ—Ç–æ—Ä—ã–π –Ω–∏–∫–æ–≥–¥–∞ –Ω–µ –∏–∑–º–µ–Ω–∏—Ç—Å—è. –ö–æ—Ä—Ç–µ–∂, —Å–æ–¥–µ—Ä–∂–∏–º–æ–µ –∫–æ—Ç–æ—Ä–æ–≥–æ –Ω–µ –º–æ–∂–µ—Ç –±—ã—Ç—å –∏–∑–º–µ–Ω–µ–Ω–æ, –º–æ–∂–µ—Ç –±—ã—Ç—å –±–æ–ª–µ–µ –ø–æ–¥—Ö–æ–¥—è—â–∏–º.

–ß–∞—Å—Ç–æ, –∫–æ–≥–¥–∞ –≤—ã —Ä–∞–±–æ—Ç–∞–µ—Ç–µ –≤ Python, –≤—ã –º–æ–∂–µ—Ç–µ –æ–±–Ω–∞—Ä—É–∂–∏—Ç—å, —á—Ç–æ —ç—Ç–∏ —Ç–∏–ø—ã –¥–∞–Ω–Ω—ã—Ö –Ω–µ –ø—Ä–µ–¥–ª–∞–≥–∞—é—Ç –≤—Å–µ —Ñ—É–Ω–∫—Ü–∏–∏, –∫–æ—Ç–æ—Ä—ã–µ –≤—ã –∏—â–µ—Ç–µ. –ö —Å—á–∞—Å—Ç—å—é, –µ—Å—Ç—å –º–æ–¥—É–ª—å Python, –∫–æ—Ç–æ—Ä—ã–π –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è –¥–æ—Å—Ç—É–ø–∞ –∫ –±–æ–ª–µ–µ –ø—Ä–æ–¥–≤–∏–Ω—É—Ç—ã–º —Ñ—É–Ω–∫—Ü–∏—è–º, —Å–≤—è–∑–∞–Ω–Ω—ã–º —Å –∫–æ–ª–ª–µ–∫—Ü–∏—è–º–∏ –¥–∞–Ω–Ω—ã—Ö: –º–æ–¥—É–ª—å –∫–æ–ª–ª–µ–∫—Ü–∏–π Python.

–ú–æ–¥—É–ª—å –∫–æ–ª–ª–µ–∫—Ü–∏–π Python –±—ã–ª —Å–æ–∑–¥–∞–Ω –¥–ª—è —É–ª—É—á—à–µ–Ω–∏—è —Ñ—É–Ω–∫—Ü–∏–æ–Ω–∞–ª—å–Ω–æ—Å—Ç–∏ –≤—Å—Ç—Ä–æ–µ–Ω–Ω—ã—Ö –ø–∞—Ä–∞–º–µ—Ç—Ä–æ–≤ —Å–±–æ—Ä–∞ –¥–∞–Ω–Ω—ã—Ö. –∏ –¥–∞—Ç—å —Ä–∞–∑—Ä–∞–±–æ—Ç—á–∏–∫–∞–º –±–æ–ª—å—à–µ –≥–∏–±–∫–æ—Å—Ç–∏ –ø—Ä–∏ —Ä–∞–±–æ—Ç–µ —Å–æ —Å—Ç—Ä—É–∫—Ç—É—Ä–∞–º–∏ –¥–∞–Ω–Ω—ã—Ö. –í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –º—ã —Ä–∞–∑–±–µ—Ä–µ–º –æ—Å–Ω–æ–≤—ã –º–æ–¥—É–ª—è –∫–æ–ª–ª–µ–∫—Ü–∏–π Python –∏ —Ä–∞—Å—Å–º–æ—Ç—Ä–∏–º —á–µ—Ç—ã—Ä–µ –Ω–∞–∏–±–æ–ª–µ–µ —á–∞—Å—Ç–æ –∏—Å–ø–æ–ª—å–∑—É–µ–º—ã–µ —Å—Ç—Ä—É–∫—Ç—É—Ä—ã –¥–∞–Ω–Ω—ã—Ö –∏–∑ –º–æ–¥—É–ª—è.

–û–±–Ω–æ–≤–ª–µ–Ω–∏–µ –∫–æ–ª–ª–µ–∫—Ü–∏–π

–ö–æ–ª–ª–µ–∫—Ü–∏–∏ - —ç—Ç–æ —Ç–∏–ø—ã –¥–∞–Ω–Ω—ã—Ö –∫–æ–Ω—Ç–µ–π–Ω–µ—Ä–∞ –∫–æ—Ç–æ—Ä—ã–µ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è –¥–∞–Ω–Ω—ã—Ö. –ö–∞–∫ –æ–±—Å—É–∂–¥–∞–ª–æ—Å—å —Ä–∞–Ω–µ–µ, –∫–æ–ª–ª–µ–∫—Ü–∏–∏ –º–æ–≥—É—Ç —Ö—Ä–∞–Ω–∏—Ç—å —Å–ø–∏—Å–∫–∏, –Ω–∞–±–æ—Ä—ã, –∫–æ—Ä—Ç–µ–∂–∏ –∏ —Å–ª–æ–≤–∞—Ä–∏. –ö–∞–∂–¥—ã–π –∏–∑ —ç—Ç–∏—Ö —Ç–∏–ø–æ–≤ –¥–∞–Ω–Ω—ã—Ö –∏–º–µ–µ—Ç —Å–≤–æ–∏ —Å–æ–±—Å—Ç–≤–µ–Ω–Ω—ã–µ —Ö–∞—Ä–∞–∫—Ç–µ—Ä–∏—Å—Ç–∏–∫–∏.

–°–ø–∏—Å–∫–∏

—Å–ø–∏—Å–æ–∫ - —ç—Ç–æ —É–ø–æ—Ä—è–¥–æ—á–µ–Ω–Ω—ã–µ –∏–∑–º–µ–Ω—è–µ–º—ã–µ –¥–∞–Ω–Ω—ã–µ. —Ç–∏–ø, –∫–æ—Ç–æ—Ä—ã–π –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è –¥–∞–Ω–Ω—ã—Ö, –∫–æ—Ç–æ—Ä—ã–µ –º–æ–≥—É—Ç –∏–∑–º–µ–Ω—è—Ç—å—Å—è —Å–æ –≤—Ä–µ–º–µ–Ω–µ–º. –ù–∞–ø—Ä–∏–º–µ—Ä, –≤—ã –º–æ–∂–µ—Ç–µ –¥–æ–±–∞–≤–ª—è—Ç—å, —É–¥–∞–ª—è—Ç—å –∏ –æ–±–Ω–æ–≤–ª—è—Ç—å —Å—É—â–µ—Å—Ç–≤—É—é—â–∏–µ —ç–ª–µ–º–µ–Ω—Ç—ã —Å–ø–∏—Å–∫–∞. –°–ø–∏—Å–∫–∏ –º–æ–≥—É—Ç —Å–æ–¥–µ—Ä–∂–∞—Ç—å –ø–æ–≤—Ç–æ—Ä—è—é—â–∏–µ—Å—è –∑–Ω–∞—á–µ–Ω–∏—è. –í—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –Ω–æ–º–µ—Ä–∞ –∏–Ω–¥–µ–∫—Å–æ–≤ –¥–ª—è —Å—Å—ã–ª–∫–∏ –Ω–∞ –æ—Ç–¥–µ–ª—å–Ω—ã–µ —ç–ª–µ–º–µ–Ω—Ç—ã –≤ —Å–ø–∏—Å–∫–µ.

–ù–∏–∂–µ –ø—Ä–∏–≤–æ–¥–∏—Ç—Å—è –ø—Ä–∏–º–µ—Ä –æ–±—ä—è–≤–ª–µ–Ω–∏—è —Å–ø–∏—Å–∫–∞ –≤ Python:

81% —É—á–∞—Å—Ç–Ω–∏–∫–æ–≤ –∑–∞—è–≤–∏–ª–∏, —á—Ç–æ –æ–Ω–∏ —á—É–≤—Å—Ç–≤—É—é—Ç —Å–µ–±—è –±–æ–ª–µ–µ —É–≤–µ—Ä–µ–Ω–Ω–æ –≤ —Å–≤–æ–∏—Ö –ø–µ—Ä—Å–ø–µ–∫—Ç–∏–≤—ã —Ç—Ä—É–¥–æ—É—Å—Ç—Ä–æ–π—Å—Ç–≤–∞ –ø–æ—Å–ª–µ –±—É—Ç–∫–µ–º–ø–∞. –ü–æ–ª—É—á–∏—Ç–µ –ø—Ä–∏–≥–ª–∞—à–µ–Ω–∏–µ –Ω–∞ —É—á–µ–±–Ω—ã–π –∫—É—Ä—Å —Å–µ–≥–æ–¥–Ω—è.

–°—Ä–µ–¥–Ω–∏–π –≤—ã–ø—É—Å–∫–Ω–∏–∫ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –ø—Ä–æ–≤–µ–ª –º–µ–Ω–µ–µ —à–µ—Å—Ç–∏ –º–µ—Å—è—Ü–µ–≤ –≤ –ø–µ—Ä–µ—Ö–æ–¥–µ –ø–æ –∫–∞—Ä—å–µ—Ä–Ω–æ–π –ª–µ—Å—Ç–Ω–∏—Ü–µ, –æ—Ç –Ω–∞—á–∞–ª–∞ —É—á–µ–±–Ω–æ–≥–æ –ª–∞–≥–µ—Ä—è –¥–æ –ø–æ–∏—Å–∫–∞ —Å–≤–æ–µ–π –ø–µ—Ä–≤–æ–π —Ä–∞–±–æ—Ç—ã.

–ö–æ—Ä—Ç–µ–∂–∏ - —ç—Ç–æ —É–ø–æ—Ä—è–¥–æ—á–µ–Ω–Ω—ã–µ –∏ –Ω–µ–∏–∑–º–µ–Ω—è–µ–º—ã–µ —Ç–∏–ø—ã –¥–∞–Ω–Ω—ã—Ö. –•–æ—Ç—è –∫–æ—Ä—Ç–µ–∂–∏ –º–æ–≥—É—Ç —Å–æ–¥–µ—Ä–∂–∞—Ç—å –ø–æ–≤—Ç–æ—Ä—è—é—â–∏–µ—Å—è –∑–Ω–∞—á–µ–Ω–∏—è, –∏—Ö –∑–Ω–∞—á–µ–Ω–∏—è –Ω–µ–ª—å–∑—è –∏–∑–º–µ–Ω–∏—Ç—å. –ö–æ—Ä—Ç–µ–∂–∏ –∑–∞–∫–ª—é—á–µ–Ω—ã –≤ —Ñ–∏–≥—É—Ä–Ω—ã–µ —Å–∫–æ–±–∫–∏. & Nbsp;

–í–æ—Ç –ø—Ä–∏–º–µ—Ä –∫–æ—Ä—Ç–µ–∂–∞ Python:

–ù–∞–±–æ—Ä—ã

–ù–∞–±–æ—Ä—ã –ø—Ä–µ–¥—Å—Ç–∞–≤–ª—è—é—Ç —Å–æ–±–æ–π –Ω–µ—É–ø–æ—Ä—è–¥–æ—á–µ–Ω–Ω—ã–µ —Å–ø–∏—Å–∫–∏. –û–Ω–∏ –æ–±—ä—è–≤–ª—è—é—Ç—Å—è –≤ –∫–≤–∞–¥—Ä–∞—Ç–Ω—ã—Ö —Å–∫–æ–±–∫–∞—Ö. –í –æ—Ç–ª–∏—á–∏–µ –æ—Ç —Å–ø–∏—Å–∫–æ–≤, –Ω–∞–±–æ—Ä—ã –Ω–µ –∏–º–µ—é—Ç –∑–Ω–∞—á–µ–Ω–∏–π –∏–Ω–¥–µ–∫—Å–∞ –∏ –Ω–µ –º–æ–≥—É—Ç –≤–∫–ª—é—á–∞—Ç—å –ø–æ–≤—Ç–æ—Ä—è—é—â–∏–µ—Å—è –∑–∞–ø–∏—Å–∏. & Nbsp;

–í–æ—Ç –ø—Ä–∏–º–µ—Ä –Ω–∞–±–æ—Ä–∞ Python:

–°–ª–æ–≤–∞—Ä–∏

–°–ª–æ–≤–∞—Ä–∏ - —ç—Ç–æ –Ω–µ—É–ø–æ—Ä—è–¥–æ—á–µ–Ω–Ω—ã–µ –∏–∑–º–µ–Ω—è–µ–º—ã–µ —Ç–∏–ø—ã –¥–∞–Ω–Ω—ã—Ö, –∫–æ—Ç–æ—Ä—ã–µ –º–æ–∂–Ω–æ –∏–Ω–¥–µ–∫—Å–∏—Ä–æ–≤–∞—Ç—å. –£ –∫–∞–∂–¥–æ–≥–æ —ç–ª–µ–º–µ–Ω—Ç–∞ –≤ —Å–ª–æ–≤–∞—Ä–µ –µ—Å—Ç—å –∫–ª—é—á –∏ –∑–Ω–∞—á–µ–Ω–∏–µ. & Nbsp;

–í–æ—Ç –ø—Ä–∏–º–µ—Ä –∑–∞–ø–∏—Å–∏ —Å–ª–æ–≤–∞—Ä—è Python:

–≠—Ç–∏ —á–µ—Ç—ã—Ä–µ —Ç–∏–ø–∞ –¥–∞–Ω–Ω—ã—Ö —à–∏—Ä–æ–∫–æ –∏—Å–ø–æ–ª—å–∑—É—é—Ç—Å—è –≤ Python. . –û–¥–Ω–∞–∫–æ, –µ—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ –≤—ã–ø–æ–ª–Ω—è—Ç—å –±–æ–ª–µ–µ —Å–ª–æ–∂–Ω—ã–µ –¥–µ–π—Å—Ç–≤–∏—è —Å —Ç–∏–ø–∞–º–∏ –¥–∞–Ω–Ω—ã—Ö –∫–æ–Ω—Ç–µ–π–Ω–µ—Ä–∞ Python, —Å—Ç–æ–∏—Ç —Ä–∞—Å—Å–º–æ—Ç—Ä–µ—Ç—å –º–æ–¥—É–ª—å –∫–æ–ª–ª–µ–∫—Ü–∏–π Python.

–ú–æ–¥—É–ª—å –∫–æ–ª–ª–µ–∫—Ü–∏–π Python —Å–æ–¥–µ—Ä–∂–∏—Ç —Ä—è–¥ —Å–ø–µ—Ü–∏–∞–ª–∏–∑–∏—Ä–æ–≤–∞–Ω–Ω—ã—Ö —Å—Ç—Ä—É–∫—Ç—É—Ä –¥–∞–Ω–Ω—ã—Ö, –∫–æ—Ç–æ—Ä—ã–µ –≤—ã –º–æ–∂–µ—Ç–µ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –≤ –¥–æ–ø–æ–ª–Ω–µ–Ω–∏–µ –∫ & mdash; –∏–ª–∏ –≤ –∫–∞—á–µ—Å—Ç–≤–µ –∞–ª—å—Ç–µ—Ä–Ω–∞—Ç–∏–≤—ã –≤—Å—Ç—Ä–æ–µ–Ω–Ω—ã–º –∫–æ–Ω—Ç–µ–π–Ω–µ—Ä–∞–º & mdash; Python. –ü–æ—Å–∫–æ–ª—å–∫—É collections - —ç—Ç–æ –º–æ–¥—É–ª—å, –º—ã –¥–æ–ª–∂–Ω—ã –∏–º–ø–æ—Ä—Ç–∏—Ä–æ–≤–∞—Ç—å –µ–≥–æ –≤ –Ω–∞—à—É –ø—Ä–æ–≥—Ä–∞–º–º—É. –û–¥–Ω–∞–∫–æ –æ–Ω –≤—Å—Ç—Ä–æ–µ–Ω –≤ Python, –ø–æ—ç—Ç–æ–º—É –Ω–∞–º –Ω–µ –Ω—É–∂–Ω–æ –∏–º–ø–æ—Ä—Ç–∏—Ä–æ–≤–∞—Ç—å –≤—Ç–æ—Ä–∏—á–Ω—ã–µ –±–∏–±–ª–∏–æ—Ç–µ–∫–∏.

–í —ç—Ç–æ–π —Å—Ç–∞—Ç—å–µ –º—ã —Å–æ—Å—Ä–µ–¥–æ—Ç–æ—á–∏–º—Å—è –Ω–∞ —á–µ—Ç—ã—Ä–µ—Ö –Ω–∞–∏–±–æ–ª–µ–µ —á–∞—Å—Ç–æ –∏—Å–ø–æ–ª—å–∑—É–µ–º—ã—Ö —Å—Ç—Ä—É–∫—Ç—É—Ä–∞—Ö –¥–∞–Ω–Ω—ã—Ö –∏–∑ –º–æ–¥—É–ª—è –∫–æ–ª–ª–µ–∫—Ü–∏–π. –≠—Ç–æ —Å–ª–µ–¥—É—é—â–∏–µ:

  • Counter < / li>
  • namedtuple
  • defaultdict
  • ChainMap

Counter

Counter () —è–≤–ª—è–µ—Ç—Å—è –ø–æ–¥–∫–ª–∞—Å—Å–æ–º –æ–±—ä–µ–∫—Ç–∞ —Å–ª–æ–≤–∞—Ä—è –∏ –º–æ–∂–µ—Ç –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å—Å—è –¥–ª—è –ø–æ–¥—Å—á–µ—Ç–∞ —Ö–µ—à–∏—Ä—É–µ–º—ã—Ö –æ–±—ä–µ–∫—Ç–æ–≤. –§—É–Ω–∫—Ü–∏—è Counter () –ø—Ä–∏–Ω–∏–º–∞–µ—Ç –∏—Ç–µ—Ä–∏—Ä—É–µ–º—ã–π –æ–±—ä–µ–∫—Ç –≤ –∫–∞—á–µ—Å—Ç–≤–µ –∞—Ä–≥—É–º–µ–Ω—Ç–∞ –∏ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Å–ª–æ–≤–∞—Ä—å.

–ò—Ç–∞–∫, , –¥–æ–ø—É—Å—Ç–∏–º, —É –Ω–∞—Å –µ—Å—Ç—å —Å–ø–∏—Å–æ–∫ –∑–∞–∫–∞–∑–æ–≤ –Ω–∞ —Å—ç–Ω–¥–≤–∏—á–∏ –Ω–∞ —è–Ω–≤–∞—Ä—å, –∏ –º—ã —Ö–æ—Ç–∏–º –∑–Ω–∞—Ç—å, —Å–∫–æ–ª—å–∫–æ —Å—ç–Ω–¥–≤–∏—á–µ–π BLT –º—ã –ø—Ä–æ–¥–∞–ª–∏ –≤ —Ç–µ—á–µ–Ω–∏–µ —ç—Ç–æ–≥–æ –º–µ—Å—è—Ü–∞. –î–ª—è —ç—Ç–æ–≥–æ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Ñ—É–Ω–∫—Ü–∏—é Counter (). & nbsp;

–í–æ—Ç –ø—Ä–∏–º–µ—Ä –∫–æ–¥–∞, –∫–æ—Ç–æ—Ä—ã–π –º—ã –±—É–¥–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: 2.

–í –Ω–∞—à–µ–º –∫–æ–¥–µ –º–Ω–æ–≥–æ —á–µ–≥–æ –ø—Ä–æ–∏—Å—Ö–æ–¥–∏—Ç, –ø–æ—ç—Ç–æ–º—É –¥–∞–≤–∞–π—Ç–µ —Ä–∞–∑–±–µ—Ä–µ–º –µ–≥–æ.

–í –ø–µ—Ä–≤–æ–π —Å—Ç—Ä–æ–∫–µ –º—ã –∏–º–ø–æ—Ä—Ç–∏—Ä—É–µ–º —Ñ—É–Ω–∫—Ü–∏—é Counter –∏–∑ –∫–æ–ª–ª–µ–∫—Ü–∏–∏. –ú—ã –¥–æ–ª–∂–Ω—ã —Å–¥–µ–ª–∞—Ç—å —ç—Ç–æ, –ø–æ—Ç–æ–º—É —á—Ç–æ collections - —ç—Ç–æ –º–æ–¥—É–ª—å. –ó–∞—Ç–µ–º –º—ã –æ–±—ä—è–≤–ª—è–µ–º –º–∞—Å—Å–∏–≤ sandwich_sales, –≤ –∫–æ—Ç–æ—Ä–æ–º —Ö—Ä–∞–Ω–∏—Ç—Å—è, —Å–∫–æ–ª—å–∫–æ –±—É—Ç–µ—Ä–±—Ä–æ–¥–æ–≤ –º—ã –ø—Ä–æ–¥–∞–ª–∏ –≤ —è–Ω–≤–∞—Ä–µ.

–í —Å–ª–µ–¥—É—é—â–µ–π —Å—Ç—Ä–æ–∫–µ –º—ã –æ–±—ä—è–≤–ª—è–µ–º –ø–µ—Ä–µ–º–µ–Ω–Ω—É—é our_counter –∏ –Ω–∞–∑–Ω–∞—á—å—Ç–µ –µ–º—É —Ñ—É–Ω–∫—Ü–∏—é Counter (sandwich_sales). –≠—Ç–æ –ø–æ–∑–≤–æ–ª—è–µ—Ç –Ω–∞–º –ø–æ–ª—É—á–∏—Ç—å –¥–æ—Å—Ç—É–ø –∫ —Ä–µ–∑—É–ª—å—Ç–∞—Ç—É —Ñ—É–Ω–∫—Ü–∏–∏ Counter (), –∫–æ–≥–¥–∞ –º—ã —Å—Å—ã–ª–∞–µ–º—Å—è –Ω–∞ our_counter.

–ù–∞–∫–æ–Ω–µ—Ü, –º—ã –∏—Å–ø–æ–ª—å–∑—É–µ–º print (our_counter [ " BLT "]), —á—Ç–æ–±—ã —Ä–∞—Å–ø–µ—á–∞—Ç–∞—Ç—å, —Å–∫–æ–ª—å–∫–æ –±—É—Ç–µ—Ä–±—Ä–æ–¥–æ–≤ –≤ –Ω–∞—à–µ–º —Å–ª–æ–≤–∞—Ä–µ —Ä–∞–≤–Ω–æ BLT. –í —ç—Ç–æ–º —Å–ª—É—á–∞–µ –æ—Ç–≤–µ—Ç –±—ã–ª 2.

namedtuple

–ú–µ—Ç–æ–¥ namedtuple () –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –∫–æ—Ä—Ç–µ–∂ —Å –∏–º–µ–Ω–∞–º–∏ –¥–ª—è –∫–∞–∂–¥–æ–≥–æ –ø–æ–∑–∏—Ü–∏—è –≤ –∫–æ—Ä—Ç–µ–∂–µ. –ö–æ–≥–¥–∞ –≤—ã —Ä–∞–±–æ—Ç–∞–µ—Ç–µ —Å–æ —Å—Ç–∞–Ω–¥–∞—Ä—Ç–Ω—ã–º –∫–æ—Ä—Ç–µ–∂–µ–º, –µ–¥–∏–Ω—Å—Ç–≤–µ–Ω–Ω—ã–π —Å–ø–æ—Å–æ–± –ø–æ–ª—É—á–∏—Ç—å –¥–æ—Å—Ç—É–ø –∫ –æ—Ç–¥–µ–ª—å–Ω—ã–º –∑–Ω–∞—á–µ–Ω–∏—è–º - —ç—Ç–æ —Å—Å—ã–ª–∞—Ç—å—Å—è –Ω–∞ –Ω–æ–º–µ—Ä–∞ –∏–Ω–¥–µ–∫—Å–æ–≤ –∫–æ—Ä—Ç–µ–∂–∞. –ï—Å–ª–∏ –≤—ã —Ä–∞–±–æ—Ç–∞–µ—Ç–µ —Å –±–æ–ª—å—à–∏–º –∫–æ—Ä—Ç–µ–∂–µ–º, —ç—Ç–æ –º–æ–∂–µ—Ç –±—ã—Å—Ç—Ä–æ –∑–∞–ø—É—Ç–∞—Ç—å.

"–ö–∞—Ä—å–µ—Ä–Ω–∞—è –∫–∞—Ä–º–∞ –≤–æ—à–ª–∞ –≤ –º–æ—é –∂–∏–∑–Ω—å —Ç–æ–≥–¥–∞, –∫–æ–≥–¥–∞ —è –±–æ–ª—å—à–µ –≤—Å–µ–≥–æ –≤ –Ω–µ–π –Ω—É–∂–¥–∞–ª–∞—Å—å, –∏ –±—ã—Å—Ç—Ä–æ –ø–æ–º–æ–≥–ª–∞ –º–Ω–µ –ø—Ä–æ–π—Ç–∏ –∫—É—Ä—Å –æ–±—É—á–µ–Ω–∏—è. –ß–µ—Ä–µ–∑ –¥–≤–∞ –º–µ—Å—è—Ü–∞ –ø–æ—Å–ª–µ –æ–∫–æ–Ω—á–∞–Ω–∏—è —É—á–µ–±—ã —è –æ–±–Ω–∞—Ä—É–∂–∏–ª —Ä–∞–±–æ—Ç–∞ –º–æ–µ–π –º–µ—á—Ç—ã, –∫–æ—Ç–æ—Ä–∞—è —Å–æ–æ—Ç–≤–µ—Ç—Å—Ç–≤–æ–≤–∞–ª–∞ –º–æ–∏–º —Ü–µ–Ω–Ω–æ—Å—Ç—è–º –∏ —Ü–µ–ª—è–º –≤ –∂–∏–∑–Ω–∏! "

–í–µ–Ω–µ—Ä–∞, –∏–Ω–∂–µ–Ω–µ—Ä-–ø—Ä–æ–≥—Ä–∞–º–º–∏—Å—Ç Rockbot

–í–æ—Ç –ø—Ä–∏–º–µ—Ä –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—è –º–µ—Ç–æ–¥–∞ namedtuple () –¥–ª—è —Ö—Ä–∞–Ω–µ–Ω–∏—è –Ω–∞–∑–≤–∞–Ω–∏—è –∏ —Ü–µ–Ω—ã —Å—ç–Ω–¥–≤–∏—á–∞:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: 3,00 –¥–æ–ª–ª–∞—Ä–∞.

–í –Ω–∞—à–µ–º –∫–æ–¥–µ –º–Ω–æ–≥–æ —á–µ–≥–æ –ø—Ä–æ–∏—Å—Ö–æ–¥–∏—Ç, —Ç–∞–∫ —á—Ç–æ –¥–∞–≤–∞–π—Ç–µ —Ä–∞–∑–±–µ—Ä–µ–º—Å—è —Å —ç—Ç–∏–º. –í –ø–µ—Ä–≤–æ–π —Å—Ç—Ä–æ–∫–µ –º—ã –∏–º–ø–æ—Ä—Ç–∏—Ä—É–µ–º namedtuple –∏–∑ –º–æ–¥—É–ª—è collections, —á—Ç–æ–±—ã –º—ã –º–æ–≥–ª–∏ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –µ–≥–æ –≤ –Ω–∞—à–µ–º –∫–æ–¥–µ.

–í —Å–ª–µ–¥—É—é—â–µ–π —Å—Ç—Ä–æ–∫–µ –º—ã —Å–æ–∑–¥–∞–µ–º –∫–æ—Ä—Ç–µ–∂ Sandwich —Å –∏–º–µ–Ω–µ–º Sandwich –∏ –Ω–∞–∑–Ω–∞—á—å—Ç–µ –µ–º—É –¥–≤–∞ –∑–∞–≥–æ–ª–æ–≤–∫–∞: –∏–º—è –∏ —Ü–µ–Ω—É. –≠—Ç–æ –ø–æ–∑–≤–æ–ª—è–µ—Ç –Ω–∞–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —ç—Ç–∏ –∑–∞–≥–æ–ª–æ–≤–∫–∏ –¥–ª—è —Å—Å—ã–ª–∫–∏ –Ω–∞ –∑–Ω–∞—á–µ–Ω–∏—è –≤ –Ω–∞—à–∏—Ö –∫–æ—Ä—Ç–µ–∂–∞—Ö –ø–æ–∑–∂–µ –≤ –Ω–∞—à–µ–º –∫–æ–¥–µ. –ó–∞—Ç–µ–º –º—ã –æ–±—ä—è–≤–ª—è–µ–º –ø–µ—Ä–µ–º–µ–Ω–Ω—É—é —Å –∏–º–µ–Ω–µ–º first_sandwich, –∫–æ—Ç–æ—Ä–æ–π –º—ã –ø—Ä–∏—Å–≤–æ–∏–ª–∏ —ç–ª–µ–º–µ–Ω—Ç –∫–æ—Ä—Ç–µ–∂–∞ Chicken Teriyaki.

–ù–∞–∫–æ–Ω–µ—Ü, –º—ã —Ä–∞—Å–ø–µ—á–∞—Ç—ã–≤–∞–µ–º —Ü–µ–Ω—É –Ω–∞—à–µ–≥–æ first_sandwich, –∫–æ—Ç–æ—Ä—ã–π –≤ –¥–∞–Ω–Ω–æ–º —Å–ª—É—á–∞–µ —Å–æ—Å—Ç–∞–≤–ª—è–µ—Ç 3 –¥–æ–ª–ª–∞—Ä–∞ –°–®–ê.

–í—ã —Ç–∞–∫–∂–µ –º–æ–∂–µ—Ç–µ —Å–æ–∑–¥–∞—Ç—å namedtuple (), –∏—Å–ø–æ–ª—å–∑—É—è —Å–ø–∏—Å–æ–∫. –í–æ—Ç –ø—Ä–∏–º–µ—Ä:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: –ü—Ä—è–Ω—ã–π –∏—Ç–∞–ª—å—è–Ω—Å–∫–∏–π. –í —ç—Ç–æ–º –ø—Ä–∏–º–µ—Ä–µ –º—ã –∏—Å–ø–æ–ª—å–∑—É–µ–º _make –≤ –¥–æ–ø–æ–ª–Ω–µ–Ω–∏–µ –∫ –Ω–∞—à–µ–º—É —ç–ª–µ–º–µ–Ω—Ç—É Sandwich, —á—Ç–æ–±—ã –æ–±–æ–∑–Ω–∞—á–∏—Ç—å, —á—Ç–æ –º—ã —Ö–æ—Ç–∏–º –ø—Ä–µ–≤—Ä–∞—Ç–∏—Ç—å –Ω–∞—à —Å–ø–∏—Å–æ–∫ –≤ namedtuple (). & nbsp;

defaultdict

–ú–µ—Ç–æ–¥ defaultdict () –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —Å–æ–∑–¥–∞–Ω–∏—è —Å–ª–æ–≤–∞—Ä—è Python, –∫–æ—Ç–æ—Ä—ã–π –Ω–µ –≥–µ–Ω–µ—Ä–∏—Ä—É–µ—Ç KeyError –ø—Ä–∏ –ø–æ–ø—ã—Ç–∫–µ –¥–æ—Å—Ç—É–ø–∞ –∫ –Ω–µ—Å—É—â–µ—Å—Ç–≤—É—é—â–µ–º—É –æ–±—ä–µ–∫—Ç—É. –í–º–µ—Å—Ç–æ —ç—Ç–æ–≥–æ, –µ—Å–ª–∏ –≤—ã —Å—Å—ã–ª–∞–µ—Ç–µ—Å—å –Ω–∞ –Ω–µ—Å—É—â–µ—Å—Ç–≤—É—é—â–∏–π –æ–±—ä–µ–∫—Ç, —Å–ª–æ–≤–∞—Ä—å –≤–µ—Ä–Ω–µ—Ç –ø—Ä–µ–¥–æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—ã–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö.

–í–æ—Ç –ø—Ä–∏–º–µ—Ä, –≤ –∫–æ—Ç–æ—Ä–æ–º –∏—Å–ø–æ–ª—å–∑—É–µ—Ç—Å—è defaultdict () –º–µ—Ç–æ–¥ t o –æ–±—ä—è–≤–∏—Ç—å —Å–ª–æ–≤–∞—Ä—å, –∫–æ—Ç–æ—Ä—ã–π –±—É–¥–µ—Ç –≤–æ–∑–≤—Ä–∞—â–∞—Ç—å str, –µ—Å–ª–∏ –º—ã —Å—Å—ã–ª–∞–µ–º—Å—è –Ω–∞ –Ω–µ—Å—É—â–µ—Å—Ç–≤—É—é—â–∏–π –æ–±—ä–µ–∫—Ç:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç:

–í –ø—Ä–∏–≤–µ–¥–µ–Ω–Ω–æ–º –≤—ã—à–µ –ø—Ä–∏–º–µ—Ä–µ –º—ã —Å–æ–∑–¥–∞–ª–∏ —Å–ª–æ–≤–∞—Ä—å —Å–æ –∑–Ω–∞—á–µ–Ω–∏—è–º–∏ –≤ –ø–æ–∑–∏—Ü–∏—è—Ö –∏–Ω–¥–µ–∫—Å–∞ –∏ 1. –ö–æ–≥–¥–∞ –º—ã —Ä–∞—Å–ø–µ—á–∞—Ç—ã–≤–∞–µ–º sandwiches [1], –º—ã –≤–∏–¥–∏–º, —á—Ç–æ –Ω–∞—à —Å–ª–æ–≤–∞—Ä—å —Å–æ—Ö—Ä–∞–Ω–∏–ª –Ω–∞—à–∏ –∑–Ω–∞—á–µ–Ω–∏—è. –û–¥–Ω–∞–∫–æ, –∫–æ–≥–¥–∞ –º—ã –ø—ã—Ç–∞–µ–º—Å—è —Ä–∞—Å–ø–µ—á–∞—Ç–∞—Ç—å —ç–ª–µ–º–µ–Ω—Ç, —Å–≤—è–∑–∞–Ω–Ω—ã–π —Å–æ –∑–Ω–∞—á–µ–Ω–∏–µ–º –∏–Ω–¥–µ–∫—Å–∞ 2, –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –ø—É—Å—Ç—É—é —Å—Ç—Ä–æ–∫—É, –ø–æ—Ç–æ–º—É —á—Ç–æ —ç—Ç–æ–º—É –∏–Ω–¥–µ–∫—Å—É –Ω–µ –ø—Ä–∏—Å–≤–æ–µ–Ω–æ –∑–Ω–∞—á–µ–Ω–∏–µ.

–í —Å—Ç–∞–Ω–¥–∞—Ä—Ç–µ Dictionary, –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–µ—Ä–Ω–µ—Ç KeyError. –û–¥–Ω–∞–∫–æ, –ø–æ—Å–∫–æ–ª—å–∫—É –º—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–ª–∏ defaultdict, –Ω–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–º–µ—Å—Ç–æ —ç—Ç–æ–≥–æ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö, –∫–æ—Ç–æ—Ä—ã–π –º—ã —É–∫–∞–∑–∞–ª–∏ –ø—Ä–∏ —Å–æ–∑–¥–∞–Ω–∏–∏ —Å–ª–æ–≤–∞—Ä—è. –í –ø—Ä–∏–≤–µ–¥–µ–Ω–Ω–æ–º –≤—ã—à–µ –ø—Ä–∏–º–µ—Ä–µ –º—ã –∑–∞—è–≤–∏–ª–∏, —á—Ç–æ –ª—é–±–æ–π –Ω–µ–¥–æ–ø—É—Å—Ç–∏–º—ã–π –∫–ª—é—á –¥–æ–ª–∂–µ–Ω –≤–æ–∑–≤—Ä–∞—â–∞—Ç—å str, –Ω–æ –º—ã –º–æ–≥–ª–∏ –±—ã –∑–∞–∫–æ–¥–∏—Ä–æ–≤–∞—Ç—å –µ–≥–æ —Ç–∞–∫, —á—Ç–æ–±—ã –æ–Ω –≤–æ–∑–≤—Ä–∞—â–∞–ª —Ü–µ–ª–æ–µ —á–∏—Å–ª–æ –∏–ª–∏ –ª—é–±–æ–π –¥—Ä—É–≥–æ–π –¥–æ–ø—É—Å—Ç–∏–º—ã–π —Ç–∏–ø –¥–∞–Ω–Ω—ã—Ö.

–≠—Ç–∞ —Ñ—É–Ω–∫—Ü–∏—è –º–æ–∂–µ—Ç –±—ã—Ç—å –ø–æ–ª–µ–∑–Ω—ã–º, –∫–æ–≥–¥–∞ –≤—ã —Ä–∞–±–æ—Ç–∞–µ—Ç–µ —Å–æ —Å–ª–æ–≤–∞—Ä–µ–º –¥–ª—è –≤—ã–ø–æ–ª–Ω–µ–Ω–∏—è –æ–ø–µ—Ä–∞—Ü–∏–∏ —Å –Ω–µ—Å–∫–æ–ª—å–∫–∏–º–∏ —ç–ª–µ–º–µ–Ω—Ç–∞–º–∏, –Ω–æ –æ–ø–µ—Ä–∞—Ü–∏—è –º–æ–∂–µ—Ç –Ω–µ —Ä–∞–±–æ—Ç–∞—Ç—å —Å –∫–∞–∂–¥—ã–º —ç–ª–µ–º–µ–Ω—Ç–æ–º. –í–º–µ—Å—Ç–æ —Ç–æ–≥–æ, —á—Ç–æ–±—ã –∑–∞—Å—Ç–∞–≤–ª—è—Ç—å –≤–∞—à—É –ø—Ä–æ–≥—Ä–∞–º–º—É –≤–æ–∑–≤—Ä–∞—â–∞—Ç—å –æ—à–∏–±–∫—É, defaultdict () –≤–µ—Ä–Ω–µ—Ç –∑–Ω–∞—á–µ–Ω–∏–µ –ø–æ —É–º–æ–ª—á–∞–Ω–∏—é –∏ –ø—Ä–æ–¥–æ–ª–∂–∏—Ç —Ä–∞–±–æ—Ç—É.

ChainMap

ChainMap () –∏—Å–ø–æ–ª—å–∑—É–µ—Ç—Å—è –¥–ª—è –æ–±—ä–µ–¥–∏–Ω–µ–Ω–∏—è –¥–≤—É—Ö –∏–ª–∏ –±–æ–ª–µ–µ —Å–ª–æ–≤–∞—Ä–µ–π; –æ–Ω –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Å–ø–∏—Å–æ–∫ —Å–ª–æ–≤–∞—Ä–µ–π. –ù–∞–ø—Ä–∏–º–µ—Ä, –ø—Ä–µ–¥–ø–æ–ª–æ–∂–∏–º, —á—Ç–æ —É –Ω–∞—Å –µ—Å—Ç—å –¥–≤–∞ –º–µ–Ω—é - —Å—Ç–∞–Ω–¥–∞—Ä—Ç–Ω–æ–µ –º–µ–Ω—é –∏ —Å–µ–∫—Ä–µ—Ç–Ω–æ–µ –º–µ–Ω—é, –∫–æ—Ç–æ—Ä—ã–µ –º—ã —Ö–æ—Ç–∏–º –æ–±—ä–µ–¥–∏–Ω–∏—Ç—å –≤ –æ–¥–Ω–æ –±–æ–ª—å—à–æ–µ –º–µ–Ω—é. –î–ª—è —ç—Ç–æ–≥–æ –º—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Ñ—É–Ω–∫—Ü–∏—é ChainMap ().

–í–æ—Ç –ø—Ä–∏–º–µ—Ä –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–Ω–∏—è ChainMap () –¥–ª—è –æ–±—ä–µ–¥–∏–Ω–µ–Ω–∏—è –Ω–∞—à–µ–≥–æ —Å—Ç–∞–Ω–¥–∞—Ä—Ç–Ω–æ–≥–æ –∏ —Å–µ–∫—Ä–µ—Ç–Ω—ã–µ –º–µ–Ω—é:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –æ–±—ä–µ–∫—Ç ChainMap, –∫–æ—Ç–æ—Ä—ã–π –æ–±—ä–µ–¥–∏–Ω–∏–ª –Ω–∞—à–∏ –¥–≤–∞ –º–µ–Ω—é, –∫–∞–∫ –ø–æ–∫–∞–∑–∞–Ω–æ –Ω–∏–∂–µ:

–ú—ã –º–æ–∂–µ–º –ø–æ–ª—É—á–∏—Ç—å –¥–æ—Å—Ç—É–ø –∫ –∫–∞–∂–¥–æ–º—É –∑–Ω–∞—á–µ–Ω–∏—é –≤ –Ω–∞—à–µ–π ChainMap, —Å–æ—Å–ª–∞–≤—à–∏—Å—å –Ω–∞ –µ–≥–æ –∏–º—è –∫–ª—é—á–∞. –ù–∞–ø—Ä–∏–º–µ—Ä, –≤–æ—Ç —Å—Ç—Ä–æ–∫–∞ –∫–æ–¥–∞, –∫–æ—Ç–æ—Ä–∞—è –ø–æ–∑–≤–æ–ª—è–µ—Ç –Ω–∞–º –ø–æ–ª—É—á–∏—Ç—å —Ü–µ–Ω—É —Å—ç–Ω–¥–≤–∏—á–∞ BLT:

–ù–∞—à–∞ –ø—Ä–æ–≥—Ä–∞–º–º–∞ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç: 3,05 –¥–æ–ª–ª–∞—Ä–∞ –°–®–ê

–ö—Ä–æ–º–µ —Ç–æ–≥–æ, –≤–∞–∂–Ω–æ –æ—Ç–º–µ—Ç–∏—Ç—å, —á—Ç–æ ChainMap –æ–±–Ω–æ–≤–ª—è–µ—Ç—Å—è –ø—Ä–∏ –æ–±–Ω–æ–≤–ª–µ–Ω–∏–∏ —Å–æ–¥–µ—Ä–∂–∞—â–∏—Ö—Å—è –≤ –Ω–µ–π —Å–ª–æ–≤–∞—Ä–µ–π. –ò—Ç–∞–∫, –µ—Å–ª–∏ –≤—ã –∏–∑–º–µ–Ω–∏—Ç–µ –∑–Ω–∞—á–µ–Ω–∏–µ –≤ standard_menu –∏–ª–∏ secret_menu , –æ–±—ä–µ–∫—Ç ChainMap —Ç–∞–∫–∂–µ –±—É–¥–µ—Ç –æ–±–Ω–æ–≤–ª–µ–Ω. –í–æ—Ç –ø—Ä–∏–º–µ—Ä:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç:

–ö–∞–∫ –≤–∏–¥–∏—Ç–µ, —Ü–µ–Ω–∞ –Ω–∞—à BLT –∏–∑–º–µ–Ω–∏–ª—Å—è —Å 3,05 –¥–æ–ª–ª–∞—Ä–∞ –Ω–∞ 3,10 –¥–æ–ª–ª–∞—Ä–∞, –ø–æ—Ç–æ–º—É —á—Ç–æ –º—ã –∏–∑–º–µ–Ω–∏–ª–∏ –µ–≥–æ —Ü–µ–Ω—É –≤ –Ω–∞—à–µ–º —Å–ª–æ–≤–∞—Ä–µ standard_menu.

The Cha –û–±—ä–µ–∫—Ç inMap —Ç–∞–∫–∂–µ –≤–∫–ª—é—á–∞–µ—Ç –¥–≤–µ —Ñ—É–Ω–∫—Ü–∏–∏, –∫–æ—Ç–æ—Ä—ã–µ –º–æ–∂–Ω–æ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è –∏–∑–≤–ª–µ—á–µ–Ω–∏—è –∫–ª—é—á–µ–π –∏–ª–∏ –∑–Ω–∞—á–µ–Ω–∏–π –∏–∑ –æ–±—ä–µ–∫—Ç–∞. –ú—ã –º–æ–∂–µ–º –ø—Ä–æ–∏–ª–ª—é—Å—Ç—Ä–∏—Ä–æ–≤–∞—Ç—å —ç—Ç–æ —Å –ø–æ–º–æ—â—å—é –º–µ—Ç–æ–¥–æ–≤ keys () –∏ values ‚Äã‚Äã(). –≠—Ç–∏ –º–µ—Ç–æ–¥—ã –≤–æ–∑–≤—Ä–∞—â–∞—é—Ç –∫–ª—é—á–∏ –Ω–∞—à–∏—Ö –¥–∞–Ω–Ω—ã—Ö (–∫–æ—Ç–æ—Ä—ã–µ –º—ã –º–æ–∂–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –¥–ª—è —Å—Å—ã–ª–∫–∏ –Ω–∞ –∫–æ–Ω–∫—Ä–µ—Ç–Ω–æ–µ –∑–Ω–∞—á–µ–Ω–∏–µ) –∏ –∑–Ω–∞—á–µ–Ω–∏—è, –∫–æ—Ç–æ—Ä—ã–µ –∏–º –±—ã–ª–∏ –ø—Ä–∏—Å–≤–æ–µ–Ω—ã:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç —Å–ª–µ–¥—É—é—â–µ–µ:

< p> –ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–ª –∫–ª—é—á–∏ –∏ –∑–Ω–∞—á–µ–Ω–∏—è –∫–∞–∂–¥–æ–≥–æ —ç–ª–µ–º–µ–Ω—Ç–∞ –≤ –Ω–∞—à–µ–º –æ–±—ä–µ–∫—Ç–µ ChainMap, –∫–æ–≥–¥–∞ –º—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞–ª–∏ –≤—ã—à–µ—É–ø–æ–º—è–Ω—É—Ç—ã–µ –º–µ—Ç–æ–¥—ã keys () –∏ values ‚Äã‚Äã().

–ö—Ä–æ–º–µ —Ç–æ–≥–æ, –≤—ã –º–æ–∂–µ—Ç–µ –¥–æ–±–∞–≤–∏—Ç—å –Ω–æ–≤—ã–π —Å–ª–æ–≤–∞—Ä—å –∫ –æ–±—ä–µ–∫—Ç—É ChainMap —Å –ø–æ–º–æ—â—å—é –º–µ—Ç–æ–¥–∞ new_child (). –î–æ–ø—É—Å—Ç–∏–º, –Ω–∞—à —à–µ—Ñ-–ø–æ–≤–∞—Ä –ø—Ä–æ–±–æ–≤–∞–ª –Ω–æ–≤—ã–µ –±—É—Ç–µ—Ä–±—Ä–æ–¥—ã –≤ —Ç–µ—Å—Ç–æ–≤–æ–º –º–µ–Ω—é –∏ —Ö–æ—á–µ—Ç –¥–æ–±–∞–≤–∏—Ç—å –¥–≤–∞ –∏–∑ –Ω–∏—Ö –≤ –Ω–∞—à–µ –Ω–æ–≤–æ–µ –º–µ–Ω—é. –î–ª—è –¥–æ—Å—Ç–∏–∂–µ–Ω–∏—è —ç—Ç–æ–π —Ü–µ–ª–∏ –º—ã –º–æ–≥–ª–∏ –±—ã –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å —Å–ª–µ–¥—É—é—â–∏–π –∫–æ–¥:

–ù–∞—à –∫–æ–¥ –≤–æ–∑–≤—Ä–∞—â–∞–µ—Ç –æ–±–Ω–æ–≤–ª–µ–Ω–Ω—É—é ChainMap —Å –Ω–∞—à–∏–º–∏ –Ω–æ–≤—ã–º–∏ –±—É—Ç–µ—Ä–±—Ä–æ–¥–∞–º–∏ –≤ –Ω–∞—á–∞–ª–µ —Å–ª–æ–≤–∞—Ä—è , –∞ –∏–º–µ–Ω–Ω–æ:

–ó–∞–∫–ª—é—á–µ–Ω–∏–µ

–ú—ã –º–æ–∂–µ–º –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å Python –ú–æ–¥—É–ª—å –∫–æ–ª–ª–µ–∫—Ü–∏–π –¥–ª—è —Ä–∞—Å—à–∏—Ä–µ–Ω–∏—è –≤—Å—Ç—Ä–æ–µ–Ω–Ω—ã—Ö –∫–æ–ª–ª–µ–∫—Ü–∏–π, –ø—Ä–µ–¥–ª–∞–≥–∞–µ–º—ã—Ö Python, –∏ –¥–ª—è –¥–æ—Å—Ç—É–ø–∞ –∫ –ø–æ–ª—å–∑–æ–≤–∞—Ç–µ–ª—å—Å–∫–∏–º –º–µ—Ç–æ–¥–∞–º —Å—Ç—Ä—É–∫—Ç—É—Ä—ã –¥–∞–Ω–Ω—ã—Ö. –≠—Ç–æ –ø–æ–ª–µ–∑–Ω–æ, –µ—Å–ª–∏ –≤—ã —Ö–æ—Ç–∏—Ç–µ —Ä–∞–±–æ—Ç–∞—Ç—å —Å —Ç–∏–ø–æ–º –¥–∞–Ω–Ω—ã—Ö –∫–æ–ª–ª–µ–∫—Ü–∏–∏, –Ω–∞–ø—Ä–∏–º–µ—Ä —Å–ø–∏—Å–∫–æ–º –∏–ª–∏ –∫–æ—Ä—Ç–µ–∂–µ–º, –Ω–æ –≤–∞–º –Ω—É–∂–Ω–æ –≤—ã–ø–æ–ª–Ω–∏—Ç—å –æ–ø—Ä–µ–¥–µ–ª–µ–Ω–Ω—É—é —Ñ—É–Ω–∫—Ü–∏—é, –∫–æ—Ç–æ—Ä–æ–π –Ω–µ—Ç –≤ –≤–∞–Ω–∏–ª—å–Ω–æ–º (–∏–ª–∏ plain) Python. < / p>

–í —ç—Ç–æ–º —Ä—É–∫–æ–≤–æ–¥—Å—Ç–≤–µ –Ω–∞ –ø—Ä–∏–º–µ—Ä–∞—Ö –º—ã —Ä–∞–∑–æ–±—Ä–∞–ª–∏, –∫–∞–∫ –∏—Å–ø–æ–ª—å–∑–æ–≤–∞—Ç—å –∫–æ–ª–ª–µ–∫—Ü–∏–∏ –≤ Python, –∏ –æ–±—Å—É–¥–∏–ª–∏ —á–µ—Ç—ã—Ä–µ –æ—Å–Ω–æ–≤–Ω—ã—Ö –º–µ—Ç–æ–¥–∞, –ø—Ä–µ–¥–ª–∞–≥–∞–µ–º—ã—Ö –±–∏–±–ª–∏–æ—Ç–µ–∫–æ–π: Counter, namedtuple , defaultdict –∏ ChainMap. & nbsp;

–¢–µ–ø–µ—Ä—å –≤—ã –≤–æ–æ—Ä—É–∂–µ–Ω—ã –∑–Ω–∞–Ω–∏—è–º–∏, –Ω–µ–æ–±—Ö–æ–¥–∏–º—ã–º–∏ –¥–ª—è –Ω–∞—á–∞–ª–∞ —Ä–∞–±–æ—Ç—ã —Å –º–æ–¥—É–ª–µ–º –∫–æ–ª–ª–µ–∫—Ü–∏–π Python –∫–∞–∫ —ç–∫—Å–ø–µ—Ä—Ç. !

–í–∞–º –∏–Ω—Ç–µ—Ä–µ—Å–Ω–æ —É–∑–Ω–∞—Ç—å, –∫–∞–∫ –∏–∑—É—á–µ–Ω–∏–µ Python –º–æ–∂–µ—Ç –ø–æ–º–æ—á—å –≤–∞–º —Å–¥–µ–ª–∞—Ç—å –∫–∞—Ä—å–µ—Ä—É –≤ —Å—Ñ–µ—Ä–µ —Ç–µ—Ö–Ω–æ–ª–æ–≥–∏–π? –ó–∞–≥—Ä—É–∑–∏—Ç–µ –±–µ—Å–ø–ª–∞—Ç–Ω–æ–µ –ø—Ä–∏–ª–æ–∂–µ–Ω–∏–µ Career Karma –ø—Ä—è–º–æ —Å–µ–π—á–∞—Å –∏ –ø–æ–≥–æ–≤–æ—Ä–∏—Ç–µ —Å –æ–¥–Ω–∏–º –∏–∑ –Ω–∞—à–∏—Ö –æ–ø—ã—Ç–Ω—ã—Ö –∫–∞—Ä—å–µ—Ä–Ω—ã—Ö —Ç—Ä–µ–Ω–µ—Ä–æ–≤!