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
29,000,392
When I Try to use the sorted() function in python it only sorts the elements within each array alphabetically as the first 3 outputs are: ``` [u'A', u'a', u'a', u'f', u'g', u'h', u'i', u'n', u'n', u's', u't'] [u'N', u'a', u'e', u'g', u'i', u'i', u'r'] [u'C', u'a', u'e', u'm', u'n', u'o', u'o', u'r'] ``` These shoul...
2015/03/12
[ "https://Stackoverflow.com/questions/29000392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3092868/" ]
As far as I'm concerned, the built in VBE is the best way to go. It has not changed in the last 10 years or even longer, but it is tightly integrated into Excel and does everything you need, especially as a beginner.
some time passed since you asked, but maybe someone else might find it useful. I looked for the same thing and couldn't find anything good until I found Notepad++. It makes analyzing the code much easier.
31,388,514
I have to split a list of characters such that it gets cut when it encounters a vowel. For example, a string like ``` toy = ['b', 'a', 'm', 'b', 'i', 'n', 'o'] ``` the output should be ``` [('b', 'a'), ('m', 'b', 'i'), ('n', 'o')] ``` I tried to run 2 loops, one behind the other. ``` # usr/bin/env/python appl...
2015/07/13
[ "https://Stackoverflow.com/questions/31388514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3116297/" ]
You seem to be overcomplicating things. A simple solution for this would be - ``` >>> toy = ['b', 'a', 'm', 'b', 'i', 'n', 'o'] >>> vowels = ['a','i','e','o','u'] >>> apples = [] >>> k = 0 >>> for i ,x in enumerate(toy): ... if x in vowels: ... apples.append(tuple(toy[k:i+1])) ... k = i+1 ....
You could also use this : ``` #usr/bin/env/python apple = [] vowels = ('i', 'a', 'u') toy = ('k', 'h', 'u', 'b', 'a', 'n', 'i') collector = [] for i in toy: collector.append(i) if i in vowels: apple.append(collector) collector = [] print apple ``` Result: ``` [['k', 'h', 'u'], ['b', 'a'], ...
31,388,514
I have to split a list of characters such that it gets cut when it encounters a vowel. For example, a string like ``` toy = ['b', 'a', 'm', 'b', 'i', 'n', 'o'] ``` the output should be ``` [('b', 'a'), ('m', 'b', 'i'), ('n', 'o')] ``` I tried to run 2 loops, one behind the other. ``` # usr/bin/env/python appl...
2015/07/13
[ "https://Stackoverflow.com/questions/31388514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3116297/" ]
1. Have a temporary list and a result list 2. loop through the elements, till the the end is reached 3. add the current element to the temporary list 4. if the current element is a vowel, then add the temporary list to the result list and empty the temporary list 5. goto step 2 --- ``` >>> result = [] >>> temp = [] >...
You could also use this : ``` #usr/bin/env/python apple = [] vowels = ('i', 'a', 'u') toy = ('k', 'h', 'u', 'b', 'a', 'n', 'i') collector = [] for i in toy: collector.append(i) if i in vowels: apple.append(collector) collector = [] print apple ``` Result: ``` [['k', 'h', 'u'], ['b', 'a'], ...
13,608,029
I have 365 2d `numpy` arrays for the every day of the year, displaying an image like this: ![http://i50.tinypic.com/34i62gw.jpg](https://i.stack.imgur.com/yJR7N.jpg) I have them all stacked in a 3d numpy array. Pixels with a value that represents cloud i want to get rid of, i want to search through the previous 7 da...
2012/11/28
[ "https://Stackoverflow.com/questions/13608029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1860229/" ]
You are essentially trying to write a filter for your array. First you need to write a function that when given an array of values, with the middle one being the element currently examined, will return some computation of those values. In your case the function will expect to take 1-d array and returns the element nea...
I would think that you could do something like: ``` data = somehow_get_your_3d_data() #indexed as [day_of_year,y,x] for i,dat in enumerate(data): weeks2 = data[max(i-7,i):min(i+7,len(data)), ... ] new_value = get_new_value(weeks2) #get value from weeks2 here somehow dat[dat == cloud_value] = new_value ```
13,608,029
I have 365 2d `numpy` arrays for the every day of the year, displaying an image like this: ![http://i50.tinypic.com/34i62gw.jpg](https://i.stack.imgur.com/yJR7N.jpg) I have them all stacked in a 3d numpy array. Pixels with a value that represents cloud i want to get rid of, i want to search through the previous 7 da...
2012/11/28
[ "https://Stackoverflow.com/questions/13608029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1860229/" ]
I solved it by this: ``` interpdata = [] j = 0 for i in stack: try: temp = np.where( stack[j] == 50, stack[j-1], modis[j] ) temp = np.where( temp == 50, stack[j+1], temp ) temp = np.where( temp == 50, stack[j-2], temp ) temp = np.where( temp == 50, stack[j+2], temp ) temp =...
I would think that you could do something like: ``` data = somehow_get_your_3d_data() #indexed as [day_of_year,y,x] for i,dat in enumerate(data): weeks2 = data[max(i-7,i):min(i+7,len(data)), ... ] new_value = get_new_value(weeks2) #get value from weeks2 here somehow dat[dat == cloud_value] = new_value ```
71,401,616
While writing a program to help myself study, I run into a problem with my program not displaying the Chinese characters properly. The Chinese characters are loaded in from a .JSON file, and are then printed using a python program. The JSON entries look like this. ``` { "symbol": "我", "reading": "wo", "meaning...
2022/03/08
[ "https://Stackoverflow.com/questions/71401616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15465144/" ]
An example creating a precompiled header: ```sh mkdir -p pch/bits && g++ -O3 -std=c++20 -pedantic-errors -o pch/bits/stdc++.h.gch \ /usr/include/c++/11/x86_64-redhat-linux/bits/stdc++.h ``` Check what you got: ```sh $ file pch/bits/stdc++.h.gch pch/bits/stdc++.h.gch: GCC precompiled header (version 014) for C++ ...
Building on Ted's answer, I would actually do something like this (untested): my\_pch.h: ``` #include <bits/stdc++.h> // might need to specify the full path here ``` And then: ``` g++ -O3 -std=c++20 -pedantic-errors -o pch/bits/my_pch.h.gch my_pch.h ``` And finally, your program would look like this: `...
71,401,616
While writing a program to help myself study, I run into a problem with my program not displaying the Chinese characters properly. The Chinese characters are loaded in from a .JSON file, and are then printed using a python program. The JSON entries look like this. ``` { "symbol": "我", "reading": "wo", "meaning...
2022/03/08
[ "https://Stackoverflow.com/questions/71401616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15465144/" ]
An example creating a precompiled header: ```sh mkdir -p pch/bits && g++ -O3 -std=c++20 -pedantic-errors -o pch/bits/stdc++.h.gch \ /usr/include/c++/11/x86_64-redhat-linux/bits/stdc++.h ``` Check what you got: ```sh $ file pch/bits/stdc++.h.gch pch/bits/stdc++.h.gch: GCC precompiled header (version 014) for C++ ...
So, After having help from @TedLyngmo's answer and doing a little bit more research, I decided to answer the question myself with more clear steps. **PS**: *This answer will be more relatable to those who are using sublime with their custom build file and are on Linux OS (Ubuntu).* > > 1. You need to find where **st...
71,401,616
While writing a program to help myself study, I run into a problem with my program not displaying the Chinese characters properly. The Chinese characters are loaded in from a .JSON file, and are then printed using a python program. The JSON entries look like this. ``` { "symbol": "我", "reading": "wo", "meaning...
2022/03/08
[ "https://Stackoverflow.com/questions/71401616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15465144/" ]
Building on Ted's answer, I would actually do something like this (untested): my\_pch.h: ``` #include <bits/stdc++.h> // might need to specify the full path here ``` And then: ``` g++ -O3 -std=c++20 -pedantic-errors -o pch/bits/my_pch.h.gch my_pch.h ``` And finally, your program would look like this: `...
So, After having help from @TedLyngmo's answer and doing a little bit more research, I decided to answer the question myself with more clear steps. **PS**: *This answer will be more relatable to those who are using sublime with their custom build file and are on Linux OS (Ubuntu).* > > 1. You need to find where **st...
71,401,616
While writing a program to help myself study, I run into a problem with my program not displaying the Chinese characters properly. The Chinese characters are loaded in from a .JSON file, and are then printed using a python program. The JSON entries look like this. ``` { "symbol": "我", "reading": "wo", "meaning...
2022/03/08
[ "https://Stackoverflow.com/questions/71401616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15465144/" ]
You **should not** `#include <bits/stdc++.h>` from ths source code, for at least two reasons: * It's not portable, so it would need to be guarded by ugly `#ifdef`s. * Unlike GCC, Clang never uses PCHs for `#include`s. Instead you should include the PCH using the `-include` flag. This is the only option accepted by bo...
Building on Ted's answer, I would actually do something like this (untested): my\_pch.h: ``` #include <bits/stdc++.h> // might need to specify the full path here ``` And then: ``` g++ -O3 -std=c++20 -pedantic-errors -o pch/bits/my_pch.h.gch my_pch.h ``` And finally, your program would look like this: `...
71,401,616
While writing a program to help myself study, I run into a problem with my program not displaying the Chinese characters properly. The Chinese characters are loaded in from a .JSON file, and are then printed using a python program. The JSON entries look like this. ``` { "symbol": "我", "reading": "wo", "meaning...
2022/03/08
[ "https://Stackoverflow.com/questions/71401616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15465144/" ]
You **should not** `#include <bits/stdc++.h>` from ths source code, for at least two reasons: * It's not portable, so it would need to be guarded by ugly `#ifdef`s. * Unlike GCC, Clang never uses PCHs for `#include`s. Instead you should include the PCH using the `-include` flag. This is the only option accepted by bo...
So, After having help from @TedLyngmo's answer and doing a little bit more research, I decided to answer the question myself with more clear steps. **PS**: *This answer will be more relatable to those who are using sublime with their custom build file and are on Linux OS (Ubuntu).* > > 1. You need to find where **st...
17,504,570
So, I'm on simple project for a online course to make an image gallery using python. The thing is to create 3 buttons one Next, Previous and Quit. So far the quit button works and the next loads a new image but in a different window, I'm quite new to python and GUI-programming with Tkinter so this is a big part of the ...
2013/07/06
[ "https://Stackoverflow.com/questions/17504570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2475520/" ]
Change image by setting image item: `Label['image'] = photoimage_obj` ``` import Image import ImageTk import Tkinter image_list = ['1.jpg', '2.jpg', '5.jpg'] text_list = ['apple', 'bird', 'cat'] current = 0 def move(delta): global current, image_list if not (0 <= current + delta < len(image_list)): t...
My UI is not so good. But my logics works well i tested well. U can change the UI. How it works is, First we need to browse the file and when we click open it displays the image and also it will creates a list of images that are in that selected image folder. I mentioned only '.png' and '.jpg' fils only. If u want to a...
64,774,439
I'm trying to install some packages, and for some reason I can't for the life of me make it happen. My set up is that I'm using PyCharm on Windows with Conda. I'm having these problems with all the non-standard packages I'd like to install (things like numpy install just fine), but for reference I'll use [this](https:/...
2020/11/10
[ "https://Stackoverflow.com/questions/64774439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5559681/" ]
You should do sth like [installation package from git](https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch) , but for conda. (replace pip with conda, and provide valid URL). This is not a pypi package, it is not known to pip by default.
In response to @buran's comments above, I updated conda using `conda update --name base conda` Then used the recommended install for Windows, with ``` conda install -c wmayner pyphi ``` which now gives the error: ``` Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C ...
41,850,809
``` import datetime from nltk_contrib import timex now = datetime.date.today() basedate = timex.Date(now.year, now.month, now.day) print timex.ground(timex.tag("Hai i would like to go to mumbai 22nd of next month"), basedate) print str(datetime.date.day) ``` when i am trying to run the above code i am getting the ...
2017/01/25
[ "https://Stackoverflow.com/questions/41850809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7334656/" ]
The `timex` module has a bug where a global variable is referenced without assignment in the `ground` function. To fix the bug, add the following code which should start at line 171: def ground(tagged\_text, base\_date): ``` # Find all identified timex and put them into a list timex_regex = re.compile(r'<TIMEX2>.*?<...
The solution above about adding month as a global variable causes other problems when timex is called multiple times in a row, because variables are not reset unless you import again. This happens for me in a deployed environment in AWS Lambda. A solution that isn't super pretty but will not cause problems is just to ...
8,399,341
I can't find any tutorial for jQuery + web.py. So I've got basic question on POST method. I've got jQuery script: ``` <script> jQuery('#continue').click(function() { var command = jQuery('#continue').attr('value'); jQuery.ajax({ type: "POST", data: {signal : command}...
2011/12/06
[ "https://Stackoverflow.com/questions/8399341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1073589/" ]
you need to use web.input in web.py to access POST variables look at the docs: <http://webpy.org/docs/0.3/api> (search for "function input") ``` def POST(self): s = web.input().signal print s return ```
``` <script> jQuery('#continue').click(function() { var command = jQuery('#continue').attr('value'); jQuery.ajax({ type: "POST", data: {signal : command}, url: "add the url here" }); }); </script> ``` **add the url of the server.**
42,237,103
I'm writing a python program for the purpose of studying HTML source code used in different countries. I'm testing in a UNIX Shell. The code I have so far works fine, except that I'm getting [HTTP Error 403: Forbidden](https://i.stack.imgur.com/9gzqG.png). Through testing it line by line, I know it has something to do ...
2017/02/14
[ "https://Stackoverflow.com/questions/42237103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6115937/" ]
With jQuery you need to also provide the other transformation: ``` //Image Category size change effect $('.cat-wrap div').hover(function() { $(this).css('width', '30%'); $(this).children().css('opacity', '1'); $(this).siblings().css("width", "16.5%"); }, function() { $(this).css('width', '19.2%'); $(this)....
For it to revert back, you need to add the handler for the mouseout event. This is simply passing a second callback argument to the `hover()` method. ``` $('.cat-wrap div').hover(function() { $(this).css('width', '30%'); $(this).children().css('opacity','1'); $(this).siblings().css( "width", "16.5%");...
42,237,103
I'm writing a python program for the purpose of studying HTML source code used in different countries. I'm testing in a UNIX Shell. The code I have so far works fine, except that I'm getting [HTTP Error 403: Forbidden](https://i.stack.imgur.com/9gzqG.png). Through testing it line by line, I know it has something to do ...
2017/02/14
[ "https://Stackoverflow.com/questions/42237103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6115937/" ]
Here is an example of the javascript you are looking for: ```js var origWidth; var origOpacity; //Image Category size change effect $('.cat-wrap div').hover(function() { origWidth = $(this).css('width'); origOpacity = $(this).children().css('opacity'); $(this).css('width', '30%'); $(this).children...
For it to revert back, you need to add the handler for the mouseout event. This is simply passing a second callback argument to the `hover()` method. ``` $('.cat-wrap div').hover(function() { $(this).css('width', '30%'); $(this).children().css('opacity','1'); $(this).siblings().css( "width", "16.5%");...
42,237,103
I'm writing a python program for the purpose of studying HTML source code used in different countries. I'm testing in a UNIX Shell. The code I have so far works fine, except that I'm getting [HTTP Error 403: Forbidden](https://i.stack.imgur.com/9gzqG.png). Through testing it line by line, I know it has something to do ...
2017/02/14
[ "https://Stackoverflow.com/questions/42237103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6115937/" ]
With jQuery you need to also provide the other transformation: ``` //Image Category size change effect $('.cat-wrap div').hover(function() { $(this).css('width', '30%'); $(this).children().css('opacity', '1'); $(this).siblings().css("width", "16.5%"); }, function() { $(this).css('width', '19.2%'); $(this)....
Here is an example of the javascript you are looking for: ```js var origWidth; var origOpacity; //Image Category size change effect $('.cat-wrap div').hover(function() { origWidth = $(this).css('width'); origOpacity = $(this).children().css('opacity'); $(this).css('width', '30%'); $(this).children...
44,181,879
I believe that I have installed virtualenvwrapper incorrectly (the perils of following different tutorials for python setup). I would like to remove the extension completely from my Mac OSX system but there seems to be no documentation on how to do this. Does anyone know how to completely reverse the installation? It...
2017/05/25
[ "https://Stackoverflow.com/questions/44181879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7442842/" ]
``` pip uninstall virtualenvwrapper ``` Or ``` sudo pip uninstall virtualenvwrapper ``` worked for me.
On windows - This works great pip uninstall virtualenvwrapper-win
38,129,357
In the python difflib library, is the SequenceMatcher class behaving unexpectedly, or am I misreading what the supposed behavior is? Why does the isjunk argument seem to not make any difference in this case? ``` difflib.SequenceMatcher(None, "AA", "A A").ratio() return 0.8 difflib.SequenceMatcher(lambda x: x in ' ',...
2016/06/30
[ "https://Stackoverflow.com/questions/38129357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5839052/" ]
This is happening because the `ratio` function uses total sequences' length while calculating the ratio, **but it doesn't filter elements using `isjunk`**. So, as long as the number of matches in the matching blocks results in the same value (with and without `isjunk`), the ratio measure will be the same. I assume tha...
You can remove the characters from the string before sequencing it ``` def withoutJunk(input, chars): return input.translate(str.maketrans('', '', chars)) a = withoutJunk('AA', ' ') b = withoutJunk('A A', ' ') difflib.SequenceMatcher(None, a, b).ratio() # -> 1.0 ```
58,674,723
I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly. However, neither `pyenv local` nor `pyenv global` seem to take effect. Here are all the details of what I'm s...
2019/11/02
[ "https://Stackoverflow.com/questions/58674723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783314/" ]
I added the following to my ~/.zprofile and got it working. ``` export PYENV_ROOT="$HOME/.pyenv/versions/3.7.3" export PATH="$PYENV_ROOT/bin:$PATH" ```
catalina (and OS X in general) uses `/etc/zprofile` to set the `$PATH` in advance of what you're specifying within the local dotfiles. it uses the `path_helper` utility to specify the `$PATH` and i suspect this is overriding the shim injection in your local dotfiles. you can comment out the following lines in `/etc/zp...
58,674,723
I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly. However, neither `pyenv local` nor `pyenv global` seem to take effect. Here are all the details of what I'm s...
2019/11/02
[ "https://Stackoverflow.com/questions/58674723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783314/" ]
If you're using `pyenv` with `pipenv` and encountering the same issue, you can add the following lines to your `.zshrc` or `.zprofile` file: ```sh export PYENV_ROOT="$HOME/.pyenv/shims" export PATH="$PYENV_ROOT:$PATH" export PIPENV_PYTHON="$PYENV_ROOT/python" ``` Referencing `pyenv`'s `/shims` folder helps to keep i...
I added the following to my ~/.zprofile and got it working. ``` export PYENV_ROOT="$HOME/.pyenv/versions/3.7.3" export PATH="$PYENV_ROOT/bin:$PATH" ```
58,674,723
I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly. However, neither `pyenv local` nor `pyenv global` seem to take effect. Here are all the details of what I'm s...
2019/11/02
[ "https://Stackoverflow.com/questions/58674723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783314/" ]
I added the following to my ~/.zprofile and got it working. ``` export PYENV_ROOT="$HOME/.pyenv/versions/3.7.3" export PATH="$PYENV_ROOT/bin:$PATH" ```
Check if exist any symbolic links on your account root ``` ls -al .pyenv/versions/x.x.x/bin ``` if you don't have symlink files ``` unset CLICOLOR unset CLICOLOR_FORCE unset LSCOLORS unalias ls ``` and try python install again with pyenv
58,674,723
I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly. However, neither `pyenv local` nor `pyenv global` seem to take effect. Here are all the details of what I'm s...
2019/11/02
[ "https://Stackoverflow.com/questions/58674723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783314/" ]
I added the following to my ~/.zprofile and got it working. ``` export PYENV_ROOT="$HOME/.pyenv/versions/3.7.3" export PATH="$PYENV_ROOT/bin:$PATH" ```
I think the issue is due to the default HD partitions that might be causing confusion. "With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the "root" directory ( / ) from the command line, such as with Terminal" (<https://support.apple.com/en-ca/HT210650>). I...
58,674,723
I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly. However, neither `pyenv local` nor `pyenv global` seem to take effect. Here are all the details of what I'm s...
2019/11/02
[ "https://Stackoverflow.com/questions/58674723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783314/" ]
If you're using `pyenv` with `pipenv` and encountering the same issue, you can add the following lines to your `.zshrc` or `.zprofile` file: ```sh export PYENV_ROOT="$HOME/.pyenv/shims" export PATH="$PYENV_ROOT:$PATH" export PIPENV_PYTHON="$PYENV_ROOT/python" ``` Referencing `pyenv`'s `/shims` folder helps to keep i...
catalina (and OS X in general) uses `/etc/zprofile` to set the `$PATH` in advance of what you're specifying within the local dotfiles. it uses the `path_helper` utility to specify the `$PATH` and i suspect this is overriding the shim injection in your local dotfiles. you can comment out the following lines in `/etc/zp...
58,674,723
I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly. However, neither `pyenv local` nor `pyenv global` seem to take effect. Here are all the details of what I'm s...
2019/11/02
[ "https://Stackoverflow.com/questions/58674723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783314/" ]
If you're using `pyenv` with `pipenv` and encountering the same issue, you can add the following lines to your `.zshrc` or `.zprofile` file: ```sh export PYENV_ROOT="$HOME/.pyenv/shims" export PATH="$PYENV_ROOT:$PATH" export PIPENV_PYTHON="$PYENV_ROOT/python" ``` Referencing `pyenv`'s `/shims` folder helps to keep i...
Check if exist any symbolic links on your account root ``` ls -al .pyenv/versions/x.x.x/bin ``` if you don't have symlink files ``` unset CLICOLOR unset CLICOLOR_FORCE unset LSCOLORS unalias ls ``` and try python install again with pyenv
58,674,723
I have a new MacBook with fresh installs of everything which I upgraded to macOS Catalina. I installed homebrew and then pyenv, and installed Python 3.8.0 using pyenv. All these things seemed to work properly. However, neither `pyenv local` nor `pyenv global` seem to take effect. Here are all the details of what I'm s...
2019/11/02
[ "https://Stackoverflow.com/questions/58674723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783314/" ]
If you're using `pyenv` with `pipenv` and encountering the same issue, you can add the following lines to your `.zshrc` or `.zprofile` file: ```sh export PYENV_ROOT="$HOME/.pyenv/shims" export PATH="$PYENV_ROOT:$PATH" export PIPENV_PYTHON="$PYENV_ROOT/python" ``` Referencing `pyenv`'s `/shims` folder helps to keep i...
I think the issue is due to the default HD partitions that might be causing confusion. "With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the "root" directory ( / ) from the command line, such as with Terminal" (<https://support.apple.com/en-ca/HT210650>). I...
54,569,512
I need to parse json file size of 200MB, at the end I would like to write data from the file in sqlite3 database. I have a working python code, but it takes around 9 minutes to complete the task. ``` @transaction.atomic def create_database(): with open('file.json') as f: data = json.load(f) cve_i...
2019/02/07
[ "https://Stackoverflow.com/questions/54569512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9517224/" ]
``` 'ODataManifestModel>EntitySetForBoolean>booleanProperty' ``` A few things: * your screenshot is probably wrong because you always need the entitySet name that can be found in the "folder" `Entity Sets` not the `Entity Type`. Although your name looks correct. * you have to bind one element of the entitySet (array...
**mode** property from ListBase can have a the following properties (**None, SingleSelect, MultiSelect, Delete**) and it is applied to all the list elements
54,569,512
I need to parse json file size of 200MB, at the end I would like to write data from the file in sqlite3 database. I have a working python code, but it takes around 9 minutes to complete the task. ``` @transaction.atomic def create_database(): with open('file.json') as f: data = json.load(f) cve_i...
2019/02/07
[ "https://Stackoverflow.com/questions/54569512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9517224/" ]
``` 'ODataManifestModel>EntitySetForBoolean>booleanProperty' ``` A few things: * your screenshot is probably wrong because you always need the entitySet name that can be found in the "folder" `Entity Sets` not the `Entity Type`. Although your name looks correct. * you have to bind one element of the entitySet (array...
Am assuming your service looks similar to this via URL, there is no sample data provided in your question: [Northwinds oData V2](https://services.odata.org/V3/Northwind/Northwind.svc/). **[`Open preview in external window`](https://embed.plnkr.co/LnJMwR/)** Here am using the `Products` Entity set. ```js //manifes...
56,793,083
I am getting an error and I'm not sure what is causing the error to occur. The error is: ``` Parts[n] = PN IndexError: list assignment index out of range ``` The code I'm using is this. I'm pretty new to python and tried to look out similar problems but didn't seem to find anything exactly similar to this. Any help...
2019/06/27
[ "https://Stackoverflow.com/questions/56793083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10560733/" ]
If the chunks you need to upper are separated with `-` or `.` you may use ``` "Filename to UPPER_SNAKE_CASE": { "prefix": "usc_", "body": [ "${TM_FILENAME/\\.component\\.html$|(^|[-.])([^-.]+)/${1:+_}${2:/upcase}/g}" ], "description": "Convert filename to UPPER_SNAKE_CASE dropping .component.ht...
Here is a pretty simple alternation regex: ``` "upcaseSnake": { "prefix": "rf1", "body": [ "${TM_FILENAME_BASE/(\\..*)|(-)|(.)/${2:+_}${3:/upcase}/g}", "${TM_FILENAME/(\\..*)|(-)|(.)/${2:+_}${3:/upcase}/g}" ], "description": "upcase and snake the filename" }, ``` Either version works. `(\\..*)|(-)|...
74,165,004
i have 2d list implementation as follows. It shows no. of times every student topped in exams:- ``` list = main_record ['student1',1] ['student2',1] ['student2',2] ['student1',5] ['student3',3] ``` i have another list of unique students as follows:- ``` list = students_enrolled ['student1','student2...
2022/10/22
[ "https://Stackoverflow.com/questions/74165004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1028289/" ]
You define a `dict` base key of `studentX` and save the max value for each student `key` then sort the `students_enrolled` base max value of each key. ``` from collections import defaultdict main_record = [['student1',1], ['student2',1], ['student2',2], ['student1',5], ['student3',3]] students_enrolled = ['student1',...
If it is a 2D list it should look like this: `l = [["student1", 2], ["student2", 3], ["student3", 4]]`. To get the highest numeric value from the 2nd column you can use a loop like this: ``` numbers = [] for student in list: numbers.append(student[1]) for num in numbers: n = numbers.copy() n.sort() n....
51,903,617
How can a check for list membership be inverted based on a boolean variable? I am looking for a way to simplify the following code: ```python # variables: `is_allowed:boolean`, `action:string` and `allowed_actions:list of strings` if is_allowed: if action not in allowed_actions: print(r'{action} must be...
2018/08/17
[ "https://Stackoverflow.com/questions/51903617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191246/" ]
Compare the result of the test to `is_allowed`. Then use `is_allowed` to put together the correct error message. ``` if (action in allowed_actions) != is_allowed: print(action, "must" if is_allowed else "must NOT", "be allowed!") ```
Given the way your specific code is structured, I think the only improvement you can make is to just store `action in allowed_actions` in a variable: ``` present = action in allowed_actions if is_allowed: if not present: print(r'{action} must be allowed!') else: if present: print(r'{action} mu...
18,033,700
I generate lot of messages for sending to client (push notifications using push woosh). I collect messages for a period of time and the send a bucket of messages. Need advice, what is the best to use for queue python list ( I am afraid to store in memory lot of messages and to lose if server restarts), Redis or MySQL ?
2013/08/03
[ "https://Stackoverflow.com/questions/18033700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1800871/" ]
Redis can save the data contained in memory on your hard drive, so you don't have to be worried about to lose informations. And you can add a key expiration to your data saved in memory, so you can remove old messages. Have a look here : <http://redis.io/topics/persistence> And here : <http://redis.io/commands/expi...
I don't know what is the best from MySQL or Redis to process message queues since I don't know Redis. But I could tell, MySQL is *not* designed for that purpose. You should take a look at dedicated tools such as [RabitMQ](http://www.rabbitmq.com/) that will probably serve better your purpose. Here is a basic tutorial...
34,939,762
I have a function called `prepared_db` in submodule `db.db_1`: ``` from spam import db submodule_name = "db_1" func_name = "prepare_db" func = ... ``` how can I get the function by the submodule name and function name in the context above? **UPDATE**: To respond @histrio 's answer, I can verify his code works for...
2016/01/22
[ "https://Stackoverflow.com/questions/34939762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/489564/" ]
It's simple. You can consider module as object. ``` import os submodule_name = "path" func_name = "exists" submodule = getattr(os, submodule_name) function = getattr(submodule, func_name) function('/home') # True ``` or [just for fun, don't do that] ``` fn = reduce(getattr, ('sub1', 'sub2', 'sub3', 'fn'), module)...
I think I figured it out, you need to add the function to the `__all__` variable in the `__init__.py` file, so that would be something along the lines of: ``` from .db_1 import prepare_db __all__ = ['prepare_db'] ``` After that, it should work just fine.
54,833,296
I am using spyder python 2.7 and i changed the syntax coloring in Spyder black theme, but i really want my python programme to look in full black, so WITHOUT the white windows. Can someone provide me a good explanation about how to change this? [Python example of how i want it to be](https://i.stack.imgur.com/MO17A....
2019/02/22
[ "https://Stackoverflow.com/questions/54833296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11103122/" ]
If you can't wait for Spyder 4 - this is what does it for **Spyder 3.3.2 in Windows, using Anaconda3**. 1. Exit Spyder 2. Open command prompt or Anaconda prompt 3. Run `pip install qdarkstyle` and exit the prompt 4. Go to ...\Anaconda3\Lib\site-packages\spyder\utils and open *qhelpers.py* 5. Add `import qdarkstyle` to...
(*Spyder maintainer here*) This functionality will be available in Spyder **4**, to be released later in 2019. For now there's nothing you can do to get what you want with Spyder's current version, sorry.
54,833,296
I am using spyder python 2.7 and i changed the syntax coloring in Spyder black theme, but i really want my python programme to look in full black, so WITHOUT the white windows. Can someone provide me a good explanation about how to change this? [Python example of how i want it to be](https://i.stack.imgur.com/MO17A....
2019/02/22
[ "https://Stackoverflow.com/questions/54833296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11103122/" ]
The complete dark theme is available from Spyder 4.0.0 beta <https://github.com/spyder-ide/spyder/releases> How I did it : 1) In Anaconda prompt, ``` conda update qt pyqt conda install -c spyder-ide spyder=4.0.0b2 ``` 2) And if you haven't done it before, go to ``` Tools > Preferences > Syntax Coloring ```
(*Spyder maintainer here*) This functionality will be available in Spyder **4**, to be released later in 2019. For now there's nothing you can do to get what you want with Spyder's current version, sorry.
54,833,296
I am using spyder python 2.7 and i changed the syntax coloring in Spyder black theme, but i really want my python programme to look in full black, so WITHOUT the white windows. Can someone provide me a good explanation about how to change this? [Python example of how i want it to be](https://i.stack.imgur.com/MO17A....
2019/02/22
[ "https://Stackoverflow.com/questions/54833296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11103122/" ]
The complete dark theme is available from Spyder 4.0.0 beta <https://github.com/spyder-ide/spyder/releases> How I did it : 1) In Anaconda prompt, ``` conda update qt pyqt conda install -c spyder-ide spyder=4.0.0b2 ``` 2) And if you haven't done it before, go to ``` Tools > Preferences > Syntax Coloring ```
If you can't wait for Spyder 4 - this is what does it for **Spyder 3.3.2 in Windows, using Anaconda3**. 1. Exit Spyder 2. Open command prompt or Anaconda prompt 3. Run `pip install qdarkstyle` and exit the prompt 4. Go to ...\Anaconda3\Lib\site-packages\spyder\utils and open *qhelpers.py* 5. Add `import qdarkstyle` to...
54,833,296
I am using spyder python 2.7 and i changed the syntax coloring in Spyder black theme, but i really want my python programme to look in full black, so WITHOUT the white windows. Can someone provide me a good explanation about how to change this? [Python example of how i want it to be](https://i.stack.imgur.com/MO17A....
2019/02/22
[ "https://Stackoverflow.com/questions/54833296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11103122/" ]
If you can't wait for Spyder 4 - this is what does it for **Spyder 3.3.2 in Windows, using Anaconda3**. 1. Exit Spyder 2. Open command prompt or Anaconda prompt 3. Run `pip install qdarkstyle` and exit the prompt 4. Go to ...\Anaconda3\Lib\site-packages\spyder\utils and open *qhelpers.py* 5. Add `import qdarkstyle` to...
Spyder 4 is out now. Dark mode is included ✌ Have a look at the changes: <https://github.com/spyder-ide/spyder/blob/master/CHANGELOG.md>
54,833,296
I am using spyder python 2.7 and i changed the syntax coloring in Spyder black theme, but i really want my python programme to look in full black, so WITHOUT the white windows. Can someone provide me a good explanation about how to change this? [Python example of how i want it to be](https://i.stack.imgur.com/MO17A....
2019/02/22
[ "https://Stackoverflow.com/questions/54833296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11103122/" ]
The complete dark theme is available from Spyder 4.0.0 beta <https://github.com/spyder-ide/spyder/releases> How I did it : 1) In Anaconda prompt, ``` conda update qt pyqt conda install -c spyder-ide spyder=4.0.0b2 ``` 2) And if you haven't done it before, go to ``` Tools > Preferences > Syntax Coloring ```
Spyder 4 is out now. Dark mode is included ✌ Have a look at the changes: <https://github.com/spyder-ide/spyder/blob/master/CHANGELOG.md>
51,839,083
I am using `MacOS`. I used following command: ``` gcloud beta functions deploy start --runtime python37 --trigger-http --memory 2048MB --timeout 540s ``` But while deploying `google cloud functions` I got this error: ``` (gcloud.beta.functions.deploy) OperationError: code=3, message=Build failed: USER ERROR: pi...
2018/08/14
[ "https://Stackoverflow.com/questions/51839083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10223950/" ]
Do you have a Pipfile in your directory? I was able to replicate this same error when I tried to deploy a GCF containing a Pipfile but no accompanying Pipfile.lock. To fix, either remove Pipfile and just include requirements.txt, or generate Pipfile.lock: `$ pipenv install` without the --skip-lock flag While the curr...
According to the google cloud function [documentation](https://cloud.google.com/appengine/docs/standard/python3/runtime#dependencies) it only supports installing dependency from `requirements.txt` file. And the file `Pipfile/Pipfile.lock` must not be present in the root directory.
1,611,625
I only just noticed this feature today! ``` s={1,2,3} #Set initialisation t={x for x in s if x!=3} #Set comprehension t=={1,2} ``` What version is it in? I also noticed that it has set comprehension. Was this added in the same version? **Resources** * [Sets in Python 2.4 Docs](http://docs.python.org/library/stdty...
2009/10/23
[ "https://Stackoverflow.com/questions/1611625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/165495/" ]
The `sets` module was added in Python 2.3, but the built-in set type was added to the language in 2.4, with essentially the same interface. (As of 2.6, the `sets` module has been deprecated.) So you can use sets as far back as 2.3, as long as you ``` import sets ``` But you will get a `DeprecationWarning` if you tr...
Well, testing it: ``` >>> s = {1, 2, 3} File "<stdin>", line 1 s = {1, 2, 3} ^ SyntaxError: invalid syntax ``` I'm running 2.5, so I would assume that this syntax was added sometime in 2.6 (Update: actually added in 3.0, but Ian beat me). I should probably be upgrading sometime soon. I'm glad they ad...
1,611,625
I only just noticed this feature today! ``` s={1,2,3} #Set initialisation t={x for x in s if x!=3} #Set comprehension t=={1,2} ``` What version is it in? I also noticed that it has set comprehension. Was this added in the same version? **Resources** * [Sets in Python 2.4 Docs](http://docs.python.org/library/stdty...
2009/10/23
[ "https://Stackoverflow.com/questions/1611625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/165495/" ]
The `sets` module was added in Python 2.3, but the built-in set type was added to the language in 2.4, with essentially the same interface. (As of 2.6, the `sets` module has been deprecated.) So you can use sets as far back as 2.3, as long as you ``` import sets ``` But you will get a `DeprecationWarning` if you tr...
The set literal and set and dict comprehension syntaxes were backported to 2.x trunk, about 2-3 days ago. So I guess this feature should be available from python 2.7.
12,698,646
How can I create a list of methods in python to be applied to an object? Given some arbitrary class: ``` class someClass: def __init__(self, s): self.size = s def shrink(self): self.size -= 1 def grow(self): self.size += 1 def invert(self): self.size = -self.size ``...
2012/10/02
[ "https://Stackoverflow.com/questions/12698646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175133/" ]
You could create a list of the method *names* then use [`getattr()`](https://docs.python.org/3/library/functions.html#getattr) to access the methods: ``` instructions = ["shrink", "grow", "shrink"] for i in instructions: getattr(elephant, i)() ```
Possibly naïvely: ``` for ins in instructions: getattr(elephant, ins)() ``` Gotchas include that `ins` must be a string and that it's probably wise to validate both that `ins` is what you really want to call and that `getattr(elephant, ins)` is a callable.
12,698,646
How can I create a list of methods in python to be applied to an object? Given some arbitrary class: ``` class someClass: def __init__(self, s): self.size = s def shrink(self): self.size -= 1 def grow(self): self.size += 1 def invert(self): self.size = -self.size ``...
2012/10/02
[ "https://Stackoverflow.com/questions/12698646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175133/" ]
You could create a list of the method *names* then use [`getattr()`](https://docs.python.org/3/library/functions.html#getattr) to access the methods: ``` instructions = ["shrink", "grow", "shrink"] for i in instructions: getattr(elephant, i)() ```
You can use [`dir`](http://docs.python.org/library/functions.html#dir) to get all property names of an object, and [`getattr`](http://docs.python.org/library/functions.html#getattr) to get a property value of an object. You may also want to not call any non-[callable](http://docs.python.org/library/functions.html#calla...
12,698,646
How can I create a list of methods in python to be applied to an object? Given some arbitrary class: ``` class someClass: def __init__(self, s): self.size = s def shrink(self): self.size -= 1 def grow(self): self.size += 1 def invert(self): self.size = -self.size ``...
2012/10/02
[ "https://Stackoverflow.com/questions/12698646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175133/" ]
You could create a list of the method *names* then use [`getattr()`](https://docs.python.org/3/library/functions.html#getattr) to access the methods: ``` instructions = ["shrink", "grow", "shrink"] for i in instructions: getattr(elephant, i)() ```
As an alternative to using strings for your list of instructions, you could do the following: ``` instructions = [someClass.shrink, someClass.grow, someClass.shrink, someClass.shrink, someClass.grow, someClass.invert] elephant = someClass(90) sizeList = [] for ins in instructions: ins(elephant) ...
12,698,646
How can I create a list of methods in python to be applied to an object? Given some arbitrary class: ``` class someClass: def __init__(self, s): self.size = s def shrink(self): self.size -= 1 def grow(self): self.size += 1 def invert(self): self.size = -self.size ``...
2012/10/02
[ "https://Stackoverflow.com/questions/12698646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175133/" ]
As an alternative to using strings for your list of instructions, you could do the following: ``` instructions = [someClass.shrink, someClass.grow, someClass.shrink, someClass.shrink, someClass.grow, someClass.invert] elephant = someClass(90) sizeList = [] for ins in instructions: ins(elephant) ...
Possibly naïvely: ``` for ins in instructions: getattr(elephant, ins)() ``` Gotchas include that `ins` must be a string and that it's probably wise to validate both that `ins` is what you really want to call and that `getattr(elephant, ins)` is a callable.
12,698,646
How can I create a list of methods in python to be applied to an object? Given some arbitrary class: ``` class someClass: def __init__(self, s): self.size = s def shrink(self): self.size -= 1 def grow(self): self.size += 1 def invert(self): self.size = -self.size ``...
2012/10/02
[ "https://Stackoverflow.com/questions/12698646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175133/" ]
As an alternative to using strings for your list of instructions, you could do the following: ``` instructions = [someClass.shrink, someClass.grow, someClass.shrink, someClass.shrink, someClass.grow, someClass.invert] elephant = someClass(90) sizeList = [] for ins in instructions: ins(elephant) ...
You can use [`dir`](http://docs.python.org/library/functions.html#dir) to get all property names of an object, and [`getattr`](http://docs.python.org/library/functions.html#getattr) to get a property value of an object. You may also want to not call any non-[callable](http://docs.python.org/library/functions.html#calla...
33,225,888
I'm new to python. I had a difficult time understanding why the output would be 2 for the problem below. Can someone explain it to be in very basic terms. ``` a = [1, 2, 3, 4, 0] b = [3, 0, 2, 4, 1] c = [3, 2, 4, 1, 5] print c[a[a[4]]] ```
2015/10/20
[ "https://Stackoverflow.com/questions/33225888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5464930/" ]
Maybe it helps understanding splitting it in 3 rows ? ``` inner_one = a[4] # a[4] = 0 inner_two = a[inner_one] # a[0] = 1 result = c[inner_two] # c[1] = 2 ```
Python lists are 0-indexed. So your first call, `a[4]`, returns `0`, then `a[0]` returns `1`, and finally `c[1]` returns `2`.
38,025,218
I am running python 2.7 and django 1.8. [I have this exact issue.](https://stackoverflow.com/questions/24983777/cant-add-a-new-field-in-migration-column-does-not-exist) The answer, posted as a comment is: `What I did is completely remake the db, erase the migration history and folders.` I am very uncertain about del...
2016/06/25
[ "https://Stackoverflow.com/questions/38025218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1261774/" ]
You can create a separate interface for your static needs: ``` interface IPerson { name: string; getName(): string; } class Person implements IPerson { public name: string; constructor(name: string) { this.name = name; } public getName() { return this.name; } public ...
I added `IPersonConstructor` to your example. The rest is identical; just included for clarity. `new (arg1: typeOfArg1, ...): TypeOfInstance;` describes a class, since it can be invoked with `new` and will return an instance of the class. ``` interface IPerson { name: string; getName(): string; } class Perso...
38,025,218
I am running python 2.7 and django 1.8. [I have this exact issue.](https://stackoverflow.com/questions/24983777/cant-add-a-new-field-in-migration-column-does-not-exist) The answer, posted as a comment is: `What I did is completely remake the db, erase the migration history and folders.` I am very uncertain about del...
2016/06/25
[ "https://Stackoverflow.com/questions/38025218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1261774/" ]
You can create a separate interface for your static needs: ``` interface IPerson { name: string; getName(): string; } class Person implements IPerson { public name: string; constructor(name: string) { this.name = name; } public getName() { return this.name; } public ...
How about a generic ``` interface IConstructor<T> extends Function { new (...args: any[]): T; } ```
17,134,897
i'm using the popular pythonscript ( <http://code.google.com/p/edim-mobile/source/browse/trunk/ios/IncrementalLocalization/localize.py> ) to localize my storyboards in ios5. I did only some changes in storyboard and got this error: > > Please file a bug at <http://bugreport.apple.com> with this warning > message an...
2013/06/16
[ "https://Stackoverflow.com/questions/17134897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The second query is an example of an implicit cross join (aka Cartesian join) - every record from users will be joined to every record from roles with `id=5`, since all these combinations will have the `where` clause evaluate as true.
A join will be required to have correct data returned ``` SELECT u.username FROM users u JOIN roles r ON u.roleid = r.id WHERE r.id = 5; ``` I think is better to use explicit join with `ON` to dtermine which columns have relationship rather than using realtionship in `WHERE` clause
17,134,897
i'm using the popular pythonscript ( <http://code.google.com/p/edim-mobile/source/browse/trunk/ios/IncrementalLocalization/localize.py> ) to localize my storyboards in ios5. I did only some changes in storyboard and got this error: > > Please file a bug at <http://bugreport.apple.com> with this warning > message an...
2013/06/16
[ "https://Stackoverflow.com/questions/17134897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The second query is an example of an implicit cross join (aka Cartesian join) - every record from users will be joined to every record from roles with `id=5`, since all these combinations will have the `where` clause evaluate as true.
You need two columns of the same type one for each table to JOIN .You need the join-predicate `ON u.roleid = r.id` to get the correct data . > > Inner join creates a new result table by combining column values of two tables (A and B) based upon the join-predicate. The query compares each row of A with each row of B t...
17,134,897
i'm using the popular pythonscript ( <http://code.google.com/p/edim-mobile/source/browse/trunk/ios/IncrementalLocalization/localize.py> ) to localize my storyboards in ios5. I did only some changes in storyboard and got this error: > > Please file a bug at <http://bugreport.apple.com> with this warning > message an...
2013/06/16
[ "https://Stackoverflow.com/questions/17134897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The second query is an example of an implicit cross join (aka Cartesian join) - every record from users will be joined to every record from roles with `id=5`, since all these combinations will have the `where` clause evaluate as true.
No. In the second version you have no relationship between the tables. The `,` operator in the `from` clause means `cross join`. The second example will either return all users at least once (depending on the number of matched in the second table). Or it will return no rows (if there are no matches in the second table)...
63,336,300
My Tensorflow model makes heavy use of data preprocessing that should be done on the CPU to leave the GPU open for training. ``` top - 09:57:54 up 16:23, 1 user, load average: 3,67, 1,57, 0,67 Tasks: 400 total, 1 running, 399 sleeping, 0 stopped, 0 zombie %Cpu(s): 19,1 us, 2,8 sy, 0,0 ni, 78,1 id, 0,0 wa, ...
2020/08/10
[ "https://Stackoverflow.com/questions/63336300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9280994/" ]
Just setting the `set_intra_op_parallelism_threads` and `set_inter_op_parallelism_threads` wasn't working for me. Incase someone else is in the same place, after a lot of struggle with the same issue, below piece of code worked for me in limiting the CPU usage of tensorflow below 500%: ``` import os import tensorflo...
There can be many issues for this, I solved it for me the following way: Set `tf.config.threading.set_intra_op_parallelism_threads(<Your_Physical_Core_Count>) tf.config.threading.set_inter_op_parallelism_threads(<Your_Physical_Core_Count>)` both to your *physical* core count. You do not want Hyperthreading for highly...
1,544,535
I have to synchronize two different LDAP servers with different schemas. To make my life easier I'm searching for an object mapper for python like SQLobject/SQLAlchemy, but for LDAP. I found the following packages via pypi and google that might provide such functionality: * **pumpkin 0.1.0-beta1**: Pumpkin is LDAP ORM...
2009/10/09
[ "https://Stackoverflow.com/questions/1544535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179014/" ]
If I were you I would either use python-ldap or ldaptor. Python-ldap is a wrapper for OpenLDAP so you may have problems with using it on Windows unless you are able to build from source. LDAPtor, is pure python so you avoid that problem. Also, there is a very well written, and graphical description of ldaptor on the w...
Giving links to the projects in question would help a lot. Being the developer of [Python LDAP Object Mapper](https://launchpad.net/python-ldap-om), I can tell that it is quite dead at the moment. If you (or anybody else) is up for taking it over, you're welcome :)
1,544,535
I have to synchronize two different LDAP servers with different schemas. To make my life easier I'm searching for an object mapper for python like SQLobject/SQLAlchemy, but for LDAP. I found the following packages via pypi and google that might provide such functionality: * **pumpkin 0.1.0-beta1**: Pumpkin is LDAP ORM...
2009/10/09
[ "https://Stackoverflow.com/questions/1544535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179014/" ]
little late maybe... bda.ldap (<http://pypi.python.org/pypi/bda.ldap>) wraps again python-ldap to a more simple API than python-ldap itself provides. Further it transparently handles query caching of results due to bda.cache (<http://pypi.python.org/pypi/bda.cache>). Additionally it provides a LDAPNode object for bu...
Giving links to the projects in question would help a lot. Being the developer of [Python LDAP Object Mapper](https://launchpad.net/python-ldap-om), I can tell that it is quite dead at the moment. If you (or anybody else) is up for taking it over, you're welcome :)
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
@BaptisteM, Instead of using AsyncTask for this you can use Handler and Runnable like this, ``` private void startColorTimer() { mColorHandler.postDelayed(ColorRunnable, interval); timerOn = true; } private Handler mColorHandler = new Handler(); private Runnable ColorRunnable = new Runnable() { @Overrid...
The question have been asked, I started to answer it but a moderator closed it so I put my exemple here. This exemple change randomly the color of a TextView every 1000ms. The interval can be changed. ``` package com.your.package; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; ...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
try this you can use `TimerTask` :-> A task that can be scheduled for one-time or repeated execution by a Timer. **[TimerTask](https://developer.android.com/reference/java/util/TimerTask.html)** ``` Timer timer; timer = new Timer(); timer.scheduleAtFixedRate(new RemindTask(), 0, 3000); // delay*/ private class Remi...
The question have been asked, I started to answer it but a moderator closed it so I put my exemple here. This exemple change randomly the color of a TextView every 1000ms. The interval can be changed. ``` package com.your.package; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; ...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
@BaptisteM, Instead of using AsyncTask for this you can use Handler and Runnable like this, ``` private void startColorTimer() { mColorHandler.postDelayed(ColorRunnable, interval); timerOn = true; } private Handler mColorHandler = new Handler(); private Runnable ColorRunnable = new Runnable() { @Overrid...
You can use a Handler class: <https://developer.android.com/reference/android/os/Handler.html#postDelayed(java.lang.Runnable>, long) postHandler() counts the time on background and sends event to main thread when it's time. Also, you can use a recurrency: <https://en.wikipedia.org/wiki/Recursion_(computer_science)> ...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
@BaptisteM, Instead of using AsyncTask for this you can use Handler and Runnable like this, ``` private void startColorTimer() { mColorHandler.postDelayed(ColorRunnable, interval); timerOn = true; } private Handler mColorHandler = new Handler(); private Runnable ColorRunnable = new Runnable() { @Overrid...
You can use TimerTask to do so. start timer from onResume() ``` @Override public void onResume() { super.onResume(); startColor(); } ``` and stop timer from onStop() ``` @Override public void onStop() { super.onStop(); if (timer != null) timer.cancel(); ...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
@BaptisteM, Instead of using AsyncTask for this you can use Handler and Runnable like this, ``` private void startColorTimer() { mColorHandler.postDelayed(ColorRunnable, interval); timerOn = true; } private Handler mColorHandler = new Handler(); private Runnable ColorRunnable = new Runnable() { @Overrid...
you can do this: ``` Handler mHandler = new Handler(); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { mHandler.post(new Runnable() { @Override public void run() { //change color ...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
@BaptisteM, Instead of using AsyncTask for this you can use Handler and Runnable like this, ``` private void startColorTimer() { mColorHandler.postDelayed(ColorRunnable, interval); timerOn = true; } private Handler mColorHandler = new Handler(); private Runnable ColorRunnable = new Runnable() { @Overrid...
try this you can use `TimerTask` :-> A task that can be scheduled for one-time or repeated execution by a Timer. **[TimerTask](https://developer.android.com/reference/java/util/TimerTask.html)** ``` Timer timer; timer = new Timer(); timer.scheduleAtFixedRate(new RemindTask(), 0, 3000); // delay*/ private class Remi...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
try this you can use `TimerTask` :-> A task that can be scheduled for one-time or repeated execution by a Timer. **[TimerTask](https://developer.android.com/reference/java/util/TimerTask.html)** ``` Timer timer; timer = new Timer(); timer.scheduleAtFixedRate(new RemindTask(), 0, 3000); // delay*/ private class Remi...
You can use a Handler class: <https://developer.android.com/reference/android/os/Handler.html#postDelayed(java.lang.Runnable>, long) postHandler() counts the time on background and sends event to main thread when it's time. Also, you can use a recurrency: <https://en.wikipedia.org/wiki/Recursion_(computer_science)> ...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
try this you can use `TimerTask` :-> A task that can be scheduled for one-time or repeated execution by a Timer. **[TimerTask](https://developer.android.com/reference/java/util/TimerTask.html)** ``` Timer timer; timer = new Timer(); timer.scheduleAtFixedRate(new RemindTask(), 0, 3000); // delay*/ private class Remi...
You can use TimerTask to do so. start timer from onResume() ``` @Override public void onResume() { super.onResume(); startColor(); } ``` and stop timer from onStop() ``` @Override public void onStop() { super.onStop(); if (timer != null) timer.cancel(); ...
45,321,425
I am using python transitions module ([link](http://github.com/pytransitions/transitions)) to create finite state machine. How do I run this finite state machine forever? Bascically what I want is a fsm model which can stay "idle" when there is no more event to trigger. For examplel, in example.py: ``` state = [ '...
2017/07/26
[ "https://Stackoverflow.com/questions/45321425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8368519/" ]
try this you can use `TimerTask` :-> A task that can be scheduled for one-time or repeated execution by a Timer. **[TimerTask](https://developer.android.com/reference/java/util/TimerTask.html)** ``` Timer timer; timer = new Timer(); timer.scheduleAtFixedRate(new RemindTask(), 0, 3000); // delay*/ private class Remi...
you can do this: ``` Handler mHandler = new Handler(); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { mHandler.post(new Runnable() { @Override public void run() { //change color ...
44,753,426
I have a .csv file with two columns of interest 'latitude' and 'longitude' with populated values I would like to return [latitude, longitude] pairs of each row from the two columns as lists... [10.222, 20.445] [10.2555, 20.119] ... and so forth for each row of my csv... The problem with > import pandas colnames = ...
2017/06/26
[ "https://Stackoverflow.com/questions/44753426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8124002/" ]
Most basic way ``` import csv with open('filename.txt', 'r') as csvfile: spamreader = csv.reader(csvfile) for row in spamreader: print row ```
So from what I understand is that you want many lists of two elements: lat and long. However what you are receiving is two lists, one of lat and one of long. what I would do is loop over the length of those lists and then take that element in the lat/long lists and put them together in their own list. ``` for x in ra...
65,511,540
I am new to this world and I am starting to take my first steps in python. I am trying to extract in a single list the indices of certain values of my list (those that are greater than 10). When using append I get the following error and I don't understand where the error is. ```py dbs = [0, 1, 0, 0, 0, 0, 1, 0, 1, 23...
2020/12/30
[ "https://Stackoverflow.com/questions/65511540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14914879/" ]
You probably mean to write ``` for i, d in enumerate(dbs): if d > 10: exceed2.append(i) print(exceed2) ``` Few fixes here: * `append=()` is invalid syntax, you should just write `append()` * the `i, d` values from `enumerate()` are returning the values and indexes. You should be checking `d > 10`, since...
Welcome to this world :D the problem is that .append is actually a function that only takes one input, and appends this input to the very end of whatever list you provide. Try this instead: ``` dbs = [0, 1, 0, 0, 0, 0, 1, 0, 1, 23, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 20, 1, 1, 15, 1, 0, 0, 0, 40, 15, 0, 0] exceed2...
14,320,758
Is there a way to run an arbitrary method whenever a new thread is started in Python (2.7)? My goal is to use [setproctitle](http://pypi.python.org/pypi/setproctitle) to set an appropriate title for each spawned thread.
2013/01/14
[ "https://Stackoverflow.com/questions/14320758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186971/" ]
Just inherit from threading.Thread and use this class instead of Thread - as long as you have control over the Threads. ``` import threading class MyThread(threading.Thread): def __init__(self, callable, *args, **kwargs): super(MyThread, self).__init__(*args, **kwargs) self._call_on_start = callab...
Use `threading.setprofile`. You give it your callback and Python will invoke it every time a new thread starts. Documentation [here](https://docs.python.org/2/library/threading.html).
40,879,394
I am new to python and pydev. I have tensorflow source and am able to run the example files using python3 /pathtoexamplefile.py. I want to try to step thru the word2vec\_basic.py code inside pydev. The debuger keep throwing File "/Users/me/workspace/tensorflow/tensorflow/python/**init**.py", line 45, in from tensor...
2016/11/30
[ "https://Stackoverflow.com/questions/40879394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1058511/" ]
``` SELECT StockNo FROM sales GROUP BY StockNo HAVING SUM(CASE WHEN DATE_FORMAT(Date, '%Y-%m') = '2016-11' THEN 1 ELSE 0 END) > 0 ``` If you also want to retrieve the full records for those matching stock numbers in the above query, you can just add a join: ``` SELECT s1.* FROM sales s1 INNER JOIN ( SELECT Stock...
Thank you very much Tim for pointing me in the right direction. Your answer was close but it still only returned records from the current month and in the end I used the following query: ``` SELECT s1.* FROM `sales` s1 INNER JOIN ( SELECT * FROM `sales` GROUP BY `StockNo` HAVING COUNT(`StockNo`) > 1 AND SUM(CA...
73,027,674
I have a Vertex AI notebook that contains a lot of python and jupyter notebook as well as pickled data files in it. I need to move these files to another notebook. There isn't a lot of documentation on google's help center. Has someone had to do this yet? I'm new to GCP.
2022/07/18
[ "https://Stackoverflow.com/questions/73027674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5917787/" ]
Can you try these steps in this [article](https://cloud.google.com/vertex-ai/docs/workbench/user-managed/migrate). It says you can copy your files to a [Google Cloud Storage Bucket](https://cloud.google.com/storage/) then move it to a new notebook by using gsutil tool. In your notebook's terminal run this code to copy...
I'm assuming that both notebooks are on the same GC project and that you have the same permissions on both, ok? There are many ways to do that... Listing some here: 1. The hardest to execute, but the simplest by concept: You can download everything for your computer/workstation from the original notebook instance, th...
1,997,327
Given this python code: ``` import webbrowser webbrowser.open("http://slashdot.org",new=0) webbrowser.open("http://cnn.com",new=0) ``` I would expect a browser to open up, load the first website, then load the second website *in the same window*. However, it opens up in a new window (or new tab depending on which br...
2010/01/04
[ "https://Stackoverflow.com/questions/1997327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83879/" ]
Note that the documentation specifically avoids guarantees with the language *if possible*: <http://docs.python.org/library/webbrowser.html#webbrowser.open> Most browser settings by default specify tab behavior and will not allow Python to override it. I have seen it in the past using Firefox and tried your example on...
I added a delay between successive invocations of `webbrowser.open()`. Then each was opened in a new tab instead of a separate window (on my Windows 10 machine). ```py import time ... time.sleep(0.5) ```
27,214,901
Please consider the following short Python 2.x script: ``` #!/usr/bin/env python class A(object): class B(object): class C(object): pass def __init__(self): self.c = A.B.C() def __init__(self): self.b = A.B() def main(): a = A() print "%s: %r" % (type(a)...
2014/11/30
[ "https://Stackoverflow.com/questions/27214901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476371/" ]
Here are two demonstrative programs one for C++ 2003 and other for C++ 2011 that do the search **C++ 2003** ``` #include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> struct FindName : std::unary_function<bool, cons...
I strongly advise you to use a data structure with an overloaded equality operator instead of `vector<string>` (especially since it seems like the third element should be saved in an integer, not a string). Anyway, this is one possibility: ``` auto iter = std::find_if( std::begin(a_words), std::end(a_words), ...
27,214,901
Please consider the following short Python 2.x script: ``` #!/usr/bin/env python class A(object): class B(object): class C(object): pass def __init__(self): self.c = A.B.C() def __init__(self): self.b = A.B() def main(): a = A() print "%s: %r" % (type(a)...
2014/11/30
[ "https://Stackoverflow.com/questions/27214901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476371/" ]
Here are two demonstrative programs one for C++ 2003 and other for C++ 2011 that do the search **C++ 2003** ``` #include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> struct FindName : std::unary_function<bool, cons...
As of C++11, a range based for loop would be a simple and readable solution: ``` for(auto r: a_words) if(r[0] == "Joan" && r[1] == "Williams") cout << r[0] << " " << r[1] << " " << r[2] << endl; ```
27,214,901
Please consider the following short Python 2.x script: ``` #!/usr/bin/env python class A(object): class B(object): class C(object): pass def __init__(self): self.c = A.B.C() def __init__(self): self.b = A.B() def main(): a = A() print "%s: %r" % (type(a)...
2014/11/30
[ "https://Stackoverflow.com/questions/27214901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476371/" ]
Here are two demonstrative programs one for C++ 2003 and other for C++ 2011 that do the search **C++ 2003** ``` #include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <functional> struct FindName : std::unary_function<bool, cons...
Essentially the answer of @Columbo is nice, eliminating C++ 11 features (besides initialization): ``` #include <algorithm> #include <iostream> #include <string> #include <vector> int main() { // Requires C++11 std::vector<std::vector<std::string>> words = { { "Joan", "Williams", "30" }, { "Mi...
24,804,667
I'm trying to wrap a C library for python using SWIG. I'm on a linux 64-bit sytem (Gentoo) using the standard system toolchain. The library (SUNDIALS) is installed on my system with shared libraries in `/usr/local/lib` My interface file is simple (to start with) ``` %module nvecserial %{ #include "sundials/sundials_...
2014/07/17
[ "https://Stackoverflow.com/questions/24804667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184986/" ]
We'll I've got it working by linking in an extra library. It seems `libsundials_nvecserial.so` and brethren don't contain the symbol N\_VLinearSum. The SUNDIALS make process places functions and symbols from `sundials_nvector.h` into different .so files, somewhat counter intuitively. For now, I got this working with ...
Instead of ``` gcc -shared /usr/local/lib/libsundials_nvecserial.so nvecserial_wrap.o -o _nvecserial.so ``` try ``` gcc -shared -L/usr/local/lib nvecserial_wrap.o -o _nvecserial.so -lsundials_nvecserial ``` The -l should be at end otherwise the lib may not be searched for symbols. This is explained in the ld ma...
38,791,685
I want to generate a single executable file from my python script. For this I use pyinstaller. I had issues with mkl libraries because I use numpy in the script. I used this [hook](https://github.com/pyinstaller/pyinstaller/issues/1881 "hook") so solve the issue, it worked fine. But it does not work if I copy the sing...
2016/08/05
[ "https://Stackoverflow.com/questions/38791685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5521383/" ]
When I faced problem described here <https://github.com/ContinuumIO/anaconda-issues/issues/443> my workaround was `pyinstaller -F --add-data vcruntime140.dll;. myscript.py` `-F` - collect into one *\*.exe* file `.` - Destination path of dll in exe file from docs <http://pyinstaller.readthedocs.io/en/stable/spec-fi...
As the selected answer didn't work for the case of using **libportaudio64bit.dll**, I put my working solution here. For me, the working solution is to add **\_sounddevice\_data** folder where the .exe file is located then making a **portaudio-binaries** folder in it and finally putting **libportaudio64bit.dll** in the...
38,791,685
I want to generate a single executable file from my python script. For this I use pyinstaller. I had issues with mkl libraries because I use numpy in the script. I used this [hook](https://github.com/pyinstaller/pyinstaller/issues/1881 "hook") so solve the issue, it worked fine. But it does not work if I copy the sing...
2016/08/05
[ "https://Stackoverflow.com/questions/38791685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5521383/" ]
When I faced problem described here <https://github.com/ContinuumIO/anaconda-issues/issues/443> my workaround was `pyinstaller -F --add-data vcruntime140.dll;. myscript.py` `-F` - collect into one *\*.exe* file `.` - Destination path of dll in exe file from docs <http://pyinstaller.readthedocs.io/en/stable/spec-fi...
Add the current project folder to Path, then Create EXE using following command: ``` pyinstaller --add-binary AutoItX3_x64.dll;. program_name.py ``` Create folder `\dist\program_name\autoit\lib` in tge current project folder, and paste `AutoItX3_x64.dll` in it.
38,791,685
I want to generate a single executable file from my python script. For this I use pyinstaller. I had issues with mkl libraries because I use numpy in the script. I used this [hook](https://github.com/pyinstaller/pyinstaller/issues/1881 "hook") so solve the issue, it worked fine. But it does not work if I copy the sing...
2016/08/05
[ "https://Stackoverflow.com/questions/38791685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5521383/" ]
When I faced problem described here <https://github.com/ContinuumIO/anaconda-issues/issues/443> my workaround was `pyinstaller -F --add-data vcruntime140.dll;. myscript.py` `-F` - collect into one *\*.exe* file `.` - Destination path of dll in exe file from docs <http://pyinstaller.readthedocs.io/en/stable/spec-fi...
Here is a modified version of Ilya's answer. `pyinstaller --onefile --add-binary ".venv/Lib/site-packages/example_package/example.dll;." myscript.py` It wasn't clear to me when first stumbling into this issue that you must tell PyInstaller exactly where to find the given file (either via relative or absolute path) if...
38,791,685
I want to generate a single executable file from my python script. For this I use pyinstaller. I had issues with mkl libraries because I use numpy in the script. I used this [hook](https://github.com/pyinstaller/pyinstaller/issues/1881 "hook") so solve the issue, it worked fine. But it does not work if I copy the sing...
2016/08/05
[ "https://Stackoverflow.com/questions/38791685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5521383/" ]
Add the current project folder to Path, then Create EXE using following command: ``` pyinstaller --add-binary AutoItX3_x64.dll;. program_name.py ``` Create folder `\dist\program_name\autoit\lib` in tge current project folder, and paste `AutoItX3_x64.dll` in it.
As the selected answer didn't work for the case of using **libportaudio64bit.dll**, I put my working solution here. For me, the working solution is to add **\_sounddevice\_data** folder where the .exe file is located then making a **portaudio-binaries** folder in it and finally putting **libportaudio64bit.dll** in the...
38,791,685
I want to generate a single executable file from my python script. For this I use pyinstaller. I had issues with mkl libraries because I use numpy in the script. I used this [hook](https://github.com/pyinstaller/pyinstaller/issues/1881 "hook") so solve the issue, it worked fine. But it does not work if I copy the sing...
2016/08/05
[ "https://Stackoverflow.com/questions/38791685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5521383/" ]
Add the current project folder to Path, then Create EXE using following command: ``` pyinstaller --add-binary AutoItX3_x64.dll;. program_name.py ``` Create folder `\dist\program_name\autoit\lib` in tge current project folder, and paste `AutoItX3_x64.dll` in it.
Here is a modified version of Ilya's answer. `pyinstaller --onefile --add-binary ".venv/Lib/site-packages/example_package/example.dll;." myscript.py` It wasn't clear to me when first stumbling into this issue that you must tell PyInstaller exactly where to find the given file (either via relative or absolute path) if...
10,550,870
I have some Pickled data, which is stored on disk, and it is about 100 MB in size. When my python program is executed, the picked data is loaded using the `cPickle` module, and all that works fine. If I execute the python multiple times using `python main.py` for example, each python process will load the same data m...
2012/05/11
[ "https://Stackoverflow.com/questions/10550870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/406930/" ]
If you're on Unix, one possibility is to load the data into memory, and then have the script use [`os.fork()`](http://docs.python.org/library/os.html#os.fork) to create a bunch of sub-processes. As long as the sub-processes don't attempt to *modify* the data, they would automatically share the parent's copy of it, with...
Depending on how seriously you need to solve this problem, you may want to look at memcached, if that is not overkill.
41,612,654
I got an error after I modified the User Model in django. when I was going to create a super user, it didn't prompt for username, instead it skipped it, anyway the object propery username still required and causing the user creation to failed. ``` import jwt from django.db import models from django.contrib.auth.model...
2017/01/12
[ "https://Stackoverflow.com/questions/41612654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3465227/" ]
`REQUIRED_FIELD` should be `REQUIRED_FIELDS` (plural), otherwise you won't be prompted for a username (or any other required fields) because Django did not find anything in `REQUIRED_FIELDS`. As an example, I use this UserManager in one of my projects: ``` class UserManager(BaseUserManager): def create_user(self,...
This bit doesn't make sense: ``` USERNAME_FIELD = 'email' REQUIRED_FIELD = ['username'] ``` Why have you set `USERNAME_FIELD` to "email"? Surely it should be "username".
48,617,779
I am receiving the error: `ImportError: No module named MySQLdb` whenever I try to run my local dev server and it is driving me crazy. I have tried everything I could find online: 1. `brew install mysql` 2. `pip install mysqldb` 3. `pip install mysql` 4. `pip install mysql-python` 5. `pip install MySQL-python` 6. `eas...
2018/02/05
[ "https://Stackoverflow.com/questions/48617779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4918575/" ]
When you are in the virtual env (`source venv/bin/activate`), just run in terminal: ``` sudo apt-get install python3-mysqldb sudo apt-get install libmysqlclient-dev pip install mysqlclient ``` You don't have to import anything in your py files. The first one is just in case, but the other two work perfectly by them...
Turns out I had the wrong python being pointed to in my virtualenv. It comes preinstalled with its own default python version and so, I created a new virtualenv and used the `-p` to set the python path to my own local python path.
48,617,779
I am receiving the error: `ImportError: No module named MySQLdb` whenever I try to run my local dev server and it is driving me crazy. I have tried everything I could find online: 1. `brew install mysql` 2. `pip install mysqldb` 3. `pip install mysql` 4. `pip install mysql-python` 5. `pip install MySQL-python` 6. `eas...
2018/02/05
[ "https://Stackoverflow.com/questions/48617779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4918575/" ]
When you are in the virtual env (`source venv/bin/activate`), just run in terminal: ``` sudo apt-get install python3-mysqldb sudo apt-get install libmysqlclient-dev pip install mysqlclient ``` You don't have to import anything in your py files. The first one is just in case, but the other two work perfectly by them...
In my project, with virtualenv, I just did > > pip install mysqlclient > > > and like magic everything is ok
21,807,660
I am trying to run the first example [here](http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html), but I am getting this error. I am using Ubuntu 13.10. ``` Failed to load OpenCL runtime OpenCV Error: Unknown error code -220 (OpenCL function is not availab...
2014/02/16
[ "https://Stackoverflow.com/questions/21807660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1852142/" ]
As for the OpenCL failure, try installing required packages: `sudo apt-get install ocl-icd-opencl-dev` Worked for me. My guess is that OCL is a part of the `opencv_core` module, and if it failed to initialise, then many other components might behave strange.
> > Failed to load OpenCL runtime > > > Most probably there is some problem with your installation. If you are not working with GPU, then I recommend you to turn off all CUDA/OpenCL modules in OpenCV during compilation. > > error: (-215) scn == 3 || scn == 4 in function cvtColor > > > This error says your in...
21,807,660
I am trying to run the first example [here](http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html), but I am getting this error. I am using Ubuntu 13.10. ``` Failed to load OpenCL runtime OpenCV Error: Unknown error code -220 (OpenCL function is not availab...
2014/02/16
[ "https://Stackoverflow.com/questions/21807660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1852142/" ]
As for the OpenCL failure, try installing required packages: `sudo apt-get install ocl-icd-opencl-dev` Worked for me. My guess is that OCL is a part of the `opencv_core` module, and if it failed to initialise, then many other components might behave strange.
You might want to install/update the driver: <http://streamcomputing.eu/blog/2011-12-29/opencl-hardware-support/> Updating the driver help to solve my problem with OpenCL
54,140,922
I want to create a multiprocessing echo server. I am currently using telnet as my client to send messages to my echo server.Currently I can handle one telnet request and it echos the response. I initially, thought I should intialize the pid whenever I create a socket. Is that correct? How do I allow several clients to...
2019/01/11
[ "https://Stackoverflow.com/questions/54140922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9005618/" ]
It's probably a good idea to understand which are blocking system calls and which are not. `listen` for example is not blocking and `accept` is blocking one. So basically - you created one process through `Process(..)`, that blocks at the `accept` and when a connection is made - handles that connection. Your code sho...
The initial part of setting up the server, binding, listening etc (your `create_socket`) should be in the master process. Once you `accept` and get a socket, you should spawn off a separate process to take care of that connection. In other words, your `start_socket` should be spawned off in a separate process and sho...
23,922,691
I am trying to add argv[0] as variable to the SQL query below and running into compilation error below,what is the syntax to fix this? ``` #!/usr/bin/python import pypyodbc as pyodbc from sys import argv component_id=argv[0] server_name='odsdb.company.com' database_name='ODS' cnx = pyodbc.connect("DRIVER={SQL Ser...
2014/05/28
[ "https://Stackoverflow.com/questions/23922691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3654069/" ]
Don't use string interpolation. Use SQL parameters; these are placeholders in the query where your database will insert values: ``` SQL = '''\ SELECT Top 1 cr.ReleaseLabel FROM [ODS].[v000001].[ComponentRevisions] cr WHERE cr.ComponentId = ? ORDER BY cr.CreatedOn DESC ''' resp_rows_obj = db_cursor.exec...
to retrieve 1st command line argument do `component_id=argv[1]` instead of 0 which is the script name... better yet, look at [argparse](https://docs.python.org/2/howto/argparse.html)
23,922,691
I am trying to add argv[0] as variable to the SQL query below and running into compilation error below,what is the syntax to fix this? ``` #!/usr/bin/python import pypyodbc as pyodbc from sys import argv component_id=argv[0] server_name='odsdb.company.com' database_name='ODS' cnx = pyodbc.connect("DRIVER={SQL Ser...
2014/05/28
[ "https://Stackoverflow.com/questions/23922691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3654069/" ]
Don't use string interpolation. Use SQL parameters; these are placeholders in the query where your database will insert values: ``` SQL = '''\ SELECT Top 1 cr.ReleaseLabel FROM [ODS].[v000001].[ComponentRevisions] cr WHERE cr.ComponentId = ? ORDER BY cr.CreatedOn DESC ''' resp_rows_obj = db_cursor.exec...
We had a hyphen in the database name that was being used in a T-SQL query being called from Python code. So we just added square brackets because SQL Server cannot interpolate the hyphen without them. Before: ``` SELECT * FROM DBMS-NAME.dbo.TABLE_NAME ``` After: ``` SELECT * FROM [DBMS-NAME].dbo.TABLE_NAME ```
24,093,888
I am looking to do a large number of reverse DNS lookups in a small amount of time. I currently have implemented an asynchronous lookup using socket.gethostbyaddr and concurrent.futures thread pool, but am still not seeing the desired performance. For example, the script took about 22 minutes to complete on 2500 IP add...
2014/06/07
[ "https://Stackoverflow.com/questions/24093888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2521829/" ]
Because of the [Global Interpreter Lock](https://docs.python.org/dev/glossary.html#term-global-interpreter-lock), you should use `ProcessPoolExecutor` instead. <https://docs.python.org/dev/library/concurrent.futures.html#processpoolexecutor>
please, use [asynchronous DNS](http://code.google.com/p/adns-python/), everything else will give you a very poor performance.
24,093,888
I am looking to do a large number of reverse DNS lookups in a small amount of time. I currently have implemented an asynchronous lookup using socket.gethostbyaddr and concurrent.futures thread pool, but am still not seeing the desired performance. For example, the script took about 22 minutes to complete on 2500 IP add...
2014/06/07
[ "https://Stackoverflow.com/questions/24093888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2521829/" ]
I discovered my main issue was IPs failing to resolve and thus sockets not obeying their set timeouts and failing after 30 seconds. See [Python 2.6 urlib2 timeout issue](https://stackoverflow.com/questions/14127115/python-2-6-urlib2-timeout-issue). *adns-python* was a no-go because of its lack of support for IPv6 (wit...
please, use [asynchronous DNS](http://code.google.com/p/adns-python/), everything else will give you a very poor performance.
24,093,888
I am looking to do a large number of reverse DNS lookups in a small amount of time. I currently have implemented an asynchronous lookup using socket.gethostbyaddr and concurrent.futures thread pool, but am still not seeing the desired performance. For example, the script took about 22 minutes to complete on 2500 IP add...
2014/06/07
[ "https://Stackoverflow.com/questions/24093888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2521829/" ]
I discovered my main issue was IPs failing to resolve and thus sockets not obeying their set timeouts and failing after 30 seconds. See [Python 2.6 urlib2 timeout issue](https://stackoverflow.com/questions/14127115/python-2-6-urlib2-timeout-issue). *adns-python* was a no-go because of its lack of support for IPv6 (wit...
Because of the [Global Interpreter Lock](https://docs.python.org/dev/glossary.html#term-global-interpreter-lock), you should use `ProcessPoolExecutor` instead. <https://docs.python.org/dev/library/concurrent.futures.html#processpoolexecutor>
61,380,858
I want to create pandas data frame with multiple lists with different length. Below is my python code. ``` import pandas as pd A=[1,2] B=[1,2,3] C=[1,2,3,4,5,6] lenA = len(A) lenB = len(B) lenC = len(C) df = pd.DataFrame(columns=['A', 'B','C']) for i,v1 in enumerate(A): for j,v2 in enumerate(B): for k,...
2020/04/23
[ "https://Stackoverflow.com/questions/61380858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1999109/" ]
You can add random values of each list to total length and then use [`DataFrame.sample`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sample.html): ``` A=[1,2] B=[1,2,3] C=[1,2,3,4,5,6] L = [A,B,C] m = max(len(x) for x in L) print (m) 6 a = [np.hstack((np.random.choice(x, m - len(x)), x...
You can use transpose to achieve the same. EDIT: Used random to randomize the output as requested. ``` import pandas as pd from random import shuffle, choice A=[1,2] B=[1,2,3] C=[1,2,3,4,5,6] shuffle(A) shuffle(B) shuffle(C) data = [A,B,C] df = pd.DataFrame(data) df = df.transpose() df.columns = ['A', 'B', 'C'] df....
47,726,664
I am trying to send messages from one python script to another using MQTT. One script is a publisher. The second script is a subscriber. I send messages every 0.1 second. Publisher: ``` client = mqtt.Client('DataReaderPub') client.connect('127.0.0.1', 1883, 60) print("MQTT parameters set.") # Read from all files co...
2017/12/09
[ "https://Stackoverflow.com/questions/47726664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2892909/" ]
You need to call the network loop function in the publisher as well so the client actually gets some time to do the IO (And the dual handshake for the QOS2). Add `client.loop()` after the call to `client.publish()` in the client: ``` import paho.mqtt.client as mqtt import time client = mqtt.Client('DataReaderPub') c...
When I ran your code, the subscriber was often missing the last packet. I was not otherwise able to reproduce the problems you described. If I rewrite the publisher like this instead... ``` from time import sleep import paho.mqtt.client as mqtt client = mqtt.Client('DataReaderPub') client.connect('127.0.0.1', 1883, ...
47,726,664
I am trying to send messages from one python script to another using MQTT. One script is a publisher. The second script is a subscriber. I send messages every 0.1 second. Publisher: ``` client = mqtt.Client('DataReaderPub') client.connect('127.0.0.1', 1883, 60) print("MQTT parameters set.") # Read from all files co...
2017/12/09
[ "https://Stackoverflow.com/questions/47726664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2892909/" ]
You need to call the network loop function in the publisher as well so the client actually gets some time to do the IO (And the dual handshake for the QOS2). Add `client.loop()` after the call to `client.publish()` in the client: ``` import paho.mqtt.client as mqtt import time client = mqtt.Client('DataReaderPub') c...
It turned out to be a silly bug. As hardillb suggested I looked at the broker logs. It showed that the subscriber client was already connected. I am using Pycharm after a really really long time. So I had accidentally ran publisher and subscriber so many times that they were running in parallel in the output console....
47,486,930
The following script generates a 2d list in python: ``` matrix = [[0 for row in range (5)] for col in range (5)] i = 2 matrix[i][i] = 1 matrix[i+1][i] = 1 matrix[i][i+1] = 1 matrix[i+1][i+1] = 1 for row in matrix: for item in row: print(item,end=" ") print() print() ``` The generated 2d list...
2017/11/25
[ "https://Stackoverflow.com/questions/47486930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3913519/" ]
In order for this combination to work you need to make sure your `virtual-repeat-container` is kept in sync. If you write a simple 'refresh' function that gets called on open select: ``` function () { return $timeout(function () { $scope.$broadcast("$md-resize"); }, 100); }; ``` it should be enough. ...
According to <https://github.com/angular/material/issues/10868> this post, different angularjs version has different behaviour. Return $timeout function should have also `window.dispatchEvent(new Event('resize'));` statement. Final $timeout function looks like this. ``` return $timeout(function() { $scope.$broadca...
55,399,396
My searches lead me to the Pywin32 which should be able to mute/unmute the sound and detect its state (on Windows 10, using Python 3+). I found a way using an AutoHotkey script, but I'm looking for a pythonic way. More specifically, I'm not interested in playing with the Windows GUI. *Pywin32 works using a Windows DLL...
2019/03/28
[ "https://Stackoverflow.com/questions/55399396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7227370/" ]
You can use the Windows Sound Manager by paradoxis (<https://github.com/Paradoxis/Windows-Sound-Manager>). ``` from sound import Sound Sound.mute() ``` Every call to `Sound.mute()` will toggle mute on or off. Have a look at the `main.py` to see how to use the setter and getter methods.
If you're also building a GUI, wxPython (and I would believe other GUI frameworks) have access to the windows audio mute "button".
10,868,410
I'm a little new to web crawlers and such, though I've been programming for a year already. So please bear with me as I try to explain my problem here. I'm parsing info from Yahoo! News, and I've managed to get most of what I want, but there's a little portion that has stumped me. For example: <http://news.yahoo.com/...
2012/06/03
[ "https://Stackoverflow.com/questions/10868410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1433227/" ]
The page is being generated via JavaScript. Check if there is a mobile version of the website first. If not, check for any APIs or RSS/Atom feeds. If there's *nothing* else, you'll either have to manually figure out what the JavaScript is loading and from where, or use [Selenium](http://seleniumhq.org/) to automate a ...
Using the Web Console in Firefox you can pretty easily see what requests the page is actually making as it runs its scripts, and figure out what URI returns the data you want. Then you can request that URI directly in your Python script and tease the data out of it. It is probably in a format that Python already has a ...
46,382,384
I'm playing around with [Chalice](http://chalice.readthedocs.io/en/latest/) for the first time as I am trying to evaluate it as a possible replacement framework to migrate my existing Python Flask APIs from EC2 to Lambda. From an Amazon Linux EC2 instance, I added some dependencies to a virtualenv I'm playing with. I ...
2017/09/23
[ "https://Stackoverflow.com/questions/46382384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2620746/" ]
You can remove "MySQL-python==1.2.5" from your requirements.txt (since it's already present in your vendor directory) See this [issue](https://github.com/aws/chalice/issues/626) in the Chalice repo for more info.
Looking at what you have in your directory listing you provided, I noticed you don't have a **init**.py file. This file identifies the folder as a library file. Put that in your vendors directory.
61,874,962
Running into installation error in python 3.8 for tensorflow and i'm wondering how to downgrade without losing my environments in pycharm.
2020/05/18
[ "https://Stackoverflow.com/questions/61874962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13435259/" ]
1. [Download](https://www.python.org/downloads/) and install Python 3.7 2. In PyCharm, go to 'File' -> 'Settings' -> 'Project: <...>' -> 'Project Interpreter', and select 'Python 3.7' in the 'Project Interpreter' dropdown. 3. If you don't see it, click on the settings icon next to it, go to the 'System Interpreter' tab...
Step1 : **Go to Preferences:** [![enter image description here](https://i.stack.imgur.com/IBt7K.png)](https://i.stack.imgur.com/IBt7K.png) Step 2: Go to Python Interpreter [![enter image description here](https://i.stack.imgur.com/S5bVB.png)](https://i.stack.imgur.com/S5bVB.png) Step 3: click Show All [![enter ima...
61,874,962
Running into installation error in python 3.8 for tensorflow and i'm wondering how to downgrade without losing my environments in pycharm.
2020/05/18
[ "https://Stackoverflow.com/questions/61874962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13435259/" ]
1. [Download](https://www.python.org/downloads/) and install Python 3.7 2. In PyCharm, go to 'File' -> 'Settings' -> 'Project: <...>' -> 'Project Interpreter', and select 'Python 3.7' in the 'Project Interpreter' dropdown. 3. If you don't see it, click on the settings icon next to it, go to the 'System Interpreter' tab...
Step 1: run following command on Terminal cse572 is the environment Name: ``` conda create -n cse572 python=3.7 scikit-learn=0.21.2 pandas=0.25.1 ``` Step 2: `conda activate cse572` Step 3: `python --version` should show python version 3.7