Questions tagged [python-3.x]

DO NOT USE UNLESS YOUR QUESTION IS FOR PYTHON 3 ONLY. Always use alongside the standard [python] tag.

Python is a widely-used, interpreted, object-oriented, and high-level programming language with dynamic semantics, used for general-purpose programming. It was created by Guido van Rossum, and first released on February 20, 1991. Python 3 is the latest version of the Python programming language, first released on December 3rd, 2008. It features simplifications and improvements to the syntax of the language. Some of these changes are backwards incompatible, and therefore Python 3 has its own tag.

Although Python 3 is now the recommended and supported version of the language, some users still remain on version 2.7 for various reasons. If you start new projects or begin to learn Python, version 3 is now the recommended target under normal circumstances:

Python 3 is strongly recommended for any new development. As of January 2020, Python 2 has reached End Of Life status, meaning it will receive no further updates or bugfixes, including for security issues. Many frameworks and other add on projects are following a similar policy. As such, we can only recommend learning and teaching Python 3.

One of the main differences is in the print statement.

Python 2:

print "Hello World"

Python 3:

print("Hello World")

For more information on the differences, see Porting Python 2 Code to Python 3.

For information on Python in general, visit the main Python tag wiki.


Tagging recommendation:

Use the tag for all Python related questions. If you believe your question includes issues specific to the incompatible Python 2.x or Python 3.x, in addition to the main tag, use or . If you believe your question may be even more specific, you may include a version specific tag, such as .

Please do not mix (or a more specific tag such as ) and (ditto) unless you are specifically asking a question about an interoperability problem between versions.

Python Free Tutorials

Python Online Books

Python API Reference

Python Online IDE

Python Package Index

341062 questions
35
votes
2 answers

Getting error while trying to run this command " pipenv install requests " in mac OS

I am facing the following error: Warning: the environment variable LANG is not set! We recommend setting this in ~/.profile (or equivalent) for proper expected behavior. Creating a virtualenv for this project… Using…
Bharanidhar Reddy
  • 420
  • 1
  • 4
  • 12
35
votes
6 answers

multiple authentication backends configured and therefore must provide the `backend` argument or set the `backend` attribute on the user

first of i am new to django/python . i am trying to create a login website that allows the user to register an account and verify via email or directly login via fb or google(Oauth) i receive the error when i click on the validation url sent to the…
gaby awad
  • 1,068
  • 1
  • 9
  • 17
35
votes
2 answers

Are numpy's basic operations vectorized, i.e. do they use SIMD operations?

I am doing some performance analysis, and i wonder, whether numpy vectorizes its standard array operations, when the datatype is known (double). a, b = (some numpy arrays) c = a + b #Is this vectorized? Edit: Is this operation vectorized, i.e. will…
hr0m
  • 2,643
  • 5
  • 28
  • 39
35
votes
6 answers

How to set a custom separator in pandas to_csv()?

From the docs I know that in order to save as a .csv file one can simply do: df.to_csv(sep = ';') However, I would like to use my custom separator, for instance: :::. How can I set ::: as a separator?. I tried to: df.to_csv(sep = ':::') And got:…
john doe
  • 2,233
  • 7
  • 37
  • 58
35
votes
5 answers

WinError 2 The system cannot find the file specified (Python)

I have a Fortran program and want to execute it in python for multiple files. I have 2000 input files but in my Fortran code I am able to run only one file at a time. How should I call the Fortran program in python? My Script: import…
Jone
  • 421
  • 1
  • 5
  • 9
35
votes
4 answers

Use concurrent.futures with new tasks for a real-time scenario

It is fairly easy to do parallel work with Python 3's concurrent.futures module as shown below. with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: future_to = {executor.submit(do_work, input, 60): input for input in…
Ali Gajani
  • 14,762
  • 12
  • 59
  • 100
35
votes
2 answers

How can I set index while converting dictionary to dataframe?

I have a dictionary that looks like the below defaultdict(list, {'Open': ['47.47', '47.46', '47.38', ...], 'Close': ['47.48', '47.45', '47.40', ...], 'Date': ['2016/11/22 07:00:00', '2016/11/22 06:59:00','2016/11/22…
maynull
  • 1,936
  • 4
  • 26
  • 46
35
votes
3 answers

printing tab-separated values of a list

Here's my current code: print(list[0], list[1], list[2], list[3], list[4], sep = '\t') I'd like to write it better. But print('\t'.join(list)) won't work because list elements may numbers, other lists, etc., so join would complain.
max
  • 49,282
  • 56
  • 208
  • 355
35
votes
9 answers

Package for listing version of packages used in a Jupyter notebook

I seem to remember there is a package that printed the versions and relevant information about Python packages used in a Jupyter notebook so the results in it were reproducible. But I cannot remember the name of the package. Can any of you point me…
msx
  • 555
  • 1
  • 5
  • 11
35
votes
4 answers

Python 3, easy_install, pip and pypi

What is the current status of easy_install, pip and the repository (pypi.python.org) with regards to Python 3.x? Are there versions of easy_install and/or pip that can install the right versions of packages from there? Else, are they expected soon?
Muhammad Alkarouri
  • 23,884
  • 19
  • 66
  • 101
35
votes
4 answers

PermissionError: [Errno 13] Permission denied Flask.run()

I am running MacOS X with python 3. The folder and files have 755 but I have also tested it in 777 with no luck. My question is if I have the right permissions why does it not let me run without sudo. Or are my settings…
c3cris
  • 1,276
  • 2
  • 15
  • 37
35
votes
6 answers

replace the punctuation with whitespace

I have a problem with the code and can not figure out how to move forward. tweet = "I am tired! I like fruit...and milk" clean_words = tweet.translate(None, ",.;@#?!&$") words = clean_words.split() print tweet print words Output: ['I', 'am',…
oceano22
  • 463
  • 1
  • 5
  • 8
35
votes
19 answers

Django Migration Error: Column does not exist

Python 3, Django 1.8.5, Postgres I have a model Sites that has been working fine. I recently tried to add a field, airport_code, and migrate the data. class Site(BaseModel): objects = SiteManager() name = models.CharField(max_length=200,…
Alex
  • 743
  • 1
  • 7
  • 19
35
votes
5 answers

Ceil and floor equivalent in Python 3 without Math module?

I need to ceil and floor 3/2 result (1.5) without using import math. math.floor(3/2) => 3//2 math.ceil(3/2) => ? OK, here is the problem: to sum all numbers 15 + 45 + 15 + 45 + 15 ... with N items. sum = (n//2) * 5 + int(n/2) * 15
zooks
  • 525
  • 1
  • 4
  • 12
35
votes
4 answers

normalize non-existing path using pathlib only

python has recently added the pathlib module (which i like a lot!). there is just one thing i'm struggling with: is it possible to normalize a path to a file or directory that does not exist? i can do that perfectly well with os.path.normpath. but…
hiro protagonist
  • 44,693
  • 14
  • 86
  • 111
1 2 3
99
100