title stringlengths 12 150 | question_id int64 469 40.1M | question_score int64 2 5.52k | question_date stringdate 2008-08-02 15:11:16 2016-10-18 06:16:31 | answer_id int64 536 40.1M | answer_score int64 7 8.38k | answer_date stringdate 2008-08-02 18:49:07 2016-10-18 06:19:33 | tags listlengths 1 5 | question_body_md stringlengths 15 30.2k | answer_body_md stringlengths 11 27.8k |
|---|---|---|---|---|---|---|---|---|---|
How to detect a Christmas Tree? | 20,772,893 | 295 | 2013-12-25T12:40:55Z | 20,893,881 | 20 | 2014-01-02T23:28:44Z | [
"c++",
"python",
"opencv",
"image-processing",
"computer-vision"
] | Which image processing techniques could be used to implement an application that detects the christmas trees displayed in the following images?




 script that detects christmas trees by their lights. The result ist always a symmetrical triangle, and if necessary numeric values like the angle ("fatness") of the tree.
The biggest threat to t... |
How to detect a Christmas Tree? | 20,772,893 | 295 | 2013-12-25T12:40:55Z | 20,894,867 | 26 | 2014-01-03T01:13:02Z | [
"c++",
"python",
"opencv",
"image-processing",
"computer-vision"
] | Which image processing techniques could be used to implement an application that detects the christmas trees displayed in the following images?




 - all operations we make on this channel:
2. Create Region of Interest (ROI)
* Threshold R channel with min value 149 (top right image)
* Dilate result region (middle left image)
3. Detect eges in computed roi. Tree has a lot of edges (middle right image)
* Dil... |
How to detect a Christmas Tree? | 20,772,893 | 295 | 2013-12-25T12:40:55Z | 21,465,318 | 10 | 2014-01-30T19:05:03Z | [
"c++",
"python",
"opencv",
"image-processing",
"computer-vision"
] | Which image processing techniques could be used to implement an application that detects the christmas trees displayed in the following images?




 to the Red channel
