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-10-17 14:11:08.787 | Making an alias for an attribute field, to be used in a django queryset | In Django, how does one give an attribute field name an alias that can be used to manipulate a queryset?
Background: I have a queryset where the underlying model has an auto-generating time field called "submitted_on". I want to use an alias for this time field (i.e. "date"). Why? Because I will concatenate this query... | It seems qset1 = qset1.annotate(date=Max('submitted_on')) is the closest I have right now. This, or using exclude(). I'll update if I get a better solution. Of course other experts from SO are welcome to chime in with their own answers. | 1.2 | true | 2 | 3,984 |
2015-10-17 14:11:08.787 | Making an alias for an attribute field, to be used in a django queryset | In Django, how does one give an attribute field name an alias that can be used to manipulate a queryset?
Background: I have a queryset where the underlying model has an auto-generating time field called "submitted_on". I want to use an alias for this time field (i.e. "date"). Why? Because I will concatenate this query... | Even if you could do this, it wouldn't help solve your ultimate problem. You can't use order_by on concatenated querysets from different models; that can't possibly work, since it is a request for the database to do an ORDER BY on the query. | 0 | false | 2 | 3,984 |
2015-10-20 08:01:24.123 | Selenium on server | I'm quite new to whole Selenim thing and I have a simple question.
When I run tests (Django application) on my local machine, everything works great. But how this should be done on server? There is no X, so how can I start up webdriver there? What's the common way?
Thanks | I suggest you use a continuous integration solution like Jenkins to run your tests periodically. | 0 | false | 1 | 3,985 |
2015-10-20 10:35:13.797 | Access pixel values within a contour boundary using OpenCV in Python | I'm using OpenCV 3.0.0 on Python 2.7.9. I'm trying to track an object in a video with a still background, and estimate some of its properties. Since there can be multiple moving objects in an image, I want to be able to differentiate between them and track them individually throughout the remaining frames of the video.... | Answer from @rayryeng is excellent!
One small thing from my implementation is:
The np.where() returns a tuple, which contains an array of row indices and an array of column indices. So, pts[0] includes a list of row indices, which correspond to height of the image, pts[1] includes a list of column indices, which corres... | 0.386912 | false | 1 | 3,986 |
2015-10-20 11:58:18.313 | How to verify that we have logged in correctly to a website using requests in python? | I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if... | HTTP status codes are usually meant for the browsers, or in case of APIs for the client talking to the server. For normal web sites, using status codes for semantical error information is not really useful. Overusing the status codes there could even cause the browser to not render responses correctly.
So for normal HT... | 1.2 | true | 2 | 3,987 |
2015-10-20 11:58:18.313 | How to verify that we have logged in correctly to a website using requests in python? | I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if... | What status code the site responds with depends entirely on their implementation; you're more likely to get a non-200 response if you're attempting to log in to a web service. If a login attempt yielded a non-200 response on a normal website, it'd require a special handler on their end, as opposed to a 200 response wit... | 0 | false | 2 | 3,987 |
2015-10-20 15:52:07.307 | Handling a literal space in a filename | I have problem with os.access(filename, os.R_OK) when file is an absolute path on a Linux system with space in the filename. I have tried many ways of quoting the space, from "'" + filename + "'" to filename.replace(' ', '\\ ') but it doesn't work.
How can I escape the filename so my shell knows how to access it? In te... | You don't need to (and shouldn't) escape the space in the file name. When you are working with a command line shell, you need to escape the space because that's how the shell tokenizes the command and its arguments. Python, however, is expecting a file name, so if the file name has a space, you just include the space. | 1.2 | true | 1 | 3,988 |
2015-10-22 05:22:08.870 | how to list all users who tweeted a given keyword using twitter api and tweepy | How to list name of users who tweeted with given keyword along with count of tweets from them ?
I am using python and tweepy.
I used tweepy to list JSON result in a file by filter(track["keyword"])
but doesn't know how to list users who tweeted given keyword. | Once your data has been loaded into JSON format, you can access the username by calling tweet['user']['screen_name']. Where tweet is whatever varibale you have assigned that holds the JSON object for that specific tweet. | 1.2 | true | 1 | 3,989 |
2015-10-23 04:12:56.640 | Login in from Phone App | I have developed a Python/Django application for a company. In this app all the employees of the company have a username and a password to login in. Now there is a need for a phone application that can do some functionality.
In some functions I have the decorator @login_required
For security reasons I would like to wor... | You would need to either expose the django token in the settings file so that it can be accessed via jquery, or that decorator wont be accessible via mobile. Alternatively, you can start using something like oauth | 0 | false | 1 | 3,990 |
2015-10-24 17:19:58.503 | How to get token value while sending post requests | I am trying to extract the data from webpage after log in. To log in website, i can see the token (authenticity_token) in Form Data section. It seems, token generating automatically.I am trying to get token values but no luck.Please anyone help me on this,how to get the token value while sending the post requests. | You need to get the response from the page then regex match for token. | 0 | false | 2 | 3,991 |
2015-10-24 17:19:58.503 | How to get token value while sending post requests | I am trying to extract the data from webpage after log in. To log in website, i can see the token (authenticity_token) in Form Data section. It seems, token generating automatically.I am trying to get token values but no luck.Please anyone help me on this,how to get the token value while sending the post requests. | token value is stored in the cookie file..check the cookie file and extract the value from it..
for example,a cookie file after login contain jsession ID=A01~xxxxxxx
where 'xxxxxxx' is the token value..extract this value..and post this value | 0 | false | 2 | 3,991 |
2015-10-25 10:41:05.717 | How to organize groups in Django? | I am currently learning how to use Django. I want to make a web app where you as a user can join groups. These groups have content that just members of this group should be able to see. I learned about users, groups and a bit of authentication.
My first impression is, that this is more about the administration of the ... | Groups in django (django.contrib.auth) are used to specify certain rights of viewing content mainly in the admin to certain users. I think your group functionality might be more custom than this and that you're better of creating your own group models, and making your own user and group management structure that suits ... | 0 | false | 1 | 3,992 |
2015-10-26 18:50:30.367 | Architectual pattern for CLI tool | I am going to write some HTTP (REST) client in Python. This will be a Command Line Interface tool with no gui. I won't use any business logic objects, no database, just using an API to communicate with the server (using Curl). Would you recommend me some architectual patterns for doing that, except for Model View Contr... | Since your app is not very complex, I see 2 layers here:
ServerClient: it provides API for remote calls and hides any details. It knows how to access HTTP server, provide auth, deal with errors etc. It has methods like do_something_good() which anyone may call and do not care if it remote method or not.
CommandLine: i... | 1.2 | true | 1 | 3,993 |
2015-10-26 19:25:00.217 | How do I fix the 'BlobService' is not defined' error | I've installed the azure SDK for Python (pip install azure).
I've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook.
I've replaced all the place holders in the script with actual values as noted in the scripts comments.
When I run the script I get the e... | James, I figured it out. I just changed from azure.storage import * to azure.storage.blob import * and it seems to be working. | 0.101688 | false | 3 | 3,994 |
2015-10-26 19:25:00.217 | How do I fix the 'BlobService' is not defined' error | I've installed the azure SDK for Python (pip install azure).
I've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook.
I've replaced all the place holders in the script with actual values as noted in the scripts comments.
When I run the script I get the e... | It's been a long time since I did any Python, but BlobStorage is in the azure.storage.blob namespace I believe.
So I don't think your from azure.storage import * is pulling it in.
If you've got a code sample in a book which shows otherwise it may just be out of date. | 0 | false | 3 | 3,994 |
2015-10-26 19:25:00.217 | How do I fix the 'BlobService' is not defined' error | I've installed the azure SDK for Python (pip install azure).
I've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook.
I've replaced all the place holders in the script with actual values as noted in the scripts comments.
When I run the script I get the e... | BlobService is function you are trying to call, but it is not defined anywhere. It should be defined when you call from azure.storage import *. It is probably not being called, due to a difference in package versions.
Calling from azure.storage.blob import * should work, as it is now invoked correctly. | 0 | false | 3 | 3,994 |
2015-10-29 03:21:37.497 | How to change build path on PyDev | In eclipse, I'm used to configuring the buildpath for versions of java installed on my computer.
I recently added Python 3.5 to my computer and want to use it in place of the default 2.7 that Macs automatically include.
How can I configure my build path on PyDev, if there is such as concept to begin with, for the plug... | First check whether python3.5 is auto-configured in eclipse.
Go to Window>Preferences
On the preferences window you will find PyDev configurations on left pan.
PyDev>Interpreters>Python Interpreter
If python3.5 is not listed you can either add using "Quick Auto-Config" or if you want to add manually click "New" then a... | 1.2 | true | 1 | 3,995 |
2015-10-29 15:26:38.267 | removing an element from a linked list in python | I was wondering if any of you could give me a walk through on how to remove an element from a linked list in python, I'm not asking for code but just kinda a pseudo algorithm in english. for example I have the linked list of
1 -> 2 -> 2 -> 3 -> 4 and I want to remove one of the 2's how would i do that? I thought of tr... | You can do something like:
if element.next.value == element.value:
element.next = element.next.next
Just be carefull to free the memory if you are programing this in C/C++ or other language that does not have GC | 0 | false | 2 | 3,996 |
2015-10-29 15:26:38.267 | removing an element from a linked list in python | I was wondering if any of you could give me a walk through on how to remove an element from a linked list in python, I'm not asking for code but just kinda a pseudo algorithm in english. for example I have the linked list of
1 -> 2 -> 2 -> 3 -> 4 and I want to remove one of the 2's how would i do that? I thought of tr... | You don't need to "delete" the node, just "skip" it. That is, change Node1's next member to the second Node2.
Edit your question if you would like specific code examples (which are the norm for this site). | 0 | false | 2 | 3,996 |
2015-10-29 15:41:06.030 | tkinter opencv and numpy in windows with python2.7 | I want to use "tkinter", "opencv" (cv2) and "numpy" in windows(8 - 64 bit and x64) with python2.7 - the same as I have running perfectly well in Linux (Elementary and DistroAstro) on other machines. I've downloaded the up to date Visual Studio and C++ compiler and installed these, as well as the latest version of PIP f... | Finally did it with .whl files. Download them, copy to C:\python27\Scripts and then open "cmd" and navigate to that folder with "cd\" etc. Once there run:
pip install numpy-1.10.1+mkl-cp27-none-win_amd64.whl
for example.
In IDLE I then get:
import numpy
numpy.version
'1.10.1' | 0 | false | 2 | 3,997 |
2015-10-29 15:41:06.030 | tkinter opencv and numpy in windows with python2.7 | I want to use "tkinter", "opencv" (cv2) and "numpy" in windows(8 - 64 bit and x64) with python2.7 - the same as I have running perfectly well in Linux (Elementary and DistroAstro) on other machines. I've downloaded the up to date Visual Studio and C++ compiler and installed these, as well as the latest version of PIP f... | small remark: WinPython has tkinter, as it's included by Python Interpreter itself | 0 | false | 2 | 3,997 |
2015-10-29 17:14:21.793 | Padding python pivot tables with 0 | I have a pivot table which has an index of dates ranging from 01-01-2014 to 12-31-2015. I would like the index to range from 01-01-2013 to 12-31-2016 and do not know how without modifying the underlying dataset by inserting a row in my pandas dataframe with those dates in the column I want to use as my index for the pi... | I'm going to be general here, since there was no sample code or data provided. Let's say your original dataframe is called df and has columns Date and Sales.
I would try creating a list that has all dates from 01-01-2014 to 12-31-2015. Let's call this list dates. I would also create an empty list called sales (i.e. sal... | 0 | false | 1 | 3,998 |
2015-10-31 09:20:14.220 | Sublime Text: run code in a new file without saving to disk and the default language setting for a new file | I am using Sublime Text Editor for Python development. If I create a new file by Ctrl + N, the default language setting for this file is Plain Text, so how to change the default language setting for the new file to be Python ?
Another question :If I write some code in the new file and have not save it to disk, it is im... | The second question about running without saving to hard disk:
1-press ctrl + shift + p
2- write install package and install it
3- write "auto save" and install it
4- go to preferences> package settings> Auto-save> Settings Default and copy all the code
5- go to preferences> package settings> Auto-save> Settings user ... | 0.201295 | false | 1 | 3,999 |
2015-10-31 09:59:20.643 | Combining SVM Classifiers in MapReduce | I've been tasked with solving a sentiment classification problem using scikit-learn, python, and mapreduce. I need to use mapreduce to parallelize the project, thus creating multiple SVM classifiers. I am then supposed to "average" the classifiers together, but I am not sure how that works or if it is even possible. Th... | Make sure that all of the required libraries (scikit-learn, NumPy, pandas) are installed on every node in your cluster.
Your mapper will process each line of input, i.e., your training row and emit a key that basically represents the fold for which you will be training your classifier.
Your reducer will collect the lin... | 0 | false | 1 | 4,000 |
2015-11-01 03:15:16.877 | how to make 1 by n dataframe from series in pandas? | I have a huge dataframe, and I index it like so:
df.ix[<integer>]
Depending on the index, sometimes this will have only one row of values. Pandas automatically converts this to a Series, which, quite frankly, is annoying because I can't operate on it the same way I can a df.
How do I either:
1) Stop pandas from con... | You can do df.ix[[n]] to get a one-row dataframe of row n. | 1.2 | true | 1 | 4,001 |
2015-11-01 16:16:42.010 | How exactly BIC in Augmented Dickey–Fuller test work in Python? | This question is on Augmented Dickey–Fuller test implementation in statsmodels.tsa.stattools python library - adfuller().
In principle, AIC and BIC are supposed to compute information criterion for a set of available models and pick up the best (the one with the lowest information loss).
But how do they operate in the ... | When we request automatic lag selection in adfulller, then the function needs to compare all models up to the given maxlag lags. For this comparison we need to use the same observations for all models. Because lagged observations enter the regressor matrix we loose observations as initial conditions corresponding to th... | 1.2 | true | 1 | 4,002 |
2015-11-01 17:43:05.513 | Django Migrations - how to insert just one model? | I just made a mess in my local Django project and realized that somehow I'm out of sync with my migrations. I tried to apply initial and realized that some of the tables already exist, so I tried --fake. This made the migration pass, but now I'm missing the one table I just wanted to add... how can I prepare migration ... | I was using a models directory. Adding an import of the model to __init__.py allowed me to control whether it's visible to makemigrations or not. I found that using strace. | 1.2 | true | 1 | 4,003 |
2015-11-01 18:32:25.747 | What is a good way to implement several very similar functions? | I need several very similar plotting functions in python that share many arguments, but differ in some and of course also differ slightly in what they do. This is what I came up with so far:
Obviously just defining them one after the other and copying the code they share is a possibility, though not a very good one, I... | More information needs to be given to fully understand the context. But, in a general sense, I'd do a mix of all of them. Use helper functions for "shared" parts, and use conditional statements too. Honestly, a lot of it comes down to just what is easier for you to do? | 0 | false | 1 | 4,004 |
2015-11-02 02:00:16.973 | Extracting certain rows from a file that match a condition from another file | So first, I know there are some answers out there for similar questions, but...my problem has to do with speed and memory efficiency.
I have a 60 GB text file that has 17 fields and 460,368,082 records. Column 3 has the ID of the individual and the same individual can have several records in this file. Lets call this f... | It sounds like what you want to do is first read File B, collecting the IDs. You can store the IDs in a set or a dict.
Then read File A. For each line in File A, extract the ID, then see if it was in File B by checking for membership in your set or dict. If not, then skip that line and continue with the next line. ... | 0 | false | 1 | 4,005 |
2015-11-03 15:37:13.853 | Async execution of commands in Python | Requirement - I want to execute a command that uses ls, grep, head etc using pipes (|). I am searching for some pattern and extracting some info which is part of the query my http server supports.
The final output should not be too big so m assuming stdout should be good to use (I read about deadlock issues somewhere)
... | You could use os.listdir or os.walk instead of ls, and the re module instead of grep.
Wrap everything up in a function, and use e.g. the map method from a multiprocessing.Pool object to run several of those in parallel. This is a pattern that works very well.
In Python3 you can also use Executors from concurrent.future... | 0.386912 | false | 1 | 4,006 |
2015-11-03 18:19:27.050 | How to add padding to a widget, but not the entire row's widgets, in tkinter? | I have an large frame of a wide array of elements. Within this frame, there are basically two different sides to the frame. Consider a widget x on the left side, which is placed by .grid(row=4, column=0). Padding is added to this object x, so it is actually x.grid(row=4, column=0, pady=10) Well, the opposite object, ob... | The very definition of a row is that is the same height all the way across. That's what makes it a row. The same can be said for columns.
Therefore, the tallest item in a row (height plus padding) is what controls the overall height of the row. The only control you have over smaller widgets is which sides of their too-... | 0 | false | 1 | 4,007 |
2015-11-03 23:09:05.937 | Can scrapy control and show a browser like Selenium does? | When I use Selenium I can see the Browser GUI, is it somehow possible to do with scrapy or is scrapy strictly command line based? | Scrapy by itself does not control browsers.
However, you could start a Selenium instance from a Scrapy crawler. Some people design their Scrapy crawler like this. They might process most pages only using Scrapy but fire Selenium to handle some of the pages they want to process. | 0.135221 | false | 1 | 4,008 |
2015-11-04 05:26:17.273 | disabling Cookies on phantomjs using selenium with python | I have searched for long time but I could not find how to disable cookies for phantomjs using selenium with python . I couldn't understand the documentation of phantomjs.Please someone help me. | Documentation suggests this driver.cookies_enabled = False, you can use it. | 1.2 | true | 1 | 4,009 |
2015-11-05 10:06:25.167 | How to find the last row in a column using openpyxl normal workbook? | I'm using openpyxl to put data validation to all rows that have "Default" in them. But to do that, I need to know how many rows there are.
I know there is a way to do that if I were using Iterable workbook mode, but I also add a new sheet to the workbook and in the iterable mode that is not possible. | ws.max_row will give you the number of rows in a worksheet.
Since version openpyxl 2.4 you can also access individual rows and columns and use their length to answer the question.
len(ws['A'])
Though it's worth noting that for data validation for a single column Excel uses 1:1048576. | 1.2 | true | 1 | 4,010 |
2015-11-05 17:25:40.517 | Crashing MR-3020 | I've got several MR-3020's that I have flashed with OpenWRT and mounted a 16GB ext4 USB drive on it. Upon boot, a daemon shell script is started which does two things:
1) It constantly looks to see if my main program is running and if not starts up the python script
2) It compares the lasts heartbeat timestamp generate... | It could be related to many things: things that I had to fix also: check the external power supply of the router, needs to be stable, the usb drives could drain too much current than the port can handle, a simple fix is to add a externally powered usbhub or the same port but with capacitors in parallel to the powerlin... | 0 | false | 1 | 4,011 |
2015-11-05 17:34:31.137 | How to monitor a AWS S3 bucket with python using boto? | I have access to a S3 bucket. I do not own the bucket. I need to check if new files were added to the bucket, to monitor it.
I saw that buckets can fire events and that it is possible to make use of Amazon's Lambda to monitor and respond to these events. However, I cannot modify the bucket's settings to allow this.
My ... | You are correct that AWS Lambda can be triggered when objects are added to, or deleted from, an Amazon S3 bucket. It is also possible to send a message to Amazon SNS and Amazon SQS. These settings needs to be configured by somebody who has the necessary permissions on the bucket.
If you have no such permissions, but yo... | 1.2 | true | 1 | 4,012 |
2015-11-06 23:37:48.317 | How do crossover.io, WAMP, twisted (+ klein), and django/flask/bottle interact? | As I understand it (please do correct misunderstandings, obviously), the mentioned projects/technologies are as follows:-
Crossover.io - A router for WAMP. Cross-language.
WAMP - An async message passing protocol, supporting (among other things) Pub/Sub and RPC. Cross-language.
twisted - An asynchronous loop, primarily... | With a Web app using WAMP, you have two separate mechanisms: Serving the Web assets and the Web app then communicating with the backend (or other WAMP components).
You can use Django, Flask or any other web framework for serving the assets - or the static Web server integrated into Crossbar.io.
The JavaScript you deli... | 0 | false | 1 | 4,013 |
2015-11-07 21:04:04.703 | finding a local maximum in a 3d array (array of images) in python | I'm trying to implement a blob detector based on LOG, the steps are:
creating an array of n levels of LOG filters
use each of the filters on the input image to create a 3d array of h*w*n where h = height, w = width and n = number of levels.
find a local maxima and circle the blob in the original image.
I already crea... | I'd take advantage of the fact that dilations are efficiently implemented in OpenCV. If a point is a local maximum in 3d, then it is also in any 2d slice, therefore:
Dilate each image in the array with a 3x3 kernel, keep as candidate maxima the points whose intensity is unchanged.
Brute-force test the candidates again... | 0 | false | 1 | 4,014 |
2015-11-09 06:03:00.040 | Create a "spotlight" in an image using Python | Here's what I'm trying to do:
I have an image.
I want to take a circular region in the image, and have it appear as normal.
The rest of the image should appear darker.
This way, it will be as if the circular region is "highlighted".
I would much appreciate feedback on how to do it in Python.
Manually, in Gimp, I wou... | I finally did it with ImageMagick, using Python to calculate the various coordinates, etc.
This command will create the desired circle (radius 400, centered at (600, 600):
convert -size 1024x1024 xc:none -stroke black -fill steelblue -strokewidth 1 -draw "translate 600,600 circle 0,0 400,0" drawn.png
This command will... | 1.2 | true | 1 | 4,015 |
2015-11-09 17:42:44.583 | Add markeredges in seaborn lmplot? | sns.lmplot(x="size", y="tip", data=tips)
gives a scatter plot. By default the markers have no edges.
How can I add markeredges? Sometimes I prefer to use edges transparent facecolor. Especially with dense data. However,
Neither markeredgewidth nor mew nor linewidths are accepted as keywords.
Does anyone know how to a... | As per the comment from @Sören, you can add the markeredges with the keyword scatter_kws. For example scatter_kws={'linewidths':1,'edgecolor':'k'} | 0.386912 | false | 1 | 4,016 |
2015-11-10 10:23:54.257 | How to allow an user of a group to modify specific parts of a form in Odoo? | I've created a new group named accountant. If an user of this group opens the res.partner form for example, he must be able to read all, but only modify some specific fields (the ones inside the tab Accountancy, for example).
So I set the permissions create, write, unlink, read to 0, 1, 0, 1 in the res.partner model fo... | You cannot make few or some of the fields as 'readonly' in odoo based on the groups. If you need to do it, you can use the custom module 'smile_model_access_extension'.
For loading appropriate view on menu click you can create record of 'ir.actions.act_window' (view_ids) field of 'ir.action', where you can specify the... | 0.201295 | false | 1 | 4,017 |
2015-11-10 11:13:18.143 | Python Opencv morphological closing gives src data type = 0 is not supported | I'm trying to morphologically close a volume with a ball structuring element created by the function SE3 = skimage.morphology.ball(8).
When using closing = cv2.morphologyEx(volume_start, cv2.MORPH_CLOSE, SE) it returns TypeError: src data type = 0 is not supported
Do you know how to solve this issue?
Thank you | Make sure volume_start is dtype=uint8. You can convert it with volume_start = np.array(volume_start, dtype=np.uint8).
Or nicer:
volume_start = volume_start.astype(np.uint8) | 0.999999 | false | 1 | 4,018 |
2015-11-10 12:36:02.920 | what is update_against_templates in pootle 2.7? | I added a new template file from my project. Now I don't know how to make the languages update or get the new template file. I've read that 2.5 has update_against_templates but it's not in 2.7. How will update my languages? | Template updates now happen outside of Pootle. The old update_against_template had performance problems and could get Pootle into a bad state. To achieve the same functionality as update_against_templates do the following. Assuming your project is myproject and you are updating language af:
sync_store --project=myp... | 1.2 | true | 1 | 4,019 |
2015-11-10 19:29:02.980 | Visual Studio 2015 IronPython | So recently I've thought about trying IronPython. I've got my GUI configured, I got my .py file. I click Start in Visual Studio, and that thing pops up: The environment "Unknown Python 2.7 [...]". I have the environment in Solution Explorer set to the Unknown Python 2.7 and I have no idea how to change it. Installed 2.... | Go to Project -> Properties -> General -> Interpreter
Set the Interpreter to IronPython 2.7 (you may need to install it). | 0.101688 | false | 2 | 4,020 |
2015-11-10 19:29:02.980 | Visual Studio 2015 IronPython | So recently I've thought about trying IronPython. I've got my GUI configured, I got my .py file. I click Start in Visual Studio, and that thing pops up: The environment "Unknown Python 2.7 [...]". I have the environment in Solution Explorer set to the Unknown Python 2.7 and I have no idea how to change it. Installed 2.... | Generally the best approach to handle this is to right click "Python Environments" in Solution Explorer, then select "Add/remove environments" and change what you have added in there. | 0.296905 | false | 2 | 4,020 |
2015-11-11 07:23:05.910 | Python, Django - how to store http requests in the middleware? | It might be that this question sounds pretty silly but I can not figure out how to do this I believe the simplest issue (because just start learning Django).
What I know is I should create a middleware file and connect it to the settings. Than create a view and a *.html page that will show these requests and write it t... | You can implement your own RequestMiddleware (which plugs in before the URL resolution) or ViewMiddleware (which plugs in after the view has been resolved for the URL).
In that middleware, it's standard python. You have access to the filesystem, database, cache server, ... the same you have anywhere else in your code.
... | 0.386912 | false | 1 | 4,021 |
2015-11-11 08:39:02.993 | Is it possible to set multiple callback functions for a given event with GTK (Python)? | If so, how would this be done? If not, is there a conventional way to achieve the same effect? | Thank you, PM 2Ring.
For posterity, the answer is that you can bind multiple callbacks to a signal in GTK3. They will be called in the order they were bound in. | 1.2 | true | 1 | 4,022 |
2015-11-12 13:26:26.947 | Reading text from a file, then writing to another file with repetitions in text marked | I'm a beginner to both Python and to this forum, so please excuse any vague descriptions or mistakes.
I have a problem regarding reading/writing to a file. What I'm trying to do is to read a text from a file and then find the words that occur more than one time, mark them as repeated_word and then write the original ... | OK. I presume that this is a homework assignment, so I'm not going to give you a complete solution. But, you really need to do a number of things.
The first is to read the input file in to memory. Then split it in to its component words (tokenize it) probably contained in a list, suitably cleaned up to remove stray pu... | 0 | false | 1 | 4,023 |
2015-11-12 17:46:11.747 | Reverse-engineering a clustering algorithm from the clusters | I have a clustering of data performed by a human based solely on their knowledge of the system. I also have a feature vector for each element. I have no knowledge about the meaning of the features, nor do I know what the reasoning behind the human clustering was.
I have complete information about which elements belong ... | Are you sure it was done automatically?
It sounds to me as if you should be treating this as a classification problem: construct a classifier that does the same as the human did. | 0 | false | 1 | 4,024 |
2015-11-13 11:10:21.483 | How to implement LIFO for multiprocessing.Queue in python? | I understand the difference between a queue and stack. But if I spawn multiple processes and send messages between them put in multiprocessing.Queue how do I access the latest element put in the queue first? | The multiprocessing.Queue is not a data type. It is a mean to communicate between two processes. It is not comparable to Stack
That's why there is no API to pop the last item off the queue.
I think what you have in mind is to make some messages to have a higher priority than others. When they are sent to the listening ... | -0.93111 | false | 1 | 4,025 |
2015-11-13 15:34:41.283 | pdb: how to show the current line, instead of continuing after the previous listing? | when using pdb to debug a python script, repeating l command will continue listing the source code right after the previous listing.
l(ist) [first[, last]] List source code for the current file. Without
arguments, list 11 lines around the current line or continue the
previous listing. With one argument, list 11 lin... | The direct way, of course, is to pass the line as an argument to l.
But without having to go through the trouble of finding the current line and typing it, the non-optimal way I usually do it is to return to the same line by navigating up+down the call stack, then listing again. The sequence of commands for that is: u ... | 0.673066 | false | 1 | 4,026 |
2015-11-13 16:54:49.917 | SublimeText 3 Anaconda autocomplete bug | I'm new to SublimeText and Python3, so I don't really know how to turn Sublime autocomplete on. I installed Anaconda from Package Control, but I don't know how to use it. Some autocomplete shows up, but I don't think it's Anaconda's. That autocomplete keeps on poping up, then dissapearing. I can't read what it says and... | in case you are still looking for the answer, I had a similar problem. I had both SublimeJEDI autocompletion as well as Anaconda.
The flashing behavior is a result of you having two separate autocompletes fighting for the same space.
Turning off SublimeJEDI solved this for me - I couldn't find a way to turn off Anaco... | 1.2 | true | 1 | 4,027 |
2015-11-17 12:06:59.600 | Programmatically create confluence content from jira and fisheye | I'm curious, how a good automated workflow could look like for the process of automating issues/touched file lists into a confluence page. I describe my current idea here:
Get all issues matching my request from JIRA using REST (DONE)
Get all touched files related to the matching Issues using Fisheye REST
Create a .ad... | I did something similar - getting info from Jira and updating confluence info.
I did it in a bash script that ran on Jenkins. The script:
Got Jira info using the Jira REST API
Parsed the JSON from Jira using jq (wonderful tool)
Created/updated the confluence page using the Confluence REST API
I have not used python b... | 0.386912 | false | 1 | 4,028 |
2015-11-17 12:29:45.300 | How can I blur or pixify images in python by using matrixes? | I already have a function that converts an image to a matrix, and back. But I was wondering how to manipulate the matrix so that the picture becomes blurry, or pixified? | To make it blurry filter it using any low-pass filter (mean filter, gaussian filter etc.). | 0 | false | 1 | 4,029 |
2015-11-17 15:47:57.817 | How to efficiently import the same module into multiple sub-packages in python | I want to create a Python package that has multiple subpackages. Each of those subpackages contain files that import the same specific module that is quite large in size.
So as an example, file A.py from subpackage A will import a module that is supposedly named LargeSizedModule and file B.py from subpackage B will al... | By doing import LargeSizedModule everywhere you need it. Python will only load it once. | 1.2 | true | 1 | 4,030 |
2015-11-18 11:24:40.627 | How to apply sklearn's EllipticEnvelope to find out top outliers in the given dataset? | I am using sklearn's EllipticEnvelope to find outliers in dataset. But I am not sure about how to model my problem? Should I just use all the data (without dividing into training and test sets) and apply fit? Also how would I obtain the outlyingness of each datapoint? Should I use predict on the same dataset? | Right way to do this is:
Divide data into normal and outliers.
Take large sample from normal data as normal_train for fitting the novelty detection model.
Create a test set with a sample from normal that is not used in training (say normal_test) and a sample from outlier (say outlier_test) in a way such that the distr... | 1.2 | true | 1 | 4,031 |
2015-11-19 10:07:11.903 | create asynchronous requests on fly using greqeusts | So I know that you could use grequests create multiple requests and use map to process them at the same time. But how do you create some requests on the fly while some requests sent have not returned a response yet? I don't want to use multiprocessing or multithreading,is there a way to use grequests to realize it? | Just use the regular requests library for this. A call to res = requests.get(...) is asynchronous anyway, it will not block until you call something like "res.content". Is this what you are looking for? | 0 | false | 1 | 4,032 |
2015-11-19 10:30:58.607 | Python: How to calculate scores and how to exercise a time limit? | I am new to programming, in fact I take a class at school and I am not very good. My assignment is to write a quiz and with every question, the person has 60 seconds to answer the question and with every right answer their score doubles.
Please help. | When displaying a question — store current time to some variable. Then after user provided answer, calculate difference between current time and the time stored at previous step. Check if it exceeds 60 seconds limit or not. | 0 | false | 1 | 4,033 |
2015-11-20 15:46:57.687 | Google App Engine File Processing | I am trying to create a process that will upload a file to GAE to interpret it's contents (most are PDFs, so we would use something like PDF Miner), and then store it in Google Cloud Storage.
To my understanding, the problem is that file uploads are limited to both 60 seconds for it to execute, as well as a size limit ... | your best bet could upload to blobstore or Cloud Storage, then use Task Queue to process the file which has no time limits. | 0 | false | 1 | 4,034 |
2015-11-21 07:37:48.080 | Jump to certain line in IDLE? | I use IDLE when I'm coding in Python and really enjoy it's simplicity. One thing I don't like though is when you need to navigate to a certain line and have to scroll around the place, haphazardly guessing how far you have to go to reach it. So, my question is is there a way to jump to a certain line number in IDLE f... | Edit then go to line :D
or Alt + G | 0 | false | 1 | 4,035 |
2015-11-21 11:46:03.183 | check if a key exists in a bucket in s3 using boto3 | I would like to know if a key exists in boto3. I can loop the bucket contents and check the key if it matches.
But that seems longer and an overkill. Boto3 official docs explicitly state how to do this.
May be I am missing the obvious. Can anybody point me how I can achieve this. | Just following the thread, can someone conclude which one is the most efficient way to check if an object exists in S3?
I think head_object might win as it just checks the metadata which is lighter than the actual object itself | 0.017005 | false | 1 | 4,036 |
2015-11-22 05:45:05.873 | How to get a standalone python script to get data from my django app? | I am currently learning how to use django. I have a standalone python script that I want to communicate with my django app. However, I have no clue how to go about doing this. My django app has a login function and a database with usernames and passwords. I want my python script to talk to my app and verify the persons... | If I understand you correctly, you're looking to have an external program communicate with your server. To do this, the server needs to expose an API (Application Interface) that communicates with the external program. That interface will receive a message and return a response.
The request will need to have two thi... | 1.2 | true | 1 | 4,037 |
2015-11-23 01:25:22.737 | IPython notebook: how to reload all modules in a specific Python file? | I define many modules in a file, and add from myFile import * to the first line of my ipython notebook so that I can use it as dependency for other parts in this notebook.
Currently my workflow is:
modify myFile
restart the Ipython kernel
rerun all code in Ipython.
Does anyone know if there is a way to reload all mod... | You should you start your workflow after restarting and opening a notebook again by running all cells. In the top menu, before you do anything else, first select "Cell->Run all" | -0.964028 | false | 1 | 4,038 |
2015-11-23 09:52:10.590 | Pip Wheel Package Installation Fail | I try to run pip wheel azure-mgmt=0.20.1, but whenever I run it I get following pip wheel error, which is very clear:
error: [Error 183] Cannot create a file when that file already exists: 'build\\bdist.win32\\wheel\\azure_mgmt-0.20.0.data\\..'
So my question is where or how I can find that path? I want to delete that ... | have you tried uninstalling and reinstalling?
I tried pip wheel azure-mgmt and that installed -0.20.1 for me.
The directory for mine is /Users/me/wheelhouse, so you could look there. I found that in the initial log of the build. | 0 | false | 1 | 4,039 |
2015-11-25 05:26:31.900 | python accessing and updating mysql from simultaneously running processes | I have 2 different python processes (running from 2 separate terminals) running separately at the same time accessing and updating mysql. It crashes when they are using same table at the same time. Any suggestions on how to fix it? | Are you using myisam or innodb? I suggest using innodb since it has a better table/record locking flexibility for multiple simultaneous updates. | 0 | false | 1 | 4,040 |
2015-11-25 21:28:28.037 | Converting coordinates vector to numpy 2D matrix | I have a set of 3D coordinates points: [lat,long,elevation] ([X,Y,Z]), derived from LIDAR data.
The points are not sorted and the steps size between the points is more or less random.
My goal is to build a function that converts this set of points to a 2D numpy matrix of a constant number of pixels where each (X,Y) cel... | I am aware that I am not answering half of your questions but this is how I would do it:
Create a 2D array of the desired resolution,
The "leftmost" values correspond to the smallest values of x and so forth
Fill the array with the elevation value of the closest match in terms of x and y values
Smoothen the result. | 0 | false | 1 | 4,041 |
2015-11-26 13:56:43.187 | Unit-testing a periodic coroutine with mock time | I'm using Tornado as a coroutine engine for a periodic process, where the repeating coroutine calls ioloop.call_later() on itself at the end of each execution. I'm now trying to drive this with unit tests (using Tornado's gen.test) where I'm mocking the ioloop's time with a local variable t:
DUT.ioloop.time = mock.Mock... | In general, using yield gen.moment to trigger specific events is dicey; there are no guarantees about how many "moments" you must wait, or in what order the triggered events occur. It's better to make sure that the function being tested has some effect that can be asynchronously waited for (if it doesn't have such an e... | 1.2 | true | 1 | 4,042 |
2015-11-27 21:13:24.903 | Python: function menu not working | I am having trouble with a menu that allows the user to choose which function to call. Part of the problem is that when I run the program it starts from the beginning (instead of calling the menu function), and the other part is that I don't know how to pass the table and the number of rows and columns from the first f... | In order to pass a variable from a function to another it needs to be ‘‘global’’. One easy way to do that is to initialize the variable outside of all functions and just let all functions call it. This way it will be defined in all functions. | 0 | false | 1 | 4,043 |
2015-11-28 17:06:29.567 | Adding dotted text placeholders within a textfield in Python? | So far I am using Tkinter to make textfields in Python.
My question is how do I make it so there are placeholders, preferably in the style of mathematica or something similar so that when a user starts a new line, a right and left place holder appear on that line and the user can only enter text in these placeholders?... | tkinter doesn't have anything built-in to support this. Tkinter likely has all of the fundamental building blocks in order to build it yourself, but it will require a lot of work on your part. | 0 | false | 1 | 4,044 |
2015-11-28 20:01:02.520 | Fourier series of time domain data | I spent couple days trying to solve this problem, but no luck so I turn to you. I have file for a photometry of a star with time and amplitude data. I'm supposed to use this data to find period changes. I used Lomb-Scargle from pysca library, but I have to use Fourier analysis. I tried fft (dft) from scipy and numpy bu... | Before doing the FFT, you will need to resample or interpolate the data until you get a set of amplitude values equally spaced in time. | 0 | false | 1 | 4,045 |
2015-11-28 22:26:05.503 | As codified the limit of 12 connections appengine to cloudsql | I want to connect my project from app engine with (googleSQL), but I get that error exceeded the maximum of 12 connections in python, I have a CLOUDSQL D8 1000 simultaneous connections
how can i change this number limit conexions, I'm using django and python
thanks | Each single app engine instance can have no more than 12 concurrent connections to Cloud SQL -- but then, by default, an instance cannot service more than 8 concurrent requests, unless you have deliberately pushed that up by setting the max_concurrent_requests in the automatic_scaling stanza to a higher value.
If you'v... | 0.673066 | false | 1 | 4,046 |
2015-11-29 07:52:59.667 | Check for tkinter events globally (across OS) | I trying to make an application with a pop-up menu - when I type SPACE-R_ALT on my keyboard, globally across the OS (Windows in my case). When that happens, I want to pop-up a window (I know how to do that), and it is crucial that I can happen to be using Chrome or Word, then tap Space-Right Alt, then be able to open u... | I figured it out with Furas's help - with Pyhook I can wait for events globally, and then tie in the event with tkinter events. | 1.2 | true | 1 | 4,047 |
2015-11-30 17:19:51.140 | Google API oauth2 - how to store credentials in order ot refresh token later | I'm a super noob in python and oauth2 but still I've wasted days on this one, so if you guys could give me hand, I would be eternally grateful :')
Goal: writing a script that download a file everything 5min from google drive
Achieved: Get the credentials with tokens and download it once
Problem: how do I refresh the to... | Okay, found it myself.
You gotta refresh you token everytime it expires, using httplib2.
Quick hint:
import httplib2
http = httplib2.Http()
http = credentials.authorize(http)
where credentials contains what you got from your first authorization flow.
Cheers | 1.2 | true | 1 | 4,048 |
2015-12-01 10:46:19.873 | Python selenium test - Facebook code generator XPATH | I'm trying to get the XPATH for Code Generator field form (Facebook) in order to fill it (of course before I need to put a code with "numbers").
In Chrome console when I get the XPATH I get:
//*[@id="approvals_code"]
And then in my test I put:
elem = driver.find_element_by_xpath("//*[@id='approvals_code']")
if elem:... | This error usually comes if element is not present in the DOM.
Or may be element is in iframe. | 0 | false | 1 | 4,049 |
2015-12-01 23:17:45.350 | How can I use the cProfile module to time each funtion in python? | I have a program in Python that takes in several command line arguments and uses them in several functions. How can I use cProfile (within my code)to obtain the running time of each function? (I still want the program to run normally when it's done). Yet I can't figure out how, for example I cannot use
cProfile.run('lo... | I run the
python program with -m cProfile
example:
python -m cProfile <myprogram.py>
This will require zero changes to the myprogram.py | 0.545705 | false | 1 | 4,050 |
2015-12-02 01:02:00.813 | how can you tell whether convert()/convert_alpha() has already been run on a pygame.Surface? | The title says it all, really. I am writing functions that deal with pygame.Surface objects from multiple sources. Among other operations, these functions will ensure that the Surface objects they return have been convert()ed at least once (or, according to user preference, convert_alpha()ed), as is required to optim... | I do not believe the existing API provides a way to do this. I think the intended use is to convert all your surfaces (why wouldn't you?) so you never have to worry about it.
Perhaps it is possible to subclass pygame.Surface and override the convert methods to set a flag in the way you wish. | 1.2 | true | 1 | 4,051 |
2015-12-02 16:53:29.813 | Import CV2: DLL load failed (Python in Windows 64bit) | ImportError: DLL load failed: %1 is not a valid Win32 application
Does anyone know how to fix this? This problem occurs when i am trying to import cv2. My laptop is 64bit and installed 64bit python, i also put the cv2.pyd file in the site-packages folder of Python.
My PYTHONPATH value = C:\Python35;C:\Python35\DLLs;C:... | in this case, I just copy file 'python3.dll' from my python3 installation folder to my virtualenv lib folder, and then it works. | -0.101688 | false | 1 | 4,052 |
2015-12-03 09:01:06.257 | How to use Django to manage GIS points easily? | I'm going to write a web system to add and manage the position of driver and shops. GEO searching is not required, so it would be easier to use SQLite instead of PostgreSQL.
The core question here is that is there any easy way to manage GIS points using Django admin. I know Django have GeoModelAdmin to manage maps base... | Yes, it is relatively easy to manage geometry data in the Django Admin, and it's all included. You can do any of the CRUD tasks relatively simply using the Geo Model manager in much the same way as any Django model or you can use the map interface you get in the admin.
From time to time I find I want to investigate my ... | 0 | false | 1 | 4,053 |
2015-12-03 20:12:49.127 | Best way of storing records and then iterating through them? | Old habits being what they are, I would declare global variables, and probably use lists to store records. I appreciate this is not the best way of doing this these days, and that Python actively discourages you from doing this by having to constantly declare 'global' throughout.
So what should I be doing? I'm thinking... | It's tough to tell, without a bit more information about the problem that you are trying to solve, the scope of your code, and your code's architecture.
Generally speaking:
If you're writing a script that's reasonably small in scope, there really is nothing wrong with declaring variables in the global namespace of the ... | 0 | false | 1 | 4,054 |
2015-12-04 22:30:09.147 | Display each section (h1, h2, h3) in a new page in Sphinx | When I build HTML output using sphinx, it is possible to display h1 and h2 on separate pages, however, h3 is always displayed on the same page as h2. Does anyone know how to make sphinx display the content of h3 on a separate page? The same way traditional online help systems do this.
For example:
Section
Sub-sect... | So, we were able to make it work by adjusting the HTML template and the globaltoc setting. | -0.905148 | false | 1 | 4,055 |
2015-12-06 16:25:37.837 | how to sort list in python which has two numbers per index value? | My code
b=[((1,1)),((1,2)),((2,1)),((2,2)),((1,3))]
for i in range(len(b)):
print b[i]
Obtained output:
(1, 1)
(1, 2)
(2, 1)
(2, 2)
(1, 3)
how do i sort this list by the first element or/and second element in each index value to get the output as:
(1, 1)
(1, 2)
(1, 3)
(2, 1)
(2, 2)
OR
(1, 1)
(2, 1)
(1, 2)
(2, ... | Try this: b = sorted(b, key = lambda i: (i[0], i[1])) | 0.201295 | false | 1 | 4,056 |
2015-12-07 14:14:53.070 | how to step over list comprehension in pycharm? | I am new to Python and Pycharm,
I am trying to step over a line with list comprehension,
but instead of moving me to the next line, pycharm is incrementing the loop in 1 iteration.
any ideas how to move to the next line without pushing F8 3000 times?
thanks! | PyCharm has 'Run to Cursor' option - just move your cursor one line down and hit it. | 0.386912 | false | 2 | 4,057 |
2015-12-07 14:14:53.070 | how to step over list comprehension in pycharm? | I am new to Python and Pycharm,
I am trying to step over a line with list comprehension,
but instead of moving me to the next line, pycharm is incrementing the loop in 1 iteration.
any ideas how to move to the next line without pushing F8 3000 times?
thanks! | Set a breakpoint at the next line of code after the comprehension and then hit play again. | 0 | false | 2 | 4,057 |
2015-12-07 14:30:14.380 | Can't retrive data from webpage for onchange fields in odoo? | I have used xml-rpc in my Odoo ERP so whenever some user inputs data in external website that will come to my ERP. Everything working fine i.e. getting data which user inputs from website like personal details, But the problem is i've some onchange selection fields in custom model.for that data is not getting updated o... | Chandu,
Well you can call on_change method on through xml-rpc which will give you desire data and you can pass those data back to the server to store correct values.
Bests | 0 | false | 1 | 4,058 |
2015-12-08 02:33:02.357 | Review data sentiment analysis, focusing on extracting negative sentiment? | I am trying to do sentiment analysis on a review dataset. Since I care more about identifying (extracting) negative sentiments in reviews (unlabeled now but I try to manually label a few hundreds or use Alchemy API), if the review is overall neutral or positive but a part has negative sentiment, I'd like my model to co... | When you annotate the sentiment, don't annotate 'Positive', 'Negative', and 'Neutral'. Instead, annotate them as either "has negative" or "doesn't have negative". Then your sentiment classification will only be concerned with how strongly the features indicate negative sentiment, which appears to be what you want. | 0 | false | 1 | 4,059 |
2015-12-08 10:46:27.103 | Python Selenium infinite loop | I'm trying to study customers behavior. Basically, I have information on customer's loyalty points activities data (e.g. how many points they have earned, how many points they have used, how recent they have used/earn points etc). I'm using R to conduct this analysis
I'm just wondering how should I go about segmenting ... | Your attempts is always less then 5 because there is no variable increment. So your loop is infinite | 0 | false | 1 | 4,060 |
2015-12-08 16:26:31.277 | Python Turtle fill the triangle with color? | I am currently using the turtle.goto cords from a text file. I have the triangle drawn and everything but I don't know how to fill the triangle. | You are ending fill after every new coordinate. You need to call t.begin_fill() before your for loop and call t.end_fill() after the last coordinate, otherwise you are just filling in your single line with each iteration. | 0.673066 | false | 1 | 4,061 |
2015-12-08 21:28:53.140 | Generator is not an iterator? | I have an generator (a function that yields stuff), but when trying to pass it to gensim.Word2Vec I get the following error:
TypeError: You can't pass a generator as the sentences argument. Try an iterator.
Isn't a generator a kind of iterator? If not, how do I make an iterator from it?
Looking at the library code, i... | It seems gensim throws a misleading error message.
Gensim wants to iterate over your data multiple times. Most libraries just build a list from the input, so the user doesn't have to care about supplying a multiple iterable sequence. Of course, generating an in-memory list can be very resource-consuming, while iteratin... | 0.296905 | false | 1 | 4,062 |
2015-12-08 23:23:56.967 | How to use 3to2 | I have to convert some of my python 3 files to 2 for class, but I can't figure out how to use 3to2. I did pip install 3to2 and it said it was successful. It install 2 folders 3to2-1.1.1.dist-info and lib3to2. I have tried doing python 3to2 file_name, `python lib3to2 file_name' I also tried changing the folder to 3to2.... | In MacOS, I have anaconda package manager installed, so after pip install 3to2 I found executable at /Users/<username>/anaconda3/bin/3to2
Run ./3to2 to convert stdin (-), files or directories given as arguments. By default, the tool outputs a unified diff-formatted patch on standard output and a “what was changed” summ... | 0 | false | 2 | 4,063 |
2015-12-08 23:23:56.967 | How to use 3to2 | I have to convert some of my python 3 files to 2 for class, but I can't figure out how to use 3to2. I did pip install 3to2 and it said it was successful. It install 2 folders 3to2-1.1.1.dist-info and lib3to2. I have tried doing python 3to2 file_name, `python lib3to2 file_name' I also tried changing the folder to 3to2.... | Had the same question and here's how I solved it:
pip install 3to2
rename 3to2 to 3to2.py (found in the Scripts folder of the Python directory)
Open a terminal window and run 3to2.py -w [file]
NB: You will either have to be in the same folder as 3to2.py or provide the full path to it when you try to run it. Same goes... | 0.99186 | false | 2 | 4,063 |
2015-12-09 01:16:05.610 | How could I find TCP retransmission and packet loss from pcap file? | The data was captured from LTE network.
I don't know how to recognize count TCP retransmission of a single TCP flow, using
Python.
Could I recognize the type of retransmission? It's because of congestion or packet loss?
Thanks. | I did it in C but the general ideas is, you need to keep track of TCP sequence numbers (there are two streams for each TCP session, one from client to server, the other is from server to client). This is a little complex.
For each stream, you have a pointer to keep track of the consecutive sequence numbers sent so far... | 0.386912 | false | 1 | 4,064 |
2015-12-10 10:04:59.947 | Ubuntu, how do you remove all Python 3 but not 2 | I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place:
iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7
Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7.
So the key question is, is there a way to remove both 3... | neither try any above ways nor sudo apt autoremove python3 because it will remove all gnome based applications from your system including gnome-terminal. In case if you have done that mistake and left with kernal only than trysudo apt install gnome on kernal.
try to change your default python version instead removing i... | 0.135221 | false | 4 | 4,065 |
2015-12-10 10:04:59.947 | Ubuntu, how do you remove all Python 3 but not 2 | I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place:
iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7
Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7.
So the key question is, is there a way to remove both 3... | EDIT: As pointed out in recent comments, this solution may BREAK your system.
You most likely don't want to remove python3.
Please refer to the other answers for possible solutions.
Outdated answer (not recommended)
sudo apt-get remove 'python3.*' | 0.545705 | false | 4 | 4,065 |
2015-12-10 10:04:59.947 | Ubuntu, how do you remove all Python 3 but not 2 | I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place:
iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7
Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7.
So the key question is, is there a way to remove both 3... | So I worked out at the end that you cannot uninstall 3.4 as it is default on Ubuntu.
All I did was simply remove Jupyter and then alias python=python2.7 and install all packages on Python 2.7 again.
Arguably, I can install virtualenv but me and my colleagues are only using 2.7. I am just going to be lazy in this case :... | 1.2 | true | 4 | 4,065 |
2015-12-10 10:04:59.947 | Ubuntu, how do you remove all Python 3 but not 2 | I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place:
iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7
Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7.
So the key question is, is there a way to remove both 3... | Its simple
just try:
sudo apt-get remove python3.7 or the versions that you want to remove | -0.201295 | false | 4 | 4,065 |
2015-12-10 23:32:40.847 | Python Twistd MySQL - Get Updated Row id (not inserting) | Python, Twistd and SO newbie.
I am writing a program that organises seating across multiple rooms. I have only included related columns from the tables below.
Basic Mysql tables
Table
id
Seat
id
table_id
name
Card
seat_id
The Seat and Table tables are pre-populated with the 'name' columns initially NULL.
Stage ... | I think the best way to accomplish this is to first make a select for the id (or ids) of the row/rows you want to update, then update the row with a WHERE condition matching the id of the item to update. That way you are certain that you only updated the specific item.
An UPDATE statement can update multiple rows that ... | 0 | false | 1 | 4,066 |
2015-12-12 16:11:48.137 | How to fetch or store data into a database on a LAMP server from devices over the internet? | I have a python code which needs to retrieve and store data to/from a database on a LAMP server. The LAMP server and the device running the python code are never on the same internet network. The devices running the python code can be either a Linux, Windows or a MAC system. Any idea how could I implement this? | are never on the same internet network.
Let me clear the question, the problem is are never on the same internet network. firstly you need to fix the network issue, add router between the two sides which you want to communicate with. No relations with Python or LAMP.
let me assume your DB is mysql, if you can make yo... | -0.386912 | false | 1 | 4,067 |
2015-12-14 19:30:01.007 | How are the points in a level curve chosen in pyplot? | I want to know how the contours levels are chosen in pyplot.contour. What I mean by this is, given a function f(x, y), the level curves are usually chosen by evaluating the points where f(x, y) = c, c=0,1,2,... etc. However if f(x, y) is an array A of nxn points, how do the level points get chosen? I don't mean how do ... | The function is evaluated at every grid node, and compared to the iso-level. When there is a change of sign along a cell edge, a point is computed by linear interpolation between the two nodes. Points are joined in pairs by line segments. This is an acceptable approximation when the grid is dense enough. | 0 | false | 1 | 4,068 |
2015-12-15 08:34:46.453 | How to integrate killable processes/thread in Python GUI? | Kind all, I'm really new to python and I'm facing a task which I can't completely grasp.
I've created an interface with Tkinter which should accomplish a couple of apparently easy feats.
By clicking a "Start" button two threads/processes will be started (each calling multiple subfunctions) which mainly read data from a... | First you can use subprocess.Popen() to spawn child processes, then later you can use Popen.terminate() to terminate them.
Note that you could also do everything in a single Python thread, without subprocesses, if you want to. It's perfectly possible to "multiplex" reading from multiple ports in a single event loop. | 0 | false | 1 | 4,069 |
2015-12-15 08:39:36.290 | How does calling C or C++ from python work? | There are multiple questions about "how to" call C C++ code from Python. But I would like to understand what exactly happens when this is done and what are the performance concerns. What is the theory underneath? Some questions I hope to get answered by understanding the principle are:
When considering data (especially... | You can call between C, C++, Python, and a bunch of other languages without spawning a separate process or copying much of anything.
In Python basically everything is reference-counted, so if you want to use a Python object in C++ you can simply use the same reference count to manage its lifetime (e.g. to avoid copying... | 1.2 | true | 1 | 4,070 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.