Q_CreationDate
stringlengths
23
23
Title
stringlengths
11
149
Question
stringlengths
25
6.53k
Answer
stringlengths
15
5.1k
Score
float64
-1
1.2
Is_accepted
bool
2 classes
N_answers
int64
1
17
Q_Id
int64
0
6.76k
2014-01-08 12:51:15.417
Is there a tutorial specifically for PyQt5?
I am looking for a PyQt5 tutorial. It is rather complicated to start GUI development with Python for the first time without a tutorial. I only found some PyQt4 tutorials so far, and since something changed from Qt4 to Qt5, for example the fact SIGNAL and SLOT are no more supported in Qt5, it would be nice to have speci...
Been looking for PyQt5 tutorials for some time? Look no further! You won't find many around the internet. Not really tutorials, but pretty self-explanatory basic scripts under the following path: /python/lib/site-packages/PyQt5/examples you will find about 100 examples in 30 folders ranging from beginner to advance...
1
false
1
2,970
2014-01-09 16:57:36.663
Text with multiple colors in PsychoPy
I am messing around in PsychoPy now, trying to modify the Sternberg demo for a class project. I want the stimulus text—the number set—to display in a variety of colors: say, one digit is red, the next blue, the next brown, etc. A variety within the same stimulus. I can only find how to change the color of the entire se...
The current way to implement this is to have a separate text stimulus for each digit, each with the desired colour. If the text representation of the number is contained in a variable called, say, stimulusText then in the Text field for the first text component put "$stimulusText[0]" so that it contains just the first ...
0.386912
false
2
2,971
2014-01-09 16:57:36.663
Text with multiple colors in PsychoPy
I am messing around in PsychoPy now, trying to modify the Sternberg demo for a class project. I want the stimulus text—the number set—to display in a variety of colors: say, one digit is red, the next blue, the next brown, etc. A variety within the same stimulus. I can only find how to change the color of the entire se...
No, that isn't possible right now. There's an experimental new stimulus class called TextBox that will allow it, but you'd have to write code to use that (not available yet from the Builder interface). Or just create some tif images of your stimuli and use those?
1.2
true
2
2,971
2014-01-10 00:10:53.093
how to write a Python program that reads from a text file, and builds a dictionary which maps each word
I am having difficulties with writing a Python program that reads from a text file, and builds a dictionary which maps each word that appears in the file to a list of all the words that immediately follow that word in the file. The list of words can be in any order and should include duplicates. For example,the key "a...
A couple of ideas: Set up a collections.defaultdict for your output. This is a dictionary with a default value for keys that don't yet exist (in this case, as aelfric5578 suggests, an empty list); Build a list of all the words in your file, in order; and You can use zip(lst, lst[1:]) to create pairs of consecutive li...
0.135221
false
1
2,972
2014-01-11 16:01:14.777
Handle Redirects one by one with scrapy
I've written a Spider which has one start_url. The parse method of my spider scraps some data and returns a list of FormRequests. The problem comes with the response of that post request. It redirects me to another site with some irrelevant GET Parameters. The only parameter which seems to matter is a SESSION_ID poste...
I found my own solution to this promlem. Instead of building a list of requests and return them at once, I build a chain of them and passed the next one inside the requests meta_data. Inside the callback I pass either the next request, storing the parsed item in a spider member, or the parsed list of items if there is...
1.2
true
1
2,973
2014-01-11 21:48:20.233
DatastoreInputReader using entity kind with ancestor
Is there a way to use the standard DatastoreInputReader from AppEngine's mapreduce with entity kind requiring ancestors ? Let's say I have an entity kind Domain with ancestor kind SuperDomain (useful for transactions), where do I specify in mapreduce_pipeline.MapreducePipeline how to use a specific SuperDomain entity a...
You cannot specify an ancestor for the DatastoreInputReader -- except for a namespace -- so the pipeline will always go through all your Domain entities in a given namespace.
1.2
true
1
2,974
2014-01-12 00:07:52.940
python version doesn't update on OS X
I've just installed python 3.3.3 on my OS X 10.9.1, however when I run python from the terminal the version that is indicated is 2.7.5. What have I done wrong and how can I make it right?
As per Martijn Pieters's comment, I used python3 and now it works as expected.
1.2
true
1
2,975
2014-01-12 18:40:32.257
Calling a function based on a Listbox current selection "curselection()" in Tkinter
I have a listbox on a GUI in Tkinter. I would like to implement a routine where if a listbox item is selected a function is called (based on this selection) to modify the gui (add another adjacent listbox). Then if that selection changes, the gui reverts back to its default view. Can this be done? Seems you would need ...
The listbox will fire the virtual event <<ListboxSelect>> whenever the selection changes. If you bind to it, your function will be called whenever the selection changes, even if it was changed via the keyboard.
1.2
true
1
2,976
2014-01-14 15:13:59.683
How to use CherrPy as Web server and Bottle as Application to support multiple virtual hosts?
I have a website (which running in Amazon EC2 Instance) running Python Bottle application with CherryPy as its front end web server. Now I need to add another website with a different domain name already registered. To reduce the cost, I want to utilize the existing website host to do that. Obviously, virtual host is ...
perhaps you can simply put nginx as reverse proxy and configure it to send the traffic to the two domains to the right upstream (the cherryPy webserver).
0
false
1
2,977
2014-01-14 16:33:32.020
How to create virtualenv and include non-global associated installed libraries
Several questions address the way to make a virtualenv that does include global site-packages. I'm looking for something different: how to create a new virtualenv based on a Python executable from another location in my network, and also to include the libraries that are installed in that location in the network. I hav...
It's not completely the same thing, but you could try running pip freeze > requirements.txt against that version of Python, then using the resulting file inside your virtualenv with pip install -r requirements.txt to install copies of the modules there.
0
false
1
2,978
2014-01-15 15:10:03.040
Distribute files to users automatically
(This may not be an appropriate question--if there is a better stack site for it, please let me know.) I belong to an organization that distributes sheet music to its users. Right now, we have to individually download each file, and it's a pain. Files are frequently updated, and every time there's a new version we ha...
I would use .. a VCS ? If it were feasible, I'd hack up a windows installer that: - installs git/subversion/your favorite vcs - does an initial checkout/clone of the repository - add a scheduled job to the machine (windows equiv of cronjobs) to run every hour and update the working copies Could be done in a couple hour...
0
false
1
2,979
2014-01-16 17:26:51.843
how do I quit a web driver session after the code has finished executing?
We're using Selenium's Python bindings at work. Occasionally I forget to put the call to WebDriver.quit() in a finally clause, or the tear down for a test. Something bad happens, an exception is thrown, and the session is abandoned and stuck as "in use" on the grid. How can I quit those sessions and return them to bein...
You can restart the node instead of the server.
0
false
1
2,980
2014-01-17 06:29:14.433
Learning python for security, having trouble with su
Preface: I am fully aware that this could be illegal if not on a test machine. I am doing this as a learning exercise for learning python for security and penetration testing. This will ONLY be done on a linux machine that I own and have full control over. I am learning python as my first scripting language hopefully f...
If you just want to do this for learning, you can easily build a fake environment with your own faked passwd-file. You can use some of the built-in python encrypt method to generate passwords. this has the advantage of proper test cases, you know what you are looking for and where you should succeed or fail.
-0.201295
false
1
2,981
2014-01-18 05:46:51.827
Curl Equivalent in Python
I have a python program that takes pictures and I am wondering how I would write a program that sends those pictures to a particular URL. If it matters, I am running this on a Raspberry Pi. (Please excuse my simplicity, I am very new to all this)
The requests library is most supported and advanced way to do this.
0
false
1
2,982
2014-01-18 08:44:47.750
randomly choose from list using random.randint in python
How to use random.randint() to select random names given in a list in python. I want to print 5 names from that list. Actually i know how to use random.randint() for numbers. but i don't know how to select random names from a given list. we are not allowed to use random.choice. help me please
Yes, for repeat sample from one population, @MaxLascombe's answer is OK. If you do not want tiles in samples, you should kick the chosen one out. Then use @MaxLascombe's answer on the rest of the list.
0
false
1
2,983
2014-01-18 11:47:17.300
Python - unit testing
Sorry if this is a really dumb question but I've been searching for ages and just can't figure it out. So I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it. I get the idea of unit testing, but the only thing I can find o...
The whole crawler would be probably tested functionally (we'll get there). As for unit testing, you have probably written your crawler with several components, like page parser, url recogniser, fetcher, redirect handler, etc. These are your UNITS. You should unit tests each of them, or at least those with at least slig...
1.2
true
2
2,984
2014-01-18 11:47:17.300
Python - unit testing
Sorry if this is a really dumb question but I've been searching for ages and just can't figure it out. So I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it. I get the idea of unit testing, but the only thing I can find o...
Unit testing verifies that your code does what you expect in a given environment. You should make sure all other variables are as you expect them to be and test your single method. To do that for methods which use third party APIs, you should probably mock them using a mocking library. By mocking you provide data you e...
0
false
2
2,984
2014-01-18 16:14:24.520
Use template html page with BaseHttpRequestHandler
I am building a small program with Python, and I would like to have a GUI for some configuration stuff. Now I have started with a BaseHTTPServer, and I am implementing a BaseHTTPRequestHandler to handle GET and POST requests. But I am wondering what would be best practice for the following problem. I have two separate ...
This has nothing to do with BaseHTTPRequestHandler as its purpose is to serve HTML, how you generate the HTML is another topic. You should use a templating tool, there are a lot available for Python, I would suggest using Mako or Jinja2. then, on your code, just get the real HTML using the template and use it on your h...
1.2
true
1
2,985
2014-01-18 20:31:39.503
Getting width and height of an image in Pygame
How do you get width and height of an image imported into pygame. I got the size using: Surface.get_size , but I dont know how to get the width and height.
There are 2 methods available for getting the width and height of a surface. The first one is get_size(), it returns a tuple (width,height). To access width for instance, you would do: surface.get_size()[0] and for height surface.get_size()[1]. The second method is to use get_width(), and get_height(), which return the...
1.2
true
1
2,986
2014-01-19 18:57:01.347
Python - Transferring session between two browsers
The issue: I have written a ton of code (to automate some pretty laborious tasks online), and have used the mechanize library for Python to handle network requests. It is working very well, except now I have encountered a page which I need javascript functionality... mechanize does not handle javascript. Proposed Solut...
Since nobody answered, I will post my work-around. Basically, wanted to "transfer" my session from Mechanize (the python module) to the QtWebKits QWebView (PyQt4 module) because the vast majority of my project was automated headless, but I had encountered a road block where I had no choice but to have the user manually...
1.2
true
1
2,987
2014-01-19 19:20:49.737
Python: Is line by line execution possible
Is it possible to run code line by line with Python. Including running any module code, when used, line by line as well. I would like to go out and run some code line by line and watch as each of the lines goes through the processing phase and see just what code is getting executed when certain actions occur. I'm cur...
Just use python -m pdb mycode.py, which will run your code in the python debugger (pdb module). In the debugger you can execute arbitrary code, watch variables, and jump to different places in the code. Specifically, n will execute the next line and h will show you the debugger help.
1.2
true
1
2,988
2014-01-19 21:02:05.463
In python, how do I preserve decimal places in numbers?
I'd like to pass numbers around between functions, while preserving the decimal places for the numbers. I've discovered that if I pass a float like '10.00' in to a function, then the decimal places don't get used. This messes an operation like calculating percentages. For example, x * (10 / 100) will always return 0. ...
You should use the decimal module. Each number knows how many significant digits it has.
0.16183
false
1
2,989
2014-01-19 21:03:16.060
py2exe/pyinstaller: Is it bad practice to put all configurable variables in a .py file?
I'm writing a script for a colleague who runs Windows but my development environment is GNU/Linux. I have a bunch of variables that need to be configurable. So I put them all in a config.py that I've imported it into the main project. Originally I planned to ask him to install Cygwin but then I thought of packaging it ...
I would definitely use a config parser or even just a json or ini file.
0.201295
false
2
2,990
2014-01-19 21:03:16.060
py2exe/pyinstaller: Is it bad practice to put all configurable variables in a .py file?
I'm writing a script for a colleague who runs Windows but my development environment is GNU/Linux. I have a bunch of variables that need to be configurable. So I put them all in a config.py that I've imported it into the main project. Originally I planned to ask him to install Cygwin but then I thought of packaging it ...
The problem you would have is that if your friend decided to change something in the config, he'd have to ask you to do it, run py2exe again and send the .exe to him again. With an .ini file, he'd simply edit the file.
1.2
true
2
2,990
2014-01-20 19:28:21.417
PyGit2 - TreeBuilder.insert('name',blobid,GIT_FILEMODE_BLOB) vs index.add( 'path/to/file' )?
I'm a little confused about how to get started with PyGit2. When adding files (plural) to a newly created repo, should I add them to index.add('path/to/file') or would I be better off creating a TreeBuilder and using tb.insert( 'name',oid, GIT_FILEMODE_BLOB ) to add new content ? If the second case, I am stumped as ...
You can do either ways. I find the index.add() method straightforward. You can fetch all the files to be added or removed to the index using Repository.status() as a dictionary. The dictionary contains the filename as key and status of file as value. Depending upon the status values deleted files will be needed t...
0
false
1
2,991
2014-01-22 04:43:48.810
Safely removing program from usr/local/bin on Mac OSX 10.6.8?
So I've been having a lot of trouble lately with a messy install of Scrapy. While I was learning the command line, I ended up installing with pip and then easy_install at the same time. Idk what kinda mess that made. I tried the command pip uninstall scrapy, and it gave me the following error: OSError: [Errno 13] Perm...
First, next time you get a Permission Denied from pip uninstall foo, try sudo pip uninstall foo rather than trying to do it manually. But it's too late to do that now, you've already erased the files that pip needs to do the uninstall. Also: Up until this point, I've resisted the urge to just delete it. But I know th...
1.2
true
1
2,992
2014-01-22 10:08:57.877
how to wire all the django apps
I'm pretty new with Django, I've been reading and watching videos but there is one thing that is confusing me. It is related to the apps. I've watched a video where a guy said that is convenient to have apps that do a single thing, so if I have a big project, I will have a lot of apps. I made an analogy to a bunch of c...
You could have base app if you want to, but you don't need one. All apps are wired when you declare them in the INSTALLED_APPS in the settings, each app has a urls.py file that will catch the route and call one of the views in that app if there's a match. I use a base app to define global templates, global static files...
1.2
true
1
2,993
2014-01-22 15:44:53.307
In the Jira Python API, how can I get a list of all labels used in a project?
I am using the python API for Jira. I would like to get a list of all the labels that are being used in a project. I know that issue.fields.labels will get me just the labels of an issue, but I am interested in looping through all the labels used in a project. Found this to list all components in a project component...
Labels are a field that is shared across all issues potentially, but I don't think there is a REST API to get the list of all labels. So you'd either have to write a JIRA add-on to provide such a resource, or retrieve all the issues in question and iterate over them. You can simplify things by excluding issues that hav...
0.386912
false
1
2,994
2014-01-22 15:53:15.593
Plotting in Python
I'm new to python and was curious as to how, given a large set of data consisting of census information, I could plot a histogram or graph of some sort. My main question is how to access the file, not exactly how the graph should be coded. Do I import the file directly? How do I extract the data from the file? How is...
what format is your data in? Python offers modules to read data from a variety of data formats (CSV, JSON, XML, ...) CSV is a very common one that suffices for many cases (the csv module is part of the standard library) Typically you write a small routine that casts the different fields as expected (string to floating ...
0
false
1
2,995
2014-01-23 15:24:57.697
How to make a dictionary, in which multiple values access one value(Python)
I want to make a Python dictionary. I want values like 0.25, 0.30, 0.35 to be keys in this dictionary. The problems is that I have values like 0.264, 0.313, 0.367. I want this values to access the keys e.g. I want every value from 0.25(inclusive) to 0.30(exclusive) to access the value under the key 0.25. Any ideas how ...
What you need is to make a custom dictionary class where the __getitem__ method rounds down the value before calling the standard __getitem__ method.
0.201295
false
1
2,996
2014-01-24 03:48:55.790
Bitcoinrpc connection to remote server
Hey I was wondering if anyone knew how to connect to a bitcoin wallet located on another server with bitcoinrpc I am running a web program made in django and using a python library called bitcoinrpc to make connections. When testing locally, I can use bitcoinrpc.connect_to_local), or even bitcoinrpc.connect_to_remote('...
You can use SSL with RPC to hide the password. rpcssl=1
-0.201295
false
1
2,997
2014-01-24 16:59:37.357
Ironworker job done notification
I'm writing python app which currently is being hosted on Heroku. It is in early development stage, so I'm using free account with one web dyno. Still, I want my heavier tasks to be done asynchronously so I'm using iron worker add-on. I have it all set up and it does the simplest jobs like sending emails or anything th...
Easiest way - push message to your api from worker - it's log or anything you need to have in your app
-0.201295
false
1
2,998
2014-01-25 08:17:42.923
On Pickle Corruption
When I load a pickle using pickle.load("foo") how do I know if whats read back is corrupt or not? For example, if I'm pickling a large list using pickle.dump and kill my python process before its finished, what would the consequences then be and how should I deal with them?
I've just manually corrupted a pickled file. It threw an error. Presumably, if a file does not throw an error it's either the file you pickled, or it's been so carefully tampered with that it fools the pickle module. In that case, I think you're pretty much sunk.
0
false
1
2,999
2014-01-26 16:45:18.503
How to find polysemous words from given input query?
If my input query is: "Dog is barking at tree" here word "bark" is polysemous word and we know that. But how to check it through a code in python language using wordnet as a lexical database?
If a word has multiple synsets then you can say it is a polysemous word.
0
false
1
3,000
2014-01-28 01:12:24.687
How do I access a dynamic property in PyQt?
I've created a dynamic property in the Designer interface. How do I access this property in my code? I don't see any properties listed with the name I've provided. I've found a dynamicPropertyNames property that contains a QByteArray object and the name I provided, but I cannot figure out how to access the data I store...
Just because I had a similar problem and the reason wasn't a wrong object: The property's content can be accessed with toString().
0
false
1
3,001
2014-01-28 05:30:39.850
Why is it taking more time, When i upgrade a module in Openerp
I'm new to Openerp.I have modified the base module and when i goto installed modules and search for BASE module and click upgrade button it is nearly taking 5mins.Can any one please say me how can i reduce the time that is taking for up-gradation of existing module. Note: I have Messaging,Sales,Invoicing,Human-resource...
why you going in installed modules and search for base module and update it? you have to only update that module in which you have done changes in xml file not event py file. if you have changes in xml file of those module you have to update only those module. if you going to update base module it will update all modul...
0
false
2
3,002
2014-01-28 05:30:39.850
Why is it taking more time, When i upgrade a module in Openerp
I'm new to Openerp.I have modified the base module and when i goto installed modules and search for BASE module and click upgrade button it is nearly taking 5mins.Can any one please say me how can i reduce the time that is taking for up-gradation of existing module. Note: I have Messaging,Sales,Invoicing,Human-resource...
As you have said that You are new to OpenERP, Let me tell you something which would be very helpful to you. i.e Never Do changes in Standard modules not in base. If you want to add or remove any functionality of any module, you can do this by creating a customzed module. in which inherit the object you want, and d...
1.2
true
2
3,002
2014-01-28 23:49:44.197
What's actually happening when I convert an int to a string?
I understand it's easy to convert an int to a string by using the built-in method str(). However, what's actually happening? I understand it may point to the __str__ method of the int object but how does it then compute the “informal” string representation? Tried looking at the source and didn't find a lead; any he...
Internally the Int object is stored as 2's complement representation like in C (well, this is true if range value allow it, python can automagically convert it to some other representation if it does not fit any more). Now to get the string representation you have to change that to a string (and a string merely some un...
1.2
true
1
3,003
2014-01-29 01:20:05.367
I am trying to save high scores with pickle, but how do I add to an already pickled document and then get the max?
I am trying to save high scores in a game that I am creating, but each time I do a pickle.dump, it overwrites my previous data. Any help?
You would need to load your existing pickle'd object, modify it, and then dump it again with the modifications.
0.265586
false
1
3,004
2014-01-29 18:19:35.563
How can I generate a list of all possible permutations of several letters?
So I am making a word generator that takes several inputted letters, puts them in all possible positions, and matches them with a document to find words. If I am approaching this wrong please tell me! If not how can I do this? Thanks
It might be faster to run it in reverse: index your document, and for each word, see if it is a subset of your list of letters.
0.201295
false
1
3,005
2014-01-30 00:55:53.017
Creating a web service for Qualtrics written in Python on Google App Engine
Has anyone out there created a a.) web service for Qualtrics or b.) a Python web service on Google App Engine? I need to build in some functionality to a Qualtrics survey that seems only a web service (in the Qualtrics Survey Flow) could do, like passing parameters to a web service then getting a response back. I've l...
I am familiar with Qualtrics but I will answer (b) first. You can write a Python Web Service in a variety of ways, depending on your choice: You could write a simple get handler Use Google Cloud Endpoints Use one of several Web Services Python libraries Having said that, a quick glance at Qualtrics indicated that it ...
1.2
true
1
3,006
2014-01-30 13:06:58.270
When installing through pip, how do I tell matplotlib how to find tkinter?
I have a fresh Python 3.3 installation on Red Hat Enterprise Linux 6.5, including Tkinter — python3.3 -m tkinter works and shows a dialogue. However, when I run pip3.3 install matplotlib, at the Optional Backend Dependencies, it says: Tkinter: no * TKAgg requires Tkinter How does matplotlib determine th...
I suggest you get matplotlib from your distro's repositories. Pip is fine for installing simple, pure Python packages but isn't very convenient for packages such as matplotlib or numpy, for which a lot of non-Python dependencies need to be solved. Your package manager should nicely take care of all this stuff for you.
-0.386912
false
1
3,007
2014-01-31 21:23:58.273
Instructing Pip to Use Python 3
I'm using Ubuntu, how do I instruct pip to use the Python3 installation and not Python2.6? 2.6 is the default installation on Ubuntu. I can't upgrade that as it will break Ubuntu.
Any single pip installation is (roughly) specific to one Python installation. You can, however, have multiple parallel pip installations. Your package manager probably has a package called pip-3.3 or similar. If not, you can manually install it (run the get-pip.py script using Python 3.3), though you'll have to be care...
1.2
true
1
3,008
2014-02-01 12:57:42.223
how do I get the name of application launched by subprocess in python?
I am launching the text editor but for different users the default text editor could be different, so how do I get the name of which text editor is being used just to handle if an error occur switch to different text editor ?
Given you're working in a Linux/POSIX environment you could read the EDITOR environment variable using the os.environ map.
1.2
true
1
3,009
2014-02-01 16:47:45.430
Python - A way to learn and detect text patterns?
Problem: I am given a long list of various position titles for jobs in the IT industry (support or development); I need to automatically categorize them based on the general type of job they represent. For example, IT-support analyst, help desk analyst... etc. Could all belong to the group IT-Support. Current Approach:...
There were suggestions about unsupervised learning, but I recommend to use supervised learning, so you'll categorize 100-200 positions manually, and then algo will do the rest. There are number of resources, libraries, etc. - look please at "Programming Collective Intelligence" book - they provided good machine learni...
0
false
2
3,010
2014-02-01 16:47:45.430
Python - A way to learn and detect text patterns?
Problem: I am given a long list of various position titles for jobs in the IT industry (support or development); I need to automatically categorize them based on the general type of job they represent. For example, IT-support analyst, help desk analyst... etc. Could all belong to the group IT-Support. Current Approach:...
This sounds like a clustering, or unsupervised, problem rather than a decision tree one (do you know all the roles in advance, and can you provide labelled data). If it were me, I'd be tempted to build a bag-of-words style representation of your strings and run a generic clustering algorithm (k-means, say) to see what ...
0
false
2
3,010
2014-02-01 22:40:51.917
How do I tell Aptana Studio to use Python virtualenv?
I did some searches on this topic and the solutions didn't work for me. I am running both a Linux (Ubuntu) environment and Windows. My system is Windows 8.1 but I have virtualbox with Ubuntu on that. Starting with Windows... I created a venv directory off the root of the e drive. Created a project folder and then r...
Configure Aptana Studio's python interpreter( you can configure more than one) In aptana, Window -> Preferences -> Interpreter Python and create a New interpreter. Select the python executable from the virtual environment (in windows it is python.exe which resides in Scripts subfoler of the virtualenv,where as in ubunt...
0.999909
false
1
3,011
2014-02-02 10:46:01.093
In Python (on Raspberry Pi) how do I create an embedded keypad within my Tkinter window
I am using Tkinter to create an application which requires a 0-9 numerical keypad to be built in to the UI. I plan to do this with 10 button widgets which enter the relevant number(s) into the currently selected Entry widget. I do not want to use one of the pre-made on-screen keyboards (e.g. Matchbox-keyboard) that ar...
You don't need to simulate keypresses if all you want to do is insert the numbers into the entry widget. Just have the buttons directly insert their value into the entry widget with the entry widget insert method.
1.2
true
1
3,012
2014-02-02 12:46:43.573
How to find out which VM i have in my Python installation?
I installed Python in my PC. how to find out which VM came with it. is it cpython or ipython or jpython?
Run this in command prompt python -c "from platform import python_implementation; print python_implementation()"
0
false
1
3,013
2014-02-03 12:11:14.003
How to get Sphinx working with Jython on an unnetworked Windows 7 computer?
Once sphinx-apidoc has been run the command C:\path\to\doc\make html produces an error beginning: The 'sphinx-build' command was not found [snip] However the command does exist and the relevant environment variables are set. More detail: 1 - Trying to run sphinx_apidoc: 'C:\path\to\jython\bin\sphinx-apidoc' is not r...
I have managed to get it working. The problem was that the manual installation and the use of Jython meant that certain environment variables that were expected were not in place. Also, the use of Windows 7 (and I believe MS Windows in general) means that Python scripts without an extension cannot be run without callin...
1.2
true
1
3,014
2014-02-03 18:36:12.997
soundcloud api python user information
Issues using SoundCloud API with python to get user info I've downloaded the soundcloud library and followed the tutorials, and saw on the soundcloud dev page that user syntax is, for example /users/{id}/favorites. I just don't know how to use python to query user information. Specifically, i would like to print a lis...
You can also do the following : import soundcloud token= 'user_access_token' client = soundcloud.Client(access_token=token) user_info = client.get('/me') user_favorites = client.get('/me/favorites') user_tracks = client.get('/me/tracks') and so on...
0.135221
false
1
3,015
2014-02-04 06:40:51.797
Pagination in Google App EngineSearch API
I want to do pagination in google app engine search api using cursors (not offset). the forward pagination is straight forward , the problem is how to implement the backward pagination.
Sorry to revive this old question, but I have a solution for this issue given a few constraints with possible workarounds. Basically, the cursors for previous pages can be stored and reused for revisiting that page. Constraints: This requires that pagination is done dynamically (e.g. with Javascript) so that older curs...
0.201295
false
1
3,016
2014-02-04 15:17:48.090
how do I re-write/redirect URLs in Gunicorn web server configuration?
I'm building a Django-based app, and I need it to use secure requests. The secure requests in my site are enabled and manually writing the url gets it through fine. As I have quite a lot of urls I don't want to do it manually, but instead do something so Django always sends secure requests. How can I make it so it alwa...
The protocol has nothing to do with django. That part is handled by your http server
0.386912
false
1
3,017
2014-02-04 16:32:05.507
Executable shell file in Windows
I have a executable file working in Ubuntu that runs a script in Python and works fine. I have also a shared directory with Samba server. The idea is that everyone (even Windows users) can execute this executable file located in this shared folder to run the script located in my computer. But, how can I make an execut...
As you've said, this executable file would need to be something that runs on both Linux and Windows. That will exclude binary files, such as compiled C files. What you are left with would be an executable script, which could be Bash Ruby Python PHP Perl If need be the script could simply be a bootstrapper that loads ...
0
false
1
3,018
2014-02-04 17:12:40.243
Redirect user when the worker is done
I have the app in python, using flask and iron worker. I'm looking to implement the following scenario: User presses the button on the site The task is queued for the worker Worker processes the task Worker finishes the task, notifies my app My app redirects the user to the new endpoint I'm currently stuck in the mid...
You can do it as follows: When the user presses the button the server starts the task, and then sends a response to the client, possibly a "please wait..." type page. Along with the response the server must include a task id that references the task accessible to Javascript. The client uses the task id to poll the ser...
1.2
true
1
3,019
2014-02-04 17:46:54.083
IPython Notebook crashing Chrome tabs
I'm doing some work in an IPython Notebook session, and I now have a large-ish notebook containing code, some plots, and some embedded videos (of plot stacks; it seemed like the easiest way to be able to scroll through a sequence of plots interactively in the Notebook view). I'm working in Chrome (Mac, 32.0.1700.102) s...
I was experiencing the same issue. Actually I found this is related to chrome extensions installed. Try disabling all the extensions and re-enabling them one by one. You'll find which is crashing your tab. In my case, crashes were due to the Evernote extension. Alternatively, you can open up an incognito window, which ...
0.201295
false
1
3,020
2014-02-05 13:14:44.150
Reorder model objects in django admin panel
I have several configuration objects in django admin panel. They are listed in the following order Email config General config Network config Each object can be configured separately, but all of them are included in General config. So basically you will need mostly General config, so I want to move it to the top. I k...
I don't see an obvious solution to this — the models are sorted by their _meta.verbose_name_plural, and this happens inside the AdminSite.index view, with no obvious place to hook custom code, short of subclassing the AdminSite class and providing your own index method, which is however a huge monolithic method, very i...
1.2
true
1
3,021
2014-02-05 16:10:28.280
How to find the breakpoint numbers in pdb (ipdb)?
Trying to find how to execute ipdb (or pdb) commands such as disable. Calling the h command on disable says disable bpnumber [bpnumber ...] Disables the breakpoints given as a space separated list of bp numbers. So how whould I get those bp numbers? was looking through the list of commands and couldn't get any t...
info breakpoints or just info b lists all breakpoints.
-0.905148
false
2
3,022
2014-02-05 16:10:28.280
How to find the breakpoint numbers in pdb (ipdb)?
Trying to find how to execute ipdb (or pdb) commands such as disable. Calling the h command on disable says disable bpnumber [bpnumber ...] Disables the breakpoints given as a space separated list of bp numbers. So how whould I get those bp numbers? was looking through the list of commands and couldn't get any t...
Use the break command. Don't add any line numbers and it will list all instead of adding them.
0.999967
false
2
3,022
2014-02-05 21:03:41.120
Using python2.7 with Emacs 24.3 and python-mode.el
I'm new to Emacs and I'm trying to set up my python environment. So far I've learned that using "python-mode.el" in a python buffer C-c C-c loads the contents of the current buffer into an interactive python shell, apparently using what which python yields. In my case that is python 3.3.3. But since I need to get a pyt...
I don't use python, but from the source to python-mode, I think you should look into customizing the variable python-python-command - It seems to default to the first path command matching "python"; perhaps you can supply it with a custom path?
0
false
1
3,023
2014-02-07 01:25:20.650
Where should I save the Amazon Manifest json file on an app hosted at PythonAnywhere?
I am trying to have my app on Amazon appstore. In order to do this Amazon needs to park a small json file (web-app-manifest.json). If I upload it to the the root of my web site (as suggested), Amazon bot says it cannot access file. Amazon support mention I should save it to /var/www/static but either I don't know how ...
You can get to /var/www/static in the File browser. Just click on the '/' in the path at the top of the page and then follow the links. You can also just copy things there from a Bash console. You may need to create the static folder in /var/www if it's not there already.
0.386912
false
1
3,024
2014-02-07 16:38:57.553
The predict method shows standardized probability?
I'm using the AdaBoostClassifier in Scikit-learn and always get an average probability of 0.5 regardless of how unbalanced the training sets are. The class predictions (predict_) seems to give correct estimates, but these aren't reflected in the predict_probas method which always average to 0.5. If my "real" probabilit...
Do you mean you get probabilities per sample that are 1/n_classes on average? That's necessarily the case; the probabilities reported by predict_proba are the conditional class probability distribution P(y|X) over all values for y. To produce different probabilities, perform any necessary computations according to your...
0
false
1
3,025
2014-02-08 00:08:32.817
Error when trying to sum an array by block's
I have a large dataset stored in a numpy array (A) I am trying to sum by block's using: B=numpy.add.reduceat(numpy.add.reduceat(A, numpy.arange(0, A.shape[0], n),axis=0), numpy.arange(0, A.shape[1], n), axis=1) it work's fine when i try it on a test array but with my data's I get the following message: TypeError: Can...
In case anyone else has a similar problem but the chosen answer doesn't solve it, one possibility could be that in Python3, some index or integer quantity fed into a np function is an expression using '/' for example n/2, which ought to be '//'.
0.201295
false
1
3,026
2014-02-08 19:39:43.780
Getting connection object in generic model class
I have a Model class which is part of my self-crafted ORM. It has all kind of methods like save(), create() and so on. Now, the thing is that all these methods require a connection object to act properly. And I have no clue on what's the best approach to feed a Model object with a connection object. What I though of so...
Here's how I would do: Use a connection pool with a queue interface. You don't have to choose a connection object, you just pick the next on the line. This can be done whenever you need transaction, and put back afterwards. Unless you have some very specific needs, I would use a Singleton class for the database connec...
1.2
true
1
3,027
2014-02-08 23:30:27.383
PyQt: Saving native QTreeWidgets using QDataStream
I recently spent some time working out how to use a QDataStream with a QTreeWidget in PyQt. I never found specific examples for doing exactly this, and pyqt documentation for QDataStream seems to be pretty scarce in general. So I thought I'd post a question here as a breadcrumb trail in case someone else down the lin...
The QTreeWidget is a red herring. What you are saving is a generic QAbstractItemModel (treeWidget->model()) - after all, a QTreeWidget is a view, and has a built-in model. Now, those model's items are simply QVariants, and those are simply Python types, but also fully supported by QDataStream::operator<<. All you need ...
0
false
1
3,028
2014-02-09 05:53:29.907
Simple explanation of Google App Engine NDB Datastore
I'm creating a Google App Engine application (python) and I'm learning about the general framework. I've been looking at the tutorial and documentation for the NDB datastore, and I'm having some difficulty wrapping my head around the concepts. I have a large background with SQL databases and I've never worked with any ...
I think you've overcomplicating things in your mind. When you create an entity, you can either give it a named key that you've chosen yourself, or leave that out and let the datastore choose a numeric ID. Either way, when you call put, the datastore will return the key, which is stored in the form [<entity_kind>, <id_o...
1.2
true
1
3,029
2014-02-10 10:59:16.017
How do I return word under cursor in tkinter?
I want to make a text editor with autocompletion feature. What I need is somehow get the text which is selected by mouse (case #1) or just a word under cursor(case #2) to compare it against a list of word I want to be proposed for autocompletion. By get I mean return as a a string value. Can it be done with tkinter at ...
You can use QTextEdit::cursorForPosition to get a cursor for mouse position. After that you can call QTextCursor::select with QTextCursor::WordUnderCursor to select the word and QTextCursor::selectedText to get the word.
-0.386912
false
1
3,030
2014-02-11 11:39:07.080
How do I find the postgres version running on my heroku app?
I have a python / django app on heroku. how do i find the postgres version running on my app?
$ heroku pg:info --app yourapp
1.2
true
1
3,031
2014-02-11 17:30:07.183
Regex for weekdays in python
I seem to be having a problem finding the correct regex for weekdays in Python. I have tried this: /(mon|tues|wednes|thurs|fri|satur|sun)day/ The problem is that this regex accepts if I just have "mon" in a text, but I only want it to accept if I have "monday". How do I fix this? I can't seem to understand how to do t...
You can also try like below, a = 'your-string' result = re.findall('(mon|tues|wed|thurs|fri|sat|sun)day', a) if result: _day = result[0] + 'day'
0
false
1
3,032
2014-02-11 23:07:46.057
Python - how to send file from filesystem with a unicode filename?
So I am using Flask to serve some files. I recently downgraded the project from Python 3 to Python 2.7 so it would work with more extensions, and ran into a problem I did not have before. I am trying to serve a file from the filesystem with a Japanese filename, and when I try return send_from_directory(new_folder_path,...
OK, after wrestling with it under the hood for a while I fixed it, but not in a very elegant way, I had to modify the source of some werkzeug things. In "http.py", I replaced str(value) with unicode(value), and replaced every instance of "latin-1" with "utf-8" in both http.py and datastructures.py. It fixed the problem...
1.2
true
1
3,033
2014-02-12 01:36:33.403
Can serialized objects be accessed simultaneously by different processes, and how do they behave if so?
I have data that is best represented by a tree. Serializing the structure makes the most sense, because I don't want to sort it every time, and it would allow me to make persistent modifications to the data. On the other hand, this tree is going to be accessed from different processes on different machines, so I'm worr...
Without trying it out I'm fairly sure the answer is: They can both be served at once, however, if one user is reading while the other is writing the reading user may get strange results. Probably not. Once the tree has been read from the file into memory the other user will not see edits of the first user. If the tr...
1.2
true
1
3,034
2014-02-13 13:25:06.517
IPython notebook - unable to export to pdf
I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1....
ipython nbconvert notebook.ipynb --to pdf
0.067922
false
3
3,035
2014-02-13 13:25:06.517
IPython notebook - unable to export to pdf
I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1....
I was facing the same problem. I tried to use the option select File --> Download as --> Pdf via LaTeX (.pdf) in the notebook but it did not worked for me(It is not working for me). I tried other options too still not working. I solved it by using the following very simple steps. I hope it will help you too: You can do...
0.067922
false
3
3,035
2014-02-13 13:25:06.517
IPython notebook - unable to export to pdf
I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1....
open terminal navigate to the directory of your notebook ipython nbconvert mynotebook.ipynb --to latex --post PDF
0.135221
false
3
3,035
2014-02-14 17:38:23.173
Display a file to the user with Python
I am trying to find a way to display a txt/csv file to the user of my Python script. Everytime I search how to do it, I keep finding information on how to open/read/write etc ... But I just want to display the file to the user. Thank you in advance for your help.
It really depends what you mean by "display" the file. When we display text, we need to take the file, get all of its text, and put it onto the screen. One possible display would be to read every line and print them. There are certainly others. You're going to have to open the file and read the lines in order to displa...
0.201295
false
1
3,036
2014-02-14 20:01:14.333
wxpython GUI program to exe using py2exe
I am new to python programming and development. After much self study through online tutorials I have been able to make a GUI with wxpython. This GUI interacts with a access database in my computer to load list of teams and employees into the comboboxes. Now my first question is while converting the whole program into...
The console could possibly appear if you used the 'console' parameter to setup(). Switch to 'windows' instead if that is the case. Can't say for sure without seeing your setup.py script. Possibly your app could also be opening console, but again hard to say without seeing source. One thing to check is to make sure you ...
1.2
true
1
3,037
2014-02-14 22:43:47.667
filter pandas dataframe for timedeltas
I got a pandas dataframe, containing timestamps 'expiration' and 'date'. I want to filter for rows with a certain maximum delta between expiration and date. When doing fr.expiration - fr.date I obtain timedelta values, but don't know how to get a filter criteria such as fr[timedelta(fr.expiration-fr.date)<=60days]
for the 60 days you're looking to compare to, create a timedelta object of that value timedelta(days=60) and use that for the filter. and if you're already getting timedelta objects from the subtraction, recasting it to a timedelta seems unnecessary. and finally, make sure you check the signs of the timedeltas you're c...
0.545705
false
1
3,038
2014-02-14 23:57:26.587
Python development on Mac OS X: pure Mac OS or linux in virtualbox
I'm new to Mac, and I have OS X 10.9.1. The main question is whether it is better to create a virtual machine with Linux and do port forwarding or set all packages directly to the Mac OS and work with it directly? If I create a virtual machine, I'm not sure how it will affect the health of SSD and ease of development. ...
On my Mac, I use Python and PyCharm and all the usual Unix tools, and I've always done just fine. Regard OS X as a Unix machine with a very nice GUI on top of it, because it basically is -- Mac OS X is POSIX-compliant, with BSD underpinnings. Why would you even consider doing VirtualBox'd Linux? Even if you don't want ...
1.2
true
2
3,039
2014-02-14 23:57:26.587
Python development on Mac OS X: pure Mac OS or linux in virtualbox
I'm new to Mac, and I have OS X 10.9.1. The main question is whether it is better to create a virtual machine with Linux and do port forwarding or set all packages directly to the Mac OS and work with it directly? If I create a virtual machine, I'm not sure how it will affect the health of SSD and ease of development. ...
I do all of my main development on OSX. I deploy on a linux box. Pycharm (CE) is your friend.
0.386912
false
2
3,039
2014-02-15 20:07:20.453
Computing K-means clustering on Location data in Python
I have a dataset of users and their music plays, with every play having location data. For every user i want to cluster their plays to see if they play music in given locations. I plan on using the sci-kit learn k-means package, but how do I get this to work with location data, as opposed to its default, euclidean dist...
Is the data already in vector space e.g. gps coordinates? If so you can cluster on it directly, lat and lon are close enough to x and y that it shouldn't matter much. If not, preprocessing will have to be applied to convert it to a vector space format (table lookup of locations to coords for instance). Euclidean distan...
0.386912
false
2
3,040
2014-02-15 20:07:20.453
Computing K-means clustering on Location data in Python
I have a dataset of users and their music plays, with every play having location data. For every user i want to cluster their plays to see if they play music in given locations. I plan on using the sci-kit learn k-means package, but how do I get this to work with location data, as opposed to its default, euclidean dist...
Don't use k-means with anything other than Euclidean distance. K-means is not designed to work with other distance metrics (see k-medians for Manhattan distance, k-medoids aka. PAM for arbitrary other distance functions). The concept of k-means is variance minimization. And variance is essentially the same as squared E...
1.2
true
2
3,040
2014-02-16 21:47:12.213
Is there a way to find out why a python program closed?
Is there a way to programmatically find out why a Python program closed? I'm making a game in python, and I've been using the built in open() function to create a log in a .txt file. A major problem I've come across is that when it occasionally crashes, the log doesn't realise it's crashed. I've managed to record if t...
A few tips: use try catch wherever possible. Even if it crashes, stack trace will tell which line was last executed.
0.265586
false
1
3,041
2014-02-18 07:32:52.633
How to select a span element which is a list box ,when multiple span elements with same class ID are present in the same page?
I am using robot framework to test a GUI application , I need to select a span element which is a list box , but I have multiple span elements with same class ID in the same page , So how can I select each span element(list box) ??? Thanks in advance
Selenium provides various ways to locate elements in the page. If you can't use id, consider using CSS or Xpath.
0
false
2
3,042
2014-02-18 07:32:52.633
How to select a span element which is a list box ,when multiple span elements with same class ID are present in the same page?
I am using robot framework to test a GUI application , I need to select a span element which is a list box , but I have multiple span elements with same class ID in the same page , So how can I select each span element(list box) ??? Thanks in advance
Could you please provide a part of your code you use to get the span element and a part of your GUI application where you are trying to get the element from (HTML, or smth.)?
0
false
2
3,042
2014-02-18 11:34:40.377
call a method in Django admin site
i have a Django project and right now everything works fine. i have a Django admin site and now, i want that when i add a new record to my model, a function calls simultaneously and a process starts. how i can do this? what is this actions name?
1 WAY You can go to your models.py into your app by using django signal you can do this. from django.db.models.signals import post_save class Test(models.Model): # ... fields here # method for updating def update_on_test(sender, instance, **kwargs): # custome operation as you want to perform # registe...
0
false
1
3,043
2014-02-19 00:47:04.067
Flask request waiting for asynchronous background job
I have an HTTP API using Flask and in one particular operation clients use it to retrieve information obtained from a 3rd party API. The retrieval is done with a celery task. Usually, my approach would be to accept the client request for that information and return a 303 See Other response with an URI that can be polle...
Tornado would do the trick. Flask is not designed for asynchronization. A Flask instance processes one request at a time in one thread. Therefore, when you hold the connection, it will not proceed to next request.
0.386912
false
1
3,044
2014-02-19 10:37:12.457
Opening Notepad and saving using python
I am doing automation task in which I have to open notepad, write some contents and save that file. I know how to open and do keyboard simulation. Is there any way through which I can save that opened Notepad file through script
First check how to open notepad through command then use this command in subprocess or os.system. or use open() in os module which allow to open file.
0
false
1
3,045
2014-02-19 14:56:02.800
keyboard shortcut for toggling sessions of terminals in pycharm
I am recently started to use pycharm. Its embedded terminal is really cool. We can create multiple sessions of terminal using 'ctr+shift+t'. Also we can close sessions using 'ctrl+sht+w'. But how to toggle between these sessions? Is there any keyboard shortcut? Also where should I get list of all shortcuts? Thanks in a...
The shortcuts: Next Tab = 'Alt'+'Right' Previous Tab = 'Alt' + 'Left' While the cursor is in the Terminal. You can see all the shortcuts in the menu (and add more, or change, or delete): File -> Setting... -> [IDE Settings] Keymap
0.995055
false
1
3,046
2014-02-19 15:00:45.077
warning about too many open figures
In a script where I create many figures with fix, ax = plt.subplots(...), I get the warning RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (matplotlib.pyplot.figure) are retained until explicitly closed and may consume too much memory. However, I don't understand wh...
matplotlib by default keeps a reference of all the figures created through pyplot. If a single variable used for storing matplotlib figure (e.g "fig") is modified and rewritten without clearing the figure, all the plots are retained in RAM memory. Its important to use plt.cla() and plt.clf() instead of modifying and re...
0.058243
false
1
3,047
2014-02-19 16:03:43.090
Custom jinja2 tag in sphinx template
I'd like to implement custom navigation to my sphinx docs. I use my custom theme based on basic sphinx theme. But I don't know how to create new tag for template system or use my custom sphinx plugin's directive in html templates. Any ideas where I can plug in? Update As I can see in sphinx sources, jinja2 environment ...
I've found a good way to do this. Sphinx's configuration parameter template_bridge allows to control over TemplateBribge object - which is responsible for themes rendering. Standard sphinx.jinja2glue.TemplateBridge constructs environment attribute in init method (it's not a constructor, unfortunate name for method) - w...
1.2
true
1
3,048
2014-02-19 19:54:45.577
OpenShift, Python Application run script every 10 min
How to create shedule on OpenShift hosting to run python script that parses RSS feeds and will send filtered information to my email? It feature is available? Please help, who works with free version of this hosting. I have script that works fine. But i dont know how to run it every 10 min to catch freelance jobs. Or a...
You are looking for the add-on cartridge that is called cron. However, by default the cron cartridge only supports jobs that run every minute or every hour. You would have to write a job that runs minutely to determine if its a 10 minute interval and then execute your script. Make sense? rhc cartridge add cron -a you...
1.2
true
1
3,049
2014-02-19 22:28:33.147
SciPy - Constrained Minimization derived from a Directed Graph
I'm looking for a solution to the following graph problem in order to perform graph analysis in Python. Basically, I have a directed graph of N nodes where I know the following: The sum of the weights of the out-edges for each node The sum of the weights of the in-edges for each node Following from the above, the sum...
The prohibition against self-flows makes some instances of this problem infeasible (e.g., one node that has in- and out-flows of 1). Otherwise, a reasonably sparse solution with at most one self-flow always can be found as follows. Initialize two queues, one for the nodes with positive out-flow from lowest ID to highes...
0
false
1
3,050
2014-02-20 20:23:51.020
How to label certain x values
I want to plot weather data over the span of several days every half hour, but I only want to label the days at the start as a string in the format 'mm/dd/yy'. I want to leave the rest unmarked. I would also want to control where such markings are placed along the x axis, and control the range of the axis. I also want ...
You can use a DayLocator as in: plt.gca().xaxis.set_major_locator(dt.DayLocator()) And DateFormatter as in: plt.gca().xaxis.set_major_formatter(dt.DateFormatter("%d/%m/%Y")) Note: import matplotlib.dates as dt
0.265586
false
2
3,051
2014-02-20 20:23:51.020
How to label certain x values
I want to plot weather data over the span of several days every half hour, but I only want to label the days at the start as a string in the format 'mm/dd/yy'. I want to leave the rest unmarked. I would also want to control where such markings are placed along the x axis, and control the range of the axis. I also want ...
Matplotlib xticks are your friend. Will allow you to set where the ticks appear. As for date formatting, make sure you're using dateutil objects, and you'll be able to handle the formatting.
0.135221
false
2
3,051
2014-02-21 00:56:51.697
Reading values over ssh in python
I would like to be able to gather the values for number of CPUs on a server and stuff like storage space etc and assign them to local variables in a python script. I have paramiko set up, so I can SSH to remote Linux nodes and run arbitrary commands on them, and then have the output returned to the script. However, man...
If you can put your own programs or scripts on the remote machine there are a couple of things you can do: Write a script on the remote machine that outputs just what you want, and execute that over ssh. Use ssh to tunnel a port on the other machine and communicate with a server on the remote machine which will respon...
0
false
1
3,052
2014-02-21 14:25:25.860
Whats the smartest way to password protect an entire Django site for testing purposes
Here is the deal, how do I put the simplest password protection on an entire site. I simply want to open the site to beta testing but don't really care about elegance - just a dirty way of giving test users a username and password without recourse to anything complex and ideally i'd like to not to have to install any c...
Why you do not do simple form on index page when user is not authenticated?
0
false
1
3,053
2014-02-23 11:14:44.557
Xtext integration with Python
I am new to DSL area and I am developing a DSL language. I will need to provide an editor to write the in that language what makes Xtext a very good option. However, some of my libraries are in Python and I need to "run" the DSL in python. Any idea how to integrate them? the perfect scenario would be: Xtext -> Pass the...
Well, I think the answer is quite simple: I can generate the code in a XML or pyconf format and read from python :) thank you anyway
0
false
1
3,054
2014-02-23 19:19:52.437
Using SWIG to interface large C-project with Python
I want to access some functions from a large C-project from Python. It seems to me that SWIG is the way to go. I'm not very used to programming i C and my experience with "make" is mostly from downloading source tars. The functions I want to access resides in a large C-project (Gnuplot) and I have no idea who to use SW...
You should start by reading the first few chapters of swig manual, and making some of its example projects for python, the distrib has many that illustrate many different capabilities of swig and the make files are already built so one less thing to learn.
0
false
1
3,055
2014-02-23 21:45:12.040
Is it practical to have both Python 2.7 and 3.3 installed at the same time?
I am using pip to pull down libraries but didnt realize the key one is only for 2.7. So now I am working in the 2.7 directory but pip is still installing libs in 3.3. So pyCharm keeps saying the lib is missing. I have the PATH var set (this is gasp fn windows 8) so that Python 2.7 comes first but i think the python e...
Try these two solutions: 1)Remove python3.3 from the path variable and try installing library using pip now. so that pip from python27 can install things. 2)if this doesn't work then use C:\python27\Scripts\pip.exe install
1.2
true
1
3,056
2014-02-25 11:59:33.973
how to do authentication of rest api from javascript, if javascript is on third party site?
I have a javascript placed on third party site and this js makes API calls to my server. JS is publicly available and third party cannot save credentials in JS. I want to authenticate API calls before sharing JSON and also want to rate limit. Any one has ideas on how can i authenticate API?
It all depends on what you're authenticating. If you're authenticating each user that uses your API, you have to do something like the following: Your site has to somehow drop a cookie in that user's browser, Your API needs to support CORS (we use easyXDM.js), somehow upon logging in to their site, their site needs t...
0
false
1
3,057