Category : python-2.7

I want to insert values from the list based on the condition, For example, Please find below my algorithm of the code using CSV module. out_file = open("c://Project//in.csv", "w") header = [‘List’,’Integer’, ‘Float’, ‘String’] l = [[4,5], 12, 2.4, "This is a string", [1,2], 45, ["Second String"]] writer = csv.writer(out_file) insert_header_in_the_beginning for i in l: ..

Read more

I am trying to use pexpect module (version 4.8.0) with Python 3.6.8. I get an error TypeError: cannot use a string pattern on a bytes-like object Here is my code: child = pexpect.spawn(path, args, logfile=buff, timeout=self.PASSPHRASE_TIMEOUT, **kwargs) while True: idx = child.expect([self.PASSPHRASE_RE,pexpect.EOF]) if idx == 0: child.sendline(passphrase) elif idx == 1: child.wait() break I am ..

Read more

error mesaage:/bin/python3 /home/monacode/data/data-structures-and-alhms/python/challange/stack_implementation.py/traning_stack.py class Stack(): def __init__(self) : # self.Node=None # self.current=None self.items=[] def push(self,item=”): self.items.append(item) def pop(self): self.item.pop() pass def peek(self): if self.item: return self.item[-1] else: return None def size(self): if self.items: return len(self.items) else: return None def isempty(self): if self.items==[]: return True else: return False Source: Python..

Read more

This doesn’t seem to be an issue in python 3 but I’m needing to use python 2.7 for this and get the following issue DIRECTORY STRUCTURE module ├── __init__.py └── submodule ├── __init__.py └── test.py # module/__init__.py from module import submodule # module/submodule/__init__.py from module.submodule import test # module/submodule/test.py from module import submodule when I ..

Read more