Questions tagged [python-2.6]

For issues that are specific to Python 2.6. If your question applies to Python in general, use the tag [python].

Use this tag if your question is specifically about Python 2.6. If your question applies to Python in general, use the tag . If your question applies to Python 2.x but not to Python 3, use the tag . If you aren't sure, tag your question and mention which version you're using in the body of your question.

1318 questions
-2
votes
2 answers

Multiple value to single key

I have an input file which contains e.g. Shankar Kale Jitendra Shirke Rajendra Bagwe Mahendra Kale I want to create dictionary which maps surnames to names like this: {'Kale':['Shankar', 'Mahendra'], 'Bagwe':'Rajendra',…
Jinesh
  • 11
  • 2
-2
votes
1 answer

Storing certain input

Here's my code; locat_file = 'info/locat.txt' Import os If not os.path.exists(locat_file): #Ask location locat = raw_input("Where are you from?\n").title with open(locat_file, "w") as f: f.write(locat) f.close This code…
-2
votes
1 answer

Taking info from a File

This is my code; Import os #hard code the path to the external file external_file = 'names.txt' username = 'testuser'# Our hardcoded name #if file doesn't exists, create a new file if not os.path.exists(external_file): #Ask the user's name …
-2
votes
3 answers

How to extract the string values "Hello" and "World" from the XML using Python 2.6

I need to extract the strings "Hello" and "World" using Python 2.6. Please advice. language-code
user321956
  • 13
  • 4
-2
votes
1 answer

Python float comparison

I have a problem to understand the following python if clause. key = '033411943470228118020044104711300230269019812152152' my_secret = hex(int(key[0:3]))[2:].zfill(2) + hex(int(key[4:7]))[2:].zfill(2) + hex(int(key[8:11]))[2:].zfill(2) +…
Martin
  • 790
  • 2
  • 9
  • 24
-2
votes
1 answer

Commands in bash don't work when translated to Python

I have this commands in bash: ACTIVE_MGMT_1=ssh -n ${MGMT_IP_1} ". .bash_profile; xms sho proc TRAF.*" 2>/dev/null |egrep " A " |awk '/TRAF/{print $1}' |cut -d "." -f2; I was trying to do it in Python like this: active_mgmgt_1 = os.popen("""ssh -n…
-2
votes
2 answers

python function compression

I have written this big function to do some formatting in my python code. Would you be able to suggest anyways to make this smaller ? def disfun(String1,String2,String3): if String3 == "A" or String3 == "B": if String3 == "A": …
misguided
  • 3,699
  • 21
  • 54
  • 96
-2
votes
3 answers

My def function is not working, do I need to save it then import it to another project?

Ok so, I am a noob at Python, to clear the air. I am 15 and just started learning Python, thought this is the best programming langauge to start with. This might seem very stupid, but here, who can debug this or autocorrect it? :P def…
-2
votes
1 answer

getting an error while executing the code

In the below code i want to print the lines which are between "first", and on those line searching for "new.txt" line.. when i am running i get an error : if "first" in lines[i+n]: IndexError: list index out of range my code: def…
Surya Gupta
  • 165
  • 6
  • 13
-2
votes
4 answers

Replace found items with regexp used.

First I search for the numbers, and replace found with regexp. Then take the changed string (?) and search for the spaces and replace found with regexp. However I get wrong results. test0 = This book id 0076 has 6782e6a test1 = This book id 0076 has…
Surya Gupta
  • 125
  • 7
-3
votes
1 answer

KeyError in While Loop

I am trying to loop through pagination URLs. I find the pagination URL on the first page, go to it, find it on the 2nd page, go to it, so on until the last page. However, I get a KeyError which is a result of pagination being absent from the last…
klex52s
  • 437
  • 1
  • 7
  • 19
-3
votes
1 answer

Python: Convert Table with Missing Data and Irregular Pattern to Dictionary

In Python 2.6, what would be a pythonic way to filter an ASCII table with columns of irregular width, missing data and indented child entries to convert them into a dictionary? col1 col2 col3 col4 A B D …
gtamorim
  • 140
  • 8
-3
votes
1 answer

How can I Install Python 2.6 in CentOs 7?

I Tried to install Python 2.6 in CentOs 7 with sudo yum install python26 But, getting the following error. Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: …
Michael Raj
  • 79
  • 1
  • 10
-3
votes
2 answers

Downloading a list of files from a website

I have a specific requirement where I need to download more than 100 files from a website. I wanted to download all these files but the file names are not consecutive (E.g., www.blah.com/1 , www.blah.com/3, www.blah.com/4, www.blah.com/10). I wanted…
sethu
  • 1,691
  • 4
  • 22
  • 34
-3
votes
4 answers

Merge dictionary values into a set

How do I do the following in the form of a oneliner: replacements = set() for i in replacement_per_file.values(): replacements.update(i)
Baz
  • 12,713
  • 38
  • 145
  • 268
1 2 3
87
88