
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

557 Views
In this article, we will see how to paginate through all databases present in AWS Glue.ExampleProblem Statement: Use boto3 library in Python to paginate through all databases from AWS Glue Data Catalog that is created in your accountApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: max_items, page_size and starting_token is parameter for this function.max_items denote the total number of records to return. If the number of available records > max_items, then a NextToken will be provided in the response to resume pagination.page_size denotes the size of each page.starting_token helps to paginate, and it ... Read More

215 Views
When it is required to trim a list of tuples by a specific number of elements, the ‘del’ operator can be used.Below is a demonstration of the same −Example Live Demomy_list = [(1, 2, 11), (99, 76, 34, 89), (3.08, 11.56), ("Hi", "Will"), ("Rob", 'Ron')] n = 2 print("The list is :") print(my_list) print("The value of N is") print(n) del my_list[n] print("The list after deleting N elements is :") print(my_list)OutputThe list is : [(1, 2, 11), (99, 76, 34, 89), (3.08, 11.56), ('Hi', 'Will'), ('Rob', 'Ron')] The value of N is 2 The list after deleting N elements is : [(1, ... Read More

417 Views
In this article, we will see how to paginate through all crawlers present in AWS Glue.ExamplePaginate through all crawlers from AWS Glue Data Catalog that is created in your account.Problem Statement: Use boto3 library in Python to paginate through all crawlers from AWS Glue Data Catalog that is created in your accountApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: max_items, page_size and starting_token are the parameters for this function.max_items denote the total number of records to return. If the number of available records > max_items, then a NextToken will be provided in the ... Read More

5K+ Views
The significance of Button widget is that it is used for handling events to perform certain operations in the application. In order to handle such events, we generally define a method which contains certain operations.Let us suppose we want to change the event method after initializing the button. We can configure the Button and its handler using configure(options) method. Thus, by defining a new method and configuring the button we can trigger a new event with the same button.Example#Import tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("750x250") #Define ... Read More

619 Views
When it is required to find the number of times every day of the week occurs in a year, a list is defined, and it is iterated over, and is count is incremented respectively.Below is a demonstration of the same −Example Live Demoimport math def num_of_occurrence( n, firstday): my_days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] my_count= [4 for i in range(0, 7)] my_position = -1 for i in range(0, 7): if (first_day == my_days[i]): my_position = i break ... Read More

1K+ Views
When it is required to convert a string into a timestamp, the ‘mktime’ method is used. This method is present in the ‘time’ package.Below is a demonstration of the same −Example Live Demoimport time import datetime my_string = "24/03/2021" print("The date string is :") print(my_string) print("The timestamp is :") print(time.mktime(datetime.datetime.strptime(my_string, "%d/%m/%Y").timetuple()))OutputThe date string is : 24/03/2021 The timestamp is : 1616544000.0ExplanationThe required packages are imported.The string is defined, and displayed on the console.The ‘mktime’ method from time package is called, and the string is passed as parameter to it.The ‘strptime’ is used to remove the extra spaces or symbols from ... Read More

298 Views
In this article, we will see how to update the details of a workflow in AWS Glue Catalog.ExampleProblem Statement: Use boto3 library in Python to update details of a workflow that is created in your account.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: workflow_name is the required parameter for this function. Description and deault_run_properties are optional parameter. It updates the details of a given workflow.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while ... Read More

415 Views
In this article, we will see how to update the scheduler of a crawler present in an AWS account.ExampleProblem Statement: Use boto3 library in Python to update the scheduler of a crawler.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: crawler_name and scheduler are the required parameters in this function.The format of scheduler should be as cron(cron_expression). Cron_Expression can be written as (15 12 * * ? *), i.e., the crawler will run every day at 12:15UTC.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. ... Read More

311 Views
In this article, we will see how to remove tags from AWS Glue Resources.ExampleRemove tags “glue-db: tests” in AWS glue database. Problem Statement: Use boto3 library in Python to remove tags in AWS Glue Resources.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: resource_arn and tags_list are the required parameters in this function.The format of resource_arn should be as following −Catalogarn:aws:glue:region:account-id:catalogDatabasearn:aws:glue:region:account-id:database/database nameTablearn:aws:glue:region:account-id:table/database name/table nameConnectionarn:aws:glue:region:account-id:connection/connection nameCrawlerarn:aws:glue:region:account-id:crawler/crawler-nameJobarn:aws:glue:region:account-id:job/job-nameTriggerarn:aws:glue:region:account-id:trigger/trigger-nameDevelopment endpointarn:aws:glue:region:account-id:devEndpoint/development-endpoint-nameMachine learning transformarn:aws:glue:region:account-id:mlTransform/transform-idtags_list should be as [“key1, key2…]Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, ... Read More

1K+ Views
In this article, we will see how the users can get the tags associated in AWS Glue Resources.ExampleGet tags “glue-db: tests” from AWS glue database. Problem Statement: Use boto3 library in Python to get the tags from AWS Glue Resources.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: resource_arn is the required parameter in this function.Format of resource_arn should be as following −Catalogarn:aws:glue:region:account-id:catalogDatabasearn:aws:glue:region:account-id:database/database nameTablearn:aws:glue:region:account-id:table/database name/table nameConnectionarn:aws:glue:region:account-id:connection/connection nameCrawlerarn:aws:glue:region:account-id:crawler/crawler-nameJobarn:aws:glue:region:account-id:job/job-nameTriggerarn:aws:glue:region:account-id:trigger/trigger-nameDevelopment endpointarn:aws:glue:region:account-id:devEndpoint/development-endpoint-nameMachine learning transformarn:aws:glue:region:account-id:mlTransform/transform-idStep 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass ... Read More