Locals 1
title: "Locals of Function"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
def myFunc():
    print("hello")
 
Score: 5
                Read More
                
            
        
            
                Logging 1
title: "Logging"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
import logging
logger = logging.getLogger()
#logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
logger.setLevel(logging.DEBUG)
logging.debug("test")
 
def do_sample():
    for x in range(10):
        logging.info('one …
 
                Read More
                
            
        
            
                Logging 2
title: "Logging 2"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
import logging
logger = logging.getLogger()
#fhandler = logging.FileHandler(filename='mylog.log', mode='a')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
#fhandler.setFormatter(formatter)
logger.addHandler(fhandler)
logger.setLevel(logging.DEBUG)
 
                Read More
                
            
        
            
                Loop-Dictionary
title: "Loop Dictionary"
author: "Rj"
date: 2019-04-20
description: "-"
type: technical_note
draft: false
d = {'person': 2, 'cat': 4, 'spider': 8}
 
for animal in d:
    legs = d[animal]
    print ('A %s has %d legs' % (animal, legs))
 
A person has 2 legs
A cat has 4 legs
A spider has 8 legs
 
Score …
                Read More
                
            
        
            
                Magicattr-Sample
title: "Magic Attribute Sample"
author: "Rj"
date: 2019-04-20
description: "-"
type: technical_note
draft: false
class City:
    def __init__(self, name, country):
        self.name = name
        self.country = country
 
to = City('Toronto', 'Canada')
ch = City('Chennai', 'India')
 
<__main__.City object at 0x10f2f8be0>
 
print(magicattr.get(to, 'country'))
 
Score …
                Read More
                
            
        
            
                Match-All-String
title: "Match All String"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
one_array = one.split(" ")
 
two = "It is nice to be in Toronto"
 
two_array = two.split(" ")
 
['It', 'is', 'nice', 'to', 'be', 'in', 'Toronto']
 
                Read More
                
            
        
            
                Modify String In Place
title: "Modify String in Place"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
sio = io.StringIO(s)
print(sio.getvalue())
 
sio.seek(11)
sio.write("Wonderful")
 
Score: 5
                Read More
                
            
        
            
                More Itertools
title: "More Itertools"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
import itertools as it
import more_itertools as mit
 
a = it.count(0, 2)
mit.take(10, a)
 
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
 
more: 
https://github.com/erikrose/more-itertools
Score: 5
                Read More
                
            
        
            
                Mutable Objet
title: "Mutable Object"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
source: https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument
def foo(a=[]):
    a.append(5)
    return a
 
Reason:
What causes the confusion is the behaviour you get when you …
                Read More
                
            
        
            
                Name Meter
title: "Get Name Meter"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
def get_int(c):
    if(c == 'a'):
        return (200 + ord(c))
    if(c == 'e'):
        return (250 + ord(c))
    if(c == 'i'):
        return (300 + ord(c))
    if(c == 'o'):
        return (350 + ord(c))
    if(c == 'u'):
        return …
 
                Read More