Questions tagged [python-3.7]

Version of the Python programming language released in June 27, 2018. For issues that are specific to Python 3.7. Use the more generic [python] and [python-3.x] tags where possible.

Python 3.7 was released on June 27, 2018 (PEP 537).


Use this tag if your question is specifically related to Python 3.7. 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.

References

4167 questions
28
votes
12 answers

Can't install pytorch with pip on Windows

I'm trying to install Pytorch with Windows and I'm using the commands of the official site https://pytorch.org/get-started/locally/ pip3 install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html This is the…
relot
  • 651
  • 1
  • 6
  • 18
28
votes
3 answers

Context variables in Python

Suppose that I have a function in my Python application that define some kind of context - a user_id for example. This function call other functions that do not take this context as a function argument. For example: def f1(user, operation): …
Jundiaius
  • 6,214
  • 3
  • 30
  • 43
28
votes
1 answer

Fastest way to sort a python 3.7+ dictionary

Now that the insertion order of Python dictionaries is guaranteed starting in Python 3.7 (and in CPython 3.6), what is the best/fastest way to sort a dictionary - both by value and by key? The most obvious way to do it is probably this: by_key = {k:…
Rick
  • 43,029
  • 15
  • 76
  • 119
26
votes
6 answers

How to create virtual environment for python 3.7.0?

I'm able to install it with root user but I wanted to install it in a clean environment. My use case is to test the installation of another application with pip for the customer who is using python3.7.0 sudo apt-get update sudo apt-get install…
Pankaj Singh
  • 863
  • 2
  • 9
  • 18
26
votes
2 answers

Python 3.7: Utility of Dataclasses and SimpleNameSpace

Python 3.7 provides new dataclasses which have predefined special functions. From an overview point, dataclasses and SimpleNamespace both provide nice data encapsulating facility. @dataclass class MyData: name:str age: int data_1 =…
xssChauhan
  • 2,728
  • 2
  • 25
  • 36
26
votes
1 answer

breakpoint() using ipdb by default

Is it possible that installing ipdb (or some other package written to do it explicitely) will result in breakpoint() running ipdb instead of pdb without binding sys.breakpointhook() to ipdb? https://www.python.org/dev/peps/pep-0553/ I'm not asking…
seler
  • 8,803
  • 4
  • 41
  • 54
24
votes
3 answers

Asyncio in corroutine RuntimeError: no running event loop

I'm writing multi-process code, which runs perfectly in Python 3.7. Yet I want one of the parallel process to execute an IO process take stakes for ever using AsyncIO i order to get better performance, but have not been able to get it to…
Francisco
  • 519
  • 1
  • 5
  • 15
22
votes
10 answers

How to extract text from pdf in Python 3.7

I am trying to extract text from a PDF file using Python. My main goal is I am trying to create a program that reads a bank statement and extracts its text to update an excel file to easily record monthly spendings. Right now I am focusing just…
RaV1oLLi
  • 529
  • 1
  • 3
  • 9
21
votes
6 answers

Check if a field is typing.Optional

What is the best way to check if a field from a class is typing.Optional? Example code: from typing import Optional import re from dataclasses import dataclass, fields @dataclass(frozen=True) class TestClass: required_field_1: str …
Rodrigo Farias Rezino
  • 2,687
  • 3
  • 33
  • 60
21
votes
2 answers

"RuntimeError: asyncio.run() cannot be called from a running event loop" in Spyder

I am trying to learn about asyncio for a websockets client. Every piece of code I try gets the following error: RuntimeError: asyncio.run() cannot be called from a running event loop I have tried the most simple code and it always gives that…
Javier Martin
  • 323
  • 1
  • 3
  • 8
21
votes
8 answers

python3 dataclass with **kwargs(asterisk)

Currently I used DTO(Data Transfer Object) like this. class Test1: def __init__(self, user_id: int = None, body: str = None): self.user_id = user_id self.body = body Example code is very small, But when object…
Hide
  • 3,199
  • 7
  • 41
  • 83
21
votes
2 answers

Python 3.7: dataclass does not raise `TypeError` for `eq=False`

I was trying out the new dataclasses in Python 3.7 The dataclass decorator can be passed arguments to control the dunder functions that are added to the class. For some reason, the decorator does not seem to raise TypeError for eq=False argument. As…
xssChauhan
  • 2,728
  • 2
  • 25
  • 36
20
votes
1 answer

How to stop my pandas data table from being truncated when printed?

I've written code that reads in two strings then compares them for similar words. A table is then produced with the data. My problem is that it keeps splitting into two. I need to rectify this to be able to incorporate this into HTML. I'd…
Brndn
  • 676
  • 1
  • 7
  • 21
19
votes
3 answers

No package 'dbus-1' found

$ python3 -m pip install dbus-python Collecting dbus-python Using cached dbus-python-1.2.16.tar.gz (576 kB) Building wheels for collected packages: dbus-python Building wheel for dbus-python (setup.py) ... error ERROR: Command errored out…
Rajesh Chaudhary
  • 894
  • 2
  • 11
  • 17
19
votes
5 answers

how to succesfully compile python 3.x

Upon attempting to compile python 3.7 I hit Could not import runpy module: jeremyr@b88:$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz .... jeremyr@b88:~/Python-3.7.3$ ./configure --enable-optimizations …
jeremy_rutman
  • 3,552
  • 4
  • 28
  • 47