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 |
|---|---|---|---|---|---|---|---|
2015-12-15 14:28:43.610 | How to easily implement C-like modulo (remainder) operation in python 2.7 | Modulo operator % on negative numbers is implemented in different way in python and in C. In C:
-4 % 3 = -1, while in python:-4 % 3 = 2.
I know how to implement python-like modulo in C. I wonder how to do the reverse, that is: easily implement a C-like modulo in python. | easily implement a C-like modulo in python.
Since C does truncation toward zero when integers are divided, the sign of the remainder is always the sign of the first operand. There are several ways to implement that; pick one you like:
def mod(a, b): return abs(a)%abs(b)*(1,-1)[a<0]
def mod(a, b): return abs(a)%abs(b... | 0.386912 | false | 1 | 4,071 |
2015-12-16 11:23:18.517 | Issues with Multi-lingual website data caching - Python - Google App Engine | Question:
What are the most efficient approaches to multi-lingual data caching on a web server, given that clients want the same base set of data but in their locale format. So 1000 data items max to be cached and then rendered on demand in specific locale format.
My current approach is as follows:
I have a multilingua... | I assume the individual product rendering in a particular language accounts for the majority (or at least a big chunk) of the rendering effort for the entire page.
You could cache server-side the rendered product results for a particular language, prior to assembling them in a complete results page and sending them to ... | 0.386912 | false | 1 | 4,072 |
2015-12-16 21:19:40.960 | how to gather all module's loggers under one parent? | I understand and like the idea of hierarchical structure of loggers with canonical module name as the name of the logger. But I don't know how to tie everything up at the top level.
Supposing I have application using
package1.subpackage1.module1 and
package2.subpackage2.module2.
And now I'd like to define one handle... | Ok I found the answer. The master parent for all loggers is root logger - no mater it's name doesn't appear in the canonical name. | 0 | false | 1 | 4,073 |
2015-12-17 11:45:43.287 | How to compile with two different compilers using SCons? | I'm trying to set up a complete build environment with SCons and I came across this problem:
My project can be compiled with two different compilers (c or cpp compilers) and the resulting object files linked with the same linker.
Because of this, I need to know how to split the compilation part from the linking part.
A... | Create two Environments, one with each compiler, use where necessary.
Then use whichever Environment you need for linking object from either Environment. | 0 | false | 1 | 4,074 |
2015-12-17 15:06:05.347 | Location of tensorflow/models.. in Windows | I have installed tensorflow on Windows using Docker, I want to go to the folder "tensorflow/models/image/imagenet" that contains "classify_image.py" python file..
Can someone please how to reach this mentioned path? | If you're using one of the devel tags (:latest-devel or :latest-devel-gpu), the file should be in /tensorflow/tensorflow/models/image/imagenet/classify_image.py.
If you're using the base container (b.gcr.io/tensorflow/tensorflow:latest), it's not included -- that image just has the binary installed, not a full source d... | 0.386912 | false | 1 | 4,075 |
2015-12-17 18:13:23.627 | MySQL module for Python 3 | MySQLdb as I understand doesn't support Python 3. I've heard about PyMySQL as a replacement for this module. But how does it work in production environment?
Is there a big difference in speed between these two? I asking because I will be managing a very active webapp that needs to create entries in the database very of... | PyMySQL is a pure-python database connector for MySQL, and can be used as a drop-in replacement using the install_as_MySQLdb() function. As a pure-python implementation, it will have some more overhead than a connector that uses C code, but it is compatible with other versions of Python, such as Jython and PyPy.
At th... | 1.2 | true | 1 | 4,076 |
2015-12-18 14:19:53.773 | PDF Miner PDFEncryptionError | I'm trying to extract text from pdf-files and later try to identify the references. I'm using pdfminer 20140328. With unencrypted files its running well, but I got now a file where i get:
File "C:\Tools\Python27\lib\site-packages\pdfminer\pdfdocument.py", line 348, in _initialize_password
raise PDFEncryptionError('Unk... | This is pdfminer's error, use pdfplumber.open(file_name, password="".encode()) to skip this error or TypeError: can only concatenate str (not "bytes") to str. | 0 | false | 1 | 4,077 |
2015-12-20 00:46:56.213 | Delete the large object in ironpython, and instantly release the memory? | I am a creating a huge mesh object (some 900 megabytes in size).
Once I am done with analysing it, I would like to somehow delete it from the memory.
I did a bit of search on stackoverflow.com, and I found out that del will only delete the reference to mentioned mesh. Not the mesh object itself.
And that after some tim... | In general managed enviroments relase there memory, if no reference is existing to the object anymore (from connection from the root to the object itself). To force the .net framework to release memory, the garbage collector is your only choice. In general it is important to know, that GC.Collect does not free the memo... | 1.2 | true | 1 | 4,078 |
2015-12-21 16:59:47.563 | how to open 3ds files with python | I am new to 3d world. I would like to open 3ds files with python and visualize the objects.
I could not find any easy and straight forward way to play with 3ds max files.
Can you let me know how can I achieve this? | According to my understanding, there are some advanced graphics libraries out there for advanced usage, however Blender, (an application developed in python) supports python scripting. There are even a simple drag and drop game engine for simpler tasks. | 0 | false | 1 | 4,079 |
2015-12-21 17:07:18.380 | Django saving models by JS rather than form submissions? | I have a contract job for editing a Django application, and Django is not my main framework to use, so I have a question regarding models in it.
The application I am editing has a form that each user can submit, and every single model in the application is edited directly through the form.
From this perspective, it see... | There is some terminology confusion here, as SColvin points out; it's really not clear what you mean by "custom variables", and how those relates to models.
However your main confusion seems to be around forms. There is absolutely no requirement to use them: they are just one method of updating models. It is always pos... | 0 | false | 1 | 4,080 |
2015-12-23 03:13:18.127 | Etags used in RESTful APIs are still susceptible to race conditions | Maybe I'm overlooking something simple and obvious here, but here goes:
So one of the features of the Etag header in a HTTP request/response it to enforce concurrency, namely so that multiple clients cannot override each other's edits of a resource (normally when doing a PUT request). I think that part is fairly well k... | Etag can be implemented in many ways, not just last updated time. If you choose to implement the Etag purely based on last updated time, then why not just use the Last-Modified header?
If you were to encode more information into the Etag about the underlying resource, you wouldn't be susceptible to the race condition ... | 0.135221 | false | 3 | 4,081 |
2015-12-23 03:13:18.127 | Etags used in RESTful APIs are still susceptible to race conditions | Maybe I'm overlooking something simple and obvious here, but here goes:
So one of the features of the Etag header in a HTTP request/response it to enforce concurrency, namely so that multiple clients cannot override each other's edits of a resource (normally when doing a PUT request). I think that part is fairly well k... | You are right that you can still get race conditions if the 'check last etag' and 'make the change' aren't in one atomic operation.
In essence, if your server itself has a race condition, sending etags to the client won't help with that.
You already mentioned a good way to achieve this atomicity:
The only fool-proof s... | 0.135221 | false | 3 | 4,081 |
2015-12-23 03:13:18.127 | Etags used in RESTful APIs are still susceptible to race conditions | Maybe I'm overlooking something simple and obvious here, but here goes:
So one of the features of the Etag header in a HTTP request/response it to enforce concurrency, namely so that multiple clients cannot override each other's edits of a resource (normally when doing a PUT request). I think that part is fairly well k... | This is really a question about how to use ORMs to do updates, not about ETags.
Imagine 2 processes transferring money into a bank account at the same time -- they both read the old balance, add some, then write the new balance. One of the transfers is lost.
When you're writing with a relational DB, the solution to th... | 0.265586 | false | 3 | 4,081 |
2015-12-23 17:54:32.183 | Simulate shell behavior (force eval of last command to be displayed) | In a python shell, if I type a = 2 nothing is printed. If I type a 2 gets printed automatically. Whereas, this doesn't happen if I run a script from idle.
I'd like to emulate this shell-like behavior using the python C api, how is it done?
For instance, executing this code PyRun_String("a=2 \na", Py_file_input, dic, d... | To compile your code so expression statements invoke sys.displayhook, you need to pass Py_single_input as the start parameter, and you need to provide one statement at a time. | 1.2 | true | 1 | 4,082 |
2015-12-26 15:18:00.947 | Unable to correctly restore postgres data: I get the same error I usually get if I haven't run syncdb and migrate | I have a Django app with a postgres backend hosted on Heroku. I'm now migrating it to Azure. On Azure, the Django application code and postgres backend have been divided over two separate VMs.
Everything's set up, I'm now at the stage where I'm transferring data from my live Heroku website to Azure. I downloaded a pg_... | Try those same steps WITHOUT running syncdb and migrate at all. So overall, your steps will be:
heroku pg:backups capture
curl -o latest.dump heroku pg:backups public-url
`scp -P latest.dump myuser@example.cloudapp.net:/home/myuser
drop database mydb;
create database mydb;
pg_restore --verbose --clean --no-acl --no-ow... | 1.2 | true | 1 | 4,083 |
2015-12-27 18:04:47.093 | 5D tensor in Theano | I was wondering how to make a 5D tensor in Theano.
Specifically, I tried dtensor = T.TensorType('float32', (False,)*5). However, the only issue is that dtensor.shapereturns: AttributeError: 'TensorType' object has no attribute 'shape'
Whereas if I used a standard tensor type likedtensor = T.tensor3('float32'), I don't ... | Theano variables do not have explicit shape information since they are symbolic variables, not numerical. Even dtensor3 = T.tensor3(T.config.floatX) does not have an explicit shape. When you type dtensor3.shape you'll get an object Shape.0 but when you do dtensor3.shape.eval() to get its value you'll get an error.
For ... | 1.2 | true | 1 | 4,084 |
2015-12-28 02:26:12.947 | In Python, how do I check that the user has entered a name instead of a number? | In Python, how do I check that the user has entered a name instead of a number, when asking for user input as string? I want a string input in the form of their name, but I want to use error checking to make sure the user doesn't enter a number. | If you wanna check correct in english dictionary then you can use pyenchant ... use pip to install it ... its east to use and gives true if spelling of a word is correct and false if word doesn't exist in english dictionary.
pip install pyenchant | 0 | false | 1 | 4,085 |
2015-12-28 20:33:24.163 | open cmd with admin rights (Windows 10) | I have my own python script that manages the IP address on my computer. Mainly it executes the netsh command in the command line (windows 10) which for you must have administrator rights.
It is my own computer, I am the administrator and when running the script I am already logged in with my user (Adrian) which is of t... | Try something like this: runas /user:administrator regedit. | 1.2 | true | 1 | 4,086 |
2015-12-29 00:37:15.510 | Python pandas: determining which "group" has the most entries | Let's say that I have pandas DataFrame with a column called "fruit" that represents what fruit my classroom of kindergartners had for a morning snack. I have 20 students in my class. Breakdown would be something like this.
Oranges = 7, Grapes = 3, Blackberries = 4, Bananas = 6
I used sort to group each of these fruit t... | To sort by name: df.fruit.value_counts().sort_index()
To sort by counts: df.fruit.value_counts().sort_values() | 0.386912 | false | 1 | 4,087 |
2015-12-29 08:59:26.637 | How to install beautifulsoup into python3, when default dir is python2.7? | I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7/site-package directory.
But how do I install it into the python3 dir? | If you are on windows, this works for Python3 as well
py -m pip install bs4 | 0 | false | 2 | 4,088 |
2015-12-29 08:59:26.637 | How to install beautifulsoup into python3, when default dir is python2.7? | I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7/site-package directory.
But how do I install it into the python3 dir? | I had some mismatch between Python version and Beautifulsoup. I was installing this project
Th3Jock3R/LinuxGSM-Arma3-Mod-Update
to a linux centos8 dedicated Arma3 server. Python3 and Beautifulsoup4 seem to match.So I updated Python3, removed manually Beautifulsoup files and re-installed it with: sudo yum install python... | 0.067922 | false | 2 | 4,088 |
2015-12-29 15:34:47.500 | How to get the index of a tab in AuiNotebook after a right click on a non-active tab? | I create a menu that popups after a right on a tab. The menu contains three options: close, close other and close all. Right clicking on a tabs does not display its content (it not already displayed), it just show the menu that control the clicked tab. The issue is that right clicking on another tab popups the menu but... | Use EVT_AUINOTEBOOK_TAB_RIGHT_DOWN to catch the event. The event.page will give you the clicked page. | 0 | false | 1 | 4,089 |
2015-12-29 22:40:26.793 | Completing Spotify Authorization Code Flow via desktop application without using browser | Working on a small app that takes a Spotify track URL submitted by a user in a messaging application and adds it to a public Spotify playlist. The app is running with the help of spotipy python on a Heroku site (so I have a valid /callback) and listens for the user posting a track URL.
When I run the app through comman... | I once ran into a similar issue with Google's Calendar API. The app was pretty low-importance so I botched a solution together by running through the auth locally in my browser, finding the response token, and manually copying it over into an environment variable on Heroku. The downside of course was that tokens are se... | 0.386912 | false | 1 | 4,090 |
2015-12-31 14:30:13.710 | Macports caffe wrong python | I installed caffe using Macports sudo port install caffe. However, Macports didn't use my anaconda python, which I would like to use for development. I can only import caffe in Macports' python2.7.
Is there a way to show anaconda python where to look or do I have to reinstall for anaconda python? Either way, I would be... | MacPorts never installs modules for use with other Python versions than MacPorts' own version. As a consequence, there is no switch to select the Python version to build against.
You'll have to install caffe for your Anaconda Python yourself, e.g. in a virtualenv, or use MacPorts Python. | 1.2 | true | 2 | 4,091 |
2015-12-31 14:30:13.710 | Macports caffe wrong python | I installed caffe using Macports sudo port install caffe. However, Macports didn't use my anaconda python, which I would like to use for development. I can only import caffe in Macports' python2.7.
Is there a way to show anaconda python where to look or do I have to reinstall for anaconda python? Either way, I would be... | Install pyvenv ... it is easy to do on a Mac - then you can use whatever you want to. | 0 | false | 2 | 4,091 |
2016-01-02 21:38:15.827 | Getting parent of AST node in Python | I'm working with Abstract Syntax Trees in Python 3. The ast library gives many ways to get children of the node (you can use iter_child_nodes() or walk()) but no ways to get parent of one. Also, every node has links to its children, but it hasn't links to its parent.
How I can get the parent of AST node if I don't want... | You might create some hash table associating AST nodes to AST nodes and scan (recursively) your topmost AST tree to register in that hash table the parent of each node. | 1.2 | true | 2 | 4,092 |
2016-01-02 21:38:15.827 | Getting parent of AST node in Python | I'm working with Abstract Syntax Trees in Python 3. The ast library gives many ways to get children of the node (you can use iter_child_nodes() or walk()) but no ways to get parent of one. Also, every node has links to its children, but it hasn't links to its parent.
How I can get the parent of AST node if I don't want... | It wouldn't be really be a plugin, but you can always write a function which adds a weakref to parent in every child. | 0 | false | 2 | 4,092 |
2016-01-03 07:43:15.450 | How to save the n-d numpy array data and read it quickly next time? | Here is my question:
I have a 3-d numpy array Data which in the shape of (1000, 100, 100).
And I want to save it as a .txt or .csv file, how to achieve that?
My first attempt was to reshape it into a 1-d array which length 1000*100*100, and transfer it into pandas.Dataframe, and then, I save it as .csv file.
When I... | If you need to re-read it quickly into numpy you could just use the cPickle module.
This is going to be much faster that parsing it back from an ASCII dump (but however only the program will be able to re-read it). As a bonus with just one instruction you could dump more than a single matrix (i.e. any data structure bu... | 1.2 | true | 1 | 4,093 |
2016-01-04 00:51:45.247 | Create SVG and save it to datastore(GAE + Python) | i have a doubt, i need to create some svg files (in a sequence) and upload to data store. I know how to create the svg, but it save to filesystem, and i have understood that GAE cannot use it.
So, i don't know how to create and put it on the datastore. | Create your "file" in memory (use e.g io.BytesIO) and then use the getvalue method of the in-memory "file" to get the blob of bytes for the datastore. Do note that a datastore entity is limited to a megabyte or so, thus it's quite possible that some SVG file might not fit in that space -- in which case, you should look... | 1.2 | true | 1 | 4,094 |
2016-01-04 13:13:20.587 | Python PDF generation - image from internet | Is there a python pdf generator that can use an image directly from a given url? Right now I'm using ReportLab and I have to download and save the image to a file and then using filename I can add it to the PDF. Which is significatly slower I imagine, in comparison to directly downloading the image, storing it in memor... | I really cannot see how this is significantly slower.
The local disks bandwidth should be much larger than the internet bandwidth.
So the extra local save/load times should be extremely low overhead.
If you really wan't to speed stuff up, check if the file already exists locally before downloading.
unless of course if ... | 1.2 | true | 1 | 4,095 |
2016-01-04 14:15:38.183 | how to see the python api doc in pycharm ipython notebook | I am developing ipython notebook in pycharm. But I don't know how to check the python doc of the library I use in the notebook with IDE support (like mouse over the code and python api doc display automatically). Does anyone know that ? Thanks | Simplest solution - print somewhere __doc__ or use LPM when clicking on method you want to check to go directly to the file, where method you need is declared. Then you should have docstring of it. | 0 | false | 1 | 4,096 |
2016-01-04 18:45:08.353 | Create 3D- polynomial via numpy etc. from given coordinates | Given some coordinates in 3D (x-, y- and z-axes), what I would like to do is to get a polynomial (fifth order). I know how to do it in 2D (for example just in x- and y-direction) via numpy. So my question is: Is it possible to do it also with the third (z-) axes?
Sorry if I missed a question somewhere.
Thank you. | Numpy has functions for multi-variable polynomial evaluation in the polynomial package -- polyval2d, polyval3d -- the problem is getting the coefficients. For fitting, you need the polyvander2d, polyvander3d functions that create the design matrices for the least squares fit. The multi-variable polynomial coefficients ... | 0 | false | 1 | 4,097 |
2016-01-06 09:43:45.240 | Non-default IPython profile in Spyder console | I use two installations of Spyder, one using my default python 2.7 and the other running in a python 3.4 virtualenv. However, the history of the IPython console is shared between the two. The cleanest way to have separate histories would be to define a new IPython profile for the python 3.4 installation. My question is... | As mentioned by Carlos' answer, there is no way to start an IPython console inside Spyder with a different profile. A workaround is to duplicate the ~/.ipython directory (I named mine ~/.ipython3) and set the environment variable IPYTHONDIR to the new location before running the python 3 version of Spyder. It will then... | 1.2 | true | 2 | 4,098 |
2016-01-06 09:43:45.240 | Non-default IPython profile in Spyder console | I use two installations of Spyder, one using my default python 2.7 and the other running in a python 3.4 virtualenv. However, the history of the IPython console is shared between the two. The cleanest way to have separate histories would be to define a new IPython profile for the python 3.4 installation. My question is... | (Spyder dev here) There is no way to start an IPython console inside Spyder with a different profile. We use the default profile to create all our consoles. | 0.545705 | false | 2 | 4,098 |
2016-01-07 07:41:01.563 | What the function apply() in scikit-learn can do? | In scikit-learn new version ,there is a new function called apply() in Gradient boosting. I'm really confused about it .
Does it like the method:GBDT + LR that facebook has used?
If dose, how can we make it work like GBDT + LR? | From the Sci-Kit Documentation
apply(X) Apply trees in the ensemble to X, return leaf indices
This function will take input data X and each data point (x) in it will be applied to each non-linear classifier tree. After application, data point x will have associated with it the leaf it end up at for each decision tre... | 0.545705 | false | 1 | 4,099 |
2016-01-07 17:38:23.473 | Directory issues within Pycharm (free version) & Perforce | Ok, so I'm looking to switch to PyCharm from PyScripter for OS independent development. I also wanted to mention that I'm using Perforce for version control.
So what I currently do is double click a .py for editing in Perforce, and PyScripter opens up and I edit to my hearts desire. I can click on an imported function... | Go to
File --> Open
in Pycharm and select your Scripts(folder) and open it. Then the Pycharm will treat it as a project and you will be able to ctrl + click a function. | 0.673066 | false | 1 | 4,100 |
2016-01-08 03:24:48.170 | Python virtualenv has changed sys.path permanently | I have activated a python virtualenv (dev) for one of my projects. However, don't know what happened, it looks like it has changed the path permanently. I cannot access my global packages. When I print sys.path it shows me paths related to virtualenv (dev) which is no more activated. When I run pip list, it shows me pa... | Your default environment variables may be wrong in path, since the default path must point to the python globally.
Try this:
Start menu > Run > 'sysdm.cpl' > Enter
Search for the tab 'Advanced'
Finally 'Environment Variables'
Edit the system variable 'Path'
Carefully and search for the python path, just change it to ... | 0 | false | 1 | 4,101 |
2016-01-09 10:31:33.783 | Using PIP in a Azure WebApp | I'm pretty new to Azure and I'm trying to get a Django WebApp up and running. I uploaded the files using FTP, But Azure doesn't run my requirements.txt.
So I searched for a bit and found out that you can install the requirements.txtwith pip.
Back in Azure, PIP doesn't seem to work. Neither in the Console, The KUDU ... | Have you tried upgrading pip with easy_install? The following worked for me in Azure kudu console:
python -m easy_install --upgrade --user pip | 0.16183 | false | 2 | 4,102 |
2016-01-09 10:31:33.783 | Using PIP in a Azure WebApp | I'm pretty new to Azure and I'm trying to get a Django WebApp up and running. I uploaded the files using FTP, But Azure doesn't run my requirements.txt.
So I searched for a bit and found out that you can install the requirements.txtwith pip.
Back in Azure, PIP doesn't seem to work. Neither in the Console, The KUDU ... | You won't be able to upgrade the pip of your Django webapp because you will not have access to system files.
Instead you can upgrade pip of your virtualenv, which you can do by adding a line in deploy.cmd file before install requirements.txt command.
env\scripts\python -m pip install --upgrade pip
Remember not to upgra... | 0.16183 | false | 2 | 4,102 |
2016-01-10 00:22:38.677 | How can I build pyquery for pypy? | I'm trying to use pyquery with pypy but it depends on lxml2, which won't build under pypy. I know there's a lxml2 build that is meant to be used with pypy but I don't know how to make pyquery use that instead of the usual one. | Pypy 5.0 and lxml 3.6 are designed to work well with each other. | 1.2 | true | 1 | 4,103 |
2016-01-10 19:50:47.283 | how to write an Android app in Java which needs to use a Python library? | I want to develop an app to track people's Whatsapp last seen and other stuff, and found out that there are APIs out there to deal with it, but the thing is they are writen in python and are normally run in Linux I think
I have Java and Android knowledge but not python, and wonder if there's a way to develop the most o... | Instead of running it as one app, what about running the python script as separate from the original script? I believe it would bee possible, as android is in fact a UNIX based OS. Any readers could give their input on this idea an if it would work. | 0 | false | 1 | 4,104 |
2016-01-11 16:23:37.373 | how to insert integers in list/array separated by space in python | I want to insert 5 integers by simply typing 3 4 6 8 9 and hitting enter. I know how to insert strings in a list by using list=raw_input().split(" ",99), but how can I insert integers using space? | The above answer is perfect if you are looking to parse strings into a list.
Else you can parse them into Integer List using the given way
integers = '22 33 11'
integers_list = []
try:
integers_list = [int(i) for i in integers.split(' ')]
except:
print "Error Parsing Integer"
print integers_list | 0 | false | 2 | 4,105 |
2016-01-11 16:23:37.373 | how to insert integers in list/array separated by space in python | I want to insert 5 integers by simply typing 3 4 6 8 9 and hitting enter. I know how to insert strings in a list by using list=raw_input().split(" ",99), but how can I insert integers using space? | map(int, "1 2 3 4 5".split())
This will take your string and convert to a list of ints.
Split defaults to splitting on a space, so you don't need an argument.
For raw_input(), you can do:
map(int, raw_input().split()) | 0 | false | 2 | 4,105 |
2016-01-11 19:07:37.250 | who creates the media folder in django and how to change permission rights? | I set up django using nginx and gunicorn. I am looking at the permission in my project folder and I see that the permission for the media folder is set to root (all others are set to debian):
-rw-r--r-- 1 root root 55K Dec 2 13:33 media
I am executing all app relevant commands like makemigrations, migrate, colle... | Coulnd't find out who exactly is it created by, however, the permissions depend on the user (root or non root).
This means if you run the commands (for example: python manage.py runserver) with sudo or under root the folder gets root permissions which can't be edited from a non root user. | 1.2 | true | 1 | 4,106 |
2016-01-12 02:41:29.060 | IPython Jupyter: uploading folder | Can you upload entire folders in IPython Jupyter? If so, how? I know how to upload individual files, of course, but this can get tedious if there are a large number of files and/or subdirectories. | Maybe it is easier to just use unix to just unzip the data.
Steps:
Transform the folder into a .zip file in your computer.
Upload the .zip file to jupyter home.
In jupyter notebook run
! unzip ~/yourfolder.zip -d ~/
where
! tells the jupyter notebook that you are going to give code directly to unix, not python code... | 0.995055 | false | 1 | 4,107 |
2016-01-12 06:30:53.437 | How to host a flask web app on my own pc? | Im developing an app using flask framework in python, i wanted to host it on my pc for a few people to be able to visit it, similar to wamps put online feature but for flask instead, i dont want to deploy it to the cloud just yet. how can i do it. | Enable port forwarding on your router, start flask on the 0.0.0.0 address of your computer, set the forwarded port to be the one started on your laptop. This will now allow your LAN and calls to your ISP provided address to be directed to your laptop.
To clarify, LAN can do it without port forwarding in my experience. | 0 | false | 1 | 4,108 |
2016-01-12 06:54:52.090 | Celery worker details | I have celery task with 100 input data in queue and need to execute using 5 workers.
How can I get which worker is executing which input?
Each worker executed how many inputs and its status?
If any task is failed how can get failed input data in separately and re-execute with available worker?
Is there any possible w... | How can I get which worker is executing which input?
There are 2 options to use multiple workers:
You run each worker separately with separate run commands
You run in one command using command line option -c i.e. concurrency
First method, flower will support it and will show you all the workers, all the tasks (you c... | 0 | false | 1 | 4,109 |
2016-01-13 01:47:56.033 | Controlling VMs using Python scripts | I want to manage virtual machines (any flavor) using Python scripts. Example, create VM, start, stop and be able to access my guest OS's resources.
My host machine runs Windows. I have VirtualBox installed. Guest OS: Kali Linux.
I just came across a software called libvirt. Do any of you think this would help me ?
An... | For aws use boto.
For GCE use Google API Python Client Library
For OpenStack use the python-openstackclient and import its methods directly.
For VMWare, google it.
For Opsware, abandon all hope as their API is undocumented and has like 12 years of accumulated abandoned methods to dig through and an equally insane datam... | 0 | false | 1 | 4,110 |
2016-01-13 10:01:44.740 | How to invoke python scripts in node.js app on Bluemix? | I'd like to run text processing Python scripts after submitting searchForms of my node.js application.
I know how the scripts can be called with child_process and spawn within js, but what should I set up on the app (probably some package.json entries?) so that it will be able to run Python after deploying to Bluemix?
... | I finally fixed this as adding an entry to dependencies in package.json of the project, which causes the call of npm install for the linked github repo. It is kinda straightforward but I found no explanation for that on Bluemix resources. | 0.201295 | false | 1 | 4,111 |
2016-01-13 15:47:26.207 | Implementing an SMPP Server in Python | Does anyone know a tool to implement a Python SMPP server and some tips on how to proceed?
I found Pythomnic3k framework, but did not find material needed for me to use it as SMPP server ... | Take a look at jasmin sms gateway, it's pythonic and has smpp server implementation. | 0.673066 | false | 1 | 4,112 |
2016-01-14 10:05:32.100 | Load a select list when selecting another select | I have a Flask-admin application and I have a class with a "Department" and a "Subdepartment" fields.
In the create form, I want that when a Department is selected, the Subdepartment select automatically loads all the corresponding subdepartments.
In the database, I have a "department" table and a "sub_department" tabl... | You have to follow this steps
Javascript
Bind a on change event to your Department select .
If the select changes you get the value selected.
When you get the value, you have to send it to the server through an AJAX request.
Flask
Implement a method that reads the value and loads the associated Subdepartments.
Send... | 0 | false | 1 | 4,113 |
2016-01-14 22:56:24.597 | tensorflow: how to rotate an image for data augmentation? | In tensorflow, I would like to rotate an image from a random angle, for data augmentation. But I don't find this transformation in the tf.image module. | For rotating an image or a batch of images counter-clockwise by multiples of 90 degrees, you can use tf.image.rot90(image,k=1,name=None).
k denotes the number of 90 degrees rotations you want to make.
In case of a single image, image is a 3-D Tensor of shape [height, width, channels] and in case of a batch of images, i... | 0 | false | 1 | 4,114 |
2016-01-16 08:56:01.047 | Using Unison "-repeat watch" in FreeBSD (10.2) after installing from ports yields error | After installing unison from /usr/ports/net/unison with X11 disabled via make config, running the command unison -repeat watch /dir/mirror/1 /dir/mirror/2
Yields the message:
Fatal error: No file monitoring helper program found
From here I decided to try using pkg to install unison-nox11 and this yields the same erro... | I think the message is pretty clear: unison-fsmonitor can't be run on freebsd10 because it's not supported, so you can't use Unison with the -repeat option.
Since it's just written in Python, though, I don't see why it shouldn't be supported. Maybe message the developer. | 0.386912 | false | 1 | 4,115 |
2016-01-16 11:41:39.943 | How to measure Python's asyncio code performance? | I can't use normal tools and technics to measure the performance of a coroutine because the time it takes at await should not be taken in consideration (or it should just consider the overhead of reading from the awaitable but not the IO latency).
So how do measure the time a coroutine takes ? How do I compare 2 implem... | If you only want to measure performance of "your" code, you could used approach similar to unit testing - just monkey-patch (even patch + Mock) the nearest IO coroutine with Future of expected result.
The main drawback is that e.g. http client is fairly simple, but let's say momoko (pg client)... it could be hard to d... | 0 | false | 1 | 4,116 |
2016-01-17 04:40:24.317 | How to track and update a great many values efficiently? | I'm making a program that simulates governments and families in the medieval ages. People (represented by objects of the class Actor) are born, grow old, have kids, and die.
This means I need to track quite a few objects, and figure out some to e.g. call update_age() for every tracked person every year/month/week.
This... | If you're running a simulation, it is certainly reasonable design to have a single "simulation engine", with various components. As long as you don't implement these as application-wide singletons, you will be fine. This is actually a great example of what the advice to avoid singletons is actually all about! Not havin... | 1.2 | true | 1 | 4,117 |
2016-01-18 00:51:35.350 | import pandas using IDLE error | This is a beginner question. I am using "import pandas as pd" in IDLE,
but got the following error message "ImportError: No module named 'pandas",
I don't know how to install the the pandas in IDLE. I run the same code in MAC linux command window, it worked. Not sure why not working in IDLE.
Thanks for the help! | May be you are using different Python versions in IDLE and the command line, if this is the case, you should install Pandas for the Python version that you are using in IDLE | 0 | false | 1 | 4,118 |
2016-01-18 21:03:51.120 | Installing virtualenv for Python2.7 | I have installation of python 2.7 and 3.3 side by side (C:\Python27 and C:\Python33). I am now trying to install virtualenv.
Python2.7 is my default interpreter. Whenever I open a command prompt and type 'python' it brings up "Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32" for me.... | I'd imagine your environment variables are set up to use the python2.7 environment variable for python and the path to the python3.3 pip for that, you either need to adjust those or use the full paths when using the tool as you require. | 1.2 | true | 1 | 4,119 |
2016-01-18 21:48:37.413 | In Jupyter notebook, how do I arrange subroutines in order to write a project efficiently? | I'd like to write a program using Python in Jupiter. To make things easy, it'd be better off writing a few subroutines (functions) and probably some user-defined classes first before writing the main script. How do I arrange them in Jupiter? Just each sub function/class for a new line and write sequentially and then wr... | The best thing to do for repeated code you want all your notebook to access is to add it to the profile directory. The notebook will load all scripts from that directory in order, so it's recommended you name files 01-<projname>.py if you want them to load in a certain order. All files in that directory will be loaded ... | 1.2 | true | 1 | 4,120 |
2016-01-19 09:09:18.687 | can python 2.7 be removed completely now? | I am on ubuntu 15.10. I notice that i have many python versions installed. Is it safe now to remove 2.7 completely? And how to make 3.5 the default one? I ask this because i think it messes up my django installation because django gets intsalled in share directory. | A lot of application still require Python 2.7 and are not yet compatible with Python3. So it really depends on what you do on the server (Only running Django?).
One solution would be to use virtualenv so that you do not depend on which python version is installed in your server, and you totally control all the packages... | 0.386912 | false | 1 | 4,121 |
2016-01-19 15:49:20.227 | How to run IDLE for python 3 in a conda environment? | For running python2 all I do is activate the required conda environment and just type idle. It automatically opens IDLE for python 2.7. But I can't figure out how to do this for Python 3. I have python 3.5 installed in my environment.
I used conda create -n py35 anaconda for install installing python 3.5 . | Type idle3 instead of idle from your conda env. | 0.591696 | false | 1 | 4,122 |
2016-01-20 11:10:13.050 | How to add RDKit to project in PyCharm? | So, I am trying to add RDKit to my project in PyCharm. I have found that if you are using interpreter /usr/bin/python2.7 PyCharm will try to install stuff using the pip. While, RDKit requires conda. I have tried to change the interpreter to conda, but RDKit is either not on the list or it can't open the URL with the re... | Another option is to select the existing virtual environment when you create a new project in PyCharm. Once you go through the steps that Anna laid out above, the "Previously configured interpreter" section of the "Create Project" screen should show the ~/anaconda/envs/my-rdkit-env/bin/python as an option. | 0 | false | 1 | 4,123 |
2016-01-20 16:46:36.560 | Django PostgreSQL : migrating database to a different directory | I have a Django website running on an Amazon EC2 instance. I want to add an EBS. In order to do that, I need to change the location of my PGDATA directory if I understand well. The new PGDATA path should be something like /vol/mydir/blabla.
I absolutely need to keep the data safe (some kind of dump could be useful).
D... | Ok, thanks for your answers, I used :
find . -name "postgresql.conf" to find the configuration find, which was located into the "/etc/postgresql/9.3/main" folder. There is also pg_lsclusters if you want to show the directory data.
Then I edited that file putting the new path, restarted postgres and imported my old DB. | 0 | false | 1 | 4,124 |
2016-01-20 23:40:08.407 | Python - Cannot upgrade six, issue uninstalling previous version | When I run sudo pip install --upgrade six I run into the issue below:
2016-01-20 18:29:48|optim $ sudo pip install --upgrade six
Collecting six
Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Found existing installation: six 1.4.1
Detected a distutils installed pro... | I, too, have had some issues with installing modules, and I sometimes find that it helps just to start over. In this case, it looks like you already have some of the 'six' module, but isn't properly set up, so if sudo pip uninstall six yields the same thing, go into your directory and manually delete anything related t... | 0.201295 | false | 1 | 4,125 |
2016-01-21 02:03:55.003 | Need help for a Python Snake game | I'm currently creating a Snake game on Python using the TKinter library.
So right now, I've implemented the movements, the food system, and the score system. I still need some help on how I can make the snake grow when it eats the food. | I do not see the associated code that actually displays the current position of the snake on the screen and remove it after movement, but this is where you can change the size if you make the length of the snake variable and have it drawn and removed in an iterate fashion. When food is eaten, you can simply increase th... | 1.2 | true | 1 | 4,126 |
2016-01-22 04:46:31.323 | Save IPython file to a particular directory | I am currently working on a machine learning project, and I would like to save my IPython files with the rest of my scripts. However, I have been unable to find any information on how to change the path that IPython files are saved to. "ipython locate" only gives me the location they are saved to, and does not appear t... | By default ipython and jupyter set the top of the working tree to the current directory at the time of launching the notebook server. You can change this by setting c.NotebookApp.notebook_dir in the either the .ipython/profile_XXX/ipython_notebook_config.py or .jupyter/jupyter_notebook_config.py (*nix/Mac - not sure w... | 0 | false | 1 | 4,127 |
2016-01-22 14:44:38.797 | Graceful reload of python tornado server | I have an HTTP server created by the Tornado framework. I need to update/reload this server without any connection lost and shutdown.
I have no idea how to do it.
Could you get me any clue? | Easy way, do it with nginx.
Start a latest tornado server.
Redirect all new connections to the new tornado server.(Change nginx configure file and reload with nginx -s reload)
Tell the old tornado server shutdown itself if all connections are closed.
Hard way
If you want to change your server on the fly, maybe you co... | 0.386912 | false | 1 | 4,128 |
2016-01-24 00:34:50.717 | Training, testing, and validation sets for bidirectional LSTM (BLSTM) | When it comes to normal ANNs, or any of the standard machine learning techniques, I understand what the training, testing, and validation sets should be (both conceptually, and the rule-of-thumb ratios). However, for a bidirectional LSTM (BLSTM) net, how to split the data is confusing me.
I am trying to improve predict... | I think this has more to do with your particular dataset than Bi-LSTMs in general.
You're confusing splitting a dataset for training/testing vs. splitting a sequence in a particular sample. It seems like you have many different subjects, which constitute a different sample. For a standard training/testing split, you wo... | 1.2 | true | 1 | 4,129 |
2016-01-24 17:42:38.750 | PyCharm & VirtualEnvs - How To Remove Legacy | How do I remove all traces of legacy projects from PyCharm?
Background: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today.
Reason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'.
I deleted the legacy project folders.
I then opened the Pro Editio... | In addition to the answer above, which removed the Venv from the Pycharm list, I also had to go into my ~/venvs directory and delete the associated directory folder in there.
That did the trick. | 0 | false | 3 | 4,130 |
2016-01-24 17:42:38.750 | PyCharm & VirtualEnvs - How To Remove Legacy | How do I remove all traces of legacy projects from PyCharm?
Background: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today.
Reason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'.
I deleted the legacy project folders.
I then opened the Pro Editio... | When virtual env is enabled, there will be a 'V' symbol active in the bottom part of pycharm in the same line with terminal and TODO. When you click on the 'V' , the first one will be enabled with a tick mark. Just click on it again. Then it will get disabled. As simple as that. | 0 | false | 3 | 4,130 |
2016-01-24 17:42:38.750 | PyCharm & VirtualEnvs - How To Remove Legacy | How do I remove all traces of legacy projects from PyCharm?
Background: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today.
Reason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'.
I deleted the legacy project folders.
I then opened the Pro Editio... | You can clean out old PyCharm interpreters that are no longer associated with a project via Settings -> Project Interpreter, click on the gear in the top right, then click "More". This gives you a listing where you can get rid of old virtualenvs that PyCharm thinks are still around. This will prevent the "(1)", "(2)" p... | 1.2 | true | 3 | 4,130 |
2016-01-25 09:08:16.810 | How to get a socket FD according to the port occupied in Python? | In my program, A serve-forever daemon is restarted in a subprocess.
The program itself is a web service, using port 5000 by default.
I don't know the detail of the start script of that daemon, but it seems to inherit the socket listening on port 5000.
So if I were to restart my program, I'll find that the port is alrea... | It seems like a permission issue. The subprocess is probably running as an other user and therefore you will not have access to the process. Use sudo ps xauw |grep [processname] to figure as under what user the daemon process is running. | 0.201295 | false | 1 | 4,131 |
2016-01-25 12:39:33.483 | how to design rest api which handle offline data | I have multiple api which we have provided to android developers.
Like :
1) Creating Business card API
2) Creating Contacts API
So these api working fine when app is online. So our requirement is to handle to create business card and contacts when app is offline.
We are following steps but not sure:-
1) Android develo... | I'm confused as to how you're approaching this. My understanding is that when the app is offline you want to "queue up" any API requests that are sent.
Your process seems fine however without knowing the terms around the app being "offline" it's hard to understand if this best.
Assuming you're meaning the server(s) ho... | 0 | false | 1 | 4,132 |
2016-01-25 17:10:59.307 | Broadcast large array in pyspark (~ 8GB) | In Pyspark, I am trying to broadcast a large numpy array of size around 8GB. But it fails with the error "OverflowError: cannot serialize a string larger than 4GiB". I have 15g in executor memory and 25g driver memory. I have tried using default and kyro serializer. Both didnot work and show same error.
Can anyone sug... | This is not the problem of PySpark, this is a limit of Spark implement.
Spark use a scala array to store the broadcast elements, since the max Integer of Scala is 2*10^9, so the total string bytes is 2*2*10^9 = 4GB, you can view the Spark code. | 0.201295 | false | 1 | 4,133 |
2016-01-25 20:48:22.280 | How to fix a Deprecation Warning in Django 1.9 | I am a new user of the Django Framework. I am currently building a REST API with the django_rest_framework. When starting my server I am getting deprecation warnings that I have no idea how to fix.
RemovedInDjango110Warning: 'get_all_related_objects is an unofficial API that has been deprecated. You may be able to rep... | You don't have to "fix" Deprecation Warnings as they are, well, only warnings and things still work. However, if you'll decide to update they might break your app. So usually it's a good idea to rewrite the parts with warnings to new interfaces, that are hinted in those warnings if it's in your code. If it's in some si... | 1.2 | true | 1 | 4,134 |
2016-01-25 23:46:13.310 | reading a large dataset in tensorflow | I am not quite sure about how file-queue works. I am trying to use a large dataset like imagenet as input. So preloading data is not the case, so I am wondering how to use the file-queue. According to the tutorial, we can convert data to TFRecords file as input. Now we have a single big TFRecords file. So when we speci... | The amount of pre-fetching depends on your queue capacity. If you use string_input_producer for your filenames and batch for batching, you will have 2 queues - filename queue, and prefetching queue created by batch. Queue created by batch has default capacity of 32, controlled by batch(...,capacity=) argument, therefor... | 1.2 | true | 1 | 4,135 |
2016-01-26 17:57:32.823 | Compare the number of significant digits in two numbers | For a coding exercise I'm working on, I'm trying to compare two numbers and choose the one that has the larger number of significant digits.
For example: compare 2.37e+07 and 2.38279e+07, select 2.38279e+07 because it has more significant digits.
I don't know how to implement this in Python. I considered counting the... | A quick and dirty approach might be len(str(NUMBER).strip('0')) which will trim off any trailing zeros and count the remaining digits.
To discount the decimal point then you'd need len(str(NUMBER).replace('.','').strip('0'))
However you need to bear in mind that in many cases converting a python float to a string can g... | 1.2 | true | 1 | 4,136 |
2016-01-27 18:16:53.340 | How do I use pytest with virtualenv? | I installed pytest into a virtual environment (using virtualenv) and am running it from that virtual environment, but it is not using the packages that I installed in that virtual environment. Instead, it is using the main system packages. (Using python -m unittest discover, I can actually run my tests with the right p... | In my case I was obliged to leave the venv (deactivate), remove pytest (pip uninstall pytest), enter the venv (source /my/path/to/venv), and then reinstall pytest (pip install pytest). I don't known exacttly why pip refuse to install pytest in venv (it says it already present).
I hope this helps | 0.296905 | false | 2 | 4,137 |
2016-01-27 18:16:53.340 | How do I use pytest with virtualenv? | I installed pytest into a virtual environment (using virtualenv) and am running it from that virtual environment, but it is not using the packages that I installed in that virtual environment. Instead, it is using the main system packages. (Using python -m unittest discover, I can actually run my tests with the right p... | There is a bit of a dance to get this to work:
activate your venv : source venv/bin/activate
install pytest : pip install pytest
re-activate your venv: deactivate && source venv/bin/activate
The reason is that the path to pytest is set by the sourceing the activate file only after pytest is actually installed in the ... | 1 | false | 2 | 4,137 |
2016-01-27 20:48:19.570 | How to select which version of python I am running on Linux? | The version of Linux I am working on has python 2.6 by default, and we installed 2.7 on it in a separate folder.
If I want to run a .py script, how do I tell it to use 2.7 instead of the default? | Use update-alternatives --config python and shoose python2.7 from choices.
If you need to remove it use update-alternatives --remove python /usr/bin/python2.7. | 0.201295 | false | 1 | 4,138 |
2016-01-27 22:06:11.487 | Run python program from terminal | I have downloaded a python program from git.
This program is python 3.
On my laptop i have both python 2.7 and python 3.4. Python 2.7 is default version.
when i want run this program in terminal it gives some module errors because of it used the wrong version.
how can i force an name.py file to open in an (non) defaul... | The Method of @Tom Dalton and @n1c9 work for me!
python3 name.py | 1.2 | true | 2 | 4,139 |
2016-01-27 22:06:11.487 | Run python program from terminal | I have downloaded a python program from git.
This program is python 3.
On my laptop i have both python 2.7 and python 3.4. Python 2.7 is default version.
when i want run this program in terminal it gives some module errors because of it used the wrong version.
how can i force an name.py file to open in an (non) defaul... | When you type "python", your path is searched to run this version. But, if you specify the absolute path of the other python, you run it the way you want it.
Here, in my laptop, I have /home/user/python3_4 and /home/user/python2_7. If I type python, the 3.4 version is executed, because this directory is set in my path ... | 0 | false | 2 | 4,139 |
2016-01-28 14:17:33.047 | reading the last index from a csv file using pandas in python2.7 | I have a .csv file on disk, formatted so that I can read it into a pandas DataFrame easily, to which I periodically write rows. I need this database to have a row index, so every time I write a new row to it I need to know the index of the last row written.
There are plenty of ways to do this:
I could read the entir... | Reading the entire index column will still need to read and parse the whole file.
If no fields in the file are multiline, you could scan the file backwards to find the first newline (but with a check if there is a newline past the data). The value following that newline will be your last index.
Storing the last index i... | 1.2 | true | 1 | 4,140 |
2016-01-28 23:33:19.740 | How to copy/paste a dataframe from iPython into Google Sheets or Excel? | I've been using iPython (aka Jupyter) quite a bit lately for data analysis and some machine learning. But one big headache is copying results from the notebook app (browser) into either Excel or Google Sheets so I can manipulate results or share them with people who don't use iPython.
I know how to convert results to c... | Paste the output to an IDE like Atom and then paste in Google Sheets/Excel | 0.067922 | false | 2 | 4,141 |
2016-01-28 23:33:19.740 | How to copy/paste a dataframe from iPython into Google Sheets or Excel? | I've been using iPython (aka Jupyter) quite a bit lately for data analysis and some machine learning. But one big headache is copying results from the notebook app (browser) into either Excel or Google Sheets so I can manipulate results or share them with people who don't use iPython.
I know how to convert results to c... | Try using the to_clipboard() method. E.g., for a dataframe, df: df.to_clipboard() will copy said dataframe to your clipboard. You can then paste it into Excel or Google Docs. | 1.2 | true | 2 | 4,141 |
2016-01-29 08:10:53.933 | Different versions of python when running cmd as admin, how do I alter admin version? | I'm having some trouble tracking down where my pip modules are going, and I finally found what seems to be the root of the issue when I did a "pip list" command in two separate cmd windows.
One window was running as admin, and the other not. They showed two completely different lists of modules installed. When I ran ... | Although you are running Python on a Windows Machine - I am assuming a Client i.e. Desktop. You should go and look at Virtual Python Environments - there are lots of resources documenting how this is accomplished...
You are directly manipulating the System copy of the Python Environment and 1 mistake will screw the wh... | 0.201295 | false | 2 | 4,142 |
2016-01-29 08:10:53.933 | Different versions of python when running cmd as admin, how do I alter admin version? | I'm having some trouble tracking down where my pip modules are going, and I finally found what seems to be the root of the issue when I did a "pip list" command in two separate cmd windows.
One window was running as admin, and the other not. They showed two completely different lists of modules installed. When I ran ... | I couldn't find a solution anywhere to this, so I just deleted every trace of Python from my computer and installed Anaconda.
I don't feel this was a very informed or optimal solution, but I now have consistent behavior in various places. Also, the Anaconda installer seems much more smooth than the pip installer. | 0 | false | 2 | 4,142 |
2016-01-30 19:03:57.710 | Tastypie. How to add time of execution to responses? | I want to measure execution time for some queries and add this data to responses, like: {"meta": {"execution_time_in_ms": 500 ...}} I know how to add fields to tastypie's responses, but I haven't idea how to measure time in it, where I should initialize the timer and where I should stop it. Any ideas? | That'll only work for list endpoints though. My advice is to use a middleware to add X- headers, it's a cleaner, more generalized solution. | 0.135221 | false | 1 | 4,143 |
2016-02-01 17:02:34.580 | Update strategy Python application + Ember frontend on BeagleBone | For the moment I've created an Python web application running on uwsgi with a frontend created in EmberJS. There is also a small python script running that is controlling I/O and serial ports connected to the beaglebone black.
The system is running on debian, packages are managed and installed via ansible, the applicat... | A natural strategy would be to make use of the package manager also used for the rest of the system. The various package managers of Linux distributions are not closed systems. You can create your own package repository containing just your application/scripts and add it as a package source on your target. Your "update... | 0 | false | 1 | 4,144 |
2016-02-02 10:19:57.753 | python - atom IDE how to enable auto-complete code to see all functions from a module | I am using atom IDE for my python projects.
there are auto-complete suggestions in some cases but I'd like to know if it's possible to have a list of all possible functions that a imported module has, for instance if i import
import urllib
when I type urlib. and press (ctrl+tab) would like to see a list with the possi... | Atom is getting various modifications. Autocomplete-python package is a handy package which helps code faster. The way to install it has changed.
In all new Atom editor go to File->Settings->install
search for autocomplete-python
and click on install. Voila its done, restart Atom is not required and you will see the di... | 0.591696 | false | 2 | 4,145 |
2016-02-02 10:19:57.753 | python - atom IDE how to enable auto-complete code to see all functions from a module | I am using atom IDE for my python projects.
there are auto-complete suggestions in some cases but I'd like to know if it's possible to have a list of all possible functions that a imported module has, for instance if i import
import urllib
when I type urlib. and press (ctrl+tab) would like to see a list with the possi... | I found the solution for my own question.
Actually I had the wrong plugin installed!
So, in the IDE, edit->preferences, and in the packages section just typed autocomplete-python and press install button.
After restart Atom, it should start work :) | 0.999823 | false | 2 | 4,145 |
2016-02-02 16:31:22.527 | How to assign a directory to PyCharm | New to python and PyCharm, but trying to use if for an online course.
After opening an assignment .py document (attached image), I get an error message if I open the python console:
Error:Cannot start process, the working directory '\c:...\python_lab.py' is not a directory.
Obviously, it is not - it is a python file,... | Looks like your default working directory is a .tmp folder. Best way to fix this is to create a new project, just make sure it's not pointing to a .tmp directory. | 0.201295 | false | 2 | 4,146 |
2016-02-02 16:31:22.527 | How to assign a directory to PyCharm | New to python and PyCharm, but trying to use if for an online course.
After opening an assignment .py document (attached image), I get an error message if I open the python console:
Error:Cannot start process, the working directory '\c:...\python_lab.py' is not a directory.
Obviously, it is not - it is a python file,... | Create new project
Create new py file in your project or copy your file to under the project directory
Second option would be import existing project by selecting a directory where you have your python file. | 1.2 | true | 2 | 4,146 |
2016-02-02 20:47:41.207 | How to remove code from external release | I want to release a subset of my code for external use. Only certain functions or methods should be used (or even seen) by the external customer. Is there a way to do this in Python?
I thought about wrapping the code I want removed in an if __debug__: and then creating a .pyc file with py_compile or compileall and the... | I don't know if there are any standard tools for doing this, but it shouldn't be too difficult to mark the sections with appropriately coded remarks and then run all your files through a script that outputs a new set of files omitting the lines between those remarks. | 1.2 | true | 1 | 4,147 |
2016-02-02 21:04:51.817 | Theano Dimshuffle equivalent in Google's TensorFlow? | I have seen that transpose and reshape together can help but I don't know how to use.
Eg. dimshuffle(0, 'x')
What is its equivalent by using transpose and reshape? or is there a better way?
Thank you. | tf.transpose is probably what you are looking for. it takes an arbitrary permutation. | 0 | false | 1 | 4,148 |
2016-02-02 21:48:33.893 | Appium Android UI testing - how to verify the style attribute of an element? | I would like to verify the style of an element i.e. the color of the text shown in a textview. Whether it is black or blue ex. textColor or textSize. This information is not listed in the uiautomatorviewer.
I can get the text using elem.get_attribute("text") as the text value is seen in the Node Detail. Is there a wa... | Update. As it turns out that cannot be done with appium webdriver.
For those of you who are wondering this is the answer I rec'd from the appium support group:
This cannot be done by appium as underlying UIAutomator framework does not allow us to do so.
In app's native context this cannot be done
In app's webview's con... | 0.386912 | false | 1 | 4,149 |
2016-02-03 04:59:33.573 | Python: how to open a file and loop through word for word and compare to a list | I have a file that is all strings and I want to loop through the file and check its contents against another file. Both files are too big to place in the code so I have to open each file with open method and then turn each into a loop that iterates over the file word for word (in each file) and compare every word for e... | If the files are both sorted, or if you can produce sorted versions of the files, then this is relatively easy. Your simplest approach (conceptually speaking) would be to take one word from file A, call it a, and then read a word from file B, calling it b. Either b is alphabetically prior to a, or it is after a, or the... | 1.2 | true | 2 | 4,150 |
2016-02-03 04:59:33.573 | Python: how to open a file and loop through word for word and compare to a list | I have a file that is all strings and I want to loop through the file and check its contents against another file. Both files are too big to place in the code so I have to open each file with open method and then turn each into a loop that iterates over the file word for word (in each file) and compare every word for e... | I found the answer. There is a pointer when reading files . The problem is that when using a nested loop it doesn't redirect back to the next statement in the outer loop for Python. | 0 | false | 2 | 4,150 |
2016-02-03 10:25:32.573 | Proper way to close tcp sockets in python | I am currently working on a server + client combo on python and I'm using TCP sockets. From networking classes I know, that TCP connection should be closed step by step, first one side sends the signal, that it wants to close the connection and waits for confirmation, then the other side does the same. After that, sock... | shutdown is useful when you have to signal the remote client that no more data is being sent. You can specify in the shutdown() parameter which half-channel you want to close.
Most commonly, you want to close the TX half-channel, by calling shutdown(1). In TCP level, it sends a FIN packet, and the remote end will recei... | 0.386912 | false | 1 | 4,151 |
2016-02-03 18:31:20.833 | Limiting the number of GB to read in read_csv in Pandas | I often work with csv files that are 100s of GB in size. Is there any way to tell read_csv to only read a fixed number of MB from a csv file?
Update:
It looks like chunks and chunksize can be used for this, but the documentation looks a bit slim here. What would be an example of how to do this with a real csv file? (e... | You can pass nrows=number_of_rows_to_read to your read_csv function to limit the lines that are read. | 0.386912 | false | 1 | 4,152 |
2016-02-03 21:40:50.383 | Default values from wxPython notebook | I'm really sorry if this question sounds really simple but I couldn't figure out the solution yet...
I'm using wxPython in order to create a GUI. I've used wx.Notebook, and created some tabs, all default configuration are located in the last tab.
My question is, how can I get these default values from the last tab and ... | When you create the UI, you can keep the default config in a variable. A dictionary would probably work. Then when you create the tabs, you can pass them a dictionary. Alternatively, you could just save the defaults to a config file and then use Python to read it and load it into the UI. Python can parse csv, json, xml... | 0 | false | 1 | 4,153 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.