[{"data":1,"prerenderedAt":3549},["ShallowReactive",2],{"tutorials-python-how-to":3,"category-items-python-how-to":600,"content-/python-how-to/write-to-files":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",[231],{"_path":232,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":233,"description":234,"slug":235,"parentId":213,"order":236,"body":602,"_type":15,"_id":237,"_source":17,"_file":238,"_stem":239,"_extension":20},{"type":603,"children":604,"toc":3535},"root",[605,614,620,757,764,769,866,873,1176,1182,1422,1428,1851,1857,1862,1866,2272,2278,2695,2701,3211,3217,3382,3388,3529],{"type":606,"tag":607,"props":608,"children":610},"element","h1",{"id":609},"️-writing-to-files",[611],{"type":612,"value":613},"text","✏️ Writing to Files",{"type":606,"tag":615,"props":616,"children":617},"p",{},[618],{"type":612,"value":619},"Python provides multiple ways to write to files. Understanding these methods is essential for data output, logging, and result storage.",{"type":606,"tag":621,"props":622,"children":623},"code-try",{},[624],{"type":606,"tag":625,"props":626,"children":630},"pre",{"className":627,"code":628,"language":629,"meta":8,"style":8},"language-python shiki shiki-themes github-light github-dark","# Basic file writing\nwith open('output.txt', 'w') as file:\n    file.write(\"Hello, Python!\")\n    file.write(\"\\nThis is a new line.\")\n","python",[631],{"type":606,"tag":632,"props":633,"children":634},"code",{"__ignoreMap":8},[635,646,704,727],{"type":606,"tag":636,"props":637,"children":639},"span",{"class":638,"line":12},"line",[640],{"type":606,"tag":636,"props":641,"children":643},{"style":642},"--shiki-default:#6A737D;--shiki-app-dark-mode:#6A737D",[644],{"type":612,"value":645},"# Basic file writing\n",{"type":606,"tag":636,"props":647,"children":648},{"class":638,"line":27},[649,655,661,667,673,678,683,688,693,699],{"type":606,"tag":636,"props":650,"children":652},{"style":651},"--shiki-default:#D73A49;--shiki-app-dark-mode:#F97583",[653],{"type":612,"value":654},"with",{"type":606,"tag":636,"props":656,"children":658},{"style":657},"--shiki-default:#005CC5;--shiki-app-dark-mode:#79B8FF",[659],{"type":612,"value":660}," open",{"type":606,"tag":636,"props":662,"children":664},{"style":663},"--shiki-default:#24292E;--shiki-app-dark-mode:#E1E4E8",[665],{"type":612,"value":666},"(",{"type":606,"tag":636,"props":668,"children":670},{"style":669},"--shiki-default:#032F62;--shiki-app-dark-mode:#9ECBFF",[671],{"type":612,"value":672},"'output.txt'",{"type":606,"tag":636,"props":674,"children":675},{"style":663},[676],{"type":612,"value":677},", ",{"type":606,"tag":636,"props":679,"children":680},{"style":669},[681],{"type":612,"value":682},"'w'",{"type":606,"tag":636,"props":684,"children":685},{"style":663},[686],{"type":612,"value":687},") ",{"type":606,"tag":636,"props":689,"children":690},{"style":651},[691],{"type":612,"value":692},"as",{"type":606,"tag":636,"props":694,"children":696},{"style":695},"--shiki-default:#E36209;--shiki-app-dark-mode:#FFAB70",[697],{"type":612,"value":698}," file",{"type":606,"tag":636,"props":700,"children":701},{"style":663},[702],{"type":612,"value":703},":\n",{"type":606,"tag":636,"props":705,"children":706},{"class":638,"line":36},[707,712,717,722],{"type":606,"tag":636,"props":708,"children":709},{"style":695},[710],{"type":612,"value":711},"    file",{"type":606,"tag":636,"props":713,"children":714},{"style":663},[715],{"type":612,"value":716},".write(",{"type":606,"tag":636,"props":718,"children":719},{"style":669},[720],{"type":612,"value":721},"\"Hello, Python!\"",{"type":606,"tag":636,"props":723,"children":724},{"style":663},[725],{"type":612,"value":726},")\n",{"type":606,"tag":636,"props":728,"children":729},{"class":638,"line":45},[730,734,738,743,748,753],{"type":606,"tag":636,"props":731,"children":732},{"style":695},[733],{"type":612,"value":711},{"type":606,"tag":636,"props":735,"children":736},{"style":663},[737],{"type":612,"value":716},{"type":606,"tag":636,"props":739,"children":740},{"style":669},[741],{"type":612,"value":742},"\"",{"type":606,"tag":636,"props":744,"children":745},{"style":657},[746],{"type":612,"value":747},"\\n",{"type":606,"tag":636,"props":749,"children":750},{"style":669},[751],{"type":612,"value":752},"This is a new line.\"",{"type":606,"tag":636,"props":754,"children":755},{"style":663},[756],{"type":612,"value":726},{"type":606,"tag":758,"props":759,"children":761},"h2",{"id":760},"writing-methods",[762],{"type":612,"value":763},"🎯 Writing Methods",{"type":606,"tag":615,"props":765,"children":766},{},[767],{"type":612,"value":768},"Python offers several approaches to write to files.",{"type":606,"tag":770,"props":771,"children":775},"info-box",{"emoji":772,"title":773,"type":774},"📝","File Writing Methods","info",[776,785,823,831],{"type":606,"tag":615,"props":777,"children":778},{},[779],{"type":606,"tag":780,"props":781,"children":782},"strong",{},[783],{"type":612,"value":784},"Basic Methods:",{"type":606,"tag":786,"props":787,"children":788},"ul",{},[789,801,812],{"type":606,"tag":790,"props":791,"children":792},"li",{},[793,799],{"type":606,"tag":632,"props":794,"children":796},{"className":795},[],[797],{"type":612,"value":798},".write()",{"type":612,"value":800},": Write string to file",{"type":606,"tag":790,"props":802,"children":803},{},[804,810],{"type":606,"tag":632,"props":805,"children":807},{"className":806},[],[808],{"type":612,"value":809},".writelines()",{"type":612,"value":811},": Write list of strings",{"type":606,"tag":790,"props":813,"children":814},{},[815,821],{"type":606,"tag":632,"props":816,"children":818},{"className":817},[],[819],{"type":612,"value":820},"print()",{"type":612,"value":822},": Write with print function",{"type":606,"tag":615,"props":824,"children":825},{},[826],{"type":606,"tag":780,"props":827,"children":828},{},[829],{"type":612,"value":830},"File Modes:",{"type":606,"tag":786,"props":832,"children":833},{},[834,844,855],{"type":606,"tag":790,"props":835,"children":836},{},[837,842],{"type":606,"tag":632,"props":838,"children":840},{"className":839},[],[841],{"type":612,"value":682},{"type":612,"value":843},": Write (overwrites existing)",{"type":606,"tag":790,"props":845,"children":846},{},[847,853],{"type":606,"tag":632,"props":848,"children":850},{"className":849},[],[851],{"type":612,"value":852},"'a'",{"type":612,"value":854},": Append to existing file",{"type":606,"tag":790,"props":856,"children":857},{},[858,864],{"type":606,"tag":632,"props":859,"children":861},{"className":860},[],[862],{"type":612,"value":863},"'x'",{"type":612,"value":865},": Exclusive creation (fails if exists)",{"type":606,"tag":867,"props":868,"children":870},"h3",{"id":869},"basic-writing-methods",[871],{"type":612,"value":872},"Basic Writing Methods",{"type":606,"tag":621,"props":874,"children":875},{},[876],{"type":606,"tag":625,"props":877,"children":879},{"className":627,"code":878,"language":629,"meta":8,"style":8},"# Basic file writing\nfilename = 'output.txt'\n\n# Write method\nwith open(filename, 'w') as file:\n    file.write(\"First line\\n\")\n    file.write(\"Second line\\n\")\n\n# Writing multiple lines at once\nlines = [\"Line 1\\n\", \"Line 2\\n\", \"Line 3\\n\"]\nwith open(filename, 'w') as file:\n    file.writelines(lines)\n\nprint(\"Basic writing completed\")\n",[880],{"type":606,"tag":632,"props":881,"children":882},{"__ignoreMap":8},[883,890,908,916,924,960,988,1016,1023,1032,1101,1136,1148,1155],{"type":606,"tag":636,"props":884,"children":885},{"class":638,"line":12},[886],{"type":606,"tag":636,"props":887,"children":888},{"style":642},[889],{"type":612,"value":645},{"type":606,"tag":636,"props":891,"children":892},{"class":638,"line":27},[893,898,903],{"type":606,"tag":636,"props":894,"children":895},{"style":663},[896],{"type":612,"value":897},"filename ",{"type":606,"tag":636,"props":899,"children":900},{"style":651},[901],{"type":612,"value":902},"=",{"type":606,"tag":636,"props":904,"children":905},{"style":669},[906],{"type":612,"value":907}," 'output.txt'\n",{"type":606,"tag":636,"props":909,"children":910},{"class":638,"line":36},[911],{"type":606,"tag":636,"props":912,"children":913},{"emptyLinePlaceholder":13},[914],{"type":612,"value":915},"\n",{"type":606,"tag":636,"props":917,"children":918},{"class":638,"line":45},[919],{"type":606,"tag":636,"props":920,"children":921},{"style":642},[922],{"type":612,"value":923},"# Write method\n",{"type":606,"tag":636,"props":925,"children":926},{"class":638,"line":54},[927,931,935,940,944,948,952,956],{"type":606,"tag":636,"props":928,"children":929},{"style":651},[930],{"type":612,"value":654},{"type":606,"tag":636,"props":932,"children":933},{"style":657},[934],{"type":612,"value":660},{"type":606,"tag":636,"props":936,"children":937},{"style":663},[938],{"type":612,"value":939},"(filename, ",{"type":606,"tag":636,"props":941,"children":942},{"style":669},[943],{"type":612,"value":682},{"type":606,"tag":636,"props":945,"children":946},{"style":663},[947],{"type":612,"value":687},{"type":606,"tag":636,"props":949,"children":950},{"style":651},[951],{"type":612,"value":692},{"type":606,"tag":636,"props":953,"children":954},{"style":695},[955],{"type":612,"value":698},{"type":606,"tag":636,"props":957,"children":958},{"style":663},[959],{"type":612,"value":703},{"type":606,"tag":636,"props":961,"children":962},{"class":638,"line":63},[963,967,971,976,980,984],{"type":606,"tag":636,"props":964,"children":965},{"style":695},[966],{"type":612,"value":711},{"type":606,"tag":636,"props":968,"children":969},{"style":663},[970],{"type":612,"value":716},{"type":606,"tag":636,"props":972,"children":973},{"style":669},[974],{"type":612,"value":975},"\"First line",{"type":606,"tag":636,"props":977,"children":978},{"style":657},[979],{"type":612,"value":747},{"type":606,"tag":636,"props":981,"children":982},{"style":669},[983],{"type":612,"value":742},{"type":606,"tag":636,"props":985,"children":986},{"style":663},[987],{"type":612,"value":726},{"type":606,"tag":636,"props":989,"children":990},{"class":638,"line":72},[991,995,999,1004,1008,1012],{"type":606,"tag":636,"props":992,"children":993},{"style":695},[994],{"type":612,"value":711},{"type":606,"tag":636,"props":996,"children":997},{"style":663},[998],{"type":612,"value":716},{"type":606,"tag":636,"props":1000,"children":1001},{"style":669},[1002],{"type":612,"value":1003},"\"Second line",{"type":606,"tag":636,"props":1005,"children":1006},{"style":657},[1007],{"type":612,"value":747},{"type":606,"tag":636,"props":1009,"children":1010},{"style":669},[1011],{"type":612,"value":742},{"type":606,"tag":636,"props":1013,"children":1014},{"style":663},[1015],{"type":612,"value":726},{"type":606,"tag":636,"props":1017,"children":1018},{"class":638,"line":81},[1019],{"type":606,"tag":636,"props":1020,"children":1021},{"emptyLinePlaceholder":13},[1022],{"type":612,"value":915},{"type":606,"tag":636,"props":1024,"children":1026},{"class":638,"line":1025},9,[1027],{"type":606,"tag":636,"props":1028,"children":1029},{"style":642},[1030],{"type":612,"value":1031},"# Writing multiple lines at once\n",{"type":606,"tag":636,"props":1033,"children":1034},{"class":638,"line":99},[1035,1040,1044,1049,1054,1058,1062,1066,1071,1075,1079,1083,1088,1092,1096],{"type":606,"tag":636,"props":1036,"children":1037},{"style":663},[1038],{"type":612,"value":1039},"lines ",{"type":606,"tag":636,"props":1041,"children":1042},{"style":651},[1043],{"type":612,"value":902},{"type":606,"tag":636,"props":1045,"children":1046},{"style":663},[1047],{"type":612,"value":1048}," [",{"type":606,"tag":636,"props":1050,"children":1051},{"style":669},[1052],{"type":612,"value":1053},"\"Line 1",{"type":606,"tag":636,"props":1055,"children":1056},{"style":657},[1057],{"type":612,"value":747},{"type":606,"tag":636,"props":1059,"children":1060},{"style":669},[1061],{"type":612,"value":742},{"type":606,"tag":636,"props":1063,"children":1064},{"style":663},[1065],{"type":612,"value":677},{"type":606,"tag":636,"props":1067,"children":1068},{"style":669},[1069],{"type":612,"value":1070},"\"Line 2",{"type":606,"tag":636,"props":1072,"children":1073},{"style":657},[1074],{"type":612,"value":747},{"type":606,"tag":636,"props":1076,"children":1077},{"style":669},[1078],{"type":612,"value":742},{"type":606,"tag":636,"props":1080,"children":1081},{"style":663},[1082],{"type":612,"value":677},{"type":606,"tag":636,"props":1084,"children":1085},{"style":669},[1086],{"type":612,"value":1087},"\"Line 3",{"type":606,"tag":636,"props":1089,"children":1090},{"style":657},[1091],{"type":612,"value":747},{"type":606,"tag":636,"props":1093,"children":1094},{"style":669},[1095],{"type":612,"value":742},{"type":606,"tag":636,"props":1097,"children":1098},{"style":663},[1099],{"type":612,"value":1100},"]\n",{"type":606,"tag":636,"props":1102,"children":1103},{"class":638,"line":108},[1104,1108,1112,1116,1120,1124,1128,1132],{"type":606,"tag":636,"props":1105,"children":1106},{"style":651},[1107],{"type":612,"value":654},{"type":606,"tag":636,"props":1109,"children":1110},{"style":657},[1111],{"type":612,"value":660},{"type":606,"tag":636,"props":1113,"children":1114},{"style":663},[1115],{"type":612,"value":939},{"type":606,"tag":636,"props":1117,"children":1118},{"style":669},[1119],{"type":612,"value":682},{"type":606,"tag":636,"props":1121,"children":1122},{"style":663},[1123],{"type":612,"value":687},{"type":606,"tag":636,"props":1125,"children":1126},{"style":651},[1127],{"type":612,"value":692},{"type":606,"tag":636,"props":1129,"children":1130},{"style":695},[1131],{"type":612,"value":698},{"type":606,"tag":636,"props":1133,"children":1134},{"style":663},[1135],{"type":612,"value":703},{"type":606,"tag":636,"props":1137,"children":1138},{"class":638,"line":117},[1139,1143],{"type":606,"tag":636,"props":1140,"children":1141},{"style":695},[1142],{"type":612,"value":711},{"type":606,"tag":636,"props":1144,"children":1145},{"style":663},[1146],{"type":612,"value":1147},".writelines(lines)\n",{"type":606,"tag":636,"props":1149,"children":1150},{"class":638,"line":126},[1151],{"type":606,"tag":636,"props":1152,"children":1153},{"emptyLinePlaceholder":13},[1154],{"type":612,"value":915},{"type":606,"tag":636,"props":1156,"children":1157},{"class":638,"line":135},[1158,1163,1167,1172],{"type":606,"tag":636,"props":1159,"children":1160},{"style":657},[1161],{"type":612,"value":1162},"print",{"type":606,"tag":636,"props":1164,"children":1165},{"style":663},[1166],{"type":612,"value":666},{"type":606,"tag":636,"props":1168,"children":1169},{"style":669},[1170],{"type":612,"value":1171},"\"Basic writing completed\"",{"type":606,"tag":636,"props":1173,"children":1174},{"style":663},[1175],{"type":612,"value":726},{"type":606,"tag":867,"props":1177,"children":1179},{"id":1178},"writing-with-print-function",[1180],{"type":612,"value":1181},"Writing with Print Function",{"type":606,"tag":621,"props":1183,"children":1184},{},[1185],{"type":606,"tag":625,"props":1186,"children":1188},{"className":627,"code":1187,"language":629,"meta":8,"style":8},"# Using print function for file writing\nfilename = 'print_output.txt'\n\nwith open(filename, 'w') as file:\n    print(\"Hello from print!\", file=file)\n    print(\"Another line\", file=file)\n    print(\"Numbers:\", 1, 2, 3, file=file)\n\nprint(\"Print-based writing completed\")\n",[1189],{"type":606,"tag":632,"props":1190,"children":1191},{"__ignoreMap":8},[1192,1200,1216,1223,1258,1296,1332,1395,1402],{"type":606,"tag":636,"props":1193,"children":1194},{"class":638,"line":12},[1195],{"type":606,"tag":636,"props":1196,"children":1197},{"style":642},[1198],{"type":612,"value":1199},"# Using print function for file writing\n",{"type":606,"tag":636,"props":1201,"children":1202},{"class":638,"line":27},[1203,1207,1211],{"type":606,"tag":636,"props":1204,"children":1205},{"style":663},[1206],{"type":612,"value":897},{"type":606,"tag":636,"props":1208,"children":1209},{"style":651},[1210],{"type":612,"value":902},{"type":606,"tag":636,"props":1212,"children":1213},{"style":669},[1214],{"type":612,"value":1215}," 'print_output.txt'\n",{"type":606,"tag":636,"props":1217,"children":1218},{"class":638,"line":36},[1219],{"type":606,"tag":636,"props":1220,"children":1221},{"emptyLinePlaceholder":13},[1222],{"type":612,"value":915},{"type":606,"tag":636,"props":1224,"children":1225},{"class":638,"line":45},[1226,1230,1234,1238,1242,1246,1250,1254],{"type":606,"tag":636,"props":1227,"children":1228},{"style":651},[1229],{"type":612,"value":654},{"type":606,"tag":636,"props":1231,"children":1232},{"style":657},[1233],{"type":612,"value":660},{"type":606,"tag":636,"props":1235,"children":1236},{"style":663},[1237],{"type":612,"value":939},{"type":606,"tag":636,"props":1239,"children":1240},{"style":669},[1241],{"type":612,"value":682},{"type":606,"tag":636,"props":1243,"children":1244},{"style":663},[1245],{"type":612,"value":687},{"type":606,"tag":636,"props":1247,"children":1248},{"style":651},[1249],{"type":612,"value":692},{"type":606,"tag":636,"props":1251,"children":1252},{"style":695},[1253],{"type":612,"value":698},{"type":606,"tag":636,"props":1255,"children":1256},{"style":663},[1257],{"type":612,"value":703},{"type":606,"tag":636,"props":1259,"children":1260},{"class":638,"line":54},[1261,1266,1270,1275,1279,1284,1288,1292],{"type":606,"tag":636,"props":1262,"children":1263},{"style":657},[1264],{"type":612,"value":1265},"    print",{"type":606,"tag":636,"props":1267,"children":1268},{"style":663},[1269],{"type":612,"value":666},{"type":606,"tag":636,"props":1271,"children":1272},{"style":669},[1273],{"type":612,"value":1274},"\"Hello from print!\"",{"type":606,"tag":636,"props":1276,"children":1277},{"style":663},[1278],{"type":612,"value":677},{"type":606,"tag":636,"props":1280,"children":1281},{"style":695},[1282],{"type":612,"value":1283},"file",{"type":606,"tag":636,"props":1285,"children":1286},{"style":651},[1287],{"type":612,"value":902},{"type":606,"tag":636,"props":1289,"children":1290},{"style":695},[1291],{"type":612,"value":1283},{"type":606,"tag":636,"props":1293,"children":1294},{"style":663},[1295],{"type":612,"value":726},{"type":606,"tag":636,"props":1297,"children":1298},{"class":638,"line":63},[1299,1303,1307,1312,1316,1320,1324,1328],{"type":606,"tag":636,"props":1300,"children":1301},{"style":657},[1302],{"type":612,"value":1265},{"type":606,"tag":636,"props":1304,"children":1305},{"style":663},[1306],{"type":612,"value":666},{"type":606,"tag":636,"props":1308,"children":1309},{"style":669},[1310],{"type":612,"value":1311},"\"Another line\"",{"type":606,"tag":636,"props":1313,"children":1314},{"style":663},[1315],{"type":612,"value":677},{"type":606,"tag":636,"props":1317,"children":1318},{"style":695},[1319],{"type":612,"value":1283},{"type":606,"tag":636,"props":1321,"children":1322},{"style":651},[1323],{"type":612,"value":902},{"type":606,"tag":636,"props":1325,"children":1326},{"style":695},[1327],{"type":612,"value":1283},{"type":606,"tag":636,"props":1329,"children":1330},{"style":663},[1331],{"type":612,"value":726},{"type":606,"tag":636,"props":1333,"children":1334},{"class":638,"line":72},[1335,1339,1343,1348,1352,1357,1361,1366,1370,1375,1379,1383,1387,1391],{"type":606,"tag":636,"props":1336,"children":1337},{"style":657},[1338],{"type":612,"value":1265},{"type":606,"tag":636,"props":1340,"children":1341},{"style":663},[1342],{"type":612,"value":666},{"type":606,"tag":636,"props":1344,"children":1345},{"style":669},[1346],{"type":612,"value":1347},"\"Numbers:\"",{"type":606,"tag":636,"props":1349,"children":1350},{"style":663},[1351],{"type":612,"value":677},{"type":606,"tag":636,"props":1353,"children":1354},{"style":657},[1355],{"type":612,"value":1356},"1",{"type":606,"tag":636,"props":1358,"children":1359},{"style":663},[1360],{"type":612,"value":677},{"type":606,"tag":636,"props":1362,"children":1363},{"style":657},[1364],{"type":612,"value":1365},"2",{"type":606,"tag":636,"props":1367,"children":1368},{"style":663},[1369],{"type":612,"value":677},{"type":606,"tag":636,"props":1371,"children":1372},{"style":657},[1373],{"type":612,"value":1374},"3",{"type":606,"tag":636,"props":1376,"children":1377},{"style":663},[1378],{"type":612,"value":677},{"type":606,"tag":636,"props":1380,"children":1381},{"style":695},[1382],{"type":612,"value":1283},{"type":606,"tag":636,"props":1384,"children":1385},{"style":651},[1386],{"type":612,"value":902},{"type":606,"tag":636,"props":1388,"children":1389},{"style":695},[1390],{"type":612,"value":1283},{"type":606,"tag":636,"props":1392,"children":1393},{"style":663},[1394],{"type":612,"value":726},{"type":606,"tag":636,"props":1396,"children":1397},{"class":638,"line":81},[1398],{"type":606,"tag":636,"props":1399,"children":1400},{"emptyLinePlaceholder":13},[1401],{"type":612,"value":915},{"type":606,"tag":636,"props":1403,"children":1404},{"class":638,"line":1025},[1405,1409,1413,1418],{"type":606,"tag":636,"props":1406,"children":1407},{"style":657},[1408],{"type":612,"value":1162},{"type":606,"tag":636,"props":1410,"children":1411},{"style":663},[1412],{"type":612,"value":666},{"type":606,"tag":636,"props":1414,"children":1415},{"style":669},[1416],{"type":612,"value":1417},"\"Print-based writing completed\"",{"type":606,"tag":636,"props":1419,"children":1420},{"style":663},[1421],{"type":612,"value":726},{"type":606,"tag":867,"props":1423,"children":1425},{"id":1424},"appending-and-formatting",[1426],{"type":612,"value":1427},"Appending and Formatting",{"type":606,"tag":621,"props":1429,"children":1430},{},[1431],{"type":606,"tag":625,"props":1432,"children":1434},{"className":627,"code":1433,"language":629,"meta":8,"style":8},"# Appending to existing file\nfilename = 'append_test.txt'\n\n# First write some content\nwith open(filename, 'w') as file:\n    file.write(\"Initial content\\n\")\n\n# Then append more content\nwith open(filename, 'a') as file:\n    file.write(\"Appended line\\n\")\n\n# Writing with formatting\ndata = {'name': 'Alice', 'age': 25}\nwith open(filename, 'a') as file:\n    file.write(f\"Name: {data['name']}\\n\")\n    file.write(f\"Age: {data['age']}\\n\")\n\nprint(\"Appending and formatting completed\")\n",[1435],{"type":606,"tag":632,"props":1436,"children":1437},{"__ignoreMap":8},[1438,1446,1462,1469,1477,1512,1540,1547,1555,1590,1618,1625,1633,1688,1723,1776,1824,1831],{"type":606,"tag":636,"props":1439,"children":1440},{"class":638,"line":12},[1441],{"type":606,"tag":636,"props":1442,"children":1443},{"style":642},[1444],{"type":612,"value":1445},"# Appending to existing file\n",{"type":606,"tag":636,"props":1447,"children":1448},{"class":638,"line":27},[1449,1453,1457],{"type":606,"tag":636,"props":1450,"children":1451},{"style":663},[1452],{"type":612,"value":897},{"type":606,"tag":636,"props":1454,"children":1455},{"style":651},[1456],{"type":612,"value":902},{"type":606,"tag":636,"props":1458,"children":1459},{"style":669},[1460],{"type":612,"value":1461}," 'append_test.txt'\n",{"type":606,"tag":636,"props":1463,"children":1464},{"class":638,"line":36},[1465],{"type":606,"tag":636,"props":1466,"children":1467},{"emptyLinePlaceholder":13},[1468],{"type":612,"value":915},{"type":606,"tag":636,"props":1470,"children":1471},{"class":638,"line":45},[1472],{"type":606,"tag":636,"props":1473,"children":1474},{"style":642},[1475],{"type":612,"value":1476},"# First write some content\n",{"type":606,"tag":636,"props":1478,"children":1479},{"class":638,"line":54},[1480,1484,1488,1492,1496,1500,1504,1508],{"type":606,"tag":636,"props":1481,"children":1482},{"style":651},[1483],{"type":612,"value":654},{"type":606,"tag":636,"props":1485,"children":1486},{"style":657},[1487],{"type":612,"value":660},{"type":606,"tag":636,"props":1489,"children":1490},{"style":663},[1491],{"type":612,"value":939},{"type":606,"tag":636,"props":1493,"children":1494},{"style":669},[1495],{"type":612,"value":682},{"type":606,"tag":636,"props":1497,"children":1498},{"style":663},[1499],{"type":612,"value":687},{"type":606,"tag":636,"props":1501,"children":1502},{"style":651},[1503],{"type":612,"value":692},{"type":606,"tag":636,"props":1505,"children":1506},{"style":695},[1507],{"type":612,"value":698},{"type":606,"tag":636,"props":1509,"children":1510},{"style":663},[1511],{"type":612,"value":703},{"type":606,"tag":636,"props":1513,"children":1514},{"class":638,"line":63},[1515,1519,1523,1528,1532,1536],{"type":606,"tag":636,"props":1516,"children":1517},{"style":695},[1518],{"type":612,"value":711},{"type":606,"tag":636,"props":1520,"children":1521},{"style":663},[1522],{"type":612,"value":716},{"type":606,"tag":636,"props":1524,"children":1525},{"style":669},[1526],{"type":612,"value":1527},"\"Initial content",{"type":606,"tag":636,"props":1529,"children":1530},{"style":657},[1531],{"type":612,"value":747},{"type":606,"tag":636,"props":1533,"children":1534},{"style":669},[1535],{"type":612,"value":742},{"type":606,"tag":636,"props":1537,"children":1538},{"style":663},[1539],{"type":612,"value":726},{"type":606,"tag":636,"props":1541,"children":1542},{"class":638,"line":72},[1543],{"type":606,"tag":636,"props":1544,"children":1545},{"emptyLinePlaceholder":13},[1546],{"type":612,"value":915},{"type":606,"tag":636,"props":1548,"children":1549},{"class":638,"line":81},[1550],{"type":606,"tag":636,"props":1551,"children":1552},{"style":642},[1553],{"type":612,"value":1554},"# Then append more content\n",{"type":606,"tag":636,"props":1556,"children":1557},{"class":638,"line":1025},[1558,1562,1566,1570,1574,1578,1582,1586],{"type":606,"tag":636,"props":1559,"children":1560},{"style":651},[1561],{"type":612,"value":654},{"type":606,"tag":636,"props":1563,"children":1564},{"style":657},[1565],{"type":612,"value":660},{"type":606,"tag":636,"props":1567,"children":1568},{"style":663},[1569],{"type":612,"value":939},{"type":606,"tag":636,"props":1571,"children":1572},{"style":669},[1573],{"type":612,"value":852},{"type":606,"tag":636,"props":1575,"children":1576},{"style":663},[1577],{"type":612,"value":687},{"type":606,"tag":636,"props":1579,"children":1580},{"style":651},[1581],{"type":612,"value":692},{"type":606,"tag":636,"props":1583,"children":1584},{"style":695},[1585],{"type":612,"value":698},{"type":606,"tag":636,"props":1587,"children":1588},{"style":663},[1589],{"type":612,"value":703},{"type":606,"tag":636,"props":1591,"children":1592},{"class":638,"line":99},[1593,1597,1601,1606,1610,1614],{"type":606,"tag":636,"props":1594,"children":1595},{"style":695},[1596],{"type":612,"value":711},{"type":606,"tag":636,"props":1598,"children":1599},{"style":663},[1600],{"type":612,"value":716},{"type":606,"tag":636,"props":1602,"children":1603},{"style":669},[1604],{"type":612,"value":1605},"\"Appended line",{"type":606,"tag":636,"props":1607,"children":1608},{"style":657},[1609],{"type":612,"value":747},{"type":606,"tag":636,"props":1611,"children":1612},{"style":669},[1613],{"type":612,"value":742},{"type":606,"tag":636,"props":1615,"children":1616},{"style":663},[1617],{"type":612,"value":726},{"type":606,"tag":636,"props":1619,"children":1620},{"class":638,"line":108},[1621],{"type":606,"tag":636,"props":1622,"children":1623},{"emptyLinePlaceholder":13},[1624],{"type":612,"value":915},{"type":606,"tag":636,"props":1626,"children":1627},{"class":638,"line":117},[1628],{"type":606,"tag":636,"props":1629,"children":1630},{"style":642},[1631],{"type":612,"value":1632},"# Writing with formatting\n",{"type":606,"tag":636,"props":1634,"children":1635},{"class":638,"line":126},[1636,1641,1645,1650,1655,1660,1665,1669,1674,1678,1683],{"type":606,"tag":636,"props":1637,"children":1638},{"style":663},[1639],{"type":612,"value":1640},"data ",{"type":606,"tag":636,"props":1642,"children":1643},{"style":651},[1644],{"type":612,"value":902},{"type":606,"tag":636,"props":1646,"children":1647},{"style":663},[1648],{"type":612,"value":1649}," {",{"type":606,"tag":636,"props":1651,"children":1652},{"style":669},[1653],{"type":612,"value":1654},"'name'",{"type":606,"tag":636,"props":1656,"children":1657},{"style":663},[1658],{"type":612,"value":1659},": ",{"type":606,"tag":636,"props":1661,"children":1662},{"style":669},[1663],{"type":612,"value":1664},"'Alice'",{"type":606,"tag":636,"props":1666,"children":1667},{"style":663},[1668],{"type":612,"value":677},{"type":606,"tag":636,"props":1670,"children":1671},{"style":669},[1672],{"type":612,"value":1673},"'age'",{"type":606,"tag":636,"props":1675,"children":1676},{"style":663},[1677],{"type":612,"value":1659},{"type":606,"tag":636,"props":1679,"children":1680},{"style":657},[1681],{"type":612,"value":1682},"25",{"type":606,"tag":636,"props":1684,"children":1685},{"style":663},[1686],{"type":612,"value":1687},"}\n",{"type":606,"tag":636,"props":1689,"children":1690},{"class":638,"line":135},[1691,1695,1699,1703,1707,1711,1715,1719],{"type":606,"tag":636,"props":1692,"children":1693},{"style":651},[1694],{"type":612,"value":654},{"type":606,"tag":636,"props":1696,"children":1697},{"style":657},[1698],{"type":612,"value":660},{"type":606,"tag":636,"props":1700,"children":1701},{"style":663},[1702],{"type":612,"value":939},{"type":606,"tag":636,"props":1704,"children":1705},{"style":669},[1706],{"type":612,"value":852},{"type":606,"tag":636,"props":1708,"children":1709},{"style":663},[1710],{"type":612,"value":687},{"type":606,"tag":636,"props":1712,"children":1713},{"style":651},[1714],{"type":612,"value":692},{"type":606,"tag":636,"props":1716,"children":1717},{"style":695},[1718],{"type":612,"value":698},{"type":606,"tag":636,"props":1720,"children":1721},{"style":663},[1722],{"type":612,"value":703},{"type":606,"tag":636,"props":1724,"children":1725},{"class":638,"line":144},[1726,1730,1734,1739,1744,1749,1754,1758,1763,1768,1772],{"type":606,"tag":636,"props":1727,"children":1728},{"style":695},[1729],{"type":612,"value":711},{"type":606,"tag":636,"props":1731,"children":1732},{"style":663},[1733],{"type":612,"value":716},{"type":606,"tag":636,"props":1735,"children":1736},{"style":651},[1737],{"type":612,"value":1738},"f",{"type":606,"tag":636,"props":1740,"children":1741},{"style":669},[1742],{"type":612,"value":1743},"\"Name: ",{"type":606,"tag":636,"props":1745,"children":1746},{"style":657},[1747],{"type":612,"value":1748},"{",{"type":606,"tag":636,"props":1750,"children":1751},{"style":663},[1752],{"type":612,"value":1753},"data[",{"type":606,"tag":636,"props":1755,"children":1756},{"style":669},[1757],{"type":612,"value":1654},{"type":606,"tag":636,"props":1759,"children":1760},{"style":663},[1761],{"type":612,"value":1762},"]",{"type":606,"tag":636,"props":1764,"children":1765},{"style":657},[1766],{"type":612,"value":1767},"}\\n",{"type":606,"tag":636,"props":1769,"children":1770},{"style":669},[1771],{"type":612,"value":742},{"type":606,"tag":636,"props":1773,"children":1774},{"style":663},[1775],{"type":612,"value":726},{"type":606,"tag":636,"props":1777,"children":1778},{"class":638,"line":153},[1779,1783,1787,1791,1796,1800,1804,1808,1812,1816,1820],{"type":606,"tag":636,"props":1780,"children":1781},{"style":695},[1782],{"type":612,"value":711},{"type":606,"tag":636,"props":1784,"children":1785},{"style":663},[1786],{"type":612,"value":716},{"type":606,"tag":636,"props":1788,"children":1789},{"style":651},[1790],{"type":612,"value":1738},{"type":606,"tag":636,"props":1792,"children":1793},{"style":669},[1794],{"type":612,"value":1795},"\"Age: ",{"type":606,"tag":636,"props":1797,"children":1798},{"style":657},[1799],{"type":612,"value":1748},{"type":606,"tag":636,"props":1801,"children":1802},{"style":663},[1803],{"type":612,"value":1753},{"type":606,"tag":636,"props":1805,"children":1806},{"style":669},[1807],{"type":612,"value":1673},{"type":606,"tag":636,"props":1809,"children":1810},{"style":663},[1811],{"type":612,"value":1762},{"type":606,"tag":636,"props":1813,"children":1814},{"style":657},[1815],{"type":612,"value":1767},{"type":606,"tag":636,"props":1817,"children":1818},{"style":669},[1819],{"type":612,"value":742},{"type":606,"tag":636,"props":1821,"children":1822},{"style":663},[1823],{"type":612,"value":726},{"type":606,"tag":636,"props":1825,"children":1826},{"class":638,"line":163},[1827],{"type":606,"tag":636,"props":1828,"children":1829},{"emptyLinePlaceholder":13},[1830],{"type":612,"value":915},{"type":606,"tag":636,"props":1832,"children":1833},{"class":638,"line":172},[1834,1838,1842,1847],{"type":606,"tag":636,"props":1835,"children":1836},{"style":657},[1837],{"type":612,"value":1162},{"type":606,"tag":636,"props":1839,"children":1840},{"style":663},[1841],{"type":612,"value":666},{"type":606,"tag":636,"props":1843,"children":1844},{"style":669},[1845],{"type":612,"value":1846},"\"Appending and formatting completed\"",{"type":606,"tag":636,"props":1848,"children":1849},{"style":663},[1850],{"type":612,"value":726},{"type":606,"tag":758,"props":1852,"children":1854},{"id":1853},"advanced-writing-techniques",[1855],{"type":612,"value":1856},"🔍 Advanced Writing Techniques",{"type":606,"tag":615,"props":1858,"children":1859},{},[1860],{"type":612,"value":1861},"Python allows more sophisticated file writing operations.",{"type":606,"tag":867,"props":1863,"children":1864},{"id":355},[1865],{"type":612,"value":353},{"type":606,"tag":621,"props":1867,"children":1868},{},[1869],{"type":606,"tag":625,"props":1870,"children":1872},{"className":627,"code":1871,"language":629,"meta":8,"style":8},"# Safe file writing with error handling\ndef safe_write_file(filename, content):\n    try:\n        with open(filename, 'w', encoding='utf-8') as file:\n            file.write(content)\n        print(f\"Successfully wrote to {filename}\")\n        return True\n    except PermissionError:\n        print(f\"Permission denied: {filename}\")\n        return False\n    except Exception as e:\n        print(f\"Error writing file: {e}\")\n        return False\n\n# Test the function\nresult = safe_write_file('test.txt', \"Test content\")\nprint(f\"Write operation successful: {result}\")\n",[1873],{"type":606,"tag":632,"props":1874,"children":1875},{"__ignoreMap":8},[1876,1884,1903,1915,1969,1982,2025,2038,2055,2095,2107,2129,2170,2181,2188,2196,2231],{"type":606,"tag":636,"props":1877,"children":1878},{"class":638,"line":12},[1879],{"type":606,"tag":636,"props":1880,"children":1881},{"style":642},[1882],{"type":612,"value":1883},"# Safe file writing with error handling\n",{"type":606,"tag":636,"props":1885,"children":1886},{"class":638,"line":27},[1887,1892,1898],{"type":606,"tag":636,"props":1888,"children":1889},{"style":651},[1890],{"type":612,"value":1891},"def",{"type":606,"tag":636,"props":1893,"children":1895},{"style":1894},"--shiki-default:#6F42C1;--shiki-app-dark-mode:#B392F0",[1896],{"type":612,"value":1897}," safe_write_file",{"type":606,"tag":636,"props":1899,"children":1900},{"style":663},[1901],{"type":612,"value":1902},"(filename, content):\n",{"type":606,"tag":636,"props":1904,"children":1905},{"class":638,"line":36},[1906,1911],{"type":606,"tag":636,"props":1907,"children":1908},{"style":651},[1909],{"type":612,"value":1910},"    try",{"type":606,"tag":636,"props":1912,"children":1913},{"style":663},[1914],{"type":612,"value":703},{"type":606,"tag":636,"props":1916,"children":1917},{"class":638,"line":45},[1918,1923,1927,1931,1935,1939,1944,1948,1953,1957,1961,1965],{"type":606,"tag":636,"props":1919,"children":1920},{"style":651},[1921],{"type":612,"value":1922},"        with",{"type":606,"tag":636,"props":1924,"children":1925},{"style":657},[1926],{"type":612,"value":660},{"type":606,"tag":636,"props":1928,"children":1929},{"style":663},[1930],{"type":612,"value":939},{"type":606,"tag":636,"props":1932,"children":1933},{"style":669},[1934],{"type":612,"value":682},{"type":606,"tag":636,"props":1936,"children":1937},{"style":663},[1938],{"type":612,"value":677},{"type":606,"tag":636,"props":1940,"children":1941},{"style":695},[1942],{"type":612,"value":1943},"encoding",{"type":606,"tag":636,"props":1945,"children":1946},{"style":651},[1947],{"type":612,"value":902},{"type":606,"tag":636,"props":1949,"children":1950},{"style":669},[1951],{"type":612,"value":1952},"'utf-8'",{"type":606,"tag":636,"props":1954,"children":1955},{"style":663},[1956],{"type":612,"value":687},{"type":606,"tag":636,"props":1958,"children":1959},{"style":651},[1960],{"type":612,"value":692},{"type":606,"tag":636,"props":1962,"children":1963},{"style":695},[1964],{"type":612,"value":698},{"type":606,"tag":636,"props":1966,"children":1967},{"style":663},[1968],{"type":612,"value":703},{"type":606,"tag":636,"props":1970,"children":1971},{"class":638,"line":54},[1972,1977],{"type":606,"tag":636,"props":1973,"children":1974},{"style":695},[1975],{"type":612,"value":1976},"            file",{"type":606,"tag":636,"props":1978,"children":1979},{"style":663},[1980],{"type":612,"value":1981},".write(content)\n",{"type":606,"tag":636,"props":1983,"children":1984},{"class":638,"line":63},[1985,1990,1994,1998,2003,2007,2012,2017,2021],{"type":606,"tag":636,"props":1986,"children":1987},{"style":657},[1988],{"type":612,"value":1989},"        print",{"type":606,"tag":636,"props":1991,"children":1992},{"style":663},[1993],{"type":612,"value":666},{"type":606,"tag":636,"props":1995,"children":1996},{"style":651},[1997],{"type":612,"value":1738},{"type":606,"tag":636,"props":1999,"children":2000},{"style":669},[2001],{"type":612,"value":2002},"\"Successfully wrote to ",{"type":606,"tag":636,"props":2004,"children":2005},{"style":657},[2006],{"type":612,"value":1748},{"type":606,"tag":636,"props":2008,"children":2009},{"style":663},[2010],{"type":612,"value":2011},"filename",{"type":606,"tag":636,"props":2013,"children":2014},{"style":657},[2015],{"type":612,"value":2016},"}",{"type":606,"tag":636,"props":2018,"children":2019},{"style":669},[2020],{"type":612,"value":742},{"type":606,"tag":636,"props":2022,"children":2023},{"style":663},[2024],{"type":612,"value":726},{"type":606,"tag":636,"props":2026,"children":2027},{"class":638,"line":72},[2028,2033],{"type":606,"tag":636,"props":2029,"children":2030},{"style":651},[2031],{"type":612,"value":2032},"        return",{"type":606,"tag":636,"props":2034,"children":2035},{"style":657},[2036],{"type":612,"value":2037}," True\n",{"type":606,"tag":636,"props":2039,"children":2040},{"class":638,"line":81},[2041,2046,2051],{"type":606,"tag":636,"props":2042,"children":2043},{"style":651},[2044],{"type":612,"value":2045},"    except",{"type":606,"tag":636,"props":2047,"children":2048},{"style":657},[2049],{"type":612,"value":2050}," PermissionError",{"type":606,"tag":636,"props":2052,"children":2053},{"style":663},[2054],{"type":612,"value":703},{"type":606,"tag":636,"props":2056,"children":2057},{"class":638,"line":1025},[2058,2062,2066,2070,2075,2079,2083,2087,2091],{"type":606,"tag":636,"props":2059,"children":2060},{"style":657},[2061],{"type":612,"value":1989},{"type":606,"tag":636,"props":2063,"children":2064},{"style":663},[2065],{"type":612,"value":666},{"type":606,"tag":636,"props":2067,"children":2068},{"style":651},[2069],{"type":612,"value":1738},{"type":606,"tag":636,"props":2071,"children":2072},{"style":669},[2073],{"type":612,"value":2074},"\"Permission denied: ",{"type":606,"tag":636,"props":2076,"children":2077},{"style":657},[2078],{"type":612,"value":1748},{"type":606,"tag":636,"props":2080,"children":2081},{"style":663},[2082],{"type":612,"value":2011},{"type":606,"tag":636,"props":2084,"children":2085},{"style":657},[2086],{"type":612,"value":2016},{"type":606,"tag":636,"props":2088,"children":2089},{"style":669},[2090],{"type":612,"value":742},{"type":606,"tag":636,"props":2092,"children":2093},{"style":663},[2094],{"type":612,"value":726},{"type":606,"tag":636,"props":2096,"children":2097},{"class":638,"line":99},[2098,2102],{"type":606,"tag":636,"props":2099,"children":2100},{"style":651},[2101],{"type":612,"value":2032},{"type":606,"tag":636,"props":2103,"children":2104},{"style":657},[2105],{"type":612,"value":2106}," False\n",{"type":606,"tag":636,"props":2108,"children":2109},{"class":638,"line":108},[2110,2114,2119,2124],{"type":606,"tag":636,"props":2111,"children":2112},{"style":651},[2113],{"type":612,"value":2045},{"type":606,"tag":636,"props":2115,"children":2116},{"style":657},[2117],{"type":612,"value":2118}," Exception",{"type":606,"tag":636,"props":2120,"children":2121},{"style":651},[2122],{"type":612,"value":2123}," as",{"type":606,"tag":636,"props":2125,"children":2126},{"style":663},[2127],{"type":612,"value":2128}," e:\n",{"type":606,"tag":636,"props":2130,"children":2131},{"class":638,"line":117},[2132,2136,2140,2144,2149,2153,2158,2162,2166],{"type":606,"tag":636,"props":2133,"children":2134},{"style":657},[2135],{"type":612,"value":1989},{"type":606,"tag":636,"props":2137,"children":2138},{"style":663},[2139],{"type":612,"value":666},{"type":606,"tag":636,"props":2141,"children":2142},{"style":651},[2143],{"type":612,"value":1738},{"type":606,"tag":636,"props":2145,"children":2146},{"style":669},[2147],{"type":612,"value":2148},"\"Error writing file: ",{"type":606,"tag":636,"props":2150,"children":2151},{"style":657},[2152],{"type":612,"value":1748},{"type":606,"tag":636,"props":2154,"children":2155},{"style":663},[2156],{"type":612,"value":2157},"e",{"type":606,"tag":636,"props":2159,"children":2160},{"style":657},[2161],{"type":612,"value":2016},{"type":606,"tag":636,"props":2163,"children":2164},{"style":669},[2165],{"type":612,"value":742},{"type":606,"tag":636,"props":2167,"children":2168},{"style":663},[2169],{"type":612,"value":726},{"type":606,"tag":636,"props":2171,"children":2172},{"class":638,"line":126},[2173,2177],{"type":606,"tag":636,"props":2174,"children":2175},{"style":651},[2176],{"type":612,"value":2032},{"type":606,"tag":636,"props":2178,"children":2179},{"style":657},[2180],{"type":612,"value":2106},{"type":606,"tag":636,"props":2182,"children":2183},{"class":638,"line":135},[2184],{"type":606,"tag":636,"props":2185,"children":2186},{"emptyLinePlaceholder":13},[2187],{"type":612,"value":915},{"type":606,"tag":636,"props":2189,"children":2190},{"class":638,"line":144},[2191],{"type":606,"tag":636,"props":2192,"children":2193},{"style":642},[2194],{"type":612,"value":2195},"# Test the function\n",{"type":606,"tag":636,"props":2197,"children":2198},{"class":638,"line":153},[2199,2204,2208,2213,2218,2222,2227],{"type":606,"tag":636,"props":2200,"children":2201},{"style":663},[2202],{"type":612,"value":2203},"result ",{"type":606,"tag":636,"props":2205,"children":2206},{"style":651},[2207],{"type":612,"value":902},{"type":606,"tag":636,"props":2209,"children":2210},{"style":663},[2211],{"type":612,"value":2212}," safe_write_file(",{"type":606,"tag":636,"props":2214,"children":2215},{"style":669},[2216],{"type":612,"value":2217},"'test.txt'",{"type":606,"tag":636,"props":2219,"children":2220},{"style":663},[2221],{"type":612,"value":677},{"type":606,"tag":636,"props":2223,"children":2224},{"style":669},[2225],{"type":612,"value":2226},"\"Test content\"",{"type":606,"tag":636,"props":2228,"children":2229},{"style":663},[2230],{"type":612,"value":726},{"type":606,"tag":636,"props":2232,"children":2233},{"class":638,"line":163},[2234,2238,2242,2246,2251,2255,2260,2264,2268],{"type":606,"tag":636,"props":2235,"children":2236},{"style":657},[2237],{"type":612,"value":1162},{"type":606,"tag":636,"props":2239,"children":2240},{"style":663},[2241],{"type":612,"value":666},{"type":606,"tag":636,"props":2243,"children":2244},{"style":651},[2245],{"type":612,"value":1738},{"type":606,"tag":636,"props":2247,"children":2248},{"style":669},[2249],{"type":612,"value":2250},"\"Write operation successful: ",{"type":606,"tag":636,"props":2252,"children":2253},{"style":657},[2254],{"type":612,"value":1748},{"type":606,"tag":636,"props":2256,"children":2257},{"style":663},[2258],{"type":612,"value":2259},"result",{"type":606,"tag":636,"props":2261,"children":2262},{"style":657},[2263],{"type":612,"value":2016},{"type":606,"tag":636,"props":2265,"children":2266},{"style":669},[2267],{"type":612,"value":742},{"type":606,"tag":636,"props":2269,"children":2270},{"style":663},[2271],{"type":612,"value":726},{"type":606,"tag":867,"props":2273,"children":2275},{"id":2274},"structured-data-writing",[2276],{"type":612,"value":2277},"Structured Data Writing",{"type":606,"tag":621,"props":2279,"children":2280},{},[2281],{"type":606,"tag":625,"props":2282,"children":2284},{"className":627,"code":2283,"language":629,"meta":8,"style":8},"# Writing structured data as formatted text\nstudents = [\n    {'name': 'Alice', 'grade': 'A'},\n    {'name': 'Bob', 'grade': 'B'},\n    {'name': 'Charlie', 'grade': 'C'}\n]\n\nwith open('students.txt', 'w') as file:\n    file.write(\"Student Report\\n\")\n    file.write(\"=\" * 20 + \"\\n\")\n    for student in students:\n        file.write(f\"{student['name']}: {student['grade']}\\n\")\n\nprint(\"Student report written successfully\")\n",[2285],{"type":606,"tag":632,"props":2286,"children":2287},{"__ignoreMap":8},[2288,2296,2313,2356,2397,2438,2445,2452,2496,2524,2572,2595,2668,2675],{"type":606,"tag":636,"props":2289,"children":2290},{"class":638,"line":12},[2291],{"type":606,"tag":636,"props":2292,"children":2293},{"style":642},[2294],{"type":612,"value":2295},"# Writing structured data as formatted text\n",{"type":606,"tag":636,"props":2297,"children":2298},{"class":638,"line":27},[2299,2304,2308],{"type":606,"tag":636,"props":2300,"children":2301},{"style":663},[2302],{"type":612,"value":2303},"students ",{"type":606,"tag":636,"props":2305,"children":2306},{"style":651},[2307],{"type":612,"value":902},{"type":606,"tag":636,"props":2309,"children":2310},{"style":663},[2311],{"type":612,"value":2312}," [\n",{"type":606,"tag":636,"props":2314,"children":2315},{"class":638,"line":36},[2316,2321,2325,2329,2333,2337,2342,2346,2351],{"type":606,"tag":636,"props":2317,"children":2318},{"style":663},[2319],{"type":612,"value":2320},"    {",{"type":606,"tag":636,"props":2322,"children":2323},{"style":669},[2324],{"type":612,"value":1654},{"type":606,"tag":636,"props":2326,"children":2327},{"style":663},[2328],{"type":612,"value":1659},{"type":606,"tag":636,"props":2330,"children":2331},{"style":669},[2332],{"type":612,"value":1664},{"type":606,"tag":636,"props":2334,"children":2335},{"style":663},[2336],{"type":612,"value":677},{"type":606,"tag":636,"props":2338,"children":2339},{"style":669},[2340],{"type":612,"value":2341},"'grade'",{"type":606,"tag":636,"props":2343,"children":2344},{"style":663},[2345],{"type":612,"value":1659},{"type":606,"tag":636,"props":2347,"children":2348},{"style":669},[2349],{"type":612,"value":2350},"'A'",{"type":606,"tag":636,"props":2352,"children":2353},{"style":663},[2354],{"type":612,"value":2355},"},\n",{"type":606,"tag":636,"props":2357,"children":2358},{"class":638,"line":45},[2359,2363,2367,2371,2376,2380,2384,2388,2393],{"type":606,"tag":636,"props":2360,"children":2361},{"style":663},[2362],{"type":612,"value":2320},{"type":606,"tag":636,"props":2364,"children":2365},{"style":669},[2366],{"type":612,"value":1654},{"type":606,"tag":636,"props":2368,"children":2369},{"style":663},[2370],{"type":612,"value":1659},{"type":606,"tag":636,"props":2372,"children":2373},{"style":669},[2374],{"type":612,"value":2375},"'Bob'",{"type":606,"tag":636,"props":2377,"children":2378},{"style":663},[2379],{"type":612,"value":677},{"type":606,"tag":636,"props":2381,"children":2382},{"style":669},[2383],{"type":612,"value":2341},{"type":606,"tag":636,"props":2385,"children":2386},{"style":663},[2387],{"type":612,"value":1659},{"type":606,"tag":636,"props":2389,"children":2390},{"style":669},[2391],{"type":612,"value":2392},"'B'",{"type":606,"tag":636,"props":2394,"children":2395},{"style":663},[2396],{"type":612,"value":2355},{"type":606,"tag":636,"props":2398,"children":2399},{"class":638,"line":54},[2400,2404,2408,2412,2417,2421,2425,2429,2434],{"type":606,"tag":636,"props":2401,"children":2402},{"style":663},[2403],{"type":612,"value":2320},{"type":606,"tag":636,"props":2405,"children":2406},{"style":669},[2407],{"type":612,"value":1654},{"type":606,"tag":636,"props":2409,"children":2410},{"style":663},[2411],{"type":612,"value":1659},{"type":606,"tag":636,"props":2413,"children":2414},{"style":669},[2415],{"type":612,"value":2416},"'Charlie'",{"type":606,"tag":636,"props":2418,"children":2419},{"style":663},[2420],{"type":612,"value":677},{"type":606,"tag":636,"props":2422,"children":2423},{"style":669},[2424],{"type":612,"value":2341},{"type":606,"tag":636,"props":2426,"children":2427},{"style":663},[2428],{"type":612,"value":1659},{"type":606,"tag":636,"props":2430,"children":2431},{"style":669},[2432],{"type":612,"value":2433},"'C'",{"type":606,"tag":636,"props":2435,"children":2436},{"style":663},[2437],{"type":612,"value":1687},{"type":606,"tag":636,"props":2439,"children":2440},{"class":638,"line":63},[2441],{"type":606,"tag":636,"props":2442,"children":2443},{"style":663},[2444],{"type":612,"value":1100},{"type":606,"tag":636,"props":2446,"children":2447},{"class":638,"line":72},[2448],{"type":606,"tag":636,"props":2449,"children":2450},{"emptyLinePlaceholder":13},[2451],{"type":612,"value":915},{"type":606,"tag":636,"props":2453,"children":2454},{"class":638,"line":81},[2455,2459,2463,2467,2472,2476,2480,2484,2488,2492],{"type":606,"tag":636,"props":2456,"children":2457},{"style":651},[2458],{"type":612,"value":654},{"type":606,"tag":636,"props":2460,"children":2461},{"style":657},[2462],{"type":612,"value":660},{"type":606,"tag":636,"props":2464,"children":2465},{"style":663},[2466],{"type":612,"value":666},{"type":606,"tag":636,"props":2468,"children":2469},{"style":669},[2470],{"type":612,"value":2471},"'students.txt'",{"type":606,"tag":636,"props":2473,"children":2474},{"style":663},[2475],{"type":612,"value":677},{"type":606,"tag":636,"props":2477,"children":2478},{"style":669},[2479],{"type":612,"value":682},{"type":606,"tag":636,"props":2481,"children":2482},{"style":663},[2483],{"type":612,"value":687},{"type":606,"tag":636,"props":2485,"children":2486},{"style":651},[2487],{"type":612,"value":692},{"type":606,"tag":636,"props":2489,"children":2490},{"style":695},[2491],{"type":612,"value":698},{"type":606,"tag":636,"props":2493,"children":2494},{"style":663},[2495],{"type":612,"value":703},{"type":606,"tag":636,"props":2497,"children":2498},{"class":638,"line":1025},[2499,2503,2507,2512,2516,2520],{"type":606,"tag":636,"props":2500,"children":2501},{"style":695},[2502],{"type":612,"value":711},{"type":606,"tag":636,"props":2504,"children":2505},{"style":663},[2506],{"type":612,"value":716},{"type":606,"tag":636,"props":2508,"children":2509},{"style":669},[2510],{"type":612,"value":2511},"\"Student Report",{"type":606,"tag":636,"props":2513,"children":2514},{"style":657},[2515],{"type":612,"value":747},{"type":606,"tag":636,"props":2517,"children":2518},{"style":669},[2519],{"type":612,"value":742},{"type":606,"tag":636,"props":2521,"children":2522},{"style":663},[2523],{"type":612,"value":726},{"type":606,"tag":636,"props":2525,"children":2526},{"class":638,"line":99},[2527,2531,2535,2540,2545,2550,2555,2560,2564,2568],{"type":606,"tag":636,"props":2528,"children":2529},{"style":695},[2530],{"type":612,"value":711},{"type":606,"tag":636,"props":2532,"children":2533},{"style":663},[2534],{"type":612,"value":716},{"type":606,"tag":636,"props":2536,"children":2537},{"style":669},[2538],{"type":612,"value":2539},"\"=\"",{"type":606,"tag":636,"props":2541,"children":2542},{"style":651},[2543],{"type":612,"value":2544}," *",{"type":606,"tag":636,"props":2546,"children":2547},{"style":657},[2548],{"type":612,"value":2549}," 20",{"type":606,"tag":636,"props":2551,"children":2552},{"style":651},[2553],{"type":612,"value":2554}," +",{"type":606,"tag":636,"props":2556,"children":2557},{"style":669},[2558],{"type":612,"value":2559}," \"",{"type":606,"tag":636,"props":2561,"children":2562},{"style":657},[2563],{"type":612,"value":747},{"type":606,"tag":636,"props":2565,"children":2566},{"style":669},[2567],{"type":612,"value":742},{"type":606,"tag":636,"props":2569,"children":2570},{"style":663},[2571],{"type":612,"value":726},{"type":606,"tag":636,"props":2573,"children":2574},{"class":638,"line":108},[2575,2580,2585,2590],{"type":606,"tag":636,"props":2576,"children":2577},{"style":651},[2578],{"type":612,"value":2579},"    for",{"type":606,"tag":636,"props":2581,"children":2582},{"style":663},[2583],{"type":612,"value":2584}," student ",{"type":606,"tag":636,"props":2586,"children":2587},{"style":651},[2588],{"type":612,"value":2589},"in",{"type":606,"tag":636,"props":2591,"children":2592},{"style":663},[2593],{"type":612,"value":2594}," students:\n",{"type":606,"tag":636,"props":2596,"children":2597},{"class":638,"line":117},[2598,2603,2607,2611,2615,2619,2624,2628,2632,2636,2640,2644,2648,2652,2656,2660,2664],{"type":606,"tag":636,"props":2599,"children":2600},{"style":695},[2601],{"type":612,"value":2602},"        file",{"type":606,"tag":636,"props":2604,"children":2605},{"style":663},[2606],{"type":612,"value":716},{"type":606,"tag":636,"props":2608,"children":2609},{"style":651},[2610],{"type":612,"value":1738},{"type":606,"tag":636,"props":2612,"children":2613},{"style":669},[2614],{"type":612,"value":742},{"type":606,"tag":636,"props":2616,"children":2617},{"style":657},[2618],{"type":612,"value":1748},{"type":606,"tag":636,"props":2620,"children":2621},{"style":663},[2622],{"type":612,"value":2623},"student[",{"type":606,"tag":636,"props":2625,"children":2626},{"style":669},[2627],{"type":612,"value":1654},{"type":606,"tag":636,"props":2629,"children":2630},{"style":663},[2631],{"type":612,"value":1762},{"type":606,"tag":636,"props":2633,"children":2634},{"style":657},[2635],{"type":612,"value":2016},{"type":606,"tag":636,"props":2637,"children":2638},{"style":669},[2639],{"type":612,"value":1659},{"type":606,"tag":636,"props":2641,"children":2642},{"style":657},[2643],{"type":612,"value":1748},{"type":606,"tag":636,"props":2645,"children":2646},{"style":663},[2647],{"type":612,"value":2623},{"type":606,"tag":636,"props":2649,"children":2650},{"style":669},[2651],{"type":612,"value":2341},{"type":606,"tag":636,"props":2653,"children":2654},{"style":663},[2655],{"type":612,"value":1762},{"type":606,"tag":636,"props":2657,"children":2658},{"style":657},[2659],{"type":612,"value":1767},{"type":606,"tag":636,"props":2661,"children":2662},{"style":669},[2663],{"type":612,"value":742},{"type":606,"tag":636,"props":2665,"children":2666},{"style":663},[2667],{"type":612,"value":726},{"type":606,"tag":636,"props":2669,"children":2670},{"class":638,"line":126},[2671],{"type":606,"tag":636,"props":2672,"children":2673},{"emptyLinePlaceholder":13},[2674],{"type":612,"value":915},{"type":606,"tag":636,"props":2676,"children":2677},{"class":638,"line":135},[2678,2682,2686,2691],{"type":606,"tag":636,"props":2679,"children":2680},{"style":657},[2681],{"type":612,"value":1162},{"type":606,"tag":636,"props":2683,"children":2684},{"style":663},[2685],{"type":612,"value":666},{"type":606,"tag":636,"props":2687,"children":2688},{"style":669},[2689],{"type":612,"value":2690},"\"Student report written successfully\"",{"type":606,"tag":636,"props":2692,"children":2693},{"style":663},[2694],{"type":612,"value":726},{"type":606,"tag":867,"props":2696,"children":2698},{"id":2697},"backup-and-logging",[2699],{"type":612,"value":2700},"Backup and Logging",{"type":606,"tag":621,"props":2702,"children":2703},{},[2704],{"type":606,"tag":625,"props":2705,"children":2707},{"className":627,"code":2706,"language":629,"meta":8,"style":8},"import os\nimport shutil\nfrom datetime import datetime\n\n# Backup existing file before writing\ndef write_with_backup(filename, content):\n    if os.path.exists(filename):\n        backup_name = f\"{filename}.backup\"\n        shutil.copy(filename, backup_name)\n        print(f\"Created backup: {backup_name}\")\n    \n    with open(filename, 'w') as file:\n        file.write(content)\n\n# Log writing function\ndef write_log(message, filename='app.log'):\n    timestamp = datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n    log_entry = f\"[{timestamp}] {message}\\n\"\n    \n    with open(filename, 'a') as file:\n        file.write(log_entry)\n\n# Example usage\nwrite_with_backup('important.txt', \"New content\")\nwrite_log(\"Application started\")\nwrite_log(\"User logged in\")\n",[2708],{"type":606,"tag":632,"props":2709,"children":2710},{"__ignoreMap":8},[2711,2724,2736,2758,2765,2773,2789,2802,2840,2848,2889,2897,2933,2944,2951,2959,2990,3026,3083,3090,3125,3137,3144,3152,3178,3195],{"type":606,"tag":636,"props":2712,"children":2713},{"class":638,"line":12},[2714,2719],{"type":606,"tag":636,"props":2715,"children":2716},{"style":651},[2717],{"type":612,"value":2718},"import",{"type":606,"tag":636,"props":2720,"children":2721},{"style":663},[2722],{"type":612,"value":2723}," os\n",{"type":606,"tag":636,"props":2725,"children":2726},{"class":638,"line":27},[2727,2731],{"type":606,"tag":636,"props":2728,"children":2729},{"style":651},[2730],{"type":612,"value":2718},{"type":606,"tag":636,"props":2732,"children":2733},{"style":663},[2734],{"type":612,"value":2735}," shutil\n",{"type":606,"tag":636,"props":2737,"children":2738},{"class":638,"line":36},[2739,2744,2749,2753],{"type":606,"tag":636,"props":2740,"children":2741},{"style":651},[2742],{"type":612,"value":2743},"from",{"type":606,"tag":636,"props":2745,"children":2746},{"style":663},[2747],{"type":612,"value":2748}," datetime ",{"type":606,"tag":636,"props":2750,"children":2751},{"style":651},[2752],{"type":612,"value":2718},{"type":606,"tag":636,"props":2754,"children":2755},{"style":663},[2756],{"type":612,"value":2757}," datetime\n",{"type":606,"tag":636,"props":2759,"children":2760},{"class":638,"line":45},[2761],{"type":606,"tag":636,"props":2762,"children":2763},{"emptyLinePlaceholder":13},[2764],{"type":612,"value":915},{"type":606,"tag":636,"props":2766,"children":2767},{"class":638,"line":54},[2768],{"type":606,"tag":636,"props":2769,"children":2770},{"style":642},[2771],{"type":612,"value":2772},"# Backup existing file before writing\n",{"type":606,"tag":636,"props":2774,"children":2775},{"class":638,"line":63},[2776,2780,2785],{"type":606,"tag":636,"props":2777,"children":2778},{"style":651},[2779],{"type":612,"value":1891},{"type":606,"tag":636,"props":2781,"children":2782},{"style":1894},[2783],{"type":612,"value":2784}," write_with_backup",{"type":606,"tag":636,"props":2786,"children":2787},{"style":663},[2788],{"type":612,"value":1902},{"type":606,"tag":636,"props":2790,"children":2791},{"class":638,"line":72},[2792,2797],{"type":606,"tag":636,"props":2793,"children":2794},{"style":651},[2795],{"type":612,"value":2796},"    if",{"type":606,"tag":636,"props":2798,"children":2799},{"style":663},[2800],{"type":612,"value":2801}," os.path.exists(filename):\n",{"type":606,"tag":636,"props":2803,"children":2804},{"class":638,"line":81},[2805,2810,2814,2819,2823,2827,2831,2835],{"type":606,"tag":636,"props":2806,"children":2807},{"style":663},[2808],{"type":612,"value":2809},"        backup_name ",{"type":606,"tag":636,"props":2811,"children":2812},{"style":651},[2813],{"type":612,"value":902},{"type":606,"tag":636,"props":2815,"children":2816},{"style":651},[2817],{"type":612,"value":2818}," f",{"type":606,"tag":636,"props":2820,"children":2821},{"style":669},[2822],{"type":612,"value":742},{"type":606,"tag":636,"props":2824,"children":2825},{"style":657},[2826],{"type":612,"value":1748},{"type":606,"tag":636,"props":2828,"children":2829},{"style":663},[2830],{"type":612,"value":2011},{"type":606,"tag":636,"props":2832,"children":2833},{"style":657},[2834],{"type":612,"value":2016},{"type":606,"tag":636,"props":2836,"children":2837},{"style":669},[2838],{"type":612,"value":2839},".backup\"\n",{"type":606,"tag":636,"props":2841,"children":2842},{"class":638,"line":1025},[2843],{"type":606,"tag":636,"props":2844,"children":2845},{"style":663},[2846],{"type":612,"value":2847},"        shutil.copy(filename, backup_name)\n",{"type":606,"tag":636,"props":2849,"children":2850},{"class":638,"line":99},[2851,2855,2859,2863,2868,2872,2877,2881,2885],{"type":606,"tag":636,"props":2852,"children":2853},{"style":657},[2854],{"type":612,"value":1989},{"type":606,"tag":636,"props":2856,"children":2857},{"style":663},[2858],{"type":612,"value":666},{"type":606,"tag":636,"props":2860,"children":2861},{"style":651},[2862],{"type":612,"value":1738},{"type":606,"tag":636,"props":2864,"children":2865},{"style":669},[2866],{"type":612,"value":2867},"\"Created backup: ",{"type":606,"tag":636,"props":2869,"children":2870},{"style":657},[2871],{"type":612,"value":1748},{"type":606,"tag":636,"props":2873,"children":2874},{"style":663},[2875],{"type":612,"value":2876},"backup_name",{"type":606,"tag":636,"props":2878,"children":2879},{"style":657},[2880],{"type":612,"value":2016},{"type":606,"tag":636,"props":2882,"children":2883},{"style":669},[2884],{"type":612,"value":742},{"type":606,"tag":636,"props":2886,"children":2887},{"style":663},[2888],{"type":612,"value":726},{"type":606,"tag":636,"props":2890,"children":2891},{"class":638,"line":108},[2892],{"type":606,"tag":636,"props":2893,"children":2894},{"style":663},[2895],{"type":612,"value":2896},"    \n",{"type":606,"tag":636,"props":2898,"children":2899},{"class":638,"line":117},[2900,2905,2909,2913,2917,2921,2925,2929],{"type":606,"tag":636,"props":2901,"children":2902},{"style":651},[2903],{"type":612,"value":2904},"    with",{"type":606,"tag":636,"props":2906,"children":2907},{"style":657},[2908],{"type":612,"value":660},{"type":606,"tag":636,"props":2910,"children":2911},{"style":663},[2912],{"type":612,"value":939},{"type":606,"tag":636,"props":2914,"children":2915},{"style":669},[2916],{"type":612,"value":682},{"type":606,"tag":636,"props":2918,"children":2919},{"style":663},[2920],{"type":612,"value":687},{"type":606,"tag":636,"props":2922,"children":2923},{"style":651},[2924],{"type":612,"value":692},{"type":606,"tag":636,"props":2926,"children":2927},{"style":695},[2928],{"type":612,"value":698},{"type":606,"tag":636,"props":2930,"children":2931},{"style":663},[2932],{"type":612,"value":703},{"type":606,"tag":636,"props":2934,"children":2935},{"class":638,"line":126},[2936,2940],{"type":606,"tag":636,"props":2937,"children":2938},{"style":695},[2939],{"type":612,"value":2602},{"type":606,"tag":636,"props":2941,"children":2942},{"style":663},[2943],{"type":612,"value":1981},{"type":606,"tag":636,"props":2945,"children":2946},{"class":638,"line":135},[2947],{"type":606,"tag":636,"props":2948,"children":2949},{"emptyLinePlaceholder":13},[2950],{"type":612,"value":915},{"type":606,"tag":636,"props":2952,"children":2953},{"class":638,"line":144},[2954],{"type":606,"tag":636,"props":2955,"children":2956},{"style":642},[2957],{"type":612,"value":2958},"# Log writing function\n",{"type":606,"tag":636,"props":2960,"children":2961},{"class":638,"line":153},[2962,2966,2971,2976,2980,2985],{"type":606,"tag":636,"props":2963,"children":2964},{"style":651},[2965],{"type":612,"value":1891},{"type":606,"tag":636,"props":2967,"children":2968},{"style":1894},[2969],{"type":612,"value":2970}," write_log",{"type":606,"tag":636,"props":2972,"children":2973},{"style":663},[2974],{"type":612,"value":2975},"(message, filename",{"type":606,"tag":636,"props":2977,"children":2978},{"style":651},[2979],{"type":612,"value":902},{"type":606,"tag":636,"props":2981,"children":2982},{"style":669},[2983],{"type":612,"value":2984},"'app.log'",{"type":606,"tag":636,"props":2986,"children":2987},{"style":663},[2988],{"type":612,"value":2989},"):\n",{"type":606,"tag":636,"props":2991,"children":2992},{"class":638,"line":163},[2993,2998,3002,3007,3012,3017,3022],{"type":606,"tag":636,"props":2994,"children":2995},{"style":663},[2996],{"type":612,"value":2997},"    timestamp ",{"type":606,"tag":636,"props":2999,"children":3000},{"style":651},[3001],{"type":612,"value":902},{"type":606,"tag":636,"props":3003,"children":3004},{"style":663},[3005],{"type":612,"value":3006}," datetime.now().strftime(",{"type":606,"tag":636,"props":3008,"children":3009},{"style":669},[3010],{"type":612,"value":3011},"\"%Y-%m-",{"type":606,"tag":636,"props":3013,"children":3014},{"style":657},[3015],{"type":612,"value":3016},"%d",{"type":606,"tag":636,"props":3018,"children":3019},{"style":669},[3020],{"type":612,"value":3021}," %H:%M:%S\"",{"type":606,"tag":636,"props":3023,"children":3024},{"style":663},[3025],{"type":612,"value":726},{"type":606,"tag":636,"props":3027,"children":3028},{"class":638,"line":172},[3029,3034,3038,3042,3047,3051,3056,3060,3065,3069,3074,3078],{"type":606,"tag":636,"props":3030,"children":3031},{"style":663},[3032],{"type":612,"value":3033},"    log_entry ",{"type":606,"tag":636,"props":3035,"children":3036},{"style":651},[3037],{"type":612,"value":902},{"type":606,"tag":636,"props":3039,"children":3040},{"style":651},[3041],{"type":612,"value":2818},{"type":606,"tag":636,"props":3043,"children":3044},{"style":669},[3045],{"type":612,"value":3046},"\"[",{"type":606,"tag":636,"props":3048,"children":3049},{"style":657},[3050],{"type":612,"value":1748},{"type":606,"tag":636,"props":3052,"children":3053},{"style":663},[3054],{"type":612,"value":3055},"timestamp",{"type":606,"tag":636,"props":3057,"children":3058},{"style":657},[3059],{"type":612,"value":2016},{"type":606,"tag":636,"props":3061,"children":3062},{"style":669},[3063],{"type":612,"value":3064},"] ",{"type":606,"tag":636,"props":3066,"children":3067},{"style":657},[3068],{"type":612,"value":1748},{"type":606,"tag":636,"props":3070,"children":3071},{"style":663},[3072],{"type":612,"value":3073},"message",{"type":606,"tag":636,"props":3075,"children":3076},{"style":657},[3077],{"type":612,"value":1767},{"type":606,"tag":636,"props":3079,"children":3080},{"style":669},[3081],{"type":612,"value":3082},"\"\n",{"type":606,"tag":636,"props":3084,"children":3085},{"class":638,"line":181},[3086],{"type":606,"tag":636,"props":3087,"children":3088},{"style":663},[3089],{"type":612,"value":2896},{"type":606,"tag":636,"props":3091,"children":3092},{"class":638,"line":190},[3093,3097,3101,3105,3109,3113,3117,3121],{"type":606,"tag":636,"props":3094,"children":3095},{"style":651},[3096],{"type":612,"value":2904},{"type":606,"tag":636,"props":3098,"children":3099},{"style":657},[3100],{"type":612,"value":660},{"type":606,"tag":636,"props":3102,"children":3103},{"style":663},[3104],{"type":612,"value":939},{"type":606,"tag":636,"props":3106,"children":3107},{"style":669},[3108],{"type":612,"value":852},{"type":606,"tag":636,"props":3110,"children":3111},{"style":663},[3112],{"type":612,"value":687},{"type":606,"tag":636,"props":3114,"children":3115},{"style":651},[3116],{"type":612,"value":692},{"type":606,"tag":636,"props":3118,"children":3119},{"style":695},[3120],{"type":612,"value":698},{"type":606,"tag":636,"props":3122,"children":3123},{"style":663},[3124],{"type":612,"value":703},{"type":606,"tag":636,"props":3126,"children":3127},{"class":638,"line":199},[3128,3132],{"type":606,"tag":636,"props":3129,"children":3130},{"style":695},[3131],{"type":612,"value":2602},{"type":606,"tag":636,"props":3133,"children":3134},{"style":663},[3135],{"type":612,"value":3136},".write(log_entry)\n",{"type":606,"tag":636,"props":3138,"children":3139},{"class":638,"line":208},[3140],{"type":606,"tag":636,"props":3141,"children":3142},{"emptyLinePlaceholder":13},[3143],{"type":612,"value":915},{"type":606,"tag":636,"props":3145,"children":3146},{"class":638,"line":217},[3147],{"type":606,"tag":636,"props":3148,"children":3149},{"style":642},[3150],{"type":612,"value":3151},"# Example usage\n",{"type":606,"tag":636,"props":3153,"children":3154},{"class":638,"line":227},[3155,3160,3165,3169,3174],{"type":606,"tag":636,"props":3156,"children":3157},{"style":663},[3158],{"type":612,"value":3159},"write_with_backup(",{"type":606,"tag":636,"props":3161,"children":3162},{"style":669},[3163],{"type":612,"value":3164},"'important.txt'",{"type":606,"tag":636,"props":3166,"children":3167},{"style":663},[3168],{"type":612,"value":677},{"type":606,"tag":636,"props":3170,"children":3171},{"style":669},[3172],{"type":612,"value":3173},"\"New content\"",{"type":606,"tag":636,"props":3175,"children":3176},{"style":663},[3177],{"type":612,"value":726},{"type":606,"tag":636,"props":3179,"children":3180},{"class":638,"line":236},[3181,3186,3191],{"type":606,"tag":636,"props":3182,"children":3183},{"style":663},[3184],{"type":612,"value":3185},"write_log(",{"type":606,"tag":636,"props":3187,"children":3188},{"style":669},[3189],{"type":612,"value":3190},"\"Application started\"",{"type":606,"tag":636,"props":3192,"children":3193},{"style":663},[3194],{"type":612,"value":726},{"type":606,"tag":636,"props":3196,"children":3197},{"class":638,"line":245},[3198,3202,3207],{"type":606,"tag":636,"props":3199,"children":3200},{"style":663},[3201],{"type":612,"value":3185},{"type":606,"tag":636,"props":3203,"children":3204},{"style":669},[3205],{"type":612,"value":3206},"\"User logged in\"",{"type":606,"tag":636,"props":3208,"children":3209},{"style":663},[3210],{"type":612,"value":726},{"type":606,"tag":758,"props":3212,"children":3214},{"id":3213},"file-writing-reference-table",[3215],{"type":612,"value":3216},"📋 File Writing Reference Table",{"type":606,"tag":3218,"props":3219,"children":3220},"table",{},[3221,3250],{"type":606,"tag":3222,"props":3223,"children":3224},"thead",{},[3225],{"type":606,"tag":3226,"props":3227,"children":3228},"tr",{},[3229,3235,3240,3245],{"type":606,"tag":3230,"props":3231,"children":3232},"th",{},[3233],{"type":612,"value":3234},"Mode",{"type":606,"tag":3230,"props":3236,"children":3237},{},[3238],{"type":612,"value":3239},"Behavior",{"type":606,"tag":3230,"props":3241,"children":3242},{},[3243],{"type":612,"value":3244},"File Exists",{"type":606,"tag":3230,"props":3246,"children":3247},{},[3248],{"type":612,"value":3249},"File Missing",{"type":606,"tag":3251,"props":3252,"children":3253},"tbody",{},[3254,3281,3306,3331,3356],{"type":606,"tag":3226,"props":3255,"children":3256},{},[3257,3266,3271,3276],{"type":606,"tag":3258,"props":3259,"children":3260},"td",{},[3261],{"type":606,"tag":632,"props":3262,"children":3264},{"className":3263},[],[3265],{"type":612,"value":682},{"type":606,"tag":3258,"props":3267,"children":3268},{},[3269],{"type":612,"value":3270},"Write (overwrite)",{"type":606,"tag":3258,"props":3272,"children":3273},{},[3274],{"type":612,"value":3275},"Overwrites",{"type":606,"tag":3258,"props":3277,"children":3278},{},[3279],{"type":612,"value":3280},"Creates new",{"type":606,"tag":3226,"props":3282,"children":3283},{},[3284,3292,3297,3302],{"type":606,"tag":3258,"props":3285,"children":3286},{},[3287],{"type":606,"tag":632,"props":3288,"children":3290},{"className":3289},[],[3291],{"type":612,"value":852},{"type":606,"tag":3258,"props":3293,"children":3294},{},[3295],{"type":612,"value":3296},"Append",{"type":606,"tag":3258,"props":3298,"children":3299},{},[3300],{"type":612,"value":3301},"Appends to end",{"type":606,"tag":3258,"props":3303,"children":3304},{},[3305],{"type":612,"value":3280},{"type":606,"tag":3226,"props":3307,"children":3308},{},[3309,3317,3322,3327],{"type":606,"tag":3258,"props":3310,"children":3311},{},[3312],{"type":606,"tag":632,"props":3313,"children":3315},{"className":3314},[],[3316],{"type":612,"value":863},{"type":606,"tag":3258,"props":3318,"children":3319},{},[3320],{"type":612,"value":3321},"Exclusive create",{"type":606,"tag":3258,"props":3323,"children":3324},{},[3325],{"type":612,"value":3326},"Raises error",{"type":606,"tag":3258,"props":3328,"children":3329},{},[3330],{"type":612,"value":3280},{"type":606,"tag":3226,"props":3332,"children":3333},{},[3334,3343,3348,3352],{"type":606,"tag":3258,"props":3335,"children":3336},{},[3337],{"type":606,"tag":632,"props":3338,"children":3340},{"className":3339},[],[3341],{"type":612,"value":3342},"'w+'",{"type":606,"tag":3258,"props":3344,"children":3345},{},[3346],{"type":612,"value":3347},"Write + read",{"type":606,"tag":3258,"props":3349,"children":3350},{},[3351],{"type":612,"value":3275},{"type":606,"tag":3258,"props":3353,"children":3354},{},[3355],{"type":612,"value":3280},{"type":606,"tag":3226,"props":3357,"children":3358},{},[3359,3368,3373,3378],{"type":606,"tag":3258,"props":3360,"children":3361},{},[3362],{"type":606,"tag":632,"props":3363,"children":3365},{"className":3364},[],[3366],{"type":612,"value":3367},"'a+'",{"type":606,"tag":3258,"props":3369,"children":3370},{},[3371],{"type":612,"value":3372},"Append + read",{"type":606,"tag":3258,"props":3374,"children":3375},{},[3376],{"type":612,"value":3377},"Appends",{"type":606,"tag":3258,"props":3379,"children":3380},{},[3381],{"type":612,"value":3280},{"type":606,"tag":758,"props":3383,"children":3385},{"id":3384},"key-takeaways",[3386],{"type":612,"value":3387},"🎯 Key Takeaways",{"type":606,"tag":770,"props":3389,"children":3393},{"emoji":3390,"title":3391,"type":3392},"📚","File Writing Essentials","success",[3394,3401,3457,3465,3488,3496,3519],{"type":606,"tag":615,"props":3395,"children":3396},{},[3397],{"type":606,"tag":780,"props":3398,"children":3399},{},[3400],{"type":612,"value":784},{"type":606,"tag":786,"props":3402,"children":3403},{},[3404,3416,3427,3445],{"type":606,"tag":790,"props":3405,"children":3406},{},[3407,3409,3414],{"type":612,"value":3408},"Use ",{"type":606,"tag":632,"props":3410,"children":3412},{"className":3411},[],[3413],{"type":612,"value":798},{"type":612,"value":3415}," for strings",{"type":606,"tag":790,"props":3417,"children":3418},{},[3419,3420,3425],{"type":612,"value":3408},{"type":606,"tag":632,"props":3421,"children":3423},{"className":3422},[],[3424],{"type":612,"value":809},{"type":612,"value":3426}," for lists",{"type":606,"tag":790,"props":3428,"children":3429},{},[3430,3431,3436,3438,3443],{"type":612,"value":3408},{"type":606,"tag":632,"props":3432,"children":3434},{"className":3433},[],[3435],{"type":612,"value":820},{"type":612,"value":3437}," with ",{"type":606,"tag":632,"props":3439,"children":3441},{"className":3440},[],[3442],{"type":612,"value":1283},{"type":612,"value":3444}," parameter",{"type":606,"tag":790,"props":3446,"children":3447},{},[3448,3450,3455],{"type":612,"value":3449},"Always use ",{"type":606,"tag":632,"props":3451,"children":3453},{"className":3452},[],[3454],{"type":612,"value":654},{"type":612,"value":3456}," statement",{"type":606,"tag":615,"props":3458,"children":3459},{},[3460],{"type":606,"tag":780,"props":3461,"children":3462},{},[3463],{"type":612,"value":3464},"Advanced Features:",{"type":606,"tag":786,"props":3466,"children":3467},{},[3468,3473,3478,3483],{"type":606,"tag":790,"props":3469,"children":3470},{},[3471],{"type":612,"value":3472},"Error handling",{"type":606,"tag":790,"props":3474,"children":3475},{},[3476],{"type":612,"value":3477},"Backup creation",{"type":606,"tag":790,"props":3479,"children":3480},{},[3481],{"type":612,"value":3482},"Structured data writing",{"type":606,"tag":790,"props":3484,"children":3485},{},[3486],{"type":612,"value":3487},"Log file management",{"type":606,"tag":615,"props":3489,"children":3490},{},[3491],{"type":606,"tag":780,"props":3492,"children":3493},{},[3494],{"type":612,"value":3495},"Best Practices:",{"type":606,"tag":786,"props":3497,"children":3498},{},[3499,3504,3509,3514],{"type":606,"tag":790,"props":3500,"children":3501},{},[3502],{"type":612,"value":3503},"Handle exceptions gracefully",{"type":606,"tag":790,"props":3505,"children":3506},{},[3507],{"type":612,"value":3508},"Specify encoding explicitly",{"type":606,"tag":790,"props":3510,"children":3511},{},[3512],{"type":612,"value":3513},"Create backups for important files",{"type":606,"tag":790,"props":3515,"children":3516},{},[3517],{"type":612,"value":3518},"Use appropriate file modes",{"type":606,"tag":615,"props":3520,"children":3521},{},[3522,3527],{"type":606,"tag":780,"props":3523,"children":3524},{},[3525],{"type":612,"value":3526},"Remember:",{"type":612,"value":3528}," Choose writing method based on your data format and requirements!",{"type":606,"tag":3530,"props":3531,"children":3532},"style",{},[3533],{"type":612,"value":3534},"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":3536},[3537,3542,3547,3548],{"id":760,"depth":27,"text":763,"children":3538},[3539,3540,3541],{"id":869,"depth":36,"text":872},{"id":1178,"depth":36,"text":1181},{"id":1424,"depth":36,"text":1427},{"id":1853,"depth":27,"text":1856,"children":3543},[3544,3545,3546],{"id":355,"depth":36,"text":353},{"id":2274,"depth":36,"text":2277},{"id":2697,"depth":36,"text":2700},{"id":3213,"depth":27,"text":3216},{"id":3384,"depth":27,"text":3387},1782373756562]