Posts

Showing posts with the label python-file-methods

Featured Post

How to Build CI/CD Pipeline: GitHub to AWS

Image
 Creating a CI/CD pipeline to deploy a project from GitHub to AWS can be done using various AWS services like AWS CodePipeline, AWS CodeBuild, and optionally AWS CodeDeploy or Amazon ECS for application deployment. Below is a high-level guide on how to set up a basic GitHub to AWS pipeline: Prerequisites AWS Account : Ensure access to the AWS account with the necessary permissions. GitHub Repository : Have your application code hosted on GitHub. IAM Roles : Create necessary IAM roles with permissions to interact with AWS services (e.g., CodePipeline, CodeBuild, S3, ECS, etc.). AWS CLI : Install and configure the AWS CLI for easier management of services. Step 1: Create an S3 Bucket for Artifacts AWS CodePipeline requires an S3 bucket to store artifacts (builds, deployments, etc.). Go to the S3 service in the AWS Management Console. Create a new bucket, ensuring it has a unique name. Note the bucket name for later use. Step 2: Set Up AWS CodeBuild CodeBuild will handle the build proces

6 Python file Methods Real Usage

Image
Files always have data in them. For different purposes, you need methods to deal with them. These six file methods of use in this case. Related:  5 top file modes in python. Python file methods Below are the top six file methods in python: Tell() Seek() Flush() Fileno() truncate() isatty() 1. tell() The usage of tell method is it  returns the cursor-position of the file-pointer from the beginning of the file. It tells the current cursor position. The position starts from zero, which is same as of an index. Syntax:  fileobject.tell() 2. seek() The usage of seek  method is cursor position, from one position to the specified position from the beginning of the file, it moves. Here, the cursor will be sought to a particular location. Syntax:  fileobject.seek(position) 3. flush() The usage of flush  method is clean out the internal buffer. Before writing the text in the file, it is best practice to clear out that the internal buffer can be cleared. Syntax:  fileobject.flush() 4. fileno() The