Integer Check

Sat 17 May 2025

title: "Integer Check" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


content = "23"
content
'23'
isinstance(content, int)
False
type(content)
str
content.isdigit()
True
text = "one 2 three 4 five 6 seven 8 nine 10"
for x in text.split(" "):
    print(x, "==>", x.isdigit())
one ==> False
2 ==> True …

Category: basics

Read More

Integer Check Temp

Sat 17 May 2025

title: "Integer Check Temp" author: "Rj" date: 2019-05-20 description: "Integer Check" type: technical_note draft: false


content = "23"
content
'23'
isinstance(content, int)
False
type(content)
str
content.isdigit()
True
text = "one 2 three 4 five 6 seven 8 nine 10"
for x in text.split(" "):
    print(x, "==>", x.isdigit())
one …

Category: basics

Read More

Ip Whois

Sat 17 May 2025

title: "IP Whois Simple" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from ipwhois import IPWhois
from pprint import pprint
obj = IPWhois('133.1.2.5')
results = obj.lookup_whois(inc_nir=True)
pprint(results)
{'asn': '4730',
 'asn_cidr': '133.1.0.0/16',
 'asn_country_code': 'JP',
 'asn_date': '1997-03-01',
 'asn_description': 'ODINS …

Category: basics

Read More

Ip2Long

Sat 17 May 2025

title: "IP To Long" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import math
class AuthException(Exception):
    pass
def ip_to_long(ip_address):
    '''

    '''

    if(ip_address == '0:0:0:0:0:0:0:1'):
        ip_address = '127.0.0.1'

    ip_address_array = ip_address.split('.')

    if(len(ip_address_array) != 4):    
        raise AuthException('Invalid Ip …

Category: basics

Read More

Item-In-List

Sat 17 May 2025

import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml311; pyv: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
haystack-ai==2.8.0
ollama-haystack is not installed in the current environment.
python-dotenv==0.21.0

model_cache = {
    "test1.joblib" : {"one …

Category: basics

Read More

Itertool Chain

Sat 17 May 2025

title: "Itertool Chain" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


from itertools import chain
string = 'Toronto'
chain(string)
<itertools.chain at 0x108ed2ba8>
chars = chain(string)
type(chars)
itertools.chain
chars
<itertools.chain at 0x108ed2b70>
for c in chars:
    print(c)
T
o
r
o
n
t …

Category: basics

Read More

Json-To-Xml

Sat 17 May 2025

title: "JSON to XML" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import xmltodict
content = {
  "note" : {
    "to" : "Tove",
    "from" : "Jani",
    "heading" : "Reminder",
    "body" : "Don't forget me this weekend!"
  }
}
content
{'note': {'body': "Don't forget me this weekend!",
  'from': 'Jani',
  'heading': 'Reminder',
  'to': 'Tove'}}
xml = xmltodict.unparse …

Category: basics

Read More

Lambda-Custom

Sat 17 May 2025

title: "Lambda Custom" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


cities = [
    'chennai', 'delhi', 'madurai', 'pune', 'bengaluru'
    ]
cities
['chennai', 'delhi', 'madurai', 'pune', 'bengaluru']
def is_south_indian_city(city):
    if city == 'chennai' or city == 'madurai' or city == 'bengaluru':
        return True

    return False
new_list = list(filter(lambda x: is_south_indian_city(x) , cities …

Category: basics

Read More

Lambda-Odd

Sat 17 May 2025

title: "Lambda Odd" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


def is_odd(digit):
    if digit % 2 != 0:
        return True

    return False 
digits = [
    1, 7, 18, 2, 4, 2, 8, 5, 3
    ]
digits
[1, 7, 18, 2, 4, 2, 8, 5, 3]
new_list = list(filter(lambda x …

Category: basics

Read More

Lambda-Sqaure

Sat 17 May 2025

title: "Lambda Square" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


squares = list(map(lambda x: x**2, range(10)))
squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]


Score: 0

Category: basics

Read More
Page 7 of 17

« Prev Next »