Skip to main content

Automation helpers

Project description



One line solutions to speed up scripting


pip3 install dracodes


Writing into a file:

aString = 'A normal phrase'
aList = ['jooj', 'cleyton', 'not foo', 'not bar']
aListOfNumbers = list(range(10))
aMixedList = ['hello', 123456789, ['nested1', 'nested2'], {'1': 2}]
aDictionary = {'key1': 1, 'key2': 'valu2', 'key3': [3]}

with open('path/out.txt') as outFile:
    for item in aList:
    for item in aListOfNumbers :
    for item in aMixedList:
    	if isinstance(item, str):
        if isistance(item, list):
        	for subItem in item:
            	# Ok, we get it

A lazy solution:

from dracodes import saveOutput

output = tuple(aString, aList, aListOfNumbers, aMixedList, aDictionary)
saveOutput('path/out.txt', output) # by default in 'write' mode, but It is possible to set 'append' mode

Iterating over lines in a file:

Instead of:

with open('path/file.txt') as file:
	for line in file:
   		# ...

You can use iterFile:

from dracodes import iterFile

for line in iterFile('path/file.txt'):
	# ...

Indented Documents:

text = """class Jooj(object):
    def __init__(self, message):

    def notBar(self):
        print('Not a Bar')

    def notFoo(self):
        print('Not a Foo')"""

doc = IndentedDocument(text)

for line in doc:
    print(f'{line} | Depth: {line.depth}')


class Jooj(object): | Depth: 1
    def __init__(self, message): | Depth: 2
        self.message | Depth: 3
 | Depth: 3
    def notBar(self): | Depth: 2
        print('Not a Bar') | Depth: 3
 | Depth: 3
    def notFoo(self): | Depth: 2
        print('Not a Foo') | Depth: 3

Lucas Vargas Noronha

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dracodes, version 0.31
Filename, size File type Python version Upload date Hashes
Filename, size dracodes-0.31-py3-none-any.whl (12.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size dracodes-0.31.tar.gz (8.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page