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.

python-2.7
Filter by
Sorted by
Tagged with
0 votes
1 answer
536 views

update an object after deleting a value from it

i have an object say it as productObj. when I am iterating through this object if a particular condition is met I have to delete that value from that object. something like for data in productObj: ...
Sakeer's user avatar
  • 1,914
1 vote
2 answers
241 views

how to run a python program in linux crontab?

I have added the following line in contab 1 * * * * /usr/bin/python /home/prkumar/Desktop/python/sample.py my sample.py file text_file = open("sample.log", "a") text_file.write("Hi...") ...
sasikkumar's user avatar
2 votes
2 answers
100 views

When python does import, does it import names in 'import' statement?

I don't have a very clear understanding of python's import mechanism. One thing that confuses me is: when python imports a module, does it also imports the names imported there. Here is the code: # A....
NeoWang's user avatar
  • 18k
0 votes
1 answer
225 views

How to create a CSV file Dynamically using Feed in python?

I'm exporting data from python with the csv library which works pretty good. After a web-search I can not find any information about how to dynamically place the rows with python. For example. for ...
Subbu's user avatar
  • 37
1 vote
2 answers
5k views

Library not loaded: QtCore.framework/Versions/4/QtCore

I was trying to do gui programming in Python.I figured out that PySide is a good framework to start with.As i was running Python 2.7.2 i downloaded PySide 2.7 and tried running a sample app.I got ...
Mr.Anonymous's user avatar
-1 votes
1 answer
547 views

Printing variables with incrementing suffixes

What I'm trying to do would be a lot easier to understand by looking at the code: suffix = 1 prefix1="success" prefix2="success" prefix3="success" prefix4="success" while suffix<5: temp = "...
Fraser Hislop's user avatar
2 votes
1 answer
1k views

Django urls.py regex doesn't match?

I'm pretty sure my regex is correct, but somehow it cannot capture the parameter and complaining no page found/match... I'm really stuck, if anyone can help me anything...heap thanks This is the ...
Romans 8.38-39's user avatar
0 votes
2 answers
58 views

Import a list from a different file

Is there a way I can import a list from a different Python file? For example if I have a list: list1 = ['horses', 'sheep', 'cows', 'chickens', 'dog'] Can I import this list into other files? I ...
Joe Michail's user avatar
3 votes
1 answer
112 views

Threading/Multiprocessing in Python

