Questions tagged [python-2.x]

For questions about Python programming that are specific to version 2.x of the language. Use the more generic [python] tag for all Python questions, and only add this tag if your question is version-specific.

Python 2 is the version of the Python programming language which was for a long time the most widely deployed in production environments; but it is now in the process of being displaced by Python 3. The two versions of the language are not compatible, though many aspects of the syntax are identical. The latest, and last, released version of Python 2 is Python 2.7.18.

Official support for Python 2 has ended on January 1, 2020.

See also Python2 or Python3.

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 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.

Community

Free Python Programming Books

2871 questions
1
vote
1 answer

Partitioning on import / distinct

I'm relatively new to spark and currently I'm wrapping my head about how to (re-)partitioning by data on importing log files from S3 to spark (parquet files). I have a bunch of GZipped log files in S3 in the following format…
mabe.berlin
  • 1,043
  • 7
  • 22
1
vote
1 answer

How to print unicode strings in a Python 2 shell under Windows?

I'm having problems when trying to print symbols such as €, ≤, Å, Ω, ℃, etc., in Python 2.7.11 under Windows 10. I expected that running this piece of code from IDLE: print u'\u20AC\u2A7D\u212B\u2126\u2103' would produce the following output on the…
Tonechas
  • 13,398
  • 16
  • 46
  • 80
1
vote
2 answers

How to compare 2 JSONs in python only with keys

I checked this thread on comparing JSON objects. JSON a: { "errors": [ {"error": "invalid", "field": "email"}, {"error": "required", "field": "name"} ], "success": false } ` JSON b: with extra field { "errors": [ …
born2Learn
  • 1,253
  • 5
  • 14
  • 25
1
vote
1 answer

Referencing with GeoIndex

I am new to GeoIndex. Currently I have ~1600 geo-tagged images, I am working with GeoIndex to find all images within a certain radius of my point(or my current location), all is working fine, it is returning the points which match the query. However…
McCourt2364
  • 61
  • 13
1
vote
3 answers

how to construct a regex that works for multiple cases

I have the following code which matches the string in comments variable,how do I construct the string that matches for both the comments shown below?I want to check for QSPR TEST RESULTS:\siggy.* and TEST RESULTS:.* import re comments = "QSPR…
user5007670
1
vote
1 answer

Migrating code using NetscapeSPKI

I am trying to migrate away from pyspkac, because it does not work with python 3. My old, working code: def createCertFromSPKAC(self, spkacInput, commonName, email): if email is None: theSPKAC = SPKAC(spkacInput, CN=commonName) …
Árpád Magosányi
  • 1,394
  • 2
  • 19
  • 35
1
vote
1 answer

Having trouble with my simple alarm clock

#import RPi.GPIO as GPIO from datetime import datetime from time import strftime import time #Setting up GPIO #GPIO.setmode(GPIO.BCM) #GPIO.setup(23, GPIO.IN) #Datetime variables now_strf = strftime("%I:%M %p") quest = raw_input("What time would…
dannnyt97
  • 11
  • 1
1
vote
1 answer

newB struggling with Backus Naur at Udacity Comp. Sci. 101

I am finishing up the Intro to Computer Science 101 course at Udacity and am looking for some help addressing one of the final quiz problems. The following code returned a "pass" when submitted but I feel like I am not getting at the heart of the…
MmmHmm
  • 3,435
  • 2
  • 27
  • 49
1
vote
1 answer

Troubleshoot a simple checksum comparison script

I have created a simple checksum script that checks a checksum of a file called tecu.a2l and compares it to a few .md5 files - ensuring that they all have the exact same checksum whenever this script is running. To make things easier to…
e_phed
  • 21
  • 3
1
vote
4 answers

Append based on length of string

I have a df like so: Year Month Day 1984 1 1 1985 12 22 and I want to make it so Month and Day have two digits no matter what. So my desired dataframe is like this: Year Month Day 1984 01 01 1985 12 22 I have been…
Stefano Potter
  • 3,467
  • 10
  • 45
  • 82
1
vote
1 answer

Convert ASCII to Unicode encoding issue

I have a question about Python 2 encoding. I am trying to decode an ASCII string which contains Unicode code of a letter to Unicode, and then encode it back to Latin-1, but with no success. Here is an illustration: In[27]: d = u'\u010d' In[28]:…
S. Nestic
  • 13
  • 1
  • 3
1
vote
2 answers

Why python3.5 links python2.7's numpy?

Update the problem: I use sudo python3 >>import numpy It works! And I use the suggestion of below comments : delete the /usr/local/lib/python2.7/site-packages in path. and the problem solved! ======== the old problem =========== I'm using Mac OS…
bengxy
  • 119
  • 1
  • 6
1
vote
3 answers

How to use string formatting with specific nubmer of digits on hex Ascii

In Python 2.7, I want to convert hex ascii number to itself using string formating with specific number of digits Example: hexNumber='9' print '%02x' % (hexNumber) Output: 09
Guy Markman
  • 426
  • 1
  • 4
  • 14
1
vote
1 answer

How to Close GTK Dialogue on event change of combobox?

I am using PyGtk 2.0. In my program I created a Dialog box which includes a Combobox. The Dialog box has no OK or Cancel button. The Dialog must close when the item in the Combobox is selected (means in onchange event). But I could not destroy the…
Anes
  • 35
  • 1
  • 9
1
vote
0 answers

python parallelize for loops

I have a time-intesive code which I would like to parallelize to be run on multiple processors. Is this even possible? import numpy as np def f_big(A, k, std_A, std_k, mean_A=10, mean_k=0.2, hh=100): return ( 1 / (std_A * std_k * 2 * np.pi) ) *…
kilojoules
  • 9,768
  • 18
  • 77
  • 149