Questions tagged [python-2.7]

Python 2.7 is the last major version in the 2.x series, and is no longer maintained since January 1st 2020. Use the generic [python] tag on all Python questions. Do not add this tag simply to convey the version of Python you're using, unless the question concerns an issue specific to Python 2.7.

Documentation for Python 2.7.

For an explanation as to why it's the last 2.x release, see PEP 404.

The End-of-life date for Python 2.7 was set as the 1st of Jan 2020, see PEP 373. The last release of Python 2.7 was 2.7.18, released April 20, 2020.

This guide explains how to choose a Python version for development. All new projects should now target Python 3 unless you have external requirements which still force you to stay on the old version.


Tagging recommendation:

Use the tag for all Python related questions. If you believe your question includes issues where the version incompatibilities between Python 2.x and Python 3.x are relevant, then add the or in addition to the main tag. If you believe your question may be even more specific, you can 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.

95376 questions
19
votes
7 answers

How to integrate SimpleGUI with Python 2.7 and 3.0 shell

I am learning Python from Coursera. In this course they use SimpleGUI module on CodeSkulptor. Can anyone tell me how to integrate SimpleGUI with python 2.7 and 3.0 shell?
19
votes
6 answers

How to clear all session variables without getting logged out

I am trying to clear all of the session variables but not logout the current user. user = request.session.get('member_id', None) request.session.flush() request.session.modified = True request.session['member_id'] = user request.session.modified =…
Siecje
  • 3,594
  • 10
  • 32
  • 50
19
votes
3 answers

Handling exit code returned by python in shell script

I am calling a python script from within a shell script. The python script returns error codes in case of failures. How do I handle these error codes in shell script and exit it when necessary?
SpikETidE
  • 6,711
  • 15
  • 46
  • 62
19
votes
1 answer

Using super() in a property's setter method when using the @property decorator raises an AttributeError

I am a little confused by the behavior when attempting to overwrite a property in a subclass. The first example sets up two classes, Parent and Child. Parent inherits from object, while Child inherits from Parent. The property a is defined using…
Vorticity
  • 4,582
  • 4
  • 32
  • 49
19
votes
13 answers

Python 2.7 creating a multidimensional list

In Python I want an intuitive way to create a 3 dimensional list. I want an (n by n) list. So for n = 4 it should be: x = [[[],[],[],[]],[[],[],[],[]],[[],[],[],[]],[[],[],[],[]]] I've tried using: y = [n*[n*[]]] y = [[[]]* n for i in…
poop
  • 223
  • 1
  • 2
  • 7
19
votes
4 answers

How to determined if a 2 dimensional list contain a value?

I have a list like following mylist = [('value1', 'value2', 'value3'), ('secval1', 'secval2', 'secval3')] how do I see if the list contains 'value2'?
Tommyka
  • 665
  • 1
  • 5
  • 9
19
votes
2 answers

How do I capture stderr from Fabric's local command?

Fabric v1.4.3 does not capture the output of 'python --version' def python_v(): m = local('python --version', capture=True) print(m)
Yogesh Mangaj
  • 3,200
  • 6
  • 32
  • 45
19
votes
4 answers

Error: "MSVCP90.dll: No such file or directory" even though Microsoft Visual C++ 2008 Redistributable Package is installed

I'm trying to build a package from source by executing python setup.py py2exe This is the section of code from setup.py, I suppose would be relevant: if sys.platform == "win32": # For py2exe. import matplotlib sys.path.append("C:\\Program…
claws
  • 52,236
  • 58
  • 146
  • 195
19
votes
2 answers

capturing dis.dis results

Is there any way to get the output of dis.dis() without redirecting sys.stdout? I have tried: out=str(dis.dis()) and out="""""" out+=str(dis.dis()) However I soon found out that it returns None. Is there any way to fix this?
IT Ninja
  • 6,174
  • 10
  • 42
  • 65
19
votes
4 answers

Text File Parsing with Python

I am trying to parse a series of text files and save them as CSV files using Python (2.7.3). All text files have a 4 line long header which needs to be stripped out. The data lines have various delimiters including " (quote), - (dash), : column, and…
marillion
  • 10,618
  • 19
  • 48
  • 63
19
votes
4 answers

How to make a redirect and keep the query string?

I want to make a redirect and keep what is the query string. Something like self.redirect plus the query parameters that was sent. Is that possible?
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
18
votes
5 answers

In a Python object, how can I see a list of properties that have been defined with the @property decorator?

I can see first-class member variables using self.__dict__, but I'd like also to see a dictionary of properties, as defined with the @property decorator. How can I do this?
Kyle Wild
  • 8,845
  • 2
  • 36
  • 36
18
votes
4 answers

get list of files in a sharepoint directory using python

I have a url for sharepoint directory(intranet) and need an api to return list of files in that directory given the url. how can I do that using python?
balakishore nadella
  • 511
  • 3
  • 7
  • 16
18
votes
2 answers

Sort a list of lists by length and value in Python

How can I sort a Python list (with sublists)? For example, I have the following list: list1 = [[0, 4, 1, 5], [3, 1, 5], [4, 0, 1, 5]] After sorting I am expecting: list1 = [[3, 1, 5], [0, 4, 1, 5], [4, 0, 1, 5]] Another example. I have the…
utij2004
  • 453
  • 1
  • 5
  • 14
18
votes
1 answer

Kivy/Buildozer Import Error - pymssql.so is 64-bit instead of 32-bit

I'm using the 64-bit Kivy/Buildozer VM to build and deploy a Kivy app to Android Lollipop (armeabi-v7a 32-bit arch). The Buildozer build is successful but on execution of the app and import of the pymssql package (used to connect to a remote MS SQL…
darthpaul
  • 211
  • 1
  • 5
1 2 3
99
100