qid
int64
46k
74.7M
question
stringlengths
54
37.8k
date
stringlengths
10
10
metadata
listlengths
3
3
response_j
stringlengths
17
26k
response_k
stringlengths
26
26k
63,415,954
why the result of C++ and python bitwise shift operator are diffrernt? python ``` >>> 1<<20 1048576 ``` C++ ``` cout <<1<<20; 120 ```
2020/08/14
[ "https://Stackoverflow.com/questions/63415954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13966865/" ]
The result differes because of the operator associativity in C++. ``` std::cout << 1 << 20; ``` is the same as ``` (std::cout << 1) << 20; ``` because `operator <<` is left-associative. What you intend to do is ``` std::cout << (1 << 20); ```
cout overloads the '<<' operator to print the values. So when you are doing ``` cout <<1<<20; ``` It actually prints 1 and 20 and doesnt do any shifting ``` int shifted = 1 << 20; cout << shifted; ``` This should return the same output as python's simpler way is to do ``` cout << (1 <<20); ```
69,592,525
I refer to [Python : Using the map function](https://stackoverflow.com/questions/18087544/python-using-the-map-function) It says "map returns a specific type of generator in Python 3 that is not a list (but rather a 'map object', as you can see). " That is my understanding too. Generator object do not contain the value...
2021/10/16
[ "https://Stackoverflow.com/questions/69592525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15670527/" ]
`del` doesn't remove the tuple from memory, it just removes the variable. The `map` object has its own reference to the tuple -- it's a class instance variable variable. Garbage collection doesn't remove a the tuple from memory until all references to it are destroyed. This will happen when the generator reaches the ...
With `del t1` you delete the *variable*, not the object it references. Before `del t1`: [![before](https://i.stack.imgur.com/7EsXt.png)](https://i.stack.imgur.com/7EsXt.png) After `del t1`: [![after](https://i.stack.imgur.com/0xwMq.png)](https://i.stack.imgur.com/0xwMq.png) So that's still all alive and well and f...
69,141,448
I have an error that I cannot resolve. here is the error I get when I authenticate with postman: **TypeError: Object of type ObjectId is not JSON serializable // Werkzeug Debugger** **File "C:\Users\Amoungui\AppData\Local\Programs\Python\Python39\Lib\json\encoder.py", line 179, in default raise TypeError(f'Object of ty...
2021/09/11
[ "https://Stackoverflow.com/questions/69141448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12665256/" ]
Try to use `timestamps` in your schema after defining you fields. ``` const itemSchema = mongoose.Schema({ person_name: String, person_position: String, person_level: String, },{timestamps:true}); var RecordItem = mongoose.model("recorditem", itemSchema); ```
There are several ways to safe createdAt 1. timestamp : true in options 2. `createdAt: { type: Date, default: Date.now },` 3. itemSchema.pre('save', function(next) { if (!this.createdAt) { this.createdAt = new Date(); } next(); });
68,168,293
I am trying to retrieve data from SQL Server database using python but the system crash and display the below error: > > ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'where'. (156) (SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQ...
2021/06/28
[ "https://Stackoverflow.com/questions/68168293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5980666/" ]
You have not declared user variable. Either declare it as follows: ``` const user = firebase.auth().currentUser ``` Or directly pass it as param if you don't need user object anywhere else: ``` .doc(firebase.auth().currentUser.uid) ```
You should initialize the user before using it. ``` // Your web app's Firebase configuration var firebaseConfig = { apiKey: "####", authDomain: "###.firebaseapp.com", projectId: "#", storageBucket: "#.appspot.com", messagingSenderId: "#", appId: "1:####" }; // Initialize Firebase fireb...
33,050,100
I am dealing with a simple csv file that contains three columns and three rows containing numeric data. The csv data file looks like the following: ``` Col1,Col2,Col3 1,2,3 2,2,3 3,2,3 4,2,3 ``` I have hard time figuring out how to let my python program subtracts the average value of the first column "Col1" fro...
2015/10/10
[ "https://Stackoverflow.com/questions/33050100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1974919/" ]
Please show your html page from where you are sending post data. I think you should have to make an array of $\_POST variables then you can get all the records at php side and you can insert all three records in table. Try this Please check the below link where you can find your solution [Inserting Multiple Rows with...
Create Model that holds all table columns. ``` class OrderModel extends BaseModel{ public $id; // Fill here all columns public function __construct($data) { foreach ($data as $key => $value) { $this->$key = $value; } } public function get_table_name() { return "ordering"; } }...
41,841,828
I would like to know if there is an else statement, like in python, that when attached to a **try-catch** structure, makes the block of code within it only executable if no exceptions were thrown/caught. For instance: ``` try { //code here } catch(...) { //exception handling here } ELSE { //this should ex...
2017/01/25
[ "https://Stackoverflow.com/questions/41841828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7408143/" ]
The concept of an `else` for a `try` block doesn't exist in c++. It can be emulated with the use of a flag: ``` { bool exception_caught = true; try { // Try block, without the else code: do_stuff_that_might_throw_an_exception(); exception_caught = false; // This needs to be the last...
Why not just put it at the end of the try block?
59,694,929
i am creating a project where react is not rendering anything on django localhost index.html ``` <!DOCTYPE html> <html lang="en"> <head></head> <body> <div id="App"> <!---all will be define in App.js--> <h1>Index.html </h1> </div> </body> {% load static%} <s...
2020/01/11
[ "https://Stackoverflow.com/questions/59694929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11631248/" ]
Change this source code: ``` document.getElementById('app') ``` ... to this: ``` document.getElementById('App') ```
Its because your element has id of "App" but you are trying to hook react app on element 'app'. It's case sensitive.
59,694,929
i am creating a project where react is not rendering anything on django localhost index.html ``` <!DOCTYPE html> <html lang="en"> <head></head> <body> <div id="App"> <!---all will be define in App.js--> <h1>Index.html </h1> </div> </body> {% load static%} <s...
2020/01/11
[ "https://Stackoverflow.com/questions/59694929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11631248/" ]
Change this source code: ``` document.getElementById('app') ``` ... to this: ``` document.getElementById('App') ```
document.getElementById is case sensitive
39,760,629
UnitTests has a feature to capture `KeyboardInterrupt`, finishes a test and then report the results. > > **-c, --catch** > > > *Control-C* during the test run waits for the current test to end and then reports all the results so far. A second *Control-C* > raises the normal KeyboardInterrupt exception. > > > See ...
2016/09/29
[ "https://Stackoverflow.com/questions/39760629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1603480/" ]
Your issue may lie in the execution ordering of your hook, such that pytest exits prior to your hook being executed. This could happen if an unhandled exception occurs in preexisting handling of the keyboard interrupt. To ensure your hook executes sooner, use `tryfirst` or `hookwrapper` as described [here](https://doc...
Take a look at pytest's [hookspec](http://doc.pytest.org/en/latest/_modules/_pytest/hookspec.html). They have a hook for keyword interrupt. ``` def pytest_keyboard_interrupt(excinfo): """ called for keyboard interrupt. """ ```
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
The reason this doesn’t work on Python 2 lies in its implementation of `literal_eval`. The original implementation only performed number evaluation for additions and subtractions when the righth operand was a complex number. This is syntactically necessary for complex numbers to be expressed as a literal. This [was ch...
Use the source, luke! [`http://hg.python.org/cpython/file/2.7/Lib/ast.py#l40`](http://hg.python.org/cpython/file/2.7/Lib/ast.py#l40) [`http://hg.python.org/cpython/file/3.2/Lib/ast.py#l39`](http://hg.python.org/cpython/file/3.2/Lib/ast.py#l39) You will find your answer in there. Specifically, the 2.7 version has the...
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
The reason this doesn’t work on Python 2 lies in its implementation of `literal_eval`. The original implementation only performed number evaluation for additions and subtractions when the righth operand was a complex number. This is syntactically necessary for complex numbers to be expressed as a literal. This [was ch...
It's in order to support complex numbers (since [issue 4907](http://bugs.python.org/issue4907)). For example, `1 + 2j` is parsed by the parser as an expression consisting of an integer literal, an addition operation and an [imaginary literal](http://docs.python.org/2/reference/lexical_analysis.html#imaginary-literals);...
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
The reason this doesn’t work on Python 2 lies in its implementation of `literal_eval`. The original implementation only performed number evaluation for additions and subtractions when the righth operand was a complex number. This is syntactically necessary for complex numbers to be expressed as a literal. This [was ch...
It is not too hard to use [pyparsing](http://pyparsing.wikispaces.com) to cobble together a simple expression evaluator. Suppose you want to eval expression, including parens, of the type of expressions of the following: ``` 2+3 4.0^2+5*(2+3+4) 1.23+4.56-7.890 (1+2+3+4)/5 1e6^2/1e7 ``` This simplification of the [S...
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
The reason this doesn’t work on Python 2 lies in its implementation of `literal_eval`. The original implementation only performed number evaluation for additions and subtractions when the righth operand was a complex number. This is syntactically necessary for complex numbers to be expressed as a literal. This [was ch...
An updated version of the answer from @poke that allows negative numbers in py3.x or other unary operators. So "-3" evaluates to -3 for example, rather than an error. ``` import ast, operator binOps = { ast.Add: operator.add, ast.Sub: operator.sub, ast.Mult: operator.mul, ast.Div: operator.truediv, ast.Mod: operator....
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
It's in order to support complex numbers (since [issue 4907](http://bugs.python.org/issue4907)). For example, `1 + 2j` is parsed by the parser as an expression consisting of an integer literal, an addition operation and an [imaginary literal](http://docs.python.org/2/reference/lexical_analysis.html#imaginary-literals);...
Use the source, luke! [`http://hg.python.org/cpython/file/2.7/Lib/ast.py#l40`](http://hg.python.org/cpython/file/2.7/Lib/ast.py#l40) [`http://hg.python.org/cpython/file/3.2/Lib/ast.py#l39`](http://hg.python.org/cpython/file/3.2/Lib/ast.py#l39) You will find your answer in there. Specifically, the 2.7 version has the...
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
Use the source, luke! [`http://hg.python.org/cpython/file/2.7/Lib/ast.py#l40`](http://hg.python.org/cpython/file/2.7/Lib/ast.py#l40) [`http://hg.python.org/cpython/file/3.2/Lib/ast.py#l39`](http://hg.python.org/cpython/file/3.2/Lib/ast.py#l39) You will find your answer in there. Specifically, the 2.7 version has the...
An updated version of the answer from @poke that allows negative numbers in py3.x or other unary operators. So "-3" evaluates to -3 for example, rather than an error. ``` import ast, operator binOps = { ast.Add: operator.add, ast.Sub: operator.sub, ast.Mult: operator.mul, ast.Div: operator.truediv, ast.Mod: operator....
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
It's in order to support complex numbers (since [issue 4907](http://bugs.python.org/issue4907)). For example, `1 + 2j` is parsed by the parser as an expression consisting of an integer literal, an addition operation and an [imaginary literal](http://docs.python.org/2/reference/lexical_analysis.html#imaginary-literals);...
It is not too hard to use [pyparsing](http://pyparsing.wikispaces.com) to cobble together a simple expression evaluator. Suppose you want to eval expression, including parens, of the type of expressions of the following: ``` 2+3 4.0^2+5*(2+3+4) 1.23+4.56-7.890 (1+2+3+4)/5 1e6^2/1e7 ``` This simplification of the [S...
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
It's in order to support complex numbers (since [issue 4907](http://bugs.python.org/issue4907)). For example, `1 + 2j` is parsed by the parser as an expression consisting of an integer literal, an addition operation and an [imaginary literal](http://docs.python.org/2/reference/lexical_analysis.html#imaginary-literals);...
An updated version of the answer from @poke that allows negative numbers in py3.x or other unary operators. So "-3" evaluates to -3 for example, rather than an error. ``` import ast, operator binOps = { ast.Add: operator.add, ast.Sub: operator.sub, ast.Mult: operator.mul, ast.Div: operator.truediv, ast.Mod: operator....
20,748,202
It is widely known that using `eval()` is a potential security risk so the use of [`ast.literal_eval(node_or_string)`](http://docs.python.org/2/library/ast.html#ast.literal_eval) is promoted However In python 2.7 it returns `ValueError: malformed string` when running this example: ``` >>> ast.literal_eval("4 + 9") `...
2013/12/23
[ "https://Stackoverflow.com/questions/20748202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425215/" ]
It is not too hard to use [pyparsing](http://pyparsing.wikispaces.com) to cobble together a simple expression evaluator. Suppose you want to eval expression, including parens, of the type of expressions of the following: ``` 2+3 4.0^2+5*(2+3+4) 1.23+4.56-7.890 (1+2+3+4)/5 1e6^2/1e7 ``` This simplification of the [S...
An updated version of the answer from @poke that allows negative numbers in py3.x or other unary operators. So "-3" evaluates to -3 for example, rather than an error. ``` import ast, operator binOps = { ast.Add: operator.add, ast.Sub: operator.sub, ast.Mult: operator.mul, ast.Div: operator.truediv, ast.Mod: operator....
61,385,841
I have specific question. I have lego EV3 and i installed Micropython. But i want import turtle, tkinter and other modules and they aren't in micropython. But time module working.Do someone know what modules are in ev3 micropython? Thanks for answer.
2020/04/23
[ "https://Stackoverflow.com/questions/61385841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13045504/" ]
To add bearer token in retrofit, you have to create a class that implements `Interceptor` ``` public class TokenInterceptor implements Interceptor{ @Override public Response intercept(Chain chain) throws IOException { //rewrite the request to add bearer token Request newRequest=chain.request(...
these three class will be your final setup for all types of call > > for first call(Login) you do not need to pass token and after login pass jwt as bearer token to authenticate after authentication do not need to pass > > > ``` public class ApiUtils { private static final String BASE_URL="https://abcd.abcd.com/...
38,775,586
The following python code: ``` # user profile information args = { 'access_token':access_token, 'fields':'id,name', } print 'ACCESSED', urllib.urlopen('https://graph.facebook.com/me', urllib.urlencode(args)).read() ``` Prints the following: *ACCESSED {"success":true}* The token is valid, no error, ...
2016/08/04
[ "https://Stackoverflow.com/questions/38775586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1507649/" ]
Turns out urllib.urlopen will send the data as a POST when the data parameter is provided. Facebook Graph API works using GET not POST. Change the call to trick the function into calling just a URL ( no data ): ``` print 'ACCESSED', urllib.urlopen('https://graph.facebook.com/me/?' + urllib.urlencode(args)).read() ```...
You have to add a `/` to the URL to get `https://graph.facebook.com/me/` instead of `https://graph.facebook.com/me`. ``` # user profile information args = { 'access_token':access_token, 'fields':'id,name' } print 'ACCESSED', urllib.urlopen('https://graph.facebook.com/me/', urllib.urlencode(args)).read() ``` ...
73,009,209
I have a pandas datafrme with a text column and was wondering how can I count the number of line breaks.This is how it's done in excel and would like to now how I can achieve this in python: [How To Count Number Of Lines (Line Breaks) In A Cell In Excel?](https://www.extendoffice.com/documents/excel/4785-excel-count-n...
2022/07/17
[ "https://Stackoverflow.com/questions/73009209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7297511/" ]
Your approach is slow because you loop over the rows and use intermediate copies. You should be able to use boolean indexing for direct swapping: ``` mask = final['HomeAway'].eq(0) final.loc[mask, 4:124], final.loc[mask, 124:] = final.loc[mask, 124:], final.loc[mask, 4:124] ```
The Data on which you are working is unknown and I have tried to replicate your problem with duplicate data. Change the variables and the indexing values while using it in your project **CODE** ``` import pandas as pd import numpy as np data = pd.DataFrame({"HomeAway": [1, 1, 0, 0, 1], "Value1":...
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
``` from django.contrib import admin,include admin.autodiscover() urlpatterns = patterns('', (r'^pnasser/',include('pnasser.urls')), (r'^admin/',include(admin.site.urls)), (r'^',include('pnasser.urls')), ) ``` maybe you missed "include" in the first line
``` Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ``` This error message should list all possible URLs, including the 'expanded' urls from your pnasser app. Since you're only getting the URLs from your main urls.py, it suggests you haven't properly enabled the `pnasser` app...
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
The problem seemed to be in the django.wsgi file - and the differences in how the standard django.wsgi file loads a python site vs how the development server loads the site. I guess it's a well known issue, that I was unaware of. Thanks everyone for the suggestions. Alternative django.wsgi file found here: <http://blo...
The following works for me: > > If your urls are not working correctly, you may need to add this line > to location /: > > > > ``` > fastcgi_split_path_info ^()(.*)$; > > ``` > > From: <https://code.djangoproject.com/wiki/DjangoAndNginx>
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
``` from django.contrib import admin,include admin.autodiscover() urlpatterns = patterns('', (r'^pnasser/',include('pnasser.urls')), (r'^admin/',include(admin.site.urls)), (r'^',include('pnasser.urls')), ) ``` maybe you missed "include" in the first line
Within your URL's file you can write something like the following below. += obviously allows us to add additional 'patterns' to our 'urlpatterns' variable, this also means we can wrap these in an 'if' statement. ``` urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), ) urlpatterns += patterns('', ...
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
The problem seemed to be in the django.wsgi file - and the differences in how the standard django.wsgi file loads a python site vs how the development server loads the site. I guess it's a well known issue, that I was unaware of. Thanks everyone for the suggestions. Alternative django.wsgi file found here: <http://blo...
``` Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ``` This error message should list all possible URLs, including the 'expanded' urls from your pnasser app. Since you're only getting the URLs from your main urls.py, it suggests you haven't properly enabled the `pnasser` app...
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
``` from django.contrib import admin,include admin.autodiscover() urlpatterns = patterns('', (r'^pnasser/',include('pnasser.urls')), (r'^admin/',include(admin.site.urls)), (r'^',include('pnasser.urls')), ) ``` maybe you missed "include" in the first line
The following works for me: > > If your urls are not working correctly, you may need to add this line > to location /: > > > > ``` > fastcgi_split_path_info ^()(.*)$; > > ``` > > From: <https://code.djangoproject.com/wiki/DjangoAndNginx>
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
The problem seemed to be in the django.wsgi file - and the differences in how the standard django.wsgi file loads a python site vs how the development server loads the site. I guess it's a well known issue, that I was unaware of. Thanks everyone for the suggestions. Alternative django.wsgi file found here: <http://blo...
``` from django.contrib import admin,include admin.autodiscover() urlpatterns = patterns('', (r'^pnasser/',include('pnasser.urls')), (r'^admin/',include(admin.site.urls)), (r'^',include('pnasser.urls')), ) ``` maybe you missed "include" in the first line
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
Within your URL's file you can write something like the following below. += obviously allows us to add additional 'patterns' to our 'urlpatterns' variable, this also means we can wrap these in an 'if' statement. ``` urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), ) urlpatterns += patterns('', ...
The following works for me: > > If your urls are not working correctly, you may need to add this line > to location /: > > > > ``` > fastcgi_split_path_info ^()(.*)$; > > ``` > > From: <https://code.djangoproject.com/wiki/DjangoAndNginx>
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
The problem is that you are using an empty regex (`"^"` will match anything, including an empty url) to handle an include directive. If you do that, it will always append a first slash at your request path. Considering that on your pnasser.urls does not contain a regex for "/", there is no match for a request on mysite...
``` Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ``` This error message should list all possible URLs, including the 'expanded' urls from your pnasser app. Since you're only getting the URLs from your main urls.py, it suggests you haven't properly enabled the `pnasser` app...
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
The problem seemed to be in the django.wsgi file - and the differences in how the standard django.wsgi file loads a python site vs how the development server loads the site. I guess it's a well known issue, that I was unaware of. Thanks everyone for the suggestions. Alternative django.wsgi file found here: <http://blo...
Within your URL's file you can write something like the following below. += obviously allows us to add additional 'patterns' to our 'urlpatterns' variable, this also means we can wrap these in an 'if' statement. ``` urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), ) urlpatterns += patterns('', ...
7,733,200
I'm trying to include an additional urls.py inside my main urls - however it doesn't seem to be working. I've done a bunch of searching and I can't seem to figure it out main urls.py file - the admin works fine ``` from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.au...
2011/10/11
[ "https://Stackoverflow.com/questions/7733200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225600/" ]
The problem is that you are using an empty regex (`"^"` will match anything, including an empty url) to handle an include directive. If you do that, it will always append a first slash at your request path. Considering that on your pnasser.urls does not contain a regex for "/", there is no match for a request on mysite...
The following works for me: > > If your urls are not working correctly, you may need to add this line > to location /: > > > > ``` > fastcgi_split_path_info ^()(.*)$; > > ``` > > From: <https://code.djangoproject.com/wiki/DjangoAndNginx>
56,093,339
I'm currently trying to write a script that does a specific action on a certain day. So for example, if today is the 6/30/2019 and in my dataframe there is a 6/30/2019 entry, xyz proceeds to happen. However, I am having troubles comparing the date from a dataframe to a DateTime date. Here's how I created the dataframe ...
2019/05/11
[ "https://Stackoverflow.com/questions/56093339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11486279/" ]
``` import datetime import pandas as pd da = str(datetime.datetime.now().date()) # converting the column to datetime, you can check the dtype of the column by doing # df['event_date'].dtypes df['event_date'] = pd.to_datetime(df['event_date']) # generate a df with rows where there is a match df_co = df.loc[df['eve...
``` import pandas as pd import time # keep only y,m,d, and throw out the rest: now = (time.strftime("%Y/%m/%d")) # the column in the dataframe needs to be converted to datetime first. df['event_date'] = pd.to_datetime(df['event_date']) # to return indices df[df['event_date']==now].index.values # if you want to lo...
44,089,727
i have a weekly report that i need to do, i chooseed to create it with openpyxl python module, and send it via mail, when i open the received mail (outlook), the cells with formulas appears as empty, but when downloading the file and open it, the data appears, OS fedora 20. parts of the code : ``` # imported ...
2017/05/20
[ "https://Stackoverflow.com/questions/44089727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6424190/" ]
Unfortunately not. There is no language support for what you want. Let me be specific about what you want just so that you understand what I answered. Your question is basically this: Given that I have *two* instances of an object, and I have properties in this object that have a private setter, is there any languag...
That won't work. If `Pos` is a property with a private setter (as it is) the only way they could change it would be by calling a public method from within `otherPlayer`. Something like `otherPlayer.SetPos(new Vector2(34,151))`, where `SetPos()` is: ``` public void SetPos(Vector2 NewPos) { Pos = NewPos; } ```
44,089,727
i have a weekly report that i need to do, i chooseed to create it with openpyxl python module, and send it via mail, when i open the received mail (outlook), the cells with formulas appears as empty, but when downloading the file and open it, the data appears, OS fedora 20. parts of the code : ``` # imported ...
2017/05/20
[ "https://Stackoverflow.com/questions/44089727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6424190/" ]
Unfortunately not. There is no language support for what you want. Let me be specific about what you want just so that you understand what I answered. Your question is basically this: Given that I have *two* instances of an object, and I have properties in this object that have a private setter, is there any languag...
If this is the property and you are worried about being set from elsewhere: ``` public Vector2 Pos { get { return pos; } private set { this.pos = value; } } private Vector2 pos; ``` This will NOT work. So you do not need to worry: ``` Player otherPlayer = GetNearestEnemy(); otherPlayer.Pos = new Vector2(34,151); //...
44,089,727
i have a weekly report that i need to do, i chooseed to create it with openpyxl python module, and send it via mail, when i open the received mail (outlook), the cells with formulas appears as empty, but when downloading the file and open it, the data appears, OS fedora 20. parts of the code : ``` # imported ...
2017/05/20
[ "https://Stackoverflow.com/questions/44089727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6424190/" ]
Unfortunately not. There is no language support for what you want. Let me be specific about what you want just so that you understand what I answered. Your question is basically this: Given that I have *two* instances of an object, and I have properties in this object that have a private setter, is there any languag...
The original scenario posted can be handled using an interface e.g. IPeerPlayer that only exposes what other players should see and hides other properties (i.e. the other properties would not be in the IPeerPlayer interface.)
32,496,664
**What is the pythonic way to set a maximum length paramter?** Let's say I want to restrict a list of strings to a certain maximum size: ``` >>> x = ['foo', 'bar', 'a', 'rushmoreorless', 'kilimangogo'] >>> maxlen = 3 >>> [i for i in x if len(i) <= maxlen] ['foo', 'bar', 'a'] ``` And I want to functionalize it and a...
2015/09/10
[ "https://Stackoverflow.com/questions/32496664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/610569/" ]
> > Let's say I want to restrict a list of strings to a certain maximum > size: > > > And I want to functionalize it and allow different maxlen but if no > maxlen is given, it should return the full list: > > > And I want to set the maxlen to the max length of element in alist > > > To address all these requ...
How about the following approach, this avoids the need to use `max`: ``` def filter_length(a_list, max_length=None): if max_length == 0: return [] elif max_length: return [i for i in x if len(i) <= max_length] else: return a_list x = ['foo', 'bar', 'a', 'rushmoreorless', 'kilimango...
32,496,664
**What is the pythonic way to set a maximum length paramter?** Let's say I want to restrict a list of strings to a certain maximum size: ``` >>> x = ['foo', 'bar', 'a', 'rushmoreorless', 'kilimangogo'] >>> maxlen = 3 >>> [i for i in x if len(i) <= maxlen] ['foo', 'bar', 'a'] ``` And I want to functionalize it and a...
2015/09/10
[ "https://Stackoverflow.com/questions/32496664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/610569/" ]
> > Let's say I want to restrict a list of strings to a certain maximum > size: > > > And I want to functionalize it and allow different maxlen but if no > maxlen is given, it should return the full list: > > > And I want to set the maxlen to the max length of element in alist > > > To address all these requ...
What about some tricks?.. Operator `or` returns first value, if both values are `True`. And, if first value is `False` and second is `True`, `or` returns second value. ``` >>> m = 3 >>> [i for i in x if len(i) <= m] or x ['foo', 'bar', 'a'] >>> m = 0 >>> [i for i in x if len(i) <= m] [] >>> [i for i in x if len(i) <= ...
32,496,664
**What is the pythonic way to set a maximum length paramter?** Let's say I want to restrict a list of strings to a certain maximum size: ``` >>> x = ['foo', 'bar', 'a', 'rushmoreorless', 'kilimangogo'] >>> maxlen = 3 >>> [i for i in x if len(i) <= maxlen] ['foo', 'bar', 'a'] ``` And I want to functionalize it and a...
2015/09/10
[ "https://Stackoverflow.com/questions/32496664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/610569/" ]
> > Let's say I want to restrict a list of strings to a certain maximum > size: > > > And I want to functionalize it and allow different maxlen but if no > maxlen is given, it should return the full list: > > > And I want to set the maxlen to the max length of element in alist > > > To address all these requ...
As you said: "*I want to allow different `maxlen`s but if no `maxlen` is given, it should return the full list*". An approach would be a definition of a `maxFilter()` function which uses Pythons **[*default argument values*](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values)**: ``` >>> def ma...
28,894,756
I have installed python 2.7, numpy 1.9.0, scipy 0.15.1 and scikit-learn 0.15.2. Now when I do the following in python: ``` train_set = ("The sky is blue.", "The sun is bright.") test_set = ("The sun in the sky is bright.", "We can see the shining sun, the bright sun.") from sklearn.feature_extraction.text import Cou...
2015/03/06
[ "https://Stackoverflow.com/questions/28894756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4193051/" ]
You are missing an underscore, try this way: ``` from sklearn.feature_extraction.text import CountVectorizer train_set = ("The sky is blue.", "The sun is bright.") test_set = ("The sun in the sky is bright.", "We can see the shining sun, the bright sun.") vectorizer = CountVectorizer(stop_words='english') docum...
Try using the `vectorizer.get_feature_names()` method. It gives the column names in the order it appears in the `document_term_matrix`. ``` from sklearn.feature_extraction.text import CountVectorizer train_set = ("The sky is blue.", "The sun is bright.") test_set = ("The sun in the sky is bright.", "We can see th...
48,671,331
Am implementing a sign up using python & mysql. Am getting the error no module named flask.ext.mysql and research implies that i should install flask first. They say it's very simple, you simply type pip install flask-mysql but where do i type this? In mysql command line for my database or in the python app?
2018/02/07
[ "https://Stackoverflow.com/questions/48671331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8857901/" ]
Pip is used from the command line. If you are on a Linux/Mac machine, type it from the Terminal. Make sure you actually have Pip. If you don't, use this command (on the Terminal) on linux: ``` sudo apt-get install pip ``` If you are on a Mac, use (in the Terminal): ``` /usr/bin/ruby -e "$(curl -fsSL https://raw.gi...
You should be able to type it in the command line for your operating system (ie. CMD/bash/terminal) as long as you have pip installed and the executable location is in your PATH.
41,708,881
I used pip today for the first time in a while and I got the helpful message > > You are using pip version 8.1.1, however version 9.0.1 is available. > You should consider upgrading via the 'pip install --upgrade pip' command. > > > So, I went ahead and ``` pip install --upgrade pip ``` but things did not go...
2017/01/17
[ "https://Stackoverflow.com/questions/41708881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3704831/" ]
You can reinstall `pip` with `conda`: ``` conda install pip ``` Looks like you need to have root rights: ``` sudo conda install pip ```
You can use curl to reinstall pip via the Python Packaging Authority website: ``` curl https://bootstrap.pypa.io/get-pip.py | python ```
41,708,881
I used pip today for the first time in a while and I got the helpful message > > You are using pip version 8.1.1, however version 9.0.1 is available. > You should consider upgrading via the 'pip install --upgrade pip' command. > > > So, I went ahead and ``` pip install --upgrade pip ``` but things did not go...
2017/01/17
[ "https://Stackoverflow.com/questions/41708881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3704831/" ]
Python comes with a module for installing pip without needing to pull anything from the internet called `ensurepip`. It's pretty straightforward to use, just run the following in a terminal: ``` python -m ensurepip ``` From there you can upgrade pip to the latest the standard way. Additional documentation is availab...
You can reinstall `pip` with `conda`: ``` conda install pip ``` Looks like you need to have root rights: ``` sudo conda install pip ```
41,708,881
I used pip today for the first time in a while and I got the helpful message > > You are using pip version 8.1.1, however version 9.0.1 is available. > You should consider upgrading via the 'pip install --upgrade pip' command. > > > So, I went ahead and ``` pip install --upgrade pip ``` but things did not go...
2017/01/17
[ "https://Stackoverflow.com/questions/41708881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3704831/" ]
Python comes with a module for installing pip without needing to pull anything from the internet called `ensurepip`. It's pretty straightforward to use, just run the following in a terminal: ``` python -m ensurepip ``` From there you can upgrade pip to the latest the standard way. Additional documentation is availab...
You can use curl to reinstall pip via the Python Packaging Authority website: ``` curl https://bootstrap.pypa.io/get-pip.py | python ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
None of the above worked for me, but turns out the solution was quite simple... All I was doing wrong was not explicitly including "null" as the parameter in the useRef initialization (it expects null, not undefined). Also you CANNOT use "HTMLElement" as your ref type, you have to be more specific, so for me it was "H...
The same stands for the `<svg>` elements: ``` const ref = useRef<SVGSVGElement>(null) ... <svg ref={ref} /> ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
Just import React: ```js import React, { useRef } from 'react'; function Test() { const node = useRef<HTMLDivElement>(null); if ( node && node.current && node.current.contains() ){ console.log("current accessed")} return <div ref={node}></div> } ``` I made an update. Use `H...
Key is to use HTMLElement and undefined for initialization ``` const node = useRef<HTMLElement>(); ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
Just import React: ```js import React, { useRef } from 'react'; function Test() { const node = useRef<HTMLDivElement>(null); if ( node && node.current && node.current.contains() ){ console.log("current accessed")} return <div ref={node}></div> } ``` I made an update. Use `H...
``` selfref = React.createRef<HTMLInputElement>() ``` I give the exacted TS Type, then the editor passed the check. it works nice now.
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
None of the above worked for me, but turns out the solution was quite simple... All I was doing wrong was not explicitly including "null" as the parameter in the useRef initialization (it expects null, not undefined). Also you CANNOT use "HTMLElement" as your ref type, you have to be more specific, so for me it was "H...
Key is to use HTMLElement and undefined for initialization ``` const node = useRef<HTMLElement>(); ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
I came here looking for help with an iframe ref. Perhaps this solution will help someone else that's looking for the same thing. I replaced `HTMLDivElement` with `HTMLIFrameElement` so: ``` const node = useRef<HTMLIFrameElement>(null); ```
The same stands for the `<svg>` elements: ``` const ref = useRef<SVGSVGElement>(null) ... <svg ref={ref} /> ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
I came here looking for help with an iframe ref. Perhaps this solution will help someone else that's looking for the same thing. I replaced `HTMLDivElement` with `HTMLIFrameElement` so: ``` const node = useRef<HTMLIFrameElement>(null); ```
``` selfref = React.createRef<HTMLInputElement>() ``` I give the exacted TS Type, then the editor passed the check. it works nice now.
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
Just import React: ```js import React, { useRef } from 'react'; function Test() { const node = useRef<HTMLDivElement>(null); if ( node && node.current && node.current.contains() ){ console.log("current accessed")} return <div ref={node}></div> } ``` I made an update. Use `H...
The same stands for the `<svg>` elements: ``` const ref = useRef<SVGSVGElement>(null) ... <svg ref={ref} /> ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
Just import React: ```js import React, { useRef } from 'react'; function Test() { const node = useRef<HTMLDivElement>(null); if ( node && node.current && node.current.contains() ){ console.log("current accessed")} return <div ref={node}></div> } ``` I made an update. Use `H...
I came here looking for help with an iframe ref. Perhaps this solution will help someone else that's looking for the same thing. I replaced `HTMLDivElement` with `HTMLIFrameElement` so: ``` const node = useRef<HTMLIFrameElement>(null); ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
Key is to use HTMLElement and undefined for initialization ``` const node = useRef<HTMLElement>(); ```
The same stands for the `<svg>` elements: ``` const ref = useRef<SVGSVGElement>(null) ... <svg ref={ref} /> ```
66,963,342
How can I change the output of the `models.ForeignKey` field in my below custom field? Custom field: ```py class BetterForeignKey(models.ForeignKey): def to_python(self, value): print('to_python', value) return { 'id': value.id, 'name_fa': value.name_fa, 'name_...
2021/04/06
[ "https://Stackoverflow.com/questions/66963342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7431943/" ]
I came here looking for help with an iframe ref. Perhaps this solution will help someone else that's looking for the same thing. I replaced `HTMLDivElement` with `HTMLIFrameElement` so: ``` const node = useRef<HTMLIFrameElement>(null); ```
Key is to use HTMLElement and undefined for initialization ``` const node = useRef<HTMLElement>(); ```
14,160,686
I'm writing a python (3.2+) plugin library and I want to create a function which will create some variables automatically handled from config files. The use case is as follows (class variable): ``` class X: option(y=0) def __init__(self): pass ``` (instance variable): ``` class Y: def __init__(...
2013/01/04
[ "https://Stackoverflow.com/questions/14160686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/889902/" ]
You cannot get a reference to the class, because the class has yet to be created. Your parent frame points a temporary function, whose `locals()` when it completes will be used as the class body. As such, all you need to do is add your variables to the parent frame locals, and these will be added to the class when cla...
It seems to me that a metaclass would be suitable here: **python2.x syntax** ``` def class_maker(name,bases,dict_): dict_['y']=0 return type(name,bases,dict_) class X(object): __metaclass__ = class_maker def __init__(self): pass print X.y foo = X() print foo.y ``` **python3.x syntax** It ...
8,301,962
I am trying to rewrite the code described [here](http://opencv.itseez.com/doc/tutorials/features2d/feature_homography/feature_homography.html#feature-homography). using the python API for Opencv. The step 3 of the code has this lines: ``` FlannBasedMatcher matcher; std::vector< DMatch > matches; matcher.match( des...
2011/11/28
[ "https://Stackoverflow.com/questions/8301962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1053925/" ]
Looking in the examples provided by OpenCV 2.3.1 under the python2 folder, I found an implementation of a flann based match function which doesn't rely on the FlanBasedMatcher object. Here is the code: ``` FLANN_INDEX_KDTREE = 1 # bug: flann enums are missing flann_params = dict(algorithm = FLANN_INDEX_KDTREE, ...
Pythonic FlannBasedMatcher is already available in OpenCV trunk, but if I remember correctly, it was added after 2.3.1 release. Here is OpenCV sample using FlannBasedMatcher: <http://code.opencv.org/projects/opencv/repository/revisions/master/entry/samples/python2/feature_homography.py>
8,301,962
I am trying to rewrite the code described [here](http://opencv.itseez.com/doc/tutorials/features2d/feature_homography/feature_homography.html#feature-homography). using the python API for Opencv. The step 3 of the code has this lines: ``` FlannBasedMatcher matcher; std::vector< DMatch > matches; matcher.match( des...
2011/11/28
[ "https://Stackoverflow.com/questions/8301962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1053925/" ]
Pythonic FlannBasedMatcher is already available in OpenCV trunk, but if I remember correctly, it was added after 2.3.1 release. Here is OpenCV sample using FlannBasedMatcher: <http://code.opencv.org/projects/opencv/repository/revisions/master/entry/samples/python2/feature_homography.py>
I could not post the dead link on the post above because of lack of reputations. So, I am posting it here. [The dead link(feature\_homography.py)](https://github.com/opencv/opencv/blob/master/samples/python/feature_homography.py)
8,301,962
I am trying to rewrite the code described [here](http://opencv.itseez.com/doc/tutorials/features2d/feature_homography/feature_homography.html#feature-homography). using the python API for Opencv. The step 3 of the code has this lines: ``` FlannBasedMatcher matcher; std::vector< DMatch > matches; matcher.match( des...
2011/11/28
[ "https://Stackoverflow.com/questions/8301962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1053925/" ]
Looking in the examples provided by OpenCV 2.3.1 under the python2 folder, I found an implementation of a flann based match function which doesn't rely on the FlanBasedMatcher object. Here is the code: ``` FLANN_INDEX_KDTREE = 1 # bug: flann enums are missing flann_params = dict(algorithm = FLANN_INDEX_KDTREE, ...
I could not post the dead link on the post above because of lack of reputations. So, I am posting it here. [The dead link(feature\_homography.py)](https://github.com/opencv/opencv/blob/master/samples/python/feature_homography.py)
31,483,448
I have a python script which I want to start using a rc(8) script in FreeBSD. The python script uses the `#!/usr/bin/env python2` pattern for portability purposes. (Different \*nix's put interpreter binaries in different locations on the filesystem). The FreeBSD rc scripts will not work with this. Here is a script th...
2015/07/17
[ "https://Stackoverflow.com/questions/31483448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183499/" ]
*Self answered my question, but I'm hoping someone else will give a better answer for posterity* The reason why env(1) does not work is because it expects an environment in the first place, but rc scripts run before the environment is set up. Hence it fails. It seems that the popular env shebang pattern is actually an...
The command interpreter warning is generated by the `_find_processes()` function in `/usr/src/etc/rc.subr`. The reason that it does that is because a service written in an interpreted language is found in `ps` output by the *name of the interpreter*.
6,648,394
I have a project and I want to use python but the server is only Windows Server 2000 can it run on this system?
2011/07/11
[ "https://Stackoverflow.com/questions/6648394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1347816/" ]
If you are using windows 2000 then it's possible that python 3.2 is not your best alternative. A couple of months ago there was an interesting thread in the python-dev mailing list[1] about dropping win2k support (there are some annoying bugs for this platform). [1] <http://mail.python.org/pipermail/python-dev/2010-M...
You can use [Micro Python](https://micropython.org/) for DOS. It has Python 3.4 syntax.
5,189,483
If my question is unclear there is a great explainaion of what I'm attempting to do here under the section, "Method 2: The British Method": <http://www.gradeamathhelp.com/how-to-factor-polynomials.html> My current program simply inputted all 3 A,B, and C variables and then assigned A\*C to D I then took the negative ...
2011/03/04
[ "https://Stackoverflow.com/questions/5189483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Your code isn't working because you need "END" commands every time you use a "THEN" command. END is also used to close off "REPEAT", "FOR", and "WHILE" loops. Why does it need "END" for an "IF,THEN" type command? Because "IF,THEN" equates to: ``` If X+Y=B and X*Y=D ( ``` In typical scripting The "END" is like an...
Download available at: <http://www.ticalc.org/pub/83/basic/math/algebra/>
5,189,483
If my question is unclear there is a great explainaion of what I'm attempting to do here under the section, "Method 2: The British Method": <http://www.gradeamathhelp.com/how-to-factor-polynomials.html> My current program simply inputted all 3 A,B, and C variables and then assigned A\*C to D I then took the negative ...
2011/03/04
[ "https://Stackoverflow.com/questions/5189483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There's an easier way to do this. Setting `a+bi` makes sure that the program displays imaginary numbers as well instead of giving errors. `"` denotes comments. Finally, adding the last line gets rid of the "Done" message. ``` : "Clear and request input : ClrHome : a+bi : Disp "ax^2+bx+c=0" : Input "a. ",A : Input "b. ...
Download available at: <http://www.ticalc.org/pub/83/basic/math/algebra/>
16,847,597
I am new to python and programming, so apologies in advance. I know of remove(), append(), len(), and rand.rang (or whatever it is), and I believe I would need those tools, but it's not clear to me *how* to code it. What I would like to do is, while looping or otherwise accessing List\_A, randomly select an index with...
2013/05/30
[ "https://Stackoverflow.com/questions/16847597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058922/" ]
If you don't care about the order of the input list, I'd shuffle it, then remove `n` items from that list, adding those to the other list: ``` from random import shuffle def remove_percentage(list_a, percentage): shuffle(list_a) count = int(len(list_a) * percentage) if not count: return [] # edge case, n...
If you can find a random index `i` of some element in `listA`, then you can easily move it from A to B using: ``` listB.append(listA.pop(i)) ```
16,847,597
I am new to python and programming, so apologies in advance. I know of remove(), append(), len(), and rand.rang (or whatever it is), and I believe I would need those tools, but it's not clear to me *how* to code it. What I would like to do is, while looping or otherwise accessing List\_A, randomly select an index with...
2013/05/30
[ "https://Stackoverflow.com/questions/16847597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058922/" ]
If you don't care about the order of the input list, I'd shuffle it, then remove `n` items from that list, adding those to the other list: ``` from random import shuffle def remove_percentage(list_a, percentage): shuffle(list_a) count = int(len(list_a) * percentage) if not count: return [] # edge case, n...
1) Calculate how many elements you want to remove, call it `k`. 2) `random.randrange(len(listA))` will return a random number between 0 and len(listA)-1 inclusive, e.g. a random index you can use in listA. 3) Grab the element at that index, remove it from listA, append it to listB. 4) Repeat until you have removed `...
16,847,597
I am new to python and programming, so apologies in advance. I know of remove(), append(), len(), and rand.rang (or whatever it is), and I believe I would need those tools, but it's not clear to me *how* to code it. What I would like to do is, while looping or otherwise accessing List\_A, randomly select an index with...
2013/05/30
[ "https://Stackoverflow.com/questions/16847597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058922/" ]
If you don't care about the order of the input list, I'd shuffle it, then remove `n` items from that list, adding those to the other list: ``` from random import shuffle def remove_percentage(list_a, percentage): shuffle(list_a) count = int(len(list_a) * percentage) if not count: return [] # edge case, n...
``` >>> lis = range(100) >>> per = .30 >>> no_of_items = int( len(lis) * per) #number of items in 30 percent >>> lis_b = [] >>> for _ in xrange(no_of_items): ind = random.randint(0,len(lis)-1) #selects a random index value lis_b.append(lis.pop(ind)) #pop the item at that index and append to lis_b ...
62,999,056
This python 3 code does exactly what I want ```py from pathlib import Path def minify(src_dir:Path, dest_dir:Path, n: int): """Write first n lines of each file f in src_dir to dest_dir/f""" dest_dir.mkdir(exist_ok=True) for path in src_dir.iterdir(): new = [x.rstrip() for x in list(path.open().read...
2020/07/20
[ "https://Stackoverflow.com/questions/62999056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4381942/" ]
Looks like you are using Bootstrap. Currently, your left nav is initially set to `position: fixed`, I recommend using `position: relative` to your left nav initially so that positioning your `nav` elements can be **relative to the height of the background image**. Using Bootstrap, this solution wraps the left nav & the...
You should be able to have that working with just CSS and no javascript using `position: sticky` attribute. Make both elements `position: sticky`, the top nav should have a `top: 0` property and the side nav should have a `top: x` property where `x` is the height of the top nav. That should be enough and you should b...
62,999,056
This python 3 code does exactly what I want ```py from pathlib import Path def minify(src_dir:Path, dest_dir:Path, n: int): """Write first n lines of each file f in src_dir to dest_dir/f""" dest_dir.mkdir(exist_ok=True) for path in src_dir.iterdir(): new = [x.rstrip() for x in list(path.open().read...
2020/07/20
[ "https://Stackoverflow.com/questions/62999056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4381942/" ]
Looks like you are using Bootstrap. Currently, your left nav is initially set to `position: fixed`, I recommend using `position: relative` to your left nav initially so that positioning your `nav` elements can be **relative to the height of the background image**. Using Bootstrap, this solution wraps the left nav & the...
why you want to do this? you can move the top menu and side menu and text container together in one container to be relative with each other, set the text box container fixed height in percent and set its `overflow-y` to `auto`. make the whole container animatable like the top menu. this will solve your problem.
62,999,056
This python 3 code does exactly what I want ```py from pathlib import Path def minify(src_dir:Path, dest_dir:Path, n: int): """Write first n lines of each file f in src_dir to dest_dir/f""" dest_dir.mkdir(exist_ok=True) for path in src_dir.iterdir(): new = [x.rstrip() for x in list(path.open().read...
2020/07/20
[ "https://Stackoverflow.com/questions/62999056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4381942/" ]
Looks like you are using Bootstrap. Currently, your left nav is initially set to `position: fixed`, I recommend using `position: relative` to your left nav initially so that positioning your `nav` elements can be **relative to the height of the background image**. Using Bootstrap, this solution wraps the left nav & the...
The side and top sliding `<nav>` elements cannot interact correctly with the page content. Especially the lateral `<nav>` with vertical sliding according to many changing rules - sit, follow, slide against, stick apart. It's too much at once. **Workaround 1 - smooth - top sliding, side fixed** *(anchors corrected)* I...
62,999,056
This python 3 code does exactly what I want ```py from pathlib import Path def minify(src_dir:Path, dest_dir:Path, n: int): """Write first n lines of each file f in src_dir to dest_dir/f""" dest_dir.mkdir(exist_ok=True) for path in src_dir.iterdir(): new = [x.rstrip() for x in list(path.open().read...
2020/07/20
[ "https://Stackoverflow.com/questions/62999056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4381942/" ]
You should be able to have that working with just CSS and no javascript using `position: sticky` attribute. Make both elements `position: sticky`, the top nav should have a `top: 0` property and the side nav should have a `top: x` property where `x` is the height of the top nav. That should be enough and you should b...
why you want to do this? you can move the top menu and side menu and text container together in one container to be relative with each other, set the text box container fixed height in percent and set its `overflow-y` to `auto`. make the whole container animatable like the top menu. this will solve your problem.
62,999,056
This python 3 code does exactly what I want ```py from pathlib import Path def minify(src_dir:Path, dest_dir:Path, n: int): """Write first n lines of each file f in src_dir to dest_dir/f""" dest_dir.mkdir(exist_ok=True) for path in src_dir.iterdir(): new = [x.rstrip() for x in list(path.open().read...
2020/07/20
[ "https://Stackoverflow.com/questions/62999056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4381942/" ]
You should be able to have that working with just CSS and no javascript using `position: sticky` attribute. Make both elements `position: sticky`, the top nav should have a `top: 0` property and the side nav should have a `top: x` property where `x` is the height of the top nav. That should be enough and you should b...
The side and top sliding `<nav>` elements cannot interact correctly with the page content. Especially the lateral `<nav>` with vertical sliding according to many changing rules - sit, follow, slide against, stick apart. It's too much at once. **Workaround 1 - smooth - top sliding, side fixed** *(anchors corrected)* I...
58,525,753
I'm trying to use Ansible with ssh for interact with Windows machines i have successfully install OpenSSH on a Windows machine that mean i can connect from linux to windows with: ``` ssh username@ipAdresse ``` i've tried using a lot of version of ansible (2.6, 2.7.12, 2.7.14, 2.8.5 and 2.8.6) and i always test if ...
2019/10/23
[ "https://Stackoverflow.com/questions/58525753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11431519/" ]
Ok solved, the problem was ``` ansible_ssh_pass=***** ``` the correct syntax is ``` ansible_password=***** ```
To use SSH as the connection to a Windows host (starting from Ansible 2.8), set the following variables in the inventory: * ansible\_connection=ssh * **ansible\_shell\_type**=cmd/powershell (Set either cmd or powershell not both) Finally, the inventory file: ``` [windows] 192.***.***.*** [all:vars] ansible_connecti...
68,590,820
I want to use the face recognition module of python in a project but when I am trying to install it using the command "pip install face\_recognition" or "pip install face-recognition", it is showing an error and is not installing. This is the screenshot of the error:[![enter image description here](https://i.stack.imgu...
2021/07/30
[ "https://Stackoverflow.com/questions/68590820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16017288/" ]
Your base template should provide defaults for most or all pages, but make it possible to override the default in cases where it's less than ideal. Here, put the base template message code into a named block. ``` {% block default_messages %} {% if messages %} {% for message in messages %} <div class="alert al...
``` {% block content %} {% endblock %} ``` put these inside div tag
61,969,924
my problem is that i am trying to use locust for the first time and i copied the basic code from their website <https://docs.locust.io/en/stable/quickstart.html> this is the code that they have given ``` from locust import HttpUser, task, between import random class WebsiteUser(HttpUser): wait_time = between(5,...
2020/05/23
[ "https://Stackoverflow.com/questions/61969924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5825106/" ]
**If it crash on iOS :** Check if you have updated your Info.plist file. You must have the key «Privacy - Contacts Usage Description» with a sentence in value. Follow the documentation : <https://github.com/morenoh149/react-native-contacts#ios-2> **If it crash on Android :** Check if you have updated your Android...
``` //Try it const addContact = () => { PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS, PermissionsAndroid.PERMISSIONS.READ_CONTACTS, ]) Contacts.getAll().then(contacts => { // console.log('hello',contacts); setMblContacts(contacts); }) } `...
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
I didn't like the idea of commenting/uncommenting code, so I tried a different approach: I migrated "manually" some apps, and then run `django-admin.py migrate` for the remaining ones. After deleting all the `*.pyc` files, my sequence of commands was: ``` $ django-admin.py migrate auth $ django-admin.py migrate conten...
I had this issues with a `forms.ChoiceForm` queryset. I was able to switch to using [`forms.ModelChoiceForm`](https://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield) which are lazily evaluated and this fixed the problem for me.
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
Working on Django 1.10 I found out another solution: My application is named "web", and first I call: ``` python manage.py makemigrations web ``` then I call: ``` python manage.py makemigrations auth ``` then I call: ``` python manage.py migrate ``` Amazed: IT'S WORKING! :) It seems auth was searching for the...
Always migrate db with `python manage.py makemigrations` and then `python manage.py migrate` in newer versions. For the error above if first time your are migrating your database then use `python manage.py migrate --fake-initial`. See docs <https://docs.djangoproject.com/en/1.9/ref/django-admin/#django-admin-migrate>
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
I didn't like the idea of commenting/uncommenting code, so I tried a different approach: I migrated "manually" some apps, and then run `django-admin.py migrate` for the remaining ones. After deleting all the `*.pyc` files, my sequence of commands was: ``` $ django-admin.py migrate auth $ django-admin.py migrate conten...
I had the same issue, but my underlying cause was the `__init__.py` file in one of the migrations folders had been deleted from source code but not locally (causing 'Not on my machine' errors). Migrations folders still need `__init__.py` files, even with Python 3.
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
Working on Django 1.10 I found out another solution: My application is named "web", and first I call: ``` python manage.py makemigrations web ``` then I call: ``` python manage.py makemigrations auth ``` then I call: ``` python manage.py migrate ``` Amazed: IT'S WORKING! :) It seems auth was searching for the...
I had the same problem, and I spent hours banging my head trying to find a solution, which was hidden in the comments. My problem was that CircleCI couldn't run tests because of this error. And I thought I would need to start fresh with a new and empty DB. But I got the same errors. Everything was seemingly related to ...
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
I didn't like the idea of commenting/uncommenting code, so I tried a different approach: I migrated "manually" some apps, and then run `django-admin.py migrate` for the remaining ones. After deleting all the `*.pyc` files, my sequence of commands was: ``` $ django-admin.py migrate auth $ django-admin.py migrate conten...
Deleting migration files, associated .pyc files, and just to be safe all .pyc files with the following commands did not solve my issue. ``` $ find . -path "*/migrations/*.py" -not -name "__init__.py" -delete $ find . -path "*/migrations/*.pyc" -delete $ find . -name "*.pyc" -exec rm -- {} + ``` What ended up solvin...
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
I didn't like the idea of commenting/uncommenting code, so I tried a different approach: I migrated "manually" some apps, and then run `django-admin.py migrate` for the remaining ones. After deleting all the `*.pyc` files, my sequence of commands was: ``` $ django-admin.py migrate auth $ django-admin.py migrate conten...
Error is basically because db (postgres or sqlite) have not found the relation, for which you are inserting or else performing CRUD. The solution is to make migrations `python manage.py makemigrations <app_name> python manage.py migrate`
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
Deleting migration files, associated .pyc files, and just to be safe all .pyc files with the following commands did not solve my issue. ``` $ find . -path "*/migrations/*.py" -not -name "__init__.py" -delete $ find . -path "*/migrations/*.pyc" -delete $ find . -name "*.pyc" -exec rm -- {} + ``` What ended up solvin...
In my case, this error was appearing when the postgresql driver was able to connect to the database, but the provided user does not have access to the schema or the tables, etc. Instead of saying permission denied, the error being shown is saying that the database table being queried is not being found. Typically in su...
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
Deleting migration files, associated .pyc files, and just to be safe all .pyc files with the following commands did not solve my issue. ``` $ find . -path "*/migrations/*.py" -not -name "__init__.py" -delete $ find . -path "*/migrations/*.pyc" -delete $ find . -name "*.pyc" -exec rm -- {} + ``` What ended up solvin...
Error is basically because db (postgres or sqlite) have not found the relation, for which you are inserting or else performing CRUD. The solution is to make migrations `python manage.py makemigrations <app_name> python manage.py migrate`
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
Working on Django 1.10 I found out another solution: My application is named "web", and first I call: ``` python manage.py makemigrations web ``` then I call: ``` python manage.py makemigrations auth ``` then I call: ``` python manage.py migrate ``` Amazed: IT'S WORKING! :) It seems auth was searching for the...
In my case, this error was appearing when the postgresql driver was able to connect to the database, but the provided user does not have access to the schema or the tables, etc. Instead of saying permission denied, the error being shown is saying that the database table being queried is not being found. Typically in su...
30,897,442
I had a working project with django 1.7, and now I moved it to django 1.8. I can do `syncdb` and run the app with sqlite, but when I switch to postgres, it fails to do **syncdb**: ``` Creating tables... Creating table x Creating table y Running deferred SQL... Traceback (most recent call last): File "m...
2015/06/17
[ "https://Stackoverflow.com/questions/30897442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896222/" ]
In my case, this error was appearing when the postgresql driver was able to connect to the database, but the provided user does not have access to the schema or the tables, etc. Instead of saying permission denied, the error being shown is saying that the database table being queried is not being found. Typically in su...
Error is basically because db (postgres or sqlite) have not found the relation, for which you are inserting or else performing CRUD. The solution is to make migrations `python manage.py makemigrations <app_name> python manage.py migrate`
2,066,049
I'm trying to write a POS-style application for a [Sheevaplug](http://en.wikipedia.org/wiki/SheevaPlug) that does the following: 1. Captures input from a card reader (as I understand, most mag card readers emulate keyboard input, so basically I'm looking to capture that) 2. Doesn't require X 3. Runs in the background ...
2010/01/14
[ "https://Stackoverflow.com/questions/2066049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231670/" ]
Section 5 of the Linux kernel [input documentation](http://www.kernel.org/doc/Documentation/input/input.txt) describes what each of the values in the event interface means.
the format is explained in the [kernel documentation](http://www.mjmwired.net/kernel/Documentation/input/) in section *5. Event Interface*.
6,495,688
There are lots of [good](https://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script) [reasons](https://stackoverflow.com/questions/1352922/why-is-usr-bin-env-python-supposedly-more-correct-than-just-usr-bin-pyth) to use #! /usr/bin/env. Bottom line: It makes ...
2011/06/27
[ "https://Stackoverflow.com/questions/6495688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730070/" ]
*"kill-ability" on the command line* can by addressed portably and reliably using the PID of the backgrounded process obtained from shell `$!` variable. ``` $ ./bintest.py & bg_pid=$! ; echo bg_pid=$bg_pid ; ps && kill $bg_pid [1] 2993 bg_pid=2993 PID TTY TIME CMD 2410 pts/0 00:00:00 bash 2993 pts/0 ...
I don't think you can rely on the `killall` using the script name to work all the time. On Mac OS X I get the following output from `ps` after running both scripts: ``` 2108 ttys004 0:00.04 /usr/local/bin/python /Users/adam/bin/bintest.py 2133 ttys004 0:00.03 python /Users/adam/bin/envtest.py ``` and running...
6,495,688
There are lots of [good](https://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script) [reasons](https://stackoverflow.com/questions/1352922/why-is-usr-bin-env-python-supposedly-more-correct-than-just-usr-bin-pyth) to use #! /usr/bin/env. Bottom line: It makes ...
2011/06/27
[ "https://Stackoverflow.com/questions/6495688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730070/" ]
*"kill-ability" on the command line* can by addressed portably and reliably using the PID of the backgrounded process obtained from shell `$!` variable. ``` $ ./bintest.py & bg_pid=$! ; echo bg_pid=$bg_pid ; ps && kill $bg_pid [1] 2993 bg_pid=2993 PID TTY TIME CMD 2410 pts/0 00:00:00 bash 2993 pts/0 ...
While I would still like a solution that makes scripting languages both cross-platform and easy-to-monitor from the command line, if you're just looking for an alternative to `killall <scriptname>` to stop custom services, here's how I solved it: ``` kill `ps -fC <interpreterName> | sed -n '/<scriptName>/s/^[^0-9]*\([...
6,495,688
There are lots of [good](https://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script) [reasons](https://stackoverflow.com/questions/1352922/why-is-usr-bin-env-python-supposedly-more-correct-than-just-usr-bin-pyth) to use #! /usr/bin/env. Bottom line: It makes ...
2011/06/27
[ "https://Stackoverflow.com/questions/6495688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730070/" ]
*"kill-ability" on the command line* can by addressed portably and reliably using the PID of the backgrounded process obtained from shell `$!` variable. ``` $ ./bintest.py & bg_pid=$! ; echo bg_pid=$bg_pid ; ps && kill $bg_pid [1] 2993 bg_pid=2993 PID TTY TIME CMD 2410 pts/0 00:00:00 bash 2993 pts/0 ...
In a comment, you say that the problem is that different systems (particularly MacOS and Linux) place executables in different directories. You can work around this by creating a directory with the same full path on both systems, and creating symbolic links to the executables. Experiment on Ubuntu, Solaris, and Cygwi...
56,594,272
I found a code for text classification in tensorflow and when I try to run this code: <https://www.tensorflow.org/beta/tutorials/keras/feature_columns> I get an error. I used the dataset from here: <https://www.kaggle.com/kazanova/sentiment140> ``` Traceback (most recent call last): File "text_clas.py", line 35, in...
2019/06/14
[ "https://Stackoverflow.com/questions/56594272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You are saving or deleting a customer from the table, but the `dataSource` is using the data that you have already fetched from the database. It cannot get the updated data unless you manually do it. While saving a new customer, you'll have to make the `getUser()` request again ( or push the customer object in the `r...
Akash's approach is correct. In addition to his approach you should use [afterClosed()](https://material.angular.io/components/dialog/api#MatDialogRef) method to link MatDialog to current component and get notified when the dialog is closed. After the dialog is closed, just fetch users again. ```js ngOnInit() { ...
33,546,935
I have a list of lists, with integer values in each list, that represent dates over an 8 year period. ``` dates = [[2014, 11, 14], [2014, 11, 13], ....., [2013, 12, 01].....] ``` I need to compare these dates so that I can find an average cost per month, with other data stored in the file. So i need to figure o...
2015/11/05
[ "https://Stackoverflow.com/questions/33546935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5522009/" ]
You can use a dictionary to preserve the year and month as the key and the relative days in a list as value, then you can do any progress on your items which are categorized by the year and month. ``` >>> dates = [['2014', '11', '14'], ['2014', '10', '13'], ['2014', '10', '01'], ['2014', '12', '01'], ['2013', '12', '0...
If you want to iterate thought you dates array, and do an action every time the month changes you could use this method: ``` dates = [[2014, 11, 14], [2014, 11, 13], [2013, 12, 1]] old_m = "" for year, month, day in dates: if old_m != month: # calculate average here old_m = month ```
51,941,175
I am trying to read a txt file(kept in another location) in python, but getting error. -------------------------------------------------------------------------------------- > > FileNotFoundError > > in () > ----> 1 employeeFile=open("C:‪/Users/xxxxxxxx/Desktop/python/files/employee.txt","r") > 2 print(employee...
2018/08/21
[ "https://Stackoverflow.com/questions/51941175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6487702/" ]
I'm guessing you copy and pasted from a Windows property pane, switching backslashes to forward slashes manually. Problem is, the properties dialog shoves a Unicode LEFT-TO-RIGHT EMBEDDING character into the path so the display is consistent, even in locales with right-to-left languages (e.g. Arabic, Hebrew). You can ...
As your error message suggests, there's a weird character between the colon and the forward slash (`C:[some character]/`). Other than that the code is fine. ```py employeeFile = open("C:/Users/xxxxxxxx/Desktop/python/files/employee.txt", "r") ``` You can copy paste this code and use it.
19,623,386
Hi: I want to do a sound waves simulation that include wave propagation, absorbing and reflection in 3D space. I do some searches and I found [this question](https://stackoverflow.com/questions/4956331/wave-simulation-with-python) in stackoverflow but it talk about electromagnetic waves not sound waves. I know i can ...
2013/10/27
[ "https://Stackoverflow.com/questions/19623386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/553460/" ]
Hope this can give you some inputs... As far as i know, in EM simulations obstacles (and thus terrain) are not considered at all. With sound you have to consider reflection, diffraction, etc there are different standards to calculate the noise originated from different sources (I'll list the europe ones, the one i kno...
An easy way to do this is use the SoundPlan software. Multiple sound propagation methods such as ISO9613-2, CONCAWE and Nord2000 are implemented. It has basic 3D visualization with sound pressure level contours.
46,309,161
I am having issues reading data from a bucket hosted by Google. I have a bucket containing ~1000 files I need to access, held at (for example) gs://my-bucket/data Using gsutil from the command line or other of Google's Python API clients I can access the data in the bucket, however importing these APIs is not suppor...
2017/09/19
[ "https://Stackoverflow.com/questions/46309161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8598909/" ]
If you just want to read data into memory, then [this answer](https://stackoverflow.com/a/42799952/1399222) has the details you need, namely, to use the [file\_io](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/lib/io/file_io.py) module. That said, you might want to consider using built-in read...
For what its worth. I also had problems reading files, in particular binary files from google cloud storage inside a datalab notebook. The first way I managed to do it was by copying files using gs-utils to my local filesystem and using tensorflow to read the files normally. This is demonstrated here after the file cop...
56,567,013
We are fairly new to Django. We we have an app and a model. We'd like to add an 'Category' object to our model. We did that, and then ran 'python manage.py makemigrations'. We then deploy our code to a server running the older code, and run 'python manage.py migrate'. This throws 2 pages of exceptions, finishing with ...
2019/06/12
[ "https://Stackoverflow.com/questions/56567013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11638068/" ]
I believe you skipped some migration in the server, so now you are missing some tables (I have been in that situation. Ensure **migrations** directories are on your **.gitignore**. You CAN NOT check in migrations files, you have to run `makemigrations` on the server). This can be solved by tracing back up to the point ...
Remember to run `python manage.py makemigrations` if you made changes to the `models.py` then run `python manage.py makemigrations` Both commands **must** be run on the same server with the same database
10,654,707
I download python2.6.6 source form <http://www.python.org/getit/releases/2.6.6/> After that I run these commands ./configure make I tried to import zlib but it says no module named zlib. How can install zlib module for it After I tried installing python2.6.8 I got same error no zlib. While installing it I got below e...
2012/05/18
[ "https://Stackoverflow.com/questions/10654707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813102/" ]
I tried following which helped me with some of these modules. You have to edit setup.py. Find the following lines in setup.py: ``` lib_dirs = self.compiler.library_dirs + [ '/lib64', '/usr/lib64', '/lib', '/usr/lib', ] ``` **For 64 bit** Add `/usr/lib/x86_64-linux-gnu`: ``` lib_dirs = self.compiler....
I wrote a note for myself addressing your problem, might be helpful: [`python installation`](http://cheater.nemoden.com/python-installation/). Do you really need `bsddb` and `sunaudiodev` modules? You might not want to since both are deprecated since python 2.6
10,654,707
I download python2.6.6 source form <http://www.python.org/getit/releases/2.6.6/> After that I run these commands ./configure make I tried to import zlib but it says no module named zlib. How can install zlib module for it After I tried installing python2.6.8 I got same error no zlib. While installing it I got below e...
2012/05/18
[ "https://Stackoverflow.com/questions/10654707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813102/" ]
I tried following which helped me with some of these modules. You have to edit setup.py. Find the following lines in setup.py: ``` lib_dirs = self.compiler.library_dirs + [ '/lib64', '/usr/lib64', '/lib', '/usr/lib', ] ``` **For 64 bit** Add `/usr/lib/x86_64-linux-gnu`: ``` lib_dirs = self.compiler....
I solved the problem adding `LDFLAGS=-L/usr/lib/x86_64-linux-gnu` as `configure` parameter.
10,654,707
I download python2.6.6 source form <http://www.python.org/getit/releases/2.6.6/> After that I run these commands ./configure make I tried to import zlib but it says no module named zlib. How can install zlib module for it After I tried installing python2.6.8 I got same error no zlib. While installing it I got below e...
2012/05/18
[ "https://Stackoverflow.com/questions/10654707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813102/" ]
I tried following which helped me with some of these modules. You have to edit setup.py. Find the following lines in setup.py: ``` lib_dirs = self.compiler.library_dirs + [ '/lib64', '/usr/lib64', '/lib', '/usr/lib', ] ``` **For 64 bit** Add `/usr/lib/x86_64-linux-gnu`: ``` lib_dirs = self.compiler....
I had this exact problem (exact python distribution as well) Dmity's answer almost worked... but after many hours searching I think I have found the issue (assuming you are using ubuntu 11.10 - 12.10) Ok, so for me at least the problem stemmed from the fact that Ubuntu disabled SSLv2, so the workaround is fairly invol...
10,654,707
I download python2.6.6 source form <http://www.python.org/getit/releases/2.6.6/> After that I run these commands ./configure make I tried to import zlib but it says no module named zlib. How can install zlib module for it After I tried installing python2.6.8 I got same error no zlib. While installing it I got below e...
2012/05/18
[ "https://Stackoverflow.com/questions/10654707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813102/" ]
I wrote a note for myself addressing your problem, might be helpful: [`python installation`](http://cheater.nemoden.com/python-installation/). Do you really need `bsddb` and `sunaudiodev` modules? You might not want to since both are deprecated since python 2.6
I had this exact problem (exact python distribution as well) Dmity's answer almost worked... but after many hours searching I think I have found the issue (assuming you are using ubuntu 11.10 - 12.10) Ok, so for me at least the problem stemmed from the fact that Ubuntu disabled SSLv2, so the workaround is fairly invol...
10,654,707
I download python2.6.6 source form <http://www.python.org/getit/releases/2.6.6/> After that I run these commands ./configure make I tried to import zlib but it says no module named zlib. How can install zlib module for it After I tried installing python2.6.8 I got same error no zlib. While installing it I got below e...
2012/05/18
[ "https://Stackoverflow.com/questions/10654707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813102/" ]
I solved the problem adding `LDFLAGS=-L/usr/lib/x86_64-linux-gnu` as `configure` parameter.
I had this exact problem (exact python distribution as well) Dmity's answer almost worked... but after many hours searching I think I have found the issue (assuming you are using ubuntu 11.10 - 12.10) Ok, so for me at least the problem stemmed from the fact that Ubuntu disabled SSLv2, so the workaround is fairly invol...
41,971,623
Is it possible to have a python script pause when you hold a button down and then start when you release that button? (I have the button connected to GPIO pins on my Raspberry Pi)
2017/02/01
[ "https://Stackoverflow.com/questions/41971623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5070269/" ]
**Yes.** The AWS account that is currently controlling your domain name with Route 53 must be used, but it can be pointed to anything on the Internet. Steps: * In the AWS account with the "other" EC2 instance, create an **Elastic IP Address** and assign it to the EC2 instance. This will ensure that its IP address doe...
Once you have set the nameserver for your domain to point to Route53, you no longer need to control the subdomains from bigrock services. Just add them to your Route53 dashboard, and they'll be reflected live.
50,628,893
I am doing a final project in a python course and I have done a program using phantomjs that run like a background process in windows. Therefore, after creating my project, I used pyinstaller --noconsole --onefile to my file in order to hide his console but even tough I did it, I still get a console popup - phantomjs....
2018/05/31
[ "https://Stackoverflow.com/questions/50628893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9581412/" ]
No need to rename the .dat to .csv. Instead you can use a regex that matches two or more spaces as a column separator. Try use `sep` parameter: ``` pd.read_csv('http://users.stat.ufl.edu/~winner/data/clinton1.dat', header=None, sep='\s\s+', engine='python') ``` Output: ``` 0 1 2 ...
You can use a regular expression as a separator. In your specific case, all the delimiters are more than one space whereas the spaces in the names are just single spaces. ``` import pandas as pd clinton = pd.read_csv("clinton1.csv", sep='\s{2,}', header=None, engine='python') ```
20,269,507
I'm a novice in python and also in py.test. I'm searching a way to run multiple tests on multiple items and cannot find it. I'm sure it's quite simple when you know how to do it. I have simplified what I'm trying to do to make it simple to understand. If I have a Test class who defines a serie of tests like this one...
2013/11/28
[ "https://Stackoverflow.com/questions/20269507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269921/" ]
Add the sorting clause to the most outer query
For paging with a "window", you can do something like this: ``` select e.* from ( select e.* , row_number() over (order by uur_id) ive$idx$ from bubs_uren_v e where ( uur_id = :w1 ) ) e where ive$idx$ between (:start_index + 1) and (:star...