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,169,443
Currently, I'm facing an issue with uploading (using python) EMOJI data to the BIG QUERY This is sample code which I'm trying to upload to BQ: ``` {"emojiCharts":{"emoji_icon":"\ud83d\udc4d","repost": 4, "doc": 4, "engagement": 0, "reach": 0, "impression": 0}} {"emojiCharts":{"emoji_icon":"\ud83d\udc49","repost": ...
2018/09/04
[ "https://Stackoverflow.com/questions/52169443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
As user 'numeral' mentions in their comment: > > Check out [charbase.com/1f618-unicode-face-throwing-a-kiss](http://charbase.com/1f618-unicode-face-throwing-a-kiss) What you want is to convert the javascript escape characters to actual unicode data. > > > , you need to change the encoding of the emojis for them t...
Python does not support "surrogate characters" representation which is composed of multiple UTF-16 characters and some emojis (over `0xFFFF`) use them. For example, can be represented by `\U0001f3e6` (UTF-32) in Python and some languages uses `\ud83c\udfe6`. For those values are less than `0xFFFF`, python and other lan...
68,633,577
I am a beginner in python and I have started with web scraping, I want to extract data from a tourist site I need the names of the hotels, the arrangements available in each hotel and the price but I got stuck in the list of arrangements, each hotel can have several arrangements but it doesn't work and I don't know why...
2021/08/03
[ "https://Stackoverflow.com/questions/68633577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16571797/" ]
You are assigning `0` to `stringArray`, `booleanArray` and `numberArray`. A `0` isn't an array, so you can't add values to it like that. ([Assigning values to a primitive type is a noop](https://stackoverflow.com/a/5201148).) Assign an array to those values and use `.push()` on them to add values to those arrays. (Usi...
Change the values of zero to an array like this: ``` let sortedData = { stringArray: [], booleanArray: [], numberArray: [], } ``` ``` // set value on array item // || // \/ sortedData.stringArray[i] === 'something' ```
68,633,577
I am a beginner in python and I have started with web scraping, I want to extract data from a tourist site I need the names of the hotels, the arrangements available in each hotel and the price but I got stuck in the list of arrangements, each hotel can have several arrangements but it doesn't work and I don't know why...
2021/08/03
[ "https://Stackoverflow.com/questions/68633577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16571797/" ]
You can do it using [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce): ```js let data = [ 538, 922, "725", false, 733, 170, 294, "336", false, "538", 79, 390, true, "816", "50", 920, "845", "728", "133", "468", false, true, 520, 747, false, ...
Change the values of zero to an array like this: ``` let sortedData = { stringArray: [], booleanArray: [], numberArray: [], } ``` ``` // set value on array item // || // \/ sortedData.stringArray[i] === 'something' ```
68,633,577
I am a beginner in python and I have started with web scraping, I want to extract data from a tourist site I need the names of the hotels, the arrangements available in each hotel and the price but I got stuck in the list of arrangements, each hotel can have several arrangements but it doesn't work and I don't know why...
2021/08/03
[ "https://Stackoverflow.com/questions/68633577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16571797/" ]
explainations at the code. ```js // data is array with mixed data type let data = [ 123, 12.3, "123", [1,2,3], {'1':[2,3]}, true, false, null, undefined ]; // sfxName : extra suffix for 'grpName' // grpName : type + sfxName // the output key will be > numberArray, booleanArray etc... let sorted = {}, sfxName = ...
Change the values of zero to an array like this: ``` let sortedData = { stringArray: [], booleanArray: [], numberArray: [], } ``` ``` // set value on array item // || // \/ sortedData.stringArray[i] === 'something' ```
68,633,577
I am a beginner in python and I have started with web scraping, I want to extract data from a tourist site I need the names of the hotels, the arrangements available in each hotel and the price but I got stuck in the list of arrangements, each hotel can have several arrangements but it doesn't work and I don't know why...
2021/08/03
[ "https://Stackoverflow.com/questions/68633577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16571797/" ]
You are assigning `0` to `stringArray`, `booleanArray` and `numberArray`. A `0` isn't an array, so you can't add values to it like that. ([Assigning values to a primitive type is a noop](https://stackoverflow.com/a/5201148).) Assign an array to those values and use `.push()` on them to add values to those arrays. (Usi...
You can do it using [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce): ```js let data = [ 538, 922, "725", false, 733, 170, 294, "336", false, "538", 79, 390, true, "816", "50", 920, "845", "728", "133", "468", false, true, 520, 747, false, ...
68,633,577
I am a beginner in python and I have started with web scraping, I want to extract data from a tourist site I need the names of the hotels, the arrangements available in each hotel and the price but I got stuck in the list of arrangements, each hotel can have several arrangements but it doesn't work and I don't know why...
2021/08/03
[ "https://Stackoverflow.com/questions/68633577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16571797/" ]
You are assigning `0` to `stringArray`, `booleanArray` and `numberArray`. A `0` isn't an array, so you can't add values to it like that. ([Assigning values to a primitive type is a noop](https://stackoverflow.com/a/5201148).) Assign an array to those values and use `.push()` on them to add values to those arrays. (Usi...
explainations at the code. ```js // data is array with mixed data type let data = [ 123, 12.3, "123", [1,2,3], {'1':[2,3]}, true, false, null, undefined ]; // sfxName : extra suffix for 'grpName' // grpName : type + sfxName // the output key will be > numberArray, booleanArray etc... let sorted = {}, sfxName = ...
15,021,877
I am developing a GUI with PyQt, to perform visual analysis of the data collected during some experiments. The GUI asks the user to indicate the directory where the data to be analyzed is located: ``` class ExperimentAnalyzer(QtGui.QMainWindow): ## other stuff here def loadExperiment(self): directory ...
2013/02/22
[ "https://Stackoverflow.com/questions/15021877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1759574/" ]
You can do in this way: ``` $(function(){ $('.yourelem, .targetDiv').click(function(ev){ $('.targetDiv').slideDown('fast'); ev.stopPropagation(); }); $(document).click(function(){ $('.targetDiv').slideUp('fast'); }); }); ``` [See the action in jsbin](http://jsbin.com/ayuhol/1/edit) -------------...
Try this : HTML ``` <a id="show" href="#">show</a> <div class="test" style="display: none;"> hey </div> ``` JS ``` $('a#show').click(function(event) { event.stopPropagation(); $('.test').toggle(); }); $('html').click(function() { $('.test').hide(); }); ```
15,021,877
I am developing a GUI with PyQt, to perform visual analysis of the data collected during some experiments. The GUI asks the user to indicate the directory where the data to be analyzed is located: ``` class ExperimentAnalyzer(QtGui.QMainWindow): ## other stuff here def loadExperiment(self): directory ...
2013/02/22
[ "https://Stackoverflow.com/questions/15021877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1759574/" ]
You can do in this way: ``` $(function(){ $('.yourelem, .targetDiv').click(function(ev){ $('.targetDiv').slideDown('fast'); ev.stopPropagation(); }); $(document).click(function(){ $('.targetDiv').slideUp('fast'); }); }); ``` [See the action in jsbin](http://jsbin.com/ayuhol/1/edit) -------------...
Take a look on .blur function of jquery <http://api.jquery.com/blur/> A quick example: ``` $("#myelement").blur(function(){ $(this).hide(); //or $("#targetelement").hide(); }); ```
15,021,877
I am developing a GUI with PyQt, to perform visual analysis of the data collected during some experiments. The GUI asks the user to indicate the directory where the data to be analyzed is located: ``` class ExperimentAnalyzer(QtGui.QMainWindow): ## other stuff here def loadExperiment(self): directory ...
2013/02/22
[ "https://Stackoverflow.com/questions/15021877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1759574/" ]
You can do in this way: ``` $(function(){ $('.yourelem, .targetDiv').click(function(ev){ $('.targetDiv').slideDown('fast'); ev.stopPropagation(); }); $(document).click(function(){ $('.targetDiv').slideUp('fast'); }); }); ``` [See the action in jsbin](http://jsbin.com/ayuhol/1/edit) -------------...
Make variable sel `true`, if we click on the `div`. ``` if(sel) $(".stackExchange").slideDown(800); else $(".stackExchange").slideUp(800); ```
15,021,877
I am developing a GUI with PyQt, to perform visual analysis of the data collected during some experiments. The GUI asks the user to indicate the directory where the data to be analyzed is located: ``` class ExperimentAnalyzer(QtGui.QMainWindow): ## other stuff here def loadExperiment(self): directory ...
2013/02/22
[ "https://Stackoverflow.com/questions/15021877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1759574/" ]
Try this : HTML ``` <a id="show" href="#">show</a> <div class="test" style="display: none;"> hey </div> ``` JS ``` $('a#show').click(function(event) { event.stopPropagation(); $('.test').toggle(); }); $('html').click(function() { $('.test').hide(); }); ```
Take a look on .blur function of jquery <http://api.jquery.com/blur/> A quick example: ``` $("#myelement").blur(function(){ $(this).hide(); //or $("#targetelement").hide(); }); ```
15,021,877
I am developing a GUI with PyQt, to perform visual analysis of the data collected during some experiments. The GUI asks the user to indicate the directory where the data to be analyzed is located: ``` class ExperimentAnalyzer(QtGui.QMainWindow): ## other stuff here def loadExperiment(self): directory ...
2013/02/22
[ "https://Stackoverflow.com/questions/15021877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1759574/" ]
Try this : HTML ``` <a id="show" href="#">show</a> <div class="test" style="display: none;"> hey </div> ``` JS ``` $('a#show').click(function(event) { event.stopPropagation(); $('.test').toggle(); }); $('html').click(function() { $('.test').hide(); }); ```
Make variable sel `true`, if we click on the `div`. ``` if(sel) $(".stackExchange").slideDown(800); else $(".stackExchange").slideUp(800); ```
43,222,378
I'm working on my python script to extract multiple strings from a .csv file but I can't recover the Spanish characters (like á, é, í) after I open the file and read the lines. This is my code so far: ``` import csv list_text=[] with open(file, 'rb') as data: reader = csv.reader(data, delimiter='\t') for row ...
2017/04/05
[ "https://Stackoverflow.com/questions/43222378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7817760/" ]
When you print a list it shows all the cancelled characters, that way `\n` and other characters don't throw off the list display, so if you print the string it will work properly: ``` 'Vivi\xc3\xb3 el sue\xc3\xb1o, ESPA\xc3\x91OL...'.decode('utf-8') ```
1. use unicodecsv instead of csv , csv doesn't support well unicode 2. open the file with codecs, and 'utf-8' **see code below** ``` import unicodecsv as csv import codecs list_text=[] with codecs.open(file, 'rb','utf-8') as data: reader = csv.reader(data, delimiter='\t') for row in reader: print r...
43,222,378
I'm working on my python script to extract multiple strings from a .csv file but I can't recover the Spanish characters (like á, é, í) after I open the file and read the lines. This is my code so far: ``` import csv list_text=[] with open(file, 'rb') as data: reader = csv.reader(data, delimiter='\t') for row ...
2017/04/05
[ "https://Stackoverflow.com/questions/43222378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7817760/" ]
The python 2.x `csv` module doesn't support unicode and you did the right thing by opening the file in binary mode and parsing the utf-8 encoded strings instead of decoded unicode strings. Python 2 is kinda strange in that the `str` type (as opposed to the `unicode` type) holds either string or binary data. You got `'V...
When you print a list it shows all the cancelled characters, that way `\n` and other characters don't throw off the list display, so if you print the string it will work properly: ``` 'Vivi\xc3\xb3 el sue\xc3\xb1o, ESPA\xc3\x91OL...'.decode('utf-8') ```
43,222,378
I'm working on my python script to extract multiple strings from a .csv file but I can't recover the Spanish characters (like á, é, í) after I open the file and read the lines. This is my code so far: ``` import csv list_text=[] with open(file, 'rb') as data: reader = csv.reader(data, delimiter='\t') for row ...
2017/04/05
[ "https://Stackoverflow.com/questions/43222378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7817760/" ]
The python 2.x `csv` module doesn't support unicode and you did the right thing by opening the file in binary mode and parsing the utf-8 encoded strings instead of decoded unicode strings. Python 2 is kinda strange in that the `str` type (as opposed to the `unicode` type) holds either string or binary data. You got `'V...
1. use unicodecsv instead of csv , csv doesn't support well unicode 2. open the file with codecs, and 'utf-8' **see code below** ``` import unicodecsv as csv import codecs list_text=[] with codecs.open(file, 'rb','utf-8') as data: reader = csv.reader(data, delimiter='\t') for row in reader: print r...
4,673,166
I'm trying to use httplib to send credit card information to authorize.net. When i try to post the request, I get the following traceback: ``` File "./lib/cgi_app.py", line 139, in run res = method() File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring,...
2011/01/12
[ "https://Stackoverflow.com/questions/4673166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/355689/" ]
> > gaierror: [Errno -2] Name or service not known > > > This error often indicates a failure of your DNS resolver. Does `ping secure.authorize.net` return successful replies from the same server that receives the gaierror? Does the hostname have a typo in it?
pass the port separately from the host: ``` conn = httplib.HTTPSConnection("secure.authorize.net", 443, ....) ```
4,673,166
I'm trying to use httplib to send credit card information to authorize.net. When i try to post the request, I get the following traceback: ``` File "./lib/cgi_app.py", line 139, in run res = method() File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring,...
2011/01/12
[ "https://Stackoverflow.com/questions/4673166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/355689/" ]
The problem ultimately came down to the fact that selinux was stopping apache from getting that port. Disabling selinux fixed the problems. I had an issue later where i didn't have /var/www/.python-eggs/, so MySQLdb was hosing on import. But after a mkdir, it was fixed.
pass the port separately from the host: ``` conn = httplib.HTTPSConnection("secure.authorize.net", 443, ....) ```
4,673,166
I'm trying to use httplib to send credit card information to authorize.net. When i try to post the request, I get the following traceback: ``` File "./lib/cgi_app.py", line 139, in run res = method() File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring,...
2011/01/12
[ "https://Stackoverflow.com/questions/4673166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/355689/" ]
As an (obvious) heads up, this same error can also be triggered by including the protocol in the host parameter. For example this code: ``` conn = httplib.HTTPConnection("http://secure.authorize.net", 80, ....) ``` will also cause the "gaierror: [Errno -2] Name or service not known" error, even if all your network...
pass the port separately from the host: ``` conn = httplib.HTTPSConnection("secure.authorize.net", 443, ....) ```
4,673,166
I'm trying to use httplib to send credit card information to authorize.net. When i try to post the request, I get the following traceback: ``` File "./lib/cgi_app.py", line 139, in run res = method() File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring,...
2011/01/12
[ "https://Stackoverflow.com/questions/4673166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/355689/" ]
> > gaierror: [Errno -2] Name or service not known > > > This error often indicates a failure of your DNS resolver. Does `ping secure.authorize.net` return successful replies from the same server that receives the gaierror? Does the hostname have a typo in it?
The problem ultimately came down to the fact that selinux was stopping apache from getting that port. Disabling selinux fixed the problems. I had an issue later where i didn't have /var/www/.python-eggs/, so MySQLdb was hosing on import. But after a mkdir, it was fixed.
4,673,166
I'm trying to use httplib to send credit card information to authorize.net. When i try to post the request, I get the following traceback: ``` File "./lib/cgi_app.py", line 139, in run res = method() File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring,...
2011/01/12
[ "https://Stackoverflow.com/questions/4673166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/355689/" ]
As an (obvious) heads up, this same error can also be triggered by including the protocol in the host parameter. For example this code: ``` conn = httplib.HTTPConnection("http://secure.authorize.net", 80, ....) ``` will also cause the "gaierror: [Errno -2] Name or service not known" error, even if all your network...
> > gaierror: [Errno -2] Name or service not known > > > This error often indicates a failure of your DNS resolver. Does `ping secure.authorize.net` return successful replies from the same server that receives the gaierror? Does the hostname have a typo in it?
4,673,166
I'm trying to use httplib to send credit card information to authorize.net. When i try to post the request, I get the following traceback: ``` File "./lib/cgi_app.py", line 139, in run res = method() File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring,...
2011/01/12
[ "https://Stackoverflow.com/questions/4673166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/355689/" ]
As an (obvious) heads up, this same error can also be triggered by including the protocol in the host parameter. For example this code: ``` conn = httplib.HTTPConnection("http://secure.authorize.net", 80, ....) ``` will also cause the "gaierror: [Errno -2] Name or service not known" error, even if all your network...
The problem ultimately came down to the fact that selinux was stopping apache from getting that port. Disabling selinux fixed the problems. I had an issue later where i didn't have /var/www/.python-eggs/, so MySQLdb was hosing on import. But after a mkdir, it was fixed.
63,587,626
I am receiving the following download error when I attempt to install Jupyter Notebook on Windows: ``` ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\*redacted*\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\loca...
2020/08/25
[ "https://Stackoverflow.com/questions/63587626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14166558/" ]
Try uninstalling virtualenv or pipenv (whichever you are using) and then reinstalling. If this doesn't work try installing conda. There are two versions of it: Anaconda Miniconda I would recommend going with miniconda as it is a lightweight installation but does not have a GUI. Here is the [link](https://docs.conda.i...
The easiest way to setup Jupyter Notebook is using pip if you do not require conda. Since you are new to python, first create a new virtual environment using virtualenv. Installing pip (Ignore if already installed): Download get-pip.py for Windows and run `python get-pip.py` Installing virtualenv: `pip install virtua...
63,587,626
I am receiving the following download error when I attempt to install Jupyter Notebook on Windows: ``` ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\*redacted*\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\loca...
2020/08/25
[ "https://Stackoverflow.com/questions/63587626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14166558/" ]
Make sure the maximum file path length limitation is turned off on your windows machine. In the Registry Editor, use the left sidebar to navigate to the following key: HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem On the right, find a value named LongPathsEnabled and double-click it. If you don’t s...
Try uninstalling virtualenv or pipenv (whichever you are using) and then reinstalling. If this doesn't work try installing conda. There are two versions of it: Anaconda Miniconda I would recommend going with miniconda as it is a lightweight installation but does not have a GUI. Here is the [link](https://docs.conda.i...
63,587,626
I am receiving the following download error when I attempt to install Jupyter Notebook on Windows: ``` ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\*redacted*\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\loca...
2020/08/25
[ "https://Stackoverflow.com/questions/63587626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14166558/" ]
Make sure the maximum file path length limitation is turned off on your windows machine. In the Registry Editor, use the left sidebar to navigate to the following key: HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem On the right, find a value named LongPathsEnabled and double-click it. If you don’t s...
The easiest way to setup Jupyter Notebook is using pip if you do not require conda. Since you are new to python, first create a new virtual environment using virtualenv. Installing pip (Ignore if already installed): Download get-pip.py for Windows and run `python get-pip.py` Installing virtualenv: `pip install virtua...
49,715,583
I have this python code solving knapsack problem using dynamic programming. this function returns the total cost of best subset but I want it to return the elements of best subset . can anybody help me with this? ``` def knapSack(W, wt, val, n): K = [[0 for x in range(W + 1)] for x in range(n + 1)] # Build t...
2018/04/08
[ "https://Stackoverflow.com/questions/49715583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8238009/" ]
What you can do is instead of returning only K[n][W], return K Then iterate K as : ``` elements=list() dp=K w = W i = n while (i> 0): if dp[w][i] - dp[w - wt(i)][i-1] == val(i): #the element 'i' is in the knapsack element.append(i) i = i-1 //only in 0-1 knapsack w -=wt(i) else: i = i-1 ...
You can add this code to the end of your function to work your way back through the items added: ``` res = K[n][W] print(res) w = W for i in range(n, 0, -1): if res <= 0: break if res == K[i - 1][w]: continue else: print(wt[i - 1]) res = res - val[i - 1] w = w - w...
33,008,401
How to define an attribute in a Python 3 enum class that is NOT an enum value? ``` class Color(Enum): red = 0 blue = 1 violet = 2 foo = 'this is a regular attribute' bar = 55 # this is also a regular attribute ``` But this seems to fail for me. It seems that Color tries to include foo and bar as...
2015/10/08
[ "https://Stackoverflow.com/questions/33008401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5421703/" ]
The point of the `Enum` type is to define enum values, so non-enum values are theoretically out of scope for this type. For constants, you should consider moving them out of the type anyway: They are likely not directly related to the enum values (but rather some logic that builds on those), and also should be a mutabl...
When building an `enum.Enum` class, **all** regular attributes become members of the enumeration. A different type of value does not make a difference. By regular attributes I mean all objects that are not descriptors (like functions are) and excluded names (using single underscore names, see the [*Allowed members and...
60,998,188
I'm trying to write a python 3 code that prints out square matrix from user input. In addition the first row of this matrix must be filled by numbers from 1,n, the second row is the multiplication of the first row by 2, the third by 3, etc., until n-th row, which is created by the first row being multiplied by n. I was...
2020/04/02
[ "https://Stackoverflow.com/questions/60998188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13111470/" ]
You can sore function in a List. ``` public class NeutralFactory: NPCFactory { private List<Func<int, Creature>> humanoids = new List<Func<int, Creature>> { hp=> new Dwarf(hp), hp=> new Fairy(hp), hp=> new Elf(hp), hp=> new Troll(hp), hp=> new Orc...
To avoid having to write creation functions for each class, you can use `Activator.CreateInstance`: ```cs using System; using System.Collections.Generic; namespace so60998181 { public class Creature { public int hp; public Creature() { this.hp = 100; } publi...
60,998,188
I'm trying to write a python 3 code that prints out square matrix from user input. In addition the first row of this matrix must be filled by numbers from 1,n, the second row is the multiplication of the first row by 2, the third by 3, etc., until n-th row, which is created by the first row being multiplied by n. I was...
2020/04/02
[ "https://Stackoverflow.com/questions/60998188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13111470/" ]
You can sore function in a List. ``` public class NeutralFactory: NPCFactory { private List<Func<int, Creature>> humanoids = new List<Func<int, Creature>> { hp=> new Dwarf(hp), hp=> new Fairy(hp), hp=> new Elf(hp), hp=> new Troll(hp), hp=> new Orc...
You can use the method `GetConstructor(type[])` to get the constructor which is most likely a `Func` object. If you use the `Invoke` method you get a object back. Last you have to parse it as Creature to return it. ``` public Creature CreateHumanoid( int hp = 100 ) { int index = random.Next( humanoids.Count );...
60,998,188
I'm trying to write a python 3 code that prints out square matrix from user input. In addition the first row of this matrix must be filled by numbers from 1,n, the second row is the multiplication of the first row by 2, the third by 3, etc., until n-th row, which is created by the first row being multiplied by n. I was...
2020/04/02
[ "https://Stackoverflow.com/questions/60998188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13111470/" ]
You can sore function in a List. ``` public class NeutralFactory: NPCFactory { private List<Func<int, Creature>> humanoids = new List<Func<int, Creature>> { hp=> new Dwarf(hp), hp=> new Fairy(hp), hp=> new Elf(hp), hp=> new Troll(hp), hp=> new Orc...
Sounds like a good case for an abstract class. If you don't ever want someone to create just an instance of 'Creature', and instead they should always create a version of a creature, then you want an abstract class. So you could do something like this: ``` public class NeutralFactory : NPCFactory { private Random ...
60,998,188
I'm trying to write a python 3 code that prints out square matrix from user input. In addition the first row of this matrix must be filled by numbers from 1,n, the second row is the multiplication of the first row by 2, the third by 3, etc., until n-th row, which is created by the first row being multiplied by n. I was...
2020/04/02
[ "https://Stackoverflow.com/questions/60998188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13111470/" ]
You can use the method `GetConstructor(type[])` to get the constructor which is most likely a `Func` object. If you use the `Invoke` method you get a object back. Last you have to parse it as Creature to return it. ``` public Creature CreateHumanoid( int hp = 100 ) { int index = random.Next( humanoids.Count );...
To avoid having to write creation functions for each class, you can use `Activator.CreateInstance`: ```cs using System; using System.Collections.Generic; namespace so60998181 { public class Creature { public int hp; public Creature() { this.hp = 100; } publi...
60,998,188
I'm trying to write a python 3 code that prints out square matrix from user input. In addition the first row of this matrix must be filled by numbers from 1,n, the second row is the multiplication of the first row by 2, the third by 3, etc., until n-th row, which is created by the first row being multiplied by n. I was...
2020/04/02
[ "https://Stackoverflow.com/questions/60998188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13111470/" ]
You can use the method `GetConstructor(type[])` to get the constructor which is most likely a `Func` object. If you use the `Invoke` method you get a object back. Last you have to parse it as Creature to return it. ``` public Creature CreateHumanoid( int hp = 100 ) { int index = random.Next( humanoids.Count );...
Sounds like a good case for an abstract class. If you don't ever want someone to create just an instance of 'Creature', and instead they should always create a version of a creature, then you want an abstract class. So you could do something like this: ``` public class NeutralFactory : NPCFactory { private Random ...
60,579,544
I have a frontend, which is hosted via Firebase. The code uses Firebase authentication and retrieves the token via `user.getIdToken()`. According to answers to similar questions that's the way to go. The backend is written in Python, expects the token and verifies it using the firebase\_admin SDK. On my local machine,...
2020/03/07
[ "https://Stackoverflow.com/questions/60579544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110963/" ]
The error message makes it sound like the user of your client app is signed into a different Firebase project than your backend is working with. Taking the error message literally, the client is using "backend-appengine-project-name", but your backend is using "firebase-project-name". Make sure they are both configured...
``` final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); final GoogleSignInAuthentication googleAuth = await googleUser.authentication; final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, ); fin...
44,669,963
I'm only starting getting into a python from #C and I have this question that I wasn't able to find an answer to, maybe I wasn't able to form a question right I need this to create two lists when using:**load(positives)** and **load(negatives)**, positives is a path to the file. From #C I'm used to use this kind of st...
2017/06/21
[ "https://Stackoverflow.com/questions/44669963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8192419/" ]
Integration with Spring and other frameworks available in Intellij IDEA Ultimate, but you're using Community Edition version which supports mainly Java Core features so there's no inspection capable of determining whether or not the field is assigned.
In recent versions of CE you can suppress these when @Autowired annotation is present, by using the light bulb (I'm using version 2022.2)
33,169,619
Having this: ``` a = 12 b = [1, 2, 3] ``` What is the most pythonic way to convert it into this?: ``` [12, 1, 12, 2, 12, 3] ```
2015/10/16
[ "https://Stackoverflow.com/questions/33169619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1468388/" ]
If you want to alternate between `a` and elements of `b`. You can use [`itertools.cycle`](https://docs.python.org/2/library/itertools.html#itertools.cycle) and `zip` , Example - ``` >>> a = 12 >>> b = [1, 2, 3] >>> from itertools import cycle >>> [i for item in zip(cycle([a]),b) for i in item] [12, 1, 12, 2, 12, 3] `...
You can use `itertools.repeat` to create an iterable with the length of `b` then use `zip` to put its item alongside the items of `a` and at last use `chain.from_iterable` function to concatenate the pairs: ``` >>> from itertools import repeat,chain >>> list(chain.from_iterable(zip(repeat(a,len(b)),b))) [12, 1, 12, 2,...
33,169,619
Having this: ``` a = 12 b = [1, 2, 3] ``` What is the most pythonic way to convert it into this?: ``` [12, 1, 12, 2, 12, 3] ```
2015/10/16
[ "https://Stackoverflow.com/questions/33169619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1468388/" ]
If you want to alternate between `a` and elements of `b`. You can use [`itertools.cycle`](https://docs.python.org/2/library/itertools.html#itertools.cycle) and `zip` , Example - ``` >>> a = 12 >>> b = [1, 2, 3] >>> from itertools import cycle >>> [i for item in zip(cycle([a]),b) for i in item] [12, 1, 12, 2, 12, 3] `...
``` import itertools as it # fillvalue, which is **a** in this case, will be zipped in tuples with, # elements of b as long as the length of b permits. # chain.from_iterable will then flatten the tuple list into a single list list(it.chain.from_iterable(zip_longest([], b, fillvalue=a))) [12, 1, 12, 2, 12, 3] ```
33,169,619
Having this: ``` a = 12 b = [1, 2, 3] ``` What is the most pythonic way to convert it into this?: ``` [12, 1, 12, 2, 12, 3] ```
2015/10/16
[ "https://Stackoverflow.com/questions/33169619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1468388/" ]
try this: ``` >>> a 12 >>> b [1, 2, 3] >>> reduce(lambda x,y:x+y,[[a] + [x] for x in b]) [12, 1, 12, 2, 12, 3] ```
You can use `itertools.repeat` to create an iterable with the length of `b` then use `zip` to put its item alongside the items of `a` and at last use `chain.from_iterable` function to concatenate the pairs: ``` >>> from itertools import repeat,chain >>> list(chain.from_iterable(zip(repeat(a,len(b)),b))) [12, 1, 12, 2,...
33,169,619
Having this: ``` a = 12 b = [1, 2, 3] ``` What is the most pythonic way to convert it into this?: ``` [12, 1, 12, 2, 12, 3] ```
2015/10/16
[ "https://Stackoverflow.com/questions/33169619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1468388/" ]
You can use `itertools.repeat` to create an iterable with the length of `b` then use `zip` to put its item alongside the items of `a` and at last use `chain.from_iterable` function to concatenate the pairs: ``` >>> from itertools import repeat,chain >>> list(chain.from_iterable(zip(repeat(a,len(b)),b))) [12, 1, 12, 2,...
``` import itertools as it # fillvalue, which is **a** in this case, will be zipped in tuples with, # elements of b as long as the length of b permits. # chain.from_iterable will then flatten the tuple list into a single list list(it.chain.from_iterable(zip_longest([], b, fillvalue=a))) [12, 1, 12, 2, 12, 3] ```
33,169,619
Having this: ``` a = 12 b = [1, 2, 3] ``` What is the most pythonic way to convert it into this?: ``` [12, 1, 12, 2, 12, 3] ```
2015/10/16
[ "https://Stackoverflow.com/questions/33169619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1468388/" ]
try this: ``` >>> a 12 >>> b [1, 2, 3] >>> reduce(lambda x,y:x+y,[[a] + [x] for x in b]) [12, 1, 12, 2, 12, 3] ```
``` import itertools as it # fillvalue, which is **a** in this case, will be zipped in tuples with, # elements of b as long as the length of b permits. # chain.from_iterable will then flatten the tuple list into a single list list(it.chain.from_iterable(zip_longest([], b, fillvalue=a))) [12, 1, 12, 2, 12, 3] ```
52,821,996
How to do early stopping in lstm. I am using python tensorflow but not keras. I would appreciate if you can provide a sample python code. Regards
2018/10/15
[ "https://Stackoverflow.com/questions/52821996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9023836/" ]
You can do it Using `checkpoints`: ``` from keras.callbacks import EarlyStopping earlyStop=EarlyStopping(monitor="val_loss",verbose=2,mode='min',patience=3) history=model.fit(xTrain,yTrain,epochs=100,batch_size=10,validation_data=(xTest,yTest) ,verbose=2,callbacks=[earlyStop]) ``` Training will stop when "val\_loss"...
You can find it with a little search <https://github.com/mmuratarat/handson-ml/blob/master/11_deep_learning.ipynb> ``` max_checks_without_progress = 20 checks_without_progress = 0 best_loss = np.infty .... if loss_val < best_loss: save_path = saver.save(sess, './my_mnist_model.ckpt') best_loss =...
51,405,580
I am trying to install behave-parallel using pip install. I have installed programmes previously using pip so I know my Python/script path is correct in my env variables. However I am seeing the following error ``` FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\.....Temp\\pip-install-rjiorrn7\\be...
2018/07/18
[ "https://Stackoverflow.com/questions/51405580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7546921/" ]
The package is simply broken, as it is missing the `setup.py` file. ``` $ tar tzvf behave-parallel-1.2.4a1.tar.gz | grep setup.py $ ``` You might be able to download the source from Github or wherever and package it yourself (`python setup.py bdist_wheel`), then install that wheel (`pip install ../../dist/behave-par...
There is a newer feature for building python packages (see also [PEP 517](https://www.python.org/dev/peps/pep-0517/) and [PEP 518](https://www.python.org/dev/peps/pep-0518/)). A package can now be built without setup.py (with pyproject.toml), but older pip versions are not aware of this feature and raise the error show...
51,405,580
I am trying to install behave-parallel using pip install. I have installed programmes previously using pip so I know my Python/script path is correct in my env variables. However I am seeing the following error ``` FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\.....Temp\\pip-install-rjiorrn7\\be...
2018/07/18
[ "https://Stackoverflow.com/questions/51405580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7546921/" ]
In my case with the same error, the solution was to do ``` pip3 install --upgrade pip ``` It was my pip3 that was in version 9.X were it's now in version 19.X
The package is simply broken, as it is missing the `setup.py` file. ``` $ tar tzvf behave-parallel-1.2.4a1.tar.gz | grep setup.py $ ``` You might be able to download the source from Github or wherever and package it yourself (`python setup.py bdist_wheel`), then install that wheel (`pip install ../../dist/behave-par...
51,405,580
I am trying to install behave-parallel using pip install. I have installed programmes previously using pip so I know my Python/script path is correct in my env variables. However I am seeing the following error ``` FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\.....Temp\\pip-install-rjiorrn7\\be...
2018/07/18
[ "https://Stackoverflow.com/questions/51405580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7546921/" ]
The package is simply broken, as it is missing the `setup.py` file. ``` $ tar tzvf behave-parallel-1.2.4a1.tar.gz | grep setup.py $ ``` You might be able to download the source from Github or wherever and package it yourself (`python setup.py bdist_wheel`), then install that wheel (`pip install ../../dist/behave-par...
Here it seems caused by setup.py not being in the root of my project. (it can't be in root because otherwise the unit test will "discover" setup.py and fail it because it's not a test)
51,405,580
I am trying to install behave-parallel using pip install. I have installed programmes previously using pip so I know my Python/script path is correct in my env variables. However I am seeing the following error ``` FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\.....Temp\\pip-install-rjiorrn7\\be...
2018/07/18
[ "https://Stackoverflow.com/questions/51405580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7546921/" ]
In my case with the same error, the solution was to do ``` pip3 install --upgrade pip ``` It was my pip3 that was in version 9.X were it's now in version 19.X
There is a newer feature for building python packages (see also [PEP 517](https://www.python.org/dev/peps/pep-0517/) and [PEP 518](https://www.python.org/dev/peps/pep-0518/)). A package can now be built without setup.py (with pyproject.toml), but older pip versions are not aware of this feature and raise the error show...
51,405,580
I am trying to install behave-parallel using pip install. I have installed programmes previously using pip so I know my Python/script path is correct in my env variables. However I am seeing the following error ``` FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\.....Temp\\pip-install-rjiorrn7\\be...
2018/07/18
[ "https://Stackoverflow.com/questions/51405580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7546921/" ]
There is a newer feature for building python packages (see also [PEP 517](https://www.python.org/dev/peps/pep-0517/) and [PEP 518](https://www.python.org/dev/peps/pep-0518/)). A package can now be built without setup.py (with pyproject.toml), but older pip versions are not aware of this feature and raise the error show...
Here it seems caused by setup.py not being in the root of my project. (it can't be in root because otherwise the unit test will "discover" setup.py and fail it because it's not a test)
51,405,580
I am trying to install behave-parallel using pip install. I have installed programmes previously using pip so I know my Python/script path is correct in my env variables. However I am seeing the following error ``` FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\.....Temp\\pip-install-rjiorrn7\\be...
2018/07/18
[ "https://Stackoverflow.com/questions/51405580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7546921/" ]
In my case with the same error, the solution was to do ``` pip3 install --upgrade pip ``` It was my pip3 that was in version 9.X were it's now in version 19.X
Here it seems caused by setup.py not being in the root of my project. (it can't be in root because otherwise the unit test will "discover" setup.py and fail it because it's not a test)
2,332,773
I am using newt/snack (a TUI graphical Widgit library for Python based on slang) to have some interactive scripts. However for some target terminals the output of those screens are not very nice. I can change the look of them by changing the `$TERM` variable to remove non printable characters, and to convert them to so...
2010/02/25
[ "https://Stackoverflow.com/questions/2332773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/110488/" ]
short: no - it (newt and slang) simply doesn't **do** that. long: newt uses the function `SLsmg_draw_box` which is shown here for reference: ``` void SLsmg_draw_box (int r, int c, unsigned int dr, unsigned int dc) { if (Smg_Mode == SMG_MODE_NONE) return; if (!dr || !dc) return; This_Row = r; This_Col = ...
It might be based on your `$LANG` being set to something like `en_US.UTF-8`. Try changing it to `en_US` (assuming your base locale is `en_US`).
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
I toyed with an idea similar to how .net core web host waits for shutdown in console applications. I was reviewing it on GitHub and was able to extract the gist of how they performed the `Run` <https://github.com/aspnet/Hosting/blob/15008b0b7fcb54235a9de3ab844c066aaf42ea44/src/Microsoft.AspNetCore.Hosting/WebHostExten...
I'm not sure it is production grade, but for a quick and dirty console app this works well: ```cs await Task.Delay(-1); //-1 indicates infinite timeout ```
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
Implementing Linux Daemon or service for `windows` quite easy with single codebase using Visual Studio 2019. Just create project using `WorkerService` template. In my case I have [`Coraval`](https://docs.coravel.net/) library to schedule the tasks. `Program.cs` class ``` public class Program { public static voi...
Have you tried **Thread.Sleep (Timeout.Infinite)** ? ``` using System; using System.IO; using System.Threading; namespace Daemon { class Program { static int Main(string[] args) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Log.Critical("Windows is not supported...
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
If you're trying to find something more robust, I found an implementation on Github that looks promising: [.NET Core Application blocks for message-based communication](https://github.com/dotnet-architecture/Messaging/). It uses `Host`, `HostBuilder`, `ApplicationServices`, `ApplicationEnvironment`, etc classes to impl...
I'm not sure it is production grade, but for a quick and dirty console app this works well: ```cs await Task.Delay(-1); //-1 indicates infinite timeout ```
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
I toyed with an idea similar to how .net core web host waits for shutdown in console applications. I was reviewing it on GitHub and was able to extract the gist of how they performed the `Run` <https://github.com/aspnet/Hosting/blob/15008b0b7fcb54235a9de3ab844c066aaf42ea44/src/Microsoft.AspNetCore.Hosting/WebHostExten...
The best I could come up with is based on the answer to two other questions: [Killing gracefully a .NET Core daemon running on Linux](https://stackoverflow.com/questions/38291567/killing-gracefully-a-net-core-daemon-running-on-linux) and [Is it possible to await an event instead of another async method?](https://stacko...
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
I toyed with an idea similar to how .net core web host waits for shutdown in console applications. I was reviewing it on GitHub and was able to extract the gist of how they performed the `Run` <https://github.com/aspnet/Hosting/blob/15008b0b7fcb54235a9de3ab844c066aaf42ea44/src/Microsoft.AspNetCore.Hosting/WebHostExten...
Have you tried **Thread.Sleep (Timeout.Infinite)** ? ``` using System; using System.IO; using System.Threading; namespace Daemon { class Program { static int Main(string[] args) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Log.Critical("Windows is not supported...
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
I toyed with an idea similar to how .net core web host waits for shutdown in console applications. I was reviewing it on GitHub and was able to extract the gist of how they performed the `Run` <https://github.com/aspnet/Hosting/blob/15008b0b7fcb54235a9de3ab844c066aaf42ea44/src/Microsoft.AspNetCore.Hosting/WebHostExten...
Implementing Linux Daemon or service for `windows` quite easy with single codebase using Visual Studio 2019. Just create project using `WorkerService` template. In my case I have [`Coraval`](https://docs.coravel.net/) library to schedule the tasks. `Program.cs` class ``` public class Program { public static voi...
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
The best I could come up with is based on the answer to two other questions: [Killing gracefully a .NET Core daemon running on Linux](https://stackoverflow.com/questions/38291567/killing-gracefully-a-net-core-daemon-running-on-linux) and [Is it possible to await an event instead of another async method?](https://stacko...
Have you tried **Thread.Sleep (Timeout.Infinite)** ? ``` using System; using System.IO; using System.Threading; namespace Daemon { class Program { static int Main(string[] args) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Log.Critical("Windows is not supported...
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
If you're trying to find something more robust, I found an implementation on Github that looks promising: [.NET Core Application blocks for message-based communication](https://github.com/dotnet-architecture/Messaging/). It uses `Host`, `HostBuilder`, `ApplicationServices`, `ApplicationEnvironment`, etc classes to impl...
Have you tried **Thread.Sleep (Timeout.Infinite)** ? ``` using System; using System.IO; using System.Threading; namespace Daemon { class Program { static int Main(string[] args) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Log.Critical("Windows is not supported...
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
I toyed with an idea similar to how .net core web host waits for shutdown in console applications. I was reviewing it on GitHub and was able to extract the gist of how they performed the `Run` <https://github.com/aspnet/Hosting/blob/15008b0b7fcb54235a9de3ab844c066aaf42ea44/src/Microsoft.AspNetCore.Hosting/WebHostExten...
If you're trying to find something more robust, I found an implementation on Github that looks promising: [.NET Core Application blocks for message-based communication](https://github.com/dotnet-architecture/Messaging/). It uses `Host`, `HostBuilder`, `ApplicationServices`, `ApplicationEnvironment`, etc classes to impl...
41,454,563
I could just write a long-running CLI app and run it, but I'm assuming it wouldn't comply to all the expectations one would have of a standards-compliant linux daemon (responding to SIGTERM, Started by System V init process, Ignore terminal I/O signals, [etc.](https://www.python.org/dev/peps/pep-3143/#id1)) Most ecosy...
2017/01/04
[ "https://Stackoverflow.com/questions/41454563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/970673/" ]
Implementing Linux Daemon or service for `windows` quite easy with single codebase using Visual Studio 2019. Just create project using `WorkerService` template. In my case I have [`Coraval`](https://docs.coravel.net/) library to schedule the tasks. `Program.cs` class ``` public class Program { public static voi...
I'm not sure it is production grade, but for a quick and dirty console app this works well: ```cs await Task.Delay(-1); //-1 indicates infinite timeout ```
62,328,661
I do understand that higher order functions are functions that take functions as parameters or return functions. I also know that decorators are functions that add some functionality to other functions. What are they exactly. Are they the functions that are passed in as parameters or are they the higher order functions...
2020/06/11
[ "https://Stackoverflow.com/questions/62328661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13675368/" ]
A higher order function is a function that takes a function as an argument OR\* returns a function. A decorator in Python is (typically) an example of a higher-order function, but there are decorators that aren't (class decorators\*\*, and decorators that aren't functions), and there are higher-order functions that ar...
A higher-order function is a function that either takes a function as an argument or returns a function. Decorator *syntax* is a syntactic shortcut: ``` @f def g(...): ... ``` is just a convenient shorthand for ``` def g(...): ... g = f(g) ``` As such, a decorator really is simply a function that takes a...
59,505,322
I am going through a Django tutorial but it's an old one. The videos were all made using Django 1.11 and Python 3.6. Problem is I have installed python3.8 in my machine. So I was trying to create virtualenv with python version 3.6. But as python 3.6 is not available in my machine, I couldn't do that. At this point I wa...
2019/12/27
[ "https://Stackoverflow.com/questions/59505322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11748245/" ]
It is possible to have two versions of python installed on the same machine. You might have to do some path manipulation to get things working, depending on the specifics of your setup. You can also probably just follow along with the tutorial using python 3.8 even if the tutorial it-self uses 3.6. You can also use th...
Yes. You can have both versions installed on single machine. All u need to do is to download Python3.6 from its Official site, set your Interpreter to python3.6 and u r all set.
25,502,666
I want to execute a linux shell in python, for example: ``` import os cmd='ps -ef | grep java | grep -v grep' p=os.popen(cmd) print p.read() ``` the code works well in python2.7,but it doesn't work well in python2.4 or python2.6 the problem is: when the environment is 2.4 or 2.6,for each process in linux it only re...
2014/08/26
[ "https://Stackoverflow.com/questions/25502666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3978288/" ]
You're making an unwarranted assumption about the behavior of `read`. Use [subprocess.Popen](https://docs.python.org/2.7/library/subprocess.html#popen-objects) (and especially its `communicate` method) to read the whole thing. It was introduced in 2.4. Use the string `splitlines` method as necessary if you want indivi...
`ps` usually clips its output according to the terminal width but, because you are piping the output to `grep`, `ps` can not determine the width, and so it determines that from various things such as the terminal type, environment variables, or command line options such as `--cols`. You might find that you get differ...
71,662,125
Context ------- The instructions on [the Linux/MacOS instructions](https://github.com/lava-nc/lava#linuxmacos) to setup your device for the Lava neuromorphic computing framework by Intel provide a few pip commands, a git clone command and some poetry instructions. I am used to be able to integrate `pip` commands in an...
2022/03/29
[ "https://Stackoverflow.com/questions/71662125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7437143/" ]
Just add the "slideUp" class in your HTML markup: ``` <div class="box slideUp"> ``` NB: the `style="display: none;"` attribute on that element is then no longer needed, nor do you have to execute `$('.box').show()`. Updated snippet: ```js $(".openNav").click(function() { $('.box').toggleClass("slideUp") }); ``` ...
Try this code: ```js $(".openNav").click(function() { $('.box').slideToggle("fast"); }); ``` ```css .clickbox { width: 100px; height: 100px; background: #343434; margin: 0 auto; color: #fff; } .openNav { color: #fff; } .box { width: 200px; height: 200px; background: orange; margin: 0 auto; m...
71,662,125
Context ------- The instructions on [the Linux/MacOS instructions](https://github.com/lava-nc/lava#linuxmacos) to setup your device for the Lava neuromorphic computing framework by Intel provide a few pip commands, a git clone command and some poetry instructions. I am used to be able to integrate `pip` commands in an...
2022/03/29
[ "https://Stackoverflow.com/questions/71662125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7437143/" ]
Just add the "slideUp" class in your HTML markup: ``` <div class="box slideUp"> ``` NB: the `style="display: none;"` attribute on that element is then no longer needed, nor do you have to execute `$('.box').show()`. Updated snippet: ```js $(".openNav").click(function() { $('.box').toggleClass("slideUp") }); ``` ...
```html <div class="clickbox"><a href="javascript:;" class="openNav">dddd</a></div> <div class="box"><a href="javascript:;" class="openNav">dddd</a</div> ``` ```js $(".openNav").click(function() { $('.box').show(); $('.box').toggleClass("slideUp") }); ``` ```css .clickbox { width: 100px; height: 100px; bac...
71,662,125
Context ------- The instructions on [the Linux/MacOS instructions](https://github.com/lava-nc/lava#linuxmacos) to setup your device for the Lava neuromorphic computing framework by Intel provide a few pip commands, a git clone command and some poetry instructions. I am used to be able to integrate `pip` commands in an...
2022/03/29
[ "https://Stackoverflow.com/questions/71662125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7437143/" ]
Just add the "slideUp" class in your HTML markup: ``` <div class="box slideUp"> ``` NB: the `style="display: none;"` attribute on that element is then no longer needed, nor do you have to execute `$('.box').show()`. Updated snippet: ```js $(".openNav").click(function() { $('.box').toggleClass("slideUp") }); ``` ...
```js $(".openNav").click(function() { $('.box').slideToggle(); }); ``` ```css .clickbox { width: 200px; height: 200px; background: yellow; margin: 0 auto; color: #fff; } .openNav { color: #fff; border:1px solid blue; } .box { width: 400px; height: 400px; background: orange; margin: 0 auto; ...
71,662,125
Context ------- The instructions on [the Linux/MacOS instructions](https://github.com/lava-nc/lava#linuxmacos) to setup your device for the Lava neuromorphic computing framework by Intel provide a few pip commands, a git clone command and some poetry instructions. I am used to be able to integrate `pip` commands in an...
2022/03/29
[ "https://Stackoverflow.com/questions/71662125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7437143/" ]
Try this code: ```js $(".openNav").click(function() { $('.box').slideToggle("fast"); }); ``` ```css .clickbox { width: 100px; height: 100px; background: #343434; margin: 0 auto; color: #fff; } .openNav { color: #fff; } .box { width: 200px; height: 200px; background: orange; margin: 0 auto; m...
```js $(".openNav").click(function() { $('.box').slideToggle(); }); ``` ```css .clickbox { width: 200px; height: 200px; background: yellow; margin: 0 auto; color: #fff; } .openNav { color: #fff; border:1px solid blue; } .box { width: 400px; height: 400px; background: orange; margin: 0 auto; ...
71,662,125
Context ------- The instructions on [the Linux/MacOS instructions](https://github.com/lava-nc/lava#linuxmacos) to setup your device for the Lava neuromorphic computing framework by Intel provide a few pip commands, a git clone command and some poetry instructions. I am used to be able to integrate `pip` commands in an...
2022/03/29
[ "https://Stackoverflow.com/questions/71662125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7437143/" ]
```html <div class="clickbox"><a href="javascript:;" class="openNav">dddd</a></div> <div class="box"><a href="javascript:;" class="openNav">dddd</a</div> ``` ```js $(".openNav").click(function() { $('.box').show(); $('.box').toggleClass("slideUp") }); ``` ```css .clickbox { width: 100px; height: 100px; bac...
```js $(".openNav").click(function() { $('.box').slideToggle(); }); ``` ```css .clickbox { width: 200px; height: 200px; background: yellow; margin: 0 auto; color: #fff; } .openNav { color: #fff; border:1px solid blue; } .box { width: 400px; height: 400px; background: orange; margin: 0 auto; ...
56,456,656
I'm a newbie to data science with python. So, I wanted to play around with the following data "<https://www.ssa.gov/OACT/babynames/limits.html>." The main problem here is that instead of giving me one file containing the data for all years, it contains a separate file for each year. Furthermore, each separate file also...
2019/06/05
[ "https://Stackoverflow.com/questions/56456656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11557970/" ]
I saw people running into this issue on Windows by not realizing that in File Explorer file extensions are hidden by default, so while they wanted to create a file called "config", they actually created a file called "config.txt" and that's not found by kubectl.
I ended up deleting windows and install Ubuntu. Windows was a nightmare.
56,456,656
I'm a newbie to data science with python. So, I wanted to play around with the following data "<https://www.ssa.gov/OACT/babynames/limits.html>." The main problem here is that instead of giving me one file containing the data for all years, it contains a separate file for each year. Furthermore, each separate file also...
2019/06/05
[ "https://Stackoverflow.com/questions/56456656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11557970/" ]
Generally if you want to configure your kubectl to use your GKE cluster, you have to run below commands to copy k8s configuration to local. 1.First list your cluster names (under NAME column) and recognize zone (under Location column) ``` $ gcloud container clusters list ``` 2.Then run below command to copy k8s con...
I ended up deleting windows and install Ubuntu. Windows was a nightmare.
56,456,656
I'm a newbie to data science with python. So, I wanted to play around with the following data "<https://www.ssa.gov/OACT/babynames/limits.html>." The main problem here is that instead of giving me one file containing the data for all years, it contains a separate file for each year. Furthermore, each separate file also...
2019/06/05
[ "https://Stackoverflow.com/questions/56456656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11557970/" ]
Generally if you want to configure your kubectl to use your GKE cluster, you have to run below commands to copy k8s configuration to local. 1.First list your cluster names (under NAME column) and recognize zone (under Location column) ``` $ gcloud container clusters list ``` 2.Then run below command to copy k8s con...
I saw people running into this issue on Windows by not realizing that in File Explorer file extensions are hidden by default, so while they wanted to create a file called "config", they actually created a file called "config.txt" and that's not found by kubectl.
53,421,991
I am using Visual Studio Code as my IDE for building web applications using Python's Django web development framework. I am developing on a 2018 MacBook Pro. I am able to launch my web applications by launching them in the terminal using: ``` python3 manage.py runserver ``` However, I want to be able to launch my ap...
2018/11/21
[ "https://Stackoverflow.com/questions/53421991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5644892/" ]
Use the command `virtualenv -p python3 venv` (or replace "venv" with your virtual environment name) in the terminal to create the virtual environment with python3 as the default when "python" is used in the terminal (e.g. `python manage.py ...`). The `-p` is used to specify a specific version of python.
The issue was that I used the "python" command instead of the "python3" command when creating the virtual environment for my project. This was causing the debugger to execute the wrong command when trying run the local server. I was able to create a new virtual environment using the command ... ``` python3 -m venv env...
53,421,991
I am using Visual Studio Code as my IDE for building web applications using Python's Django web development framework. I am developing on a 2018 MacBook Pro. I am able to launch my web applications by launching them in the terminal using: ``` python3 manage.py runserver ``` However, I want to be able to launch my ap...
2018/11/21
[ "https://Stackoverflow.com/questions/53421991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5644892/" ]
Same issue caused to my VS Code environment even launching VS Code after activating venv (Python virtual environment). The VS Code also displayed the Python Environment option "Python 3.7.3 64 bit" on the Status Bar. On first sight, this python environment option looks correct. But, my issue resolved after applying ...
The issue was that I used the "python" command instead of the "python3" command when creating the virtual environment for my project. This was causing the debugger to execute the wrong command when trying run the local server. I was able to create a new virtual environment using the command ... ``` python3 -m venv env...
53,421,991
I am using Visual Studio Code as my IDE for building web applications using Python's Django web development framework. I am developing on a 2018 MacBook Pro. I am able to launch my web applications by launching them in the terminal using: ``` python3 manage.py runserver ``` However, I want to be able to launch my ap...
2018/11/21
[ "https://Stackoverflow.com/questions/53421991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5644892/" ]
Same issue caused to my VS Code environment even launching VS Code after activating venv (Python virtual environment). The VS Code also displayed the Python Environment option "Python 3.7.3 64 bit" on the Status Bar. On first sight, this python environment option looks correct. But, my issue resolved after applying ...
Use the command `virtualenv -p python3 venv` (or replace "venv" with your virtual environment name) in the terminal to create the virtual environment with python3 as the default when "python" is used in the terminal (e.g. `python manage.py ...`). The `-p` is used to specify a specific version of python.
860,140
What is the best way to find out the user that a python process is running under? I could do this: ``` name = os.popen('whoami').read() ``` But that has to start a whole new process. ``` os.environ["USER"] ``` works sometimes, but sometimes that environment variable isn't set.
2009/05/13
[ "https://Stackoverflow.com/questions/860140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83898/" ]
``` import getpass print(getpass.getuser()) ``` See the documentation of the [getpass](https://docs.python.org/3/library/getpass.html) module. > > getpass.getuser() > > > Return the “login name” of the user. Availability: Unix, Windows. > > > This function checks the environment variables LOGNAME, USER, > LNAME...
This should work under Unix. ``` import os print(os.getuid()) # numeric uid import pwd print(pwd.getpwuid(os.getuid())) # full /etc/passwd info ```
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can use a two-way key encryption algorithms like RSA, The password is stored encrypted (by a key, which is stored in the user's brain) on the filesystem, but to decode the password, the user must enter the key.
I don't think you are understanding the answers provided. You don't ever store a plain-text password anywhere, nor do you transmit it to another device. > > You wrote: Sorry, but the issue is storing a > password on the file system... This > password is needed to authenticate by > the other web app. > > > You...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can use a two-way key encryption algorithms like RSA, The password is stored encrypted (by a key, which is stored in the user's brain) on the filesystem, but to decode the password, the user must enter the key.
Is your web application hosted on a farm? If not then a technology such as [DPAPI](http://msdn.microsoft.com/en-us/library/ms995355.aspx) will allow you to encrypt the password so that it can only be decrypted on the machine it was encrypted on. From memory there can be problems with using it on a web farm though, as ...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I don't think you will find a foolproof way to do this. I would suggest a combination of things to achieve 'security by obscurity': * store the password file on a different computer than the one which will use it * store the file path in a separate config file on the app nachine * use permissions to limit access to th...
At the very least you should use permissions (if you are on a filesystem which supports them) to ensure that you are the only one able to read the file. In addition, if your app is compiled, it would not be too difficult to encrypt the password with a hard-coded passphrase. If the code is not compiled this method woul...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I don't think you will find a foolproof way to do this. I would suggest a combination of things to achieve 'security by obscurity': * store the password file on a different computer than the one which will use it * store the file path in a separate config file on the app nachine * use permissions to limit access to th...
Is your web application hosted on a farm? If not then a technology such as [DPAPI](http://msdn.microsoft.com/en-us/library/ms995355.aspx) will allow you to encrypt the password so that it can only be decrypted on the machine it was encrypted on. From memory there can be problems with using it on a web farm though, as ...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From the question it seems you need to store password in such a way, that it can be read and used in an automated transaction with another site. You could encrypt the password and store it encrypted in the file, then decrypt it using a key stored elsewhere in your system before using it. This makes difficulties to some...
Is your web application hosted on a farm? If not then a technology such as [DPAPI](http://msdn.microsoft.com/en-us/library/ms995355.aspx) will allow you to encrypt the password so that it can only be decrypted on the machine it was encrypted on. From memory there can be problems with using it on a web farm though, as ...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From the question it seems you need to store password in such a way, that it can be read and used in an automated transaction with another site. You could encrypt the password and store it encrypted in the file, then decrypt it using a key stored elsewhere in your system before using it. This makes difficulties to some...
You can store it as a result of hash algorithm, this is one way algorithm (eg. MD5 or SHA). On authentication you calc MD5 of password typed by user and checking equality with your stored MD5 password hash for this user. If is equal password is ok. For more information about hasing algorithms you can visit: * <http:/...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From the question it seems you need to store password in such a way, that it can be read and used in an automated transaction with another site. You could encrypt the password and store it encrypted in the file, then decrypt it using a key stored elsewhere in your system before using it. This makes difficulties to some...
I don't think you are understanding the answers provided. You don't ever store a plain-text password anywhere, nor do you transmit it to another device. > > You wrote: Sorry, but the issue is storing a > password on the file system... This > password is needed to authenticate by > the other web app. > > > You...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
At the very least you should use permissions (if you are on a filesystem which supports them) to ensure that you are the only one able to read the file. In addition, if your app is compiled, it would not be too difficult to encrypt the password with a hard-coded passphrase. If the code is not compiled this method woul...
You can store it as a result of hash algorithm, this is one way algorithm (eg. MD5 or SHA). On authentication you calc MD5 of password typed by user and checking equality with your stored MD5 password hash for this user. If is equal password is ok. For more information about hasing algorithms you can visit: * <http:/...
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
At the very least you should use permissions (if you are on a filesystem which supports them) to ensure that you are the only one able to read the file. In addition, if your app is compiled, it would not be too difficult to encrypt the password with a hard-coded passphrase. If the code is not compiled this method woul...
[Protecting the Automatic Logon Password](https://msdn.microsoft.com/en-us/library/aa378826.aspx) The LsaStorePrivateData function can be used by server applications to store client and machine passwords. Windows only
2,664,099
I've found numerous posts on stackoverflow on how to store user passwords. However, I need to know what is the best way to store a password that my application needs to communicate with another application via the web? Currently, our web app needs to transmit data to a remote website. To upload the data, our web app re...
2010/04/18
[ "https://Stackoverflow.com/questions/2664099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From the question it seems you need to store password in such a way, that it can be read and used in an automated transaction with another site. You could encrypt the password and store it encrypted in the file, then decrypt it using a key stored elsewhere in your system before using it. This makes difficulties to some...
At the very least you should use permissions (if you are on a filesystem which supports them) to ensure that you are the only one able to read the file. In addition, if your app is compiled, it would not be too difficult to encrypt the password with a hard-coded passphrase. If the code is not compiled this method woul...
49,524,189
Comparing two lists is tough, there are numerous posts on this subject. But what if I have a list of lists? Simplified to extreme: ``` members=[['john',1964,'NY'], \ ['anna',1991,'CA'], \ ['bert',2001,'AL'], \ ['eddy',1990,'OH']] cash =[['john',200], \ ['dirk',200], \ ...
2018/03/28
[ "https://Stackoverflow.com/questions/49524189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8407665/" ]
You'll need a nested list comprehension. Additionally, you can get rid of punctuation using `re.sub`. ``` import re data = ["How are you. Don't wait for me", "this is all fine"] words = [ re.sub([^a-z\s], '', j.lower()).split() for i in data for j in nlp(i).sents ] ``` Or, ``` words = [] for i in data: .....
There is a much simpler way for list comprehension. You can first join the strings with a period '.' and split them again. ``` [x.split() for x in '.'.join(s).split('.')] ``` It will give the desired result. ``` [["How", "are","you"],["Don't", "wait", "for", "me"],["this","is","all","fine"]] ``` For Pandas datafr...
18,423,941
I have an excel sheet that has a lot of data in it in one column in the form of a python dictionary from a sql database. I don't have access to the original database and I can't import the CSV back into sql with the local infile command due to the fact that the keys/values on each row of the CSV are not in the same ord...
2013/08/24
[ "https://Stackoverflow.com/questions/18423941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/802136/" ]
If the input file is just as shown, and of the small size you mention, you can load the whole file in memory, make the substitutions, and then save it. IMHO, you don't need a RegEx to do this. The easiest to read code that does this is: ``` with open(filename) as f: input= f.read() input= str.replace('""','"') inp...
I think you are overthinking the problem, why don't replace data? ``` l = list() with open('foo.txt') as f: for line in f: l.append(line.replace('""','"').replace('"{','{').replace('}"','}')) s = ''.join(l) print s # or save it to file ``` It generates: ``` {"first_name":"John","last_name":"Smith","age...
18,423,941
I have an excel sheet that has a lot of data in it in one column in the form of a python dictionary from a sql database. I don't have access to the original database and I can't import the CSV back into sql with the local infile command due to the fact that the keys/values on each row of the CSV are not in the same ord...
2013/08/24
[ "https://Stackoverflow.com/questions/18423941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/802136/" ]
Easy: `text = re.sub(r'"(?!")', '', text)` ------------------------------------ Given the input file: TEST.TXT: `"{""first_name"":""John"",""last_name"":""Smith"",""age"":30}"` `"{""first_name"":""Tim"",""last_name"":""Johnson"",""age"":34}"` The script: ```py import re f = open("TEST.TXT","r") text_in = f.rea...
I think you are overthinking the problem, why don't replace data? ``` l = list() with open('foo.txt') as f: for line in f: l.append(line.replace('""','"').replace('"{','{').replace('}"','}')) s = ''.join(l) print s # or save it to file ``` It generates: ``` {"first_name":"John","last_name":"Smith","age...
18,423,941
I have an excel sheet that has a lot of data in it in one column in the form of a python dictionary from a sql database. I don't have access to the original database and I can't import the CSV back into sql with the local infile command due to the fact that the keys/values on each row of the CSV are not in the same ord...
2013/08/24
[ "https://Stackoverflow.com/questions/18423941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/802136/" ]
This should do it: ``` with open('old.csv') as old, open('new.csv', 'w') as new: new.writelines(re.sub(r'"(?!")', '', line) for line in old) ```
I think you are overthinking the problem, why don't replace data? ``` l = list() with open('foo.txt') as f: for line in f: l.append(line.replace('""','"').replace('"{','{').replace('}"','}')) s = ''.join(l) print s # or save it to file ``` It generates: ``` {"first_name":"John","last_name":"Smith","age...
18,423,941
I have an excel sheet that has a lot of data in it in one column in the form of a python dictionary from a sql database. I don't have access to the original database and I can't import the CSV back into sql with the local infile command due to the fact that the keys/values on each row of the CSV are not in the same ord...
2013/08/24
[ "https://Stackoverflow.com/questions/18423941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/802136/" ]
If the input file is just as shown, and of the small size you mention, you can load the whole file in memory, make the substitutions, and then save it. IMHO, you don't need a RegEx to do this. The easiest to read code that does this is: ``` with open(filename) as f: input= f.read() input= str.replace('""','"') inp...
You can actual use the csv module and regex to do this: ``` st='''\ "{""first_name"":""John"",""last_name"":""Smith"",""age"":30}" "{""first_name"":""Tim"",""last_name"":""Johnson"",""age"":34}"\ ''' import csv, re data=[] reader=csv.reader(st, dialect='excel') for line in reader: data.extend(line) s=re.sub(r'(...
18,423,941
I have an excel sheet that has a lot of data in it in one column in the form of a python dictionary from a sql database. I don't have access to the original database and I can't import the CSV back into sql with the local infile command due to the fact that the keys/values on each row of the CSV are not in the same ord...
2013/08/24
[ "https://Stackoverflow.com/questions/18423941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/802136/" ]
Easy: `text = re.sub(r'"(?!")', '', text)` ------------------------------------ Given the input file: TEST.TXT: `"{""first_name"":""John"",""last_name"":""Smith"",""age"":30}"` `"{""first_name"":""Tim"",""last_name"":""Johnson"",""age"":34}"` The script: ```py import re f = open("TEST.TXT","r") text_in = f.rea...
You can actual use the csv module and regex to do this: ``` st='''\ "{""first_name"":""John"",""last_name"":""Smith"",""age"":30}" "{""first_name"":""Tim"",""last_name"":""Johnson"",""age"":34}"\ ''' import csv, re data=[] reader=csv.reader(st, dialect='excel') for line in reader: data.extend(line) s=re.sub(r'(...
18,423,941
I have an excel sheet that has a lot of data in it in one column in the form of a python dictionary from a sql database. I don't have access to the original database and I can't import the CSV back into sql with the local infile command due to the fact that the keys/values on each row of the CSV are not in the same ord...
2013/08/24
[ "https://Stackoverflow.com/questions/18423941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/802136/" ]
This should do it: ``` with open('old.csv') as old, open('new.csv', 'w') as new: new.writelines(re.sub(r'"(?!")', '', line) for line in old) ```
You can actual use the csv module and regex to do this: ``` st='''\ "{""first_name"":""John"",""last_name"":""Smith"",""age"":30}" "{""first_name"":""Tim"",""last_name"":""Johnson"",""age"":34}"\ ''' import csv, re data=[] reader=csv.reader(st, dialect='excel') for line in reader: data.extend(line) s=re.sub(r'(...
46,164,770
Keywords [have to](https://mail.python.org/pipermail/python-dev/2012-March/117441.html) be strings ``` >>> def foo(**kwargs): ... pass ... >>> foo(**{0:0}) TypeError: foo() keywords must be strings ``` But by some black magic, namespaces are able to bypass that ``` >>> from types import SimpleNamespace >>> Sim...
2017/09/11
[ "https://Stackoverflow.com/questions/46164770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/674039/" ]
> > Could you implement a Python function that can receive integers in the kwargs mapping? > > > No, you can't. The Python evaluation loop handles calling functions defined in Python code differently from calling a callable object defined in C code. The Python evaluation loop code that handles keyword argument exp...
No, kwargs cannot be integers. This answer, however, is designed as a (very) short history lesson rather than technical answer (for that, please see @MartijnPierter's answer). The check was originally added in 2010, in [issue 8419](https://bugs.python.org/issue8419) ([commit fb88636199c12f63d6c8c89f311cdafc91f30d2f](h...
46,164,770
Keywords [have to](https://mail.python.org/pipermail/python-dev/2012-March/117441.html) be strings ``` >>> def foo(**kwargs): ... pass ... >>> foo(**{0:0}) TypeError: foo() keywords must be strings ``` But by some black magic, namespaces are able to bypass that ``` >>> from types import SimpleNamespace >>> Sim...
2017/09/11
[ "https://Stackoverflow.com/questions/46164770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/674039/" ]
SimpleNamespace now rejects integer keyword keys. As Martijn supposed, [the original behavior was a bug](https://bugs.python.org/issue31655). It seems that it was fixed by [bpo-31655: Validate keyword names in SimpleNamespace constructor](https://github.com/python/cpython/commit/79ba471488b936abda5ba5234b1ea90cbc94cae6...
No, kwargs cannot be integers. This answer, however, is designed as a (very) short history lesson rather than technical answer (for that, please see @MartijnPierter's answer). The check was originally added in 2010, in [issue 8419](https://bugs.python.org/issue8419) ([commit fb88636199c12f63d6c8c89f311cdafc91f30d2f](h...
71,277,152
``` "127.0.0.1": { "nmaprun": { "@scanner": "nmap", "@args": "nmap -v -sS -sV -sC -A -O -oX nmap 127.0.0.1 1-1024", "@start": "1645467733", "@startstr": "Mon Feb 21 23:52:13 2022", "@version": "7.91", "@xmloutputversion": "1.05", ...
2022/02/26
[ "https://Stackoverflow.com/questions/71277152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13668217/" ]
I would guess that `Contest` does not implement `IEquatable<Contest>` or otherwise override `Equals(object)`. Therefore `Assert.Equal` will only work when the objects are reference equal. If you don't want to do this, you can create your own `IEqualityComparer<Contest>` and use the overload `Assert.Equal(expectedRankin...
I'd suggest to use the [Fluent Assertions](https://fluentassertions.com/introduction) library for this kind of assert checks in unit tests. Instead of rigid equality, you are looking for *equivalency*. Then your assert becomes: ```cs input.Should().BeEquivalentTo(expectedRanking); ``` and this doesn't look for refe...
9,921,976
I have a list iteration in python defined like this: ``` for i in range(5): for j in range(5): if i != j: print i , j ``` So for each element in my defined range [0..5] I want to get each element i, but also all other elements which are not i. This code does exactly as I expect, but is there...
2012/03/29
[ "https://Stackoverflow.com/questions/9921976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1220022/" ]
Use [`itertools.permutations`](http://docs.python.org/library/itertools.html#itertools.permutations): ``` import itertools as it for i, j in it.permutations(range(5), 2): print i, j ```
[(x,y)for x in range(5) for y in range(5) if x!=y]
48,339,383
My python script is not running under my Crontab. But when i try to run it from the Terminal it works perfectly. I have placed this in the python script at the top: ``` #!/usr/bin/python ``` Also I tried: ``` #!/usr/bin/env python ``` I did my file executable: ``` chmod a+x vida.py ``` Added to my crontab and ...
2018/01/19
[ "https://Stackoverflow.com/questions/48339383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9239574/" ]
You should change you crontab line as such to get `stdout` and `stderr` saved to the file: ``` */1 * * * * gg /usr/bin/python /home/gg/vida.py >> /home/gg/out1.txt 2>&1 ``` Simply read `out1.txt` after crontab has run the line to see what's wrong Edit after your comment: Based on the error you've shared, I be...
syntax: minutes hour dom mon dow user command 55 16 \* \* \* root /root/anaconda/bin/python /root/path/file\_name.py &>> /root/output/output.log
65,699,603
I want to use some function of ximgproc, so I uninstalled opencv-python and re-installed opencv-contrib-python ``` (venv) C:\Users\Administrator\PycharmProjects\eps>pip uninstall opencv-contrib-python opencv-python Skipping opencv-contrib-python as it is not installed. Uninstalling opencv-python-4.5.1.48: Would remo...
2021/01/13
[ "https://Stackoverflow.com/questions/65699603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11702897/" ]
Can you check which packages you have intalled with `pip list`? Even though you uninstalled opencv-python, you also need to uninstall `opencv-python-headless, opencv-contrib-python-headless` packages. As @skvark says > > never install both package > > >
Install opencv and opencv-contrib modules separately. Command for standard desktop environment: ``` $ pip install opencv-python opencv-contrib-python ```
13,262,575
Making a turn based game using python 3. I want 2 characters (foe & enemy) to attack, pause based on random+speed, then attack again if they are still alive. The problem I am running into is the time.sleep freezes both modules, not 1 or the other. Any suggestions to make this work effectively? ``` from multiprocessin...
2012/11/07
[ "https://Stackoverflow.com/questions/13262575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804903/" ]
Edit the [netbeans.conf](http://wiki.netbeans.org/FaqNetbeansConf) file (located in the /etc folder of your NetBeans installation), look for the line that starts with "netbeans\_default\_options=". Edit the fontsize parameter if present. If not, add something like "--fontsize 11" (without the quote) at the end of the l...
How about using a screen magnifier? on Windows 7, [Sysinternals ZoomIt](https://technet.microsoft.com/en-us/sysinternals/zoomit.aspx) works fine. Nearly every Linux desktop has one as well.
13,262,575
Making a turn based game using python 3. I want 2 characters (foe & enemy) to attack, pause based on random+speed, then attack again if they are still alive. The problem I am running into is the time.sleep freezes both modules, not 1 or the other. Any suggestions to make this work effectively? ``` from multiprocessin...
2012/11/07
[ "https://Stackoverflow.com/questions/13262575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804903/" ]
`Alt` + `scroll wheel` will increase / decrease the font size of the main code window
My overall NetBeans (8.0) window and fonts was annoyingly and unpleasantly small so I found that Options/Appearance/Look and Feel - Windows Classic was the only one that could be used on a Windows 10.
13,262,575
Making a turn based game using python 3. I want 2 characters (foe & enemy) to attack, pause based on random+speed, then attack again if they are still alive. The problem I am running into is the time.sleep freezes both modules, not 1 or the other. Any suggestions to make this work effectively? ``` from multiprocessin...
2012/11/07
[ "https://Stackoverflow.com/questions/13262575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804903/" ]
For Linux: <http://cristian-radulescu.ro/article/fix-netbeans-big-fonts-on-ubuntu.html> That post recommends adding ``` --laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd ``` It certainly works on Ubuntu 12.04. I don't know if the same settings will work for Windows7 (but they could because they...
How about using a screen magnifier? on Windows 7, [Sysinternals ZoomIt](https://technet.microsoft.com/en-us/sysinternals/zoomit.aspx) works fine. Nearly every Linux desktop has one as well.
13,262,575
Making a turn based game using python 3. I want 2 characters (foe & enemy) to attack, pause based on random+speed, then attack again if they are still alive. The problem I am running into is the time.sleep freezes both modules, not 1 or the other. Any suggestions to make this work effectively? ``` from multiprocessin...
2012/11/07
[ "https://Stackoverflow.com/questions/13262575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804903/" ]
Try this: ![enter image description here](https://i.stack.imgur.com/ItbBH.png) Size of font can be set via settings
I have a NetBeans plugin called 'UI-Editor' that you can use to customize virtually all Swing Settings (including Font types, sizes, and colors). Go to Tools->Plugins and search for UI-Editor. Or go here: <http://plugins.netbeans.org/plugin/55618/?show=true>
13,262,575
Making a turn based game using python 3. I want 2 characters (foe & enemy) to attack, pause based on random+speed, then attack again if they are still alive. The problem I am running into is the time.sleep freezes both modules, not 1 or the other. Any suggestions to make this work effectively? ``` from multiprocessin...
2012/11/07
[ "https://Stackoverflow.com/questions/13262575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804903/" ]
I have a NetBeans plugin called 'UI-Editor' that you can use to customize virtually all Swing Settings (including Font types, sizes, and colors). Go to Tools->Plugins and search for UI-Editor. Or go here: <http://plugins.netbeans.org/plugin/55618/?show=true>
How about using a screen magnifier? on Windows 7, [Sysinternals ZoomIt](https://technet.microsoft.com/en-us/sysinternals/zoomit.aspx) works fine. Nearly every Linux desktop has one as well.
13,262,575
Making a turn based game using python 3. I want 2 characters (foe & enemy) to attack, pause based on random+speed, then attack again if they are still alive. The problem I am running into is the time.sleep freezes both modules, not 1 or the other. Any suggestions to make this work effectively? ``` from multiprocessin...
2012/11/07
[ "https://Stackoverflow.com/questions/13262575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804903/" ]
For Linux: <http://cristian-radulescu.ro/article/fix-netbeans-big-fonts-on-ubuntu.html> That post recommends adding ``` --laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd ``` It certainly works on Ubuntu 12.04. I don't know if the same settings will work for Windows7 (but they could because they...
My overall NetBeans (8.0) window and fonts was annoyingly and unpleasantly small so I found that Options/Appearance/Look and Feel - Windows Classic was the only one that could be used on a Windows 10.
13,262,575
Making a turn based game using python 3. I want 2 characters (foe & enemy) to attack, pause based on random+speed, then attack again if they are still alive. The problem I am running into is the time.sleep freezes both modules, not 1 or the other. Any suggestions to make this work effectively? ``` from multiprocessin...
2012/11/07
[ "https://Stackoverflow.com/questions/13262575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804903/" ]
Try this: ![enter image description here](https://i.stack.imgur.com/ItbBH.png) Size of font can be set via settings
Go to, *Tools -> Options -> Appearance* Check the box which says ***'Override default fonts by'***. Choose the Font Size. This should change the font of Project Window. Doesn't significantly affect the overall font. Note : Im using Netbeans 8.2