python-3.4

How does python and the regex module handle backslashes?

How does python and the regex module handle backslashes? Question: My current understanding of the python 3.4 regex library from the language reference does not seem to match up with my experiment results of the module. My current understanding The regular expression engine can be thought of as a separate entity with its own programming …

Total answers: 1

Python __init__.py proved to be irrelevant in version 3.4?

Python __init__.py proved to be irrelevant in version 3.4? Question: I am running python 3.4 on the main.py file in the same directory. /root directory is not in python path. It is simply the current directory that the script is executing in. All pycache folders were deleted after each test So why exactly is __init__.py …

Total answers: 2

No module named 'openpyxl' – Python 3.4 – Ubuntu

No module named 'openpyxl' – Python 3.4 – Ubuntu Question: I installed openpyxl with $ pip install openpyxl when I try the command from openpyxl import Workbook I get Traceback (most recent call last): File “<pyshell#0>”, line 1, in <module> from openpyxl import Workbook ImportError: No module named ‘openpyxl’ I am using Python 3.4 and …

Total answers: 11

Export C++ function to python using ctypes: undefined symbol

Export C++ function to python using ctypes: undefined symbol Question: Consider this file containing two similar functions: #include <iostream> int main() { std::cout << “mainn”; } int notmain() { std::cout << “notmainn”; } I compiled this into a shared library: g++ -shared -Wl,-soname,code -o code.so -fPIC code.cpp I wish to call these from python, for …

Total answers: 2

Python 3 zip list unpacking

Python 3 zip list unpacking Question: I have two lists of tuples mkp1 and mkp2 which I zip and want to unpack them later to lists. But after the first part is unpacked, the rest ist missing… Why? Minimal example: # list of tuples mkp1 = [(1, 2), (3, 4), (5, 6)] mkp2 = [(10, …

Total answers: 1

print binary tree level by level in python

print binary tree level by level in python Question: I want to print my binary tree in the following manner: 10 6 12 5 7 11 13 I have written code for insertion of nodes but can’t able to write for printing the tree. so please help on this . My code is : class …

Total answers: 14

Using turtle.onscreenclick to find coordinates of a mouse click

Using turtle.onscreenclick to find coordinates of a mouse click Question: I simply want to use the turtle method onscreenclick to find the coordinates of a mouse click. Currently, I have a grid on which I am playing Othello. I already have the algorithm to convert the raw coordinates to specific grid coordinates that can be …

Total answers: 3

Making a collatz program automate the boring stuff

Making a collatz program automate the boring stuff Question: I’m trying to write a Collatz program using the guidelines from a project found at the end of chapter 3 of Automate the Boring Stuff with Python. I’m using python 3.4.0. Following is the project outline: Write a function named collatz() that has one parameter named …

Total answers: 29

Unable to install logging module (Python)

Unable to install logging module (Python) Question: I’m trying to install the logging module for Python 3.4. I’m using pip3 install logging. Both times I run into a SyntaxError at line 618 of the __init__ method: "raise NotImplementedError, ’emit must be implemented ‘". Someone posted the same question as me, and solved their problem by …

Total answers: 2

python map exception continue mapping execution

python map exception continue mapping execution Question: The following example is very simple. I want to execute map() with a function which can raise Exception. It will be more clearly with an example : number_list = range(-2,8) def one_divide_by(n): return 1/n try: for number, divide in zip(number_list, map(one_divide_by, number_list)): print(“%d : %f” % (number, divide)) …

Total answers: 5