SShortSingh.
Back to feed

Python Basics Explained: Functions, Error Handling, and File Operations

0
·1 views

A new developer guide published on DEV Community breaks down core Python programming concepts without requiring prior coding experience. The guide covers how functions work, including parameter types such as positional, keyword, default, and variable arguments, as well as scope and return values. It also outlines eight common built-in exceptions in Python, explaining the conditions that trigger each error. The article further explains error handling using try, except, else, finally, and raise blocks to manage runtime failures gracefully. Finally, it addresses file operations, covering read, write, and append modes alongside the context manager for safe resource handling.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How to Build a Thread-Safe HTTP Server in Python Using Threading

A new developer tutorial on DEV Community walks through the concept of thread safety and its importance in concurrent programming. Thread safety ensures multiple threads can run simultaneously without corrupting shared data, similar to how a bank must coordinate ATM transactions to prevent errors. The guide uses Python's built-in http.server module to first build a basic single-threaded HTTP server, then extends it with the ThreadingMixIn class from the socketserver module to handle multiple client requests at once. The tutorial is aimed at beginners and explains core concepts like threads, processes, and shared resource management before introducing code. The goal is to help developers understand how to build efficient, concurrent servers suitable for real-world use cases.

0
ProgrammingDEV Community ·

Amazon S3 at 18: Why AWS's First Storage Service Still Powers the Cloud

Amazon S3 (Simple Storage Service), launched in 2006 as one of AWS's earliest offerings, remains a foundational component of modern cloud infrastructure. The object storage service stores data as objects inside buckets, supports individual files up to 5 TB, and guarantees 99.999999999% durability by replicating data across at least three availability zones. Unlike traditional file systems such as EBS or EFS, S3 offers unlimited capacity with no provisioning required and natively integrates with over 200 AWS services. It supports multiple storage classes — from S3 Standard for frequently accessed data to Glacier Deep Archive for long-term retention — allowing teams to balance cost against access needs. S3 is widely used as the backbone of data lakes, static website hosting, backup storage, and machine learning pipelines on AWS.

0
ProgrammingDEV Community ·

Amazon S3 Security, Performance and Infrastructure-as-Code Best Practices Explained

A technical guide covering Amazon S3 security, cost optimisation, and infrastructure-as-code using Terraform has been published as the second part of a two-part series. Since April 2023, all new S3 buckets have Block Public Access enabled by default, and since January 2023, all new objects are encrypted by default using SSE-S3 with AES-256. The guide recommends using SSE-KMS with a dedicated customer-managed key per sensitive bucket to enable auditing via AWS CloudTrail and enforce separation of responsibilities. For cost management, lifecycle policies can automatically transition objects across storage classes, while S3 Intelligent-Tiering handles unpredictable access patterns with no retrieval fees. The article also covers data protection features such as versioning, Object Lock in Compliance mode, and MFA Delete to guard against accidental or malicious deletion.

Python Basics Explained: Functions, Error Handling, and File Operations · ShortSingh