Questions tagged [python-3.4]

The version of the Python programming language released on March 16, 2014. For issues that are specific to Python 3.4. Use the more generic [python] and [python-3.x] tags where possible.

Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability.

Python 3.4 (released on March 16, 2014), the first beta having been released on November 24, 2013) introduces a new enum module providing an enumerated type, and an improved marshal format. Other new modules include:

3.4 also includes a bundled installer for pip to standardize installation of third-party modules.


Use this tag if your question is specifically about . If your question applies to Python in general, use the tag . If your question applies to Python 3.x but not to Python 2, use the tag . If you aren't sure, tag your question and mention which version you're using in the body of your question.

2588 questions
325
votes
7 answers

Python type hinting without cyclic imports

I'm trying to split my huge class into two; well, basically into the "main" class and a mixin with additional functions, like so: main.py file: import mymixin.py class Main(object, MyMixin): def func1(self, xxx): ... mymixin.py…
velis
  • 8,747
  • 4
  • 44
  • 64
299
votes
18 answers

Python3 project remove __pycache__ folders and .pyc files

What is the BEST way to clear out all the __pycache__ folders and .pyc/.pyo files from a python3 project. I have seen multiple users suggest the pyclean script bundled with Debian, but this does not remove the folders. I want a simple way to clean…
SalientGreen
  • 4,764
  • 3
  • 15
  • 20
286
votes
22 answers

Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing

I am using Ubuntu and have installed Python 2.7.5 and 3.4.0. In Python 2.7.5 I am able to successfully assign a variable x = Value('i', 2), but not in 3.4.0. I am getting: Traceback (most recent call last): File "", line 1, in
241
votes
5 answers

Getting value of enum on string conversion

I have the following enum defined: from enum import Enum class D(Enum): x = 1 y = 2 print(D.x) now the printed value is D.x instead, I wanted the enum's value to be print 1 What can be done to achieve this functionality?
Vaibhav Mishra
  • 11,384
  • 12
  • 45
  • 58
199
votes
7 answers

How could I use requests in asyncio?

I want to do parallel http request tasks in asyncio, but I find that python-requests would block the event loop of asyncio. I've found aiohttp but it couldn't provide the service of http request using a http proxy. So I want to know if there's a way…
flyer
  • 9,280
  • 11
  • 46
  • 62
112
votes
10 answers

How to install pip in CentOS 7?

CentOS 7 EPEL now includes Python 3.4: yum install python34 However, when I try that, even though Python 3.4 installs successfully, it doesn't appear to install pip. Which is weird, because pip should be included by default with Python 3.4. which…
Jeff Widman
  • 22,014
  • 12
  • 72
  • 88
94
votes
3 answers

How to properly create and run concurrent tasks using python's asyncio module?

I am trying to properly understand and implement two concurrently running Task objects using Python 3's relatively new asyncio module. In a nutshell, asyncio seems designed to handle asynchronous processes and concurrent Task execution over an event…
songololo
  • 4,724
  • 5
  • 35
  • 49
91
votes
11 answers

No module named 'openpyxl' - Python 3.4 - Ubuntu

I installed openpyxl with $ pip install openpyxl when I try the command from openpyxl import Workbook I get Traceback (most recent call last): File "", line 1, in from openpyxl import Workbook ImportError: No module named…
FrancescoVe
  • 1,060
  • 1
  • 7
  • 12
82
votes
4 answers

Getting values from functions that run as asyncio tasks

I was trying the following code: import asyncio @asyncio.coroutine def func_normal(): print("A") yield from asyncio.sleep(5) print("B") return 'saad' @asyncio.coroutine def func_infinite(): i = 0 while…
Saad Aleem
  • 1,709
  • 1
  • 12
  • 18
80
votes
14 answers

OSError: [WinError 193] %1 is not a valid Win32 application

I am trying to call a Python file "hello.py" from within the python interpreter with subprocess. But I am unable to resolve this error. [Python 3.4.1]. import subprocess subprocess.call(['hello.py', 'htmlfilename.htm']) Traceback (most recent…
Caxton
  • 1,050
  • 1
  • 8
  • 10
70
votes
1 answer

Python Enum, when and where to use?

Python 3.4.0 introduced enum, I've read the doc but still don't know the usage of it. From my perspective, enum.Enum is an extended namedtuple type, which may not be true. So these are what I want to know about Enum: When and where to use Enum? Why…
laike9m
  • 18,344
  • 20
  • 107
  • 140
66
votes
5 answers

What's the correct way to clean up after an interrupted event loop?

I have an event loop that runs some co-routines as part of a command line tool. The user may interrupt the tool with the usual Ctrl + C, at which point I want to clean up properly after the interrupted event loop. Here's what I tried. import…
Nick Chammas
  • 11,843
  • 8
  • 56
  • 115
66
votes
5 answers

Getting Home Directory with pathlib

Looking through the new pathlib module in Python 3.4, I notice that there isn't any simple way to get the user's home directory. The only way I can come up with for getting a user's home directory is to use the older os.path lib like so: import…
Alex Bliskovsky
  • 5,973
  • 7
  • 32
  • 41
61
votes
4 answers

Please explain "Task was destroyed but it is pending!" after cancelling tasks

I am learning asyncio with Python 3.4.2 and I use it to continuously listen on an IPC bus, while gbulb listens on the DBus. I created a function listen_to_ipc_channel_layer that continuously listens for incoming messages on the IPC channel and…
Daniel
  • 3,092
  • 3
  • 32
  • 49
59
votes
3 answers

How can I use functools.singledispatch with instance methods?

Python 3.4 added the ability to define function overloading with static methods. This is essentially the example from the documentation: from functools import singledispatch class TestClass(object): @singledispatch def test_method(arg,…
Dustin Oprea
  • 9,673
  • 13
  • 65
  • 105
1
2 3
99 100