I have the following code: import SimpleHTTPServer import SocketServer def http_server(): PORT = 80 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("",...
Novicode's user avatar
  • 275
0 votes
1 answer
2k views

RDS - boto - how to get results from read_replica_dbinstance_identifiers?

According to my understanding of the boto.rds.dbinstance class, I should be able to get a variable named read_replica_dbinstance_identifiers from the object, but I cannot and I don't understand why. I ...
Bernie's user avatar
  • 1
0 votes
1 answer
112 views

Python Class that Never Throws an AttributeError or TypeError

What is the best way to implement a class that never throws an AttributeError or TypeError? The idea is that I have a class like this class A(): def __init__(self): self.logger = ...
qwwqwwq's user avatar
  • 7,189
2 votes
1 answer
189 views

Display django Model fields in a table

I have Model with 30+ fields and I want to display about 20 of them in a table. I know that there is {{ form.as_table }} but is there a comparable function for non-form models? I am currently using {%...
aled1027's user avatar
  • 1,346
2 votes
1 answer
5k views

HTTPError: HTTP Error 502: Proxy Error ( Connection refused )

I am continuously getting connection Proxy error 502 (connection refused) on Google app engine while running the devserver locally. proxy is by passed for localserver but still its its refusing the ...
Arslan Rafique's user avatar
0 votes
1 answer
214 views

datastore error after migrating to python2.7 - works fine on localhost

I understand that google.appengine.dist was removed from python2.7. What should I use instead? application works fine on localhost, deployment seems to be successful, but I am getting this message ...
Tyra's user avatar
  • 531
1 vote
0 answers
77 views

How to terminate the running function in Python Shell?

I thought this is an easy task but I googled around and had no clue at all. I'm trying to run the pyhook tutorial and once I get to pythoncom.PumpMessages(), the function will stay idle and wait for ...
ailerifren's user avatar
6 votes
2 answers
2k views

How to store an image as a Bytes field in cassandra database using cql engine?

I want to store my website images in cassandra database! I must read and store bytes of image. Do you have a nice code for me? I'm using python2.7, django framework and cql-engine! This is my code: ...
Omid Ebrahimi's user avatar
1 vote
3 answers
2k views

Ignore the items in the ignore list by name in python

I would like to ignore all the items in a ignore_list by name in python. For example consider fruit_list = ["apple", "mango", "strawberry", "cherry", "peach","peach pie"] allergy_list = ["cherry", "...
Deepak B's user avatar
  • 2,305
4 votes
3 answers
2k views

Changing a value in one list changes the values in another list with a different memory ID

I have been beating my head against a wall over this problem. I create a list and make 4 copies, only one of which shares the same memory index. If I change the original list, is somehow changes 3 of ...
Adrian Reich's user avatar
1 vote
2 answers
611 views

findAll() in BeautifulSoup missing nodes

The method findAll() in BeautifulSoup does not return all elements in XML. If you look the code below and open URL, you can see that there are 10 PubmedArticle nodes in XML. However the findAll method ...
nikicc's user avatar
  • 638
0 votes
1 answer
55 views

sys module giving different output when running Python script through IDLE and by double-clicking the script

I was trying to get the Python directory for executing some scripts there. I found an odd behavior. This is just a sample code for pointing out the specific problem. I will place this path into a ...
Aseem Bansal's user avatar
  • 6,872
1 vote
3 answers
786 views

Two Python Version conflict in Ubuntu Oneiric 11.10 issue: ImportError: No module

I installed python 2.7.5 using make install not altinstall Previously it was 2.7.2+ now when i run python it gives ImportError: cannot import name MAXREPEAT I know there are already entries ...
user2290820's user avatar
  • 2,739
0 votes
1 answer
69 views

Is there anyway to make a localized python version?

The problem that I have right now is that I require a specific version of python in order for the source code that I have to work. To make this source code more accessible to everyone, I don't want ...
user2574069's user avatar
0 votes
1 answer
6k views

Read in multiple columns with csv readin

Maybe I am just being picky but as a Matlab user trying to convert I am really having trouble with importing data. I can't seem to read in more than two columns of data with a CSV read in. Here is ...
Casivio's user avatar
  • 333
0 votes
1 answer
508 views

Changing the file name of a Sqlite3 database connection, while keeping keeping entire data

I have something like....: conn = sqlite3.connect(db_path) ... ... conn.close() My db_path could be ":memory:" or a real path, so how would I change it to say "newFile.db" while keeping all of my ...
Ryan's user avatar
  • 269
2 votes
2 answers
1k views

Value Error : invalid literal for int() with base 10: ''

I'm new in Python and I don't know why I'm getting this error sometimes. This is the code: import random sorteio = [] urna = open("urna.txt") y = 1 while y <= 50: sort = int(random.random() *...
Matheus Corrêa's user avatar
1 vote
2 answers
464 views

Whats the python equivalent of a `while read ... do; ... done < file` for tab delimited file?

I'm in the process of converting BASH scripts I've written into python (my BASH chops put me in a minority where I'm working). I've got a BASH while read function loop that opens a file and formats ...
Jamie's user avatar
  • 7,220
2 votes
1 answer
4k views

Python signals for multiprocessing

I would like to execute a certain signal handler in a multi-threading python program. I noted that my signal handler is called for main thread and the other thread (thread_1) that I have created. Is ...
Wael Showair's user avatar
  • 3,102
0 votes
3 answers
78 views

Editing a duplicate list edits the original

So I've started a simple sort of roguelike game project in python, but I have problems with editing a duplicate list editing the original. The code is as follows: charx = 1 chary = 1 level = [["#","#"...
Fraser Hislop's user avatar
0 votes
1 answer
487 views

Once SSHd into my windows laptop, Putty doesn't recognize python

I'm SSHing from a mac into my windows laptop which has PuTTY on it. I can SSH in just fine, and everything seems to work, except for python. When I type in 'python myfile.py' I get the error "-bash: ...
user avatar
7 votes
1 answer
657 views

Python ctypes segmentation fault when rootfs is read-only and /tmp is noexec

I'm trying to use Python for an embedded app on an Arm processor running Linux (CPython 2.7.3 cross-compiled from X86/Linux). It worked really well until I started securing the device to prevent ...
IndigoFire's user avatar
1 vote
1 answer
534 views

Python sub process call

What i am trying to accomplish in a few words is this: change directories and call script from shell. So far so good i have managed to change directories with os.chdir() . However i haven't been ...
user avatar
1 vote
1 answer
526 views

Dirrectory name invalid

The following code gives me the weirdest errors I have seen in a long time. IT gives reference to /*.* when I am not using that? The code: t_src = src.get() t_dst = dst.get() print t_src try: ...
Insert Text Here's user avatar
0 votes
1 answer
2k views

Catching runtime exceptions and outputs from python script in c#

I'm writing a WCF service which runs python scripts. For That I've been using the following code: ProcessStartInfo start = new ProccessStartInfo(); start.FileName = "my/full/path/to/python.exe"; ...
Matt Star's user avatar
3 votes
1 answer
3k views

TypeError: decoding Unicode is not supported python

I am using lxml.html to parse an html file and get the text from the page. Bur now I have a string which has a character ' for example Florian's due to which, while printing the output I get traceback ...
Sangamesh Hs's user avatar
  • 1,447
2 votes
1 answer
2k views

psycopg2: re-using connection object after connection closing

I could not find a way to re-use a connection object. After executing conn.close() I still have the object in memory so there must be a way to re-use it. What's the best way to do it?
casper's user avatar
  • 1,401
3 votes
1 answer
344 views

from import syntax discards attributes starts with _ (underscore)

I have a basic understanding of python, but somewhere I have read that when we import a module using following syntax, it doesn't import attributes defined in specified module which starts with _ (...
tailor_raj's user avatar
  • 1,047
3 votes
3 answers
357 views

Appengine SDK 1.8.2 : Unable to view cron jobs

When using the python SDK 1.8.2, View cron jobs page in dev_appserver admin interface return following errors : Error loading cron.yaml: Traceback (most recent call last): File "/home/User/...
Nijin Narayanan's user avatar
5 votes
0 answers
309 views

Google App Engine Template Not Found

I've written a lightweight application for Google App Engine in Python 2.5 using webapp. After I migrated it to Python 2.7, I caught TemplateDoesNotExist error: TemplateDoesNotExist: ../../base....
user2590854's user avatar
0 votes
1 answer
215 views

Bash - Get output from non-blocking command

I have a python program main.py which produces some outputs which I would like to write to a file. I want to execute the program non-blocking. Usually I would use python2.7 main.py > main.out & ...
Heinrich Ody's user avatar
17 votes
4 answers
61k views

how to display a full screen images with python2.7 and opencv2.4

I am trying to create a sort of image player with python and opencv. The images that i show are the same resolution on my screen and i would like to display them bordless in a full screen mode (...
Gianfra's user avatar
  • 1,139
4 votes
3 answers
20k views

Extract a part of URL - python

I have an URL for example: http://name.abc.wxyz:1234/Assts/asset.epx?id=F3F94D94-7232-4FA2-98EF-07sdfssfdsa3B5 From this Url I want to extract only 'asset.epx?id=F3F94D94-7232-4FA2-98EF-...
Sangamesh Hs's user avatar
  • 1,447
2 votes
1 answer
4k views

How to set offset with matplotlib

I'm trying to remove the offset that matplotlib automatically put on my graphs. For example, with the following code: x=np.array([1., 2., 3.]) y=2.*x*1.e7 MyFig = plt.figure() MyAx = MyFig....
user1618164's user avatar
3 votes
2 answers
2k views

Pandas DataFrames to_latex: how to fit tables on a page?

I'm trying to use the pandas to_latex() function to create PDFs with my tables on them, but every time I try I get an Overfull \hbox (914.42409pt too wide) in paragraph at lines 1--43 or similar ...
Charles Dillon's user avatar
1 vote
1 answer
137 views

Django Filtering data from different model

I have two models User, Details and Skills. In Skills table can store "n" number of skills for particular user. At the time of filtering it display unique user details but keyskills not displayed. I ...
user's user avatar
  • 685
0 votes
0 answers
51 views

IPython redirects to command window after attempted python version update

I am trying to learn something about GUI and game programming, so I was wanting to install Pygame. I was reading through how to install it, and I was recommended to make sure I had the latest version ...
NumberOneRobot's user avatar
1 vote
1 answer
855 views

Problems with merging on-disk tables with millions of rows

TypeError: Cannot serialize the column [date] because its data contents are [empty] object dtype. Hello SO! Currently have got two large HDFStore containing each one node, both the nodes doesn't ...
Mattijn's user avatar
  • 13.5k
8 votes
2 answers
34k views

How to print list item + integer/string using logging in Python

I'd like to print list item with the index of item such as 0: [('idx', 10), ('degree', 0)] 1: [('idx', 20), ('degree', 0)] Based on the code below, how can I append '0:' as integer + string + list ...
twfx's user avatar
  • 1,684
-1 votes
2 answers
8k views

Triangular numbers in python adding a range

I am struggling with what I know should be a really simple loop. I need to add all the numbers from 0 to n. The end result needs to be a positive integer, though I know if it comes out negative I can ...
Minelr G's user avatar
-1 votes
2 answers
2k views

URL Classification in Python: How to know whether given URL belongs to homepage of blog or any article

I'm running a URL classifier algorithm. I have few URLs related to blogs and I want to find out whether entered URL is for any blogpost or URL for blog whle blog. example 1 - if we enter following ...
Wiz's user avatar
  • 307
0 votes
0 answers
946 views

Win7 Taskbar Icon Incorrect for PySide py2exe App

I have a PySide app that I'm converting to an exe to be run on Windows 7 without any dependencies using py2exe. Here's setup from setup.py setup(windows=[{ "script" : "src/main.py", ...
ArtOfWarfare's user avatar