3. Then apply Morphological Gradient and then do a 'Closing' (dilation followed by Erosion)
4. Then it finds the contours in the plane and it picks the longe... |
python nltk naive bayes probabilities | 20,773,200 | 3 | 2013-12-25T13:17:00Z | 20,773,513 | 7 | 2013-12-25T13:56:14Z | [
"python",
"text",
"classification",
"nltk"
] | Is there a way to get at the individual probabilities using nltk.NaiveBayesClassifier.classify? I want to see the probabilities of classification to try and make a confidence scale. Obviously with a binary classifier the decision is going to be one or the other, but is there some way to see the inner workings of how th... | How about `nltk.NaiveBayesClassifier.prob_classify`?
<http://nltk.org/api/nltk.classify.html#nltk.classify.naivebayes.NaiveBayesClassifier.prob_classify>
`classify` calls this function:
```
def classify(self, featureset):
return self.prob_classify(featureset).max()
```
**Edit:** something like this should work ... |
Salt Stack: using execution modules in SLS | 20,773,400 | 13 | 2013-12-25T13:42:36Z | 20,788,572 | 25 | 2013-12-26T17:18:53Z | [
"python",
"service",
"salt-stack"
] | So far as I can see in the Salt documentation (e.g. [here](https://salt.readthedocs.org/en/latest/ref/modules/all/index.html)) there are two main types of modules supported: **state modules** and **execution modules** (I know there're also renderers, returners and so on). Most of examples of SLS files contain statement... | You are correct that there are significant differences between **execution modules** and **state modules**. Unfortunately the term **module** is a bit overloaded.
An **execution module** is a command sent to a Salt Minion to be executed immediately. Examples are "install apache" or "restart memcached".
A **state modu... |
Python: for loop inside print() | 20,774,607 | 2 | 2013-12-25T16:07:57Z | 20,774,626 | 10 | 2013-12-25T16:10:38Z | [
"python",
"list",
"python-3.x",
"printing"
] | I have a question about Python (3.3.2).
I have a list:
```
L = [['some'], ['lists'], ['here']]
```
I want to print these nested lists (each one on a new line) using the `print()` function:
```
print('The lists are:', for list in L: print(list, '\n'))
```
I know this is incorrect but I hope you get the idea. Could ... | Apply the whole `L` object as separate arguments:
```
print('The lists are:', *L, sep='\n')
```
By setting `sep` to a newline this'll print all list objects on new lines.
Demo:
```
>>> L = [['some'], ['lists'], ['here']]
>>> print('The lists are:', *L, sep='\n')
The lists are:
['some']
['lists']
['here']
```
If yo... |
Get information for Facebook page in Facebook API graph | 20,775,149 | 2 | 2013-12-25T17:19:13Z | 20,775,483 | 7 | 2013-12-25T18:04:51Z | [
"python",
"facebook",
"facebook-graph-api",
"python-2.7"
] | I have a simple question in python.
If I have a Facebook page ID let say '6127898346' for example, how can I retrieve this page information such as (Likes count) , and store the result on a file? | Use some sort of Facebook API package, like <https://github.com/pythonforfacebook/facebook-sdk> available with `pip install facebook-sdk`.
```
import facebook
graph = facebook.GraphAPI()
page = graph.get_object('6127898346')
print '{} has {} likes.'.format(page['name'], page['likes'])
```
Easy way to save everything:... |
Concurrent.futures vs Multiprocessing in Python 3 | 20,776,189 | 35 | 2013-12-25T19:41:55Z | 20,776,444 | 36 | 2013-12-25T20:19:20Z | [
"python",
"python-3.x",
"multiprocessing"
] | Python 3.2 introduced [Concurrent Futures](http://docs.python.org/3/library/concurrent.futures.html), which appear to be some advanced combination of the older threading and [multiprocessing](http://docs.python.org/2/library/multiprocessing.html) modules.
What are the advantages and disadvantages of using this for CPU... | I wouldn't call `concurrent.futures` more "advanced" - it's a *simpler* interface that works very much the same regardless of whether you use multiple threads or multiple processes as the underlying parallelization gimmick.
So, like virtually all instances of "simpler interface", much the same tradeoffs are involved: ... |
Point in Polygon with geoJSON in Python | 20,776,205 | 13 | 2013-12-25T19:44:17Z | 20,793,808 | 18 | 2013-12-27T02:09:59Z | [
"python",
"json",
"geometry",
"geojson"
] | So I have a geoJSON database with lots of polygons (census tracts specifically) and I have lots of long,lat points.
I am hoping that there would exist an efficient python code to identify which census tract a given coordinate is in, however so far my googling hasn't revealed anything.
Thanks! | I found an interesting [article](http://www.mhermans.net/geojson-shapely-geocoding.html) describing how to do exactly what you are looking to do.
TL;DR: Use [Shapely](https://pypi.python.org/pypi/Shapely)
You will find this code at the end of the article:
```
import json
from shapely import shape, Point
# depending ... |
What's the best between return the result and print it at the end of the function? | 20,777,336 | 5 | 2013-12-25T22:39:18Z | 20,777,359 | 10 | 2013-12-25T22:43:05Z | [
"python",
"function",
"python-3.x",
"coding-style"
] | Assume we define a function and then end it with:
```
def function():
# ...
return result
# To see the result, we need to type:
print(function())
```
Another option is to end a function with a `print`:
```
def function():
# ...
print(result)
# no need of print at the call anymore so
function()
`... | If you `return print(result)`, you're essentially doing `return None` because `print()` returns `None`. So that doesn't make much sense.
I'd say it's much cleaner to `return result` and have the caller decide whether to `print()` it or do whatever else with it. |
What's the best between return the result and print it at the end of the function? | 20,777,336 | 5 | 2013-12-25T22:39:18Z | 20,777,417 | 8 | 2013-12-25T22:51:35Z | [
"python",
"function",
"python-3.x",
"coding-style"
] | Assume we define a function and then end it with:
```
def function():
# ...
return result
# To see the result, we need to type:
print(function())
```
Another option is to end a function with a `print`:
```
def function():
# ...
print(result)
# no need of print at the call anymore so
function()
`... | The **most cleaner way is with the `return` statement**. In general, a function returns a result, and this result can be processed after by another algorithm. Maybe you don't need to get the result in a variable in your case, but imagine you do in 1 week, month...
The best way is to delegate the `print` at the main pr... |
Case Insensitive Python string split() method | 20,782,186 | 9 | 2013-12-26T09:16:52Z | 20,782,251 | 13 | 2013-12-26T09:22:16Z | [
"python",
"string"
] | I have 2 strings
```
a = "abc feat. def"
b = "abc Feat. def"
```
I want to retrieve the string before the word `feat.` or `Feat.`
This is what I'm doing,
```
a.split("feat.", 1)[0].rstrip()
```
This returns `abc`. But how can I perform a case insensitive search using split delimiter?
This is what I've tried so fa... | Use a regex instead:
```
>>> import re
>>> regex = re.compile(r"\s*feat\.\s*", flags=re.I)
>>> regex.split("abc feat. def")
['abc', 'def']
>>> regex.split("abc Feat. def")
['abc', 'def']
```
or, if you don't want to allow `FEAT.` or `fEAT.` (which this regex would):
```
>>> regex = re.compile(r"\s*[Ff]eat\.\s*")
``` |
Parsing Command line arguments in python which has spaces | 20,784,997 | 6 | 2013-12-26T12:37:42Z | 20,785,122 | 9 | 2013-12-26T12:45:16Z | [
"python",
"jython",
"wlst"
] | I am invoking the script from ant . I am getting it as a single string from the caller but python is strangely treating it as two individual strings.I have script that reads a file name with it's path in windows. The folder structure may or may not have spaces in between
Here is an example
`test.py D:/test/File Name`... | You pass the folder name wrapped in quotes:
```
test.py "D:\test\File Name"
```
`sys.argv[1]` will contain the folder path, spaces included.
If for some reason you *cannot* quote the folder name, you will need to use the `ctypes` module and use the Win32 API's `GetCommandLine` function. Here's a [functional example]... |
python - specifically handle file exists exception | 20,790,580 | 4 | 2013-12-26T20:01:27Z | 20,790,635 | 10 | 2013-12-26T20:06:00Z | [
"python",
"exception",
"ioerror"
] | I have come across examples in this forum where a specific error around files and directories is handled by testing the `errno` value in `OSError` (or `IOError` these days ?). For example, some discussion here - [Python's "open()" throws different errors for "file not found" - how to handle both exceptions?](http://sta... | According to the code `print ...`, it seems like you're using Python 2.x. [`FileExistsError`](http://docs.python.org/3/library/exceptions.html#FileExistsError) was added in Python 3.3; You can't use `FileExistsError`.
Use [`errno.EEXIST`](http://docs.python.org/2/library/errno.html#errno.EEXIST):
```
import os
import... |
Calculate RGB value for a range of values to create heat map | 20,792,445 | 10 | 2013-12-26T23:07:36Z | 20,792,531 | 18 | 2013-12-26T23:18:10Z | [
"python",
"colors",
"rgb",
"heatmap",
"linear-interpolation"
] | I am trying to create a heat map with python. For this I have to assign an RGB value to every value in the range of possible values. I thought of changing the color from blue (minimal value) over green to red (maximal value).
The picture example below explains how I thought of the color composition: We have a range fr... | ```
def rgb(minimum, maximum, value):
minimum, maximum = float(minimum), float(maximum)
ratio = 2 * (value-minimum) / (maximum - minimum)
b = int(max(0, 255*(1 - ratio)))
r = int(max(0, 255*(ratio - 1)))
g = 255 - b - r
return r, g, b
``` |
Calculate RGB value for a range of values to create heat map | 20,792,445 | 10 | 2013-12-26T23:07:36Z | 20,793,850 | 8 | 2013-12-27T02:16:25Z | [
"python",
"colors",
"rgb",
"heatmap",
"linear-interpolation"
] | I am trying to create a heat map with python. For this I have to assign an RGB value to every value in the range of possible values. I thought of changing the color from blue (minimal value) over green to red (maximal value).
The picture example below explains how I thought of the color composition: We have a range fr... | Here's another way to do it that, while not as absolutely short as possible, is much more general since it hasn't been hardcoded for your specific set of colors. This means it can also be used to linearly interpolate a specified range of values over a variably-sized palette of arbitrary colors.
Also note that colors c... |
python 'with' statement, should I use contextlib.closing? | 20,793,283 | 9 | 2013-12-27T00:57:46Z | 20,793,386 | 13 | 2013-12-27T01:10:48Z | [
"python",
"with-statement",
"contextmanager"
] | ```
from contextlib import closing
def init_db():
with closing(connect_db()) as db:
with app.open_resource('schema.sql') as f:
db.cursor().executescript(f.read())
db.commit()
```
This is from flask tutorial Step 3(<http://flask.pocoo.org/docs/tutorial/dbinit/#tutorial-dbinit>). And I'm... | Yes, you should be using `context.closing()`; your own version does something different entirely.
The `with` statement lets a context manager know when a block of code is entered and exited; on exit the context manager is also given access to the exception, if one occurred. File objects use this to automatically close... |
Configuring Django | 20,794,901 | 9 | 2013-12-27T04:46:10Z | 20,798,527 | 14 | 2013-12-27T09:55:56Z | [
"python",
"django",
"osx",
"django-settings"
] | I just installed Django 1.6 on OS X 10.8 with python 2.7 and am having trouble going through the tutorial. After setting creating a server called mysite by running:
```
django-admin.py startproject mysite
```
I then cd'ed into mysite and ran
```
python manage.py runserver
```
and got this error:
```
Traceback (mos... | Check in `manage.py` if you have this:
```
import os
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
```
And in `wsgi.py` this:
```
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
```
Also, any python scripts that integrate Django shou... |
Get reference to the current exception | 20,797,923 | 7 | 2013-12-27T09:15:43Z | 22,973,302 | 16 | 2014-04-09T20:28:47Z | [
"python",
"debugging",
"exception",
"pdb",
"ipdb"
] | ```
$ ./runtests.py -v tests/managers/test_customer.py:CustomerManagerTest.test_register_without_subscription --ipdb
...
test_register_without_subscription (tests.managers.test_customer.CustomerManagerTest) ...
- TRACEBACK --------------------------------------------------------------------
Traceback (most recent ca... | This has frustrated me too for a while. I eventually found the answer [here](http://www.onlamp.com/pub/a/python/2005/09/01/debugger.html?page=6), along with a good detailed explanation.
The short answer is, use the `!` magic prefix (`!sys.exc_info()`):
```
In [4]: 1/0
-------------------------------------------------... |
How to measure download speed and progress using requests? | 20,801,034 | 2 | 2013-12-27T12:49:59Z | 21,868,231 | 10 | 2014-02-19T00:02:20Z | [
"python",
"python-2.7",
"progress",
"python-requests",
"download-speed"
] | I am using `requests` to download files, but for large files I need to check the size of the file on disk every time because I can't display the progress in percentage and I would also like to know the download speed. How can I go about doing it ? Here's my code :
```
import requests
import sys
import time
import os
... | see here: [Python progress bar and downloads](http://stackoverflow.com/questions/15644964/python-progress-bar-and-downloads/15645088#15645088)
i think the code would be something like this, it should show the **average speed since start** as bytes per second:
```
import requests
import sys
import time
def downloadFi... |
Django form.is_valid() always false | 20,801,452 | 8 | 2013-12-27T13:18:48Z | 20,802,107 | 11 | 2013-12-27T14:07:47Z | [
"python",
"django",
"forms"
] | I'm coding a login. When I programmed the form by hand I got it working.
The code below works:
views.py
```
def login_view(request):
if request.method == 'GET':
return render(request, 'app/login.htm')
if request.method == 'POST':
username = request.POST.get('username', '')
password = ... | It turns out that Maxime was right after all (sorry) - you do need the `data` parameter:
```
form = AuthenticationForm(data=request.POST)
```
The reason for that, though, is that AuthenticationForm overwrites the signature of `__init__` to expect the *request* as the first positional parameter. If you explicitly supp... |
Appending column totals to a Pandas DataFrame | 20,804,673 | 6 | 2013-12-27T17:03:04Z | 29,541,211 | 8 | 2015-04-09T14:23:05Z | [
"python",
"pandas"
] | I have a DataFrame with numerical values. What is the simplest way of appending a row (with a given index value) that represents the sum of each column? | This is the easiest way:
```
df['Total'] = df.sum(axis=1)
``` |
Appending column totals to a Pandas DataFrame | 20,804,673 | 6 | 2013-12-27T17:03:04Z | 34,812,293 | 7 | 2016-01-15T13:35:18Z | [
"python",
"pandas"
] | I have a DataFrame with numerical values. What is the simplest way of appending a row (with a given index value) that represents the sum of each column? | To add a row with column-totals:
```
df.loc['Total']= df.sum()
``` |
TimeSeries with a groupby in Pandas | 20,805,299 | 4 | 2013-12-27T17:45:41Z | 20,807,853 | 8 | 2013-12-27T21:08:34Z | [
"python",
"pandas"
] | I would like to look at `TimeSeries` data for every client over various time periods in `Pandas`.
```
import pandas as pd
import numpy as np
import random
clients = np.random.randint(1, 11, size=100)
dates = pd.date_range('20130101',periods=365)
OrderDates = random.sample(dates,100)
Values = np.random.randint(10, 250,... | A slight alternative is to `set_index` before doing the groupby:
```
In [11]: df.set_index('OrderDate', inplace=True)
In [12]: g = df.groupby('Client')
In [13]: g['Value'].resample('Q', how=[np.sum, len])
Out[13]:
sum len
Client OrderDate
1 2013-03-31 239 1
2013-06-30 ... |
'{:08b}' .format(i) Equivalent in Python 2.x | 20,806,050 | 4 | 2013-12-27T18:43:21Z | 20,806,097 | 9 | 2013-12-27T18:47:04Z | [
"python",
"binary",
"string-formatting"
] | I have a small bit of code in Python 3 -
```
'{:08b}' .format(i)
```
that gives an error in Python 2.x. Does anyone know the equivalent? | Your original code actually works in Python 2.7. For Python 2.6, you need to introduce a reference to your `format` argument - either an index (`0`):
```
'{0:08b}'.format(i)
```
or a name:
```
'{x:08b}'.format(x=i) # or:
'{i:08b}'.format(i=i) # or even:
'{_:08b}'.format(_=i) # (since you don't care about the name... |
Non Brute Force Solution to Project Euler 25 | 20,808,763 | 6 | 2013-12-27T22:38:00Z | 20,808,921 | 10 | 2013-12-27T22:53:32Z | [
"python",
"brute-force"
] | Project Euler Problem 25:
> The Fibonacci sequence is defined by the recurrence relation:
>
> Fn = Fnâ1 + Fnâ2, where F1 = 1 and F2 = 1. Hence the first 12 terms
> will be F1 = 1, F2 = 1, F3 = 2, F4 = 3, F5 = 5, F6 = 8, F7 = 13, F8 =
> 21, F9 = 34, F10 = 55, F11 = 89, F12 = 144
>
> The 12th term, F12, is the first... | You can write a fibonacci function that runs in linear time and with constant memory footprint, you don't need a list to keep them.
Here's a recursive version (however, if n is big enough, it will just [stackoverflow](http://stackoverflow.com/questions/13591970/does-python-optimize-tail-recursion))
```
def fib(a, b, n... |
Open more than 1 file using with - python | 20,813,944 | 10 | 2013-12-28T11:22:21Z | 20,813,965 | 9 | 2013-12-28T11:24:16Z | [
"python",
"file-io",
"with-statement"
] | Normally, we would use this to read/write a file:
```
with open(infile,'r') as fin:
pass
with open(outfile,'w') as fout:
pass
```
And to do read one file and output to another, can i do it with just one `with`?
I've been doing it as such:
```
with open(outfile,'w') as fout:
with open(infile,'r') as fin:
f... | ```
with open(infile,'r') as fin, open(outfile,'w') as fout:
fout.write(fin.read())
```
It used to be necessary to use (the now deprecated) [contextlib.nested](http://docs.python.org/2/library/contextlib.html#contextlib.nested), but as of Python2.7, [`with` supports multiple context managers](http://docs.python.org... |
Can Syntax Errors be handled properly? | 20,816,332 | 14 | 2013-12-28T15:46:43Z | 20,816,359 | 7 | 2013-12-28T15:50:26Z | [
"python",
"python-2.7",
"exception-handling"
] | Consider the following code:
```
try:
if True a = 1 #It's missing a colon So it's a SyntaxError!!!!!!!
except SyntaxError:
print 'hey'
```
You'd expect it to print `hey` However It raises a `SyntaxError`, The same error I'm trying to avoid. So Can all Exceptions be handled using a `try-except` block? Well If... | Of course you need `SyntaxError` as a built-in exception - what else should be raised if the compiler/parser encounters a syntax error?
You're right that this error usually happens at compile time, which is before you're able to catch it (runtime). (And how would you recover from it?)
I can think of one exception, th... |
Can Syntax Errors be handled properly? | 20,816,332 | 14 | 2013-12-28T15:46:43Z | 20,816,402 | 21 | 2013-12-28T15:56:40Z | [
"python",
"python-2.7",
"exception-handling"
] | Consider the following code:
```
try:
if True a = 1 #It's missing a colon So it's a SyntaxError!!!!!!!
except SyntaxError:
print 'hey'
```
You'd expect it to print `hey` However It raises a `SyntaxError`, The same error I'm trying to avoid. So Can all Exceptions be handled using a `try-except` block? Well If... | `SyntaxError` is a perfectly ordinary built-in exception. It is not special in any way. Only the circumstances of when it's (usually) thrown are a bit unusual.
A syntax error means that the code featuring said error **cannot be parsed**. It doesn't even begin to be a valid program, hence it cannot be executed. Therefo... |
Best and/or fastest way to create lists in python | 20,816,600 | 8 | 2013-12-28T16:15:53Z | 20,816,744 | 13 | 2013-12-28T16:28:48Z | [
"python",
"list"
] | In python, as far as I know, there are at least 3 to 4 ways to create and initialize lists of a given size:
**Simple loop with `append`:**
```
my_list = []
for i in range(50):
my_list.append(0)
```
**Simple loop with `+=`:**
```
my_list = []
for i in range(50):
my_list += [0]
```
**List comprehension:**
`... | Let's run some time tests\* with [`timeit.timeit`](http://docs.python.org/2/library/timeit.html#timeit.timeit):
```
>>> from timeit import timeit
>>>
>>> # Test 1
>>> test = """
... my_list = []
... for i in xrange(50):
... my_list.append(0)
... """
>>> timeit(test)
22.384258893239178
>>>
>>> # Test 2
>>> test = "... |
In PyCharm, how to navigate to the top of the file? | 20,817,133 | 7 | 2013-12-28T17:07:18Z | 20,817,174 | 7 | 2013-12-28T17:12:04Z | [
"python",
"django",
"pycharm"
] | I'm new to PyCharm and haven't been able to figure out what I'm sure is a very simple thing -- what's the key stroke to go to the top of the current file?
(Bonus question -- is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?) | You navigate to the top of the file using `Ctrl`+`Home`. It moves cursor too. So does navigating via `Page Up` and `Page Down` keys.
`Ctrl`+`Up` and `Ctrl`+`Down` move the view without moving cursor but scrolling the long file takes some time.
Additionally You can change the keymap (Settings > Keymap). There is 'Scro... |
What is the difference between pelicanconf and publishconf when using Pelican | 20,817,192 | 7 | 2013-12-28T17:13:45Z | 20,845,195 | 12 | 2013-12-30T18:23:16Z | [
"python",
"github-pages",
"pelican"
] | I used the pelican-quickstart to create a static website and this comes with a default pelicanconf and publishconf. I have a GOOGLE\_ANALYTICS variable in my publishconf, but when I publish my static page in Github Pages, using this snippet:
```
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAc... | As the person who bifurcated the Pelican settings file in the first place, I recommend
thinking of two primary modes of operation: local development and production deployment (i.e., `pelicanconf.py` and `publishconf.py`, respectively).
Moving `GOOGLE_ANALYTICS` from `publishconf.py` to `pelicanconf.py` is not recommen... |
SQL query using %s in Python 3.3 | 20,817,827 | 5 | 2013-12-28T18:21:42Z | 20,817,890 | 9 | 2013-12-28T18:27:19Z | [
"python",
"mysql",
"sql"
] | I'm trying to retrieve data from a MySQL-database.
```
A = "James"
query = ("SELECT * FROM DB.tblusers WHERE UserName = %s ")
c = mysql.connector.connect(user='root', password='',
host='127.0.0.1',
database='DB')
cur1 = c.cursor()
cur1.execute(query, A)
```
Gives th... | `A` should be a tuple, try with `A = ("James",)`
see documentation of [MySQLCursor.execute(operation, params=None, multi=False)](http://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-execute.html)
---
EDIT: added a comma, thanks to "swordofpain" (I learned something) |
Not all parameters were used in the SQL statement (Python, MySQL) | 20,818,155 | 14 | 2013-12-28T18:56:37Z | 20,818,201 | 17 | 2013-12-28T19:00:29Z | [
"python",
"mysql",
"sql"
] | I get an error on the following Python code:
```
import mysql.connector
cnx = mysql.connector.connect(user='root', password='',
host='127.0.0.1',
database='DB')
cursor = cnx.cursor()
Name = "James"
Department = "Finance"
StartYear = 2001
CurrentPos = 2001
Link = ""
... | The parameter marker is `%s` not `%d`.
```
add_user = """INSERT INTO DB.tbluser
(username, department, startyear, currentpos, link)
VALUES (%s, %s, %s, %s, %s)"""
```
Note that the [parameter markers](http://www.python.org/dev/peps/pep-0249/) used by `mysql.connector` may look the same a... |
Is there a count type of method that you can use on a Python set? | 20,819,225 | 2 | 2013-12-28T20:49:44Z | 20,819,293 | 7 | 2013-12-28T20:55:20Z | [
"python",
"list",
"python-2.7",
"count",
"set"
] | For example (which did not work):
```
rock_group = ([])
if rock_group.count() <= 12:
rock_group.add(a_rock)
```
I'm looking to count the number of items in a set and if it is less than 12, then add the object `a_rock` to the set.
I was hoping to write something quicker and more efficient than a for loop. | You can use `len(rock_group)`. Also your `rock_group` is currently a list, not a set.
To create a set you can write: `rock_group = set()`. This means the code becomes:
```
rock_group = set()
if len(rock_group) <= 12:
rock_group.add(a_rock)
``` |
(Python) List index out of range - iteration | 20,819,504 | 2 | 2013-12-28T21:21:02Z | 20,819,524 | 8 | 2013-12-28T21:23:26Z | [
"python",
"list",
"indexing",
"range",
"out"
] | ```
for i in range(len(lst)):
if lst[i][0]==1 or lst[i][1]==1:
lst.remove(lst[i])
return lst
```
This gives "IndexError: list index out of range" Why is this happening? | You're modifying the list you're iterating over. If you do that, the size of the list shrinks, so eventually `lst[i]` will point beyond the list's boundaries.
```
>>> lst = [1,2,3]
>>> lst[2]
3
>>> lst.remove(1)
>>> lst[1]
3
>>> lst[2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError... |
python selenium: does not wait until page is loaded after a click() command | 20,819,671 | 15 | 2013-12-28T21:39:00Z | 20,819,830 | 12 | 2013-12-28T22:00:18Z | [
"python",
"selenium"
] | does someone know how to wait until the page is loaded? I tried all possible variants I found on the web but is simply does not work.
I need to wait after I trigger a click() command, there is some internal scripting on the web server which fools checks such as (I exclude the code to import required modules and use st... | Fundamentally if the page is being generated by JavaScript then there is no way to tell when it has "finished" loading.
However. I typically try to retrieve a page element, catch the exception and keep on trying until a timeout is reached. I might also check that the element is visible not merely present.
There must ... |
Django: "Too many values to unpack" when calling user.objects.get() | 20,820,830 | 9 | 2013-12-29T00:18:50Z | 20,830,181 | 18 | 2013-12-29T21:18:51Z | [
"python",
"django",
"django-models",
"django-1.6"
] | In Django 1.6, I've defined a custom user model, but for some reason now when I create a superuser and try to get it or access the Django admin as that superuser, I get this `ValueError: Too many values to unpack`. I have perused the many similar questions on SO about this error and haven't found anything that fits my ... | Turns out that the problem here was actually very unrelated to the errors thrown.
I realized I was actually calling
```
UserObject.objects.get('user@email.com')
```
instead of
```
UserObject.objects.get(email='user@email.com')
```
which is why the errors were being thrown. If you look into the Django source code, ... |
Find multiple maximum values in a 2d array fast | 20,825,990 | 4 | 2013-12-29T14:13:41Z | 20,826,735 | 9 | 2013-12-29T15:27:47Z | [
"python",
"arrays",
"performance",
"numpy",
"max"
] | The situation is as follows:
I have a 2D numpy array. Its shape is (1002, 1004). Each element contains a value between 0 and Inf. What I now want to do is determine the first 1000 maximum values and store the corresponding indices in to a list named x and a list named y. This is because I want to plot the maximum valu... | If you have numpy 1.8, you can use the [`argpartition`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.argpartition.html) function or method.
Here's a script that calculates `x` and `y`:
```
import numpy as np
# Create an array to work with.
np.random.seed(123)
full = np.random.randint(1, 99, size=(8, 8))
... |
nltk NaiveBayesClassifier training for sentiment analysis | 20,827,741 | 8 | 2013-12-29T17:00:44Z | 20,827,919 | 17 | 2013-12-29T17:18:12Z | [
"python",
"nlp",
"nltk",
"sentiment-analysis",
"textblob"
] | I am training the `NaiveBayesClassifier` in Python using sentences, and it gives me the error below. I do not understand what the error might be, and any help would be good.
I have tried many other input formats, but the error remains. The code given below:
```
from text.classifiers import NaiveBayesClassifier
from t... | You need to change your data structure. Here is your `train` list as it currently stands:
```
>>> train = [('I love this sandwich.', 'pos'),
('This is an amazing place!', 'pos'),
('I feel very good about these beers.', 'pos'),
('This is my best work.', 'pos'),
("What an awesome view", 'pos'),
('I do not like this rest... |
nltk NaiveBayesClassifier training for sentiment analysis | 20,827,741 | 8 | 2013-12-29T17:00:44Z | 20,833,372 | 12 | 2013-12-30T04:31:37Z | [
"python",
"nlp",
"nltk",
"sentiment-analysis",
"textblob"
] | I am training the `NaiveBayesClassifier` in Python using sentences, and it gives me the error below. I do not understand what the error might be, and any help would be good.
I have tried many other input formats, but the error remains. The code given below:
```
from text.classifiers import NaiveBayesClassifier
from t... | @275365's tutorial on the data structure for NLTK's bayesian classifier is great. From a more high level, we can look at it as,
We have inputs sentences with sentiment tags:
```
training_data = [('I love this sandwich.', 'pos'),
('This is an amazing place!', 'pos'),
('I feel very good about these beers.', 'pos'),
('T... |
Is there a way to have a python program run an action when it's about to crash? | 20,829,300 | 3 | 2013-12-29T19:37:26Z | 20,829,384 | 7 | 2013-12-29T19:47:29Z | [
"python"
] | I have a python script with a loop that crashes every so often with various exceptions, and needs to be restarted. Is there a way to run an action when this happens, so that I can be notified? | You could install an exception hook, by assigning a custom function to the [`sys.excepthook` handler](http://docs.python.org/2/library/sys.html#sys.excepthook). The function is called whenever there is a *unhandled* exception (so one that exits the interpreter).
```
import sys
def myexcepthook(type, value, tb):
i... |
Virtualenv no module named zlib | 20,829,507 | 7 | 2013-12-29T20:02:13Z | 21,068,361 | 9 | 2014-01-11T21:52:50Z | [
"python",
"virtualenv",
"zlib"
] | I'm trying to create Python 2.7 virtual env under Python2.6, I'm simply running:
```
virtualenv --python=python27 #python27 correctly leads to my python installation in /opt/python2.7/bin/python
```
Virtualenv fails with following error
```
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/vi... | Your Python must have been compiled without Python support, most likely because **`zlib-devel` was not installed when it was compiled**. Looking at the output of `make` or `make install` you should see something like the following (taken from a build of Python 2.7.6):
```
Python build finished, but the necessary bits ... |
Getting the bounding box of the recognized words using python-tesseract | 20,831,612 | 4 | 2013-12-30T00:15:13Z | 20,832,430 | 8 | 2013-12-30T02:18:22Z | [
"python",
"image-processing",
"ocr",
"tesseract",
"python-tesseract"
] | I am using python-tesseract to extract words from an image. This is a python wrapper for tesseract which is an OCR code.
I am using the following code for getting the words:
```
import tesseract
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetVariable("tessedit_char_whitelist", "012345... | `tesseract.GetBoxText()` method returns the exact position of each character in an array.
Besides, there is a command line option `tesseract test.jpg result hocr` that will generate a `result.html` file with each recognized word's coordinates in it. But I'm not sure whether it can be called through python script. |
Python Using Adblock with Selenium and Firefox Webdriver | 20,832,159 | 10 | 2013-12-30T01:33:55Z | 20,835,825 | 12 | 2013-12-30T08:20:03Z | [
"python",
"selenium",
"firefox-addon",
"adblock"
] | My goal is to use Adblock Plus with Selenium via Python. I have been able to get it to the point where it will load the extension, but by default it does not include the default filter "EasyList." Here is what I have so far:
```
from selenium import webdriver
from time import sleep
ffprofile = webdriver.FirefoxProf... | Actually, Adblock Plus will add EasyList by default - but not if you set `extensions.adblockplus.currentVersion` preference to disable update/first-run actions. I guess that your goal was preventing the first-run page from showing up but it also prevented data storage initialization. Note that you have more issues here... |
Python frozenset hashing algorithm / implementation | 20,832,279 | 17 | 2013-12-30T01:54:21Z | 20,833,285 | 18 | 2013-12-30T04:18:04Z | [
"python",
"hash",
"set"
] | I'm currently trying to understand the mechanism behind the hash function defined for Python's built-in `frozenset` data type. The implementation is shown at the bottom for reference. What I'm interested in particular is the rationale for the choice of this scattering operation:
```
lambda h: (h ^ (h << 16) ^ 89869747... | Unless Raymond Hettinger (the code's author) chimes in, we'll never know for sure ;-) But there's usually less "science" in these things than you might expect: you take some general principles, and a test suite, and fiddle the constants almost arbitrarily until the results look "good enough".
Some general principles "... |
Python frozenset hashing algorithm / implementation | 20,832,279 | 17 | 2013-12-30T01:54:21Z | 20,931,478 | 18 | 2014-01-05T08:13:47Z | [
"python",
"hash",
"set"
] | I'm currently trying to understand the mechanism behind the hash function defined for Python's built-in `frozenset` data type. The implementation is shown at the bottom for reference. What I'm interested in particular is the rationale for the choice of this scattering operation:
```
lambda h: (h ^ (h << 16) ^ 89869747... | The problem being solved is that the previous hash algorithm in *Lib/sets.py* had horrendous performance on datasets that arise in a number of graph algorithms (where nodes are represented as *frozensets*):
```
# Old-algorithm with bad performance
def _compute_hash(self):
result = 0
for elt in self:
r... |
Fix invalid polygon | Python Shapely | 20,833,344 | 10 | 2013-12-30T04:27:51Z | 20,873,812 | 14 | 2014-01-01T22:08:57Z | [
"python",
"geometry",
"shapely"
] | Shapely defines a Polygon as invalid if any of its segments intersect, including segments that are colinear. Many software packages will create a region or area with a "cutout" as shown here which has colinear segments ([Image](https://www.dropbox.com/s/25pmp0fm64z9rp1/invalid_poly.png)):
```
>>> pp = Polygon([(0,... | I found a solution that works for the specific case given:
```
>>> pp2 = pp.buffer(0)
>>> pp2.is_valid
True
>>> pp2.exterior.coords[:]
[(0.0, 0.0), (0.0, 3.0), (3.0, 3.0), (3.0, 0.0), (2.0, 0.0), (0.0, 0.0)]
>>> pp2.interiors[0].coords[:]
[(2.0, 1.0), (2.0, 2.0), (1.0, 2.0), (1.0, 1.0), (2.... |
Auto-Loading a module on IPython startup | 20,835,977 | 8 | 2013-12-30T08:32:38Z | 20,936,088 | 7 | 2014-01-05T16:34:19Z | [
"python",
"python-2.7",
"module",
"ipython",
"startup"
] | I'm trying to to auto load the `division` module from `__future__` on startup,
i've currently got a simple script in the IPython startup libray with the line:
```
from __future__ import division
```
which works fine when run directly from the shell,
however, the module does not appear to load when the line is run fro... | i've found a solution to this one, in your IPython profile directory (by default - `.ipython\profile_default`), edit the file `ipython_config.py` (create it with `ipython profile create` if it does not exist) with the following lines:
```
# loads the root config object
c=get_config()
# executes the line in brackets o... |
BOTO : How to retrieve ipRanges from a security group object? | 20,836,303 | 4 | 2013-12-30T08:57:39Z | 20,839,653 | 9 | 2013-12-30T12:32:59Z | [
"python",
"amazon-web-services",
"boto"
] | I m using **Python AWS-SDK BOTO**. I m trying to retrieve all the security group details of my account.
```
secgrpList = ec2conn.get_all_security_groups()
ipRange = secgrpList[0].rules[1].ipRanges
print ipRange
print type(ipRange).__name__
```
But when i print the ipRange it shows nothing just two `enter`. When i che... | To loop over all security groups and print its rules including protocol, ports and ip range, try this:
```
import boto.ec2
conn = boto.ec2.connect_to_region("eu-west-1")
groups = conn.get_all_security_groups()
for group in groups:
print group.name
for rule in group.rules:
print rule.ip_protocol, rule.f... |
Changing the referrer URL in python requests | 20,837,786 | 16 | 2013-12-30T10:36:06Z | 20,838,143 | 25 | 2013-12-30T10:59:34Z | [
"python",
"python-2.7",
"python-requests",
"referer"
] | How do I change the referrer if I'm using the requests library to make a GET request to a web page. I went through the entire manual, but couldn't find it. | According to <http://docs.python-requests.org/en/latest/user/advanced/#session-objects> , you should be able to do:
```
s = requests.Session()
s.headers.update({'referer': my_referer})
s.get(url)
```
Or just:
```
requests.get(url, headers={'referer': my_referer})
```
Your `headers` dict will be merged with the defa... |
Resize display resolution using python with cross platform support | 20,838,201 | 11 | 2013-12-30T11:03:20Z | 20,881,688 | 7 | 2014-01-02T11:14:05Z | [
"python",
"windows",
"cross-platform",
"desktop-application",
"screen-resolution"
] | Resize display resolution using a python function. It should be cross platform, ie support for windows, linux and mac (it is okay to have multiple cases depending on the operating system)
I have code which I think works on linux (Ubuntu) I am looking for a solution for windows and mac (should support both 32 and 64 bi... | Many of the answers are already scattered around StackOverflow and can be summarized as follows.
To get the resolution on Windows in a purely pythonic fashion (reference: <http://stackoverflow.com/a/3129524/2942522>):
```
import ctypes
user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetS... |
What is the point of .ix indexing for pandas Series | 20,838,395 | 15 | 2013-12-30T11:15:58Z | 20,842,283 | 17 | 2013-12-30T15:18:14Z | [
"python",
"pandas"
] | For the Series object (let's call it s), pandas offers three types of addressing.
s.iloc[] -- for integer position addressing;
s.loc[] -- for index label addressing; and
s.ix[] -- for a hybrid of integer position and label addressing.
The pandas object also performs ix addressing directly.
```
# play data ...
impo... | For a `Series`, `.ix` is equivalent of `[]`, the `getitem` syntax. `.ix/.loc` support multi-axis indexing, which for a Series does not matter (only has 1 axis), and hence is there for compatibility.
e.g.
```
DataFrame(...).ix[row_indexer,column_indexer]
Series(...).ix[row_indexer]
```
`.ix` itself is an 'older' meth... |
How to remove project PyCharm? | 20,839,182 | 28 | 2013-12-30T12:04:19Z | 21,887,362 | 31 | 2014-02-19T17:05:05Z | [
"python",
"pycharm"
] | If I'm closing project and then just delete project folder, then after PyCharm restarts empty project folder created again. | Just follow these steps in order. They assume you currently have the project open in a PyCharm window:
1. Close your project by clicking on File -> Close Project
2. Locate your project in the PyCharm file directory
3. Delete your project's directory
I agree that PyCharm's handling of what should be a very simple proc... |
How to remove project PyCharm? | 20,839,182 | 28 | 2013-12-30T12:04:19Z | 23,500,783 | 29 | 2014-05-06T17:07:35Z | [
"python",
"pycharm"
] | If I'm closing project and then just delete project folder, then after PyCharm restarts empty project folder created again. | If you want to remove the project from the recent projects list, just highlight the project with your mouse and hit the del key. |
Python 'return not' statement in subprocess returncode | 20,839,849 | 3 | 2013-12-30T12:43:47Z | 20,839,875 | 8 | 2013-12-30T12:45:36Z | [
"python",
"return",
"subprocess",
"popen",
"return-code"
] | I just came across a very strange line of code in Python:
```
....
self.myReturnCode = externalProcessPopen.returncode
....
....
return not self.myReturnCode
....
```
What exactly `return not` stands for? I am aware that the returncode of a Popen process is None while it's still running and a random number once it co... | `not` is a [boolean operator](http://docs.python.org/2/reference/expressions.html#boolean-operations) that returns the boolean inverse of the value. `return` returns the result of that operator. In other words, the expression should be read as `return (not self.myReturnCode)`. Quoting the documentation:
> The operator... |
How to convert false to 0 and true to 1 in python | 20,840,803 | 12 | 2013-12-30T13:45:16Z | 20,840,816 | 30 | 2013-12-30T13:46:09Z | [
"python"
] | I'm just wondering is there any way in python which converts `true` of type `unicode` to 1 and `false` of type `unicode` to 0.
For eg:- `x = 'true' and type(x) = unicode`
I want `x = 1`
PS:- I dont want to use if-else. | Use `int()` on a boolean test:
```
x = int(x == 'true')
```
`int()` turns the boolean into `1` or `0`. Note that any value **not** equal to `'true'` will result in `0` being returned. |
How to predict time series in scikit-learn? | 20,841,167 | 17 | 2013-12-30T14:06:33Z | 20,842,836 | 10 | 2013-12-30T15:51:08Z | [
"python",
"machine-learning",
"time-series",
"scikit-learn"
] | Scikit-learn utilizes a very convenient approach based on `fit` and `predict` methods. I have already time-series data in the format suited for `fit` and `predict`.
For example I have the following `Xs`:
```
[[1.0, 2.3, 4.5], [6.7, 2.7, 1.2], ..., [3.2, 4.7, 1.1]]
```
and the corresponding `ys` are:
```
[[1.0], [2.... | This *might* be what you're looking for, with regard to the exponentially weighted moving average:
```
import pandas, numpy
ewma = pandas.stats.moments.ewma
EMOV_n = ewma( ys, com=2 )
```
Here, `com` is a parameter that you can read about [here](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.stats.momen... |
How to predict time series in scikit-learn? | 20,841,167 | 17 | 2013-12-30T14:06:33Z | 21,438,635 | 10 | 2014-01-29T17:45:29Z | [
"python",
"machine-learning",
"time-series",
"scikit-learn"
] | Scikit-learn utilizes a very convenient approach based on `fit` and `predict` methods. I have already time-series data in the format suited for `fit` and `predict`.
For example I have the following `Xs`:
```
[[1.0, 2.3, 4.5], [6.7, 2.7, 1.2], ..., [3.2, 4.7, 1.1]]
```
and the corresponding `ys` are:
```
[[1.0], [2.... | According to Wikipedia, EWMA works well with stationary data, but it does not work as expected in the presence of trends, or seasonality. In those cases your should use a second or third order EWMA method, respectively. I decided to look at the pandas `ewma` function to see how it handled trends, and this is what I cam... |
libpython2.7.so.1.0: cannot open shared object file: No such file or directory | 20,842,732 | 8 | 2013-12-30T15:45:48Z | 35,623,092 | 10 | 2016-02-25T09:23:41Z | [
"python",
"shared-libraries"
] | I have trying to run python script from the terminal but getting the next error message :
```
ImportError: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
```
if I run print sys.version I get :
```
>>> import sys
>>> print sys.version
2.7.3 (default, Feb 26 2013, 16:27:39)
[GCC 4.4.6 2... | Try to find file `libpython2.7.so.1.0`:
`locate libpython2.7.so.1.0`
In my case, it show out put:
`/opt/rh/python27/root/usr/lib64/libpython2.7.so.1.0`
Then add dir `/opt/rh/python27/root/usr/lib64` to file `/etc/ld.so.conf`
And run `ldconfig`.
It solved my problem. Goodluck! |
Where to save my custom scripts so that my python scripts can access the module in the default directory? | 20,843,088 | 6 | 2013-12-30T16:06:53Z | 20,862,632 | 7 | 2013-12-31T19:58:08Z | [
"python",
"import",
"directory",
"native"
] | This is going to be a multi-part question but the ultimate aim is such that I can access custom-made modules/libraries/functions like how I do in native python.
**Where are the non-native but `pip` installed python libraries stored and how to configure my interpreter/IDE to access them?**
My users' script all starts ... | Well, you've asked a lot of questions; I will address the one in the subject line.
You can put Python module files anywhere you want and still `import` them without any problems as long as they are in your [module search path](http://docs.python.org/2/tutorial/modules.html#the-module-search-path). You can influence yo... |
Python remove certain elements in source | 20,843,434 | 3 | 2013-12-30T16:26:28Z | 20,843,682 | 8 | 2013-12-30T16:40:04Z | [
"python",
"regex"
] | I have some source where I am trying to remove some tags, I do know that using regular expression for removing tags and such is not advised but figured this would be the easiest route to take.
What I need to do is remove all `img` and `a` tags along with the contents of the `a` tags that are **only** inside a `p` tag ... | Your regular expression indeed will remove all tags without using some type of assertion. Although you possibly could use regular expression to perform this, I do advise not going this route for many reasons.
You could simply use [`BeautifulSoup`](http://www.crummy.com/software/BeautifulSoup/bs4/doc/#) to pass a list ... |
How to avoid Python/Pandas creating an index in a saved csv? | 20,845,213 | 51 | 2013-12-30T18:24:25Z | 25,230,582 | 80 | 2014-08-10T16:17:52Z | [
"python",
"csv",
"indexing",
"pandas"
] | I am trying to save a csv to a folder after making some edits to the file.
Every time I use `pd.to_csv('C:/Path of file.csv')` the csv file has a separate column of indexes. I want to avoid this so I found that it may be possible to write `index_col =False`.
I then used for both
```
pd.read_csv('C:/Path to file to e... | Use `index=False`.
```
pd.to_csv('your.csv', index=False)
``` |
Python exception handling - How to do it pythonic? | 20,845,549 | 6 | 2013-12-30T18:47:54Z | 20,845,803 | 9 | 2013-12-30T19:06:07Z | [
"python",
"exception"
] | I am still learning the Python programmimg language. I asked myself in terms of code exceptions, when it is neccessary to handle such situations in a pythonic way. I read a few times "you should never pass an error silently".
For example a little function:
```
def square(list_with_items):
return [i**2 for i in li... | In the specific case of checking types, the "Pythonic" thing to do is not to check them. Unless there is a good reason, you should assume that the caller is passing in a sensible type (note: "sensible type" might be different from "the type you expect"), and do your best to return something sensible as well. If the cal... |
python bit array (performant) | 20,845,686 | 5 | 2013-12-30T18:58:15Z | 20,846,054 | 16 | 2013-12-30T19:23:57Z | [
"python",
"performance",
"bitarray",
"bloom-filter"
] | I'm designing a bloom filter and I'm wondering what the most performant bit array implementation is in Python.
The nice thing about Python is that it can handle arbitrary length integers out of the box and that's what I use now, but I don't know enough about Python internals to know if that's the most performant way t... | The built-in `int` is pretty nicely optimized, and it already supports `&`, `|`, and `<<`.
There's at least one alternative implementation of arbitrary-length integers, based on [GMP](https://gmplib.org), known as [`gmpy2`](https://pypi.python.org/pypi/gmpy2/2.0.3). (There's also the original `gmpy`, `PyGMP`, `Sophie`... |
How does del operator work in list in python? | 20,847,149 | 8 | 2013-12-30T20:37:57Z | 20,847,186 | 11 | 2013-12-30T20:40:53Z | [
"python",
"list",
"del"
] | I have read the `python docs` for `list` and how the `del` operators works, but I need explanation for the following behavior
In this case, `c` and `l` points to the same object(list), so doing changes on one affects the other, but deleting one does not delete the object. So what happens here? Is it just the `pointer`... | `l` and `c` are *bound* to the same object. They both are references to a list, and manipulating that list object is visible through both references. `del c` *unbinds* `c`; it removes the reference to the list.
`del l[::2]` removes a specific set of indices *from the list*, you are now operating on the list object *it... |
program to extract every alternate letters from a string in python? | 20,847,205 | 3 | 2013-12-30T20:42:07Z | 20,847,220 | 14 | 2013-12-30T20:43:02Z | [
"python",
"string"
] | Python programs are often short and concise and what usually requires bunch of lines in other programming languages (that I know of) can be accomplished in a line or two in python.
One such program I am trying to write was to extract every other letters from a string.
I have this working code, but wondering if any othe... | ```
>>> 'abcdefg'[::2]
'aceg'
``` |
program to extract every alternate letters from a string in python? | 20,847,205 | 3 | 2013-12-30T20:42:07Z | 20,847,228 | 9 | 2013-12-30T20:43:19Z | [
"python",
"string"
] | Python programs are often short and concise and what usually requires bunch of lines in other programming languages (that I know of) can be accomplished in a line or two in python.
One such program I am trying to write was to extract every other letters from a string.
I have this working code, but wondering if any othe... | Use [Python's slice notation](http://stackoverflow.com/questions/509211/pythons-slice-notation):
```
>>> 'abcdefg'[::2]
'aceg'
>>>
```
The format for slice notation is `[start:stop:step]`. So, `[::2]` is telling Python to step through the string by 2's (which will return every other character). |
Python: Inheritance versus Composition | 20,847,727 | 5 | 2013-12-30T21:16:48Z | 34,832,643 | 8 | 2016-01-16T22:03:24Z | [
"python",
"inheritance",
"composition"
] | I am working with two classes in Python, one of which should be allowed to have any number objects from another class as children while keeping an inventory of these children as an attribute. Inheritance seemed like the obvious choice for this parent<>child situation but instead what I have arrived at is an example of ... | It is definitely not good to inherint Child from Parent or Parent from Child.
The correct way to do it is to make a base class, let's say Person and inherit both Child and Parent from it.
An advantage of doing this is to remove code repetition, at the moment you have only firstname / lastname fields copied into both o... |
pandas dataframe as field in django | 20,847,791 | 5 | 2013-12-30T21:21:13Z | 20,850,627 | 7 | 2013-12-31T02:06:22Z | [
"python",
"arrays",
"django",
"pandas"
] | I want to add pandas dataframe (or a numpy array) as a field in django model. Each model instance in django has a large size 2D array associated with it so I want to store it as numpy array or pandas dataframe.
please guide me how can I achieve it. I tried below but it doesn't work.
```
from django.db import models
i... | You're likely gonna want to use a [PickleField](https://github.com/gintas/django-picklefield) to store your numpy or Pandas dataframe. The PickleField will serialize the data into a text field for the database storage and convert it back upon retrieval.
```
from django.db import models
from picklefield.fields import P... |
In python how to I make [x , y] into individual variables? | 20,848,222 | 2 | 2013-12-30T21:55:50Z | 20,848,240 | 8 | 2013-12-30T21:57:04Z | [
"python"
] | I'm working with an API that returns variables in this format:
```
[x, y]
```
How can I take that and turn it into individual x and y variables? | ```
>>> a,b = [1, 2]
>>> a
1
>>> b
2
``` |
unable to create autoincrementing primary key with flask-sqlalchemy | 20,848,300 | 10 | 2013-12-30T22:02:45Z | 20,861,531 | 7 | 2013-12-31T18:06:50Z | [
"python",
"postgresql",
"sqlalchemy",
"flask",
"flask-sqlalchemy"
] | I want my model's primary key to be an autoincrementing integer. Here is how my model looks like
```
class Region(db.Model):
__tablename__ = 'regions'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(100))
parent_id = db.Column(db.Integer, db.ForeignKey('regio... | Nothing is wrong with the above code. In fact, you don't even need `autoincrement=True` or `db.Sequence('seq_reg_id', start=1, increment=1),` as SQLAlchemy will automatically set the first `Integer` PK column that's not marked as a FK as `autoincrement=True`.
Here, I've put together a working setup based on yours. SQL... |
Python HMAC: TypeError: character mapping must return integer, None or unicode | 20,849,805 | 11 | 2013-12-31T00:21:54Z | 20,862,445 | 21 | 2013-12-31T19:37:36Z | [
"python"
] | I am having a slight problem with HMAC. When running this piece of code:
```
signature = hmac.new(
key=secret_key,
msg=string_to_sign,
digestmod=sha1,
)
```
I get a strange error:
```
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 133, in new
... | As asked I'll post this as an answer.
The error that you faced is a *feature* of Python's HMAC. It does not accept unicode.
This *feature* is described [here](http://bugs.python.org/issue5285).
HMAC is a function which works at byte level. For this reason in Python 3 it accepts only `bytes`. In Python 2 we don't have ... |
Comparing Two Lists to Find Bigger List | 20,850,998 | 7 | 2013-12-31T02:49:11Z | 20,851,070 | 8 | 2013-12-31T02:58:31Z | [
"python",
"arrays",
"list"
] | I have two lists and need to compare them by their largest element, if that is tied, their 2nd largest element, and if that is tied, 3rd largest etc iterating to the entire array.
For example:
```
list1= [0,2,3,6,12]
list2= [1,2,3,6,12]
list3= [1,4,5,8,12]
list4= [1,4,5,9,12]
```
So list4 > list3 > list2 > list1.
I... | How about this?
```
>>> list1= [0,2,3,6,12]
>>> list2= [1,2,3,6,12]
>>> list3= [1,4,5,8,12]
>>> list4= [1,4,5,9,12]
>>> def sort_lists_by_maxes(*lists):
return sorted(lists, key=lambda x: sorted(x, reverse=True), reverse=True)
>>> sort_lists_by_maxes(list1, list2, list3, list4)
[[1, 4, 5, 9, 12], [1, 4, 5, 8, 12]... |
Python PyCrypto encrypt/decrypt text files with AES | 20,852,664 | 4 | 2013-12-31T06:09:52Z | 20,868,265 | 16 | 2014-01-01T11:43:09Z | [
"python",
"file",
"encryption",
"aes",
"pycrypto"
] | I already have a working program, but the only thing that doesn't work is the decrypt\_file() function I have. I can still copy the encrypted text from the file and put it in my decrypt() function and have it work, but when I try to use my supposed-to-be handy decrypt\_file() function it throws an error. Now I know 99.... | I took a closer look at your code, and saw that there were several problems with it. First one is that the crypto functions with with bytes, not text. So it's better to just keep the data as a byte string. This is done simply by putting a 'b' character in the mode. This way you can get rid of all the encoding and bytes... |
ImportError: No module named dateutil.parser | 20,853,474 | 37 | 2013-12-31T07:18:17Z | 22,920,808 | 75 | 2014-04-07T19:01:50Z | [
"python",
"pandas",
"pip"
] | I am receiving the following error when importing `pandas` in a `Python` program
```
monas-mbp:book mona$ sudo pip install python-dateutil
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Cleaning up...
monas-mbp:boo... | On Ubuntu you may need to install the package manager `pip` first:
```
sudo apt-get install python-pip
```
Then install the `python-dateutil` package with:
```
sudo pip install python-dateutil
``` |
ImportError: No module named dateutil.parser | 20,853,474 | 37 | 2013-12-31T07:18:17Z | 26,865,524 | 7 | 2014-11-11T12:59:19Z | [
"python",
"pandas",
"pip"
] | I am receiving the following error when importing `pandas` in a `Python` program
```
monas-mbp:book mona$ sudo pip install python-dateutil
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Cleaning up...
monas-mbp:boo... | You can find the dateutil package at <https://pypi.python.org/pypi/python-dateutil>. Extract it to somewhere and run the command:
`python setup.py install`
It worked for me! |
SelectField in wtforms and added <option> via javascript | 20,856,893 | 4 | 2013-12-31T11:47:25Z | 20,862,553 | 8 | 2013-12-31T19:50:31Z | [
"python",
"pyramid",
"wtforms"
] | I'm currently work on some project in pyramid and have problem with wtforms SelectField.
I have a 3 SelectField fields:
* car\_make (e.g., "audi")
* car\_model (e.g., "audi 80")
* car\_version (e.g., "AUDI 80 B4").
The car\_make choices I can load in the view. The choices for rest of SelectFields (car\_model, car\_v... | What you are asking to do is have WTForms handle "cascading selects" (having the valid fields of one choice be determined by the value of another field). There really isn't a good way using the built in fields.
The SelectField in WTForms does NOT provide you with an option to say "Don't validate that the choice suppli... |
Using pass on a non necessary else statement | 20,859,998 | 4 | 2013-12-31T16:08:10Z | 20,860,027 | 9 | 2013-12-31T16:10:01Z | [
"python",
"pep8"
] | Based on PEP8 documentation, I was not able to find any reference regarding if I should use `pass` for aesthetic reasons on code. Based on the example below, should I keep those `else` or can I erase them? Until now, the main reason I'm keeping it is based on the mantra "Explicit is better than implicit."
```
if field... | Yes, you can/should remove them because they do nothing.
The Python community teaches "explicit is better than implicit" as long as the explicit code does something useful. Those `else: pass`'s however contribute nothing positive to the code. Instead, all they do is pointlessly consume two lines each. |
Python sqlite3 cursor has no attribute commit | 20,860,127 | 5 | 2013-12-31T16:17:02Z | 20,860,210 | 9 | 2013-12-31T16:22:11Z | [
"python",
"sqlite3"
] | When I run this code:
```
path = '~/Scripts/wallpapers/single.png'
conn = sqlite3.connect('/Users/Heaven/Library/Application Support/Dock/desktoppicture.db')
cur = conn.cursor();
cur.execute("insert into data values ('" + path + "');")
cur.commit()
```
I receive the following error
```
AttributeError: 'sqlite3.Curso... | `commit()` is a member method of `sqlite3.Connection` not `sqlite3.Cursor`. Here it is in the [docs](http://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.commit). |
itertools.imap vs map over the entire iterable | 20,860,181 | 2 | 2013-12-31T16:20:07Z | 20,860,218 | 7 | 2013-12-31T16:22:49Z | [
"python",
"python-2.x",
"itertools"
] | I'm curious about a statement from <http://docs.python.org/2/library/itertools.html#itertools.imap>, namely it describes
```
sum(imap(operator.mul, vector1, vector2))
```
as an efficient dot-product. My understanding is that imap gives a generator instead of a list, and while I understand how it would be faster/consu... | The first line will calculate the sum accumulating items one by one. The second one will at first calculate the whole dot-product, and after that, having the whole result in memory it would proceed to calculate the sum. So there is a memory complexity gain. |
itertools.imap vs map over the entire iterable | 20,860,181 | 2 | 2013-12-31T16:20:07Z | 20,860,321 | 8 | 2013-12-31T16:29:29Z | [
"python",
"python-2.x",
"itertools"
] | I'm curious about a statement from <http://docs.python.org/2/library/itertools.html#itertools.imap>, namely it describes
```
sum(imap(operator.mul, vector1, vector2))
```
as an efficient dot-product. My understanding is that imap gives a generator instead of a list, and while I understand how it would be faster/consu... | The difference between `map` and `imap` becomes clear when you start increasing the size of what you're iterating over:
```
# xrange object, takes up no memory
data = xrange(1000000000)
# Tries to builds a list of 1 billion elements!
# Therefore, fails with MemoryError on 32-bit systems.
doubled = map(lambda x: x * 2... |
How Do I Setup SublimeREPL with Anaconda's interpreter? | 20,861,176 | 7 | 2013-12-31T17:38:32Z | 20,861,527 | 12 | 2013-12-31T18:06:29Z | [
"python",
"sublimetext",
"anaconda"
] | I love Python in Sublimetext, but what I really need is an interactive mode for data exploration. However, for the life of me I cannot get SublimeREPL to use Anaconda's interpreter. Any ideas would be appreciated.
I have added the following to my SublimeREPL.settings.user file, but it doesn't have any effect:
```
{
... | In your `Packages/User` folder, create `SublimeREPL/config/Python/Main.sublime-menu` with the following contents:
```
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
... |
Extracting indices from numpy array python | 20,862,702 | 2 | 2013-12-31T20:07:18Z | 20,862,720 | 7 | 2013-12-31T20:09:52Z | [
"python",
"numpy"
] | I want the last 4 values of this equation.
Is there a better way to this in one step, like modifying the equation or another extraction technique other than using `delete`
```
a=5
d=2
n = np.cumsum(d ** np.arange(1, a+1))
print 'n=', n
n = np.delete(n,0)
print 'n extracted=', n
n= [ 2 6 14 30 62]
n extracted= [ 6 ... | ```
print n[-4::]
```
will print the last 4 elements. You can do all kinds of array slicing like this, the above was just an example. You can index the array from the front or the back. |
How do I install psycopg2 for Python 3.x? | 20,863,295 | 8 | 2013-12-31T21:18:14Z | 20,863,357 | 12 | 2013-12-31T21:25:53Z | [
"python",
"django",
"python-3.x",
"pycharm",
"psycopg2"
] | Just started Python a few days ago and I'm using PyCharm to develop a web application with Django. I have libpq-dev python-dev packages already installed, but it's still throwing me the same error:
```
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
```
which according to Google is the iss... | Just run this using the terminal:
```
$ sudo apt-get install python3-dev
```
This way, you could use gcc to build the module you're trying to use. |
How do I install psycopg2 for Python 3.x? | 20,863,295 | 8 | 2013-12-31T21:18:14Z | 27,315,639 | 15 | 2014-12-05T12:11:51Z | [
"python",
"django",
"python-3.x",
"pycharm",
"psycopg2"
] | Just started Python a few days ago and I'm using PyCharm to develop a web application with Django. I have libpq-dev python-dev packages already installed, but it's still throwing me the same error:
```
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or directory
```
which according to Google is the iss... | On Ubuntu you just run this:
```
sudo apt-get install python3-psycopg2
``` |
Flask-Login + Flask-Sockets = Chaos | 20,863,629 | 2 | 2013-12-31T22:00:14Z | 20,872,146 | 7 | 2014-01-01T19:06:05Z | [
"python",
"flask",
"websocket"
] | I have installed Flask-Login and Flask-Sockets. Both of them work fine HOWEVER when I try to get the current user (using g.user), I get an `AttributeError: '_AppCtxGlobals' object has no attribute 'user'`
```
@sockets.route('/echo')
def echo_socket(ws):
with app.app_context():
user = current_user #This cau... | The problem is that you are treating your socket functions as if they were regular requests, which they are not.
In a regular (i.e. non-socket) situation the client sends requests to the server. Each request contains a cookie that was set at login time by Flask-Login. This cookie contains the user that is logged in. F... |
Get Public URL for File - Google Cloud Storage - App Engine (Python) | 20,863,747 | 4 | 2013-12-31T22:17:19Z | 21,226,442 | 12 | 2014-01-20T04:49:56Z | [
"python",
"google-app-engine",
"cloud",
"google-cloud-storage"
] | Is there a python equivalent to the getPublicUrl [PHP method](https://developers.google.com/appengine/docs/php/googlestorage/)?
```
$public_url = CloudStorageTools::getPublicUrl("gs://my_bucket/some_file.txt", true);
```
I am storing some files using the Google Cloud Client Library for Python, and I'm trying to figur... | Please read:
<https://cloud.google.com/storage/docs/reference-uris>
http(s)://storage.googleapis.com/[bucket]/[object]
or
http(s)://[bucke].storage.googleapis.com/[object]
Example:
```
bucket = 'my_bucket'
file = 'some_file.txt'
gcs_url = 'https://%(bucket)s.storage.googleapis.com/%(file)s' % {'bucket':bucket, 'f... |
Probability to z-score and vice versa in python | 20,864,847 | 17 | 2014-01-01T01:35:33Z | 20,864,883 | 32 | 2014-01-01T01:47:04Z | [
"python",
"statistics"
] | I have numpy, statsmodel, pandas, and scipy(I think)
How do I calculate the z score of a p-value and vice versa?
For example if I have a p value of 0.95 I should get 1.96 in return.
I saw some functions in scipy but they only run a z-test on a array. | ```
>>> import scipy.stats as st
>>> st.norm.ppf(.95)
1.6448536269514722
>>> st.norm.cdf(1.64)
0.94949741652589625
```
[](http://i.stack.imgur.com/fGYNp.png)
As other users noted, Python calculates left/lower-tail probabilities by default. If you want... |
Get list of circles of a user using Google Plus API using python client | 20,868,048 | 3 | 2014-01-01T11:13:57Z | 20,868,497 | 7 | 2014-01-01T12:12:23Z | [
"python",
"google-app-engine",
"google-api",
"google-plus",
"google-api-python-client"
] | I am using Google OAuth2 authentication with the following scope included:
```
https://www.googleapis.com/auth/plus.login
```
This allows my application to access a user's Google plus account information (basic).
Is it possbile to get a list of the user's **"Circles"** using the `google-api-python-client`
If yes, ho... | There is no way to do this with the regular Google+ API. As you seem to be aware, it can be achieved with the Google+ Domains API but that requires your target user to be a Google Apps account and you to have admin access to the domain. |
Pandas and sum and cum sum in same dataframe | 20,868,232 | 3 | 2014-01-01T11:39:51Z | 20,868,409 | 7 | 2014-01-01T12:02:05Z | [
"python",
"pandas"
] | I use the below to create a sum and a cumsum. But they are in two separate dataframes. I want all in one
```
asp = np.array(np.array([0,0,1]))
asq = np.array(np.array([10,10,20]))
columns=['asp']
df = pd.DataFrame(asp, index=None, columns=columns)
df['asq'] = asq
df = df.groupby(by=['asp']).sum()
dfcum =df.cumsum()
``... | Maybe you want this?
```
In [20]: df['asq_cum']=df['asq'].cumsum()
In [21]: df
Out[21]:
asq asq_cum
asp
0 20 20
1 20 40
``` |
Changing a specific column name in pandas DataFrame | 20,868,394 | 62 | 2014-01-01T11:59:54Z | 20,868,446 | 117 | 2014-01-01T12:06:46Z | [
"python",
"pandas"
] | I was looking for an elegant way to change a specified column name in a `DataFrame`.
play data ...
```
import pandas as pd
d = {
'one': [1, 2, 3, 4, 5],
'two': [9, 8, 7, 6, 5],
'three': ['a', 'b', 'c', 'd', 'e']
}
df = pd.DataFrame(d)
```
The most elegant solution I have found so far .... | A one liner does exist:
```
In [27]: df=df.rename(columns = {'two':'new_name'})
In [28]: df
Out[28]:
one three new_name
0 1 a 9
1 2 b 8
2 3 c 7
3 4 d 6
4 5 e 5
```
Following is the docstring for the `rename` method.
```
Definition: df.re... |
Changing a specific column name in pandas DataFrame | 20,868,394 | 62 | 2014-01-01T11:59:54Z | 25,574,089 | 39 | 2014-08-29T18:23:55Z | [
"python",
"pandas"
] | I was looking for an elegant way to change a specified column name in a `DataFrame`.
play data ...
```
import pandas as pd
d = {
'one': [1, 2, 3, 4, 5],
'two': [9, 8, 7, 6, 5],
'three': ['a', 'b', 'c', 'd', 'e']
}
df = pd.DataFrame(d)
```
The most elegant solution I have found so far .... | Since `inplace` argument is available, you don't need to copy and assign the original data frame back to itself, but do as follows:
```
df.rename(columns={'two':'new_name'}, inplace=True)
``` |
Changing a specific column name in pandas DataFrame | 20,868,394 | 62 | 2014-01-01T11:59:54Z | 34,192,820 | 9 | 2015-12-10T02:41:10Z | [
"python",
"pandas"
] | I was looking for an elegant way to change a specified column name in a `DataFrame`.
play data ...
```
import pandas as pd
d = {
'one': [1, 2, 3, 4, 5],
'two': [9, 8, 7, 6, 5],
'three': ['a', 'b', 'c', 'd', 'e']
}
df = pd.DataFrame(d)
```
The most elegant solution I have found so far .... | What about?
```
df.columns.values[2] = "new_name"
``` |
What is the pythonic way to write strings to file? | 20,868,484 | 5 | 2014-01-01T12:10:29Z | 20,868,556 | 8 | 2014-01-01T12:18:37Z | [
"python",
"file-io"
] | What's the difference between using `File.write()` and `print>>File,`?
Which is the pythonic way to write to file?
```
>>> with open('out.txt','w') as fout:
... fout.write('foo bar')
...
>>> with open('out.txt', 'w') as fout:
... print>>fout, 'foo bar'
...
```
Is there an advantage when using `print>>File,... | `write()` method writes to a buffer, which (the buffer) is flushed to a file whenever overflown/file closed/gets explicit request (`.flush()`).
`print` will block execution till actual writing to file completes.
The first form is preferred because its execution is more efficient. Besides, the 2nd form is ugly and un-... |
Python counting through a number with >= | 20,868,522 | 8 | 2014-01-01T12:15:02Z | 20,868,640 | 10 | 2014-01-01T12:27:29Z | [
"python"
] | I'm learning Python(2.7) at the moment, and an exercise says to write a program which counts how many coins you need to pay a specific sum.
My solution is this:
```
sum = input("Bitte gebe einen Euro Betrag ein: ")
coins = []
euro = [20,10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01]
for i in euro:
while sum >= i:
s... | For currency calculations it's best to avoid `float` type if you can, because of accumulating rounding errors. You can do it in a way similar to this:
```
amount= input("Bitte gib einen Euro Betrag ein: ")
coins = []
cents = [2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1]
amount = int(float(amount) * 100)
for cent in... |
PyCharm "Run configuration" asking for "script parameters" | 20,868,780 | 10 | 2014-01-01T12:46:01Z | 21,081,281 | 9 | 2014-01-12T22:46:52Z | [
"python",
"ide",
"pycharm"
] | While writing an application parsing command line arguments I would like to run it with various parameters.
I don't want to create a *Run Configuration* for every possible command line argument that I want my script to test with. Is there a way in PyCharm (and I guess with any JetBrains IDE) to make a *Run Configurati... | Currently the only possibility is to use the "Before launch | Show this page" option. |
Python: list.sort() query when list contains different element types | 20,872,314 | 7 | 2014-01-01T19:22:30Z | 20,872,416 | 8 | 2014-01-01T19:34:17Z | [
"python",
"list",
"sorting",
"python-3.x"
] | Greetings Pythonic world. Day 4 of learning Python 3.3 and I've come across a strange property of `list.sort`.
I created a list of five elements: four strings, with a number in the middle. Trying to get `list.sort` to work gave the expected error because of mixing types:
```
>>> list = ['b', 'a', 3, 'd', 'c']
>>> lis... | From the Python 3 [docs](http://docs.python.org/dev/library/stdtypes.html#list.sort):
> This method sorts the list in place, using only < comparisons between
> items. Exceptions are not suppressed - if any comparison operations
> fail, the entire sort operation will fail (and the list will likely be
> left in a partia... |
Using IntellijIdea within an existing virtualenv | 20,877,106 | 31 | 2014-01-02T05:51:16Z | 20,879,661 | 40 | 2014-01-02T09:15:21Z | [
"python",
"django",
"intellij-idea",
"virtualenv",
"pycharm"
] | I want to use Intellij Idea within my existing python django project which was built within a virtual environment in ubuntu. How do I configure Intellij Idea to use the libraries of the virtual environment? | Well I solved the above problem. I have added virtualenv folder's python to project sdk. The virtualenv directory's python( for example venv/bin/python2.7) needs to be added to Intellij Idea project path. Example: need to go to file>project structure (intellij Idea)
, for example:
```
ITEM_PIPELINES = {
'myproject.pipeline.custompipeline': 300,
}
```
> The integer values you assign to classes in this setting dete... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.