[{"data":1,"prerenderedAt":4737},["ShallowReactive",2],{"tutorials-python-how-to":3,"category-items-python-how-to":600,"content-/python-how-to/use-context-managers":601},[4,22,31,40,49,58,67,76,86,94,103,112,121,130,139,148,158,167,176,185,194,203,212,222,231,240,249,258,267,276,285,297,306,315,324,333,342,351,362,371,380,389,398,407,418,427,436,445,454,463,472,483,492,501,510,519,528,539,548,557,566,575,584,593],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"slug":11,"order":12,"isParent":13,"icon":14,"_type":15,"_id":16,"_source":17,"_file":18,"_stem":19,"_extension":20,"children":21,"expanded":13},"/python-how-to/string-manipulation","python-how-to",false,"","String Manipulation","Learn essential string manipulation techniques in Python","string-manipulation",1,true,"pi pi-folder","markdown","content:python-how-to:1.string-manipulation.md","content","python-how-to/1.string-manipulation.md","python-how-to/1.string-manipulation","md",[22,31,40,49,58,67],{"_path":23,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":24,"description":25,"slug":26,"parentId":5,"order":27,"_type":15,"_id":28,"_source":17,"_file":29,"_stem":30,"_extension":20},"/python-how-to/split-join-strings","Split and Join Strings","Learn how to split strings into lists and join lists back into strings in Python","split-join-strings",2,"content:python-how-to:2.split-join-strings.md","python-how-to/2.split-join-strings.md","python-how-to/2.split-join-strings",{"_path":32,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":33,"description":34,"slug":35,"parentId":5,"order":36,"_type":15,"_id":37,"_source":17,"_file":38,"_stem":39,"_extension":20},"/python-how-to/remove-whitespace","Remove Whitespace","Learn how to clean up and remove unwanted whitespace from strings in Python","remove-whitespace",3,"content:python-how-to:3.remove-whitespace.md","python-how-to/3.remove-whitespace.md","python-how-to/3.remove-whitespace",{"_path":41,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":42,"description":43,"slug":44,"parentId":5,"order":45,"_type":15,"_id":46,"_source":17,"_file":47,"_stem":48,"_extension":20},"/python-how-to/find-replace-text","Find and Replace Text","Learn how to search for and replace text within strings in Python","find-replace-text",4,"content:python-how-to:4.find-replace-text.md","python-how-to/4.find-replace-text.md","python-how-to/4.find-replace-text",{"_path":50,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":51,"description":52,"slug":53,"parentId":5,"order":54,"_type":15,"_id":55,"_source":17,"_file":56,"_stem":57,"_extension":20},"/python-how-to/check-string-content","Check String Content","Learn how to validate and check the content of strings in Python","check-string-content",5,"content:python-how-to:5.check-string-content.md","python-how-to/5.check-string-content.md","python-how-to/5.check-string-content",{"_path":59,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":60,"description":61,"slug":62,"parentId":5,"order":63,"_type":15,"_id":64,"_source":17,"_file":65,"_stem":66,"_extension":20},"/python-how-to/format-strings","Format Strings","Learn how to format strings in Python using f-strings and format() method","format-strings",6,"content:python-how-to:6.format-strings.md","python-how-to/6.format-strings.md","python-how-to/6.format-strings",{"_path":68,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":69,"description":70,"slug":71,"parentId":5,"order":72,"_type":15,"_id":73,"_source":17,"_file":74,"_stem":75,"_extension":20},"/python-how-to/unicode-special-chars","Handle Unicode and Special Characters","Learn how to work with Unicode and special characters in Python strings","unicode-special-chars",7,"content:python-how-to:7.unicode-special-chars.md","python-how-to/7.unicode-special-chars.md","python-how-to/7.unicode-special-chars",{"_path":77,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":78,"description":79,"slug":80,"order":81,"isParent":13,"icon":14,"_type":15,"_id":82,"_source":17,"_file":83,"_stem":84,"_extension":20,"children":85,"expanded":13},"/python-how-to/list-operations","List Operations","Learn essential operations for working with lists in Python","list-operations",8,"content:python-how-to:8.list-operations.md","python-how-to/8.list-operations.md","python-how-to/8.list-operations",[86,94,103,112,121,130,139],{"_path":87,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":88,"description":89,"slug":90,"parentId":77,"order":81,"_type":15,"_id":91,"_source":17,"_file":92,"_stem":93,"_extension":20},"/python-how-to/sort-lists","Sort Lists","Learn how to sort lists in Python using different methods and custom sorting","sort-lists","content:python-how-to:9.sort-lists.md","python-how-to/9.sort-lists.md","python-how-to/9.sort-lists",{"_path":95,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":96,"description":97,"slug":98,"parentId":77,"order":99,"_type":15,"_id":100,"_source":17,"_file":101,"_stem":102,"_extension":20},"/python-how-to/remove-duplicates","Remove Duplicates","Learn how to remove duplicate elements from lists in Python","remove-duplicates",10,"content:python-how-to:10.remove-duplicates.md","python-how-to/10.remove-duplicates.md","python-how-to/10.remove-duplicates",{"_path":104,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":105,"description":106,"slug":107,"parentId":77,"order":108,"_type":15,"_id":109,"_source":17,"_file":110,"_stem":111,"_extension":20},"/python-how-to/filter-lists","Filter Lists","Learn how to filter lists in Python using different methods","filter-lists",11,"content:python-how-to:11.filter-lists.md","python-how-to/11.filter-lists.md","python-how-to/11.filter-lists",{"_path":113,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":114,"description":115,"slug":116,"parentId":77,"order":117,"_type":15,"_id":118,"_source":17,"_file":119,"_stem":120,"_extension":20},"/python-how-to/combine-lists","Combine Lists","Learn different methods to combine lists in Python","combine-lists",12,"content:python-how-to:12.combine-lists.md","python-how-to/12.combine-lists.md","python-how-to/12.combine-lists",{"_path":122,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":123,"description":124,"slug":125,"parentId":77,"order":126,"_type":15,"_id":127,"_source":17,"_file":128,"_stem":129,"_extension":20},"/python-how-to/list-comprehensions","Use List Comprehensions","Learn how to create and transform lists efficiently using Python's list comprehension syntax","list-comprehensions",13,"content:python-how-to:13.list-comprehensions.md","python-how-to/13.list-comprehensions.md","python-how-to/13.list-comprehensions",{"_path":131,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":132,"description":133,"slug":134,"parentId":77,"order":135,"_type":15,"_id":136,"_source":17,"_file":137,"_stem":138,"_extension":20},"/python-how-to/nested-lists","Work with Nested Lists","Learn how to work with nested lists (2D arrays) in Python","nested-lists",14,"content:python-how-to:14.nested-lists.md","python-how-to/14.nested-lists.md","python-how-to/14.nested-lists",{"_path":140,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":141,"description":142,"slug":143,"parentId":77,"order":144,"_type":15,"_id":145,"_source":17,"_file":146,"_stem":147,"_extension":20},"/python-how-to/enumerate-zip","Use enumerate() and zip()","Learn how to use enumerate() and zip() for efficient iteration in Python","enumerate-zip",15,"content:python-how-to:15.enumerate-zip.md","python-how-to/15.enumerate-zip.md","python-how-to/15.enumerate-zip",{"_path":149,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":150,"description":151,"slug":152,"order":153,"isParent":13,"icon":14,"_type":15,"_id":154,"_source":17,"_file":155,"_stem":156,"_extension":20,"children":157,"expanded":13},"/python-how-to/dictionary-operations","Dictionary Operations","Learn essential operations for working with dictionaries in Python","dictionary-operations",16,"content:python-how-to:16.dictionary-operations.md","python-how-to/16.dictionary-operations.md","python-how-to/16.dictionary-operations",[158,167,176,185,194,203],{"_path":159,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":160,"description":161,"slug":162,"parentId":149,"order":163,"_type":15,"_id":164,"_source":17,"_file":165,"_stem":166,"_extension":20},"/python-how-to/merge-dictionaries","Merge Dictionaries","Learn different methods to merge dictionaries in Python","merge-dictionaries",17,"content:python-how-to:17.merge-dictionaries.md","python-how-to/17.merge-dictionaries.md","python-how-to/17.merge-dictionaries",{"_path":168,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":169,"description":170,"slug":171,"parentId":149,"order":172,"_type":15,"_id":173,"_source":17,"_file":174,"_stem":175,"_extension":20},"/python-how-to/sort-dictionaries","Sort Dictionaries","Learn how to sort dictionaries by keys or values in Python","sort-dictionaries",18,"content:python-how-to:18.sort-dictionaries.md","python-how-to/18.sort-dictionaries.md","python-how-to/18.sort-dictionaries",{"_path":177,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":178,"description":179,"slug":180,"parentId":149,"order":181,"_type":15,"_id":182,"_source":17,"_file":183,"_stem":184,"_extension":20},"/python-how-to/filter-dictionaries","Filter Dictionaries","Learn how to filter dictionaries based on keys or values in Python","filter-dictionaries",19,"content:python-how-to:19.filter-dictionaries.md","python-how-to/19.filter-dictionaries.md","python-how-to/19.filter-dictionaries",{"_path":186,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":187,"description":188,"slug":189,"parentId":149,"order":190,"_type":15,"_id":191,"_source":17,"_file":192,"_stem":193,"_extension":20},"/python-how-to/handle-missing-keys","Handle Missing Keys","Learn safe ways to access dictionary keys and handle missing values","handle-missing-keys",20,"content:python-how-to:20.handle-missing-keys.md","python-how-to/20.handle-missing-keys.md","python-how-to/20.handle-missing-keys",{"_path":195,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":196,"description":197,"slug":198,"parentId":149,"order":199,"_type":15,"_id":200,"_source":17,"_file":201,"_stem":202,"_extension":20},"/python-how-to/dictionary-comprehensions","Use Dictionary Comprehensions","Learn how to create dictionaries efficiently using comprehensions","dictionary-comprehensions",21,"content:python-how-to:21.dictionary-comprehensions.md","python-how-to/21.dictionary-comprehensions.md","python-how-to/21.dictionary-comprehensions",{"_path":204,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":205,"description":206,"slug":207,"parentId":149,"order":208,"_type":15,"_id":209,"_source":17,"_file":210,"_stem":211,"_extension":20},"/python-how-to/convert-lists-dictionaries","Convert Between Lists and Dictionaries","Learn how to transform data between lists and dictionaries in Python","convert-lists-dictionaries",22,"content:python-how-to:22.convert-lists-dictionaries.md","python-how-to/22.convert-lists-dictionaries.md","python-how-to/22.convert-lists-dictionaries",{"_path":213,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":214,"description":215,"slug":216,"order":217,"isParent":13,"icon":14,"_type":15,"_id":218,"_source":17,"_file":219,"_stem":220,"_extension":20,"children":221,"expanded":13},"/python-how-to/file-operations","File Operations","Learn essential file operations in Python for reading, writing, and managing files","file-operations",23,"content:python-how-to:23.file-operations.md","python-how-to/23.file-operations.md","python-how-to/23.file-operations",[222,231,240,249,258,267,276],{"_path":223,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":224,"description":225,"slug":226,"parentId":213,"order":227,"_type":15,"_id":228,"_source":17,"_file":229,"_stem":230,"_extension":20},"/python-how-to/read-text-files","Read Text Files","Learn how to read text files in Python using different methods","read-text-files",24,"content:python-how-to:24.read-text-files.md","python-how-to/24.read-text-files.md","python-how-to/24.read-text-files",{"_path":232,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":233,"description":234,"slug":235,"parentId":213,"order":236,"_type":15,"_id":237,"_source":17,"_file":238,"_stem":239,"_extension":20},"/python-how-to/write-to-files","Write to Files","Learn how to write and create files in Python using different methods","write-to-files",25,"content:python-how-to:25.write-to-files.md","python-how-to/25.write-to-files.md","python-how-to/25.write-to-files",{"_path":241,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":242,"description":243,"slug":244,"parentId":213,"order":245,"_type":15,"_id":246,"_source":17,"_file":247,"_stem":248,"_extension":20},"/python-how-to/work-csv-files","Work with CSV Files","Learn how to read and write CSV files in Python using the csv module","work-csv-files",26,"content:python-how-to:26.work-csv-files.md","python-how-to/26.work-csv-files.md","python-how-to/26.work-csv-files",{"_path":250,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":251,"description":252,"slug":253,"parentId":213,"order":254,"_type":15,"_id":255,"_source":17,"_file":256,"_stem":257,"_extension":20},"/python-how-to/handle-file-paths","Handle File Paths","Learn how to work with file and directory paths in Python using pathlib and os modules","handle-file-paths",27,"content:python-how-to:27.handle-file-paths.md","python-how-to/27.handle-file-paths.md","python-how-to/27.handle-file-paths",{"_path":259,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":260,"description":261,"slug":262,"parentId":213,"order":263,"_type":15,"_id":264,"_source":17,"_file":265,"_stem":266,"_extension":20},"/python-how-to/work-json-files","Work with JSON Files","Learn how to read and write JSON files in Python using the json module","work-json-files",28,"content:python-how-to:28.work-json-files.md","python-how-to/28.work-json-files.md","python-how-to/28.work-json-files",{"_path":268,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":269,"description":270,"slug":271,"parentId":213,"order":272,"_type":15,"_id":273,"_source":17,"_file":274,"_stem":275,"_extension":20},"/python-how-to/handle-binary-files","Handle Binary Files","Learn how to work with binary files in Python for images, data, and other non-text content","handle-binary-files",29,"content:python-how-to:29.handle-binary-files.md","python-how-to/29.handle-binary-files.md","python-how-to/29.handle-binary-files",{"_path":277,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":278,"description":279,"slug":280,"parentId":213,"order":281,"_type":15,"_id":282,"_source":17,"_file":283,"_stem":284,"_extension":20},"/python-how-to/use-context-managers","Use Context Managers","Learn how to use context managers for safe resource handling in Python","use-context-managers",30,"content:python-how-to:30.use-context-managers.md","python-how-to/30.use-context-managers.md","python-how-to/30.use-context-managers",{"_path":286,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":287,"description":288,"slug":289,"parentId":290,"order":291,"isParent":13,"icon":292,"_type":15,"_id":293,"_source":17,"_file":294,"_stem":295,"_extension":20,"children":296},"/python-how-to/date-and-time","Date and Time","Master Python's date and time handling with datetime, time zones, formatting, and calculations","date-and-time","/python-how-to",31,"pi pi-calendar","content:python-how-to:31.date-and-time.md","python-how-to/31.date-and-time.md","python-how-to/31.date-and-time",[297,306,315,324,333,342],{"_path":298,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":299,"description":300,"slug":301,"parentId":286,"order":302,"_type":15,"_id":303,"_source":17,"_file":304,"_stem":305,"_extension":20},"/python-how-to/get-current-datetime","Get Current Date/Time","Learn how to get current date, time, and timestamps using Python's datetime module","get-current-datetime",32,"content:python-how-to:32.get-current-datetime.md","python-how-to/32.get-current-datetime.md","python-how-to/32.get-current-datetime",{"_path":307,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":308,"description":309,"slug":310,"parentId":286,"order":311,"_type":15,"_id":312,"_source":17,"_file":313,"_stem":314,"_extension":20},"/python-how-to/format-dates","Format Dates","Master date formatting with strftime, custom formats, and locale-aware formatting for user-friendly displays","format-dates",33,"content:python-how-to:33.format-dates.md","python-how-to/33.format-dates.md","python-how-to/33.format-dates",{"_path":316,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":317,"description":318,"slug":319,"parentId":286,"order":320,"_type":15,"_id":321,"_source":17,"_file":322,"_stem":323,"_extension":20},"/python-how-to/calculate-date-differences","Calculate Date Differences","Learn to calculate time differences, durations, and intervals using Python's timedelta for scheduling and analytics","calculate-date-differences",34,"content:python-how-to:34.calculate-date-differences.md","python-how-to/34.calculate-date-differences.md","python-how-to/34.calculate-date-differences",{"_path":325,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":326,"description":327,"slug":328,"parentId":286,"order":329,"_type":15,"_id":330,"_source":17,"_file":331,"_stem":332,"_extension":20},"/python-how-to/parse-date-strings","Parse Date Strings","Convert text dates into Python datetime objects using strptime, handle multiple formats, and validate date input","parse-date-strings",35,"content:python-how-to:35.parse-date-strings.md","python-how-to/35.parse-date-strings.md","python-how-to/35.parse-date-strings",{"_path":334,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":335,"description":336,"slug":337,"parentId":286,"order":338,"_type":15,"_id":339,"_source":17,"_file":340,"_stem":341,"_extension":20},"/python-how-to/handle-timezones","Handle Timezones","Master timezone handling with zoneinfo, UTC conversions, and timezone-aware datetime objects for global applications","handle-timezones",36,"content:python-how-to:36.handle-timezones.md","python-how-to/36.handle-timezones.md","python-how-to/36.handle-timezones",{"_path":343,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":344,"description":345,"slug":346,"parentId":286,"order":347,"_type":15,"_id":348,"_source":17,"_file":349,"_stem":350,"_extension":20},"/python-how-to/work-with-timestamps","Work with Timestamps","Master Unix timestamps in Python - convert between datetime objects and timestamps for APIs, databases, and system integration","work-with-timestamps",37,"content:python-how-to:37.work-with-timestamps.md","python-how-to/37.work-with-timestamps.md","python-how-to/37.work-with-timestamps",{"_path":352,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":353,"description":354,"slug":355,"parentId":290,"order":356,"isParent":13,"icon":357,"_type":15,"_id":358,"_source":17,"_file":359,"_stem":360,"_extension":20,"children":361},"/python-how-to/error-handling","Error Handling","Learn Python's error handling with try/except, custom exceptions, debugging, logging, and retry logic for robust applications","error-handling",38,"pi pi-exclamation-triangle","content:python-how-to:38.error-handling.md","python-how-to/38.error-handling.md","python-how-to/38.error-handling",[362,371,380,389,398],{"_path":363,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":364,"description":365,"slug":366,"parentId":352,"order":367,"_type":15,"_id":368,"_source":17,"_file":369,"_stem":370,"_extension":20},"/python-how-to/handle-exceptions","Handle Exceptions","Master try/except blocks, multiple exception handling, and finally clauses for robust error handling in Python","handle-exceptions",39,"content:python-how-to:39.handle-exceptions.md","python-how-to/39.handle-exceptions.md","python-how-to/39.handle-exceptions",{"_path":372,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":373,"description":374,"slug":375,"parentId":352,"order":376,"_type":15,"_id":377,"_source":17,"_file":378,"_stem":379,"_extension":20},"/python-how-to/create-custom-exceptions","Create Custom Exceptions","Learn to create custom exception classes in Python for specific error handling and better code organization","create-custom-exceptions",40,"content:python-how-to:40.create-custom-exceptions.md","python-how-to/40.create-custom-exceptions.md","python-how-to/40.create-custom-exceptions",{"_path":381,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":382,"description":383,"slug":384,"parentId":352,"order":385,"_type":15,"_id":386,"_source":17,"_file":387,"_stem":388,"_extension":20},"/python-how-to/debug-code","Debug Code","Learn Python debugging techniques using print statements, the debugger, and tools to find and fix code issues","debug-code",41,"content:python-how-to:41.debug-code.md","python-how-to/41.debug-code.md","python-how-to/41.debug-code",{"_path":390,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":391,"description":392,"slug":393,"parentId":352,"order":394,"_type":15,"_id":395,"_source":17,"_file":396,"_stem":397,"_extension":20},"/python-how-to/use-logging","Use Logging","Learn Python's logging module for tracking application behavior, errors, and debugging information","use-logging",42,"content:python-how-to:42.use-logging.md","python-how-to/42.use-logging.md","python-how-to/42.use-logging",{"_path":399,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":400,"description":401,"slug":402,"parentId":352,"order":403,"_type":15,"_id":404,"_source":17,"_file":405,"_stem":406,"_extension":20},"/python-how-to/implement-retry-logic","Implement Retry Logic","Learn to implement retry mechanisms in Python for handling temporary failures and building resilient applications","implement-retry-logic",43,"content:python-how-to:43.implement-retry-logic.md","python-how-to/43.implement-retry-logic.md","python-how-to/43.implement-retry-logic",{"_path":408,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":409,"description":410,"slug":411,"parentId":290,"order":412,"isParent":13,"icon":413,"_type":15,"_id":414,"_source":17,"_file":415,"_stem":416,"_extension":20,"children":417},"/python-how-to/functions-and-modules","Functions and Modules","Learn Python functions, modules, and code organization for building reusable, maintainable applications","functions-and-modules",44,"pi pi-box","content:python-how-to:44.functions-and-modules.md","python-how-to/44.functions-and-modules.md","python-how-to/44.functions-and-modules",[418,427,436,445,454,463],{"_path":419,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":420,"description":421,"slug":422,"parentId":408,"order":423,"_type":15,"_id":424,"_source":17,"_file":425,"_stem":426,"_extension":20},"/python-how-to/write-functions","Write Functions","Learn to create Python functions with parameters, return values, and documentation for reusable code","write-functions",45,"content:python-how-to:45.write-functions.md","python-how-to/45.write-functions.md","python-how-to/45.write-functions",{"_path":428,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":429,"description":430,"slug":431,"parentId":408,"order":432,"_type":15,"_id":433,"_source":17,"_file":434,"_stem":435,"_extension":20},"/python-how-to/use-args-kwargs","Use *args and **kwargs","Learn to use *args and **kwargs for flexible function arguments in Python","use-args-kwargs",46,"content:python-how-to:46.use-args-kwargs.md","python-how-to/46.use-args-kwargs.md","python-how-to/46.use-args-kwargs",{"_path":437,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":438,"description":439,"slug":440,"parentId":408,"order":441,"_type":15,"_id":442,"_source":17,"_file":443,"_stem":444,"_extension":20},"/python-how-to/create-decorators","Create Decorators","Learn to create and use Python decorators to enhance function behavior and add functionality","create-decorators",47,"content:python-how-to:47.create-decorators.md","python-how-to/47.create-decorators.md","python-how-to/47.create-decorators",{"_path":446,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":447,"description":448,"slug":449,"parentId":408,"order":450,"_type":15,"_id":451,"_source":17,"_file":452,"_stem":453,"_extension":20},"/python-how-to/use-generators","Use Generators","Learn to create memory-efficient generators with yield for processing large datasets and sequences","use-generators",48,"content:python-how-to:48.use-generators.md","python-how-to/48.use-generators.md","python-how-to/48.use-generators",{"_path":455,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":456,"description":457,"slug":458,"parentId":408,"order":459,"_type":15,"_id":460,"_source":17,"_file":461,"_stem":462,"_extension":20},"/python-how-to/work-modules-packages","Work with Modules and Packages","Learn to organize Python code with modules and packages, and use imports effectively","work-modules-packages",49,"content:python-how-to:49.work-modules-packages.md","python-how-to/49.work-modules-packages.md","python-how-to/49.work-modules-packages",{"_path":464,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":465,"description":466,"slug":467,"parentId":408,"order":468,"_type":15,"_id":469,"_source":17,"_file":470,"_stem":471,"_extension":20},"/python-how-to/create-virtual-environments","Create Virtual Environments","Learn to create and manage Python virtual environments for project dependency isolation","create-virtual-environments",50,"content:python-how-to:50.create-virtual-environments.md","python-how-to/50.create-virtual-environments.md","python-how-to/50.create-virtual-environments",{"_path":473,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":474,"description":475,"slug":476,"parentId":290,"order":477,"isParent":13,"icon":478,"_type":15,"_id":479,"_source":17,"_file":480,"_stem":481,"_extension":20,"children":482},"/python-how-to/data-processing","Data Processing","Learn Python data processing techniques including regex, APIs, databases, and large file handling","data-processing",51,"pi pi-database","content:python-how-to:51.data-processing.md","python-how-to/51.data-processing.md","python-how-to/51.data-processing",[483,492,501,510,519],{"_path":484,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":485,"description":486,"slug":487,"parentId":473,"order":488,"_type":15,"_id":489,"_source":17,"_file":490,"_stem":491,"_extension":20},"/python-how-to/work-regular-expressions","Work with Regular Expressions","Learn to use Python's re module for pattern matching, text extraction, and data validation","work-regular-expressions",52,"content:python-how-to:52.work-regular-expressions.md","python-how-to/52.work-regular-expressions.md","python-how-to/52.work-regular-expressions",{"_path":493,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":494,"description":495,"slug":496,"parentId":473,"order":497,"_type":15,"_id":498,"_source":17,"_file":499,"_stem":500,"_extension":20},"/python-how-to/parse-xml-html","Parse XML and HTML","Learn to extract data from XML and HTML documents using Python's built-in parsing tools","parse-xml-html",53,"content:python-how-to:53.parse-xml-html.md","python-how-to/53.parse-xml-html.md","python-how-to/53.parse-xml-html",{"_path":502,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":503,"description":504,"slug":505,"parentId":473,"order":506,"_type":15,"_id":507,"_source":17,"_file":508,"_stem":509,"_extension":20},"/python-how-to/handle-api-requests","Handle API Requests","Learn to fetch and process data from web APIs using Python's urllib and external requests library","handle-api-requests",54,"content:python-how-to:54.handle-api-requests.md","python-how-to/54.handle-api-requests.md","python-how-to/54.handle-api-requests",{"_path":511,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":512,"description":513,"slug":514,"parentId":473,"order":515,"_type":15,"_id":516,"_source":17,"_file":517,"_stem":518,"_extension":20},"/python-how-to/work-databases","Work with Databases","Learn to connect to and query SQL databases using Python's sqlite3 and database techniques","work-databases",55,"content:python-how-to:55.work-databases.md","python-how-to/55.work-databases.md","python-how-to/55.work-databases",{"_path":520,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":521,"description":522,"slug":523,"parentId":473,"order":524,"_type":15,"_id":525,"_source":17,"_file":526,"_stem":527,"_extension":20},"/python-how-to/process-large-files","Process Large Files","Learn memory-efficient techniques for handling large files and datasets in Python","process-large-files",56,"content:python-how-to:56.process-large-files.md","python-how-to/56.process-large-files.md","python-how-to/56.process-large-files",{"_path":529,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":530,"description":531,"slug":532,"parentId":290,"order":533,"isParent":13,"icon":534,"_type":15,"_id":535,"_source":17,"_file":536,"_stem":537,"_extension":20,"children":538},"/python-how-to/best-practices","Best Practices","Learn Python best practices for writing clean, maintainable, and efficient code","best-practices",57,"pi pi-star","content:python-how-to:57.best-practices.md","python-how-to/57.best-practices.md","python-how-to/57.best-practices",[539,548,557,566,575,584],{"_path":540,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":541,"description":542,"slug":543,"parentId":529,"order":544,"_type":15,"_id":545,"_source":17,"_file":546,"_stem":547,"_extension":20},"/python-how-to/structure-code","Structure Your Code","Learn to organize Python code with proper module structure, functions, and classes","structure-code",58,"content:python-how-to:58.structure-code.md","python-how-to/58.structure-code.md","python-how-to/58.structure-code",{"_path":549,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":550,"description":551,"slug":552,"parentId":529,"order":553,"_type":15,"_id":554,"_source":17,"_file":555,"_stem":556,"_extension":20},"/python-how-to/write-clean-code","Write Clean Code","Learn to write readable, maintainable Python code with proper naming, comments, and clear logic","write-clean-code",59,"content:python-how-to:59.write-clean-code.md","python-how-to/59.write-clean-code.md","python-how-to/59.write-clean-code",{"_path":558,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":559,"description":560,"slug":561,"parentId":529,"order":562,"_type":15,"_id":563,"_source":17,"_file":564,"_stem":565,"_extension":20},"/python-how-to/optimize-performance","Optimize Performance","Learn to identify and fix performance bottlenecks in Python code for faster execution","optimize-performance",60,"content:python-how-to:60.optimize-performance.md","python-how-to/60.optimize-performance.md","python-how-to/60.optimize-performance",{"_path":567,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":568,"description":569,"slug":570,"parentId":529,"order":571,"_type":15,"_id":572,"_source":17,"_file":573,"_stem":574,"_extension":20},"/python-how-to/write-unit-tests","Write Unit Tests","Learn to create reliable unit tests to verify your Python code works correctly and catch bugs early","write-unit-tests",61,"content:python-how-to:61.write-unit-tests.md","python-how-to/61.write-unit-tests.md","python-how-to/61.write-unit-tests",{"_path":576,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":577,"description":578,"slug":579,"parentId":529,"order":580,"_type":15,"_id":581,"_source":17,"_file":582,"_stem":583,"_extension":20},"/python-how-to/document-code","Document Your Code","Learn to write clear documentation and helpful comments for your Python code","document-code",62,"content:python-how-to:62.document-code.md","python-how-to/62.document-code.md","python-how-to/62.document-code",{"_path":585,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":586,"description":587,"slug":588,"parentId":529,"order":589,"_type":15,"_id":590,"_source":17,"_file":591,"_stem":592,"_extension":20},"/python-how-to/use-type-hints","Use Type Hints","Learn to add type annotations to Python code for better clarity, tooling support, and error detection","use-type-hints",63,"content:python-how-to:63.use-type-hints.md","python-how-to/63.use-type-hints.md","python-how-to/63.use-type-hints",{"_path":290,"_dir":8,"_draft":7,"_partial":7,"_locale":8,"title":594,"description":595,"slug":6,"order":596,"icon":14,"_type":15,"_id":597,"_source":17,"_file":598,"_stem":599,"_extension":20},"Python How-To Guide","Practical Python tutorials for common programming tasks. Learn step-by-step solutions for string manipulation, file operations, data processing, and more with real-world examples.",0,"content:python-how-to:index.md","python-how-to/index.md","python-how-to/index",[276],{"_path":277,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":278,"description":279,"slug":280,"parentId":213,"order":281,"body":602,"_type":15,"_id":282,"_source":17,"_file":283,"_stem":284,"_extension":20},{"type":603,"children":604,"toc":4720},"root",[605,614,629,754,761,766,854,861,1199,1205,1429,1435,1937,1943,2258,2264,2269,2275,2637,2643,3004,3008,3364,3370,3784,3790,4406,4412,4580,4586,4714],{"type":606,"tag":607,"props":608,"children":610},"element","h1",{"id":609},"using-context-managers",[611],{"type":612,"value":613},"text","🔒 Using Context Managers",{"type":606,"tag":615,"props":616,"children":617},"p",{},[618,620,627],{"type":612,"value":619},"Context managers provide a clean way to handle resources that need setup and cleanup. The ",{"type":606,"tag":621,"props":622,"children":624},"code",{"className":623},[],[625],{"type":612,"value":626},"with",{"type":612,"value":628}," statement ensures proper resource management, even when errors occur.",{"type":606,"tag":630,"props":631,"children":632},"code-try",{},[633],{"type":606,"tag":634,"props":635,"children":639},"pre",{"className":636,"code":637,"language":638,"meta":8,"style":8},"language-python shiki shiki-themes github-light github-dark","# Basic context manager usage\nwith open('example.txt', 'r') as file:\n    content = file.read()\n    print(content)\n# File is automatically closed here\n","python",[640],{"type":606,"tag":621,"props":641,"children":642},{"__ignoreMap":8},[643,654,711,733,746],{"type":606,"tag":644,"props":645,"children":647},"span",{"class":646,"line":12},"line",[648],{"type":606,"tag":644,"props":649,"children":651},{"style":650},"--shiki-default:#6A737D;--shiki-app-dark-mode:#6A737D",[652],{"type":612,"value":653},"# Basic context manager usage\n",{"type":606,"tag":644,"props":655,"children":656},{"class":646,"line":27},[657,662,668,674,680,685,690,695,700,706],{"type":606,"tag":644,"props":658,"children":660},{"style":659},"--shiki-default:#D73A49;--shiki-app-dark-mode:#F97583",[661],{"type":612,"value":626},{"type":606,"tag":644,"props":663,"children":665},{"style":664},"--shiki-default:#005CC5;--shiki-app-dark-mode:#79B8FF",[666],{"type":612,"value":667}," open",{"type":606,"tag":644,"props":669,"children":671},{"style":670},"--shiki-default:#24292E;--shiki-app-dark-mode:#E1E4E8",[672],{"type":612,"value":673},"(",{"type":606,"tag":644,"props":675,"children":677},{"style":676},"--shiki-default:#032F62;--shiki-app-dark-mode:#9ECBFF",[678],{"type":612,"value":679},"'example.txt'",{"type":606,"tag":644,"props":681,"children":682},{"style":670},[683],{"type":612,"value":684},", ",{"type":606,"tag":644,"props":686,"children":687},{"style":676},[688],{"type":612,"value":689},"'r'",{"type":606,"tag":644,"props":691,"children":692},{"style":670},[693],{"type":612,"value":694},") ",{"type":606,"tag":644,"props":696,"children":697},{"style":659},[698],{"type":612,"value":699},"as",{"type":606,"tag":644,"props":701,"children":703},{"style":702},"--shiki-default:#E36209;--shiki-app-dark-mode:#FFAB70",[704],{"type":612,"value":705}," file",{"type":606,"tag":644,"props":707,"children":708},{"style":670},[709],{"type":612,"value":710},":\n",{"type":606,"tag":644,"props":712,"children":713},{"class":646,"line":36},[714,719,724,728],{"type":606,"tag":644,"props":715,"children":716},{"style":670},[717],{"type":612,"value":718},"    content ",{"type":606,"tag":644,"props":720,"children":721},{"style":659},[722],{"type":612,"value":723},"=",{"type":606,"tag":644,"props":725,"children":726},{"style":702},[727],{"type":612,"value":705},{"type":606,"tag":644,"props":729,"children":730},{"style":670},[731],{"type":612,"value":732},".read()\n",{"type":606,"tag":644,"props":734,"children":735},{"class":646,"line":45},[736,741],{"type":606,"tag":644,"props":737,"children":738},{"style":664},[739],{"type":612,"value":740},"    print",{"type":606,"tag":644,"props":742,"children":743},{"style":670},[744],{"type":612,"value":745},"(content)\n",{"type":606,"tag":644,"props":747,"children":748},{"class":646,"line":54},[749],{"type":606,"tag":644,"props":750,"children":751},{"style":650},[752],{"type":612,"value":753},"# File is automatically closed here\n",{"type":606,"tag":755,"props":756,"children":758},"h2",{"id":757},"context-manager-benefits",[759],{"type":612,"value":760},"🎯 Context Manager Benefits",{"type":606,"tag":615,"props":762,"children":763},{},[764],{"type":612,"value":765},"Context managers provide several advantages for resource management.",{"type":606,"tag":767,"props":768,"children":772},"info-box",{"emoji":769,"title":770,"type":771},"📝","Context Manager Benefits","info",[773,782,802,810,828,836],{"type":606,"tag":615,"props":774,"children":775},{},[776],{"type":606,"tag":777,"props":778,"children":779},"strong",{},[780],{"type":612,"value":781},"Automatic Cleanup:",{"type":606,"tag":783,"props":784,"children":785},"ul",{},[786,792,797],{"type":606,"tag":787,"props":788,"children":789},"li",{},[790],{"type":612,"value":791},"Resources are always released",{"type":606,"tag":787,"props":793,"children":794},{},[795],{"type":612,"value":796},"Works even with exceptions",{"type":606,"tag":787,"props":798,"children":799},{},[800],{"type":612,"value":801},"No need to remember to close",{"type":606,"tag":615,"props":803,"children":804},{},[805],{"type":606,"tag":777,"props":806,"children":807},{},[808],{"type":612,"value":809},"Error Safety:",{"type":606,"tag":783,"props":811,"children":812},{},[813,818,823],{"type":606,"tag":787,"props":814,"children":815},{},[816],{"type":612,"value":817},"Exception handling built-in",{"type":606,"tag":787,"props":819,"children":820},{},[821],{"type":612,"value":822},"Guaranteed cleanup",{"type":606,"tag":787,"props":824,"children":825},{},[826],{"type":612,"value":827},"Prevents resource leaks",{"type":606,"tag":615,"props":829,"children":830},{},[831],{"type":606,"tag":777,"props":832,"children":833},{},[834],{"type":612,"value":835},"Code Clarity:",{"type":606,"tag":783,"props":837,"children":838},{},[839,844,849],{"type":606,"tag":787,"props":840,"children":841},{},[842],{"type":612,"value":843},"Clear resource boundaries",{"type":606,"tag":787,"props":845,"children":846},{},[847],{"type":612,"value":848},"Readable and maintainable",{"type":606,"tag":787,"props":850,"children":851},{},[852],{"type":612,"value":853},"Pythonic approach",{"type":606,"tag":855,"props":856,"children":858},"h3",{"id":857},"file-operations-with-context-managers",[859],{"type":612,"value":860},"File Operations with Context Managers",{"type":606,"tag":630,"props":862,"children":863},{},[864],{"type":606,"tag":634,"props":865,"children":867},{"className":636,"code":866,"language":638,"meta":8,"style":8},"# Safe file operations with context managers\ndef safe_file_operations():\n    # Reading files\n    try:\n        with open('data.txt', 'r') as file:\n            lines = file.readlines()\n            print(f\"Read {len(lines)} lines\")\n    except FileNotFoundError:\n        print(\"File not found\")\n\n    # Writing files\n    with open('output.txt', 'w') as file:\n        file.write(\"Hello, context managers!\")\n        file.write(\"\\nAutomatic cleanup!\")\n\nsafe_file_operations()\n",[868],{"type":606,"tag":621,"props":869,"children":870},{"__ignoreMap":8},[871,879,898,906,918,963,984,1031,1048,1070,1078,1086,1132,1154,1184,1191],{"type":606,"tag":644,"props":872,"children":873},{"class":646,"line":12},[874],{"type":606,"tag":644,"props":875,"children":876},{"style":650},[877],{"type":612,"value":878},"# Safe file operations with context managers\n",{"type":606,"tag":644,"props":880,"children":881},{"class":646,"line":27},[882,887,893],{"type":606,"tag":644,"props":883,"children":884},{"style":659},[885],{"type":612,"value":886},"def",{"type":606,"tag":644,"props":888,"children":890},{"style":889},"--shiki-default:#6F42C1;--shiki-app-dark-mode:#B392F0",[891],{"type":612,"value":892}," safe_file_operations",{"type":606,"tag":644,"props":894,"children":895},{"style":670},[896],{"type":612,"value":897},"():\n",{"type":606,"tag":644,"props":899,"children":900},{"class":646,"line":36},[901],{"type":606,"tag":644,"props":902,"children":903},{"style":650},[904],{"type":612,"value":905},"    # Reading files\n",{"type":606,"tag":644,"props":907,"children":908},{"class":646,"line":45},[909,914],{"type":606,"tag":644,"props":910,"children":911},{"style":659},[912],{"type":612,"value":913},"    try",{"type":606,"tag":644,"props":915,"children":916},{"style":670},[917],{"type":612,"value":710},{"type":606,"tag":644,"props":919,"children":920},{"class":646,"line":54},[921,926,930,934,939,943,947,951,955,959],{"type":606,"tag":644,"props":922,"children":923},{"style":659},[924],{"type":612,"value":925},"        with",{"type":606,"tag":644,"props":927,"children":928},{"style":664},[929],{"type":612,"value":667},{"type":606,"tag":644,"props":931,"children":932},{"style":670},[933],{"type":612,"value":673},{"type":606,"tag":644,"props":935,"children":936},{"style":676},[937],{"type":612,"value":938},"'data.txt'",{"type":606,"tag":644,"props":940,"children":941},{"style":670},[942],{"type":612,"value":684},{"type":606,"tag":644,"props":944,"children":945},{"style":676},[946],{"type":612,"value":689},{"type":606,"tag":644,"props":948,"children":949},{"style":670},[950],{"type":612,"value":694},{"type":606,"tag":644,"props":952,"children":953},{"style":659},[954],{"type":612,"value":699},{"type":606,"tag":644,"props":956,"children":957},{"style":702},[958],{"type":612,"value":705},{"type":606,"tag":644,"props":960,"children":961},{"style":670},[962],{"type":612,"value":710},{"type":606,"tag":644,"props":964,"children":965},{"class":646,"line":63},[966,971,975,979],{"type":606,"tag":644,"props":967,"children":968},{"style":670},[969],{"type":612,"value":970},"            lines ",{"type":606,"tag":644,"props":972,"children":973},{"style":659},[974],{"type":612,"value":723},{"type":606,"tag":644,"props":976,"children":977},{"style":702},[978],{"type":612,"value":705},{"type":606,"tag":644,"props":980,"children":981},{"style":670},[982],{"type":612,"value":983},".readlines()\n",{"type":606,"tag":644,"props":985,"children":986},{"class":646,"line":72},[987,992,996,1001,1006,1011,1016,1021,1026],{"type":606,"tag":644,"props":988,"children":989},{"style":664},[990],{"type":612,"value":991},"            print",{"type":606,"tag":644,"props":993,"children":994},{"style":670},[995],{"type":612,"value":673},{"type":606,"tag":644,"props":997,"children":998},{"style":659},[999],{"type":612,"value":1000},"f",{"type":606,"tag":644,"props":1002,"children":1003},{"style":676},[1004],{"type":612,"value":1005},"\"Read ",{"type":606,"tag":644,"props":1007,"children":1008},{"style":664},[1009],{"type":612,"value":1010},"{len",{"type":606,"tag":644,"props":1012,"children":1013},{"style":670},[1014],{"type":612,"value":1015},"(lines)",{"type":606,"tag":644,"props":1017,"children":1018},{"style":664},[1019],{"type":612,"value":1020},"}",{"type":606,"tag":644,"props":1022,"children":1023},{"style":676},[1024],{"type":612,"value":1025}," lines\"",{"type":606,"tag":644,"props":1027,"children":1028},{"style":670},[1029],{"type":612,"value":1030},")\n",{"type":606,"tag":644,"props":1032,"children":1033},{"class":646,"line":81},[1034,1039,1044],{"type":606,"tag":644,"props":1035,"children":1036},{"style":659},[1037],{"type":612,"value":1038},"    except",{"type":606,"tag":644,"props":1040,"children":1041},{"style":664},[1042],{"type":612,"value":1043}," FileNotFoundError",{"type":606,"tag":644,"props":1045,"children":1046},{"style":670},[1047],{"type":612,"value":710},{"type":606,"tag":644,"props":1049,"children":1051},{"class":646,"line":1050},9,[1052,1057,1061,1066],{"type":606,"tag":644,"props":1053,"children":1054},{"style":664},[1055],{"type":612,"value":1056},"        print",{"type":606,"tag":644,"props":1058,"children":1059},{"style":670},[1060],{"type":612,"value":673},{"type":606,"tag":644,"props":1062,"children":1063},{"style":676},[1064],{"type":612,"value":1065},"\"File not found\"",{"type":606,"tag":644,"props":1067,"children":1068},{"style":670},[1069],{"type":612,"value":1030},{"type":606,"tag":644,"props":1071,"children":1072},{"class":646,"line":99},[1073],{"type":606,"tag":644,"props":1074,"children":1075},{"emptyLinePlaceholder":13},[1076],{"type":612,"value":1077},"\n",{"type":606,"tag":644,"props":1079,"children":1080},{"class":646,"line":108},[1081],{"type":606,"tag":644,"props":1082,"children":1083},{"style":650},[1084],{"type":612,"value":1085},"    # Writing files\n",{"type":606,"tag":644,"props":1087,"children":1088},{"class":646,"line":117},[1089,1094,1098,1102,1107,1111,1116,1120,1124,1128],{"type":606,"tag":644,"props":1090,"children":1091},{"style":659},[1092],{"type":612,"value":1093},"    with",{"type":606,"tag":644,"props":1095,"children":1096},{"style":664},[1097],{"type":612,"value":667},{"type":606,"tag":644,"props":1099,"children":1100},{"style":670},[1101],{"type":612,"value":673},{"type":606,"tag":644,"props":1103,"children":1104},{"style":676},[1105],{"type":612,"value":1106},"'output.txt'",{"type":606,"tag":644,"props":1108,"children":1109},{"style":670},[1110],{"type":612,"value":684},{"type":606,"tag":644,"props":1112,"children":1113},{"style":676},[1114],{"type":612,"value":1115},"'w'",{"type":606,"tag":644,"props":1117,"children":1118},{"style":670},[1119],{"type":612,"value":694},{"type":606,"tag":644,"props":1121,"children":1122},{"style":659},[1123],{"type":612,"value":699},{"type":606,"tag":644,"props":1125,"children":1126},{"style":702},[1127],{"type":612,"value":705},{"type":606,"tag":644,"props":1129,"children":1130},{"style":670},[1131],{"type":612,"value":710},{"type":606,"tag":644,"props":1133,"children":1134},{"class":646,"line":126},[1135,1140,1145,1150],{"type":606,"tag":644,"props":1136,"children":1137},{"style":702},[1138],{"type":612,"value":1139},"        file",{"type":606,"tag":644,"props":1141,"children":1142},{"style":670},[1143],{"type":612,"value":1144},".write(",{"type":606,"tag":644,"props":1146,"children":1147},{"style":676},[1148],{"type":612,"value":1149},"\"Hello, context managers!\"",{"type":606,"tag":644,"props":1151,"children":1152},{"style":670},[1153],{"type":612,"value":1030},{"type":606,"tag":644,"props":1155,"children":1156},{"class":646,"line":135},[1157,1161,1165,1170,1175,1180],{"type":606,"tag":644,"props":1158,"children":1159},{"style":702},[1160],{"type":612,"value":1139},{"type":606,"tag":644,"props":1162,"children":1163},{"style":670},[1164],{"type":612,"value":1144},{"type":606,"tag":644,"props":1166,"children":1167},{"style":676},[1168],{"type":612,"value":1169},"\"",{"type":606,"tag":644,"props":1171,"children":1172},{"style":664},[1173],{"type":612,"value":1174},"\\n",{"type":606,"tag":644,"props":1176,"children":1177},{"style":676},[1178],{"type":612,"value":1179},"Automatic cleanup!\"",{"type":606,"tag":644,"props":1181,"children":1182},{"style":670},[1183],{"type":612,"value":1030},{"type":606,"tag":644,"props":1185,"children":1186},{"class":646,"line":144},[1187],{"type":606,"tag":644,"props":1188,"children":1189},{"emptyLinePlaceholder":13},[1190],{"type":612,"value":1077},{"type":606,"tag":644,"props":1192,"children":1193},{"class":646,"line":153},[1194],{"type":606,"tag":644,"props":1195,"children":1196},{"style":670},[1197],{"type":612,"value":1198},"safe_file_operations()\n",{"type":606,"tag":855,"props":1200,"children":1202},{"id":1201},"multiple-file-handling",[1203],{"type":612,"value":1204},"Multiple File Handling",{"type":606,"tag":630,"props":1206,"children":1207},{},[1208],{"type":606,"tag":634,"props":1209,"children":1211},{"className":636,"code":1210,"language":638,"meta":8,"style":8},"# Working with multiple files\ndef process_multiple_files():\n    try:\n        # Multiple files in one context\n        with open('input.txt', 'r') as infile, open('backup.txt', 'w') as outfile:\n            content = infile.read()\n            outfile.write(content)\n            print(\"File copying completed\")\n    except FileNotFoundError:\n        print(\"Input file not found\")\n\nprocess_multiple_files()\n",[1212],{"type":606,"tag":621,"props":1213,"children":1214},{"__ignoreMap":8},[1215,1223,1239,1250,1258,1334,1351,1359,1379,1394,1414,1421],{"type":606,"tag":644,"props":1216,"children":1217},{"class":646,"line":12},[1218],{"type":606,"tag":644,"props":1219,"children":1220},{"style":650},[1221],{"type":612,"value":1222},"# Working with multiple files\n",{"type":606,"tag":644,"props":1224,"children":1225},{"class":646,"line":27},[1226,1230,1235],{"type":606,"tag":644,"props":1227,"children":1228},{"style":659},[1229],{"type":612,"value":886},{"type":606,"tag":644,"props":1231,"children":1232},{"style":889},[1233],{"type":612,"value":1234}," process_multiple_files",{"type":606,"tag":644,"props":1236,"children":1237},{"style":670},[1238],{"type":612,"value":897},{"type":606,"tag":644,"props":1240,"children":1241},{"class":646,"line":36},[1242,1246],{"type":606,"tag":644,"props":1243,"children":1244},{"style":659},[1245],{"type":612,"value":913},{"type":606,"tag":644,"props":1247,"children":1248},{"style":670},[1249],{"type":612,"value":710},{"type":606,"tag":644,"props":1251,"children":1252},{"class":646,"line":45},[1253],{"type":606,"tag":644,"props":1254,"children":1255},{"style":650},[1256],{"type":612,"value":1257},"        # Multiple files in one context\n",{"type":606,"tag":644,"props":1259,"children":1260},{"class":646,"line":54},[1261,1265,1269,1273,1278,1282,1286,1290,1294,1299,1304,1308,1313,1317,1321,1325,1329],{"type":606,"tag":644,"props":1262,"children":1263},{"style":659},[1264],{"type":612,"value":925},{"type":606,"tag":644,"props":1266,"children":1267},{"style":664},[1268],{"type":612,"value":667},{"type":606,"tag":644,"props":1270,"children":1271},{"style":670},[1272],{"type":612,"value":673},{"type":606,"tag":644,"props":1274,"children":1275},{"style":676},[1276],{"type":612,"value":1277},"'input.txt'",{"type":606,"tag":644,"props":1279,"children":1280},{"style":670},[1281],{"type":612,"value":684},{"type":606,"tag":644,"props":1283,"children":1284},{"style":676},[1285],{"type":612,"value":689},{"type":606,"tag":644,"props":1287,"children":1288},{"style":670},[1289],{"type":612,"value":694},{"type":606,"tag":644,"props":1291,"children":1292},{"style":659},[1293],{"type":612,"value":699},{"type":606,"tag":644,"props":1295,"children":1296},{"style":670},[1297],{"type":612,"value":1298}," infile, ",{"type":606,"tag":644,"props":1300,"children":1301},{"style":664},[1302],{"type":612,"value":1303},"open",{"type":606,"tag":644,"props":1305,"children":1306},{"style":670},[1307],{"type":612,"value":673},{"type":606,"tag":644,"props":1309,"children":1310},{"style":676},[1311],{"type":612,"value":1312},"'backup.txt'",{"type":606,"tag":644,"props":1314,"children":1315},{"style":670},[1316],{"type":612,"value":684},{"type":606,"tag":644,"props":1318,"children":1319},{"style":676},[1320],{"type":612,"value":1115},{"type":606,"tag":644,"props":1322,"children":1323},{"style":670},[1324],{"type":612,"value":694},{"type":606,"tag":644,"props":1326,"children":1327},{"style":659},[1328],{"type":612,"value":699},{"type":606,"tag":644,"props":1330,"children":1331},{"style":670},[1332],{"type":612,"value":1333}," outfile:\n",{"type":606,"tag":644,"props":1335,"children":1336},{"class":646,"line":63},[1337,1342,1346],{"type":606,"tag":644,"props":1338,"children":1339},{"style":670},[1340],{"type":612,"value":1341},"            content ",{"type":606,"tag":644,"props":1343,"children":1344},{"style":659},[1345],{"type":612,"value":723},{"type":606,"tag":644,"props":1347,"children":1348},{"style":670},[1349],{"type":612,"value":1350}," infile.read()\n",{"type":606,"tag":644,"props":1352,"children":1353},{"class":646,"line":72},[1354],{"type":606,"tag":644,"props":1355,"children":1356},{"style":670},[1357],{"type":612,"value":1358},"            outfile.write(content)\n",{"type":606,"tag":644,"props":1360,"children":1361},{"class":646,"line":81},[1362,1366,1370,1375],{"type":606,"tag":644,"props":1363,"children":1364},{"style":664},[1365],{"type":612,"value":991},{"type":606,"tag":644,"props":1367,"children":1368},{"style":670},[1369],{"type":612,"value":673},{"type":606,"tag":644,"props":1371,"children":1372},{"style":676},[1373],{"type":612,"value":1374},"\"File copying completed\"",{"type":606,"tag":644,"props":1376,"children":1377},{"style":670},[1378],{"type":612,"value":1030},{"type":606,"tag":644,"props":1380,"children":1381},{"class":646,"line":1050},[1382,1386,1390],{"type":606,"tag":644,"props":1383,"children":1384},{"style":659},[1385],{"type":612,"value":1038},{"type":606,"tag":644,"props":1387,"children":1388},{"style":664},[1389],{"type":612,"value":1043},{"type":606,"tag":644,"props":1391,"children":1392},{"style":670},[1393],{"type":612,"value":710},{"type":606,"tag":644,"props":1395,"children":1396},{"class":646,"line":99},[1397,1401,1405,1410],{"type":606,"tag":644,"props":1398,"children":1399},{"style":664},[1400],{"type":612,"value":1056},{"type":606,"tag":644,"props":1402,"children":1403},{"style":670},[1404],{"type":612,"value":673},{"type":606,"tag":644,"props":1406,"children":1407},{"style":676},[1408],{"type":612,"value":1409},"\"Input file not found\"",{"type":606,"tag":644,"props":1411,"children":1412},{"style":670},[1413],{"type":612,"value":1030},{"type":606,"tag":644,"props":1415,"children":1416},{"class":646,"line":108},[1417],{"type":606,"tag":644,"props":1418,"children":1419},{"emptyLinePlaceholder":13},[1420],{"type":612,"value":1077},{"type":606,"tag":644,"props":1422,"children":1423},{"class":646,"line":117},[1424],{"type":606,"tag":644,"props":1425,"children":1426},{"style":670},[1427],{"type":612,"value":1428},"process_multiple_files()\n",{"type":606,"tag":855,"props":1430,"children":1432},{"id":1431},"custom-context-manager-class",[1433],{"type":612,"value":1434},"Custom Context Manager Class",{"type":606,"tag":630,"props":1436,"children":1437},{},[1438],{"type":606,"tag":634,"props":1439,"children":1441},{"className":636,"code":1440,"language":638,"meta":8,"style":8},"# Custom context manager using class\nclass FileManager:\n    def __init__(self, filename, mode):\n        self.filename = filename\n        self.mode = mode\n        self.file = None\n    \n    def __enter__(self):\n        print(f\"Opening {self.filename}\")\n        self.file = open(self.filename, self.mode)\n        return self.file\n    \n    def __exit__(self, exc_type, exc_value, traceback):\n        print(f\"Closing {self.filename}\")\n        if self.file:\n            self.file.close()\n        \n        # Handle exceptions\n        if exc_type:\n            print(f\"Exception occurred: {exc_value}\")\n        return False  # Don't suppress exceptions\n\n# Using custom context manager\nwith FileManager('test.txt', 'w') as file:\n    file.write(\"Custom context manager!\")\n",[1442],{"type":606,"tag":621,"props":1443,"children":1444},{"__ignoreMap":8},[1445,1453,1470,1488,1510,1531,1552,1560,1577,1619,1661,1679,1686,1703,1743,1760,1773,1781,1789,1801,1843,1860,1867,1875,1916],{"type":606,"tag":644,"props":1446,"children":1447},{"class":646,"line":12},[1448],{"type":606,"tag":644,"props":1449,"children":1450},{"style":650},[1451],{"type":612,"value":1452},"# Custom context manager using class\n",{"type":606,"tag":644,"props":1454,"children":1455},{"class":646,"line":27},[1456,1461,1466],{"type":606,"tag":644,"props":1457,"children":1458},{"style":659},[1459],{"type":612,"value":1460},"class",{"type":606,"tag":644,"props":1462,"children":1463},{"style":889},[1464],{"type":612,"value":1465}," FileManager",{"type":606,"tag":644,"props":1467,"children":1468},{"style":670},[1469],{"type":612,"value":710},{"type":606,"tag":644,"props":1471,"children":1472},{"class":646,"line":36},[1473,1478,1483],{"type":606,"tag":644,"props":1474,"children":1475},{"style":659},[1476],{"type":612,"value":1477},"    def",{"type":606,"tag":644,"props":1479,"children":1480},{"style":664},[1481],{"type":612,"value":1482}," __init__",{"type":606,"tag":644,"props":1484,"children":1485},{"style":670},[1486],{"type":612,"value":1487},"(self, filename, mode):\n",{"type":606,"tag":644,"props":1489,"children":1490},{"class":646,"line":45},[1491,1496,1501,1505],{"type":606,"tag":644,"props":1492,"children":1493},{"style":664},[1494],{"type":612,"value":1495},"        self",{"type":606,"tag":644,"props":1497,"children":1498},{"style":670},[1499],{"type":612,"value":1500},".filename ",{"type":606,"tag":644,"props":1502,"children":1503},{"style":659},[1504],{"type":612,"value":723},{"type":606,"tag":644,"props":1506,"children":1507},{"style":670},[1508],{"type":612,"value":1509}," filename\n",{"type":606,"tag":644,"props":1511,"children":1512},{"class":646,"line":54},[1513,1517,1522,1526],{"type":606,"tag":644,"props":1514,"children":1515},{"style":664},[1516],{"type":612,"value":1495},{"type":606,"tag":644,"props":1518,"children":1519},{"style":670},[1520],{"type":612,"value":1521},".mode ",{"type":606,"tag":644,"props":1523,"children":1524},{"style":659},[1525],{"type":612,"value":723},{"type":606,"tag":644,"props":1527,"children":1528},{"style":670},[1529],{"type":612,"value":1530}," mode\n",{"type":606,"tag":644,"props":1532,"children":1533},{"class":646,"line":63},[1534,1538,1543,1547],{"type":606,"tag":644,"props":1535,"children":1536},{"style":664},[1537],{"type":612,"value":1495},{"type":606,"tag":644,"props":1539,"children":1540},{"style":670},[1541],{"type":612,"value":1542},".file ",{"type":606,"tag":644,"props":1544,"children":1545},{"style":659},[1546],{"type":612,"value":723},{"type":606,"tag":644,"props":1548,"children":1549},{"style":664},[1550],{"type":612,"value":1551}," None\n",{"type":606,"tag":644,"props":1553,"children":1554},{"class":646,"line":72},[1555],{"type":606,"tag":644,"props":1556,"children":1557},{"style":670},[1558],{"type":612,"value":1559},"    \n",{"type":606,"tag":644,"props":1561,"children":1562},{"class":646,"line":81},[1563,1567,1572],{"type":606,"tag":644,"props":1564,"children":1565},{"style":659},[1566],{"type":612,"value":1477},{"type":606,"tag":644,"props":1568,"children":1569},{"style":664},[1570],{"type":612,"value":1571}," __enter__",{"type":606,"tag":644,"props":1573,"children":1574},{"style":670},[1575],{"type":612,"value":1576},"(self):\n",{"type":606,"tag":644,"props":1578,"children":1579},{"class":646,"line":1050},[1580,1584,1588,1592,1597,1602,1607,1611,1615],{"type":606,"tag":644,"props":1581,"children":1582},{"style":664},[1583],{"type":612,"value":1056},{"type":606,"tag":644,"props":1585,"children":1586},{"style":670},[1587],{"type":612,"value":673},{"type":606,"tag":644,"props":1589,"children":1590},{"style":659},[1591],{"type":612,"value":1000},{"type":606,"tag":644,"props":1593,"children":1594},{"style":676},[1595],{"type":612,"value":1596},"\"Opening ",{"type":606,"tag":644,"props":1598,"children":1599},{"style":664},[1600],{"type":612,"value":1601},"{self",{"type":606,"tag":644,"props":1603,"children":1604},{"style":670},[1605],{"type":612,"value":1606},".filename",{"type":606,"tag":644,"props":1608,"children":1609},{"style":664},[1610],{"type":612,"value":1020},{"type":606,"tag":644,"props":1612,"children":1613},{"style":676},[1614],{"type":612,"value":1169},{"type":606,"tag":644,"props":1616,"children":1617},{"style":670},[1618],{"type":612,"value":1030},{"type":606,"tag":644,"props":1620,"children":1621},{"class":646,"line":99},[1622,1626,1630,1634,1638,1642,1647,1652,1656],{"type":606,"tag":644,"props":1623,"children":1624},{"style":664},[1625],{"type":612,"value":1495},{"type":606,"tag":644,"props":1627,"children":1628},{"style":670},[1629],{"type":612,"value":1542},{"type":606,"tag":644,"props":1631,"children":1632},{"style":659},[1633],{"type":612,"value":723},{"type":606,"tag":644,"props":1635,"children":1636},{"style":664},[1637],{"type":612,"value":667},{"type":606,"tag":644,"props":1639,"children":1640},{"style":670},[1641],{"type":612,"value":673},{"type":606,"tag":644,"props":1643,"children":1644},{"style":664},[1645],{"type":612,"value":1646},"self",{"type":606,"tag":644,"props":1648,"children":1649},{"style":670},[1650],{"type":612,"value":1651},".filename, ",{"type":606,"tag":644,"props":1653,"children":1654},{"style":664},[1655],{"type":612,"value":1646},{"type":606,"tag":644,"props":1657,"children":1658},{"style":670},[1659],{"type":612,"value":1660},".mode)\n",{"type":606,"tag":644,"props":1662,"children":1663},{"class":646,"line":108},[1664,1669,1674],{"type":606,"tag":644,"props":1665,"children":1666},{"style":659},[1667],{"type":612,"value":1668},"        return",{"type":606,"tag":644,"props":1670,"children":1671},{"style":664},[1672],{"type":612,"value":1673}," self",{"type":606,"tag":644,"props":1675,"children":1676},{"style":670},[1677],{"type":612,"value":1678},".file\n",{"type":606,"tag":644,"props":1680,"children":1681},{"class":646,"line":117},[1682],{"type":606,"tag":644,"props":1683,"children":1684},{"style":670},[1685],{"type":612,"value":1559},{"type":606,"tag":644,"props":1687,"children":1688},{"class":646,"line":126},[1689,1693,1698],{"type":606,"tag":644,"props":1690,"children":1691},{"style":659},[1692],{"type":612,"value":1477},{"type":606,"tag":644,"props":1694,"children":1695},{"style":664},[1696],{"type":612,"value":1697}," __exit__",{"type":606,"tag":644,"props":1699,"children":1700},{"style":670},[1701],{"type":612,"value":1702},"(self, exc_type, exc_value, traceback):\n",{"type":606,"tag":644,"props":1704,"children":1705},{"class":646,"line":135},[1706,1710,1714,1718,1723,1727,1731,1735,1739],{"type":606,"tag":644,"props":1707,"children":1708},{"style":664},[1709],{"type":612,"value":1056},{"type":606,"tag":644,"props":1711,"children":1712},{"style":670},[1713],{"type":612,"value":673},{"type":606,"tag":644,"props":1715,"children":1716},{"style":659},[1717],{"type":612,"value":1000},{"type":606,"tag":644,"props":1719,"children":1720},{"style":676},[1721],{"type":612,"value":1722},"\"Closing ",{"type":606,"tag":644,"props":1724,"children":1725},{"style":664},[1726],{"type":612,"value":1601},{"type":606,"tag":644,"props":1728,"children":1729},{"style":670},[1730],{"type":612,"value":1606},{"type":606,"tag":644,"props":1732,"children":1733},{"style":664},[1734],{"type":612,"value":1020},{"type":606,"tag":644,"props":1736,"children":1737},{"style":676},[1738],{"type":612,"value":1169},{"type":606,"tag":644,"props":1740,"children":1741},{"style":670},[1742],{"type":612,"value":1030},{"type":606,"tag":644,"props":1744,"children":1745},{"class":646,"line":144},[1746,1751,1755],{"type":606,"tag":644,"props":1747,"children":1748},{"style":659},[1749],{"type":612,"value":1750},"        if",{"type":606,"tag":644,"props":1752,"children":1753},{"style":664},[1754],{"type":612,"value":1673},{"type":606,"tag":644,"props":1756,"children":1757},{"style":670},[1758],{"type":612,"value":1759},".file:\n",{"type":606,"tag":644,"props":1761,"children":1762},{"class":646,"line":153},[1763,1768],{"type":606,"tag":644,"props":1764,"children":1765},{"style":664},[1766],{"type":612,"value":1767},"            self",{"type":606,"tag":644,"props":1769,"children":1770},{"style":670},[1771],{"type":612,"value":1772},".file.close()\n",{"type":606,"tag":644,"props":1774,"children":1775},{"class":646,"line":163},[1776],{"type":606,"tag":644,"props":1777,"children":1778},{"style":670},[1779],{"type":612,"value":1780},"        \n",{"type":606,"tag":644,"props":1782,"children":1783},{"class":646,"line":172},[1784],{"type":606,"tag":644,"props":1785,"children":1786},{"style":650},[1787],{"type":612,"value":1788},"        # Handle exceptions\n",{"type":606,"tag":644,"props":1790,"children":1791},{"class":646,"line":181},[1792,1796],{"type":606,"tag":644,"props":1793,"children":1794},{"style":659},[1795],{"type":612,"value":1750},{"type":606,"tag":644,"props":1797,"children":1798},{"style":670},[1799],{"type":612,"value":1800}," exc_type:\n",{"type":606,"tag":644,"props":1802,"children":1803},{"class":646,"line":190},[1804,1808,1812,1816,1821,1826,1831,1835,1839],{"type":606,"tag":644,"props":1805,"children":1806},{"style":664},[1807],{"type":612,"value":991},{"type":606,"tag":644,"props":1809,"children":1810},{"style":670},[1811],{"type":612,"value":673},{"type":606,"tag":644,"props":1813,"children":1814},{"style":659},[1815],{"type":612,"value":1000},{"type":606,"tag":644,"props":1817,"children":1818},{"style":676},[1819],{"type":612,"value":1820},"\"Exception occurred: ",{"type":606,"tag":644,"props":1822,"children":1823},{"style":664},[1824],{"type":612,"value":1825},"{",{"type":606,"tag":644,"props":1827,"children":1828},{"style":670},[1829],{"type":612,"value":1830},"exc_value",{"type":606,"tag":644,"props":1832,"children":1833},{"style":664},[1834],{"type":612,"value":1020},{"type":606,"tag":644,"props":1836,"children":1837},{"style":676},[1838],{"type":612,"value":1169},{"type":606,"tag":644,"props":1840,"children":1841},{"style":670},[1842],{"type":612,"value":1030},{"type":606,"tag":644,"props":1844,"children":1845},{"class":646,"line":199},[1846,1850,1855],{"type":606,"tag":644,"props":1847,"children":1848},{"style":659},[1849],{"type":612,"value":1668},{"type":606,"tag":644,"props":1851,"children":1852},{"style":664},[1853],{"type":612,"value":1854}," False",{"type":606,"tag":644,"props":1856,"children":1857},{"style":650},[1858],{"type":612,"value":1859},"  # Don't suppress exceptions\n",{"type":606,"tag":644,"props":1861,"children":1862},{"class":646,"line":208},[1863],{"type":606,"tag":644,"props":1864,"children":1865},{"emptyLinePlaceholder":13},[1866],{"type":612,"value":1077},{"type":606,"tag":644,"props":1868,"children":1869},{"class":646,"line":217},[1870],{"type":606,"tag":644,"props":1871,"children":1872},{"style":650},[1873],{"type":612,"value":1874},"# Using custom context manager\n",{"type":606,"tag":644,"props":1876,"children":1877},{"class":646,"line":227},[1878,1882,1887,1892,1896,1900,1904,1908,1912],{"type":606,"tag":644,"props":1879,"children":1880},{"style":659},[1881],{"type":612,"value":626},{"type":606,"tag":644,"props":1883,"children":1884},{"style":670},[1885],{"type":612,"value":1886}," FileManager(",{"type":606,"tag":644,"props":1888,"children":1889},{"style":676},[1890],{"type":612,"value":1891},"'test.txt'",{"type":606,"tag":644,"props":1893,"children":1894},{"style":670},[1895],{"type":612,"value":684},{"type":606,"tag":644,"props":1897,"children":1898},{"style":676},[1899],{"type":612,"value":1115},{"type":606,"tag":644,"props":1901,"children":1902},{"style":670},[1903],{"type":612,"value":694},{"type":606,"tag":644,"props":1905,"children":1906},{"style":659},[1907],{"type":612,"value":699},{"type":606,"tag":644,"props":1909,"children":1910},{"style":702},[1911],{"type":612,"value":705},{"type":606,"tag":644,"props":1913,"children":1914},{"style":670},[1915],{"type":612,"value":710},{"type":606,"tag":644,"props":1917,"children":1918},{"class":646,"line":236},[1919,1924,1928,1933],{"type":606,"tag":644,"props":1920,"children":1921},{"style":702},[1922],{"type":612,"value":1923},"    file",{"type":606,"tag":644,"props":1925,"children":1926},{"style":670},[1927],{"type":612,"value":1144},{"type":606,"tag":644,"props":1929,"children":1930},{"style":676},[1931],{"type":612,"value":1932},"\"Custom context manager!\"",{"type":606,"tag":644,"props":1934,"children":1935},{"style":670},[1936],{"type":612,"value":1030},{"type":606,"tag":855,"props":1938,"children":1940},{"id":1939},"decorator-based-context-manager",[1941],{"type":612,"value":1942},"Decorator-Based Context Manager",{"type":606,"tag":630,"props":1944,"children":1945},{},[1946],{"type":606,"tag":634,"props":1947,"children":1949},{"className":636,"code":1948,"language":638,"meta":8,"style":8},"from contextlib import contextmanager\n\n# Context manager using decorator\n@contextmanager\ndef managed_resource(resource_name):\n    print(f\"Acquiring {resource_name}\")\n    resource = f\"Resource: {resource_name}\"\n    try:\n        yield resource\n    finally:\n        print(f\"Releasing {resource_name}\")\n\n# Using decorated context manager\nwith managed_resource(\"database connection\") as resource:\n    print(f\"Using {resource}\")\n",[1950],{"type":606,"tag":621,"props":1951,"children":1952},{"__ignoreMap":8},[1953,1976,1983,1991,1999,2016,2057,2096,2107,2120,2132,2172,2179,2187,2217],{"type":606,"tag":644,"props":1954,"children":1955},{"class":646,"line":12},[1956,1961,1966,1971],{"type":606,"tag":644,"props":1957,"children":1958},{"style":659},[1959],{"type":612,"value":1960},"from",{"type":606,"tag":644,"props":1962,"children":1963},{"style":670},[1964],{"type":612,"value":1965}," contextlib ",{"type":606,"tag":644,"props":1967,"children":1968},{"style":659},[1969],{"type":612,"value":1970},"import",{"type":606,"tag":644,"props":1972,"children":1973},{"style":670},[1974],{"type":612,"value":1975}," contextmanager\n",{"type":606,"tag":644,"props":1977,"children":1978},{"class":646,"line":27},[1979],{"type":606,"tag":644,"props":1980,"children":1981},{"emptyLinePlaceholder":13},[1982],{"type":612,"value":1077},{"type":606,"tag":644,"props":1984,"children":1985},{"class":646,"line":36},[1986],{"type":606,"tag":644,"props":1987,"children":1988},{"style":650},[1989],{"type":612,"value":1990},"# Context manager using decorator\n",{"type":606,"tag":644,"props":1992,"children":1993},{"class":646,"line":45},[1994],{"type":606,"tag":644,"props":1995,"children":1996},{"style":889},[1997],{"type":612,"value":1998},"@contextmanager\n",{"type":606,"tag":644,"props":2000,"children":2001},{"class":646,"line":54},[2002,2006,2011],{"type":606,"tag":644,"props":2003,"children":2004},{"style":659},[2005],{"type":612,"value":886},{"type":606,"tag":644,"props":2007,"children":2008},{"style":889},[2009],{"type":612,"value":2010}," managed_resource",{"type":606,"tag":644,"props":2012,"children":2013},{"style":670},[2014],{"type":612,"value":2015},"(resource_name):\n",{"type":606,"tag":644,"props":2017,"children":2018},{"class":646,"line":63},[2019,2023,2027,2031,2036,2040,2045,2049,2053],{"type":606,"tag":644,"props":2020,"children":2021},{"style":664},[2022],{"type":612,"value":740},{"type":606,"tag":644,"props":2024,"children":2025},{"style":670},[2026],{"type":612,"value":673},{"type":606,"tag":644,"props":2028,"children":2029},{"style":659},[2030],{"type":612,"value":1000},{"type":606,"tag":644,"props":2032,"children":2033},{"style":676},[2034],{"type":612,"value":2035},"\"Acquiring ",{"type":606,"tag":644,"props":2037,"children":2038},{"style":664},[2039],{"type":612,"value":1825},{"type":606,"tag":644,"props":2041,"children":2042},{"style":670},[2043],{"type":612,"value":2044},"resource_name",{"type":606,"tag":644,"props":2046,"children":2047},{"style":664},[2048],{"type":612,"value":1020},{"type":606,"tag":644,"props":2050,"children":2051},{"style":676},[2052],{"type":612,"value":1169},{"type":606,"tag":644,"props":2054,"children":2055},{"style":670},[2056],{"type":612,"value":1030},{"type":606,"tag":644,"props":2058,"children":2059},{"class":646,"line":72},[2060,2065,2069,2074,2079,2083,2087,2091],{"type":606,"tag":644,"props":2061,"children":2062},{"style":670},[2063],{"type":612,"value":2064},"    resource ",{"type":606,"tag":644,"props":2066,"children":2067},{"style":659},[2068],{"type":612,"value":723},{"type":606,"tag":644,"props":2070,"children":2071},{"style":659},[2072],{"type":612,"value":2073}," f",{"type":606,"tag":644,"props":2075,"children":2076},{"style":676},[2077],{"type":612,"value":2078},"\"Resource: ",{"type":606,"tag":644,"props":2080,"children":2081},{"style":664},[2082],{"type":612,"value":1825},{"type":606,"tag":644,"props":2084,"children":2085},{"style":670},[2086],{"type":612,"value":2044},{"type":606,"tag":644,"props":2088,"children":2089},{"style":664},[2090],{"type":612,"value":1020},{"type":606,"tag":644,"props":2092,"children":2093},{"style":676},[2094],{"type":612,"value":2095},"\"\n",{"type":606,"tag":644,"props":2097,"children":2098},{"class":646,"line":81},[2099,2103],{"type":606,"tag":644,"props":2100,"children":2101},{"style":659},[2102],{"type":612,"value":913},{"type":606,"tag":644,"props":2104,"children":2105},{"style":670},[2106],{"type":612,"value":710},{"type":606,"tag":644,"props":2108,"children":2109},{"class":646,"line":1050},[2110,2115],{"type":606,"tag":644,"props":2111,"children":2112},{"style":659},[2113],{"type":612,"value":2114},"        yield",{"type":606,"tag":644,"props":2116,"children":2117},{"style":670},[2118],{"type":612,"value":2119}," resource\n",{"type":606,"tag":644,"props":2121,"children":2122},{"class":646,"line":99},[2123,2128],{"type":606,"tag":644,"props":2124,"children":2125},{"style":659},[2126],{"type":612,"value":2127},"    finally",{"type":606,"tag":644,"props":2129,"children":2130},{"style":670},[2131],{"type":612,"value":710},{"type":606,"tag":644,"props":2133,"children":2134},{"class":646,"line":108},[2135,2139,2143,2147,2152,2156,2160,2164,2168],{"type":606,"tag":644,"props":2136,"children":2137},{"style":664},[2138],{"type":612,"value":1056},{"type":606,"tag":644,"props":2140,"children":2141},{"style":670},[2142],{"type":612,"value":673},{"type":606,"tag":644,"props":2144,"children":2145},{"style":659},[2146],{"type":612,"value":1000},{"type":606,"tag":644,"props":2148,"children":2149},{"style":676},[2150],{"type":612,"value":2151},"\"Releasing ",{"type":606,"tag":644,"props":2153,"children":2154},{"style":664},[2155],{"type":612,"value":1825},{"type":606,"tag":644,"props":2157,"children":2158},{"style":670},[2159],{"type":612,"value":2044},{"type":606,"tag":644,"props":2161,"children":2162},{"style":664},[2163],{"type":612,"value":1020},{"type":606,"tag":644,"props":2165,"children":2166},{"style":676},[2167],{"type":612,"value":1169},{"type":606,"tag":644,"props":2169,"children":2170},{"style":670},[2171],{"type":612,"value":1030},{"type":606,"tag":644,"props":2173,"children":2174},{"class":646,"line":117},[2175],{"type":606,"tag":644,"props":2176,"children":2177},{"emptyLinePlaceholder":13},[2178],{"type":612,"value":1077},{"type":606,"tag":644,"props":2180,"children":2181},{"class":646,"line":126},[2182],{"type":606,"tag":644,"props":2183,"children":2184},{"style":650},[2185],{"type":612,"value":2186},"# Using decorated context manager\n",{"type":606,"tag":644,"props":2188,"children":2189},{"class":646,"line":135},[2190,2194,2199,2204,2208,2212],{"type":606,"tag":644,"props":2191,"children":2192},{"style":659},[2193],{"type":612,"value":626},{"type":606,"tag":644,"props":2195,"children":2196},{"style":670},[2197],{"type":612,"value":2198}," managed_resource(",{"type":606,"tag":644,"props":2200,"children":2201},{"style":676},[2202],{"type":612,"value":2203},"\"database connection\"",{"type":606,"tag":644,"props":2205,"children":2206},{"style":670},[2207],{"type":612,"value":694},{"type":606,"tag":644,"props":2209,"children":2210},{"style":659},[2211],{"type":612,"value":699},{"type":606,"tag":644,"props":2213,"children":2214},{"style":670},[2215],{"type":612,"value":2216}," resource:\n",{"type":606,"tag":644,"props":2218,"children":2219},{"class":646,"line":144},[2220,2224,2228,2232,2237,2241,2246,2250,2254],{"type":606,"tag":644,"props":2221,"children":2222},{"style":664},[2223],{"type":612,"value":740},{"type":606,"tag":644,"props":2225,"children":2226},{"style":670},[2227],{"type":612,"value":673},{"type":606,"tag":644,"props":2229,"children":2230},{"style":659},[2231],{"type":612,"value":1000},{"type":606,"tag":644,"props":2233,"children":2234},{"style":676},[2235],{"type":612,"value":2236},"\"Using ",{"type":606,"tag":644,"props":2238,"children":2239},{"style":664},[2240],{"type":612,"value":1825},{"type":606,"tag":644,"props":2242,"children":2243},{"style":670},[2244],{"type":612,"value":2245},"resource",{"type":606,"tag":644,"props":2247,"children":2248},{"style":664},[2249],{"type":612,"value":1020},{"type":606,"tag":644,"props":2251,"children":2252},{"style":676},[2253],{"type":612,"value":1169},{"type":606,"tag":644,"props":2255,"children":2256},{"style":670},[2257],{"type":612,"value":1030},{"type":606,"tag":755,"props":2259,"children":2261},{"id":2260},"advanced-context-managers",[2262],{"type":612,"value":2263},"🔍 Advanced Context Managers",{"type":606,"tag":615,"props":2265,"children":2266},{},[2267],{"type":612,"value":2268},"Python allows sophisticated context manager implementations.",{"type":606,"tag":855,"props":2270,"children":2272},{"id":2271},"timing-operations",[2273],{"type":612,"value":2274},"Timing Operations",{"type":606,"tag":630,"props":2276,"children":2277},{},[2278],{"type":606,"tag":634,"props":2279,"children":2281},{"className":636,"code":2280,"language":638,"meta":8,"style":8},"import time\nfrom contextlib import contextmanager\n\n# Timing context manager\n@contextmanager\ndef timer(operation_name):\n    \"\"\"Context manager for timing operations\"\"\"\n    start_time = time.time()\n    print(f\"Starting {operation_name}\")\n    try:\n        yield\n    finally:\n        end_time = time.time()\n        duration = end_time - start_time\n        print(f\"{operation_name} took {duration:.2f} seconds\")\n\n# Example usage\nwith timer(\"file processing\"):\n    time.sleep(0.1)  # Simulate work\n    print(\"Processing files...\")\n",[2282],{"type":606,"tag":621,"props":2283,"children":2284},{"__ignoreMap":8},[2285,2297,2316,2323,2331,2338,2355,2363,2380,2421,2432,2440,2451,2467,2494,2557,2564,2572,2594,2617],{"type":606,"tag":644,"props":2286,"children":2287},{"class":646,"line":12},[2288,2292],{"type":606,"tag":644,"props":2289,"children":2290},{"style":659},[2291],{"type":612,"value":1970},{"type":606,"tag":644,"props":2293,"children":2294},{"style":670},[2295],{"type":612,"value":2296}," time\n",{"type":606,"tag":644,"props":2298,"children":2299},{"class":646,"line":27},[2300,2304,2308,2312],{"type":606,"tag":644,"props":2301,"children":2302},{"style":659},[2303],{"type":612,"value":1960},{"type":606,"tag":644,"props":2305,"children":2306},{"style":670},[2307],{"type":612,"value":1965},{"type":606,"tag":644,"props":2309,"children":2310},{"style":659},[2311],{"type":612,"value":1970},{"type":606,"tag":644,"props":2313,"children":2314},{"style":670},[2315],{"type":612,"value":1975},{"type":606,"tag":644,"props":2317,"children":2318},{"class":646,"line":36},[2319],{"type":606,"tag":644,"props":2320,"children":2321},{"emptyLinePlaceholder":13},[2322],{"type":612,"value":1077},{"type":606,"tag":644,"props":2324,"children":2325},{"class":646,"line":45},[2326],{"type":606,"tag":644,"props":2327,"children":2328},{"style":650},[2329],{"type":612,"value":2330},"# Timing context manager\n",{"type":606,"tag":644,"props":2332,"children":2333},{"class":646,"line":54},[2334],{"type":606,"tag":644,"props":2335,"children":2336},{"style":889},[2337],{"type":612,"value":1998},{"type":606,"tag":644,"props":2339,"children":2340},{"class":646,"line":63},[2341,2345,2350],{"type":606,"tag":644,"props":2342,"children":2343},{"style":659},[2344],{"type":612,"value":886},{"type":606,"tag":644,"props":2346,"children":2347},{"style":889},[2348],{"type":612,"value":2349}," timer",{"type":606,"tag":644,"props":2351,"children":2352},{"style":670},[2353],{"type":612,"value":2354},"(operation_name):\n",{"type":606,"tag":644,"props":2356,"children":2357},{"class":646,"line":72},[2358],{"type":606,"tag":644,"props":2359,"children":2360},{"style":676},[2361],{"type":612,"value":2362},"    \"\"\"Context manager for timing operations\"\"\"\n",{"type":606,"tag":644,"props":2364,"children":2365},{"class":646,"line":81},[2366,2371,2375],{"type":606,"tag":644,"props":2367,"children":2368},{"style":670},[2369],{"type":612,"value":2370},"    start_time ",{"type":606,"tag":644,"props":2372,"children":2373},{"style":659},[2374],{"type":612,"value":723},{"type":606,"tag":644,"props":2376,"children":2377},{"style":670},[2378],{"type":612,"value":2379}," time.time()\n",{"type":606,"tag":644,"props":2381,"children":2382},{"class":646,"line":1050},[2383,2387,2391,2395,2400,2404,2409,2413,2417],{"type":606,"tag":644,"props":2384,"children":2385},{"style":664},[2386],{"type":612,"value":740},{"type":606,"tag":644,"props":2388,"children":2389},{"style":670},[2390],{"type":612,"value":673},{"type":606,"tag":644,"props":2392,"children":2393},{"style":659},[2394],{"type":612,"value":1000},{"type":606,"tag":644,"props":2396,"children":2397},{"style":676},[2398],{"type":612,"value":2399},"\"Starting ",{"type":606,"tag":644,"props":2401,"children":2402},{"style":664},[2403],{"type":612,"value":1825},{"type":606,"tag":644,"props":2405,"children":2406},{"style":670},[2407],{"type":612,"value":2408},"operation_name",{"type":606,"tag":644,"props":2410,"children":2411},{"style":664},[2412],{"type":612,"value":1020},{"type":606,"tag":644,"props":2414,"children":2415},{"style":676},[2416],{"type":612,"value":1169},{"type":606,"tag":644,"props":2418,"children":2419},{"style":670},[2420],{"type":612,"value":1030},{"type":606,"tag":644,"props":2422,"children":2423},{"class":646,"line":99},[2424,2428],{"type":606,"tag":644,"props":2425,"children":2426},{"style":659},[2427],{"type":612,"value":913},{"type":606,"tag":644,"props":2429,"children":2430},{"style":670},[2431],{"type":612,"value":710},{"type":606,"tag":644,"props":2433,"children":2434},{"class":646,"line":108},[2435],{"type":606,"tag":644,"props":2436,"children":2437},{"style":659},[2438],{"type":612,"value":2439},"        yield\n",{"type":606,"tag":644,"props":2441,"children":2442},{"class":646,"line":117},[2443,2447],{"type":606,"tag":644,"props":2444,"children":2445},{"style":659},[2446],{"type":612,"value":2127},{"type":606,"tag":644,"props":2448,"children":2449},{"style":670},[2450],{"type":612,"value":710},{"type":606,"tag":644,"props":2452,"children":2453},{"class":646,"line":126},[2454,2459,2463],{"type":606,"tag":644,"props":2455,"children":2456},{"style":670},[2457],{"type":612,"value":2458},"        end_time ",{"type":606,"tag":644,"props":2460,"children":2461},{"style":659},[2462],{"type":612,"value":723},{"type":606,"tag":644,"props":2464,"children":2465},{"style":670},[2466],{"type":612,"value":2379},{"type":606,"tag":644,"props":2468,"children":2469},{"class":646,"line":135},[2470,2475,2479,2484,2489],{"type":606,"tag":644,"props":2471,"children":2472},{"style":670},[2473],{"type":612,"value":2474},"        duration ",{"type":606,"tag":644,"props":2476,"children":2477},{"style":659},[2478],{"type":612,"value":723},{"type":606,"tag":644,"props":2480,"children":2481},{"style":670},[2482],{"type":612,"value":2483}," end_time ",{"type":606,"tag":644,"props":2485,"children":2486},{"style":659},[2487],{"type":612,"value":2488},"-",{"type":606,"tag":644,"props":2490,"children":2491},{"style":670},[2492],{"type":612,"value":2493}," start_time\n",{"type":606,"tag":644,"props":2495,"children":2496},{"class":646,"line":144},[2497,2501,2505,2509,2513,2517,2521,2525,2530,2534,2539,2544,2548,2553],{"type":606,"tag":644,"props":2498,"children":2499},{"style":664},[2500],{"type":612,"value":1056},{"type":606,"tag":644,"props":2502,"children":2503},{"style":670},[2504],{"type":612,"value":673},{"type":606,"tag":644,"props":2506,"children":2507},{"style":659},[2508],{"type":612,"value":1000},{"type":606,"tag":644,"props":2510,"children":2511},{"style":676},[2512],{"type":612,"value":1169},{"type":606,"tag":644,"props":2514,"children":2515},{"style":664},[2516],{"type":612,"value":1825},{"type":606,"tag":644,"props":2518,"children":2519},{"style":670},[2520],{"type":612,"value":2408},{"type":606,"tag":644,"props":2522,"children":2523},{"style":664},[2524],{"type":612,"value":1020},{"type":606,"tag":644,"props":2526,"children":2527},{"style":676},[2528],{"type":612,"value":2529}," took ",{"type":606,"tag":644,"props":2531,"children":2532},{"style":664},[2533],{"type":612,"value":1825},{"type":606,"tag":644,"props":2535,"children":2536},{"style":670},[2537],{"type":612,"value":2538},"duration",{"type":606,"tag":644,"props":2540,"children":2541},{"style":659},[2542],{"type":612,"value":2543},":.2f",{"type":606,"tag":644,"props":2545,"children":2546},{"style":664},[2547],{"type":612,"value":1020},{"type":606,"tag":644,"props":2549,"children":2550},{"style":676},[2551],{"type":612,"value":2552}," seconds\"",{"type":606,"tag":644,"props":2554,"children":2555},{"style":670},[2556],{"type":612,"value":1030},{"type":606,"tag":644,"props":2558,"children":2559},{"class":646,"line":153},[2560],{"type":606,"tag":644,"props":2561,"children":2562},{"emptyLinePlaceholder":13},[2563],{"type":612,"value":1077},{"type":606,"tag":644,"props":2565,"children":2566},{"class":646,"line":163},[2567],{"type":606,"tag":644,"props":2568,"children":2569},{"style":650},[2570],{"type":612,"value":2571},"# Example usage\n",{"type":606,"tag":644,"props":2573,"children":2574},{"class":646,"line":172},[2575,2579,2584,2589],{"type":606,"tag":644,"props":2576,"children":2577},{"style":659},[2578],{"type":612,"value":626},{"type":606,"tag":644,"props":2580,"children":2581},{"style":670},[2582],{"type":612,"value":2583}," timer(",{"type":606,"tag":644,"props":2585,"children":2586},{"style":676},[2587],{"type":612,"value":2588},"\"file processing\"",{"type":606,"tag":644,"props":2590,"children":2591},{"style":670},[2592],{"type":612,"value":2593},"):\n",{"type":606,"tag":644,"props":2595,"children":2596},{"class":646,"line":181},[2597,2602,2607,2612],{"type":606,"tag":644,"props":2598,"children":2599},{"style":670},[2600],{"type":612,"value":2601},"    time.sleep(",{"type":606,"tag":644,"props":2603,"children":2604},{"style":664},[2605],{"type":612,"value":2606},"0.1",{"type":606,"tag":644,"props":2608,"children":2609},{"style":670},[2610],{"type":612,"value":2611},")  ",{"type":606,"tag":644,"props":2613,"children":2614},{"style":650},[2615],{"type":612,"value":2616},"# Simulate work\n",{"type":606,"tag":644,"props":2618,"children":2619},{"class":646,"line":190},[2620,2624,2628,2633],{"type":606,"tag":644,"props":2621,"children":2622},{"style":664},[2623],{"type":612,"value":740},{"type":606,"tag":644,"props":2625,"children":2626},{"style":670},[2627],{"type":612,"value":673},{"type":606,"tag":644,"props":2629,"children":2630},{"style":676},[2631],{"type":612,"value":2632},"\"Processing files...\"",{"type":606,"tag":644,"props":2634,"children":2635},{"style":670},[2636],{"type":612,"value":1030},{"type":606,"tag":855,"props":2638,"children":2640},{"id":2639},"directory-management",[2641],{"type":612,"value":2642},"Directory Management",{"type":606,"tag":630,"props":2644,"children":2645},{},[2646],{"type":606,"tag":634,"props":2647,"children":2649},{"className":636,"code":2648,"language":638,"meta":8,"style":8},"import os\nfrom pathlib import Path\n\n# Directory context manager\n@contextmanager\ndef change_directory(path):\n    \"\"\"Context manager for temporary directory change\"\"\"\n    original_dir = Path.cwd()\n    try:\n        os.chdir(path)\n        yield Path.cwd()\n    finally:\n        os.chdir(original_dir)\n\n# Example usage\nprint(f\"Current directory: {Path.cwd()}\")\ntry:\n    with change_directory('/tmp'):\n        print(f\"Inside context: {Path.cwd()}\")\nexcept FileNotFoundError:\n    print(\"Directory not found\")\nprint(f\"After context: {Path.cwd()}\")\n",[2650],{"type":606,"tag":621,"props":2651,"children":2652},{"__ignoreMap":8},[2653,2665,2686,2693,2701,2708,2725,2733,2750,2761,2769,2780,2791,2799,2806,2813,2855,2867,2888,2928,2944,2964],{"type":606,"tag":644,"props":2654,"children":2655},{"class":646,"line":12},[2656,2660],{"type":606,"tag":644,"props":2657,"children":2658},{"style":659},[2659],{"type":612,"value":1970},{"type":606,"tag":644,"props":2661,"children":2662},{"style":670},[2663],{"type":612,"value":2664}," os\n",{"type":606,"tag":644,"props":2666,"children":2667},{"class":646,"line":27},[2668,2672,2677,2681],{"type":606,"tag":644,"props":2669,"children":2670},{"style":659},[2671],{"type":612,"value":1960},{"type":606,"tag":644,"props":2673,"children":2674},{"style":670},[2675],{"type":612,"value":2676}," pathlib ",{"type":606,"tag":644,"props":2678,"children":2679},{"style":659},[2680],{"type":612,"value":1970},{"type":606,"tag":644,"props":2682,"children":2683},{"style":670},[2684],{"type":612,"value":2685}," Path\n",{"type":606,"tag":644,"props":2687,"children":2688},{"class":646,"line":36},[2689],{"type":606,"tag":644,"props":2690,"children":2691},{"emptyLinePlaceholder":13},[2692],{"type":612,"value":1077},{"type":606,"tag":644,"props":2694,"children":2695},{"class":646,"line":45},[2696],{"type":606,"tag":644,"props":2697,"children":2698},{"style":650},[2699],{"type":612,"value":2700},"# Directory context manager\n",{"type":606,"tag":644,"props":2702,"children":2703},{"class":646,"line":54},[2704],{"type":606,"tag":644,"props":2705,"children":2706},{"style":889},[2707],{"type":612,"value":1998},{"type":606,"tag":644,"props":2709,"children":2710},{"class":646,"line":63},[2711,2715,2720],{"type":606,"tag":644,"props":2712,"children":2713},{"style":659},[2714],{"type":612,"value":886},{"type":606,"tag":644,"props":2716,"children":2717},{"style":889},[2718],{"type":612,"value":2719}," change_directory",{"type":606,"tag":644,"props":2721,"children":2722},{"style":670},[2723],{"type":612,"value":2724},"(path):\n",{"type":606,"tag":644,"props":2726,"children":2727},{"class":646,"line":72},[2728],{"type":606,"tag":644,"props":2729,"children":2730},{"style":676},[2731],{"type":612,"value":2732},"    \"\"\"Context manager for temporary directory change\"\"\"\n",{"type":606,"tag":644,"props":2734,"children":2735},{"class":646,"line":81},[2736,2741,2745],{"type":606,"tag":644,"props":2737,"children":2738},{"style":670},[2739],{"type":612,"value":2740},"    original_dir ",{"type":606,"tag":644,"props":2742,"children":2743},{"style":659},[2744],{"type":612,"value":723},{"type":606,"tag":644,"props":2746,"children":2747},{"style":670},[2748],{"type":612,"value":2749}," Path.cwd()\n",{"type":606,"tag":644,"props":2751,"children":2752},{"class":646,"line":1050},[2753,2757],{"type":606,"tag":644,"props":2754,"children":2755},{"style":659},[2756],{"type":612,"value":913},{"type":606,"tag":644,"props":2758,"children":2759},{"style":670},[2760],{"type":612,"value":710},{"type":606,"tag":644,"props":2762,"children":2763},{"class":646,"line":99},[2764],{"type":606,"tag":644,"props":2765,"children":2766},{"style":670},[2767],{"type":612,"value":2768},"        os.chdir(path)\n",{"type":606,"tag":644,"props":2770,"children":2771},{"class":646,"line":108},[2772,2776],{"type":606,"tag":644,"props":2773,"children":2774},{"style":659},[2775],{"type":612,"value":2114},{"type":606,"tag":644,"props":2777,"children":2778},{"style":670},[2779],{"type":612,"value":2749},{"type":606,"tag":644,"props":2781,"children":2782},{"class":646,"line":117},[2783,2787],{"type":606,"tag":644,"props":2784,"children":2785},{"style":659},[2786],{"type":612,"value":2127},{"type":606,"tag":644,"props":2788,"children":2789},{"style":670},[2790],{"type":612,"value":710},{"type":606,"tag":644,"props":2792,"children":2793},{"class":646,"line":126},[2794],{"type":606,"tag":644,"props":2795,"children":2796},{"style":670},[2797],{"type":612,"value":2798},"        os.chdir(original_dir)\n",{"type":606,"tag":644,"props":2800,"children":2801},{"class":646,"line":135},[2802],{"type":606,"tag":644,"props":2803,"children":2804},{"emptyLinePlaceholder":13},[2805],{"type":612,"value":1077},{"type":606,"tag":644,"props":2807,"children":2808},{"class":646,"line":144},[2809],{"type":606,"tag":644,"props":2810,"children":2811},{"style":650},[2812],{"type":612,"value":2571},{"type":606,"tag":644,"props":2814,"children":2815},{"class":646,"line":153},[2816,2821,2825,2829,2834,2838,2843,2847,2851],{"type":606,"tag":644,"props":2817,"children":2818},{"style":664},[2819],{"type":612,"value":2820},"print",{"type":606,"tag":644,"props":2822,"children":2823},{"style":670},[2824],{"type":612,"value":673},{"type":606,"tag":644,"props":2826,"children":2827},{"style":659},[2828],{"type":612,"value":1000},{"type":606,"tag":644,"props":2830,"children":2831},{"style":676},[2832],{"type":612,"value":2833},"\"Current directory: ",{"type":606,"tag":644,"props":2835,"children":2836},{"style":664},[2837],{"type":612,"value":1825},{"type":606,"tag":644,"props":2839,"children":2840},{"style":670},[2841],{"type":612,"value":2842},"Path.cwd()",{"type":606,"tag":644,"props":2844,"children":2845},{"style":664},[2846],{"type":612,"value":1020},{"type":606,"tag":644,"props":2848,"children":2849},{"style":676},[2850],{"type":612,"value":1169},{"type":606,"tag":644,"props":2852,"children":2853},{"style":670},[2854],{"type":612,"value":1030},{"type":606,"tag":644,"props":2856,"children":2857},{"class":646,"line":163},[2858,2863],{"type":606,"tag":644,"props":2859,"children":2860},{"style":659},[2861],{"type":612,"value":2862},"try",{"type":606,"tag":644,"props":2864,"children":2865},{"style":670},[2866],{"type":612,"value":710},{"type":606,"tag":644,"props":2868,"children":2869},{"class":646,"line":172},[2870,2874,2879,2884],{"type":606,"tag":644,"props":2871,"children":2872},{"style":659},[2873],{"type":612,"value":1093},{"type":606,"tag":644,"props":2875,"children":2876},{"style":670},[2877],{"type":612,"value":2878}," change_directory(",{"type":606,"tag":644,"props":2880,"children":2881},{"style":676},[2882],{"type":612,"value":2883},"'/tmp'",{"type":606,"tag":644,"props":2885,"children":2886},{"style":670},[2887],{"type":612,"value":2593},{"type":606,"tag":644,"props":2889,"children":2890},{"class":646,"line":181},[2891,2895,2899,2903,2908,2912,2916,2920,2924],{"type":606,"tag":644,"props":2892,"children":2893},{"style":664},[2894],{"type":612,"value":1056},{"type":606,"tag":644,"props":2896,"children":2897},{"style":670},[2898],{"type":612,"value":673},{"type":606,"tag":644,"props":2900,"children":2901},{"style":659},[2902],{"type":612,"value":1000},{"type":606,"tag":644,"props":2904,"children":2905},{"style":676},[2906],{"type":612,"value":2907},"\"Inside context: ",{"type":606,"tag":644,"props":2909,"children":2910},{"style":664},[2911],{"type":612,"value":1825},{"type":606,"tag":644,"props":2913,"children":2914},{"style":670},[2915],{"type":612,"value":2842},{"type":606,"tag":644,"props":2917,"children":2918},{"style":664},[2919],{"type":612,"value":1020},{"type":606,"tag":644,"props":2921,"children":2922},{"style":676},[2923],{"type":612,"value":1169},{"type":606,"tag":644,"props":2925,"children":2926},{"style":670},[2927],{"type":612,"value":1030},{"type":606,"tag":644,"props":2929,"children":2930},{"class":646,"line":190},[2931,2936,2940],{"type":606,"tag":644,"props":2932,"children":2933},{"style":659},[2934],{"type":612,"value":2935},"except",{"type":606,"tag":644,"props":2937,"children":2938},{"style":664},[2939],{"type":612,"value":1043},{"type":606,"tag":644,"props":2941,"children":2942},{"style":670},[2943],{"type":612,"value":710},{"type":606,"tag":644,"props":2945,"children":2946},{"class":646,"line":199},[2947,2951,2955,2960],{"type":606,"tag":644,"props":2948,"children":2949},{"style":664},[2950],{"type":612,"value":740},{"type":606,"tag":644,"props":2952,"children":2953},{"style":670},[2954],{"type":612,"value":673},{"type":606,"tag":644,"props":2956,"children":2957},{"style":676},[2958],{"type":612,"value":2959},"\"Directory not found\"",{"type":606,"tag":644,"props":2961,"children":2962},{"style":670},[2963],{"type":612,"value":1030},{"type":606,"tag":644,"props":2965,"children":2966},{"class":646,"line":208},[2967,2971,2975,2979,2984,2988,2992,2996,3000],{"type":606,"tag":644,"props":2968,"children":2969},{"style":664},[2970],{"type":612,"value":2820},{"type":606,"tag":644,"props":2972,"children":2973},{"style":670},[2974],{"type":612,"value":673},{"type":606,"tag":644,"props":2976,"children":2977},{"style":659},[2978],{"type":612,"value":1000},{"type":606,"tag":644,"props":2980,"children":2981},{"style":676},[2982],{"type":612,"value":2983},"\"After context: ",{"type":606,"tag":644,"props":2985,"children":2986},{"style":664},[2987],{"type":612,"value":1825},{"type":606,"tag":644,"props":2989,"children":2990},{"style":670},[2991],{"type":612,"value":2842},{"type":606,"tag":644,"props":2993,"children":2994},{"style":664},[2995],{"type":612,"value":1020},{"type":606,"tag":644,"props":2997,"children":2998},{"style":676},[2999],{"type":612,"value":1169},{"type":606,"tag":644,"props":3001,"children":3002},{"style":670},[3003],{"type":612,"value":1030},{"type":606,"tag":855,"props":3005,"children":3006},{"id":355},[3007],{"type":612,"value":353},{"type":606,"tag":630,"props":3009,"children":3010},{},[3011],{"type":606,"tag":634,"props":3012,"children":3014},{"className":636,"code":3013,"language":638,"meta":8,"style":8},"# Error handling context manager\n@contextmanager\ndef error_handler(operation):\n    \"\"\"Context manager with error handling\"\"\"\n    try:\n        print(f\"Starting {operation}\")\n        yield\n        print(f\"Successfully completed {operation}\")\n    except Exception as e:\n        print(f\"Error in {operation}: {e}\")\n        # Log error, send notification, etc.\n        raise  # Re-raise the exception\n\n# Example with error\ntry:\n    with error_handler(\"risky operation\"):\n        raise ValueError(\"Something went wrong!\")\nexcept ValueError:\n    print(\"Handled the error\")\n",[3015],{"type":606,"tag":621,"props":3016,"children":3017},{"__ignoreMap":8},[3018,3026,3033,3050,3058,3069,3109,3116,3156,3178,3236,3244,3257,3264,3272,3283,3304,3329,3344],{"type":606,"tag":644,"props":3019,"children":3020},{"class":646,"line":12},[3021],{"type":606,"tag":644,"props":3022,"children":3023},{"style":650},[3024],{"type":612,"value":3025},"# Error handling context manager\n",{"type":606,"tag":644,"props":3027,"children":3028},{"class":646,"line":27},[3029],{"type":606,"tag":644,"props":3030,"children":3031},{"style":889},[3032],{"type":612,"value":1998},{"type":606,"tag":644,"props":3034,"children":3035},{"class":646,"line":36},[3036,3040,3045],{"type":606,"tag":644,"props":3037,"children":3038},{"style":659},[3039],{"type":612,"value":886},{"type":606,"tag":644,"props":3041,"children":3042},{"style":889},[3043],{"type":612,"value":3044}," error_handler",{"type":606,"tag":644,"props":3046,"children":3047},{"style":670},[3048],{"type":612,"value":3049},"(operation):\n",{"type":606,"tag":644,"props":3051,"children":3052},{"class":646,"line":45},[3053],{"type":606,"tag":644,"props":3054,"children":3055},{"style":676},[3056],{"type":612,"value":3057},"    \"\"\"Context manager with error handling\"\"\"\n",{"type":606,"tag":644,"props":3059,"children":3060},{"class":646,"line":54},[3061,3065],{"type":606,"tag":644,"props":3062,"children":3063},{"style":659},[3064],{"type":612,"value":913},{"type":606,"tag":644,"props":3066,"children":3067},{"style":670},[3068],{"type":612,"value":710},{"type":606,"tag":644,"props":3070,"children":3071},{"class":646,"line":63},[3072,3076,3080,3084,3088,3092,3097,3101,3105],{"type":606,"tag":644,"props":3073,"children":3074},{"style":664},[3075],{"type":612,"value":1056},{"type":606,"tag":644,"props":3077,"children":3078},{"style":670},[3079],{"type":612,"value":673},{"type":606,"tag":644,"props":3081,"children":3082},{"style":659},[3083],{"type":612,"value":1000},{"type":606,"tag":644,"props":3085,"children":3086},{"style":676},[3087],{"type":612,"value":2399},{"type":606,"tag":644,"props":3089,"children":3090},{"style":664},[3091],{"type":612,"value":1825},{"type":606,"tag":644,"props":3093,"children":3094},{"style":670},[3095],{"type":612,"value":3096},"operation",{"type":606,"tag":644,"props":3098,"children":3099},{"style":664},[3100],{"type":612,"value":1020},{"type":606,"tag":644,"props":3102,"children":3103},{"style":676},[3104],{"type":612,"value":1169},{"type":606,"tag":644,"props":3106,"children":3107},{"style":670},[3108],{"type":612,"value":1030},{"type":606,"tag":644,"props":3110,"children":3111},{"class":646,"line":72},[3112],{"type":606,"tag":644,"props":3113,"children":3114},{"style":659},[3115],{"type":612,"value":2439},{"type":606,"tag":644,"props":3117,"children":3118},{"class":646,"line":81},[3119,3123,3127,3131,3136,3140,3144,3148,3152],{"type":606,"tag":644,"props":3120,"children":3121},{"style":664},[3122],{"type":612,"value":1056},{"type":606,"tag":644,"props":3124,"children":3125},{"style":670},[3126],{"type":612,"value":673},{"type":606,"tag":644,"props":3128,"children":3129},{"style":659},[3130],{"type":612,"value":1000},{"type":606,"tag":644,"props":3132,"children":3133},{"style":676},[3134],{"type":612,"value":3135},"\"Successfully completed ",{"type":606,"tag":644,"props":3137,"children":3138},{"style":664},[3139],{"type":612,"value":1825},{"type":606,"tag":644,"props":3141,"children":3142},{"style":670},[3143],{"type":612,"value":3096},{"type":606,"tag":644,"props":3145,"children":3146},{"style":664},[3147],{"type":612,"value":1020},{"type":606,"tag":644,"props":3149,"children":3150},{"style":676},[3151],{"type":612,"value":1169},{"type":606,"tag":644,"props":3153,"children":3154},{"style":670},[3155],{"type":612,"value":1030},{"type":606,"tag":644,"props":3157,"children":3158},{"class":646,"line":1050},[3159,3163,3168,3173],{"type":606,"tag":644,"props":3160,"children":3161},{"style":659},[3162],{"type":612,"value":1038},{"type":606,"tag":644,"props":3164,"children":3165},{"style":664},[3166],{"type":612,"value":3167}," Exception",{"type":606,"tag":644,"props":3169,"children":3170},{"style":659},[3171],{"type":612,"value":3172}," as",{"type":606,"tag":644,"props":3174,"children":3175},{"style":670},[3176],{"type":612,"value":3177}," e:\n",{"type":606,"tag":644,"props":3179,"children":3180},{"class":646,"line":99},[3181,3185,3189,3193,3198,3202,3206,3210,3215,3219,3224,3228,3232],{"type":606,"tag":644,"props":3182,"children":3183},{"style":664},[3184],{"type":612,"value":1056},{"type":606,"tag":644,"props":3186,"children":3187},{"style":670},[3188],{"type":612,"value":673},{"type":606,"tag":644,"props":3190,"children":3191},{"style":659},[3192],{"type":612,"value":1000},{"type":606,"tag":644,"props":3194,"children":3195},{"style":676},[3196],{"type":612,"value":3197},"\"Error in ",{"type":606,"tag":644,"props":3199,"children":3200},{"style":664},[3201],{"type":612,"value":1825},{"type":606,"tag":644,"props":3203,"children":3204},{"style":670},[3205],{"type":612,"value":3096},{"type":606,"tag":644,"props":3207,"children":3208},{"style":664},[3209],{"type":612,"value":1020},{"type":606,"tag":644,"props":3211,"children":3212},{"style":676},[3213],{"type":612,"value":3214},": ",{"type":606,"tag":644,"props":3216,"children":3217},{"style":664},[3218],{"type":612,"value":1825},{"type":606,"tag":644,"props":3220,"children":3221},{"style":670},[3222],{"type":612,"value":3223},"e",{"type":606,"tag":644,"props":3225,"children":3226},{"style":664},[3227],{"type":612,"value":1020},{"type":606,"tag":644,"props":3229,"children":3230},{"style":676},[3231],{"type":612,"value":1169},{"type":606,"tag":644,"props":3233,"children":3234},{"style":670},[3235],{"type":612,"value":1030},{"type":606,"tag":644,"props":3237,"children":3238},{"class":646,"line":108},[3239],{"type":606,"tag":644,"props":3240,"children":3241},{"style":650},[3242],{"type":612,"value":3243},"        # Log error, send notification, etc.\n",{"type":606,"tag":644,"props":3245,"children":3246},{"class":646,"line":117},[3247,3252],{"type":606,"tag":644,"props":3248,"children":3249},{"style":659},[3250],{"type":612,"value":3251},"        raise",{"type":606,"tag":644,"props":3253,"children":3254},{"style":650},[3255],{"type":612,"value":3256},"  # Re-raise the exception\n",{"type":606,"tag":644,"props":3258,"children":3259},{"class":646,"line":126},[3260],{"type":606,"tag":644,"props":3261,"children":3262},{"emptyLinePlaceholder":13},[3263],{"type":612,"value":1077},{"type":606,"tag":644,"props":3265,"children":3266},{"class":646,"line":135},[3267],{"type":606,"tag":644,"props":3268,"children":3269},{"style":650},[3270],{"type":612,"value":3271},"# Example with error\n",{"type":606,"tag":644,"props":3273,"children":3274},{"class":646,"line":144},[3275,3279],{"type":606,"tag":644,"props":3276,"children":3277},{"style":659},[3278],{"type":612,"value":2862},{"type":606,"tag":644,"props":3280,"children":3281},{"style":670},[3282],{"type":612,"value":710},{"type":606,"tag":644,"props":3284,"children":3285},{"class":646,"line":153},[3286,3290,3295,3300],{"type":606,"tag":644,"props":3287,"children":3288},{"style":659},[3289],{"type":612,"value":1093},{"type":606,"tag":644,"props":3291,"children":3292},{"style":670},[3293],{"type":612,"value":3294}," error_handler(",{"type":606,"tag":644,"props":3296,"children":3297},{"style":676},[3298],{"type":612,"value":3299},"\"risky operation\"",{"type":606,"tag":644,"props":3301,"children":3302},{"style":670},[3303],{"type":612,"value":2593},{"type":606,"tag":644,"props":3305,"children":3306},{"class":646,"line":163},[3307,3311,3316,3320,3325],{"type":606,"tag":644,"props":3308,"children":3309},{"style":659},[3310],{"type":612,"value":3251},{"type":606,"tag":644,"props":3312,"children":3313},{"style":664},[3314],{"type":612,"value":3315}," ValueError",{"type":606,"tag":644,"props":3317,"children":3318},{"style":670},[3319],{"type":612,"value":673},{"type":606,"tag":644,"props":3321,"children":3322},{"style":676},[3323],{"type":612,"value":3324},"\"Something went wrong!\"",{"type":606,"tag":644,"props":3326,"children":3327},{"style":670},[3328],{"type":612,"value":1030},{"type":606,"tag":644,"props":3330,"children":3331},{"class":646,"line":172},[3332,3336,3340],{"type":606,"tag":644,"props":3333,"children":3334},{"style":659},[3335],{"type":612,"value":2935},{"type":606,"tag":644,"props":3337,"children":3338},{"style":664},[3339],{"type":612,"value":3315},{"type":606,"tag":644,"props":3341,"children":3342},{"style":670},[3343],{"type":612,"value":710},{"type":606,"tag":644,"props":3345,"children":3346},{"class":646,"line":181},[3347,3351,3355,3360],{"type":606,"tag":644,"props":3348,"children":3349},{"style":664},[3350],{"type":612,"value":740},{"type":606,"tag":644,"props":3352,"children":3353},{"style":670},[3354],{"type":612,"value":673},{"type":606,"tag":644,"props":3356,"children":3357},{"style":676},[3358],{"type":612,"value":3359},"\"Handled the error\"",{"type":606,"tag":644,"props":3361,"children":3362},{"style":670},[3363],{"type":612,"value":1030},{"type":606,"tag":855,"props":3365,"children":3367},{"id":3366},"multiple-resource-management",[3368],{"type":612,"value":3369},"Multiple Resource Management",{"type":606,"tag":630,"props":3371,"children":3372},{},[3373],{"type":606,"tag":634,"props":3374,"children":3376},{"className":636,"code":3375,"language":638,"meta":8,"style":8},"from contextlib import ExitStack\n\n# Managing multiple resources with ExitStack\ndef process_multiple_files(filenames):\n    \"\"\"Process multiple files using ExitStack\"\"\"\n    with ExitStack() as stack:\n        files = []\n        for filename in filenames:\n            try:\n                file = stack.enter_context(open(filename, 'r'))\n                files.append(file)\n            except FileNotFoundError:\n                print(f\"File {filename} not found, skipping\")\n        \n        for file in files:\n            content = file.read()\n            print(f\"Processed {file.name}: {len(content)} characters\")\n\n# Example usage\nprocess_multiple_files(['file1.txt', 'file2.txt', 'file3.txt'])\n",[3377],{"type":606,"tag":621,"props":3378,"children":3379},{"__ignoreMap":8},[3380,3400,3407,3415,3431,3439,3460,3477,3500,3512,3548,3565,3581,3624,3631,3652,3671,3734,3741,3748],{"type":606,"tag":644,"props":3381,"children":3382},{"class":646,"line":12},[3383,3387,3391,3395],{"type":606,"tag":644,"props":3384,"children":3385},{"style":659},[3386],{"type":612,"value":1960},{"type":606,"tag":644,"props":3388,"children":3389},{"style":670},[3390],{"type":612,"value":1965},{"type":606,"tag":644,"props":3392,"children":3393},{"style":659},[3394],{"type":612,"value":1970},{"type":606,"tag":644,"props":3396,"children":3397},{"style":670},[3398],{"type":612,"value":3399}," ExitStack\n",{"type":606,"tag":644,"props":3401,"children":3402},{"class":646,"line":27},[3403],{"type":606,"tag":644,"props":3404,"children":3405},{"emptyLinePlaceholder":13},[3406],{"type":612,"value":1077},{"type":606,"tag":644,"props":3408,"children":3409},{"class":646,"line":36},[3410],{"type":606,"tag":644,"props":3411,"children":3412},{"style":650},[3413],{"type":612,"value":3414},"# Managing multiple resources with ExitStack\n",{"type":606,"tag":644,"props":3416,"children":3417},{"class":646,"line":45},[3418,3422,3426],{"type":606,"tag":644,"props":3419,"children":3420},{"style":659},[3421],{"type":612,"value":886},{"type":606,"tag":644,"props":3423,"children":3424},{"style":889},[3425],{"type":612,"value":1234},{"type":606,"tag":644,"props":3427,"children":3428},{"style":670},[3429],{"type":612,"value":3430},"(filenames):\n",{"type":606,"tag":644,"props":3432,"children":3433},{"class":646,"line":54},[3434],{"type":606,"tag":644,"props":3435,"children":3436},{"style":676},[3437],{"type":612,"value":3438},"    \"\"\"Process multiple files using ExitStack\"\"\"\n",{"type":606,"tag":644,"props":3440,"children":3441},{"class":646,"line":63},[3442,3446,3451,3455],{"type":606,"tag":644,"props":3443,"children":3444},{"style":659},[3445],{"type":612,"value":1093},{"type":606,"tag":644,"props":3447,"children":3448},{"style":670},[3449],{"type":612,"value":3450}," ExitStack() ",{"type":606,"tag":644,"props":3452,"children":3453},{"style":659},[3454],{"type":612,"value":699},{"type":606,"tag":644,"props":3456,"children":3457},{"style":670},[3458],{"type":612,"value":3459}," stack:\n",{"type":606,"tag":644,"props":3461,"children":3462},{"class":646,"line":72},[3463,3468,3472],{"type":606,"tag":644,"props":3464,"children":3465},{"style":670},[3466],{"type":612,"value":3467},"        files ",{"type":606,"tag":644,"props":3469,"children":3470},{"style":659},[3471],{"type":612,"value":723},{"type":606,"tag":644,"props":3473,"children":3474},{"style":670},[3475],{"type":612,"value":3476}," []\n",{"type":606,"tag":644,"props":3478,"children":3479},{"class":646,"line":81},[3480,3485,3490,3495],{"type":606,"tag":644,"props":3481,"children":3482},{"style":659},[3483],{"type":612,"value":3484},"        for",{"type":606,"tag":644,"props":3486,"children":3487},{"style":670},[3488],{"type":612,"value":3489}," filename ",{"type":606,"tag":644,"props":3491,"children":3492},{"style":659},[3493],{"type":612,"value":3494},"in",{"type":606,"tag":644,"props":3496,"children":3497},{"style":670},[3498],{"type":612,"value":3499}," filenames:\n",{"type":606,"tag":644,"props":3501,"children":3502},{"class":646,"line":1050},[3503,3508],{"type":606,"tag":644,"props":3504,"children":3505},{"style":659},[3506],{"type":612,"value":3507},"            try",{"type":606,"tag":644,"props":3509,"children":3510},{"style":670},[3511],{"type":612,"value":710},{"type":606,"tag":644,"props":3513,"children":3514},{"class":646,"line":99},[3515,3520,3525,3530,3534,3539,3543],{"type":606,"tag":644,"props":3516,"children":3517},{"style":702},[3518],{"type":612,"value":3519},"                file",{"type":606,"tag":644,"props":3521,"children":3522},{"style":659},[3523],{"type":612,"value":3524}," =",{"type":606,"tag":644,"props":3526,"children":3527},{"style":670},[3528],{"type":612,"value":3529}," stack.enter_context(",{"type":606,"tag":644,"props":3531,"children":3532},{"style":664},[3533],{"type":612,"value":1303},{"type":606,"tag":644,"props":3535,"children":3536},{"style":670},[3537],{"type":612,"value":3538},"(filename, ",{"type":606,"tag":644,"props":3540,"children":3541},{"style":676},[3542],{"type":612,"value":689},{"type":606,"tag":644,"props":3544,"children":3545},{"style":670},[3546],{"type":612,"value":3547},"))\n",{"type":606,"tag":644,"props":3549,"children":3550},{"class":646,"line":108},[3551,3556,3561],{"type":606,"tag":644,"props":3552,"children":3553},{"style":670},[3554],{"type":612,"value":3555},"                files.append(",{"type":606,"tag":644,"props":3557,"children":3558},{"style":702},[3559],{"type":612,"value":3560},"file",{"type":606,"tag":644,"props":3562,"children":3563},{"style":670},[3564],{"type":612,"value":1030},{"type":606,"tag":644,"props":3566,"children":3567},{"class":646,"line":117},[3568,3573,3577],{"type":606,"tag":644,"props":3569,"children":3570},{"style":659},[3571],{"type":612,"value":3572},"            except",{"type":606,"tag":644,"props":3574,"children":3575},{"style":664},[3576],{"type":612,"value":1043},{"type":606,"tag":644,"props":3578,"children":3579},{"style":670},[3580],{"type":612,"value":710},{"type":606,"tag":644,"props":3582,"children":3583},{"class":646,"line":126},[3584,3589,3593,3597,3602,3606,3611,3615,3620],{"type":606,"tag":644,"props":3585,"children":3586},{"style":664},[3587],{"type":612,"value":3588},"                print",{"type":606,"tag":644,"props":3590,"children":3591},{"style":670},[3592],{"type":612,"value":673},{"type":606,"tag":644,"props":3594,"children":3595},{"style":659},[3596],{"type":612,"value":1000},{"type":606,"tag":644,"props":3598,"children":3599},{"style":676},[3600],{"type":612,"value":3601},"\"File ",{"type":606,"tag":644,"props":3603,"children":3604},{"style":664},[3605],{"type":612,"value":1825},{"type":606,"tag":644,"props":3607,"children":3608},{"style":670},[3609],{"type":612,"value":3610},"filename",{"type":606,"tag":644,"props":3612,"children":3613},{"style":664},[3614],{"type":612,"value":1020},{"type":606,"tag":644,"props":3616,"children":3617},{"style":676},[3618],{"type":612,"value":3619}," not found, skipping\"",{"type":606,"tag":644,"props":3621,"children":3622},{"style":670},[3623],{"type":612,"value":1030},{"type":606,"tag":644,"props":3625,"children":3626},{"class":646,"line":135},[3627],{"type":606,"tag":644,"props":3628,"children":3629},{"style":670},[3630],{"type":612,"value":1780},{"type":606,"tag":644,"props":3632,"children":3633},{"class":646,"line":144},[3634,3638,3642,3647],{"type":606,"tag":644,"props":3635,"children":3636},{"style":659},[3637],{"type":612,"value":3484},{"type":606,"tag":644,"props":3639,"children":3640},{"style":702},[3641],{"type":612,"value":705},{"type":606,"tag":644,"props":3643,"children":3644},{"style":659},[3645],{"type":612,"value":3646}," in",{"type":606,"tag":644,"props":3648,"children":3649},{"style":670},[3650],{"type":612,"value":3651}," files:\n",{"type":606,"tag":644,"props":3653,"children":3654},{"class":646,"line":153},[3655,3659,3663,3667],{"type":606,"tag":644,"props":3656,"children":3657},{"style":670},[3658],{"type":612,"value":1341},{"type":606,"tag":644,"props":3660,"children":3661},{"style":659},[3662],{"type":612,"value":723},{"type":606,"tag":644,"props":3664,"children":3665},{"style":702},[3666],{"type":612,"value":705},{"type":606,"tag":644,"props":3668,"children":3669},{"style":670},[3670],{"type":612,"value":732},{"type":606,"tag":644,"props":3672,"children":3673},{"class":646,"line":163},[3674,3678,3682,3686,3691,3695,3699,3704,3708,3712,3716,3721,3725,3730],{"type":606,"tag":644,"props":3675,"children":3676},{"style":664},[3677],{"type":612,"value":991},{"type":606,"tag":644,"props":3679,"children":3680},{"style":670},[3681],{"type":612,"value":673},{"type":606,"tag":644,"props":3683,"children":3684},{"style":659},[3685],{"type":612,"value":1000},{"type":606,"tag":644,"props":3687,"children":3688},{"style":676},[3689],{"type":612,"value":3690},"\"Processed ",{"type":606,"tag":644,"props":3692,"children":3693},{"style":664},[3694],{"type":612,"value":1825},{"type":606,"tag":644,"props":3696,"children":3697},{"style":702},[3698],{"type":612,"value":3560},{"type":606,"tag":644,"props":3700,"children":3701},{"style":670},[3702],{"type":612,"value":3703},".name",{"type":606,"tag":644,"props":3705,"children":3706},{"style":664},[3707],{"type":612,"value":1020},{"type":606,"tag":644,"props":3709,"children":3710},{"style":676},[3711],{"type":612,"value":3214},{"type":606,"tag":644,"props":3713,"children":3714},{"style":664},[3715],{"type":612,"value":1010},{"type":606,"tag":644,"props":3717,"children":3718},{"style":670},[3719],{"type":612,"value":3720},"(content)",{"type":606,"tag":644,"props":3722,"children":3723},{"style":664},[3724],{"type":612,"value":1020},{"type":606,"tag":644,"props":3726,"children":3727},{"style":676},[3728],{"type":612,"value":3729}," characters\"",{"type":606,"tag":644,"props":3731,"children":3732},{"style":670},[3733],{"type":612,"value":1030},{"type":606,"tag":644,"props":3735,"children":3736},{"class":646,"line":172},[3737],{"type":606,"tag":644,"props":3738,"children":3739},{"emptyLinePlaceholder":13},[3740],{"type":612,"value":1077},{"type":606,"tag":644,"props":3742,"children":3743},{"class":646,"line":181},[3744],{"type":606,"tag":644,"props":3745,"children":3746},{"style":650},[3747],{"type":612,"value":2571},{"type":606,"tag":644,"props":3749,"children":3750},{"class":646,"line":190},[3751,3756,3761,3765,3770,3774,3779],{"type":606,"tag":644,"props":3752,"children":3753},{"style":670},[3754],{"type":612,"value":3755},"process_multiple_files([",{"type":606,"tag":644,"props":3757,"children":3758},{"style":676},[3759],{"type":612,"value":3760},"'file1.txt'",{"type":606,"tag":644,"props":3762,"children":3763},{"style":670},[3764],{"type":612,"value":684},{"type":606,"tag":644,"props":3766,"children":3767},{"style":676},[3768],{"type":612,"value":3769},"'file2.txt'",{"type":606,"tag":644,"props":3771,"children":3772},{"style":670},[3773],{"type":612,"value":684},{"type":606,"tag":644,"props":3775,"children":3776},{"style":676},[3777],{"type":612,"value":3778},"'file3.txt'",{"type":606,"tag":644,"props":3780,"children":3781},{"style":670},[3782],{"type":612,"value":3783},"])\n",{"type":606,"tag":855,"props":3785,"children":3787},{"id":3786},"thread-safety-and-database-connections",[3788],{"type":612,"value":3789},"Thread Safety and Database Connections",{"type":606,"tag":630,"props":3791,"children":3792},{},[3793],{"type":606,"tag":634,"props":3794,"children":3796},{"className":636,"code":3795,"language":638,"meta":8,"style":8},"import threading\n\n# Lock context manager for threading\nclass ThreadLock:\n    def __init__(self):\n        self.lock = threading.Lock()\n    \n    def __enter__(self):\n        self.lock.acquire()\n        print(\"Lock acquired\")\n        return self\n    \n    def __exit__(self, exc_type, exc_value, traceback):\n        self.lock.release()\n        print(\"Lock released\")\n        return False\n\n# Database connection context manager\n@contextmanager\ndef database_connection(connection_string):\n    \"\"\"Mock database connection context manager\"\"\"\n    print(f\"Connecting to {connection_string}\")\n    connection = f\"Connection to {connection_string}\"\n    try:\n        yield connection\n    except Exception as e:\n        print(f\"Rolling back transaction: {e}\")\n        # Rollback logic here\n        raise\n    else:\n        print(\"Committing transaction\")\n        # Commit logic here\n    finally:\n        print(\"Closing database connection\")\n        # Cleanup logic here\n\n# Example database usage\nwith database_connection(\"postgresql://localhost/mydb\") as conn:\n    print(f\"Using {conn}\")\n    # Database operations here\n",[3797],{"type":606,"tag":621,"props":3798,"children":3799},{"__ignoreMap":8},[3800,3812,3819,3827,3843,3858,3879,3886,3901,3913,3933,3945,3952,3967,3979,3999,4011,4018,4026,4033,4050,4058,4099,4136,4147,4159,4178,4218,4226,4234,4246,4266,4274,4285,4305,4313,4320,4328,4358,4398],{"type":606,"tag":644,"props":3801,"children":3802},{"class":646,"line":12},[3803,3807],{"type":606,"tag":644,"props":3804,"children":3805},{"style":659},[3806],{"type":612,"value":1970},{"type":606,"tag":644,"props":3808,"children":3809},{"style":670},[3810],{"type":612,"value":3811}," threading\n",{"type":606,"tag":644,"props":3813,"children":3814},{"class":646,"line":27},[3815],{"type":606,"tag":644,"props":3816,"children":3817},{"emptyLinePlaceholder":13},[3818],{"type":612,"value":1077},{"type":606,"tag":644,"props":3820,"children":3821},{"class":646,"line":36},[3822],{"type":606,"tag":644,"props":3823,"children":3824},{"style":650},[3825],{"type":612,"value":3826},"# Lock context manager for threading\n",{"type":606,"tag":644,"props":3828,"children":3829},{"class":646,"line":45},[3830,3834,3839],{"type":606,"tag":644,"props":3831,"children":3832},{"style":659},[3833],{"type":612,"value":1460},{"type":606,"tag":644,"props":3835,"children":3836},{"style":889},[3837],{"type":612,"value":3838}," ThreadLock",{"type":606,"tag":644,"props":3840,"children":3841},{"style":670},[3842],{"type":612,"value":710},{"type":606,"tag":644,"props":3844,"children":3845},{"class":646,"line":54},[3846,3850,3854],{"type":606,"tag":644,"props":3847,"children":3848},{"style":659},[3849],{"type":612,"value":1477},{"type":606,"tag":644,"props":3851,"children":3852},{"style":664},[3853],{"type":612,"value":1482},{"type":606,"tag":644,"props":3855,"children":3856},{"style":670},[3857],{"type":612,"value":1576},{"type":606,"tag":644,"props":3859,"children":3860},{"class":646,"line":63},[3861,3865,3870,3874],{"type":606,"tag":644,"props":3862,"children":3863},{"style":664},[3864],{"type":612,"value":1495},{"type":606,"tag":644,"props":3866,"children":3867},{"style":670},[3868],{"type":612,"value":3869},".lock ",{"type":606,"tag":644,"props":3871,"children":3872},{"style":659},[3873],{"type":612,"value":723},{"type":606,"tag":644,"props":3875,"children":3876},{"style":670},[3877],{"type":612,"value":3878}," threading.Lock()\n",{"type":606,"tag":644,"props":3880,"children":3881},{"class":646,"line":72},[3882],{"type":606,"tag":644,"props":3883,"children":3884},{"style":670},[3885],{"type":612,"value":1559},{"type":606,"tag":644,"props":3887,"children":3888},{"class":646,"line":81},[3889,3893,3897],{"type":606,"tag":644,"props":3890,"children":3891},{"style":659},[3892],{"type":612,"value":1477},{"type":606,"tag":644,"props":3894,"children":3895},{"style":664},[3896],{"type":612,"value":1571},{"type":606,"tag":644,"props":3898,"children":3899},{"style":670},[3900],{"type":612,"value":1576},{"type":606,"tag":644,"props":3902,"children":3903},{"class":646,"line":1050},[3904,3908],{"type":606,"tag":644,"props":3905,"children":3906},{"style":664},[3907],{"type":612,"value":1495},{"type":606,"tag":644,"props":3909,"children":3910},{"style":670},[3911],{"type":612,"value":3912},".lock.acquire()\n",{"type":606,"tag":644,"props":3914,"children":3915},{"class":646,"line":99},[3916,3920,3924,3929],{"type":606,"tag":644,"props":3917,"children":3918},{"style":664},[3919],{"type":612,"value":1056},{"type":606,"tag":644,"props":3921,"children":3922},{"style":670},[3923],{"type":612,"value":673},{"type":606,"tag":644,"props":3925,"children":3926},{"style":676},[3927],{"type":612,"value":3928},"\"Lock acquired\"",{"type":606,"tag":644,"props":3930,"children":3931},{"style":670},[3932],{"type":612,"value":1030},{"type":606,"tag":644,"props":3934,"children":3935},{"class":646,"line":108},[3936,3940],{"type":606,"tag":644,"props":3937,"children":3938},{"style":659},[3939],{"type":612,"value":1668},{"type":606,"tag":644,"props":3941,"children":3942},{"style":664},[3943],{"type":612,"value":3944}," self\n",{"type":606,"tag":644,"props":3946,"children":3947},{"class":646,"line":117},[3948],{"type":606,"tag":644,"props":3949,"children":3950},{"style":670},[3951],{"type":612,"value":1559},{"type":606,"tag":644,"props":3953,"children":3954},{"class":646,"line":126},[3955,3959,3963],{"type":606,"tag":644,"props":3956,"children":3957},{"style":659},[3958],{"type":612,"value":1477},{"type":606,"tag":644,"props":3960,"children":3961},{"style":664},[3962],{"type":612,"value":1697},{"type":606,"tag":644,"props":3964,"children":3965},{"style":670},[3966],{"type":612,"value":1702},{"type":606,"tag":644,"props":3968,"children":3969},{"class":646,"line":135},[3970,3974],{"type":606,"tag":644,"props":3971,"children":3972},{"style":664},[3973],{"type":612,"value":1495},{"type":606,"tag":644,"props":3975,"children":3976},{"style":670},[3977],{"type":612,"value":3978},".lock.release()\n",{"type":606,"tag":644,"props":3980,"children":3981},{"class":646,"line":144},[3982,3986,3990,3995],{"type":606,"tag":644,"props":3983,"children":3984},{"style":664},[3985],{"type":612,"value":1056},{"type":606,"tag":644,"props":3987,"children":3988},{"style":670},[3989],{"type":612,"value":673},{"type":606,"tag":644,"props":3991,"children":3992},{"style":676},[3993],{"type":612,"value":3994},"\"Lock released\"",{"type":606,"tag":644,"props":3996,"children":3997},{"style":670},[3998],{"type":612,"value":1030},{"type":606,"tag":644,"props":4000,"children":4001},{"class":646,"line":153},[4002,4006],{"type":606,"tag":644,"props":4003,"children":4004},{"style":659},[4005],{"type":612,"value":1668},{"type":606,"tag":644,"props":4007,"children":4008},{"style":664},[4009],{"type":612,"value":4010}," False\n",{"type":606,"tag":644,"props":4012,"children":4013},{"class":646,"line":163},[4014],{"type":606,"tag":644,"props":4015,"children":4016},{"emptyLinePlaceholder":13},[4017],{"type":612,"value":1077},{"type":606,"tag":644,"props":4019,"children":4020},{"class":646,"line":172},[4021],{"type":606,"tag":644,"props":4022,"children":4023},{"style":650},[4024],{"type":612,"value":4025},"# Database connection context manager\n",{"type":606,"tag":644,"props":4027,"children":4028},{"class":646,"line":181},[4029],{"type":606,"tag":644,"props":4030,"children":4031},{"style":889},[4032],{"type":612,"value":1998},{"type":606,"tag":644,"props":4034,"children":4035},{"class":646,"line":190},[4036,4040,4045],{"type":606,"tag":644,"props":4037,"children":4038},{"style":659},[4039],{"type":612,"value":886},{"type":606,"tag":644,"props":4041,"children":4042},{"style":889},[4043],{"type":612,"value":4044}," database_connection",{"type":606,"tag":644,"props":4046,"children":4047},{"style":670},[4048],{"type":612,"value":4049},"(connection_string):\n",{"type":606,"tag":644,"props":4051,"children":4052},{"class":646,"line":199},[4053],{"type":606,"tag":644,"props":4054,"children":4055},{"style":676},[4056],{"type":612,"value":4057},"    \"\"\"Mock database connection context manager\"\"\"\n",{"type":606,"tag":644,"props":4059,"children":4060},{"class":646,"line":208},[4061,4065,4069,4073,4078,4082,4087,4091,4095],{"type":606,"tag":644,"props":4062,"children":4063},{"style":664},[4064],{"type":612,"value":740},{"type":606,"tag":644,"props":4066,"children":4067},{"style":670},[4068],{"type":612,"value":673},{"type":606,"tag":644,"props":4070,"children":4071},{"style":659},[4072],{"type":612,"value":1000},{"type":606,"tag":644,"props":4074,"children":4075},{"style":676},[4076],{"type":612,"value":4077},"\"Connecting to ",{"type":606,"tag":644,"props":4079,"children":4080},{"style":664},[4081],{"type":612,"value":1825},{"type":606,"tag":644,"props":4083,"children":4084},{"style":670},[4085],{"type":612,"value":4086},"connection_string",{"type":606,"tag":644,"props":4088,"children":4089},{"style":664},[4090],{"type":612,"value":1020},{"type":606,"tag":644,"props":4092,"children":4093},{"style":676},[4094],{"type":612,"value":1169},{"type":606,"tag":644,"props":4096,"children":4097},{"style":670},[4098],{"type":612,"value":1030},{"type":606,"tag":644,"props":4100,"children":4101},{"class":646,"line":217},[4102,4107,4111,4115,4120,4124,4128,4132],{"type":606,"tag":644,"props":4103,"children":4104},{"style":670},[4105],{"type":612,"value":4106},"    connection ",{"type":606,"tag":644,"props":4108,"children":4109},{"style":659},[4110],{"type":612,"value":723},{"type":606,"tag":644,"props":4112,"children":4113},{"style":659},[4114],{"type":612,"value":2073},{"type":606,"tag":644,"props":4116,"children":4117},{"style":676},[4118],{"type":612,"value":4119},"\"Connection to ",{"type":606,"tag":644,"props":4121,"children":4122},{"style":664},[4123],{"type":612,"value":1825},{"type":606,"tag":644,"props":4125,"children":4126},{"style":670},[4127],{"type":612,"value":4086},{"type":606,"tag":644,"props":4129,"children":4130},{"style":664},[4131],{"type":612,"value":1020},{"type":606,"tag":644,"props":4133,"children":4134},{"style":676},[4135],{"type":612,"value":2095},{"type":606,"tag":644,"props":4137,"children":4138},{"class":646,"line":227},[4139,4143],{"type":606,"tag":644,"props":4140,"children":4141},{"style":659},[4142],{"type":612,"value":913},{"type":606,"tag":644,"props":4144,"children":4145},{"style":670},[4146],{"type":612,"value":710},{"type":606,"tag":644,"props":4148,"children":4149},{"class":646,"line":236},[4150,4154],{"type":606,"tag":644,"props":4151,"children":4152},{"style":659},[4153],{"type":612,"value":2114},{"type":606,"tag":644,"props":4155,"children":4156},{"style":670},[4157],{"type":612,"value":4158}," connection\n",{"type":606,"tag":644,"props":4160,"children":4161},{"class":646,"line":245},[4162,4166,4170,4174],{"type":606,"tag":644,"props":4163,"children":4164},{"style":659},[4165],{"type":612,"value":1038},{"type":606,"tag":644,"props":4167,"children":4168},{"style":664},[4169],{"type":612,"value":3167},{"type":606,"tag":644,"props":4171,"children":4172},{"style":659},[4173],{"type":612,"value":3172},{"type":606,"tag":644,"props":4175,"children":4176},{"style":670},[4177],{"type":612,"value":3177},{"type":606,"tag":644,"props":4179,"children":4180},{"class":646,"line":254},[4181,4185,4189,4193,4198,4202,4206,4210,4214],{"type":606,"tag":644,"props":4182,"children":4183},{"style":664},[4184],{"type":612,"value":1056},{"type":606,"tag":644,"props":4186,"children":4187},{"style":670},[4188],{"type":612,"value":673},{"type":606,"tag":644,"props":4190,"children":4191},{"style":659},[4192],{"type":612,"value":1000},{"type":606,"tag":644,"props":4194,"children":4195},{"style":676},[4196],{"type":612,"value":4197},"\"Rolling back transaction: ",{"type":606,"tag":644,"props":4199,"children":4200},{"style":664},[4201],{"type":612,"value":1825},{"type":606,"tag":644,"props":4203,"children":4204},{"style":670},[4205],{"type":612,"value":3223},{"type":606,"tag":644,"props":4207,"children":4208},{"style":664},[4209],{"type":612,"value":1020},{"type":606,"tag":644,"props":4211,"children":4212},{"style":676},[4213],{"type":612,"value":1169},{"type":606,"tag":644,"props":4215,"children":4216},{"style":670},[4217],{"type":612,"value":1030},{"type":606,"tag":644,"props":4219,"children":4220},{"class":646,"line":263},[4221],{"type":606,"tag":644,"props":4222,"children":4223},{"style":650},[4224],{"type":612,"value":4225},"        # Rollback logic here\n",{"type":606,"tag":644,"props":4227,"children":4228},{"class":646,"line":272},[4229],{"type":606,"tag":644,"props":4230,"children":4231},{"style":659},[4232],{"type":612,"value":4233},"        raise\n",{"type":606,"tag":644,"props":4235,"children":4236},{"class":646,"line":281},[4237,4242],{"type":606,"tag":644,"props":4238,"children":4239},{"style":659},[4240],{"type":612,"value":4241},"    else",{"type":606,"tag":644,"props":4243,"children":4244},{"style":670},[4245],{"type":612,"value":710},{"type":606,"tag":644,"props":4247,"children":4248},{"class":646,"line":291},[4249,4253,4257,4262],{"type":606,"tag":644,"props":4250,"children":4251},{"style":664},[4252],{"type":612,"value":1056},{"type":606,"tag":644,"props":4254,"children":4255},{"style":670},[4256],{"type":612,"value":673},{"type":606,"tag":644,"props":4258,"children":4259},{"style":676},[4260],{"type":612,"value":4261},"\"Committing transaction\"",{"type":606,"tag":644,"props":4263,"children":4264},{"style":670},[4265],{"type":612,"value":1030},{"type":606,"tag":644,"props":4267,"children":4268},{"class":646,"line":302},[4269],{"type":606,"tag":644,"props":4270,"children":4271},{"style":650},[4272],{"type":612,"value":4273},"        # Commit logic here\n",{"type":606,"tag":644,"props":4275,"children":4276},{"class":646,"line":311},[4277,4281],{"type":606,"tag":644,"props":4278,"children":4279},{"style":659},[4280],{"type":612,"value":2127},{"type":606,"tag":644,"props":4282,"children":4283},{"style":670},[4284],{"type":612,"value":710},{"type":606,"tag":644,"props":4286,"children":4287},{"class":646,"line":320},[4288,4292,4296,4301],{"type":606,"tag":644,"props":4289,"children":4290},{"style":664},[4291],{"type":612,"value":1056},{"type":606,"tag":644,"props":4293,"children":4294},{"style":670},[4295],{"type":612,"value":673},{"type":606,"tag":644,"props":4297,"children":4298},{"style":676},[4299],{"type":612,"value":4300},"\"Closing database connection\"",{"type":606,"tag":644,"props":4302,"children":4303},{"style":670},[4304],{"type":612,"value":1030},{"type":606,"tag":644,"props":4306,"children":4307},{"class":646,"line":329},[4308],{"type":606,"tag":644,"props":4309,"children":4310},{"style":650},[4311],{"type":612,"value":4312},"        # Cleanup logic here\n",{"type":606,"tag":644,"props":4314,"children":4315},{"class":646,"line":338},[4316],{"type":606,"tag":644,"props":4317,"children":4318},{"emptyLinePlaceholder":13},[4319],{"type":612,"value":1077},{"type":606,"tag":644,"props":4321,"children":4322},{"class":646,"line":347},[4323],{"type":606,"tag":644,"props":4324,"children":4325},{"style":650},[4326],{"type":612,"value":4327},"# Example database usage\n",{"type":606,"tag":644,"props":4329,"children":4330},{"class":646,"line":356},[4331,4335,4340,4345,4349,4353],{"type":606,"tag":644,"props":4332,"children":4333},{"style":659},[4334],{"type":612,"value":626},{"type":606,"tag":644,"props":4336,"children":4337},{"style":670},[4338],{"type":612,"value":4339}," database_connection(",{"type":606,"tag":644,"props":4341,"children":4342},{"style":676},[4343],{"type":612,"value":4344},"\"postgresql://localhost/mydb\"",{"type":606,"tag":644,"props":4346,"children":4347},{"style":670},[4348],{"type":612,"value":694},{"type":606,"tag":644,"props":4350,"children":4351},{"style":659},[4352],{"type":612,"value":699},{"type":606,"tag":644,"props":4354,"children":4355},{"style":670},[4356],{"type":612,"value":4357}," conn:\n",{"type":606,"tag":644,"props":4359,"children":4360},{"class":646,"line":367},[4361,4365,4369,4373,4377,4381,4386,4390,4394],{"type":606,"tag":644,"props":4362,"children":4363},{"style":664},[4364],{"type":612,"value":740},{"type":606,"tag":644,"props":4366,"children":4367},{"style":670},[4368],{"type":612,"value":673},{"type":606,"tag":644,"props":4370,"children":4371},{"style":659},[4372],{"type":612,"value":1000},{"type":606,"tag":644,"props":4374,"children":4375},{"style":676},[4376],{"type":612,"value":2236},{"type":606,"tag":644,"props":4378,"children":4379},{"style":664},[4380],{"type":612,"value":1825},{"type":606,"tag":644,"props":4382,"children":4383},{"style":670},[4384],{"type":612,"value":4385},"conn",{"type":606,"tag":644,"props":4387,"children":4388},{"style":664},[4389],{"type":612,"value":1020},{"type":606,"tag":644,"props":4391,"children":4392},{"style":676},[4393],{"type":612,"value":1169},{"type":606,"tag":644,"props":4395,"children":4396},{"style":670},[4397],{"type":612,"value":1030},{"type":606,"tag":644,"props":4399,"children":4400},{"class":646,"line":376},[4401],{"type":606,"tag":644,"props":4402,"children":4403},{"style":650},[4404],{"type":612,"value":4405},"    # Database operations here\n",{"type":606,"tag":755,"props":4407,"children":4409},{"id":4408},"context-manager-patterns-reference",[4410],{"type":612,"value":4411},"📋 Context Manager Patterns Reference",{"type":606,"tag":4413,"props":4414,"children":4415},"table",{},[4416,4440],{"type":606,"tag":4417,"props":4418,"children":4419},"thead",{},[4420],{"type":606,"tag":4421,"props":4422,"children":4423},"tr",{},[4424,4430,4435],{"type":606,"tag":4425,"props":4426,"children":4427},"th",{},[4428],{"type":612,"value":4429},"Pattern",{"type":606,"tag":4425,"props":4431,"children":4432},{},[4433],{"type":612,"value":4434},"Use Case",{"type":606,"tag":4425,"props":4436,"children":4437},{},[4438],{"type":612,"value":4439},"Implementation",{"type":606,"tag":4441,"props":4442,"children":4443},"tbody",{},[4444,4467,4489,4511,4533,4557],{"type":606,"tag":4421,"props":4445,"children":4446},{},[4447,4453,4458],{"type":606,"tag":4448,"props":4449,"children":4450},"td",{},[4451],{"type":612,"value":4452},"File handling",{"type":606,"tag":4448,"props":4454,"children":4455},{},[4456],{"type":612,"value":4457},"Resource cleanup",{"type":606,"tag":4448,"props":4459,"children":4460},{},[4461],{"type":606,"tag":621,"props":4462,"children":4464},{"className":4463},[],[4465],{"type":612,"value":4466},"with open()",{"type":606,"tag":4421,"props":4468,"children":4469},{},[4470,4475,4480],{"type":606,"tag":4448,"props":4471,"children":4472},{},[4473],{"type":612,"value":4474},"Custom resource",{"type":606,"tag":4448,"props":4476,"children":4477},{},[4478],{"type":612,"value":4479},"Specific cleanup",{"type":606,"tag":4448,"props":4481,"children":4482},{},[4483],{"type":606,"tag":621,"props":4484,"children":4486},{"className":4485},[],[4487],{"type":612,"value":4488},"__enter__/__exit__",{"type":606,"tag":4421,"props":4490,"children":4491},{},[4492,4497,4502],{"type":606,"tag":4448,"props":4493,"children":4494},{},[4495],{"type":612,"value":4496},"Decorator",{"type":606,"tag":4448,"props":4498,"children":4499},{},[4500],{"type":612,"value":4501},"Simple cases",{"type":606,"tag":4448,"props":4503,"children":4504},{},[4505],{"type":606,"tag":621,"props":4506,"children":4508},{"className":4507},[],[4509],{"type":612,"value":4510},"@contextmanager",{"type":606,"tag":4421,"props":4512,"children":4513},{},[4514,4519,4524],{"type":606,"tag":4448,"props":4515,"children":4516},{},[4517],{"type":612,"value":4518},"Multiple resources",{"type":606,"tag":4448,"props":4520,"children":4521},{},[4522],{"type":612,"value":4523},"Complex scenarios",{"type":606,"tag":4448,"props":4525,"children":4526},{},[4527],{"type":606,"tag":621,"props":4528,"children":4530},{"className":4529},[],[4531],{"type":612,"value":4532},"ExitStack",{"type":606,"tag":4421,"props":4534,"children":4535},{},[4536,4541,4546],{"type":606,"tag":4448,"props":4537,"children":4538},{},[4539],{"type":612,"value":4540},"Error handling",{"type":606,"tag":4448,"props":4542,"children":4543},{},[4544],{"type":612,"value":4545},"Graceful failures",{"type":606,"tag":4448,"props":4547,"children":4548},{},[4549,4551],{"type":612,"value":4550},"Try/except in ",{"type":606,"tag":621,"props":4552,"children":4554},{"className":4553},[],[4555],{"type":612,"value":4556},"__exit__",{"type":606,"tag":4421,"props":4558,"children":4559},{},[4560,4565,4570],{"type":606,"tag":4448,"props":4561,"children":4562},{},[4563],{"type":612,"value":4564},"Timing",{"type":606,"tag":4448,"props":4566,"children":4567},{},[4568],{"type":612,"value":4569},"Performance monitoring",{"type":606,"tag":4448,"props":4571,"children":4572},{},[4573,4578],{"type":606,"tag":621,"props":4574,"children":4576},{"className":4575},[],[4577],{"type":612,"value":4510},{"type":612,"value":4579}," with timing",{"type":606,"tag":755,"props":4581,"children":4583},{"id":4582},"key-takeaways",[4584],{"type":612,"value":4585},"🎯 Key Takeaways",{"type":606,"tag":767,"props":4587,"children":4591},{"emoji":4588,"title":4589,"type":4590},"📚","Context Manager Essentials","success",[4592,4600,4629,4637,4659,4667,4704],{"type":606,"tag":615,"props":4593,"children":4594},{},[4595],{"type":606,"tag":777,"props":4596,"children":4597},{},[4598],{"type":612,"value":4599},"Basic Usage:",{"type":606,"tag":783,"props":4601,"children":4602},{},[4603,4615,4620,4625],{"type":606,"tag":787,"props":4604,"children":4605},{},[4606,4608,4613],{"type":612,"value":4607},"Always use ",{"type":606,"tag":621,"props":4609,"children":4611},{"className":4610},[],[4612],{"type":612,"value":626},{"type":612,"value":4614}," for file operations",{"type":606,"tag":787,"props":4616,"children":4617},{},[4618],{"type":612,"value":4619},"Automatic resource cleanup",{"type":606,"tag":787,"props":4621,"children":4622},{},[4623],{"type":612,"value":4624},"Exception safety guaranteed",{"type":606,"tag":787,"props":4626,"children":4627},{},[4628],{"type":612,"value":843},{"type":606,"tag":615,"props":4630,"children":4631},{},[4632],{"type":606,"tag":777,"props":4633,"children":4634},{},[4635],{"type":612,"value":4636},"Advanced Features:",{"type":606,"tag":783,"props":4638,"children":4639},{},[4640,4645,4650,4655],{"type":606,"tag":787,"props":4641,"children":4642},{},[4643],{"type":612,"value":4644},"Custom context managers",{"type":606,"tag":787,"props":4646,"children":4647},{},[4648],{"type":612,"value":4649},"Multiple resource handling",{"type":606,"tag":787,"props":4651,"children":4652},{},[4653],{"type":612,"value":4654},"Error handling and recovery",{"type":606,"tag":787,"props":4656,"children":4657},{},[4658],{"type":612,"value":4569},{"type":606,"tag":615,"props":4660,"children":4661},{},[4662],{"type":606,"tag":777,"props":4663,"children":4664},{},[4665],{"type":612,"value":4666},"Best Practices:",{"type":606,"tag":783,"props":4668,"children":4669},{},[4670,4682,4687,4692],{"type":606,"tag":787,"props":4671,"children":4672},{},[4673,4675,4680],{"type":612,"value":4674},"Use ",{"type":606,"tag":621,"props":4676,"children":4678},{"className":4677},[],[4679],{"type":612,"value":626},{"type":612,"value":4681}," for all resource management",{"type":606,"tag":787,"props":4683,"children":4684},{},[4685],{"type":612,"value":4686},"Implement proper cleanup logic",{"type":606,"tag":787,"props":4688,"children":4689},{},[4690],{"type":612,"value":4691},"Handle exceptions appropriately",{"type":606,"tag":787,"props":4693,"children":4694},{},[4695,4697,4702],{"type":612,"value":4696},"Consider using ",{"type":606,"tag":621,"props":4698,"children":4700},{"className":4699},[],[4701],{"type":612,"value":4532},{"type":612,"value":4703}," for complex cases",{"type":606,"tag":615,"props":4705,"children":4706},{},[4707,4712],{"type":606,"tag":777,"props":4708,"children":4709},{},[4710],{"type":612,"value":4711},"Remember:",{"type":612,"value":4713}," Context managers make your code more reliable and easier to maintain!",{"type":606,"tag":4715,"props":4716,"children":4717},"style",{},[4718],{"type":612,"value":4719},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .app-dark-mode .shiki span {color: var(--shiki-app-dark-mode);background: var(--shiki-app-dark-mode-bg);font-style: var(--shiki-app-dark-mode-font-style);font-weight: var(--shiki-app-dark-mode-font-weight);text-decoration: var(--shiki-app-dark-mode-text-decoration);}html.app-dark-mode .shiki span {color: var(--shiki-app-dark-mode);background: var(--shiki-app-dark-mode-bg);font-style: var(--shiki-app-dark-mode-font-style);font-weight: var(--shiki-app-dark-mode-font-weight);text-decoration: var(--shiki-app-dark-mode-text-decoration);}",{"title":8,"searchDepth":36,"depth":36,"links":4721},[4722,4728,4735,4736],{"id":757,"depth":27,"text":760,"children":4723},[4724,4725,4726,4727],{"id":857,"depth":36,"text":860},{"id":1201,"depth":36,"text":1204},{"id":1431,"depth":36,"text":1434},{"id":1939,"depth":36,"text":1942},{"id":2260,"depth":27,"text":2263,"children":4729},[4730,4731,4732,4733,4734],{"id":2271,"depth":36,"text":2274},{"id":2639,"depth":36,"text":2642},{"id":355,"depth":36,"text":353},{"id":3366,"depth":36,"text":3369},{"id":3786,"depth":36,"text":3789},{"id":4408,"depth":27,"text":4411},{"id":4582,"depth":27,"text":4585},1782373757663]