Questions tagged [python-3.5]

The version of the Python programming language released on September 13, 2015. For issues that are specific to Python 3.5. Use the more generic [python] and [python-3.x] tags where possible.

Python 3.5 was released on September 13, 2015 (PEP 478).


Use this tag if your question is specifically related to Python 3.5. Otherwise, use the following guidelines to determine which tag(s) you should add to your question:

  • If your question applies to Python in general, use only the tag.
  • If your question applies to Python 3.x but not to Python 2.x, add the tag .
  • If you aren't sure, tag your question with and mention which version you're using in the post.
3423 questions
347
votes
4 answers

What are type hints in Python 3.5?

One of the most talked-about features in Python 3.5 is type hints. An example of type hints is mentioned in this article and this one while also mentioning to use type hints responsibly. Can someone explain more about them and when they should be…
Vaulstein
  • 20,055
  • 8
  • 52
  • 73
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
248
votes
12 answers

ImportError: No module named 'django.core.urlresolvers'

I am working on Django project where I need to create a form for inputs. I tried to import reverse from django.core.urlresolvers. I got an error: line 2, in from django.core.urlresolvers import reverse ImportError: No module named…
viratayya salimath
  • 2,695
  • 2
  • 10
  • 11
232
votes
4 answers

What is the '@=' symbol for in Python?

I know @ is for decorators, but what is @= for in Python? Is it just reservation for some future idea? This is just one of my many questions while reading tokenizer.py.
200
votes
5 answers

"Fire and forget" python async/await

Sometimes there is some non-critical asynchronous operation that needs to happen but I don't want to wait for it to complete. In Tornado's coroutine implementation you can "fire & forget" an asynchronous function by simply ommitting the yield…
Mike N
  • 6,395
  • 4
  • 24
  • 21
188
votes
6 answers

Difference between numpy dot() and Python 3.5+ matrix multiplication @

I recently moved to Python 3.5 and noticed the new matrix multiplication operator (@) sometimes behaves differently from the numpy dot operator. In example, for 3d arrays: import numpy as np a = np.random.rand(8,13,13) b = np.random.rand(8,13,13) c…
blaz
  • 4,108
  • 7
  • 29
  • 54
165
votes
3 answers

Why is x**4.0 faster than x**4 in Python 3?

Why is x**4.0 faster than x**4? I am using CPython 3.5.2. $ python -m timeit "for x in range(100):" " x**4.0" 10000 loops, best of 3: 24.2 usec per loop $ python -m timeit "for x in range(100):" " x**4" 10000 loops, best of 3: 30.6 usec per…
arieljannai
  • 2,124
  • 3
  • 19
  • 39
136
votes
4 answers

asyncio.ensure_future vs. BaseEventLoop.create_task vs. simple coroutine?

I've seen several basic Python 3.5 tutorials on asyncio doing the same operation in various flavours. In this code: import asyncio async def doit(i): print("Start %d" % i) await asyncio.sleep(3) print("End %d" % i) return i if…
crusaderky
  • 2,552
  • 3
  • 20
  • 28
116
votes
1 answer

Why is str.translate much faster in Python 3.5 compared to Python 3.4?

I was trying to remove unwanted characters from a given string using text.translate() in Python 3.4. The minimal code is: import sys s = 'abcde12345@#@$#%$' mapper = dict.fromkeys(i for i in range(sys.maxunicode) if chr(i) in…
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
113
votes
3 answers

"Asyncio Event Loop is Closed" when getting loop

When trying to run the asyncio hello world code example given in the docs: import asyncio async def hello_world(): print("Hello World!") loop = asyncio.get_event_loop() # Blocking call which returns when the hello_world() coroutine is…
TryingToTry
  • 1,033
  • 2
  • 9
  • 9
109
votes
14 answers

How to disable password request for a Jupyter notebook session?

I have been launching Jupyter Notebook for years using the following command: jupyter-notebook --port=7000 --no-browser --no-mathjax When I try to open the jupyter on the browser it ask me for a password, even though I have never set any before. It…
Salvatore Cosentino
  • 6,663
  • 6
  • 17
  • 25
107
votes
2 answers

typing.Any vs object?

Is there any difference between using typing.Any as opposed to object in typing? For example: def get_item(L: list, i: int) -> typing.Any: return L[i] Compared to: def get_item(L: list, i: int) -> object: return L[i]
Markus Meskanen
  • 19,939
  • 18
  • 80
  • 119
107
votes
9 answers

How can I periodically execute a function with asyncio?

I'm migrating from tornado to asyncio, and I can't find the asyncio equivalent of tornado's PeriodicCallback. (A PeriodicCallback takes two arguments: the function to run and the number of milliseconds between calls.) Is there such an equivalent in…
2Cubed
  • 3,401
  • 7
  • 23
  • 40
99
votes
12 answers

'python3' is not recognized as an internal or external command, operable program or batch file

I am using Python 3.5.2 version on Windows 7 and tried using python3 app.py. I am getting this error message: 'python3' is not recognized as an internal or external command, operable program or batch file. Is there any specific cause about why the…
Gaurav Shukla
  • 1,194
  • 1
  • 10
  • 14
89
votes
8 answers

Test if function or method is normal or asynchronous

How can I find out if a function or method is a normal function or an async function? I would like my code to automatically support normal or async callbacks and need a way to test what type of function is passed. async def exampleAsyncCb(): …
Ecko
  • 1,185
  • 1
  • 9
  • 11
1
2 3
99 100