Python Code Samples



Filters


Get os details using python os
kishore_kumar | 7 years, 4 months
import os
print os.uname()
# Don't use os.system('uname -a'), its just executing "uname -a" comman
python python-os
Ramya
PYTHON: To download AWS ELB access log files from S3 bucket based on last modified time
Ramya | 5 years, 8 months
import boto3
import datetime
from datetime import datetime,timedelta,date
Before using this script, you need to set up AWS CLI first as below: ubuntu@ip-172-31-46-2:~$ aws
python boto3 s3
Usage of Operator functions instead of lambda functions
harika | 6 years, 8 months
import functools
import operator
list = [1, 2, 3, 4, 5]
Both lines generates the same result
lambda operator python
fetch all documents from mongo db collection using python
kishore_kumar | 6 years, 7 months
import pymongo

client = pymongo.MongoClient("mongodb://localhost:27017")
pymongo python mongodb
How to connect to PostgreSQL database and display list of tables in python
kishore_kumar | 6 years, 7 months
import psycopg2

conn = psycopg2.connect(host="localhost", database="mydb", user="kishore", passwo
python psycopg2 postgresql
How to get the master IP Address of EMR Cluster
Reshma | 6 years, 2 months
import os
import boto3
session = boto3.Session(profile_name='aws_profile_name')
python aws ipaddress
json string to python dictionary using json module
kishore_kumar | 6 years, 11 months
import json

my_str = '{"1": 4, "4": 2, "5":3 }'
python json
Ramya
Difference between normal def defined function and lambda function in Python
Ramya | 6 years, 3 months
li = [4,65,65,23,86,343,75,3,7,5,87,34,56,64,90] 
final_list = list(filter(lambda x: (x%2 == 0) , l
lambda python
Matrix transpose using list comprehensions in python
harika | 6 years, 8 months
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
#Procedure1:--------
transposed = [[row[i] for row in a ] fo
List comprehensions in python basically reduce the loc. Check the difference between two procudures
python matrix list
sandeep
Python Script to create AWS beanstalk
sandeep | 7 years, 4 months
#!/usr/bin/python
  
import boto
python aws beanstalk
Prev Next