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
0 answers

Reading bigfiles in NLTK Corpus Reader

I am trying to create tagged corpus with from nltk.corpus.reader import TaggedCorpusReader reader = TaggedCorpusReader('.', r'.*\.pos') it is working fine. But it seems it is showing each .pos file as a sentence, but one file may contain multiple…
Coeus2016
  • 355
  • 4
  • 14
1
vote
3 answers

How to use another language with other characters in Python?

I'm trying to pass letters from another language in Python through the program like this: theWord = "阿麗思道" theWord = theWord.decode('unicode-escape') print theWord I keep getting the following error: UnicodeEncodeError: 'charmap' codec can't…
king
  • 1,304
  • 3
  • 23
  • 43
1
vote
1 answer

pip -r error at in bash script

#!/bin/bash -e pip install -r requirements.txt when I execute above script I get below error message; Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main status =…
user44332
  • 85
  • 6
1
vote
2 answers

Python trying to parse input

I'm new to python and have problems with input. When I'm using command userName = input('What is your name? ') it says something like this: >>> userName = input('What is your name? ') What is your name? Name Traceback (most recent call last): …
Andrew Zitsew
  • 45
  • 1
  • 6
1
vote
1 answer

dont want character by character printing

File content: aditya@aditya-virtual-machine:~/urlcat$ cat http_resp telnet 10.192.67.40 80 Trying 10.192.67.40... Connected to 10.192.67.40. Escape character is '^]'. GET /same_domain HTTP/1.1 Host: www.google.com HTTP/1.1 200 OK Date: Tue, 09 Feb…
1
vote
2 answers

Python regex finding sub-string

I'm New to python and regex. Here I'm trying to recover the text between two limits. The starting could be mov/add/rd/sub/and/etc.. and end limit is end of the line. /********** sample input text file *************/ f0004030: a0 10 20 02 mov …
1
vote
1 answer

Add a string to a Python list

movie_list=[] movie_list.extend(movieid[1]) print movieid print movie_list I got the following output: (832871, 'Espas en Hollywood') ['E', 's', 'p', 'a', 's', ' ', 'e', 'n', ' ', 'H', 'o', 'l', 'l', 'y', 'w', 'o', 'o', 'd'] Why did I get a…
user5870009
1
vote
3 answers

Python .split IndexError

New to Python. Trying to call .split to seperate time values so I can count all the login dates for april: here is what the data looks like if I call response['data] [{u'email': u'wilderman.nyree@heidenreich.com'}, {u'login_date':…
Adam Weitzman
  • 1,552
  • 6
  • 23
  • 45
1
vote
1 answer

Learn python the hard way ex24

I don't understand why beans, jars, crates = secret_formula(start_point) refers to jelly_beans, jars, crates. This is the Ex24 from Learn python the hard way. Below I will put a answer from a Stackoverflow question with almost the same answer but…
Nz1
  • 91
  • 1
  • 9
1
vote
1 answer

python Windows "ImportError: DLL load failed: The specified module could not be found." When loading compiled extension

I compiled a module for python using MinGW64 and it won't load. I tried checking the file types of the files (with the mingw file command) and they are both 64 bit, so that's not the problem.
Tim Ludwinski
  • 2,704
  • 30
  • 34
1
vote
2 answers

How does element-wise comparison of dicts, lists and tuples work in Python?

[1,3] > [1,2] True OK, sounds reasonable, on an intuitive level if nothing else. (3,2) <= (3,2) True Ditto. But what makes: (4,3) >= (1,1,1) True And if we are comparing values() here: {'a':1, 'b':2} < {'a':1, 'b':3} True Then why are we…
Pyderman
  • 14,809
  • 13
  • 61
  • 106
1
vote
2 answers

Adding another column to a CSV file w/ python

I am looking to add another column to a CSV file w/ python. file1 is Date.csv has format ID, Date 0,"Jan 22, 2016" 1,"Jan 21, 2016" 2,"Jan 20, 2016" 3,"Jan 19, 2016" and file2 is Price.csv ID, Price 0,27.89 1,26.80 2,26.78 3,26.00 My desired…
Iorek
  • 571
  • 1
  • 13
  • 31
1
vote
5 answers

Python split string every n char

I want to split a string every n char and the print must be like that: MISSISSIPPI => MI*SS*IS*SI*PP*I I've done a program but I don't know how to change the , with a *. Here is the code: n=input('chunk size') s=input('Add word') import…
1
vote
5 answers

Find Symmetric pairs in python

I have the below code to find and print all symmetric pairs from given input. ''' Given a list of number pairs. If pair(i,j) exist, and pair(j,i) exist report all such pairs. ''' def find_all_symmetric_pairs(inp_dic): for key in inp_dic: …
KurinchiMalar
  • 598
  • 3
  • 12
  • 28
1
vote
1 answer

Getting "None" and 'NoneType object...' error when using BeautifulSoup4 to get Text from a webpage

I'm trying to pull the main headline (currently: "Wenger predicts 'active' January") from BBC Sport page. The ID is 'lead-caption' and it's in a

and an tag. I'm using Python. from bs4 import BeautifulSoup import urllib2 url =…

1 2 3
99
100