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 |
|---|---|---|---|---|---|
52,911,232 | I'm trying to install and import the Basemap library into my Jupyter Notebook, but this returns the following error:
```
KeyError: 'PROJ_LIB'
```
After some research online, I understand I'm to install Basemap on a separate environment in Anaconda. After creating a new environment and installing Basemap (as well as ... | 2018/10/21 | [
"https://Stackoverflow.com/questions/52911232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10534668/"
] | In Windows 10 command line: first find the directory where the **epsg** file is stored:
```
where /r "c:\Users\username" epsg.*
```
...
**c:\Users\username\AppData\Local\conda\conda\envs\envname\Library\share**\epsg
...
then either in command line:
```
activate envname
SET PROJ_LIB=c:\Users\username\AppData\Loc... | If you **can not locate epsg file** at all, you can download it here:
<https://raw.githubusercontent.com/matplotlib/basemap/master/lib/mpl_toolkits/basemap/data/epsg>
And copy this file to your PATH, e.g. to:
os.environ['PROJ\_LIB'] = 'C:\Users\username\Anaconda3\pkgs\basemap-1.2.0-py37h4e5d7af\_0\Lib\site-packages\... |
67,439,037 | Code to extract sequences
```
from Bio import SeqIO
def get_cds_feature_with_qualifier_value(seq_record, name, value):
for feature in genome_record.features:
if feature.type == "CDS" and value in feature.qualifiers.get(name, []):
return feature
return None
genome_record = SeqIO.read("470.8... | 2021/05/07 | [
"https://Stackoverflow.com/questions/67439037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13965256/"
] | You can resolve the inline execution error by changing `scriptTag.innerHTML = scriptText;` to `scriptTag.src = chrome.runtime.getURL(filePath);`, no need to fetch the script. Manifest v3 seems to only allow injecting static scripts into the page context.
If you want to run dynamically sourced scripts I think this can ... | Download the script files and put it on your project to make it local. It solved my content security policy problem. |
20,564,010 | I am calling a python script from a ruby program as:
```
sku = ["VLJAI20225", "VJLS1234"]
qty = ["3", "7"]
system "python2 /home/nish/stuff/repos/Untitled/voylla_staging_changes/app/models/ReviseItem.py #{sku} #{qtys}"
```
But I'd like to access the array elements in the python script.
```
print sys.argv[1]
#... | 2013/12/13 | [
"https://Stackoverflow.com/questions/20564010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2388940/"
] | Not a python specialist, but a quick fix would be to use json:
```
system "python2 /home/nish/stuff/repos/Untitled/voylla_staging_changes/app/models/ReviseItem.py #{sku.to_json} #{qtys.to_json}"
```
Then parse in your python script. | ```
"python2 /home/nish/stuff/repos/Untitled/voylla_staging_changes/app/models/ReviseItem.py \'#{sku}\' \'#{qtys}\'"
```
Maybe something like this? |
20,564,010 | I am calling a python script from a ruby program as:
```
sku = ["VLJAI20225", "VJLS1234"]
qty = ["3", "7"]
system "python2 /home/nish/stuff/repos/Untitled/voylla_staging_changes/app/models/ReviseItem.py #{sku} #{qtys}"
```
But I'd like to access the array elements in the python script.
```
print sys.argv[1]
#... | 2013/12/13 | [
"https://Stackoverflow.com/questions/20564010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2388940/"
] | You need to find a suitable protocol to encode your data (your array, list, whatever) over the interface you've chosen (this much is true pretty general).
In your case, you've chosen as interface the Unix process call mechanism which allows only passing of a list of strings during calling. This list also is rather lim... | Not a python specialist, but a quick fix would be to use json:
```
system "python2 /home/nish/stuff/repos/Untitled/voylla_staging_changes/app/models/ReviseItem.py #{sku.to_json} #{qtys.to_json}"
```
Then parse in your python script. |
20,564,010 | I am calling a python script from a ruby program as:
```
sku = ["VLJAI20225", "VJLS1234"]
qty = ["3", "7"]
system "python2 /home/nish/stuff/repos/Untitled/voylla_staging_changes/app/models/ReviseItem.py #{sku} #{qtys}"
```
But I'd like to access the array elements in the python script.
```
print sys.argv[1]
#... | 2013/12/13 | [
"https://Stackoverflow.com/questions/20564010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2388940/"
] | You need to find a suitable protocol to encode your data (your array, list, whatever) over the interface you've chosen (this much is true pretty general).
In your case, you've chosen as interface the Unix process call mechanism which allows only passing of a list of strings during calling. This list also is rather lim... | ```
"python2 /home/nish/stuff/repos/Untitled/voylla_staging_changes/app/models/ReviseItem.py \'#{sku}\' \'#{qtys}\'"
```
Maybe something like this? |
66,297,277 | I'm trying to embed python code in a C++ application. Problem is that if I use OpenCV functions in the C++ code and also in python function I am embedding there is memory corruption. Simply commenting all the opencv functions from the code below solve the problem.
One thing is that my OpenCV for c++ is 4.5.0 (dinamical... | 2021/02/20 | [
"https://Stackoverflow.com/questions/66297277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4267439/"
] | It seems a linking problem.
Python uses "dlopen" to dynamically load libraries, try changing the [flags](https://manpages.debian.org/buster/manpages-dev/dlopen.3.en.html) that are passed to this function. For example, using RTLD\_DEEPBIND you can specify to prefer the symbols contained by the loaded objects (instead o... | I think your problem is that python uses binding for c++ functions, and as you mention you are using different opencv versions for opencv c++ and python. Refer to <https://docs.opencv.org/3.4/da/d49/tuy_bindings_basics.html> for more information about python bindings. One solution will be to use already bonded function... |
67,094,562 | My dataset is a .txt file separated by colons (:). One of the columns contains a date *AND* time, the date is separated by backslash (/) which is fine. However, the time is separated by colons (:) just like the rest of the data which throws off my method for cleaning the data.
Example of a couple of lines of the datas... | 2021/04/14 | [
"https://Stackoverflow.com/questions/67094562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12326879/"
] | You cannot assign to arrays. You should use [`strcpy()`](https://man7.org/linux/man-pages/man3/strcpy.3.html) to copy C-style strings.
```
strcpy(dstPath, getenv("APPDATA"));
strcat(dstPath, p.filename().string().c_str());
```
Or the concatination can be done in one line via [`snprintf()`](https://man7.org/linux/man... | You are trying to use strcat to concatenate two strings and store the result in another one, but it does not work that way. The call `strcat (str1, str2)` adds the content of `str2` at the end of `str1`. It also returns a pointer to `str1` but I don't normally use it.
What you are trying to do should be done in three ... |
67,094,562 | My dataset is a .txt file separated by colons (:). One of the columns contains a date *AND* time, the date is separated by backslash (/) which is fine. However, the time is separated by colons (:) just like the rest of the data which throws off my method for cleaning the data.
Example of a couple of lines of the datas... | 2021/04/14 | [
"https://Stackoverflow.com/questions/67094562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12326879/"
] | You cannot assign to arrays. You should use [`strcpy()`](https://man7.org/linux/man-pages/man3/strcpy.3.html) to copy C-style strings.
```
strcpy(dstPath, getenv("APPDATA"));
strcat(dstPath, p.filename().string().c_str());
```
Or the concatination can be done in one line via [`snprintf()`](https://man7.org/linux/man... | First off, you are mixing `TCHAR` and `char` APIs in a way you should not be. You really should not be using `TCHAR` at all in modern code. But, if you are going to use `TCHAR`, then at least use `TCHAR`- based functions/macros, like `_tprintf()` instead of `printf()`, `_tcscat()` instead of `strcat()`, etc.
The compi... |
65,974,443 | When I compile `graalpython -m ginstall install pandas` or `graalpython -m ginstall install bumpy`
I got the following error, please comment how to fix the error. Thank you.
```
line 54, in __init__
File "number.c", line 284, in array_power
File "ufunc_object.c", line 4688, in ufunc_generic_call
File "ufunc_obje... | 2021/01/31 | [
"https://Stackoverflow.com/questions/65974443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5329711/"
] | I'm seeing a couple steps missing.
1. You shouldn't be installing chromedriver from brew, you can use the "webdrivers" gem to handle that. The gem will install drivers in the `~/.webdrivers` directory by default.
2. When running integration tests, you'll need to set the proper driver for Capybara. <https://github.com/... | Very stupid and non-obvious issue - the gems need to be in the `test` group ♂️:
```
group :test do
gem 'capybara'
gem 'webdrivers'
end
``` |
41,175,862 | I'm using Connector/Python to insert many rows into a temp table in mysql. The rows are all in a list-of-lists. I perform the insertion like this:
```
cursor = connection.cursor();
batch = [[1, 'foo', 'bar'],[2, 'xyz', 'baz']]
cursor.executemany('INSERT INTO temp VALUES(?, ?, ?)', batch)
connection.commit()
```
I no... | 2016/12/16 | [
"https://Stackoverflow.com/questions/41175862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2627992/"
] | Answering so other people won't go through the debugging I had to!
I wrote the query modeling it on other queries in our code that used prepared statements and used '?' to indicate parameters. But you *can't do that* for executemany()! It *must* use '%s'. Changing to the following:
```
cursor.executemany('INSERT INTO... | Try turn this command on:
cursor.fast\_executemany = True
Otherwise executemany acts just like multiple execute |
41,175,862 | I'm using Connector/Python to insert many rows into a temp table in mysql. The rows are all in a list-of-lists. I perform the insertion like this:
```
cursor = connection.cursor();
batch = [[1, 'foo', 'bar'],[2, 'xyz', 'baz']]
cursor.executemany('INSERT INTO temp VALUES(?, ?, ?)', batch)
connection.commit()
```
I no... | 2016/12/16 | [
"https://Stackoverflow.com/questions/41175862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2627992/"
] | Answering so other people won't go through the debugging I had to!
I wrote the query modeling it on other queries in our code that used prepared statements and used '?' to indicate parameters. But you *can't do that* for executemany()! It *must* use '%s'. Changing to the following:
```
cursor.executemany('INSERT INTO... | If you used `IGNORE` like `cursor.executemany('INSERT IGNORE INTO temp VALUES(%s,%s,%s)', batch)`, `executemany()` acts just like multiple execute! |
41,175,862 | I'm using Connector/Python to insert many rows into a temp table in mysql. The rows are all in a list-of-lists. I perform the insertion like this:
```
cursor = connection.cursor();
batch = [[1, 'foo', 'bar'],[2, 'xyz', 'baz']]
cursor.executemany('INSERT INTO temp VALUES(?, ?, ?)', batch)
connection.commit()
```
I no... | 2016/12/16 | [
"https://Stackoverflow.com/questions/41175862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2627992/"
] | If you used `IGNORE` like `cursor.executemany('INSERT IGNORE INTO temp VALUES(%s,%s,%s)', batch)`, `executemany()` acts just like multiple execute! | Try turn this command on:
cursor.fast\_executemany = True
Otherwise executemany acts just like multiple execute |
35,162,989 | I am learning python and need some help with lists and printing of the same.
List would end up looking list this:
```
mylist = ["a", "d", "c", "g", "g", "g", "a", "b", "n", "g", "a", "s", "t", "z", "a"]
```
I've used Counter(i think lol)
```
class item_print(Counter):
def __str__(self):
return '\n'.... | 2016/02/02 | [
"https://Stackoverflow.com/questions/35162989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5699265/"
] | Three problems.
First this needs to be put in a directive so you are assured the element(s) exist(s) when the code is run
Next...the event is outside of angular context . Whenever code outside of angular updates scope you need to tell angular to update view
Last ... `angular.element` doesn't accept class selectors ... | You are updating scope variable angular, out of its context. Angular doesn't run the digest cycle for those kind of updation. In this case you are updating scope variables from custom events, which doesn't intimate Angular digest system something has udpated on UI, resultant the digest cycle doesn't get fired.
You ne... |
55,738,296 | A call to [`functools.reduce`](https://docs.python.org/3/library/functools.html#functools.reduce) returns only the final result:
```
>>> from functools import reduce
>>> a = [1, 2, 3, 4, 5]
>>> f = lambda x, y: x + y
>>> reduce(f, a)
15
```
Instead of writing a loop myself, does a function exist which returns the in... | 2019/04/18 | [
"https://Stackoverflow.com/questions/55738296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1621041/"
] | You can use [`itertools.accumulate()`](https://docs.python.org/3/library/itertools.html#itertools.accumulate):
```
>>> from itertools import accumulate
>>> list(accumulate([1, 2, 3, 4, 5], lambda x, y: x+y))[1:]
[3, 6, 10, 15]
```
Note that the order of parameters is switched relative to `functools.reduce()`.
Also,... | ```
import numpy as np
x=[1, 2, 3, 4, 5]
y=np.cumsum(x) # gets you the cumulative sum
y=list(y[1:]) # remove the first number
print(y)
#[3, 6, 10, 15]
``` |
53,129,790 | I'm using Django with Postgres.
On a page I can show a list of featured items, let's say 10.
1. If in the database I have more featured items than 10, I want to get them random/(better rotate).
2. If the number of featured item is lower than 10, get all featured item and add to the list until 10 non-featured items.
... | 2018/11/03 | [
"https://Stackoverflow.com/questions/53129790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3541631/"
] | you may use the `whereHas` keyword in laravel:
```
public function search(Request $request) {
return Product::with('categories')
->whereHas('categories', function ($query) use ($request){
$query->where('category_id', $request->category_id);
})->get();
}
```
Here is the [docs](https://laravel.... | You can search it in following way:
```
public function search(Request $request) {
return Product::with('categories')
->whereHas('categories', function ($q) use (request) {
$q->where('id', $request->category_id);
});
}
``` |
37,530,804 | I'm new to MPI, but I have been trying to use it on a cluster with OpenMPI. I'm having the following problem:
```
$ python -c "from mpi4py import MPI"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: libmpi.so.1: cannot open shared object file: No such file or directory
```
I've... | 2016/05/30 | [
"https://Stackoverflow.com/questions/37530804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6332838/"
] | Even adding to LD\_LIBRARY\_PATH did not work for me. I had to uninstall mpi4py, then install it manually with my mpicc path according to the instructions here - <https://mpi4py.readthedocs.io/en/stable/install.html> (using distutils section) | I solve this problem by
```bash
pip uninstall mpi4py
conda install mpi4py
``` |
44,132,619 | I used the `pyodbc` and `pypyodbc` python package to connect to SQL server.
Drivers used anyone of these `['SQL Server', 'SQL Server Native Client 10.0', 'ODBC Driver 11 for SQL Server', 'ODBC Driver 13 for SQL Server']`.
connection string :
```
connection = pyodbc.connect('DRIVER={SQL Server};'
'Server=aaa.database... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44132619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5602871/"
] | The problem is not driver issue, you can see the error message is `DatabaseError: Login failed for user`, it means this problem occurs if the user tries to log in with credentials that cannot be validated. I suspect you are login with your windows Authentication, if so, use `Trusted_Connection=yes` instead:
```
connec... | I think problem because of driver definition in your connection string. You may try with below.
```
connection = pyodbc.connect('DRIVER={SQL Server Native Client 10.0}; Server=aaa.database.windows.net; DATABASE=DB_NAME; UID=User_name; PWD=password')
``` |
44,132,619 | I used the `pyodbc` and `pypyodbc` python package to connect to SQL server.
Drivers used anyone of these `['SQL Server', 'SQL Server Native Client 10.0', 'ODBC Driver 11 for SQL Server', 'ODBC Driver 13 for SQL Server']`.
connection string :
```
connection = pyodbc.connect('DRIVER={SQL Server};'
'Server=aaa.database... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44132619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5602871/"
] | The problem is not driver issue, you can see the error message is `DatabaseError: Login failed for user`, it means this problem occurs if the user tries to log in with credentials that cannot be validated. I suspect you are login with your windows Authentication, if so, use `Trusted_Connection=yes` instead:
```
connec... | I applied your connection string and updated it with my server connections details and it worked fine.
Are you sure your are passing correct user name and password ?
Login failed implies connection was established successfully, but authentication didn't pass. |
44,132,619 | I used the `pyodbc` and `pypyodbc` python package to connect to SQL server.
Drivers used anyone of these `['SQL Server', 'SQL Server Native Client 10.0', 'ODBC Driver 11 for SQL Server', 'ODBC Driver 13 for SQL Server']`.
connection string :
```
connection = pyodbc.connect('DRIVER={SQL Server};'
'Server=aaa.database... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44132619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5602871/"
] | I see you have no `port` defined in your script.
The general way to connect to a server using pyodbc `${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort}`, where `DBName` is your database name, `DBUser` is the username used to connect to it, `DBPass` is the password, `DBHost` is the URL of your database, and `DBPort` i... | I think problem because of driver definition in your connection string. You may try with below.
```
connection = pyodbc.connect('DRIVER={SQL Server Native Client 10.0}; Server=aaa.database.windows.net; DATABASE=DB_NAME; UID=User_name; PWD=password')
``` |
44,132,619 | I used the `pyodbc` and `pypyodbc` python package to connect to SQL server.
Drivers used anyone of these `['SQL Server', 'SQL Server Native Client 10.0', 'ODBC Driver 11 for SQL Server', 'ODBC Driver 13 for SQL Server']`.
connection string :
```
connection = pyodbc.connect('DRIVER={SQL Server};'
'Server=aaa.database... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44132619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5602871/"
] | I see you have no `port` defined in your script.
The general way to connect to a server using pyodbc `${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort}`, where `DBName` is your database name, `DBUser` is the username used to connect to it, `DBPass` is the password, `DBHost` is the URL of your database, and `DBPort` i... | I applied your connection string and updated it with my server connections details and it worked fine.
Are you sure your are passing correct user name and password ?
Login failed implies connection was established successfully, but authentication didn't pass. |
44,132,619 | I used the `pyodbc` and `pypyodbc` python package to connect to SQL server.
Drivers used anyone of these `['SQL Server', 'SQL Server Native Client 10.0', 'ODBC Driver 11 for SQL Server', 'ODBC Driver 13 for SQL Server']`.
connection string :
```
connection = pyodbc.connect('DRIVER={SQL Server};'
'Server=aaa.database... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44132619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5602871/"
] | You can add `Trusted_Connection=NO;` in your connection string after the password | I think problem because of driver definition in your connection string. You may try with below.
```
connection = pyodbc.connect('DRIVER={SQL Server Native Client 10.0}; Server=aaa.database.windows.net; DATABASE=DB_NAME; UID=User_name; PWD=password')
``` |
44,132,619 | I used the `pyodbc` and `pypyodbc` python package to connect to SQL server.
Drivers used anyone of these `['SQL Server', 'SQL Server Native Client 10.0', 'ODBC Driver 11 for SQL Server', 'ODBC Driver 13 for SQL Server']`.
connection string :
```
connection = pyodbc.connect('DRIVER={SQL Server};'
'Server=aaa.database... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44132619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5602871/"
] | You can add `Trusted_Connection=NO;` in your connection string after the password | I applied your connection string and updated it with my server connections details and it worked fine.
Are you sure your are passing correct user name and password ?
Login failed implies connection was established successfully, but authentication didn't pass. |
12,700,194 | I've installed git-core (+svn) on my Mac from MacPorts. This has given me:
```
git-core @1.7.12.2_0+credential_osxkeychain+doc+pcre+python27+svn
subversion @1.7.6_2
```
I'm attempting to call something like the following:
```
git svn clone http://my.svn.com/svn/area/subarea/project -s
```
The output looks someth... | 2012/10/03 | [
"https://Stackoverflow.com/questions/12700194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1637252/"
] | Add this setting to your `~/.subversion/servers` file:
```
[global]
http-bulk-updates=on
```
I had this issue on Linux, and saw the above workaround on [this thread](http://mail-archives.apache.org/mod_mbox/subversion-users/201307.mbox/%[email protected]%3E). I **think** I ran into this because I force... | <http://bugs.debian.org/534763> suggests it is a bug in libsvn-perl package, try upgrading that |
12,700,194 | I've installed git-core (+svn) on my Mac from MacPorts. This has given me:
```
git-core @1.7.12.2_0+credential_osxkeychain+doc+pcre+python27+svn
subversion @1.7.6_2
```
I'm attempting to call something like the following:
```
git svn clone http://my.svn.com/svn/area/subarea/project -s
```
The output looks someth... | 2012/10/03 | [
"https://Stackoverflow.com/questions/12700194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1637252/"
] | Note that [git 1.8.5rc3 (release November 20st, 2013](https://github.com/git/git/blob/5fd09df3937f54c5cfda4f1087f5d99433cce527/Documentation/RelNotes/1.8.5.txt#L56-L61), [announced here](http://article.gmane.org/gmane.comp.version-control.git/238099)) now includes:
* "`git-svn`" has been taught to use the [**`serf`** ... | <http://bugs.debian.org/534763> suggests it is a bug in libsvn-perl package, try upgrading that |
12,700,194 | I've installed git-core (+svn) on my Mac from MacPorts. This has given me:
```
git-core @1.7.12.2_0+credential_osxkeychain+doc+pcre+python27+svn
subversion @1.7.6_2
```
I'm attempting to call something like the following:
```
git svn clone http://my.svn.com/svn/area/subarea/project -s
```
The output looks someth... | 2012/10/03 | [
"https://Stackoverflow.com/questions/12700194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1637252/"
] | Add this setting to your `~/.subversion/servers` file:
```
[global]
http-bulk-updates=on
```
I had this issue on Linux, and saw the above workaround on [this thread](http://mail-archives.apache.org/mod_mbox/subversion-users/201307.mbox/%[email protected]%3E). I **think** I ran into this because I force... | Note that [git 1.8.5rc3 (release November 20st, 2013](https://github.com/git/git/blob/5fd09df3937f54c5cfda4f1087f5d99433cce527/Documentation/RelNotes/1.8.5.txt#L56-L61), [announced here](http://article.gmane.org/gmane.comp.version-control.git/238099)) now includes:
* "`git-svn`" has been taught to use the [**`serf`** ... |
73,629,234 | Simplest way to explain will be I have this code,
```
Str = 'Floor_Live_Patterened_SpanPairs_1: [[-3, 0, 0, 5.5], [-3, 5.5, 0, 9.5]]Floor_Live_Patterened_SpanPairs_2: [[-3, 0, 0, 5.5], [-3, 9.5, 0, 13.5]]Floor_Live_Patterened_SpanPairs_3: [[-3, 5.5, 0, 9.5], [-3, 9.5, 0, 13.5]]'
from re import findall
findall ('[^\]\... | 2022/09/07 | [
"https://Stackoverflow.com/questions/73629234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16966180/"
] | You can simplify and start to make the code reusable by putting it into a function. Also, it's a good idea to make it pythonic and remove all the `;` that will only serve to confuse the reader as to what language they're looking at.
```
def login(name, age):
password = input('Enter your desired password: ')
pr... | I got this working.
```py
def login():
counter = 1;
x = 5;
for i in range(5):
print(' Login ');
login = input('Enter password: ');
if login == password:
counter -= 1
print(' Welcome ');
print('Account Information: ');
print('Name: ',n... |
53,810,242 | i have two functions in python
```
class JENKINS_JOB_INFO():
def __init__(self):
parser = argparse.ArgumentParser(description='xxxx. e.g., script.py -j jenkins_url -u user -a api')
parser.add_argument('-j', '--address', dest='address', default="", required=True, action="store")
parser.add_a... | 2018/12/17 | [
"https://Stackoverflow.com/questions/53810242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5871199/"
] | Just write `params.params` instead of `params`.
The way you do it is extremely confusing because in `get_jenkins_josn_data`, `self` will be the `params` and `params` will be the `base_url`. I would advise you no to do that in the future. If you want to send some parameters to the function, send the minimal amount of ... | So your solution is a bit confusing. You shouldn't pass the self to the `get_jenkins_json_data` method. The python will do that for you automatically. You should check out the data model for how [instance methods](https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy) work. I would refactor you... |
53,810,242 | i have two functions in python
```
class JENKINS_JOB_INFO():
def __init__(self):
parser = argparse.ArgumentParser(description='xxxx. e.g., script.py -j jenkins_url -u user -a api')
parser.add_argument('-j', '--address', dest='address', default="", required=True, action="store")
parser.add_a... | 2018/12/17 | [
"https://Stackoverflow.com/questions/53810242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5871199/"
] | In your function `get_jobs_state` you are passing in self as the argument for the params argument to the `get_jenkins_json_data`, and self in this case is an instance of a class.
Try something like this:
```
class Jenkins:
def __init__(self, domain):
self.user = "user"
self.api_token = "api_token"
self.... | So your solution is a bit confusing. You shouldn't pass the self to the `get_jenkins_json_data` method. The python will do that for you automatically. You should check out the data model for how [instance methods](https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy) work. I would refactor you... |
66,038,159 | To improve performance on project of mine, i've coded a function using tf.function to replace a function witch does not use tf. The result is that plain python code runs much (100x faster) than the tf.funtion when GPU is enabled. When running on CPU, TF is still slower, but only 10x slower. Am i missing something?
```... | 2021/02/04 | [
"https://Stackoverflow.com/questions/66038159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15140159/"
] | When you use some tf functions with GPU enabled, it does a callback and transfers data to the GPU. In some cases, this overhead is not worth it. When running on the CPU, this overhead decreases, but it's still slower than pure python code.
Tensorflow is faster when you do heavy calculations, and that's what Tensorflow... | The slow part (while loop) is still in python and simple functions like this are pretty fast. The linear overhead of switching from python to tf each time is certainly bigger than anything you could ever gain on such a small function. For more complex operations, this might be very different. In this case tf is simply ... |
13,216,520 | Walking through matplotlib's animation example on my Mac OSX machine - <http://matplotlib.org/examples/animation/simple_anim.html> - I am getting this error:-
```
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 248, in _blit_clear
a.figure.canvas.r... | 2012/11/04 | [
"https://Stackoverflow.com/questions/13216520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482506/"
] | You can avoid the problem by switching to a different backend:
```
import matplotlib
matplotlib.use('TkAgg')
``` | Looks like it's a known (and unresolved at this time of writing) issue - <https://github.com/matplotlib/matplotlib/issues/531> |
13,216,520 | Walking through matplotlib's animation example on my Mac OSX machine - <http://matplotlib.org/examples/animation/simple_anim.html> - I am getting this error:-
```
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 248, in _blit_clear
a.figure.canvas.r... | 2012/11/04 | [
"https://Stackoverflow.com/questions/13216520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482506/"
] | Just set
```
blit=False
```
when [animation.FuncAnimation()](http://matplotlib.org/api/animation_api.html#matplotlib.animation.FuncAnimation) is called and it will work.
For instance ([from double\_pendulum\_animated](http://matplotlib.org/examples/animation/double_pendulum_animated.html)):
```
ani = animation.Fu... | Looks like it's a known (and unresolved at this time of writing) issue - <https://github.com/matplotlib/matplotlib/issues/531> |
13,216,520 | Walking through matplotlib's animation example on my Mac OSX machine - <http://matplotlib.org/examples/animation/simple_anim.html> - I am getting this error:-
```
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 248, in _blit_clear
a.figure.canvas.r... | 2012/11/04 | [
"https://Stackoverflow.com/questions/13216520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482506/"
] | As noted at <https://mail.python.org/pipermail/pythonmac-sig/2012-September/023664.html> use:
```
import matplotlib
matplotlib.use('TkAgg')
#just *before*
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
```
This has worked for me with Tkinter installed using the ActiveS... | Looks like it's a known (and unresolved at this time of writing) issue - <https://github.com/matplotlib/matplotlib/issues/531> |
13,216,520 | Walking through matplotlib's animation example on my Mac OSX machine - <http://matplotlib.org/examples/animation/simple_anim.html> - I am getting this error:-
```
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 248, in _blit_clear
a.figure.canvas.r... | 2012/11/04 | [
"https://Stackoverflow.com/questions/13216520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482506/"
] | Just set
```
blit=False
```
when [animation.FuncAnimation()](http://matplotlib.org/api/animation_api.html#matplotlib.animation.FuncAnimation) is called and it will work.
For instance ([from double\_pendulum\_animated](http://matplotlib.org/examples/animation/double_pendulum_animated.html)):
```
ani = animation.Fu... | You can avoid the problem by switching to a different backend:
```
import matplotlib
matplotlib.use('TkAgg')
``` |
13,216,520 | Walking through matplotlib's animation example on my Mac OSX machine - <http://matplotlib.org/examples/animation/simple_anim.html> - I am getting this error:-
```
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 248, in _blit_clear
a.figure.canvas.r... | 2012/11/04 | [
"https://Stackoverflow.com/questions/13216520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482506/"
] | You can avoid the problem by switching to a different backend:
```
import matplotlib
matplotlib.use('TkAgg')
``` | As noted at <https://mail.python.org/pipermail/pythonmac-sig/2012-September/023664.html> use:
```
import matplotlib
matplotlib.use('TkAgg')
#just *before*
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
```
This has worked for me with Tkinter installed using the ActiveS... |
13,216,520 | Walking through matplotlib's animation example on my Mac OSX machine - <http://matplotlib.org/examples/animation/simple_anim.html> - I am getting this error:-
```
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 248, in _blit_clear
a.figure.canvas.r... | 2012/11/04 | [
"https://Stackoverflow.com/questions/13216520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/482506/"
] | Just set
```
blit=False
```
when [animation.FuncAnimation()](http://matplotlib.org/api/animation_api.html#matplotlib.animation.FuncAnimation) is called and it will work.
For instance ([from double\_pendulum\_animated](http://matplotlib.org/examples/animation/double_pendulum_animated.html)):
```
ani = animation.Fu... | As noted at <https://mail.python.org/pipermail/pythonmac-sig/2012-September/023664.html> use:
```
import matplotlib
matplotlib.use('TkAgg')
#just *before*
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
```
This has worked for me with Tkinter installed using the ActiveS... |
34,347,401 | I have a Pelican blog where I write the posts in Markdown. I want each article to link to the previous and next article in the sequence, and to one random article.
All the articles are generated with a python script, resulting in a folder of markdown files called /content/. Here the files are like:
* article-slug1.m... | 2015/12/18 | [
"https://Stackoverflow.com/questions/34347401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4108771/"
] | There is the [Pelican Neighbours](https://github.com/getpelican/pelican-plugins/tree/master/neighbors) plug-in that might do what you want. You'll have to active the plug-in and update your template to get it to work.
* Adding plug-ins: [Pelican-Plugins' Readme](https://github.com/getpelican/pelican-plugins/blob/maste... | I am not sure about the random article, but for next and previous, there is a Pelican plugin called [neighbor articles](https://github.com/getpelican/pelican-plugins/tree/master/neighbors). |
34,347,401 | I have a Pelican blog where I write the posts in Markdown. I want each article to link to the previous and next article in the sequence, and to one random article.
All the articles are generated with a python script, resulting in a folder of markdown files called /content/. Here the files are like:
* article-slug1.m... | 2015/12/18 | [
"https://Stackoverflow.com/questions/34347401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4108771/"
] | There is the [Pelican Neighbours](https://github.com/getpelican/pelican-plugins/tree/master/neighbors) plug-in that might do what you want. You'll have to active the plug-in and update your template to get it to work.
* Adding plug-ins: [Pelican-Plugins' Readme](https://github.com/getpelican/pelican-plugins/blob/maste... | Random article:<https://github.com/getpelican/pelican-plugins/tree/master/random_article>
More pelican plugins: <https://github.com/getpelican/pelican-plugins> |
34,347,401 | I have a Pelican blog where I write the posts in Markdown. I want each article to link to the previous and next article in the sequence, and to one random article.
All the articles are generated with a python script, resulting in a folder of markdown files called /content/. Here the files are like:
* article-slug1.m... | 2015/12/18 | [
"https://Stackoverflow.com/questions/34347401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4108771/"
] | There is the [Pelican Neighbours](https://github.com/getpelican/pelican-plugins/tree/master/neighbors) plug-in that might do what you want. You'll have to active the plug-in and update your template to get it to work.
* Adding plug-ins: [Pelican-Plugins' Readme](https://github.com/getpelican/pelican-plugins/blob/maste... | If you are generating all your posts programatically, is it safe to assume that your generation script knows what the next and previous articles? If this is the case, then you can write the links in directly in your generated markdown.
E.g. at the end of `another-article-slug.md` add the lines:
```
<!-- end of articl... |
67,455,130 | I am new to python and trying to create a small atm like project using classes. I wanna have the user ability to input the amount they want to withdraw and if the amount exceeds the current balance, it prints out that you cannot have negative balance and asks for the input again.
```
class account:
def __init__(s... | 2021/05/09 | [
"https://Stackoverflow.com/questions/67455130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11606914/"
] | Via `np.select`
```
condlist = [
(df.Email_x.isna()) & (~df.Email_y.isna()), # 1st column NAN but 2nd is not
(df.Email_y.isna()) & (~df.Email_x.isna()), # 2nd column NAN but 1st is not
(~df.Email_x.isna()) & (~df.Email_y.isna()) # both is not NAN
]
choicelist = [
df.Email_y,
df.Email_x,
df.Em... | You can use [`.mask()`](https://pandas.pydata.org/docs/reference/api/pandas.Series.mask.html), as follows:
```
df['email'] = df['Email_x'].mask(df['Email_x'].isna(), df['Email_y'])
```
It will retain the value of `df['Email_x']` if the condition is false (i.e. not `NaN`) and replace with value of `df['Email_y']` if ... |
67,455,130 | I am new to python and trying to create a small atm like project using classes. I wanna have the user ability to input the amount they want to withdraw and if the amount exceeds the current balance, it prints out that you cannot have negative balance and asks for the input again.
```
class account:
def __init__(s... | 2021/05/09 | [
"https://Stackoverflow.com/questions/67455130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11606914/"
] | Here is a [great answer](https://stackoverflow.com/questions/44061607/pandas-lambda-function-with-nan-support), which can be achieved with combine\_first().
```
df['email'] = df['Email_x'].combine_first(df['Email_y'])
``` | You can use [`.mask()`](https://pandas.pydata.org/docs/reference/api/pandas.Series.mask.html), as follows:
```
df['email'] = df['Email_x'].mask(df['Email_x'].isna(), df['Email_y'])
```
It will retain the value of `df['Email_x']` if the condition is false (i.e. not `NaN`) and replace with value of `df['Email_y']` if ... |
24,468,944 | I am trying to write a python program that asks the user to enter an existing text file's name and then display the first 5 lines of the text file or the complete file if it is 5 lines or less. This is what I have programmed so far:
```
def main():
# Ask user for the file name they wish to view
filename = inpu... | 2014/06/28 | [
"https://Stackoverflow.com/questions/24468944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3786320/"
] | Just `print()`, by itself, will only print a newline, nothing else. You need to pass the `line` variable to `print()`:
```
print(line)
```
The `line` string will have a newline at the end, you probably want to ask `print` not to add another:
```
print(line, end='')
```
or you can remove the newline:
```
print(li... | In order to print first 5 or less lines. You can try the following code:
```
filename = input('Enter the file name that you wish to view: ')
from itertools import islice
with open(filename) as myfile:
head = list(islice(myfile,5))
print head
```
Hope the above code will satisfy your query.
Thank you. |
24,468,944 | I am trying to write a python program that asks the user to enter an existing text file's name and then display the first 5 lines of the text file or the complete file if it is 5 lines or less. This is what I have programmed so far:
```
def main():
# Ask user for the file name they wish to view
filename = inpu... | 2014/06/28 | [
"https://Stackoverflow.com/questions/24468944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3786320/"
] | Just `print()`, by itself, will only print a newline, nothing else. You need to pass the `line` variable to `print()`:
```
print(line)
```
The `line` string will have a newline at the end, you probably want to ask `print` not to add another:
```
print(line, end='')
```
or you can remove the newline:
```
print(li... | As Martijn said, the print() command takes an argument, and that argument is what it is you'd like to print. Python is interpreted line by line. When the interpreter arrives at your print() line, it is not aware that you want it to print the "line" variable assigned above.
Also, it's good practice to close a file tha... |
24,468,944 | I am trying to write a python program that asks the user to enter an existing text file's name and then display the first 5 lines of the text file or the complete file if it is 5 lines or less. This is what I have programmed so far:
```
def main():
# Ask user for the file name they wish to view
filename = inpu... | 2014/06/28 | [
"https://Stackoverflow.com/questions/24468944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3786320/"
] | As Martijn said, the print() command takes an argument, and that argument is what it is you'd like to print. Python is interpreted line by line. When the interpreter arrives at your print() line, it is not aware that you want it to print the "line" variable assigned above.
Also, it's good practice to close a file tha... | In order to print first 5 or less lines. You can try the following code:
```
filename = input('Enter the file name that you wish to view: ')
from itertools import islice
with open(filename) as myfile:
head = list(islice(myfile,5))
print head
```
Hope the above code will satisfy your query.
Thank you. |
12,231,733 | I have a python script that I want to only allow to be running once on a machine. I want it to print something like "Error, already running" if it is already running, whether its running in the background or in a different ssh session. How would I do this? Here is my script.
```
import urllib, urllib2, sys
num = sys.a... | 2012/09/01 | [
"https://Stackoverflow.com/questions/12231733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1601509/"
] | 1. You can implement a lock on the file.
2. Create a temp file at the start of the execution and check if that file is present before running the script.
Refer to this post for answer- [Check to see if python script is running](https://stackoverflow.com/questions/788411/check-to-see-if-python-script-is-running) | You could lock an existing file using e.g. [flock](http://docs.python.org/library/fcntl.html#fcntl.flock) at start of your script. Then, if the same script is run twice, the latest started would block. See also [this question](https://stackoverflow.com/questions/3918385/flock-question). |
12,231,733 | I have a python script that I want to only allow to be running once on a machine. I want it to print something like "Error, already running" if it is already running, whether its running in the background or in a different ssh session. How would I do this? Here is my script.
```
import urllib, urllib2, sys
num = sys.a... | 2012/09/01 | [
"https://Stackoverflow.com/questions/12231733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1601509/"
] | 1. You can implement a lock on the file.
2. Create a temp file at the start of the execution and check if that file is present before running the script.
Refer to this post for answer- [Check to see if python script is running](https://stackoverflow.com/questions/788411/check-to-see-if-python-script-is-running) | You can install the [single](http://pypi.python.org/pypi/single/) package with `pip install single` that will use an advisory lock to ensure that only a single instance of a command will run without leaving stale lock files behind.
You can invoke it on your script like this:
```
single.py -c long-running-script arg1 ... |
12,231,733 | I have a python script that I want to only allow to be running once on a machine. I want it to print something like "Error, already running" if it is already running, whether its running in the background or in a different ssh session. How would I do this? Here is my script.
```
import urllib, urllib2, sys
num = sys.a... | 2012/09/01 | [
"https://Stackoverflow.com/questions/12231733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1601509/"
] | You can install the [single](http://pypi.python.org/pypi/single/) package with `pip install single` that will use an advisory lock to ensure that only a single instance of a command will run without leaving stale lock files behind.
You can invoke it on your script like this:
```
single.py -c long-running-script arg1 ... | You could lock an existing file using e.g. [flock](http://docs.python.org/library/fcntl.html#fcntl.flock) at start of your script. Then, if the same script is run twice, the latest started would block. See also [this question](https://stackoverflow.com/questions/3918385/flock-question). |
60,682,568 | I've been trying to write code which seperates the age (digits) from name (alphabets) and then compares it to a pre-defined list and if it doesn't match with the list then it sends out an error but instead of getting (for example) alex:error, i'm getting a:error l:error e:error x:error, that is it's splitting the words... | 2020/03/14 | [
"https://Stackoverflow.com/questions/60682568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12387627/"
] | You need to change your names2 variable as its a string type. You need to conver it to a list and append each name to it after str.translate(). Here is the modified code.
```
names2=[name.translate(removed_digits) for name in names1]
```
I hope your problem will solved. | You can try something like this:
```
names=input("Data:")
names1=names.strip().split(',') #split names
for name in names1:
names2 = name.strip().split(' ') #split name and digit
if names2[0] not in lst1:
print(f"{name}:Not Matching to our database.")
``` |
62,789,471 | I'm running python in docker and run across the `ModuleNotFoundError: No module named 'flask'` error message. any thoughts what am I missing in the Dockerfile or requirements ?
```sh
FROM python:3.7.2-alpine
RUN pip install --upgrade pip
RUN apk update && \
apk add --virtual build-deps gcc python-dev
RUN ad... | 2020/07/08 | [
"https://Stackoverflow.com/questions/62789471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13115677/"
] | One way using `itertools.starmap`, `islice` and `operator.sub`:
```
from operator import sub
from itertools import starmap, islice
l = list(range(1, 10000000))
[l[0], *starmap(sub, zip(islice(l, 1, None), l))]
```
Output:
```
[1, 1, 1, ..., 1]
```
---
Benchmark:
```
l = list(range(1, 100000000))
# OP's metho... | You could use [numpy.diff](https://numpy.org/doc/stable/reference/generated/numpy.diff.html), For example:
```py
import numpy as np
a = [1, 2, 3, 4, 5]
npa = np.array(a)
a_diff = np.diff(npa)
``` |
62,789,471 | I'm running python in docker and run across the `ModuleNotFoundError: No module named 'flask'` error message. any thoughts what am I missing in the Dockerfile or requirements ?
```sh
FROM python:3.7.2-alpine
RUN pip install --upgrade pip
RUN apk update && \
apk add --virtual build-deps gcc python-dev
RUN ad... | 2020/07/08 | [
"https://Stackoverflow.com/questions/62789471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13115677/"
] | One way using `itertools.starmap`, `islice` and `operator.sub`:
```
from operator import sub
from itertools import starmap, islice
l = list(range(1, 10000000))
[l[0], *starmap(sub, zip(islice(l, 1, None), l))]
```
Output:
```
[1, 1, 1, ..., 1]
```
---
Benchmark:
```
l = list(range(1, 100000000))
# OP's metho... | You could use `zip` to put together the list with an offset version and subtract those values
```
a = [1, 2, 3, 4, 5]
a[1:] = [nxt - cur for cur, nxt in zip(a, a[1:])]
print(a)
```
Output:
```
[1, 1, 1, 1, 1]
```
Out of interest, I ran this, the original code and @ynotzort answer through `timeit` and this was mu... |
69,788,691 | I am new here. I am a begginer with python so I am trying to write a code that allows me to remove the link break of a list in python.
I have the following list (which is more extense), but I will share a part of it.
```
info = ['COLOMBIA Y LA \nNUEVA REVOLUCIÓN \nINDUSTRIAL\nPropuestas del Foco \nde Tecnologías Con... | 2021/10/31 | [
"https://Stackoverflow.com/questions/69788691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17293731/"
] | You can use list comprehension:
```
info = [i.replace("\n", "") for i in info]
``` | You can use a generator comprehension and then join each entries of the list by a separator character, `sep`, I choose an empty string.
```
sep = '' # choose the separator character
text = sep.join(s.replace('\n', '') for s in info)
``` |
31,972,419 | I have a file whose contents are
```
{'FileID': 'a3333.txt','Timestamp': '2014-12-05T02:01:28.271Z','SuccessList':'a,b,c,d,e'}
```
When I read the file using python, I get the string as
```
"{'FileID': 'a3333.txt','Timestamp': '2014-12-05T02:01:28.271Z','SuccessList':'a,b,c,d,e'}"
```
I want the double quotes t... | 2015/08/12 | [
"https://Stackoverflow.com/questions/31972419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642114/"
] | If the files as stored are intended to be JSON then they are invalid. The JSON format doesn't allow the use of single quotes to delimit strings. **Assuming you have no single quotes within the key/value strings** themselves, you can replace the single quotes with double quotes and then read in using the JSON module:
`... | If your string actually contains double quotes (which it might not, as they could just be part of the printed representation), you could get rid of them with a slice, e.g.,
```
>>> hello = '"hello more stuff things"'
>>> hello
'"hello more stuff things"'
>>> hello[1:-1]
'hello more stuff things'
```
Note in this cas... |
31,972,419 | I have a file whose contents are
```
{'FileID': 'a3333.txt','Timestamp': '2014-12-05T02:01:28.271Z','SuccessList':'a,b,c,d,e'}
```
When I read the file using python, I get the string as
```
"{'FileID': 'a3333.txt','Timestamp': '2014-12-05T02:01:28.271Z','SuccessList':'a,b,c,d,e'}"
```
I want the double quotes t... | 2015/08/12 | [
"https://Stackoverflow.com/questions/31972419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642114/"
] | If the files as stored are intended to be JSON then they are invalid. The JSON format doesn't allow the use of single quotes to delimit strings. **Assuming you have no single quotes within the key/value strings** themselves, you can replace the single quotes with double quotes and then read in using the JSON module:
`... | The double quotes you are referring to are not part of the string, and are just there to delimit it.
If you assign the string "thi's'" to a variable:
`>>> a = "thi's'"`
the first element in that string is `t`:
`>>> a[0]`
`t`
In your example, the first element in the string would be `{`, which I believe is what y... |
31,972,419 | I have a file whose contents are
```
{'FileID': 'a3333.txt','Timestamp': '2014-12-05T02:01:28.271Z','SuccessList':'a,b,c,d,e'}
```
When I read the file using python, I get the string as
```
"{'FileID': 'a3333.txt','Timestamp': '2014-12-05T02:01:28.271Z','SuccessList':'a,b,c,d,e'}"
```
I want the double quotes t... | 2015/08/12 | [
"https://Stackoverflow.com/questions/31972419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642114/"
] | If the files as stored are intended to be JSON then they are invalid. The JSON format doesn't allow the use of single quotes to delimit strings. **Assuming you have no single quotes within the key/value strings** themselves, you can replace the single quotes with double quotes and then read in using the JSON module:
`... | You can convert the `string` back to `dictionary` using
```
import re
x="{'FileID': 'a3333.txt','Timestamp': '2014-12-05T02:01:28.271Z','SuccessList':'a,b,c,d,e'}"
print dict(re.findall(r"""'([^']*)'\s*:\s*'([^']*)'""",x))
``` |
10,436,130 | How should this python be expressed
```
gl_enums = ... # map from name to values for opengl enums
# use with gl_enums["enum name"]
```
in clojure? This works, but is it right?
```
(def gl-enums ...) ; map from name to values for opengl enums
(defn gl-enum [k] (or (gl-enums k) (throw (SomeException.))))
; use with (... | 2012/05/03 | [
"https://Stackoverflow.com/questions/10436130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/322866/"
] | Your original example is OK. Two approaches you are also likely to come across:
```
;; not very idiomatic
(defn example
[m]
(if (contains? m :name)
(:name m)
(throw (IllegalArgumentException. (format "key %s is missing" :name)))))
;; idiomatic
(defn example
[m]
(if-let [v (:name m)]
v
(throw (... | Just use a regular hashmap:
```
(def gl-enums {:name1 "value1", :name2 "value2",
:name3 "value3", ...})
```
if you don't want to provide keywords (like `:keyword`) but prefer strings, you'll need to use `(get gl-enums str)` in `gl-enum` |
43,684,760 | I have very basic python knowledge. This is my code so far:
when i run this code the error `UnboundLocalError: local variable 'response' referenced before assignment on line 7` displays. I am trying to create a function that compares the response input to two lists and if that input is found true or false is assigned ... | 2017/04/28 | [
"https://Stackoverflow.com/questions/43684760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7937653/"
] | You are complicating things a lot here, but that is understandable if you are new to programming or python.
To put you on the right track, this is a better way to attack the problem:
```
valid_responses = ['a', 'b']
response = input("chose a or b: ").lower().strip()
if response in valid_responses:
print("Valid re... | Instead of enumerating a list of exact possible answers, you could instead match against patterns of possible answers. Here is one way to do that, case insensitively:
```
import re
known_fruits = ['apple', 'orange']
response = str(input("What would you like to eat? (Answer " + ' or '.join(known_fruits) + '): '))
def... |
15,854,916 | i've a problem, like a title.
I've tried to install smart\_selects in my project Django, but does not work.
I followed the readme in <https://github.com/digi604/django-smart-selects>... but the error is:
>
> No module named admin\_static
> Request Method: GET
> Request URL: http://**\*.com/panel/schedevendorcomplet... | 2013/04/06 | [
"https://Stackoverflow.com/questions/15854916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2252933/"
] | Use Java's Calendar: (since my beloved Date is deprecated)
[Calendar API](http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html)
Try something like:
```
Calendar c = Calendar.getInstance();
c.setTimeInMillis(1365228375*1000);
System.out.print(c.toString()); - just to demonstrate the API has lots of i... | Well, conversion from seconds to microseconds shouldn't be too difficult;
```
echo time() * 1000;
```
If you need the time stamp to be **acurate** in milliseconds, look at [`microtime()`](http://www.php.net/manual/en/function.microtime.php) however, this function does *not* return an integer so you'll have to do som... |
15,854,916 | i've a problem, like a title.
I've tried to install smart\_selects in my project Django, but does not work.
I followed the readme in <https://github.com/digi604/django-smart-selects>... but the error is:
>
> No module named admin\_static
> Request Method: GET
> Request URL: http://**\*.com/panel/schedevendorcomplet... | 2013/04/06 | [
"https://Stackoverflow.com/questions/15854916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2252933/"
] | Use Java's Calendar: (since my beloved Date is deprecated)
[Calendar API](http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html)
Try something like:
```
Calendar c = Calendar.getInstance();
c.setTimeInMillis(1365228375*1000);
System.out.print(c.toString()); - just to demonstrate the API has lots of i... | There isn't really an "Android" time stamp per se. [PHP:time()](http://php.net/manual/en/function.time.php) returns a unix time stamp measured in seconds from epoch GMT/UTC. If you want to create a human readable time stamp such as `January 1 1970 00:00:00 GMT` you can use Java's Calender but I would recommend using [J... |
27,740,044 | I am installing cffi package for cryptography and Jasmin installation.
I did some research before posting question, so I found following option but which is seems not working:
System
------
>
> Mac OSx 10.9.5
>
>
> python2.7
>
>
>
Error
-----
```
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
... | 2015/01/02 | [
"https://Stackoverflow.com/questions/27740044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1694106/"
] | In your terminal try and run:
```
xcode-select --install
```
After that try installing the package again.
By default, XCode installs itself as the IDE and does not set up the environment for the use by command line tools; for example, the `/usr/include` folder will be missing.
Running the above command will ins... | Install CLI development toolchain with
```
$ xcode-select --install
```
If you have a broken pkg-config, unlink it with following command as mentioned in comments.
```
$ brew unlink pkg-config
```
Install libffi package
```
$ brew install pkg-config libffi
```
and then install cffi
```
$ pip install cffi
```... |
27,740,044 | I am installing cffi package for cryptography and Jasmin installation.
I did some research before posting question, so I found following option but which is seems not working:
System
------
>
> Mac OSx 10.9.5
>
>
> python2.7
>
>
>
Error
-----
```
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
... | 2015/01/02 | [
"https://Stackoverflow.com/questions/27740044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1694106/"
] | In your terminal try and run:
```
xcode-select --install
```
After that try installing the package again.
By default, XCode installs itself as the IDE and does not set up the environment for the use by command line tools; for example, the `/usr/include` folder will be missing.
Running the above command will ins... | Running the below command in terminal took care of my issue.
xcode-select --install |
27,740,044 | I am installing cffi package for cryptography and Jasmin installation.
I did some research before posting question, so I found following option but which is seems not working:
System
------
>
> Mac OSx 10.9.5
>
>
> python2.7
>
>
>
Error
-----
```
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
... | 2015/01/02 | [
"https://Stackoverflow.com/questions/27740044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1694106/"
] | Install CLI development toolchain with
```
$ xcode-select --install
```
If you have a broken pkg-config, unlink it with following command as mentioned in comments.
```
$ brew unlink pkg-config
```
Install libffi package
```
$ brew install pkg-config libffi
```
and then install cffi
```
$ pip install cffi
```... | Running the below command in terminal took care of my issue.
xcode-select --install |
47,275,478 | I'm using azure service bus queues in my application and here my question is, is there a way how to check the message queue is empty so that I can shutdown my containers and vms to save cost. If there is way to get that please let me know, preferably in python.
Thanks | 2017/11/13 | [
"https://Stackoverflow.com/questions/47275478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6918471/"
] | For this, you can use [`Azure Service Bus Python SDK`](https://pypi.python.org/pypi/azure-servicebus). What you would need to do is get the properties of a queue using `get_queue` method that will return an object of type `Queue`. This object exposes the total number of messages through `message_count` property. Please... | You could check the length of the messages returned from [peek\_messages](https://azuresdkdocs.blob.core.windows.net/$web/python/azure-servicebus/latest/azure.servicebus.html?highlight=peek_messages#azure.servicebus.ServiceBusReceiver.peek_messages) method on the class `azure.servicebus.ServiceBusReceiver`
```
with se... |
40,130,468 | I am using Alamofire for the HTTP networking in my app. But in my api which is written in python have an header key for getting request, if there is a key then only give response. Now I want to use that header key in my iOS app with Alamofire, I am not getting it how to implement. Below is my code of normal without any... | 2016/10/19 | [
"https://Stackoverflow.com/questions/40130468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5088930/"
] | This should work
```
let headers = [
"appkey": "test"
]
Alamofire.request(.GET, "http://name/user_data/\(userName)@someURL.com", parameters: nil, encoding: .URL, headers: headers).responseJSON {
response in
//handle response
}
``` | ```
let headers: HTTPHeaders = [
"Accept": "application/json",
"appkey": "test"
]
Alamofire.request("http://name/user_data/\(userName)@someURL.com", headers: headers).responseJSON { response in
print(response.request) // original URL request
print(response.response) // URL response
print(response.... |
49,997,303 | Write a program using Python 3.x
Write the scipt that will read "input.txt" and print the first 5 lines of the file input.txt that consists of the single odd number to stdout The file may contain lines having numeric and non numeric data your script should ignore all the lines that contain anything except single odd i... | 2018/04/24 | [
"https://Stackoverflow.com/questions/49997303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8064377/"
] | **Put your admin link like this :**
as `Admin` is not your default `controller` and you not set your route for admin
Put your `admin` link like this
```
<li class="nav-item">
<a class="nav-link" href="<?php echo base_url('admin/index'); ?>">Admin</a>
</li>
```
but if you want to do like this :
```
<li class="... | Please use parent construct and after you can do your way.
```
public function __construct() {
parent :: __construct();
$this->load->model(array('restaurants_m', 'categories_m', 'cities_m', 'customers_m', 'states_m', 'orders_m', 'delivery_boys_m'));
$this->load->library(array('ema... |
55,168,955 | On Mac OS 10.14 (Mojave) I used:
```
pip install -U pytest
```
to install pytest. I got a permission denied error trying to install the packages to `/Users/nagen/Library/Python/2.7`
I tried
```
sudo pip install -U pytest
```
This time it installed successfully
But, despite adding the full path, the terminal doe... | 2019/03/14 | [
"https://Stackoverflow.com/questions/55168955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11204687/"
] | I think the best option might be to use a python virtual env. <https://packaging.python.org/guides/installing-using-pip-and-virtualenv/> is a good starting point
```
> virtualenv env
> source env/bin/activate
> pip install pytest
> pytest
```
This will avoid pathing and permissions issues and keep your environment c... | I would **strongly** recommend using [homebrew](https://brew.sh/). This is the **best** dev tool there is for mac users and I never install things without it.
To install it run the following in terminal:
```
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```
Now t... |
15,034,151 | I have a directory /a/b/c that has files and subdirectories.
I need to copy the /a/b/c/\* in the /x/y/z directory. What python methods can I use?
I tried `shutil.copytree("a/b/c", "/x/y/z")`, but python tries to create /x/y/z and raises an `error "Directory exists"`. | 2013/02/22 | [
"https://Stackoverflow.com/questions/15034151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | I found this code working which is part of the standard library:
```
from distutils.dir_util import copy_tree
# copy subdirectory example
from_directory = "/a/b/c"
to_directory = "/x/y/z"
copy_tree(from_directory, to_directory)
```
Reference:
* Python 2: <https://docs.python.org/2/distutils/apiref.html#distutils.... | You can also use glob2 to recursively collect all paths (using \*\* subfolders wildcard) and then use shutil.copyfile, saving the paths
glob2 link: <https://code.activestate.com/pypm/glob2/> |
15,034,151 | I have a directory /a/b/c that has files and subdirectories.
I need to copy the /a/b/c/\* in the /x/y/z directory. What python methods can I use?
I tried `shutil.copytree("a/b/c", "/x/y/z")`, but python tries to create /x/y/z and raises an `error "Directory exists"`. | 2013/02/22 | [
"https://Stackoverflow.com/questions/15034151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | I found this code working which is part of the standard library:
```
from distutils.dir_util import copy_tree
# copy subdirectory example
from_directory = "/a/b/c"
to_directory = "/x/y/z"
copy_tree(from_directory, to_directory)
```
Reference:
* Python 2: <https://docs.python.org/2/distutils/apiref.html#distutils.... | The python libs are obsolete with this function. I've done one that works correctly:
```
import os
import shutil
def copydirectorykut(src, dst):
os.chdir(dst)
list=os.listdir(src)
nom= src+'.txt'
fitx= open(nom, 'w')
for item in list:
fitx.write("%s\n" % item)
fitx.close()
f = o... |
15,034,151 | I have a directory /a/b/c that has files and subdirectories.
I need to copy the /a/b/c/\* in the /x/y/z directory. What python methods can I use?
I tried `shutil.copytree("a/b/c", "/x/y/z")`, but python tries to create /x/y/z and raises an `error "Directory exists"`. | 2013/02/22 | [
"https://Stackoverflow.com/questions/15034151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | I found this code working which is part of the standard library:
```
from distutils.dir_util import copy_tree
# copy subdirectory example
from_directory = "/a/b/c"
to_directory = "/x/y/z"
copy_tree(from_directory, to_directory)
```
Reference:
* Python 2: <https://docs.python.org/2/distutils/apiref.html#distutils.... | ```
from subprocess import call
def cp_dir(source, target):
call(['cp', '-a', source, target]) # Linux
cp_dir('/a/b/c/', '/x/y/z/')
```
It works for me. Basically, it executes shell command **cp**. |
15,034,151 | I have a directory /a/b/c that has files and subdirectories.
I need to copy the /a/b/c/\* in the /x/y/z directory. What python methods can I use?
I tried `shutil.copytree("a/b/c", "/x/y/z")`, but python tries to create /x/y/z and raises an `error "Directory exists"`. | 2013/02/22 | [
"https://Stackoverflow.com/questions/15034151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | You can also use glob2 to recursively collect all paths (using \*\* subfolders wildcard) and then use shutil.copyfile, saving the paths
glob2 link: <https://code.activestate.com/pypm/glob2/> | The python libs are obsolete with this function. I've done one that works correctly:
```
import os
import shutil
def copydirectorykut(src, dst):
os.chdir(dst)
list=os.listdir(src)
nom= src+'.txt'
fitx= open(nom, 'w')
for item in list:
fitx.write("%s\n" % item)
fitx.close()
f = o... |
15,034,151 | I have a directory /a/b/c that has files and subdirectories.
I need to copy the /a/b/c/\* in the /x/y/z directory. What python methods can I use?
I tried `shutil.copytree("a/b/c", "/x/y/z")`, but python tries to create /x/y/z and raises an `error "Directory exists"`. | 2013/02/22 | [
"https://Stackoverflow.com/questions/15034151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | You can also use glob2 to recursively collect all paths (using \*\* subfolders wildcard) and then use shutil.copyfile, saving the paths
glob2 link: <https://code.activestate.com/pypm/glob2/> | ```
from subprocess import call
def cp_dir(source, target):
call(['cp', '-a', source, target]) # Linux
cp_dir('/a/b/c/', '/x/y/z/')
```
It works for me. Basically, it executes shell command **cp**. |
15,034,151 | I have a directory /a/b/c that has files and subdirectories.
I need to copy the /a/b/c/\* in the /x/y/z directory. What python methods can I use?
I tried `shutil.copytree("a/b/c", "/x/y/z")`, but python tries to create /x/y/z and raises an `error "Directory exists"`. | 2013/02/22 | [
"https://Stackoverflow.com/questions/15034151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | ```
from subprocess import call
def cp_dir(source, target):
call(['cp', '-a', source, target]) # Linux
cp_dir('/a/b/c/', '/x/y/z/')
```
It works for me. Basically, it executes shell command **cp**. | The python libs are obsolete with this function. I've done one that works correctly:
```
import os
import shutil
def copydirectorykut(src, dst):
os.chdir(dst)
list=os.listdir(src)
nom= src+'.txt'
fitx= open(nom, 'w')
for item in list:
fitx.write("%s\n" % item)
fitx.close()
f = o... |
59,296,151 | I'm writing a python script that uses a model to predict a large number of values by groupID, where **efficiency is important** (N on the order of 10^8). I initialize a results matrix and am trying to sequentially update a running sum of values in the results matrix.
Trying to be efficient, in my current method I use ... | 2019/12/12 | [
"https://Stackoverflow.com/questions/59296151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11918892/"
] | The problem is that your in your language dates use the slash separator, which makes Blazor think you're trying to access a different route.
Whenever sending dates as a URL parameter they need to be in invariant culture and use dashes.
```cs
NavigationManager.NavigateTo("routeTest/"+numberToSend+"/"+dateToSend.ToStr... | As you've identified, the DateTime in the URL is affecting the routing due to the slashes.
Send the `DateTime` in ISO8601 format `yyyy-MM-ddTHH:mm:ss`.
You could use:
```
dateToSend.ToString("s", System.Globalization.CultureInfo.InvariantCulture)
```
where the format specifier `s` is known as the [Sortable date/ti... |
59,296,151 | I'm writing a python script that uses a model to predict a large number of values by groupID, where **efficiency is important** (N on the order of 10^8). I initialize a results matrix and am trying to sequentially update a running sum of values in the results matrix.
Trying to be efficient, in my current method I use ... | 2019/12/12 | [
"https://Stackoverflow.com/questions/59296151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11918892/"
] | The problem is that your in your language dates use the slash separator, which makes Blazor think you're trying to access a different route.
Whenever sending dates as a URL parameter they need to be in invariant culture and use dashes.
```cs
NavigationManager.NavigateTo("routeTest/"+numberToSend+"/"+dateToSend.ToStr... | This can solve your issue:
```
@code{
int numberToSend = 123;
string dateToSend = DateTime.Now.ToString("yyyy-MM-dd");
private void Naviagte()
{
NavigationManager.NavigateTo("routeTest/" + numberToSend + "/" + dateToSend);
}
}
``` |
62,061,258 | I am trying to create a view that handles the email confirmation but i keep on getting an error, your help is highly appreciated
My views.py
```
import re
from django.contrib.auth import login, logout, authenticate
from django.shortcuts import render, HttpResponseRedirect, Http404
# Create your views here.
from .for... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62061258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13633361/"
] | Use [`justify`](https://stackoverflow.com/a/44559180/2901002) with `DataFrame` constructor:
```
arr = justify(data_df.to_numpy(), invalid_val=np.nan,axis=0)
df = pd.DataFrame(arr, columns=data_df.columns, index=data_df.index)
print(df)
8 16 20 24
0 4.0 0.0 1.0 6.0
0 7.0 2.0 5.0 8.0
0 NaN 3.0 NaN... | This is not that pretty - but with help of `numpy` you can fairly easy get a numpy array with your desired result.
```
import numpy
def shifted_column(values):
none_nan_values = values[ ~np.isnan(values) ]
nan_row = np.zeros(values.shape)
nan_row[:] = np.nan
nan_row[:none_nan_values.size] = none_nan_... |
3,387,663 | HI all
I am trying to use SWIG to export C++ code to Python.
The C sample I read on the web site does work but I have problem with C++ code.
Here are the lines I call
```
swig -c++ -python SWIG_TEST.i
g++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I/usr/include/python2.4/
gcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -... | 2010/08/02 | [
"https://Stackoverflow.com/questions/3387663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/245416/"
] | It looks like you aren't linking to the Python runtime library. Something like adding `-lpython24` to your gcc line. (I don't have a Linux system handy at the moment). | you might try building the shared library using `gcc`
```
g++ -shared SWIG_TEST.o SWIG_TEST_wrap.o -o _SWIG_TEST.so
```
rather than using `ld` directly. |
3,387,663 | HI all
I am trying to use SWIG to export C++ code to Python.
The C sample I read on the web site does work but I have problem with C++ code.
Here are the lines I call
```
swig -c++ -python SWIG_TEST.i
g++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I/usr/include/python2.4/
gcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -... | 2010/08/02 | [
"https://Stackoverflow.com/questions/3387663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/245416/"
] | It looks like you aren't linking to the Python runtime library. Something like adding `-lpython24` to your gcc line. (I don't have a Linux system handy at the moment). | As Mark said, it's a problem linking to the python library. A nice way to get hints as to just which flags you need to successfully link can be gotten by running `python-config --ldflags`. In fact, a particularly painless way of compiling your test is the following:
```
swig -c++ -python SWIG_TEST.i
g++ -c `python-con... |
54,856,829 | In TensorFlow <2 the training function for a DDPG actor could be concisely implemented using `tf.keras.backend.function` as follows:
```
critic_output = self.critic([self.actor(state_input), state_input])
actor_updates = self.optimizer_actor.get_updates(params=self.actor.trainable_weights,
... | 2019/02/24 | [
"https://Stackoverflow.com/questions/54856829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552418/"
] | I found two ways to solve it:
###Using data attribute
Get the max number of pages in the template, assign it to a data attribute, and access it in the scripts. Then check current page against total page numbers, and set disabled states to the load more button when it reaches the last page.
PHP/HTML:
```
<ul id="aja... | The problem appears to be an invalid query to that endpoint so the `success: function()` is never being run in this circumstance.
### Add to All API Errors
You could add the same functionality for all errors like this...
```
error: function(jqXHR, textStatus, errorThrown) {
loadMoreButton.remove();
...... |
43,819,092 | I have installed ngram using pip install ngram. While I am running the following code
```
from ngram import NGram
c=NGram.compare('cereal_crop','cereals')
print c
```
I get the error `ImportError: cannot import name NGram`
Screenshot for it: [](ht... | 2017/05/06 | [
"https://Stackoverflow.com/questions/43819092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4451870/"
] | Your Python script is named `ngram.py`, so it defines a module named `ngram`. When Python runs `from ngram import NGram`, Python ends up looking in your script for something named `NGram`, not in the `ngram` module you have installed.
Try changing the name of your script to something else, for example `ngram_test.py`. | try like this:
```
import ngram
c = ngram.NGram.compare('cereal_crop','cereals')
print c
``` |
45,006,190 | ConnectionRefusedError error showing when register user,
basic information added on database but password field was blank and other database fields submitted please find the following error and our class code,
**Class**
class ProfessionalRegistrationSerializer(serializers.HyperlinkedModelSerializer):
```
password =... | 2017/07/10 | [
"https://Stackoverflow.com/questions/45006190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7225424/"
] | I was getting the same error and it may be due to email verification. I add following code in my setting.py file and now authentication working perfectly
```
ACCOUNT_EMAIL_VERIFICATION = 'none'
ACCOUNT_AUTHENTICATION_METHOD = 'username'
ACCOUNT_EMAIL_REQUIRED = False
``` | You perform a call to a remote server that you can't reach / isn't configured / isn't running.
It's not an issue with Django or DRF. |
27,259,112 | I want to test uploaded python programs with the `unittest` module on a django based web site and give a useful feedback to the student. I created some helper function to get statistics (how many failures and errors) and messages.
```
def suite(*test_cases):
suites = [unittest.makeSuite(case) for case in test_cas... | 2014/12/02 | [
"https://Stackoverflow.com/questions/27259112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813946/"
] | If you have a `TestCase` like:
```
class ExampleTestCase(unittest.TestCase):
def test_example(self):
"""If this fails, it may not be your fault.
Try hacking the integer cache. Evil laugh."""
self.assertEqual(3, 4)
```
You can later, in your `testcase_statistics_and_messages` function, get... | Here is one possible solution - override the specific assertion methods that you're using (`assertEqual`, etc, hopefully not too many) and store the variables in a JSON string as message:
```
import json
import unittest
class ExampleTestCase(unittest.TestCase):
longMessage = False
def assertEqual(self, first... |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | The accepted answer is close but incorrect if you're trying to take % difference from left to right.
You should get the following percent difference:
`1,2,3,5,7` --> `100%, 50%, 66.66%, 40%`
check for yourself: <https://www.calculatorsoup.com/calculators/algebra/percent-change-calculator.php>
Going by what Josmoor9... | 1. Combine all your arrays.
2. Then make a data frame from them.
```
df = pd.df(data=array you made)
```
3. Use the `pct_change()` function on dataframe. It will calculate the % change for all rows in dataframe. |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | I suggest to simply shift the array. The computation basically becomes a one-liner.
```
import numpy as np
arr = np.array(
[
[1, 2, 3, 5, 7],
[1, 4, 5, 6, 7],
[5, 8, 9, 10, 32],
[3, 5, 6, 13, 11],
]
)
# Percentage change from row to row
pct_chg_row = arr[1:] / arr[:-1] - 1
[[... | The accepted answer is close but incorrect if you're trying to take % difference from left to right.
You should get the following percent difference:
`1,2,3,5,7` --> `100%, 50%, 66.66%, 40%`
check for yourself: <https://www.calculatorsoup.com/calculators/algebra/percent-change-calculator.php>
Going by what Josmoor9... |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | I suggest to simply shift the array. The computation basically becomes a one-liner.
```
import numpy as np
arr = np.array(
[
[1, 2, 3, 5, 7],
[1, 4, 5, 6, 7],
[5, 8, 9, 10, 32],
[3, 5, 6, 13, 11],
]
)
# Percentage change from row to row
pct_chg_row = arr[1:] / arr[:-1] - 1
[[... | ```
import numpy as np
a = np.array([[1,2,3,5,7],
[1,4,5,6,7],
[5,8,9,10,32],
[3,5,6,13,11]])
np.array([(i[:-1]/i[1:]) for i in a])
``` |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | I know you have asked this question with Numpy in mind and got answers above:
```
import numpy as np
np.diff(a) / a[:,1:]
```
I attempt to solve this with Pandas. For those who would have the same question but using Pandas instead of Numpy
```
import pandas as pd
data = [[1,2,3,4,5],
[1,4,5,6,7],
... | 1. Combine all your arrays.
2. Then make a data frame from them.
```
df = pd.df(data=array you made)
```
3. Use the `pct_change()` function on dataframe. It will calculate the % change for all rows in dataframe. |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | If I understand correctly, that you're trying to find percent change in each row, then you can do:
```
>>> np.diff(a) / a[:,1:] * 100
```
Which gives you:
```
array([[ 50. , 33.33333333, 40. , 28.57142857],
[ 75. , 20. , 16.66666667, 14.28571429],
[ 37.5 , 11.... | The accepted answer is close but incorrect if you're trying to take % difference from left to right.
You should get the following percent difference:
`1,2,3,5,7` --> `100%, 50%, 66.66%, 40%`
check for yourself: <https://www.calculatorsoup.com/calculators/algebra/percent-change-calculator.php>
Going by what Josmoor9... |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | If I understand correctly, that you're trying to find percent change in each row, then you can do:
```
>>> np.diff(a) / a[:,1:] * 100
```
Which gives you:
```
array([[ 50. , 33.33333333, 40. , 28.57142857],
[ 75. , 20. , 16.66666667, 14.28571429],
[ 37.5 , 11.... | I know you have asked this question with Numpy in mind and got answers above:
```
import numpy as np
np.diff(a) / a[:,1:]
```
I attempt to solve this with Pandas. For those who would have the same question but using Pandas instead of Numpy
```
import pandas as pd
data = [[1,2,3,4,5],
[1,4,5,6,7],
... |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | If I understand correctly, that you're trying to find percent change in each row, then you can do:
```
>>> np.diff(a) / a[:,1:] * 100
```
Which gives you:
```
array([[ 50. , 33.33333333, 40. , 28.57142857],
[ 75. , 20. , 16.66666667, 14.28571429],
[ 37.5 , 11.... | ```
import numpy as np
a = np.array([[1,2,3,5,7],
[1,4,5,6,7],
[5,8,9,10,32],
[3,5,6,13,11]])
np.array([(i[:-1]/i[1:]) for i in a])
``` |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | I know you have asked this question with Numpy in mind and got answers above:
```
import numpy as np
np.diff(a) / a[:,1:]
```
I attempt to solve this with Pandas. For those who would have the same question but using Pandas instead of Numpy
```
import pandas as pd
data = [[1,2,3,4,5],
[1,4,5,6,7],
... | The accepted answer is close but incorrect if you're trying to take % difference from left to right.
You should get the following percent difference:
`1,2,3,5,7` --> `100%, 50%, 66.66%, 40%`
check for yourself: <https://www.calculatorsoup.com/calculators/algebra/percent-change-calculator.php>
Going by what Josmoor9... |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | I know you have asked this question with Numpy in mind and got answers above:
```
import numpy as np
np.diff(a) / a[:,1:]
```
I attempt to solve this with Pandas. For those who would have the same question but using Pandas instead of Numpy
```
import pandas as pd
data = [[1,2,3,4,5],
[1,4,5,6,7],
... | ```
import numpy as np
a = np.array([[1,2,3,5,7],
[1,4,5,6,7],
[5,8,9,10,32],
[3,5,6,13,11]])
np.array([(i[:-1]/i[1:]) for i in a])
``` |
53,067,695 | I'm writing a function to find the percentage change using Numpy and function calls. So far what I got is:
```
def change(a,b):
answer = (np.subtract(a[b+1], a[b])) / a[b+1] * 100
return answer
print(change(a,0))
```
"a" is the array I have made and b will be the index/numbers I am trying to calculate.
For exa... | 2018/10/30 | [
"https://Stackoverflow.com/questions/53067695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10541940/"
] | If I understand correctly, that you're trying to find percent change in each row, then you can do:
```
>>> np.diff(a) / a[:,1:] * 100
```
Which gives you:
```
array([[ 50. , 33.33333333, 40. , 28.57142857],
[ 75. , 20. , 16.66666667, 14.28571429],
[ 37.5 , 11.... | I suggest to simply shift the array. The computation basically becomes a one-liner.
```
import numpy as np
arr = np.array(
[
[1, 2, 3, 5, 7],
[1, 4, 5, 6, 7],
[5, 8, 9, 10, 32],
[3, 5, 6, 13, 11],
]
)
# Percentage change from row to row
pct_chg_row = arr[1:] / arr[:-1] - 1
[[... |
28,323,435 | I'm trying to use [`logging`'s `SMTPHandler`](https://docs.python.org/3/library/logging.handlers.html#smtphandler). From Python 3.3 on, you can specify a `timeout` keyword argument. If you add that argument in older versions, it fails. To get around this, I used the following:
```
import sys
if sys.version_info >= (3... | 2015/02/04 | [
"https://Stackoverflow.com/questions/28323435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/810870/"
] | Rather than test for the version, use exception handling:
```
try:
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT, timeout=20.0)
except TypeError:
# Python < 3.3, no timeout parameter
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT)
```
Now you can conceivably... | Here is another slightly different approach:
```
from logging.handlers import SMTPHandler
import sys
if sys.version_info >= (3, 3):
# patch in timeout where available
from functools import partial
SMTPHandler = partial(SMTPHandler, timeout=20.0)
```
Now in the rest of the code you can just use:
```
smt... |
28,323,435 | I'm trying to use [`logging`'s `SMTPHandler`](https://docs.python.org/3/library/logging.handlers.html#smtphandler). From Python 3.3 on, you can specify a `timeout` keyword argument. If you add that argument in older versions, it fails. To get around this, I used the following:
```
import sys
if sys.version_info >= (3... | 2015/02/04 | [
"https://Stackoverflow.com/questions/28323435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/810870/"
] | I would do something like this:
```
kargs = {}
if sys.version_info >= (3, 3):
kargs['timeout'] = 20.0
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT, **kargs)
```
**UPDATE**: The idea of `try/catch` of other answers is nice, but it assumes that it fails because of the `timeout` argument. ... | Here is another slightly different approach:
```
from logging.handlers import SMTPHandler
import sys
if sys.version_info >= (3, 3):
# patch in timeout where available
from functools import partial
SMTPHandler = partial(SMTPHandler, timeout=20.0)
```
Now in the rest of the code you can just use:
```
smt... |
28,323,435 | I'm trying to use [`logging`'s `SMTPHandler`](https://docs.python.org/3/library/logging.handlers.html#smtphandler). From Python 3.3 on, you can specify a `timeout` keyword argument. If you add that argument in older versions, it fails. To get around this, I used the following:
```
import sys
if sys.version_info >= (3... | 2015/02/04 | [
"https://Stackoverflow.com/questions/28323435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/810870/"
] | Rather than test for the version, use exception handling:
```
try:
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT, timeout=20.0)
except TypeError:
# Python < 3.3, no timeout parameter
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT)
```
Now you can conceivably... | I would do something like this:
```
kargs = {}
if sys.version_info >= (3, 3):
kargs['timeout'] = 20.0
smtp_handler = SMTPHandler(SMTP_SERVER, FROM_EMAIL, TO_EMAIL, SUBJECT, **kargs)
```
**UPDATE**: The idea of `try/catch` of other answers is nice, but it assumes that it fails because of the `timeout` argument. ... |
5,763,608 | I'm trying to start a script on bootup on a Ubuntu Server 10.10 machine.
The relevant parts of my rc.local look like this:
```
/usr/local/bin/python3.2 "/root/Advantage/main.py" >> /startuplogfile
exit 0
```
If I run ./rc.local from /etc everything works just fine and it writes the following into /startuplogfile:
... | 2011/04/23 | [
"https://Stackoverflow.com/questions/5763608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/317163/"
] | You can't depend on `argv[0]` containing something specific. Sometimes you'll get the full path, sometimes only the program name, sometimes something else entirely.
It depends on how the code was invoked. | As you’ve noticed, `argv[0]` can (but doesn’t always) contain the full path of your executable. If you want the file name only, one solution is:
```
#include <libgen.h>
const char *proName = basename(argv[0]);
```
---
As noted by Mat, `argv[0]` is not always reliable — although it should usually be. It depends on ... |
6,730,735 | Last weekend (16. July 2011) our mercurial packages auto-updated to the newest 1.9 mercurial binaries using the mercurial-stable ppa on a ubuntu lucid.
Now pulling from repository over SSH no longer works.
Following error is displayed:
```
remote: Traceback (most recent call last):
remote: File "/usr/share/mercuria... | 2011/07/18 | [
"https://Stackoverflow.com/questions/6730735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/619789/"
] | Ok, found a (workaround) solution by editing a python script.
Edit the script /usr/share/mercurial-server/hg-ssh
At the end of the script replace the line:
```
dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
```
with the line:
```
dispatch.dispatch(dispatch.request(['-R', repo, 'serve', '--stdio']))
```
Repl... | More recent versions of mercurial-server are updated to support the API changes, but **may require** the `refresh-auth` script to be rerun for installations being upgraded. |
56,145,426 | I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found".
I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name.
I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56145426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39242/"
] | You can use Treemap to contain the duplicity and total sum corresponding to your input String. Also using treemap, your output will be in sorted format if that you require.
```java
public static void main(String[] args) {
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String... | You can use Map interface.
Use your String array "names" as keys. Write a for loop for it and inside:
If your map contains the key, get the value and sum with the new value.
PS: Couldn't write code right now, I can update it later. |
56,145,426 | I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found".
I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name.
I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56145426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39242/"
] | I already suggested it in the comments: You can use a map to count all the values.
Here is an **intentionally verbose** example (to make clear what happens):
```
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String, Integer> totals = new HashMap<String, Integer>(); ... | You can use Map interface.
Use your String array "names" as keys. Write a for loop for it and inside:
If your map contains the key, get the value and sum with the new value.
PS: Couldn't write code right now, I can update it later. |
56,145,426 | I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found".
I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name.
I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56145426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39242/"
] | Here is a working example:
```
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String, Integer> occurrences = new HashMap<>();
for(int i ... | You can use Map interface.
Use your String array "names" as keys. Write a for loop for it and inside:
If your map contains the key, get the value and sum with the new value.
PS: Couldn't write code right now, I can update it later. |
56,145,426 | I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found".
I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name.
I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56145426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39242/"
] | I already suggested it in the comments: You can use a map to count all the values.
Here is an **intentionally verbose** example (to make clear what happens):
```
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String, Integer> totals = new HashMap<String, Integer>(); ... | You can use Treemap to contain the duplicity and total sum corresponding to your input String. Also using treemap, your output will be in sorted format if that you require.
```java
public static void main(String[] args) {
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String... |
56,145,426 | I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found".
I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name.
I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56145426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39242/"
] | You can use Treemap to contain the duplicity and total sum corresponding to your input String. Also using treemap, your output will be in sorted format if that you require.
```java
public static void main(String[] args) {
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String... | Using Map will suffice your requirement. It could be done as below
String[] names = {"a", "b", "a", "a", "c", "b"};
Integer[] numbers = {5, 2, 3, 1, 2, 1};
Map expectedOut = new HashMap();
```
for (int i = 0; i < names.length; i++) {
if (expectedOut.containsKey(names[i]))
expectedOut.put(names[i], expectedOut... |
56,145,426 | I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found".
I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name.
I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18... | 2019/05/15 | [
"https://Stackoverflow.com/questions/56145426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39242/"
] | I already suggested it in the comments: You can use a map to count all the values.
Here is an **intentionally verbose** example (to make clear what happens):
```
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String, Integer> totals = new HashMap<String, Integer>(); ... | Here is a working example:
```
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String[] names = {"a","b","a","a","c","b"};
Integer[] numbers = {5,2,3,1,2,1};
Map<String, Integer> occurrences = new HashMap<>();
for(int i ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.