Tagged Questions
-3
votes
0answers
35 views
How to link C libraries
In my python project I have 4 libraries. libedk.so, libedk.so.1 libedk.so.1.0 libedk.so.1.0.0 . I read around that I should link them since Im getting a ctype error while importing them. How can I do ...
0
votes
0answers
7 views
how to pass the current directory as argument in platypus and default python version for Platypus
I finally managed to package python/PyQt4 based tool using Platypus, however since my executable python script can take the directory from which the application is run as argument
I don't know how ...
2
votes
1answer
34 views
Python super usage example
Python docs for super say: Return a proxy object that delegates method calls to a parent or sibling class of type
super(type[, object-or-type])
http://docs.python.org/2/library/functions.html#super
...
-2
votes
1answer
58 views
Unable to import python module
I am working on an exercise where I need to import a python module called ex25. However, I am getting the following error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, ...
2
votes
0answers
18 views
In python using matplotlib how to display multiline strings in ax.fmt_xdata
I'm using matplotlib version 1.2.0 and python 2.7 on linux.
plot(numpy.arange(10))
ax = gca()
ax.fmt_xdata = lambda x: "line1 %d\nline2 %f"%(int(x),x)
On linux using the Qt4Agg backend it does ...
0
votes
5answers
76 views
Python — list comprehension with try/exception and nested conditional
This code should find the mode of a list in O(n) linear time. I want to turn this into a list comprehension because I'm teaching myself Python, and am trying to improve my list comprehension skills.
...
1
vote
2answers
24 views
Python Facebook 'NoneType object error'
I am new to programing and python. I wrote this script below and I am getting a "TypeError: 'NoneType' object is not iterable"
import csv
import json
import urllib
import sys
import time
import re
...
1
vote
1answer
49 views
How to check if a file that contains the ┤character in its name exists?
I have a file named a┤rv.txt on Windows, I'd like to know if this file exists.
I've tried to use the following but it always returns Unsupported characters in input:
>>> import os
...
1
vote
2answers
32 views
Print listdir items on new line – getting None
I have this piece of code:
import os
def listdir(path):
print(os.listdir(path))
print '\n'.join(os.listdir(path))
which returns
['.idea', 'commands', 'testfile.py', '__pycache__']
.idea
...
1
vote
1answer
42 views
Why os.listdir converts ┤ to \xa6 and how to convert it back?
When I run
files = os.listdir(path)
it returns a list with the files in directory path and save it to files, the problem is that one of the files on directory path uses the box drawing charactere ┤ ...
2
votes
3answers
35 views
ArgumentParser with optional argument (in a mutually_exclusive_group)
I'm trying to do a very simple thing - have only two options: -p and -c, mutually exclusive and may or may not have an argument, do th...is with optional argument or do th...at without one. This is ...
1
vote
2answers
55 views
python: behavior of json.dumps on dict
I am trying to override the behavior of the dict on json.dumps. For instance, I can order the keys. Thus, I create a class which inherits if dict, and override some of its methods.
import json
...
0
votes
1answer
38 views
Python reading unicode from local files
I am trying to read some unicode files that I have locally. How do I read unicode files while using a list? I've read the python docs, and a ton of stackoverflow Q&A's, which have answered a lot ...
0
votes
1answer
10 views
Instantiating VisualStudio.VCProjectEngine.10.0 and later fails mysteriously, 8.0 doesn't
Note: the question was originally about Python and win32com, but it turns out that the issue exists within the COM server, not the client-side. Therefore the information in the question and the answer ...
0
votes
1answer
27 views
RobotFramework-selenium2 Chrome browser error
I tried to install google-chrome manually ... using this command
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
...
0
votes
0answers
11 views
How to debug makepy.py failures?
So I was trying to use makepy.py (part of win32com) on the interface VisualStudio.VCProjectEngine.9.0 like this:
makepy.py VisualStudio.VCProjectEngine.9.0
and got that instead of the expected ...
1
vote
4answers
45 views
Decorate a function if condition is True?
I want to do something akin to this, which (understandably) results in a SyntaxError:
@api_view(['GET'])
if settings.USE_API_KEY:
@authentication_classes((TokenAuthentication, ))
...
0
votes
0answers
16 views
Error with StringVar “get” method inheritance with ttk
I'm using Python 2.7.5 on a Windows 7 machine.
I defined a subclass of the Tkinter StringVar that triggers the execution of a specified function when the variable is set. I just started ...
0
votes
1answer
31 views
How to access variables from one method into another?
def check_answer(total,current):
if user_entry == books:
current += 1
total += 1
currentscore = current
def __init__(self):
...
...
2
votes
2answers
52 views
python different length for same unicode
I found something really weird about unicode, in my understanding, if I u"" + "string", the type will be unicode, but why are their length different?
print len(u''+'New York\u200b')
14
print ...
0
votes
1answer
28 views
Pygame: Text Won't Appear Only Background
I have just added in some code I had tried out into my game as a scoreboard and I have encountered an error. Only my background will display. No text or anything will appear. Here is the code I am ...
2
votes
2answers
26 views
Quit when QThreadPool not empty?
I have a lot of long running tasks that run in the background of my Python app. I put them all in the global QThreadPool. When the user quits, all of those background tasks need to stop.
Right now, I ...
3
votes
1answer
41 views
Terminating a while loop after 2 seconds for a lengthy process within the loop
I have a while loop which contains a process which takes roughly 1 second each time but occasionally takes over 5 minutes. I want the loop to terminate after 2 seconds in case this 5 minute scenario ...
0
votes
1answer
40 views
pip install won't install on my machine
so, i am trying to upgrade my Django version to 1.4.2, but when i do pip install Django==1.4.2 -vvv i get:
Will skip URL http://awdb.pypi.python.org/simple/Django/ when looking for download links for ...
-8
votes
1answer
35 views
Transform expression in string without the function str [on hold]
I'd like to transform an expression like 4D2 (without "") into an str so as "4D2" but the function str doesn't work because of the D. Can I do it by anoher way?
Is there for example a way to prevent ...
0
votes
1answer
40 views
Get values from xml file using lxml
As an alternative to store user configs to database, I'm choosing now to store those configs inside a xml file. Using lxml, I created the following (example):
<root>
<trigger ...
1
vote
1answer
26 views
Pygame: Limit Name to 3 or 4 Letters
I am learning about text input in pygame for a game I am creating and currently adding scores into. I have learnt how to write text to a file then read and display the text on the screen. Now I am ...
2
votes
1answer
60 views
Why doesn't python3 care about non-ascii characters in source file?
Suppose I have a .py file with the following contents
print('(ノಠ益ಠ)ノ彡┻━┻')
When called by python3 it prints the angry guy flipping a table, however on python2 we get SyntaxError and need to add a ...
0
votes
1answer
20 views
Changing the referrer URL in python requests
How do I change the referrer if I'm using the requests library to make a GET request to a web page. I went through the entire manual, but couldn't find it.
3
votes
0answers
35 views
Auto-Loading a module from __future__ on iPython startup
I'm trying to to auto load the division module from future on startup,
i've currently got a simple script in the iPython startup libray with the line:
from __future__ import division
which works ...
2
votes
3answers
95 views
Best way to “combine” functions in algorithm?
I am new to programming but I have been trying my hands at an algorithm lately. I need to perform calculations with an equation that uses all angles in a structural assembly in the coordinate plane as ...
0
votes
1answer
21 views
How to install PyQt4 and PyQt5 at different virtualenv?
I'm trying to maintain 2 python projects. one of them is using PyQt4 and another one is using PyQt5. So I created 2 virtualenv as follow.
1) installed virtualenv and virtualenvwrapper by sudo
...
0
votes
2answers
39 views
python extract value from dict nested in list and append back into dict [on hold]
Im using this script to download a json file and alter it to work as a geojson file, and retain the attributes of each location.
The Data I am using can be found here:
...
0
votes
1answer
13 views
Make Tkinter.Listbox selection persist
I have a program where I need to take a selection from Tkinter.Listbox and an entry field and do something with that data. However, if I highlight any text within the entry field (i.e., to delete ...
0
votes
1answer
23 views
How to Install BeautifulSoup4 Python 3.3 Mac
Is there a way to install beautifulsoup4 for python 3.3? pip install beautifulsoup4, easy_install beautifulsoup4, and python setup.py install for beautifulsoup all only install it for python 2.7. When ...
1
vote
1answer
24 views
Email attachment received as 'noname'
The following Python function results in the attachment being named "noname" when it should be "text_file.txt". As you can see I've tried a 2 different approaches with MIMEBase and MIMEApplication. ...
0
votes
2answers
32 views
Merging inherited class's variable
I'm trying to merge a dictionary of a subclass with class inheritance
class Person(object):
nametag = {
"name": "Bob",
"occupation": "Nobody"
}
class Teacher(Person):
...
0
votes
0answers
24 views
How to install python packages in Ubuntu SS? (noob)
I don't normally use python or act as a server admin in the least. I need to install the xlrd package. I have downloaded the package but have no idea where to upload this package on the server. I see ...
0
votes
0answers
50 views
How to decode Hebrew String with Python?
I have searched in all the web how to decode Hebrew String with Python ?
I have tried this and none of them work:
text = "עברית"
text = text.decode("UTF-8")
text = unicode("עברית", "UTF-8")
text = ...
0
votes
4answers
75 views
Transform a list to a number composed of its elements
I'd like to convert a list, for example [1,0,1,0] to the number 1010 (type int). Moreover, I'd like to do it within a function, so not using return. Is it possible and how can I do it?
0
votes
0answers
20 views
How to Configure App Engine Multi Class Endpoints
I'm currently setting up a project to use app engine with python 2.7 on mac and the new endpoints with a multi class configuration. I believe I'm following the instructions, but when I execute a GET ...
-2
votes
2answers
51 views
str.split(' ') giving me “ValueError: empty separator” for a sentence in the form of a string
In case you were wondering, the separator I specified is a space in
words = stuff.split(" ")
The string in question is "This is an example of a question."
I also also tried # as the separator and ...
1
vote
1answer
37 views
Shallow copy of list of lists
I know that [:] doing is shallow copy(member is not copied) ,still can someone explain this behaviour:
>>> a=[['a','b','c','a','b','c','a','b','c'],
... ...
1
vote
4answers
64 views
Trouble with defining global variables
I am writing a class that reads the number of lines in a file before the line "end"
class readFile:
global count
global txt
def __init__(self):
self.count = 0
def ...
0
votes
1answer
42 views
Editing words in a file using python
I'm not getting the logic to edit a file in python which has following content
session1: Part1
host1: #All the four host here should be user input
host2:
host3:
host4:
...
1
vote
2answers
62 views
Relative Import in Python
I am having the following directory structure and I'm new to python. In folder bin I have a single file "script.py" in which I want to import "module.py" from code package. I have seen many solutions ...
-1
votes
1answer
34 views
IndentationError : unexpected indent (views.py, line 40)
i am doing python and i cant solve this error as it looks good. it displays error in else statement.
I have following code:
def getName():
cur = django.db.connections['oprs'].cursor()
...
1
vote
2answers
51 views
Formating list data by table
I am trying to analyse some data, but my data contains letters which require standardising. What I would like to be able to do is, for every datatable in the data (this csv data contains 3 datatables) ...
-4
votes
0answers
21 views
I need source code webkit.WebView() class in python to complete my browser? [on hold]
I have used python to build a browser and when i reached the stage to interpret it and searched online i found webkit.webview() class every where i just want to see how this class make the GUI for ...
0
votes
1answer
40 views
Python27: random() after a setstate() doesn't produce the same random number
I have been subclassing an Python's random number generator to make a generator that doesn't repeat results (it's going to be used to generate unique id's for a simulator) and I was just testing to ...