1
vote
1answer
11 views
tkinter root window isn't quite the right size
So I am creating a tkinter canvas, and I need to check for when the user changes the size of the window. The problem is, initially the window apparently isn't the size it's supposed to be. I have the ...
0
votes
0answers
40 views
How to import specific functions, still preserve namespace?
In python, I'd like to import my_fun() from mymodule but I still wish to call it as mymodule.my_fun(). How can I do that?
So far I know only about the following unsatisfying options:
import mymodule ...
1
vote
2answers
30 views
Most reliable way of exiting out of a function on a failed try
What is the best way to except out of ALL potential errors?
## Try to...
try:
## Print
print "hi"
## On failure to get data
except Exception:
## Exit out of current function
return
...
0
votes
1answer
12 views
SocketServer no modules are getting import
I want to create a SocketServer on my mac.
However it seems to be some problem with the packages. When I try this sampling code found here it raises attributeerror.
import SocketServer
class ...
3
votes
4answers
63 views
From-Import while retaining access by module
The title is a little hard to understand, but my question is simple.
I have a program that needs to take the sqrt() of something, but that's the only thing I need from math. It seems a bit wasteful ...
0
votes
0answers
16 views
numpy/arrayobject.h can't be found when profiling, but is fine when running normally
I'm trying to profile some software which includes some cython code. It runs fine but when I run it through the profiler it fails. The other answer on this site suggests adding numpy.get_include() but ...
1
vote
1answer
60 views
Python not detecting when a variable is equal to another variable
I am making a program for my family for keeping ping pong scores. When the score limit is reached, it should end the game and say who won. This works for one player but not the other, and I can't ...
1
vote
3answers
43 views
Why is my code printing 'None'?
My code can be found here: https://github.com/thekarangoel/HackerNewsAPI/blob/master/hn.py
The test case is this:
from hn import HN
hn = HN()
for story in hn.get_top_stories()[:10]:
print ...
0
votes
2answers
26 views
Python 2.7 decode error using UTF-8 header: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3
Traceback:
Traceback (most recent call last):
File "venues.py", line 22, in <module>
main()
File "venues.py", line 19, in main
print_category(category, 0)
File "venues.py", line ...
1
vote
1answer
31 views
AttributeError: module object has no attribute “Series”. Code works in iPython
This is going to be downvoted, and trolled to no end.
Submodules aren't implicitly imported, and must be explicitly declared, but I'm making an explicit call to the pd.Series submodule, aren't I?
...
1
vote
2answers
67 views
Python - How do i write only case statements and instances start with $ from input text file?
I want to only write into a file case line and all instances start with symbol $ in nvp_add function after statement Extended attributes from below input file, so i'm expecting for output like below ...
0
votes
2answers
30 views
Python 2.7: Building Sub Lists from Specific Ranges within a Master List Without Replacement [on hold]
That was a mouthful!
As part of an experiment, I generate an Array of 448 items. Each index (item) looks like this: {'stimulus bin': 1, 'label': 2, 'stimID': 1, 'fileName': 'stim1.png'} and should be ...
0
votes
0answers
9 views
How to install SimpleCV on OSX 10.8
I believe SimpleCV has installed correctly. When I run:
sudo pip install SimpleCV
And then in python try to import the library, I run into this error:
ImportError: No module named ...
1
vote
3answers
48 views
How to add trailing zeros to an integer in python? or How to add ZEROS after any integer in python?
I'm without clues on how to do this in Python. The problem is the following: I have for example an orders numbers like:
1
2
...
10
The output should be
1000
2000
...
10000
That is I want to add ...
2
votes
3answers
47 views
How do i open files in python with variable as part of filename?
something where the filenames have numbers 1-32 and i want to open them in order in a loop like:
i = 1
while i < 32:
filename = "C:\\Documents and Settings\\file[i].txt"
f = open(filename, 'r')
...