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 |
|---|---|---|---|---|---|---|---|
2016-03-29 23:51:30.767 | can i use django to access folders on my pc using same os.path for windows? | I have a python algorithm that access a huge database in my laptop. I want to create a web server to work with it. can I use django with the folder paths I have used ? like how do I communicate with it ? I want to get an image from web application and get it sent to my laptop and run algorithm on it then send result ba... | I have found out that django works fine with os.path and no problems. actually if you are programming with python then django is a great choice for server work. | 1.2 | true | 1 | 4,247 |
2016-03-30 16:14:41.527 | Kivy TextInput how to combine hint_text and focus | Hi i noticed that whenever you have the focus property of a textinput widget set to True,
the hint_text is not displayed when the textinput is actually in focus.
Please is there a way to combine them both, i.e the hint_text gets displayed even when the text input is in focus? | This is an issue with Kivy 1.9.1, where the hint text disappears as soon as the TextInput is focused. It has been fixed in the development branch, and now only disappears when there is content in the field. | 1.2 | true | 1 | 4,248 |
2016-03-31 19:18:04.977 | How to Enable Scrolling for Python Console Application | I have a Python (2.7) console application that I have written on Windows (8.1). I have used argparse.ArgumentParser() for handling the parameters when executing the program.
The application has quite a few parameters, so when the --help parameter is used the documentation greatly exceeds the size of the console window... | You can not do it from you python script (OK, it is possible, but most probably you don't want to do it). Scrolling depends on environment (Windows or Linux terminal, doesn't matter). So it is up to users to set it up in a way that is good for them.
On Linux you can use less or more:
python script.py | less
it will b... | 0 | false | 1 | 4,249 |
2016-03-31 20:46:10.097 | Python exit from all function and stop the execution | I'm trying to develop a script that will connect to our switch and do some tasks.
In this script I have a main function that calls a second function. In the second function I pass a list of switches that Python will start to connect one by one.
The second function will call a third function. In the third function the s... | Thanks for your reply.
I already tried use sys.exit, raise and others into the third funcion but nothing works. What I did, I put a return with stantement pass or fail. On the secund function I test the return and if fail the script execute sys.exit(). When I do this on the secund function the script stop like we want.... | 0.135221 | false | 1 | 4,250 |
2016-04-01 09:04:06.813 | Getting portfolio names and existing orders using Interactive Brokers IBPy | I've been experimenting with IBPy for a while; however, the two following things have been eluding me:
a) How does one the name of the actual portfolios that positions belong to? I know how to find positions, their costs, values etc. (using message.UpdatePortfolio), but out trading simulation will likely have many port... | a) As far as I know, IB API has no concept of 'Portfolio'. You probably need to keep a list of orders put in for which portfolio and then resolve the order data supplied by IB against your portfolio vs order data.
b) IB does keep track of the client (i.e. your client that is calling the API code - normally defaulted to... | 0 | false | 1 | 4,251 |
2016-04-01 18:34:12.783 | spark python product top 5 numbers from a file | total noob question. I have a file that contains a number on each line, there are approximately 5 millions rows, each row has a different number, how do i find the top 5 values in the file using spark and python. | You distribute the data you read among nodes.
Every node finds it's 5 local maximums.
You combine all the local maximums and you keep the 5 max of them,
which is the answer. | 0.386912 | false | 1 | 4,252 |
2016-04-03 04:10:21.570 | Swapping pairs of characters in a string | Okay, I'm really new to Python and have no idea how to do this:
I need to take a string, say 'ABAB__AB', convert it to a list, and then take the leading index of the pair I want to move and swap that pair with the __. I think the output should look something like this:
move_chars('ABAB__AB', 0)
'__ABABAB'
and another e... | I think this should go to the comment section, but I can't comment because of lack of reputation, so...
You'll probably want to stick with list index swapping, rather than using .pop() and .append(). .pop() can remove elements from arbitrary index, but only one at once, and .append() can only add to the end of the list... | 0 | false | 1 | 4,253 |
2016-04-03 14:16:44.447 | Estimated Cost field is missing in Appengine's new Developer Console | In the old (non-Ajax) Google Appengine's Developer Console Dashboard - showed estimated cost for the last 'n' hours. This was useful to quickly tell how the App engine is doing vis-a-vis the daily budget.
This field seems to be missing in the new Appengine Developer Console. I have tried to search various tabs on the C... | App Engine > Dashboard
This view shows how much you are charged so far during the current billing day, and how many hours you still have until the reset of the day. This is equivalent to what the old console was showing, except there is no "total" line under all charges.
App Engine > Quotas
This view shows how much of ... | 0.386912 | false | 1 | 4,254 |
2016-04-03 17:51:36.013 | Python how to find which class owns a variable | Can anyone tell me, whether there is a way to find which class a member variable belongs to, using the variable.
I am trying to create a decorator that will allow only member method and variables of certain classes be used as method parameter.
like
@acceptmemberofclass(class1,class2)
def method(memberfunc, membervar... | To my knowledge, there's no "cheap trick" you'll have to have all your class elements and compare their variable values with what you have . (Couldn't comment, sry) At least from what I understand you're trying to achieve, the question isn't very well constructed. | 0 | false | 1 | 4,255 |
2016-04-04 19:00:43.177 | Can the model object for a learner be exported with joblib? | I'm evaluating orange as a potential solution to helping new entrants into data science to get started. I would like to have them save out model objects created from different algorithms as pkl files similar to how it is done in scikit-learn with joblib or pickle. | I don't understand what "exported with joblib" refers to, but you can save trained Orange models by pickling them, or with Save Classifier widget if you are using the GUI. | 0 | false | 1 | 4,256 |
2016-04-06 08:42:42.097 | using os.system() to run a command without root | I have a python 2 script that is run as root. I want to use os.system("some bash command") without root privileges, how do I go about this? | Try to use os.seteuid(some_user_id) before os.system("some bash command"). | 1.2 | true | 2 | 4,257 |
2016-04-06 08:42:42.097 | using os.system() to run a command without root | I have a python 2 script that is run as root. I want to use os.system("some bash command") without root privileges, how do I go about this? | I have test on my PC. If you run the python script like 'sudo test.py' and the question is resolved. | -0.201295 | false | 2 | 4,257 |
2016-04-06 16:10:40.700 | How to download pygame for non default version of python | I am running El Capitan, when I type python --version the terminal prints Python 2.7.10, I have successfully downloaded pygame for Python 2.7.10 but I want to develop in python 3.5.1, I know I can do this by entering python3 in the terminal, but how do I properly set up pygame for this version of python? | Use python3.5 -mpip install pygame. | 0.386912 | false | 1 | 4,258 |
2016-04-06 21:41:33.940 | how to use --patterns for tests in django | I have a test file with tests in it which will not be called with the regular
manage.py test
command, only when I specifically tell django to do so.
So my file lives in the same folder as tests.py and its name is test_blub.py
I tried it with
manage.py test --pattern="test_*.py"
Any idea? | Ok, so the key is quite simple, the file is not supposed to start with test.
I named it blub_test.py and then called it with
./manage.py test --pattern="blub_test.py" | 1.2 | true | 1 | 4,259 |
2016-04-07 10:23:32.997 | Parse python module installtion for python 2.7 | Can somebody let me know how to install python "parse" module for python2.7 version?
Server details :
CloudLinux Server release 5.11
cPanel 54.0 (build 21) | If you have pip installed, try to run pip install parse as root. | 0.386912 | false | 1 | 4,260 |
2016-04-07 19:25:26.543 | How to serve Beaker Notebook from different directory | Trying to experiment with Beaker Notebooks, but I can not figure out how to launch from a specified directory. I've downloaded the .zip file (I'm on Windows 10), and can launch from that directory using the beaker.command batch file, but cannot figure out where to configure or set a separate launch directory for a spec... | If you want to change the current working directory, I don't think that's possible.
But if you want to serve files as in make them available to the web server that creates the page, use ~/.beaker/v1/web as described in the "Generating and accessing web content" tutorial. | 0 | false | 1 | 4,261 |
2016-04-08 01:40:10.393 | How to get twitter user's location with tweepy? | I am starting to make a python program to get user locations, I've never worked with the twitter API and I've looked at the documentation but I don't understand much. I'm using tweepy, can anyone tell me how I can do this? I've got the basics down, I found a project on github on how to download a user's tweets and I un... | Once you have a tweet, the tweet includes a user, which belongs to the user model. To call the location just do the following
tweet.user.location | 0.265586 | false | 1 | 4,262 |
2016-04-11 14:48:34.833 | Properly formatting numbers in pygal | I'm using Pygal (with Python / Flask) relatively successfully in regards to loading data, formatting colors, min/max, etc., but can't figure out how to format a number in Pygal using dollar signs and commas.
I'm getting 265763.557372895 and instead want $265,763.
This goes for both the pop-up boxes when hovering over... | graph.value_formatter = lambda y: "{:,}".format(y) will get you the commas.
graph.value_formatter = lambda y: "${:,}".format(y) will get you the commas and the dollar sign.
Note that this formatting seems to be valid for Python 2.7 but would not work on 2.6. | 1.2 | true | 1 | 4,263 |
2016-04-12 14:23:27.807 | Paramiko get stdout from connection object (not exec_command) | I'm writing a script that uses paramiko to ssh onto several remote hosts and run a few checks. Some hosts are setup as fail-overs for others and I can't determine which is in use until I try to connect. Upon connecting to one of these 'inactive' hosts the host will inform me that you need to connect to another 'active'... | I figured out a way to get the data, it was pretty straight forward to be honest, albeit a little hackish. This might not work in other cases, especially if there is latency, but I could also be misunderstanding what's happening:
When the connection opens, the server spits out two messages, one saying it can't chdir to... | 1.2 | true | 1 | 4,264 |
2016-04-13 09:02:27.563 | How to collect data from multiple threads in the parent process with ZeroMQ while keeping the solution both as simple & as scaleable as possible? | The parent process launches a few tens of threads that receive data (up to few KB, 10 requests per second), which has to be collected in a list in the parent process. What is the recommended way to achieve this, which is efficient, asynchronous, non-blocking, and simpler to implement with least overhead?
The ZeroMQ gui... | There is no dinner for free
even if some marketing blable offers that, do not take it for granted.
Efficient means usually a complex resources handling.
Simplest to implement usually fights with overheads & efficient resources handling.
Simplest?
Using sir Henry FORD's point of view, a component, that is not present i... | 1.2 | true | 1 | 4,265 |
2016-04-15 09:49:11.437 | Creating Simple Password Check In wxPython | I want to add a simple password check to a Python/wxPython/MySQL application to confirm that the user wants to carry out a particular action. So far I have a DialogBox with a textCtrl for password input and Buttons for Submit or Cancel. At the moment the password appears in the textCtrl. I would prefer this to appear a... | Set the style on the text ctrl as
TE_PASSWORD: The text will be echoed as asterisks. | 1.2 | true | 1 | 4,266 |
2016-04-15 10:46:44.123 | Django app deployment on shared hosting | I am trying to deploy a django app on hostgator shared hosting. I followed the hostgator django installation wiki and i deployed my app. The issue is that i am getting a 500 error internal page when entering the site url in the browser. I contacted the support team but could not provide enough info on troubleshooting t... | I know this is a while as to when i asked the question. I finally fixed this by changing the hosts. I went for Digital Oceans (created a new droplet) which supports wsgi. I deployed the app using gunicorn (application server) and nginx (proxy server).
It is not a good idea to deploy a Django app on shared hosting as yo... | 1.2 | true | 2 | 4,267 |
2016-04-15 10:46:44.123 | Django app deployment on shared hosting | I am trying to deploy a django app on hostgator shared hosting. I followed the hostgator django installation wiki and i deployed my app. The issue is that i am getting a 500 error internal page when entering the site url in the browser. I contacted the support team but could not provide enough info on troubleshooting t... | As you say, Django 1.9 does not support FastCGI.
You could try using Django 1.8, which is a long term support release and does still support FastCGI.
Or you could switch to a different host that supports deploying Django 1.9 with wsgi. | 0 | false | 2 | 4,267 |
2016-04-16 20:42:54.060 | Streaming values in a python script to a wep app | I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App.
I don't know how to proceed to link the WebJob to the web app.
Any ideas ? | You have two main options:
You can have the WebJobs write the values to a database or to Azure Storage (e.g. a queue), and have the Web App read them from there.
Or if the WebJob and App are in the same Web App, you can use the file system. e.g. have the WebJob write things into %home%\data\SomeFolderYouChoose, and hav... | 1.2 | true | 2 | 4,268 |
2016-04-16 20:42:54.060 | Streaming values in a python script to a wep app | I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App.
I don't know how to proceed to link the WebJob to the web app.
Any ideas ? | You would need to provide some more information about what kind of interface your web app exposes. Does it only handle normal HTTP1 requests or does it have a web socket or HTTP2 type interface? If it has only HTTP1 requests that it can handle then you just need to make multiple requests or try and do long polling. Oth... | 0 | false | 2 | 4,268 |
2016-04-18 07:35:32.550 | similarity measure scikit-learn document classification | I am doing some work in document classification with scikit-learn. For this purpose, I represent my documents in a tf-idf matrix and feed a Random Forest classifier with this information, works perfectly well. I was just wondering which similarity measure is used by the classifier (cosine, euclidean, etc.) and how I ca... | As with most supervised learning algorithms, Random Forest Classifiers do not use a similarity measure, they work directly on the feature supplied to them. So decision trees are built based on the terms in your tf-idf vectors.
If you want to use similarity then you will have to compute a similarity matrix for your docu... | 1.2 | true | 1 | 4,269 |
2016-04-18 13:10:26.657 | Burlap java server to work with python client | I'm trying to connect a burlap java server with a python client but I can't find any detail whatsoever regarding how to use burlap with python or if it even is implemented for python. Any ideas? Can I build burlap python clients? Any resources? Would using a hessian python client work with a java burlap server? | Burlap and Hessian are 2 different (but related) RPC protocols, with Burlap being XML based and Hessian being binary.
They're both also pretty ancient, so if you have an opportunity to use something else, I'd highly recommend it. If not, then you're going to have to find a Burlap lib for Python.
Since it seems that a B... | 1.2 | true | 1 | 4,270 |
2016-04-19 11:56:38.960 | Passing an image from Lambda to API Gateway | I have a lambdas function that resizes and image, stores it back into S3. However I want to pass this image to my API to be returned to the client.
Is there a way to return a png image to the API gateway, and if so how can this be done? | You could return it base64-encoded... | 0 | false | 2 | 4,271 |
2016-04-19 11:56:38.960 | Passing an image from Lambda to API Gateway | I have a lambdas function that resizes and image, stores it back into S3. However I want to pass this image to my API to be returned to the client.
Is there a way to return a png image to the API gateway, and if so how can this be done? | API Gateway does not currently support passing through binary data either as part of a request nor as part of a response. This feature request is on our backlog and is prioritized fairly high. | 0 | false | 2 | 4,271 |
2016-04-19 15:31:31.727 | theano g++ not detected | I installed theano but when I try to use it I got this error:
WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute
optimized C-implementations (for both CPU and GPU) and will default to Python
implementations. Performance will be severely degraded.
I installed g++, and put the c... | This is the error that I experienced in my mac running jupyter notebook with a python 3.5 kernal hope this helps someone, i am sure rggir is well sorted at this stage :)
Error
Using Theano backend.
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for bot... | 0.201295 | false | 3 | 4,272 |
2016-04-19 15:31:31.727 | theano g++ not detected | I installed theano but when I try to use it I got this error:
WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute
optimized C-implementations (for both CPU and GPU) and will default to Python
implementations. Performance will be severely degraded.
I installed g++, and put the c... | On Windows, you need to install mingw to support g++. Usually, it is advisable to use Anaconda distribution to install Python. Theano works with Python3.4 or older versions. You can use conda install command to install mingw. | 0.386912 | false | 3 | 4,272 |
2016-04-19 15:31:31.727 | theano g++ not detected | I installed theano but when I try to use it I got this error:
WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute
optimized C-implementations (for both CPU and GPU) and will default to Python
implementations. Performance will be severely degraded.
I installed g++, and put the c... | I had this occur on OS X after I updated XCode (through the App Store). Everything worked before the update, but after the update I had to start XCode and accept the license agreement. Then everything worked again. | 0.443188 | false | 3 | 4,272 |
2016-04-21 03:24:27.110 | tensorflow sequence to sequence without softmax | I was using Tensorflow sequence to sequence example code. for some reason, I don't want to add softmax to output. instead, I want to get the raw output of decoder without softmax. I was wondering if anyone know how to do it based on sequence to sequence example code? Or I need to create it from scratch or modify the th... | The model_with_buckets() function in seq2seq.py returns 2 tensors: the output and the losses. The outputs variable contains the raw output of the decoder that you're looking for (that would normally be fed to the softmax). | 1.2 | true | 1 | 4,273 |
2016-04-21 20:12:29.323 | remove known exact row in huge csv | I have a ~220 million row, 7 column csv file. I need to remove row 2636759.
This file is 7.7GB, more than will fit in memory. I'm most familiar with R, but could also do this in python or bash.
I can't read or write this file in one operation. What is the best way to build this file incrementally on disk, instead of tr... | use sed '2636759d' file.csv > fixedfile.csv
As a test for a 40,001 line 1.3G csv, removing line 40,000 this way takes 0m35.710s. The guts of the python solution from @en_Knight (just stripping the line and writing to a temp file) is ~ 2 seconds faster for this same file.
edit OK sed (or some implementations) may not wo... | 0.265586 | false | 1 | 4,274 |
2016-04-24 14:17:56.130 | Running python from notepad in cmd | I am trying to run a python program
import random
random.random()
Written in notepad in two different lines,I want to run it in cmd.how to do it? | Save the program with a .py extention. For example: hello.py
Then run it with python <script_name>.py. For example: python hello.py | 0.386912 | false | 1 | 4,275 |
2016-04-25 04:08:33.570 | How to make Python executable pause when it raises an error? | So I know I can make Python executable using pyinstaller.
However, every time it raises an error, it will instantly end the program, so I can't find what is the error.
I know I probably can use time.sleep(30000) to stop it.
But if the code raises error before it meets time.sleep(30000), it will just shut down.
To sum u... | Instead of just double-clicking the file, run it from the command line. A terminal window that your program automatically created will also be automatically closed when the program ends, but if you open a terminal yourself and run the program from the command line, it won't touch the open terminal and you can read the ... | 0 | false | 1 | 4,276 |
2016-04-25 09:04:03.517 | How to modify a pyramid template on the fly before rendering | please I am working on a site where I would scrap another website's html table source code and append it to my template before rendering my page.
I have written the script which stores the html code in a variable but don't know how to appendix it.
Kindly suggest. | If you're using jinja, try this:
<div class="html-content">{{scraped_html|safe}}</div> | 0 | false | 1 | 4,277 |
2016-04-26 08:49:07.410 | How to extract the frequencies associated with fft2 values in numpy? | I know that for fft.fft, I can use fft.fftfreq. But there seems to be no such thing as fft.fftfreq2. Can I somehow use fft.fftfreq to calculate the frequencies in 2 dimensions, possibly with meshgrid? Or is there some other way? | Yes. Apply fftfreq to each spatial vector (x and y) separately. Then create a meshgrid from those frequency vectors.
Note that you need to use fftshift if you want the typical representation (zero frequencies in center of spatial spectrum) to both the output and your new spatial frequencies (before using meshgrid). | 1.2 | true | 1 | 4,278 |
2016-04-26 09:51:56.857 | Securing OTP API at code level or Nginx level? | Scenario :
I have an OTP generation API. As of now , if I do POST with contact number in body, it will be generating OTP code irrespective of how many times, it gets invoked by same ip. There is no security at code level and nginx level.
Suggestions are accepted whether blocking IP should be done at code level or Ngi... | You really should move away from using the IP as the restriction. Not only can the IP be changed allowing for an intermediary to replay the OTP.
A combination of the visiting IP along with additional unique vectors would serve as a better method of identifying the visitor and associating the OTP with their access.
Beca... | 0 | false | 1 | 4,279 |
2016-04-26 15:23:37.423 | How to use Graphviz with Anaconda/Spyder? | I am attempting to use Graphviz from Spyder (via an Anaconda install). I am having trouble understanding what is needed to do this and how to go about loading packages, setting variables, etc.
I straight forward approach for a new Python and Graphviz and Spyder user would be great!
Also, apart from just creating and ru... | Open Anaconda Prompt
Run-> "conda install python-graphviz" in anaconda prompt.
After install graphviz then copy the directory:
C:\Users\Admin\anaconda3\Library\bin\graphviz
Open Control Panel\System\Advanced system settings
Enviornment variables\path\Edit\New
Paste that copied directory and then click Ok | 0.386912 | false | 1 | 4,280 |
2016-04-27 07:53:20.370 | How do you work with big array in python? | I need to create a big array in python from Sqlite database. It's size is 1000_000_000*1000_000_000 and each item is one or zero. Actually, my computer can't store in RAM this volume of information. Maybe someone have idea how to work in this situation? Maybe store these vectors in database or there is some framework ... | I also work with really big datasets (complete genomes or all possible gene combinations) and i store these in a zipped database with pickle. this way it is ram efficient and uses a lot less hard disk memory.
I suggest you try that. | 0 | false | 1 | 4,281 |
2016-04-27 08:12:08.297 | If "a is not b" how to know what is the difference? | Two items may be unequal in many ways. Can python tell what is the reason?
For example: 5 is not 6, int(5) is not float(5), "5" is not "5 ", ...
Edit: I did not ask what kinds of equality test there are, but why and how those are not equal. I think my question is not duplicate. | is checks if the two items are the exact same object. This check identity
== checks if the two objects are equal values
You use is not None to make sure that the object the "real" none and not just false-y. | 0 | false | 1 | 4,282 |
2016-04-27 15:24:24.217 | How to get a normal distribution within a range in numpy? | In machine learning task. We should get a group of random w.r.t normal distribution with bound. We can get a normal distribution number with np.random.normal() but it does't offer any bound parameter. I want to know how to do that? | You can subdivide your targeted range (by convention) to equal partitions and then calculate the integration of each and all area, then call uniform method on each partition according to the surface.
It's implemented in python:
quad_vec(eval('scipy.stats.norm.pdf'), 1, 4,points=[0.5,2.5,3,4],full_output=True) | 0 | false | 1 | 4,283 |
2016-04-27 22:01:14.750 | Most effective way to run execute API calls | I am 'kind of' new to programming and must have searched a large chunk of the web in connection with this question. I am sure the answer is somewhere out there but I am probably simply not using the right terminology to find it. Nevertheless, I did my best and I am totally stuck. I hope people here understand the feeli... | You don't mention what server side language you're using, but the concepts would be the same for all - make your query to get your 200K variables, loop through the result set, making the curl call to the API for each, store the results in an array, json encode the array at the end of the loop, and then dump the result ... | 1.2 | true | 1 | 4,284 |
2016-04-28 05:16:14.507 | Clickable website URL | I know writing print "website url" does not provide a clickable url. So is it possible to get a clickable URL in python, which would take you directly to that website? And if so, how can it be done? | This is typically a function of the terminal that you're using.
In iterm2, you can click links by pressing cmd+alt+left click.
In gnome-terminal, you can click links by pressting ctrl+left click or right clicking and open link. | 0 | false | 1 | 4,285 |
2016-04-28 10:21:57.880 | define the best possible move (AI - game) | I do not see too how I could set this:
I must code a small IA for asymmetric board game for 2 players. Each turn each player has a number of action points to use to move their pieces on the board (10x10).
For now I know how to generate the list of possible moves for each pawn based on the number of given action point b... | You need to assign score (evaluation) to each move based on the rules of the game. When you choose appropriate scoring method you can evaluate which out of 5 possible actions is the best one.
As an example let's assume simple game where you must take all opponents pawns by placing your pawn on top of theirs (checkers w... | 0 | false | 1 | 4,286 |
2016-04-28 17:46:56.003 | How to create a .pyd file? | I'm creating a project that uses Python OpenCV. My image processing is a bit slow, so I thought I can made the code faster by creating a .pyd file (I read that somewhere).
I am able to create a .c file using Cython, but how to make a .pyd? While they are a kind of .dll, should I make a .dll first and convert it? And I ... | If you try to find your answer using cython with Visual Studio to convert python code into pyd( Python Dynamic Module ) then, you will have a blurry answer. As, visual code that you expect to work might not due to compatibility issue with later versions. For instance, 1900, 1929 of msvc.
You will need to edit cygwin-co... | 0 | false | 1 | 4,287 |
2016-04-28 19:54:46.250 | Python: If Raw_Input Contains...BLAH | (I am new to Python and programming) I am using raw_input() so I can make a program that talks to the user. For example:
Program: How are you?
User: I am doing great!/I feel terrible.
I need my program to respond accordingly, as in "YAY!" or "Aw man... I hope you feel better soon." so can you please give me ways to sca... | Well I'm not sure of having a program understand the english language. It will only take a string literal as a string literal. "Good" does not mean Good or Bad to the Interpreter in Python.
What I'd suggest is making a dictionary of all of the good phrases you want, such as I'm good, Feelin' great, I'm A OK. You can s... | 0 | false | 1 | 4,288 |
2016-04-29 15:08:28.770 | How to implement EAV in Django | I need to implement a fairly standard entity-attribute-value hierarchy. There are devices of multiple types, each type has a bunch of settings it can have, each individual device has a set of particular values for each setting. It seems that both django-eav and eav-django packages are no longer maintained, so I guess I... | I am trying to answer,let me know, wheather we are on a same plane. I think, you need to formulate EAV database scema first. For that identify what are the entities,attributes, and the associated values. Here, in the example mentioned by you, entity maybe device and it's attribute maybe setting. If we take other exampl... | -0.201295 | false | 1 | 4,289 |
2016-04-29 19:40:16.647 | How to check if a git repo was updated without using a git command | TL;DR
I would like to be able to check if a git repo (located on a shared network) was updated without using a git command. I was thinking checking one of the files located in the .git folder to do so, but I can't find the best file to check. Anyone have a suggestion on how to achieve this?
Why:
The reason why I need t... | Check the .git/FETCH_HEAD for the time stamp and the content.
Every time you fetch content its updating the content and the modification time of the file. | 1.2 | true | 1 | 4,290 |
2016-04-30 15:03:39.333 | BlueZ DBUS API - GATT interfaces unavailable for BLE device | I have a BLE device which has a bunch of GATT services running on it. My goal is to access and read data from the service characteristics on this device from a Linux computer (BlueZ version is 5.37). I have enabled experimental mode - therefore, full GATT support should be available. BlueZ's DBUS API, however, only pro... | A system update resolved this problem. | 1.2 | true | 1 | 4,291 |
2016-04-30 17:14:53.743 | Trying to understand the pythonpath variable | What is the $PYTHONPATH variable, and what's the significance in setting it?
Also, if I want to know the content of my current pythonpath, how do I find that out? | PYTHONPATH is the default search path for importing modules. If you use bash, you could type echo $PYTHONPATH to look at it. | 0 | false | 1 | 4,292 |
2016-04-30 21:42:43.957 | Python: sort by date and time? | I have a list of objects that each contain a datetime.date() and a datetime.time() element. I know how to sort the array based on a single element using insertion sort, or any other sorting algorithm. However, how would I sort this list in chronological order using date AND time? | Use a tuple of (my_date, my_time) as the "single element" you're sorting on. You could build a datetime.datetime object from the two, but that seems unnecessary just to sort them.
This applies in general to any situation where you want a lexicographical comparison between multiple quantities. "Lexicographical" meaning,... | 1.2 | true | 1 | 4,293 |
2016-05-01 21:40:52.443 | Scaling a sequential program into chain of queues | I am trying to scale an export system that works in the following steps:
Fetch a large number of records from a MySQL database. Each record is a person with an address and a product they want.
Make an external API call to verify address information for each of them.
Make an internal API call to get store and price inf... | You should probably use a cache instead of a queue. | 0 | false | 2 | 4,294 |
2016-05-01 21:40:52.443 | Scaling a sequential program into chain of queues | I am trying to scale an export system that works in the following steps:
Fetch a large number of records from a MySQL database. Each record is a person with an address and a product they want.
Make an external API call to verify address information for each of them.
Make an internal API call to get store and price inf... | It looks like you can do the following:
Assigner
Reads from the assigner queue and assigns the proper ids
Packs the data in bulks and uploads them to S3.
Sends the path to S3 to the Dumper queue
Dumper reads the bulks and dumps them to DB in bulks | 0 | false | 2 | 4,294 |
2016-05-02 08:19:27.860 | Selenium Python, New Page | My main Question:
How do I switch pages?
I did some things on a page and than switch to another one,
how do I update the driver to be the current page? | With .get(url), just like you got to the first page. | 0.673066 | false | 1 | 4,295 |
2016-05-02 23:30:05.783 | How to include a directory of files with RST and Sphinx | I am trying to write documentation and want and have multiply files used by multiple toc trees. Previously I used an empty file with .. include:: <isonum.txt> however, this does not work for multiply files in a directory with sub directories. Another solution I have used was to use a relative file path to the index fil... | Perhaps indicate the start and end of the section where the files should go with a comment (.. START_GLOB_INCLUDE etc), and then have a build pre-process step that finds the files you want and rewrites that section of the master file. | 0 | false | 1 | 4,296 |
2016-05-03 10:51:56.777 | How to programmatically wrap a C++ dll with Python | I know how to use ctypes to call a function from a C++ .dll in Python by creating a "wrapper" function that casts the Python input types to C. I think of this as essentially recreating the function signatures in Python, where the function body contains the type cast to C and a corresponding .dll function call.
I curren... | I would recommend using Cython to do your wrapping. Cython allows you to use C/C++ code directly with very little changes (in addition to some boilerplate). For wrapping large libraries, it's often straightforward to get something up and running very quickly with minimal extra wrapping work (such as in Ctypes). It's al... | 1.2 | true | 1 | 4,297 |
2016-05-05 22:08:08.557 | Trouble with TensorFlow in Jupyter Notebook | I installed Jupyter notebooks in Ubuntu 14.04 via Anaconda earlier, and just now I installed TensorFlow. I would like TensorFlow to work regardless of whether I am working in a notebook or simply scripting. In my attempt to achieve this, I ended up installing TensorFlow twice, once using Anaconda, and once using pip. T... | Open an Anaconda Prompt screen: (base) C:\Users\YOU>conda create -n tf tensorflow
After the environment is created type: conda activate tf
Prompt moves to (tf) environment, that is: (tf) C:\Users\YOU>
then install Jupyter Notebook in this (tf) environment:
conda install -c conda-forge jupyterlab - jupyter notebook
St... | -0.029146 | false | 2 | 4,298 |
2016-05-05 22:08:08.557 | Trouble with TensorFlow in Jupyter Notebook | I installed Jupyter notebooks in Ubuntu 14.04 via Anaconda earlier, and just now I installed TensorFlow. I would like TensorFlow to work regardless of whether I am working in a notebook or simply scripting. In my attempt to achieve this, I ended up installing TensorFlow twice, once using Anaconda, and once using pip. T... | Here is what I did to enable tensorflow in Anaconda -> Jupyter.
Install Tensorflow using the instructions provided at
Go to /Users/username/anaconda/env and ensure Tensorflow is installed
Open the Anaconda navigator and go to "Environments" (located in the left navigation)
Select "All" in teh first drop down and sea... | 0.116092 | false | 2 | 4,298 |
2016-05-06 04:19:18.807 | Kivy ScrollView (with Gridview) Suffering Performance Issues | I have a GridView inside of a ScrollView. I am trying to create and display approximately ~12,000 items in the GridView (which clearly will not display appropriately on screen), but the number of items could feasible be ~40,000. Currently ~18 seconds are spent constructing all of the items (Labels), and any resizing of... | How can you imagine a user scrolling through 40000 labels? You should rethink your app design.
Consider adding a text input, and based on the given string, fetch filtered data from the database you have. | 0 | false | 1 | 4,299 |
2016-05-08 09:57:28.660 | Difference between Variable and get_variable in TensorFlow | As far as I know, Variable is the default operation for making a variable, and get_variable is mainly used for weight sharing.
On the one hand, there are some people suggesting using get_variable instead of the primitive Variable operation whenever you need a variable. On the other hand, I merely see any use of get_var... | I'd recommend to always use tf.get_variable(...) -- it will make it way easier to refactor your code if you need to share variables at any time, e.g. in a multi-gpu setting (see the multi-gpu CIFAR example). There is no downside to it.
Pure tf.Variable is lower-level; at some point tf.get_variable() did not exist so s... | 1.2 | true | 1 | 4,300 |
2016-05-09 19:31:48.917 | Installing Anaconda Python in a virtual world without changing global Python version | Good afternoon. I have been learning Virtualenv and Virtualenvwrapper. I then decided I wanted to install Anaconda Python again so I could continue learning how to do data analysis. Then I saw where you can use conda to make a virtual environment for Anaconda. I installed it and told it not to add the path to my bashrc... | fix your PATH environment variable so it has the global python directory declared before the anacaonda directory. | 1.2 | true | 1 | 4,301 |
2016-05-10 00:05:34.723 | Reset python path after Anaconda | I used IDLE for some time, then for a class they told us to download Anaconda, which I ended up not using, but still downloaded it anyway.
I uninstalled anaconda and deleted all the files from my CPU and started using IDLE again. I now can't import a module to IDLE because it can't find it. I think anaconda messed up ... | To add the python path for anaconda if you are on windows:
Right click my computer
Go to advanced settings
Click on environment variables
Find the PATH variable and click edit
Add the path where your python.exe file is located
Example:
C:\Anaconda3 - might not work
C:\Anaconda3 - then this should work
Same thing for... | 0 | false | 1 | 4,302 |
2016-05-12 04:31:23.890 | How to install pyzmq "--with-pgm" | I have zmq version 4.1.3 and pyzmq version 15.2.0 installed on my machine (I assume through pip but I dont remember now). I have a need to connect to a UDP epgm socket but get the error "protocol not supported". I have searched the vast expanses of the internet and have found the answer: "build zero mq with --with-pg... | Here is the general procedure which works for me:
1. download zeromq package (using zeromq-4.1.5.tar.gz as example)
2. tar zxvf zeromq-4.1.5.tar.gz
3. cd zeromq-4.1.5
4. apt-get install libpgm-dev
5. ./configure --with-pgm && make && make install
6. pip install --no-binary :all: pyzmq
Then you can use pgm/epgm as you w... | 0.386912 | false | 1 | 4,303 |
2016-05-12 06:10:48.683 | How to stop flask app.run()? | I made a flask app following flask's tutorial. After python flaskApp.py, how can I stop the app? I pressed ctrl + c in the terminal but I can still access the app through the browser. I'm wondering how to stop the app? Thanks.
I even rebooted the vps. After the vps is restated, the app still is running! | CTRL+C is the right way to quit the app, I do not think that you can visit the url after CTRL+C. In my environment it works well.
What is the terminal output after CTRL+C? Maybe you can add some details.
You can try to visit the url by curl to test if browser cache or anything related with browser cause this problem. | 0.265586 | false | 2 | 4,304 |
2016-05-12 06:10:48.683 | How to stop flask app.run()? | I made a flask app following flask's tutorial. After python flaskApp.py, how can I stop the app? I pressed ctrl + c in the terminal but I can still access the app through the browser. I'm wondering how to stop the app? Thanks.
I even rebooted the vps. After the vps is restated, the app still is running! | Have you tried pkill python?
WARNING: do not do so before consulting your system admin if are sharing a server with others. | 0.135221 | false | 2 | 4,304 |
2016-05-12 10:44:52.963 | Find out if/which BLAS library is used by Numpy | I use numpy and scipy in different environments (MacOS, Ubuntu, RedHat).
Usually I install numpy by using the package manager that is available (e.g., mac ports, apt, yum).
However, if you don't compile Numpy manually, how can you be sure that it uses a BLAS library? Using mac ports, ATLAS is installed as a dependency.... | numpy.show_config() just tells that info is not available on my Debian Linux.
However /usr/lib/python3/dist-packages/scipy/lib has a subdirectory for blas which may tell you what you want. There are a couple of test programs for BLAS in subdirectory tests.
Hope this helps. | 0.496174 | false | 1 | 4,305 |
2016-05-12 13:37:38.953 | Ubuntu, how to install OpenCV for python3? | I want to install OpenCV for python3 in ubuntu 16.04. Fist I tried running sudo apt-get install python3-opencv which is how I pretty much install all of my python software. This could not find a repository. The install does work however if I do sudo apt-get install python-opencv this issue with this is that by not a... | This is because you have multiple installations of python in your machine.You should make python3 the default, because by default is the python2.7 | 0.04532 | false | 1 | 4,306 |
2016-05-13 10:25:47.350 | Smart algorithm for finding the divisors of a binomial coefficient | I'm interested in tips for my algorithm that I use to find out the divisors of a very large number, more specifically "n over k" or C(n, k). The number itself can range very high, so it really needs to take time complexity into the 'equation' so to say.
The formula for n over k is n! / (k!(n-k)!) and I understand that... | First you could start with the fact that : C(n,k) = (n/k) C(n-1,k-1).
You can prouve that C(n,k) is divisible by n/gcd(n,k).
If n is prime then n divides C(n,k).
Check Kummer's theorem: if p is a prime number, n a positive number, and k a positive number with 0< k < n then the greatest exponent r for which p^r divides ... | 1.2 | true | 1 | 4,307 |
2016-05-13 20:43:09.917 | Windows: run python command from clickable icon | I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this? | A better way (in my opinion):
Create a shortcut:
Set the target to
%systemroot%\System32\cmd.exe /c "python C:\Users\MyUsername\Documents\MyScript.py"
Start In:
C:\Users\MyUsername\Documents\
Obviously change the path to the location of your script. May need to add escaped quotes if there is a space in it. | 0.067922 | false | 1 | 4,308 |
2016-05-14 14:37:26.733 | Proper way of loading large amounts of image data | For a Deep Learning application I am building, I have a dataset of about 50k grayscale images, ranging from about 300*2k to 300*10k pixels. Loading all this data into memory is not possible, so I am looking for a proper way to handle reading in random batches of data. One extra complication with this is, I need to know... | Why not add a preprocessing step, where you would either (a) physically move the images to folders associated with bucket and/or rename them, or (b) first scan through all images (headers only) to build the in-memory table of image filenames and their sizes/buckets, and then the random sampling step would be quite simp... | 0 | false | 1 | 4,309 |
2016-05-15 15:55:25.797 | python tools visual studio - step into not working | I am trying to debug a scrapy project , built in Python 2.7.1
in visual studio 2013.
I am able to reach breakpoints, but when I do step into/ step over
the debugger seems to continue the exceution as if I did resume (F5).
I am working with standard python launcher.
Any idea how to make the step into/over functionalit... | workaround rather than full answer.
I encountered this problem while importing my own module which ran code (which was erroring) on import.
By setting the imported module to the startup script, I was able to step through the startup code in the module and debug.
My best guess is that visual studio 2015 decided the imp... | 0.201295 | false | 1 | 4,310 |
2016-05-16 11:11:32.783 | how to hide "py4j.java_gateway:Received command c on object id p0"? | Once logging is started in INFO level I keep getting bunch of py4j.java_gateway:Received command c on object id p0 on your logs. How can I hide it? | using the logging module run:
logging.getLogger("py4j").setLevel(logging.ERROR) | 1 | false | 1 | 4,311 |
2016-05-18 02:29:10.640 | How to specify language for watch window expressions in a multi-language debugging environment? | How does Visual Studio switch between python and C# expressions when debugging a process that mixes both C# an Python by embedding and invoking python interpreter?
For background: My Visual Studio 2015 with PTVS 2.2.2 did not allow me to specify any python expressions in the watch window (on at least two machines), unt... | There seems to be a bug/issue in PTVS and/or Visual Studio in that the watch window does not realize that the context has switched to Python, unless there is at least one call to a python method in the call stack.
so if embedded script does:
print ('foo')
, the watch window thinks it's still in c# context.
If the embed... | 1.2 | true | 1 | 4,312 |
2016-05-18 22:33:13.253 | Django sending xml requests at the same time | Using the form i create several strings that looks like xml data. One part of this strings i need to send on several servers using urllib and another part, on soap server, then i use suds library. When i receive the respond, i need to compare all of this data and show it to user. The sum of these server is nine and qua... | You might want to consider using PycURL or Twisted. These should have the asynchronous capabilities you're looking for. | 1.2 | true | 1 | 4,313 |
2016-05-19 03:10:57.693 | How to convert two channel audio into one channel audio | I am playing around with some audio processing in python. Right now I have the audio as a 2x(Large Number) numpy array. I want to combine the channels since I only want to try some simple stuff. I am just unsure how I should do this mathematically. At first I thought this is kind of like converting an RGB image to ... | To convert any stereo audio to mono, what I have always seen is the following:
For each pair of left and right samples:
Add the values of the samples together in a way that will not overflow
Divide the resulting value by two
Use this resulting value as the sample in the mono track - make sure to round it properly if ... | 1.2 | true | 2 | 4,314 |
2016-05-19 03:10:57.693 | How to convert two channel audio into one channel audio | I am playing around with some audio processing in python. Right now I have the audio as a 2x(Large Number) numpy array. I want to combine the channels since I only want to try some simple stuff. I am just unsure how I should do this mathematically. At first I thought this is kind of like converting an RGB image to ... | i handle this by using Matlab.python can do the same. (left-channel+right-channel)/2.0 | 0.201295 | false | 2 | 4,314 |
2016-05-19 16:12:37.927 | How to configure the Jenkins ShiningPanda plugin Python Installations | The Jenkins ShiningPanda plugin provides a Managers Jenkins - Configure System setting for Python installations... which includes the ability to Install automatically. This should allow me to automatically setup Python on my slaves.
But I'm having trouble figuring out how to use it. When I use the Add Installer drop d... | As far as my experiments for jenkins and python goes, shining panda plug-in doesn't install python in slave machines in fact it uses the existing python library set in the jenkins configuration to run python commands.
In order to install python on slaves, I would recommend to use python virtual environment which comes ... | 1.2 | true | 1 | 4,315 |
2016-05-20 07:43:41.360 | Dynamically update static webpage with python script | So I'm using a Raspberry Pi 2 with a rfid scanner and wrote a script in python that logs people in and out of our attendance system, connects to our postgresql database and returns some data like how much overtime they have and whether their action was a login or logout.
This data is meant to be displayed on a very bas... | To update page data without delay you need to use websockets.
There is no need in using heavy frameworks.
Once page is loaded first time you open websocket with js and listen to it.
Every time you read a tag you post all necessary data to this open socket and it instantly appear on client side. | 0 | false | 1 | 4,316 |
2016-05-23 00:28:43.973 | Replacing sprites idea | Ok so I am very bad at sprites and I just don't get how to use sprites with blitted images. So I was wondering, if I make the image and just make a rectangle around that object that follows that image around, would that be a good replacement for sprites, the rectangle would be the one that's colliding for instances... ... | In my experience, most uses for sprites can work with rectangular collision boxes. Only if you had an instance where a ball needed to be collided with then you would have to use an actual sprite. In the long run, I would recommend learning sprites, but if you need help with sprites, the pygame documentation has loads o... | 1.2 | true | 1 | 4,317 |
2016-05-23 08:52:33.410 | What is the optimal topic-modelling workflow with MALLET? | Introduction
I'd like to know what other topic modellers consider to be an optimal topic-modelling workflow all the way from pre-processing to maintenance. While this question consists of a number of sub-questions (which I will specify below), I believe this thread would be useful for myself and others who are interest... | Thank you for this thorough summary!
As an alternative to topicmodels try the package mallet in R. It runs Mallet in a JVM directly from R and allows you to pull out results as R tables. I expect to release a new version soon, and compatibility with tm constructs is something others have requested.
To clarify, it's a g... | 1.2 | true | 1 | 4,318 |
2016-05-23 23:29:57.597 | Getting error on installing polyglot for python 3.5? | HI i want to install the polyglot on python version 3.5. it requires to have numpy installed which i already have and also libicu-dev. My OS is windows X86. I went through cmd, pip and wrote "pip install libicu-dev" but it gives me an error that could not find a version to satisfy the requirements.
how can i install li... | This will work by typing it on Anaconda Prompt:
pip install polyglot==14.11 | 0 | false | 1 | 4,319 |
2016-05-24 12:15:51.720 | f1 score of all classes from scikits cross_val_score | I'm using cross_val_score from scikit-learn (package sklearn.cross_validation) to evaluate my classifiers.
If I use f1 for the scoring parameter, the function will return the f1-score for one class. To get the average I can use f1_weighted but I can't find out how to get the f1-score of the other class. (precision and ... | For individual scores of each class, use this :
f1 = f1_score(y_test, y_pred, average= None)
print("f1 list non intent: ", f1) | -0.101688 | false | 1 | 4,320 |
2016-05-24 13:04:39.783 | creating a simple function using lists of operators and integers | EDIT: When I say function in the title, I mean mathematical function not programming function. Sorry for any confusion caused.
I'm trying to create a function from randomly generated integers and operators. The approach I am currently taking is as follows:
STEP 1: Generate random list of operators and integers as a... | Why not create one list for the ints and one for the operators and them append from each list step by step?
edit: you can first convert your ints to strings then, create a string by using string=''.joint(list) after that you can just eval(string)
edit2: you can also take a look at the Sympy module that allows you to us... | 1.2 | true | 2 | 4,321 |
2016-05-24 13:04:39.783 | creating a simple function using lists of operators and integers | EDIT: When I say function in the title, I mean mathematical function not programming function. Sorry for any confusion caused.
I'm trying to create a function from randomly generated integers and operators. The approach I am currently taking is as follows:
STEP 1: Generate random list of operators and integers as a... | So, for those that are interested. I achieved what I was after by using the eval() function. Although not the most robust, within the particular loop I have written the inputs are closely controlled so I am happy with this approach for now. | 0 | false | 2 | 4,321 |
2016-05-24 17:03:14.057 | Using Python, how to stop the screen from updating its content? | I searched the web and SO but did not find an aswer.
Using Python, I would like to know how (if possible) can I stop the screen from updating its changes to the user.
In other words, I would like to buid a function in Python that, when called, would freeze the whole screen, preventing the user from viewing its changes.... | If by "the screen" you're talking about the terminal then I highly recommend checking out the curses library. It comes with the standard version of Python. It gives control of many different aspects of the terminal window including the functionality you described. | 1.2 | true | 1 | 4,322 |
2016-05-26 14:29:48.217 | How can I retrieve Proxmox node notes? | I am using proxmoxer to manipulate machines on ProxMox (create, delete etc).
Every time I am creating a machine, I provide a description which is being written in ProxMox UI in section "Notes".
I am wondering how can I retrieve that information?
Best would be if it can be done with ProxMox, but if there is not a way to... | The description parameter is only a message to show in proxmox UI, and it's not related to any function | 0 | false | 1 | 4,323 |
2016-05-27 09:38:54.957 | Django + Pythonanywhere: How to disable Debug Mode | I am using Django and PythonAnywhere, and I want to make the DEBUG to False. But when I set it to False and make ALLOWED_HOSTS = ['*'], it works fine. But the problem is the media (or the images) is not displaying. Anyone encounter this and know how to resolve it? | I Figured it out, thanks for the hint Mr. Raja Simon.
In my PythonAnywhere Dashboard on Web Tab. I set something like this..
URL /media/
Directory /home//media_cdn
*media_cdn is where my images located. | 1.2 | true | 1 | 4,324 |
2016-05-27 10:10:31.457 | how to access a particular column of a particular csv file from many imported csv files | Suppose that i have multiple .csv files with columns of same kind . If i wanted to access data of a particular column from a specified .csv file , how is it possible?
All .csv files have been stored in list.data
for ex:
Suppose that here , list.data[1] gives me the first .csv file.
How will i access a column of this fi... | you can use list.data[[1]]$name1 | 0 | false | 1 | 4,325 |
2016-05-28 19:17:02.737 | Tkinter Creating Multiple Windows - Use new Tk instance or Toplevel or Frame? | I am starting to learn Tkinter and have been creating new windows with new instances of Tk every time. I just read that that wasn't a good practice. If so, why? And how could this be done better? I have seen others create windows with Toplevel and Frame instances. What are the benefits/drawbacks of using these instead?... | Every tkinter program needs exactly one instance of Tk. Tkinter is a wrapper around an embedded tcl interpreter. Each instance of Tk gets its own copy of the interpreter, so two Tk instances have two different namespaces.
If you need multiple windows, create one instance of Tk and then additional windows should be ins... | 1.2 | true | 1 | 4,326 |
2016-05-30 13:38:38.263 | How can I set QGroupBox's title with HTML expressions? (Python) | I want to set my QGroupBox's title with HTML expressions in python program,
e.g. :
ABC. (subscript)
Does anybody have an idea how to do this? | QGroupBox's title property does not support HTML. The only customization you can do through the title string (besides the text itself) is the addition of an ampersand (&) for keyboard accelerators.
In short, unlike QLabel, you can't use HTML with QGroupBox. | 1.2 | true | 1 | 4,327 |
2016-05-30 22:39:48.970 | Passing command line arguments to argv in jupyter/ipython notebook | I'm wondering if it's possible to populate sys.argv (or some other structure) with command line arguments in a jupyter/ipython notebook, similar to how it's done through a python script.
For instance, if I were to run a python script as follows:
python test.py False
Then sys.argv would contain the argument False. But ... | A workaround is to make the jupyter notebook read the arguments from a file.
From the command line, modify the file and run the notebook. | 0.037089 | false | 1 | 4,328 |
2016-05-31 06:11:49.077 | giving more weight to a feature using sklearn svm | I 'm using svm to predict the label from the title of a book. However I want to give more weight to some features pre defined. For example, if the title of the book contains words like fairy, Alice I want to label them as children's books. I'm using word n-gram svm. Please suggest how to achieve this using sklearn. | You can create one more feature vector in your training data, if the name of the book contains your predefined words then make it one otherwise zero. | 0 | false | 1 | 4,329 |
2016-05-31 22:40:32.710 | Python: Create a message box with a text entry field using tkinter | I know how to make message boxes, and I know how to create textboxes. However, I don't know how to make a message box WITH a textbox in it. I've looked through the tkinter documentation and it seems message boxes are kind of limited.
Is there a way to make a message box that contains a text entry field, or would I have... | simpledialog.askstring() was exactly what I needed. | 1.2 | true | 1 | 4,330 |
2016-06-01 04:34:27.020 | Python push single file into android device with different names until the device runs out of memory | I know "adb push" command could be used to push files to android device. But in Python how do i push single file for example file.txt(size of about 50 KB) into android sdcard with different names(for ex. file1.txt, file2.txt etc) until the device storage is full. Any idea much appreciated. | I found an alternative solution to this problem. In a python while loop push a single file into SD Card and use "adb mv" to rename the file in the SD Card after pushing the file, continue this until the device memory is full. | 0 | false | 1 | 4,331 |
2016-06-01 12:36:04.073 | Sharing URL generation from uuid4? | I'm having a bit of a problem figuring out how to generate user friendly links to products for sharing.
I'm currently using /product/{uuid4_of_said_product}
Which is working quite fine - but it's a bit user unfriendly - it's kind of long and ugly.
And I do not wish to use and id as it would allow users to "guess" produ... | As Seluck suggested I decided to go with base64 encoding and decoding:
In the model my "link" property is now built from the standard url + base64.urlsafe_b64encode(str(media_id))
The url pattern I use to match the base64 pattern:
base64_pattern = r'(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$'
And f... | 1.2 | true | 1 | 4,332 |
2016-06-02 23:18:18.403 | are there any limitations on the number of locks a python program can create? | I have a single-threaded python3 program that I'm trying to convert to use many threads. I have a tree-like data structure that gets read from and written to. Potentially many threads will want to read and write at the same time.
One obvious way about this is to have a single lock for the entire data structure: no on... | Premature Optimization
This is a classic example of premature optimization. Without knowing how much time your threads spend blocking, presumably waiting for other writes to happen, it's unclear what you have to gain from creating the added complexity of managing thousands of locks.
The Global Interpreter Lock
Threa... | 0.673066 | false | 1 | 4,333 |
2016-06-04 16:13:24.863 | how to close tensorboard server with jupyter notebook | what is the proper way to close tensorboard with jupyter notebook?
I'm coding tensorflow on my jupyter notebook. To launch, I'm doing: 1.
!tensorboard --logdir = logs/
open a new browser tab and type in localh... | The jupyter stuff seems fine. In general, if you don't close TensorBoard properly, you'll find out as soon as you try to turn on TensorBoard again and it fails because port 6006 is taken. If that isn't happening, then your method is fine.
As regards the logdir, passing in the top level logdir is generally best because ... | 0.386912 | false | 1 | 4,334 |
2016-06-05 13:31:41.033 | Jupyter Notebook uses my system's python3.4 instead of anaconda's python3.5 as a kernel | I had anaconda2 installed, and manually added the python3 kernel, so I could chose between python2 and python3. The problem was that I added my system's python3 binary, not anaconda's, so I was missing all the libraries that anaconda brings. Specifically I couldnt import 'from scipy.misc import imread'.
So I deleted an... | Ended up solving it with:
pip install -U ipython
ipython3 kernelspec install-self | 0.386912 | false | 1 | 4,335 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.