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
4,149,274
Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was a...
2010/11/10
[ "https://Stackoverflow.com/questions/4149274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/502486/" ]
In Windows Powershell use: python -m pydoc Examples: python -m pydoc open python -m pydoc raw\_input python -m pydoc argv
Based on your second edit, you may have more than one copy of pydoc.py in your path, with the 'wrong' one first such that when it starts up it doesn't have the correct environment in which to execute.
4,149,274
Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was a...
2010/11/10
[ "https://Stackoverflow.com/questions/4149274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/502486/" ]
When you type the name of a file at the windows command prompt, cmd can check the windows registry for the default file association, and use that program to open it. So if the Inkscape installer associated .py files with its own version of python, cmd might preferentially run that and ignore the PATH entirely. See [thi...
``` python -m pydoc -k/p/g/w <name> ```
4,149,274
Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was a...
2010/11/10
[ "https://Stackoverflow.com/questions/4149274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/502486/" ]
In Windows Powershell use: python -m pydoc Examples: python -m pydoc open python -m pydoc raw\_input python -m pydoc argv
When you type the name of a file at the windows command prompt, cmd can check the windows registry for the default file association, and use that program to open it. So if the Inkscape installer associated .py files with its own version of python, cmd might preferentially run that and ignore the PATH entirely. See [thi...
4,149,274
Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was a...
2010/11/10
[ "https://Stackoverflow.com/questions/4149274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/502486/" ]
When you type the name of a file at the windows command prompt, cmd can check the windows registry for the default file association, and use that program to open it. So if the Inkscape installer associated .py files with its own version of python, cmd might preferentially run that and ignore the PATH entirely. See [thi...
**Syntax for pydoc on windows:** alt1: > > C:\path\PythonXX\python.exe C:\path\PythonXX\Lib\pydoc.py -k/p/g/w X:\path\file\_to\_doc.py > > > alt2: > > python -m pydoc -k/p/g/w X:\path\file\_to\_doc.py > > > Of which the latter is the one to prefer, duh. However it requires your windows installation to have...
4,149,274
Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was a...
2010/11/10
[ "https://Stackoverflow.com/questions/4149274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/502486/" ]
In Windows Powershell use: python -m pydoc Examples: python -m pydoc open python -m pydoc raw\_input python -m pydoc argv
``` python -m pydoc -k/p/g/w <name> ```
4,149,274
Okay, I'm having one of those moments that makes me question my ability to use a computer. This is not the sort of question I imagined asking as my first SO post, but here goes. Started on Zed's new "Learn Python the Hard Way" since I've been looking to get back into programming after a 10 year hiatus and python was a...
2010/11/10
[ "https://Stackoverflow.com/questions/4149274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/502486/" ]
In Windows Powershell use: python -m pydoc Examples: python -m pydoc open python -m pydoc raw\_input python -m pydoc argv
**Syntax for pydoc on windows:** alt1: > > C:\path\PythonXX\python.exe C:\path\PythonXX\Lib\pydoc.py -k/p/g/w X:\path\file\_to\_doc.py > > > alt2: > > python -m pydoc -k/p/g/w X:\path\file\_to\_doc.py > > > Of which the latter is the one to prefer, duh. However it requires your windows installation to have...
68,272,509
I'm a Python beginner, and trying to improve my skill. Recently I read the source cord of some python packages, and found these codes. ``` while True: x = string_variable != -1 if x: time.sleep(1) else: break ``` So, what does the second line mean? You can find the original cord in 149t...
2021/07/06
[ "https://Stackoverflow.com/questions/68272509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15340967/" ]
Just to add here, the actual code you are looking at is not a simple string variable test like your example: ``` in_process = status_container.text.find(Constant.UPLOADED) != -1 ``` is effectively doing this: ``` string_var.find("foo") != -1 ``` which is looking for an occurrence of "foo" inside the string\_var. ...
This line has two operators ``` x = string_variable != -1 ``` `=` is assignment operator and `!=` is logical operator which means `NOT EQUALS` so, `x` will hold a boolean value based on the evaluation of the logical operator `!=`.
33,107,224
I have 5 astronomy images in python, each for a different wavelength, therefore they are of different angular resolutions and grid sizes and in order to compare them so that i can create temperature maps i need them to be the same angular resolution and grid size. I have managed to Gaussian convolve each image to the ...
2015/10/13
[ "https://Stackoverflow.com/questions/33107224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4596311/" ]
If the image headers have the correct World Coordinate System data, you can use the reproject package to resample the images: <http://reproject.readthedocs.org/en/stable/>
You can use FITS\_tools (<https://pypi.python.org/pypi/FITS_tools>, it can also be installed via `$ pip install FITS_TOOLS` in the anaconda distribution of python). Both images must have wcs in the header information. ``` import FITS_tools to_be_projected = 'fits_file_to_be_projected.fits' reference_fits = 'fits_fil...
9,577,252
In ipython, if I press 'esc' followed by 'enter' (and possibly other characters?), readline breaks. I can no longer search through command history using the 'up' key, and some commands (e.g., control-K) fail. Is there a way to reset readline within an ipython session? What is going on when I press these keys?
2012/03/06
[ "https://Stackoverflow.com/questions/9577252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814354/" ]
The poster's suggested answer doesn't seem to work for me in iPython 0.12+. I can run: ``` get_ipython().init_readline() ``` but that doesn't seem to help. However I noticed that I sometimes see similar problems in my iPython sessions. It appears that I had inadvertently switched from the default Emacs readline edi...
Got impatient. Solution is: ``` IPython.InteractiveShell.init_readline(get_ipython()) ``` Looks like this might be a known bug too: <http://www.catonmat.net/blog/bash-vi-editing-mode-cheat-sheet/>
40,327,136
[This is how I setted up my python3 envirnoment on Ubuntu 16.04.](https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-16-04) And I installed TensorFlow 0.8 with Virtualenv installation. [As I wanted to start TensorFlow tutorial MNIST For ML Beg...
2016/10/30
[ "https://Stackoverflow.com/questions/40327136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7090901/" ]
Sorry for the very late update, I had update tensorflow to the latest version. And I think I had some mistakes back then. Since I install the tensorflow via Virtualenv installation, so I should load tensorflow and other packages in Virtualenv environment. ``` source ~/tensorflow/bin/activate ``` Then run the exist...
Try installing it with PIP using ``` sudo apt-get install python-pip sudo pip install numpy==1.11.1 ``` or in your case use pip3 instead of pip for python 3 like ``` sudo apt-get install python3-pip sudo pip3 install numpy==1.11.1 ``` this will help
40,327,136
[This is how I setted up my python3 envirnoment on Ubuntu 16.04.](https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-16-04) And I installed TensorFlow 0.8 with Virtualenv installation. [As I wanted to start TensorFlow tutorial MNIST For ML Beg...
2016/10/30
[ "https://Stackoverflow.com/questions/40327136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7090901/" ]
Sorry for the very late update, I had update tensorflow to the latest version. And I think I had some mistakes back then. Since I install the tensorflow via Virtualenv installation, so I should load tensorflow and other packages in Virtualenv environment. ``` source ~/tensorflow/bin/activate ``` Then run the exist...
I suggest first installing [Anaconda](https://docs.continuum.io/anaconda/install#linux-install) (or miniconda) and installing with conda. Then you will all python dependencies taken care of automatically! The downside with installing with Anaconda is that there is no GPU support (yet). But if you're fine running on CPU...
12,197,806
I have this script which runs well in Python 2.7 but not in 2.6: ``` def main(): tempfile = '/tmp/tempfile' stats_URI="http://x.x.x.x/stats.json" hits_ = 0 advances_ = 0 requests = 0 failed = 0 as_data = urllib.urlopen(stats_URI).read() data = json.loads(as_data) for x, y in data['hits-se...
2012/08/30
[ "https://Stackoverflow.com/questions/12197806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1579819/" ]
When creating a `typedef` alias for a function pointer, the alias is in the function *name* position, so use: ``` typedef unsigned (__stdcall *task )(void *); ``` `task` is now a type alias for: *pointer to a function taking a `void` pointer and returning `unsigned`*.
Since hmjd's answer has been deleted... In C++11 a whole newsome *alias* syntax has been developed, to make such things much easier: ``` using task = unsigned (__stdcall*)(void*); ``` is equivalent the to `typedef unsigned (__stdcall* task)(void*);` (note the position of the alias in the middle of the function sign...
12,197,806
I have this script which runs well in Python 2.7 but not in 2.6: ``` def main(): tempfile = '/tmp/tempfile' stats_URI="http://x.x.x.x/stats.json" hits_ = 0 advances_ = 0 requests = 0 failed = 0 as_data = urllib.urlopen(stats_URI).read() data = json.loads(as_data) for x, y in data['hits-se...
2012/08/30
[ "https://Stackoverflow.com/questions/12197806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1579819/" ]
When creating a `typedef` alias for a function pointer, the alias is in the function *name* position, so use: ``` typedef unsigned (__stdcall *task )(void *); ``` `task` is now a type alias for: *pointer to a function taking a `void` pointer and returning `unsigned`*.
Sidenote: The `__stdcall` part might break your code under different compilers / compiler settings (unless the function is explicitly declared as `__stdcall`, too). I'd stick to the default calling convention only using proprietary compiler extensions having good reaons.
12,197,806
I have this script which runs well in Python 2.7 but not in 2.6: ``` def main(): tempfile = '/tmp/tempfile' stats_URI="http://x.x.x.x/stats.json" hits_ = 0 advances_ = 0 requests = 0 failed = 0 as_data = urllib.urlopen(stats_URI).read() data = json.loads(as_data) for x, y in data['hits-se...
2012/08/30
[ "https://Stackoverflow.com/questions/12197806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1579819/" ]
Since hmjd's answer has been deleted... In C++11 a whole newsome *alias* syntax has been developed, to make such things much easier: ``` using task = unsigned (__stdcall*)(void*); ``` is equivalent the to `typedef unsigned (__stdcall* task)(void*);` (note the position of the alias in the middle of the function sign...
Sidenote: The `__stdcall` part might break your code under different compilers / compiler settings (unless the function is explicitly declared as `__stdcall`, too). I'd stick to the default calling convention only using proprietary compiler extensions having good reaons.
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
add this to makefile: ``` # makefile git clone REPO cd REPO_DIR; python setup.py bdist_wheel cp REPO_DIR/dist/* . rm -rf REPO_DIR/ ``` add this to dockerfile: ``` # dockerfile RUN pip install REPO*.whl ``` and then the package is successfully installed within docker
can you `pip install` the git repo next to your source code and mount it together with your code into the container? ``` cd WORKING_DIRECTORY pip install --target ./ GIT_URL ```
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
``` RUN python -m pip install git+URL_OF_GIT_REPO ```
can you `pip install` the git repo next to your source code and mount it together with your code into the container? ``` cd WORKING_DIRECTORY pip install --target ./ GIT_URL ```
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
in your dockerfile put this code before installing requirements and you will be fine: ``` RUN apt-get update && apt-get install -y git ```
can you `pip install` the git repo next to your source code and mount it together with your code into the container? ``` cd WORKING_DIRECTORY pip install --target ./ GIT_URL ```
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
add this to makefile: ``` # makefile git clone REPO cd REPO_DIR; python setup.py bdist_wheel cp REPO_DIR/dist/* . rm -rf REPO_DIR/ ``` add this to dockerfile: ``` # dockerfile RUN pip install REPO*.whl ``` and then the package is successfully installed within docker
in your dockerfile put this code before installing requirements and you will be fine: ``` RUN apt-get update && apt-get install -y git ```
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
add this to makefile: ``` # makefile git clone REPO cd REPO_DIR; python setup.py bdist_wheel cp REPO_DIR/dist/* . rm -rf REPO_DIR/ ``` add this to dockerfile: ``` # dockerfile RUN pip install REPO*.whl ``` and then the package is successfully installed within docker
``` FROM python:3.9 as builder RUN pip install --target /tmp/site-packages "git+GIT_URL" FROM public.ecr.aws/lambda/python:3.9 COPY --from=builder /tmp/site-packages /var/lang/lib/python3.9/site-packages ``` You could use python:3.9 which has git, or any other image to install dependancies and then copy it into the ...
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
``` RUN python -m pip install git+URL_OF_GIT_REPO ```
in your dockerfile put this code before installing requirements and you will be fine: ``` RUN apt-get update && apt-get install -y git ```
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
``` RUN python -m pip install git+URL_OF_GIT_REPO ```
``` FROM python:3.9 as builder RUN pip install --target /tmp/site-packages "git+GIT_URL" FROM public.ecr.aws/lambda/python:3.9 COPY --from=builder /tmp/site-packages /var/lang/lib/python3.9/site-packages ``` You could use python:3.9 which has git, or any other image to install dependancies and then copy it into the ...
55,249,689
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux. Is there any possible way to fix this installing git? Or is there any other bette...
2019/03/19
[ "https://Stackoverflow.com/questions/55249689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6763224/" ]
in your dockerfile put this code before installing requirements and you will be fine: ``` RUN apt-get update && apt-get install -y git ```
``` FROM python:3.9 as builder RUN pip install --target /tmp/site-packages "git+GIT_URL" FROM public.ecr.aws/lambda/python:3.9 COPY --from=builder /tmp/site-packages /var/lang/lib/python3.9/site-packages ``` You could use python:3.9 which has git, or any other image to install dependancies and then copy it into the ...
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
Simply use select2 plugin to implement this feature Plugin link: [Select2](https://select2.github.io/examples.html) [![enter image description here](https://i.stack.imgur.com/6ora6.png)](https://i.stack.imgur.com/6ora6.png)
you can use **semantic ui** to implement this feature <https://semantic-ui.com/introduction/new.html>
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
If you don't like external library, you can use the HTML5 element `datalist`. Example from [W3School](https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_datalist): ``` <input list="browsers" name="browser"> <datalist id="browsers"> <option value="Internet Explorer"> <option value="Firefox"> <op...
you can use **semantic ui** to implement this feature <https://semantic-ui.com/introduction/new.html>
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
There's also a plain HTML solution You can use a [datalist element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) to display suggestions: ``` <div> <datalist id="suggestions"> <option>First option</option> <option>Second Option</option> </datalist> <input autoComplete...
I have made a custom dropdown using HTML and CSS with search tag on the top which is fixed at the top of dropdown.You can use the following HTML and CSS with bootstrap:- ``` <div class="dropdown dropdown-scroll"> <button class="btn btn-default event-button dropdown-toggle" type="button" id="dropdownMenu1" data-toggle=...
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
Simply use select2 plugin to implement this feature Plugin link: [Select2](https://select2.github.io/examples.html) [![enter image description here](https://i.stack.imgur.com/6ora6.png)](https://i.stack.imgur.com/6ora6.png)
There's also a plain HTML solution You can use a [datalist element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) to display suggestions: ``` <div> <datalist id="suggestions"> <option>First option</option> <option>Second Option</option> </datalist> <input autoComplete...
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
There's also a plain HTML solution You can use a [datalist element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) to display suggestions: ``` <div> <datalist id="suggestions"> <option>First option</option> <option>Second Option</option> </datalist> <input autoComplete...
Use [Select2](https://select2.org/getting-started/basic-usage). For Installation Process [Click Here](https://select2.org/getting-started/installation)
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
If you don't like external library, you can use the HTML5 element `datalist`. Example from [W3School](https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_datalist): ``` <input list="browsers" name="browser"> <datalist id="browsers"> <option value="Internet Explorer"> <option value="Firefox"> <op...
I have made a custom dropdown using HTML and CSS with search tag on the top which is fixed at the top of dropdown.You can use the following HTML and CSS with bootstrap:- ``` <div class="dropdown dropdown-scroll"> <button class="btn btn-default event-button dropdown-toggle" type="button" id="dropdownMenu1" data-toggle=...
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
If you don't like external library, you can use the HTML5 element `datalist`. Example from [W3School](https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_datalist): ``` <input list="browsers" name="browser"> <datalist id="browsers"> <option value="Internet Explorer"> <option value="Firefox"> <op...
Use [Select2](https://select2.org/getting-started/basic-usage). For Installation Process [Click Here](https://select2.org/getting-started/installation)
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
I have made a custom dropdown using HTML and CSS with search tag on the top which is fixed at the top of dropdown.You can use the following HTML and CSS with bootstrap:- ``` <div class="dropdown dropdown-scroll"> <button class="btn btn-default event-button dropdown-toggle" type="button" id="dropdownMenu1" data-toggle=...
you can use **semantic ui** to implement this feature <https://semantic-ui.com/introduction/new.html>
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
Simply use select2 plugin to implement this feature Plugin link: [Select2](https://select2.github.io/examples.html) [![enter image description here](https://i.stack.imgur.com/6ora6.png)](https://i.stack.imgur.com/6ora6.png)
Use [Select2](https://select2.org/getting-started/basic-usage). For Installation Process [Click Here](https://select2.org/getting-started/installation)
36,712,967
I want to add search box to a single select drop down option. **Code:** ``` <select id="widget_for" name="{{widget_for}}"> <option value="">select</option> {% for key, value in dr.items %} <input placeholder="This "> <option value="{% firstof value.id key %}" {% if key in selected_value %}selected{% endif %}>{% fi...
2016/04/19
[ "https://Stackoverflow.com/questions/36712967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324868/" ]
There's also a plain HTML solution You can use a [datalist element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) to display suggestions: ``` <div> <datalist id="suggestions"> <option>First option</option> <option>Second Option</option> </datalist> <input autoComplete...
you can use **semantic ui** to implement this feature <https://semantic-ui.com/introduction/new.html>
53,174,590
Im currently making my own model and all works fine with the tensorflow-for-poets-2 demo. I trained multiple pictures in different folders, and the app recognized it. Now I want to display a bounding box around the object. I found an example [here](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/e...
2018/11/06
[ "https://Stackoverflow.com/questions/53174590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8531947/" ]
You need to set **tinymce.suffix = '.min';** before you init TinyMCE ``` tinymce.suffix = '.min'; tinymce.baseURL = '/js/tinymce'; tinymce.init({ selector: '#editor', menubar: false, plugins: 'code' }); ```
TinyMCE should work out to load minified (or non-minified) files based on which TinyMCE file you load (`tinymce.js` or `tinymce.min.js`). Not sure what's happening in your case but that logic appears to be failing. If you grab the DEV package from <https://www.tiny.cloud/get-tiny/self-hosted/> it would come with bot...
53,174,590
Im currently making my own model and all works fine with the tensorflow-for-poets-2 demo. I trained multiple pictures in different folders, and the app recognized it. Now I want to display a bounding box around the object. I found an example [here](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/e...
2018/11/06
[ "https://Stackoverflow.com/questions/53174590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8531947/" ]
You need to set **tinymce.suffix = '.min';** before you init TinyMCE ``` tinymce.suffix = '.min'; tinymce.baseURL = '/js/tinymce'; tinymce.init({ selector: '#editor', menubar: false, plugins: 'code' }); ```
I think I found the solution for this. There is a property you can set in the tinymce object called "suffix" that resolved this for me. So, for the first part I set a rootURL property in the page calling TinyMCE, and then added the line tinymce.baseURL = rootURL + 'Scripts/libs/tinymce' just before the tinymce.init. ...
23,007,203
Write a program that prompts the user for the name of a file, opens the file for reading, and then outputs how many times each character of the alphabet appears in the file. ``` #!/usr/local/bin/python name=raw_input("Enter file name: ") input_file=open(name,"r") list=input_file.readlines() count = 0 counter = 0 for...
2014/04/11
[ "https://Stackoverflow.com/questions/23007203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1836292/" ]
Create style like this- ``` <style name="Theme.MyAppTheme" parent="Theme.Sherlock.Light"> <item name="android:actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item> <item name="actionBarStyle">@style/Theme.MyAppTheme.ActionBar</item> </style> <style name="Theme.MyAppTheme.ActionBar" parent="Wi...
Try to use this one: ``` <style name="Theme.white_style" parent="@android:style/Theme.Holo.Light.DarkActionBar"> <item name="android:actionBarSize">55dp</item> <item name="actionBarSize">55dp</item> </style> ```
12,735,852
The question is an attempt to get the exact instruction on how to do that. There were few attempts before, which don't seem to be full solutions: [solution to move the file inside the package](https://stackoverflow.com/questions/3071327/problem-accessing-config-files-within-a-python-egg) [solution to read as zip](htt...
2012/10/04
[ "https://Stackoverflow.com/questions/12735852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/673423/" ]
Setuptools/distribute/pkg\_resources is designed to be a sort of transparent overlay to standard Python distutils, which are pretty limited and don't allow a good way of distributing code. eggs are just a way of putting together a bunch of python files, data files, and metadata, somewhat similar to Java JARs - but pyt...
The [`zipimporter`](http://docs.python.org/library/zipimport.html#zipimporter-objects) used to load a module can be accessed using the [`__loader__`](http://www.python.org/dev/peps/pep-0302/#specification-part-1-the-importer-protocol) attribute on the module, so accessing a file within the egg should be as simple as: ...
59,821,535
I have a JSON file name.json with below contents, ``` { "Name": [{ "firstName": "John", "lastName": "Stark" }] } ``` Using python how to add the members of Stark family to the JSON file using following list `firstNameList=['Sansa','Arya','Brandon']` Expected Output ``` { "Name": [{ ...
2020/01/20
[ "https://Stackoverflow.com/questions/59821535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522495/" ]
The following should do the trick: ``` import json with open('name.json', 'r+') as f: data = json.load(f) for name in firstNameList: data["Name"].append({"firstName": name, "lastName": "Stark"}) ```
``` dicts = { "Name": [{ "firstName": "John", "lastName": "Stark" } ] } firstNameList = ['Sansa','Arya','Brandon'] for j in firstNameList: dicts["Name"].append({'firstName': j, 'lastName': 'Stark'}) print(dicts) ``` And you will get ``` {'Name': [{'firstName': 'John', ...
59,821,535
I have a JSON file name.json with below contents, ``` { "Name": [{ "firstName": "John", "lastName": "Stark" }] } ``` Using python how to add the members of Stark family to the JSON file using following list `firstNameList=['Sansa','Arya','Brandon']` Expected Output ``` { "Name": [{ ...
2020/01/20
[ "https://Stackoverflow.com/questions/59821535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522495/" ]
You could try this: ``` import json test = '''{ "Name": [{ "firstName": "John", "lastName": "Stark" }] }''' data = json.loads(test) firstNameList = ['Sansa','Arya','Brandon'] for member in firstNameList: test_dict = {'firstName': member, 'lastName': 'Stark'} data['Name'].append(test_di...
``` dicts = { "Name": [{ "firstName": "John", "lastName": "Stark" } ] } firstNameList = ['Sansa','Arya','Brandon'] for j in firstNameList: dicts["Name"].append({'firstName': j, 'lastName': 'Stark'}) print(dicts) ``` And you will get ``` {'Name': [{'firstName': 'John', ...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
The first line of the `Rationale` section of [PEP 338](http://www.python.org/dev/peps/pep-0338/) says: > > Python 2.4 adds the command line switch -m to allow modules to be located using the Python module namespace for execution as scripts. The motivating examples were standard library modules such as pdb and profile...
It's worth mentioning **this only works if the package has a file `__main__.py`** Otherwise, this package can not be executed directly. ``` python -m some_package some_arguments ``` The python interpreter will looking for a `__main__.py` file in the package path to execute. It's equivalent to: ``` python path_to_pa...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
The first line of the `Rationale` section of [PEP 338](http://www.python.org/dev/peps/pep-0338/) says: > > Python 2.4 adds the command line switch -m to allow modules to be located using the Python module namespace for execution as scripts. The motivating examples were standard library modules such as pdb and profile...
Despite this question having been asked and answered several times (e.g., [here](https://stackoverflow.com/q/52441280/1066291), [here](https://stackoverflow.com/q/22241420/1066291), [here](https://stackoverflow.com/q/50821312/1066291), and [here](https://stackoverflow.com/q/46319694/1066291)), in my opinion no existing...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
The first line of the `Rationale` section of [PEP 338](http://www.python.org/dev/peps/pep-0338/) says: > > Python 2.4 adds the command line switch -m to allow modules to be located using the Python module namespace for execution as scripts. The motivating examples were standard library modules such as pdb and profile...
I just want to mention one potentially confusing case. Suppose you use `pip3` to install a package `foo`, which contains a `bar` module. So this means you can execute `python3 -m foo.bar` from any directory. On the other hand, you have a directory structure like this: ``` src | +-- foo | +-- __init__.py |...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
The first line of the `Rationale` section of [PEP 338](http://www.python.org/dev/peps/pep-0338/) says: > > Python 2.4 adds the command line switch -m to allow modules to be located using the Python module namespace for execution as scripts. The motivating examples were standard library modules such as pdb and profile...
Since this question comes up when you google `Use of "python -m"`, I just wanted to add a quick reference for those who like to modularize code without creating full [python packages](https://packaging.python.org/en/latest/) or [modifying](https://gist.github.com/TheProjectsGuy/a998c0a53313ee0bdc937018603d93a4) `PYTHON...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
Despite this question having been asked and answered several times (e.g., [here](https://stackoverflow.com/q/52441280/1066291), [here](https://stackoverflow.com/q/22241420/1066291), [here](https://stackoverflow.com/q/50821312/1066291), and [here](https://stackoverflow.com/q/46319694/1066291)), in my opinion no existing...
It's worth mentioning **this only works if the package has a file `__main__.py`** Otherwise, this package can not be executed directly. ``` python -m some_package some_arguments ``` The python interpreter will looking for a `__main__.py` file in the package path to execute. It's equivalent to: ``` python path_to_pa...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
It's worth mentioning **this only works if the package has a file `__main__.py`** Otherwise, this package can not be executed directly. ``` python -m some_package some_arguments ``` The python interpreter will looking for a `__main__.py` file in the package path to execute. It's equivalent to: ``` python path_to_pa...
I just want to mention one potentially confusing case. Suppose you use `pip3` to install a package `foo`, which contains a `bar` module. So this means you can execute `python3 -m foo.bar` from any directory. On the other hand, you have a directory structure like this: ``` src | +-- foo | +-- __init__.py |...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
It's worth mentioning **this only works if the package has a file `__main__.py`** Otherwise, this package can not be executed directly. ``` python -m some_package some_arguments ``` The python interpreter will looking for a `__main__.py` file in the package path to execute. It's equivalent to: ``` python path_to_pa...
Since this question comes up when you google `Use of "python -m"`, I just wanted to add a quick reference for those who like to modularize code without creating full [python packages](https://packaging.python.org/en/latest/) or [modifying](https://gist.github.com/TheProjectsGuy/a998c0a53313ee0bdc937018603d93a4) `PYTHON...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
Despite this question having been asked and answered several times (e.g., [here](https://stackoverflow.com/q/52441280/1066291), [here](https://stackoverflow.com/q/22241420/1066291), [here](https://stackoverflow.com/q/50821312/1066291), and [here](https://stackoverflow.com/q/46319694/1066291)), in my opinion no existing...
I just want to mention one potentially confusing case. Suppose you use `pip3` to install a package `foo`, which contains a `bar` module. So this means you can execute `python3 -m foo.bar` from any directory. On the other hand, you have a directory structure like this: ``` src | +-- foo | +-- __init__.py |...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
Despite this question having been asked and answered several times (e.g., [here](https://stackoverflow.com/q/52441280/1066291), [here](https://stackoverflow.com/q/22241420/1066291), [here](https://stackoverflow.com/q/50821312/1066291), and [here](https://stackoverflow.com/q/46319694/1066291)), in my opinion no existing...
Since this question comes up when you google `Use of "python -m"`, I just wanted to add a quick reference for those who like to modularize code without creating full [python packages](https://packaging.python.org/en/latest/) or [modifying](https://gist.github.com/TheProjectsGuy/a998c0a53313ee0bdc937018603d93a4) `PYTHON...
7,610,001
Could you explain to me what the difference is between calling ``` python -m mymod1 mymod2.py args ``` and ``` python mymod1.py mymod2.py args ``` It seems in both cases `mymod1.py` is called and `sys.argv` is ``` ['mymod1.py', 'mymod2.py', 'args'] ``` So what is the `-m` switch for?
2011/09/30
[ "https://Stackoverflow.com/questions/7610001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/621944/" ]
I just want to mention one potentially confusing case. Suppose you use `pip3` to install a package `foo`, which contains a `bar` module. So this means you can execute `python3 -m foo.bar` from any directory. On the other hand, you have a directory structure like this: ``` src | +-- foo | +-- __init__.py |...
Since this question comes up when you google `Use of "python -m"`, I just wanted to add a quick reference for those who like to modularize code without creating full [python packages](https://packaging.python.org/en/latest/) or [modifying](https://gist.github.com/TheProjectsGuy/a998c0a53313ee0bdc937018603d93a4) `PYTHON...
11,021,405
I am designing a text processing program that will generate a list of keywords from a long itemized text document, and combine entries for words that are similar in meaning. There are metrics out there, however I have a new issue of dealing with words that are not in the dictionary that I am using. I am currently usi...
2012/06/13
[ "https://Stackoverflow.com/questions/11021405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1287834/" ]
Looks like you need a spelling corrector to match words in your dictionary. The code below works and taken directly from this blog <http://norvig.com/spell-correct.html> written by Peter Norvig, ``` import re, collections def words(text): return re.findall('[a-z]+', text.lower()) def train(features): model = co...
Your task sounds like it's really just non-word spelling correction, so a relatively straight-forward solution would be to use an existing spell checker like aspell with a custom dictionary. A quick and dirty approach would be to just use a phonetic mapping like metaphone (which is one the algorithms used by aspell). ...
11,021,405
I am designing a text processing program that will generate a list of keywords from a long itemized text document, and combine entries for words that are similar in meaning. There are metrics out there, however I have a new issue of dealing with words that are not in the dictionary that I am using. I am currently usi...
2012/06/13
[ "https://Stackoverflow.com/questions/11021405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1287834/" ]
Looks like you need a spelling corrector to match words in your dictionary. The code below works and taken directly from this blog <http://norvig.com/spell-correct.html> written by Peter Norvig, ``` import re, collections def words(text): return re.findall('[a-z]+', text.lower()) def train(features): model = co...
Hopefully this answer is not too vague: 1) It sounds like you might need to look at your tokenisation and phrase chunking layers first. This is is where you should discard symbolic phrase chunks before submitting them to any fuzzy spell checking. 2) I would still recommend edit distance to come up with alternatives ...
11,021,405
I am designing a text processing program that will generate a list of keywords from a long itemized text document, and combine entries for words that are similar in meaning. There are metrics out there, however I have a new issue of dealing with words that are not in the dictionary that I am using. I am currently usi...
2012/06/13
[ "https://Stackoverflow.com/questions/11021405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1287834/" ]
Looks like you need a spelling corrector to match words in your dictionary. The code below works and taken directly from this blog <http://norvig.com/spell-correct.html> written by Peter Norvig, ``` import re, collections def words(text): return re.findall('[a-z]+', text.lower()) def train(features): model = co...
I do not see a reason to use Levenshtein distance to find a word similar in *meaning*. LD looks at form (you want to map "bus" to "truck" not to "bush"). The correct solution depends on what you want to do next. Unless you really need the information in those unknown words, I would simply map all of them to a single...
73,247,351
I found a way to query all global address in outlook with python, ``` import win32com.client import csv from datetime import datetime # Outlook outApp = win32com.client.gencache.EnsureDispatch("Outlook.Application") outGAL = outApp.Session.GetGlobalAddressList() entries = outGAL.AddressEntries # Create a dateID date...
2022/08/05
[ "https://Stackoverflow.com/questions/73247351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9821792/" ]
Actually your program works fine except that one problem with removing element from list, look: ``` l = [1,2,3] print(l.remove(1)) # None print(l) # [2,3] ``` So `list.remove()` modifies **mutable** list and doesn't return new one like in case of e.g. **immutable** strings ``` s = "abc" print(s.upper()) # ABC print...
The only problem was the `three.remove(smallest_1)`. Change this and it becomes: ```py def sum_two_smallest_numbers(numbers, index=0, two=[]): if index == 0: two = [numbers[0], numbers[1]] index += 2 if index < len(numbers) and index >= 2: three = two + [numbers[index]] smalles...
28,296,476
I finished installing pip on linux, the `pip list` command works. But when using the `pip install` command it got the following error: ``` Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main status = self.run(options, args) ...
2015/02/03
[ "https://Stackoverflow.com/questions/28296476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1305814/" ]
[pip 6.1.0](https://pypi.python.org/pypi/pip/6.1.0) has been released, fixing this issue. You can upgrade with: ``` pip --trusted-host pypi.python.org install -U pip ``` to self-upgrade. --- *Original answer*: This is caused by a change in Python 2.7.9, which `urllib3` needs to account for. See [issue #543](https...
It is related to urllib3. You can resolve it with urllib3 version 1.25.8. Download that version of urllib3 manually and install it. Even though you install thia version, pip will still use its own version.So you have to remove it and replace it. Usually, installed module is on PythonXX/Lib/site-packages 1. Delete ur...
28,296,476
I finished installing pip on linux, the `pip list` command works. But when using the `pip install` command it got the following error: ``` Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main status = self.run(options, args) ...
2015/02/03
[ "https://Stackoverflow.com/questions/28296476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1305814/" ]
[pip 6.1.0](https://pypi.python.org/pypi/pip/6.1.0) has been released, fixing this issue. You can upgrade with: ``` pip --trusted-host pypi.python.org install -U pip ``` to self-upgrade. --- *Original answer*: This is caused by a change in Python 2.7.9, which `urllib3` needs to account for. See [issue #543](https...
I encountered this problem and tried the above methods, but not work. I finally find it is because I turn on the VPN. When I turn off the VPN, I can successfully download packages.
28,296,476
I finished installing pip on linux, the `pip list` command works. But when using the `pip install` command it got the following error: ``` Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main status = self.run(options, args) ...
2015/02/03
[ "https://Stackoverflow.com/questions/28296476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1305814/" ]
I get the same issue, and find that it can be avoided (pip 6.0.8) in my case as follows ``` pip --trusted-host pypi.python.org install <thing> ```
It is related to urllib3. You can resolve it with urllib3 version 1.25.8. Download that version of urllib3 manually and install it. Even though you install thia version, pip will still use its own version.So you have to remove it and replace it. Usually, installed module is on PythonXX/Lib/site-packages 1. Delete ur...
28,296,476
I finished installing pip on linux, the `pip list` command works. But when using the `pip install` command it got the following error: ``` Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main status = self.run(options, args) ...
2015/02/03
[ "https://Stackoverflow.com/questions/28296476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1305814/" ]
I get the same issue, and find that it can be avoided (pip 6.0.8) in my case as follows ``` pip --trusted-host pypi.python.org install <thing> ```
I encountered this problem and tried the above methods, but not work. I finally find it is because I turn on the VPN. When I turn off the VPN, I can successfully download packages.
28,296,476
I finished installing pip on linux, the `pip list` command works. But when using the `pip install` command it got the following error: ``` Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main status = self.run(options, args) ...
2015/02/03
[ "https://Stackoverflow.com/questions/28296476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1305814/" ]
It is related to urllib3. You can resolve it with urllib3 version 1.25.8. Download that version of urllib3 manually and install it. Even though you install thia version, pip will still use its own version.So you have to remove it and replace it. Usually, installed module is on PythonXX/Lib/site-packages 1. Delete ur...
I encountered this problem and tried the above methods, but not work. I finally find it is because I turn on the VPN. When I turn off the VPN, I can successfully download packages.
63,019,336
I am yet to learn the 'lambda' concept in python, I tried to look for answers and every answer includes lambda in it. This is my code, can you please suggest me a way to sort it by values. ```html sorted_dict = {'sir': '113', 'to': '146', 'my': '9', 'jesus': '4', 'saving': '275', 'changing': '72', 'apologize': '285', ...
2020/07/21
[ "https://Stackoverflow.com/questions/63019336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13967182/" ]
lambda is often used as the key to sort every value in an iterator. The same step from turning dictionaries to list of tuples, can be done using the dict method `dict.items()`. and i used lambda in sorting, as a key to tell the sorted function that, i want to sort based on the value in each tuple located in the 1st i...
if you are familiar with other programming concepts, you may have heard of what is called an "inline function"... Lambda is an "inline function" equivalent in Python.. its a function which doesnt have a function name, and is restricted to have only a single line of code. now coming to the problem of sort, the sort f...
3,351,218
If a string contains `*SUBJECT123`, how do I determine that the string has `subject` in it in python?
2010/07/28
[ "https://Stackoverflow.com/questions/3351218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277603/" ]
``` if "subject" in mystring.lower(): # do something ```
If you want to have `subject` match `SUBJECT`, you could use [`re`](http://docs.python.org/library/re.html) ``` import re if re.search('subject', your_string, re.IGNORECASE) ``` Or you could transform the string to lower case first and simply use: ``` if "subject" in your_string.lower() ```
3,351,218
If a string contains `*SUBJECT123`, how do I determine that the string has `subject` in it in python?
2010/07/28
[ "https://Stackoverflow.com/questions/3351218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277603/" ]
``` if "subject" in mystring.lower(): # do something ```
``` if "*SUGJECT123" in mystring and "subject" in mystring: # do something ```
3,351,218
If a string contains `*SUBJECT123`, how do I determine that the string has `subject` in it in python?
2010/07/28
[ "https://Stackoverflow.com/questions/3351218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277603/" ]
``` if "subject" in mystring.lower(): # do something ```
Just another way ``` mystring.find("subject") ``` the above answers will return true if the string contains "subject" and false otherwise. While find will return its position in the string if it exists else a negative number.
3,351,218
If a string contains `*SUBJECT123`, how do I determine that the string has `subject` in it in python?
2010/07/28
[ "https://Stackoverflow.com/questions/3351218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277603/" ]
If you want to have `subject` match `SUBJECT`, you could use [`re`](http://docs.python.org/library/re.html) ``` import re if re.search('subject', your_string, re.IGNORECASE) ``` Or you could transform the string to lower case first and simply use: ``` if "subject" in your_string.lower() ```
``` if "*SUGJECT123" in mystring and "subject" in mystring: # do something ```
3,351,218
If a string contains `*SUBJECT123`, how do I determine that the string has `subject` in it in python?
2010/07/28
[ "https://Stackoverflow.com/questions/3351218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277603/" ]
If you want to have `subject` match `SUBJECT`, you could use [`re`](http://docs.python.org/library/re.html) ``` import re if re.search('subject', your_string, re.IGNORECASE) ``` Or you could transform the string to lower case first and simply use: ``` if "subject" in your_string.lower() ```
Just another way ``` mystring.find("subject") ``` the above answers will return true if the string contains "subject" and false otherwise. While find will return its position in the string if it exists else a negative number.
3,351,218
If a string contains `*SUBJECT123`, how do I determine that the string has `subject` in it in python?
2010/07/28
[ "https://Stackoverflow.com/questions/3351218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277603/" ]
Just another way ``` mystring.find("subject") ``` the above answers will return true if the string contains "subject" and false otherwise. While find will return its position in the string if it exists else a negative number.
``` if "*SUGJECT123" in mystring and "subject" in mystring: # do something ```
29,276,668
I have created a new project in django. when I run **python manage.py runserver**, I am getting the msg in command prompt like below. ``` /var/www/samplepro/myapp$ python manage.py runserver Performing system checks... System check identified no issues (0 silenced). March 26, 2015 - 10:52:31 Django version 1.7.7...
2015/03/26
[ "https://Stackoverflow.com/questions/29276668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2522688/" ]
You stated that you are running the server on Ubuntu while you are trying to connect it from another PC running Windows. In that case, you should replace the `127.0.0.1` with the actual IP address of Ubuntu server (the one you use for PuTTY).
I am also developing in a virtual machine. Use `ifconfig` to figure out the IP address that has been assigned to your virtual machine. Then start the server with: ``` python manage.py runserver <IP>:8000 ``` Of course you could also use a different port instead of `8000`. Then use that address and port in your hos...
27,595,162
I am looking for an algorithm or modification of an efficient way to get the sum of run through of a tree depth, for example: ``` Z / \ / \ / \ / \ X Y / \ / \ / \ / \ A B ...
2014/12/22
[ "https://Stackoverflow.com/questions/27595162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3947332/" ]
You can recurse over the nodes of the tree keeping the sum from the root down to this point. When you reach a leaf node, you return the current sum in a list of one element. In the internal nodes, you concatenate the lists returned from children. Sample Code: ``` class Node: def __init__(self, value, children): ...
Here is what you are looking for. In this example, trees are stored as dicts with a "value" and a "children" keys, and "children" maps to a list. ``` def triesum(t): if not t['children']: return [t['value']] return [t['value'] + n for c in t['children'] for n in triesum(c)] ``` Example ``` trie = {'...
24,828,771
I am in the process of writing a python script that will (1) obtain a list of y-values for each subplot to plot against a common set of x-values, (2) make each of these subplots a scatter-plot and put it in the appropriate location in the subplot grid, and (3) complete these tasks for different sizes of subplot grids. ...
2014/07/18
[ "https://Stackoverflow.com/questions/24828771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3421870/" ]
A useful function for things like this is `plt.subplots(nrows, ncols)` which will return an array (a numpy object array) of subplots on a regular grid. As an example: ``` import matplotlib.pyplot as plt import numpy as np fig, axes = plt.subplots(nrows=4, ncols=4, sharex=True, sharey=True) # "axes" is a 2D array of...
If you are going to use Python, you will want to take a stroll through the [Python Tutorial](https://docs.python.org/2.7/tutorial/index.html) to learn the the language and data structures available to you, there is good instructional material online, you might want to consider some of the *computer science 101* courses...
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
In Windows you will need to right click a .py, and press Edit to edit the file using IDLE. Since the default action of double clicking a .py is executing the file with python on a shell prompt. To open just IDLE: Click on that. `C:\Python36\Lib\idlelib\idle.bat`
If your using Windows 10 just type in `idle` where it says: "Type here for search"
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
In Windows you will need to right click a .py, and press Edit to edit the file using IDLE. Since the default action of double clicking a .py is executing the file with python on a shell prompt. To open just IDLE: Click on that. `C:\Python36\Lib\idlelib\idle.bat`
My solution to setting options and then invoking Idle on a python script is: ``` Set optn=blah ... Set optn=blah start pythonw C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Lib\idlelib\idle.py STFxlate.py ``` This allows you to setup the environment prior to invoking idle. This assumes that pythonw i...
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
In Windows you will need to right click a .py, and press Edit to edit the file using IDLE. Since the default action of double clicking a .py is executing the file with python on a shell prompt. To open just IDLE: Click on that. `C:\Python36\Lib\idlelib\idle.bat`
Start menu > type `IDLE (Python 3.4.3 <bitnum>-bit)`. Replace `<bitnum>` with 32 if 32-bit, otherwise 64. Example: > > IDLE (Python 3.6.2 64-bit) > > > I agree with one who says: > > just type "IDLE" in the start-menu where it says "Type here to search" and press **[**{**ENTER**}**]** > > >
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
In Windows you will need to right click a .py, and press Edit to edit the file using IDLE. Since the default action of double clicking a .py is executing the file with python on a shell prompt. To open just IDLE: Click on that. `C:\Python36\Lib\idlelib\idle.bat`
For those using Anaconda, type idle on windows search bar ("Run or Execute command"). This probably wont work if you didn't install anaconda with environment variables. You can also go to ``` Anaconda3 folder > Scripts >idle.exe ``` and create a shortcut to you desktop.
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
If your using Windows 10 just type in `idle` where it says: "Type here for search"
My solution to setting options and then invoking Idle on a python script is: ``` Set optn=blah ... Set optn=blah start pythonw C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Lib\idlelib\idle.py STFxlate.py ``` This allows you to setup the environment prior to invoking idle. This assumes that pythonw i...
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
If your using Windows 10 just type in `idle` where it says: "Type here for search"
For those using Anaconda, type idle on windows search bar ("Run or Execute command"). This probably wont work if you didn't install anaconda with environment variables. You can also go to ``` Anaconda3 folder > Scripts >idle.exe ``` and create a shortcut to you desktop.
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
Start menu > type `IDLE (Python 3.4.3 <bitnum>-bit)`. Replace `<bitnum>` with 32 if 32-bit, otherwise 64. Example: > > IDLE (Python 3.6.2 64-bit) > > > I agree with one who says: > > just type "IDLE" in the start-menu where it says "Type here to search" and press **[**{**ENTER**}**]** > > >
My solution to setting options and then invoking Idle on a python script is: ``` Set optn=blah ... Set optn=blah start pythonw C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Lib\idlelib\idle.py STFxlate.py ``` This allows you to setup the environment prior to invoking idle. This assumes that pythonw i...
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
My solution to setting options and then invoking Idle on a python script is: ``` Set optn=blah ... Set optn=blah start pythonw C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32\Lib\idlelib\idle.py STFxlate.py ``` This allows you to setup the environment prior to invoking idle. This assumes that pythonw i...
For those using Anaconda, type idle on windows search bar ("Run or Execute command"). This probably wont work if you didn't install anaconda with environment variables. You can also go to ``` Anaconda3 folder > Scripts >idle.exe ``` and create a shortcut to you desktop.
43,159,565
I've been using the script below to download technical videos for later analysis. The script has worked well for me and retrieves the highest resolution version available for the videos that I have needed. Now I've come across a [4K YouTube video](https://youtu.be/vzS1Vkpsi5k), and my script only saves an mp4 with 128...
2017/04/01
[ "https://Stackoverflow.com/questions/43159565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904031/" ]
Start menu > type `IDLE (Python 3.4.3 <bitnum>-bit)`. Replace `<bitnum>` with 32 if 32-bit, otherwise 64. Example: > > IDLE (Python 3.6.2 64-bit) > > > I agree with one who says: > > just type "IDLE" in the start-menu where it says "Type here to search" and press **[**{**ENTER**}**]** > > >
For those using Anaconda, type idle on windows search bar ("Run or Execute command"). This probably wont work if you didn't install anaconda with environment variables. You can also go to ``` Anaconda3 folder > Scripts >idle.exe ``` and create a shortcut to you desktop.
49,327,630
I am new to python 3 and I'm working on sentiment analysis of tweets. My code begins with a for loop that takes in 50 tweets, which i clean and pre-process. After this (still inside the for loop) i want to save each tweet in a text file(every tweet on a new line) Here's how the code goes: ``` for loop: .. ...
2018/03/16
[ "https://Stackoverflow.com/questions/49327630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9504637/" ]
I'm not sure if this is exactly what you want to do but you can change this ``` filename=open("withnouns.txt","a") sys.stdout = filename print(new_words) print("\n") sys.stdout.close() ``` to ``` filename=open("withnouns.txt","a") filename.write(new_words + "\n") filename.write("\n\n") filename.close() ``` altern...
You're confusing two different kinds of writing to file. `sys.stdout` pipes your output to the console/terminal. This can be written to file but it's very roundabout. Writing to file is different. In python you should look at the [`csv` module](https://docs.python.org/3/library/csv.html) if you're writing lists of va...
49,327,630
I am new to python 3 and I'm working on sentiment analysis of tweets. My code begins with a for loop that takes in 50 tweets, which i clean and pre-process. After this (still inside the for loop) i want to save each tweet in a text file(every tweet on a new line) Here's how the code goes: ``` for loop: .. ...
2018/03/16
[ "https://Stackoverflow.com/questions/49327630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9504637/" ]
You do not need to assign to `sys.stdout` *at all*. Just tell `print()` to write to the file instead, using the `file` argument: ``` print(new_words, file=filename) print("\n", file=filename) ``` There is no need to assign anything to `sys.stdout` now, because now `print()` writes directly to your file instead. You...
You're confusing two different kinds of writing to file. `sys.stdout` pipes your output to the console/terminal. This can be written to file but it's very roundabout. Writing to file is different. In python you should look at the [`csv` module](https://docs.python.org/3/library/csv.html) if you're writing lists of va...
67,293,952
In short, I have to scrape Flipkart and store the data in Mongodb. Firstly, use [MongoDB Atlas](https://www.mongodb.com/cloud/atlas/lp/try2-in) to get yourself a free managed Mongodb server. Test if you are able to connect to it using python's library pymongo. Secondly, install [Scrapy](https://docs.scrapy.org/en/lat...
2021/04/28
[ "https://Stackoverflow.com/questions/67293952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15781486/" ]
I had the same issue, and here's what I figured out: You need to include `Store` from redux, and use it as your type definition for your own `store` return value. Short answer: ``` import {combineReducers, Store} from 'redux'; [...] const store:Store = configureStore([...]) [...] export default store; ``` Longer an...
A potential solution would be to extend the RootState type to include $CombinedState as follows: ``` import { $CombinedState } from '@reduxjs/toolkit'; export type RootState = ReturnType<typeof store.getState> & { readonly [$CombinedState]?: undefined; }; ```
50,847,000
I have a csv file which has contents like the following: **stores.csv** ``` Site, Score, Rank roolee.com,100,125225 piperandscoot.com,29.3,222166 calledtosurf.com,23.8,361542 cladandcloth.com,17.9,208670 neeseesdresses.com,9.6,251016 ... ``` Here's my model. **models.py** ``` class SimilarStore(models.Model): ...
2018/06/13
[ "https://Stackoverflow.com/questions/50847000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9393766/" ]
You can read the csv file through pandas and then convert it to your desired object ny using pandas funtion 'infer\_objects()'. I hope the code below helps you in this regard, ``` import pandas as pd SimilarStore_df = pd.read_csv('./store.csv') #importing csv file as pandas DataFrame SimilarStore_df.columns = ['Domain...
Just find the table name in your Database also find the corresponding column names with the table and use the to\_sql command in pandas
6,906,515
Okay, so I'm writing a very simplistic password cracker in python that brute forces a password with alphanumeric characters. Currently this code only supports 1 character passwords and a password file with a md5 hashed password inside. It will eventually include the option to specify your own character limits (how many...
2011/08/02
[ "https://Stackoverflow.com/questions/6906515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856255/" ]
The way to allow a `KeyboardInterrupt` to end your program is to **do nothing**. They work by depending on nothing catching them in an `except` block; when an exception bubbles all the way out of a program (or thread), it terminates. What you have done is to trap the `KeyboardInterrupt`s and handle them by printing a ...
This is what worked for me... ``` import sys try: ....code that hangs.... except KeyboardInterrupt: print "interupt" sys.exit() ```
6,906,515
Okay, so I'm writing a very simplistic password cracker in python that brute forces a password with alphanumeric characters. Currently this code only supports 1 character passwords and a password file with a md5 hashed password inside. It will eventually include the option to specify your own character limits (how many...
2011/08/02
[ "https://Stackoverflow.com/questions/6906515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856255/" ]
The way to allow a `KeyboardInterrupt` to end your program is to **do nothing**. They work by depending on nothing catching them in an `except` block; when an exception bubbles all the way out of a program (or thread), it terminates. What you have done is to trap the `KeyboardInterrupt`s and handle them by printing a ...
Well, when you use that `try` and `except` block, the error is raised when that error occurs. In your case, `KeyboardInterrupt` is your error here. But when `KeyboardInterrupt` is activated, nothing happens. This due to having nothing in the `except` part. You could do this after importing `sys`: ``` try: #Your co...
6,906,515
Okay, so I'm writing a very simplistic password cracker in python that brute forces a password with alphanumeric characters. Currently this code only supports 1 character passwords and a password file with a md5 hashed password inside. It will eventually include the option to specify your own character limits (how many...
2011/08/02
[ "https://Stackoverflow.com/questions/6906515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856255/" ]
Besides printing, you need to actually exit your program when capturin `KeyboardInterrupt`, you're only printing a message.
This is what worked for me... ``` import sys try: ....code that hangs.... except KeyboardInterrupt: print "interupt" sys.exit() ```
6,906,515
Okay, so I'm writing a very simplistic password cracker in python that brute forces a password with alphanumeric characters. Currently this code only supports 1 character passwords and a password file with a md5 hashed password inside. It will eventually include the option to specify your own character limits (how many...
2011/08/02
[ "https://Stackoverflow.com/questions/6906515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856255/" ]
Besides printing, you need to actually exit your program when capturin `KeyboardInterrupt`, you're only printing a message.
Well, when you use that `try` and `except` block, the error is raised when that error occurs. In your case, `KeyboardInterrupt` is your error here. But when `KeyboardInterrupt` is activated, nothing happens. This due to having nothing in the `except` part. You could do this after importing `sys`: ``` try: #Your co...
28,168,732
Here is my JSON string which I need to parse. ``` { "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1" : { "@class" : "com.barco.compose.media.transcode.internal.h264.H264Gateway", "id" : "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1", "uri" : { "high" : "rtp://239.1.1.2:5006", ...
2015/01/27
[ "https://Stackoverflow.com/questions/28168732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498089/" ]
Your `JSON` object contains several root (or top) objects indexed with keys such as `"192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1"`. From your question it seems you want to access the `id` field of these elements. For that the simple way is probably using the `json` module - included in the standard librar...
The following expression is what you need: ``` $..id ``` Proof: ``` In [12]: vv = json.loads(my_input_string) In [13]: jsonpath_expr = parse('$..id') In [14]: [x.value for x in jsonpath_expr.find(vv)] Out[14]: [u'192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1', u'192.168.1.2_151b3a32-ce00-114a-e000-00...
28,168,732
Here is my JSON string which I need to parse. ``` { "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1" : { "@class" : "com.barco.compose.media.transcode.internal.h264.H264Gateway", "id" : "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1", "uri" : { "high" : "rtp://239.1.1.2:5006", ...
2015/01/27
[ "https://Stackoverflow.com/questions/28168732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498089/" ]
The following expression is what you need: ``` $..id ``` Proof: ``` In [12]: vv = json.loads(my_input_string) In [13]: jsonpath_expr = parse('$..id') In [14]: [x.value for x in jsonpath_expr.find(vv)] Out[14]: [u'192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1', u'192.168.1.2_151b3a32-ce00-114a-e000-00...
you can get `id` like this(save your json string as a **single line** file as `test.json`): ``` import simplejson as json with open("test.json") as fp: line = fp.readline() json = json.loads(line) for k,v in json.items(): print v.get("id","no id found") # no id found is the default value in case t...
28,168,732
Here is my JSON string which I need to parse. ``` { "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1" : { "@class" : "com.barco.compose.media.transcode.internal.h264.H264Gateway", "id" : "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1", "uri" : { "high" : "rtp://239.1.1.2:5006", ...
2015/01/27
[ "https://Stackoverflow.com/questions/28168732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498089/" ]
Your `JSON` object contains several root (or top) objects indexed with keys such as `"192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1"`. From your question it seems you want to access the `id` field of these elements. For that the simple way is probably using the `json` module - included in the standard librar...
You don't have a base/root element - just a collection of keys and values. You can iterate through them with something like this: ``` import json import pprint values = json.loads(YOUR_JSON_STRING) for v in values: print v, pprint.pprint(values[v]) ``` That will print out the following two elements (each with...
28,168,732
Here is my JSON string which I need to parse. ``` { "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1" : { "@class" : "com.barco.compose.media.transcode.internal.h264.H264Gateway", "id" : "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1", "uri" : { "high" : "rtp://239.1.1.2:5006", ...
2015/01/27
[ "https://Stackoverflow.com/questions/28168732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498089/" ]
Your `JSON` object contains several root (or top) objects indexed with keys such as `"192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1"`. From your question it seems you want to access the `id` field of these elements. For that the simple way is probably using the `json` module - included in the standard librar...
you can get `id` like this(save your json string as a **single line** file as `test.json`): ``` import simplejson as json with open("test.json") as fp: line = fp.readline() json = json.loads(line) for k,v in json.items(): print v.get("id","no id found") # no id found is the default value in case t...
28,168,732
Here is my JSON string which I need to parse. ``` { "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1" : { "@class" : "com.barco.compose.media.transcode.internal.h264.H264Gateway", "id" : "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1", "uri" : { "high" : "rtp://239.1.1.2:5006", ...
2015/01/27
[ "https://Stackoverflow.com/questions/28168732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498089/" ]
Your `JSON` object contains several root (or top) objects indexed with keys such as `"192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1"`. From your question it seems you want to access the `id` field of these elements. For that the simple way is probably using the `json` module - included in the standard librar...
Found the subject when trying to find a solution for a problem of mine. In the meantime, I think you found a solution but if anyone is passing by check the jsonlines library that is very useful and could solve the problem <https://jsonlines.readthedocs.io/en/latest/>
28,168,732
Here is my JSON string which I need to parse. ``` { "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1" : { "@class" : "com.barco.compose.media.transcode.internal.h264.H264Gateway", "id" : "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1", "uri" : { "high" : "rtp://239.1.1.2:5006", ...
2015/01/27
[ "https://Stackoverflow.com/questions/28168732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498089/" ]
You don't have a base/root element - just a collection of keys and values. You can iterate through them with something like this: ``` import json import pprint values = json.loads(YOUR_JSON_STRING) for v in values: print v, pprint.pprint(values[v]) ``` That will print out the following two elements (each with...
you can get `id` like this(save your json string as a **single line** file as `test.json`): ``` import simplejson as json with open("test.json") as fp: line = fp.readline() json = json.loads(line) for k,v in json.items(): print v.get("id","no id found") # no id found is the default value in case t...
28,168,732
Here is my JSON string which I need to parse. ``` { "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1" : { "@class" : "com.barco.compose.media.transcode.internal.h264.H264Gateway", "id" : "192.168.1.2_151b3a32-ce00-114a-e000-0004a50c1c6d_stream1", "uri" : { "high" : "rtp://239.1.1.2:5006", ...
2015/01/27
[ "https://Stackoverflow.com/questions/28168732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498089/" ]
Found the subject when trying to find a solution for a problem of mine. In the meantime, I think you found a solution but if anyone is passing by check the jsonlines library that is very useful and could solve the problem <https://jsonlines.readthedocs.io/en/latest/>
you can get `id` like this(save your json string as a **single line** file as `test.json`): ``` import simplejson as json with open("test.json") as fp: line = fp.readline() json = json.loads(line) for k,v in json.items(): print v.get("id","no id found") # no id found is the default value in case t...
12,730,524
On this sample code i want to use the variables on the `function db_properties` at the function `connect_and_query`. To accomplish that I choose the `return`. So, using that strategy the code works perfectly. But, in this example the db.properties files only has 4 variables. That said, if the properties file had 20+ va...
2012/10/04
[ "https://Stackoverflow.com/questions/12730524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
If there are a lot of variables, or if you want to easily change the variables being read, return a dictionary. ``` def db_properties(self, *variables): cfgFile='c:\test\db.properties' parser = SafeConfigParser() parser.read(cfgFile) return { variable: parser.get('database', variable) for varia...
You certainly don't want to call `db_properties()` 4 times; just call it once and store the result. It's also almost certainly better to return a dict rather than a tuple, since as it is the caller needs to know what the method returns in order, rather than just having access to the values by their names. As the numbe...
12,730,524
On this sample code i want to use the variables on the `function db_properties` at the function `connect_and_query`. To accomplish that I choose the `return`. So, using that strategy the code works perfectly. But, in this example the db.properties files only has 4 variables. That said, if the properties file had 20+ va...
2012/10/04
[ "https://Stackoverflow.com/questions/12730524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
You certainly don't want to call `db_properties()` 4 times; just call it once and store the result. It's also almost certainly better to return a dict rather than a tuple, since as it is the caller needs to know what the method returns in order, rather than just having access to the values by their names. As the numbe...
NB: untested You could change your db\_properties to return a dict: ``` from functools import partial # call as db_properties('db_host', 'db_name'...) def db_properties(self, *args): parser = SafeConfigParser() parser.read('config file') getter = partial(parser.get, 'database') return dict(zip(args, ...
12,730,524
On this sample code i want to use the variables on the `function db_properties` at the function `connect_and_query`. To accomplish that I choose the `return`. So, using that strategy the code works perfectly. But, in this example the db.properties files only has 4 variables. That said, if the properties file had 20+ va...
2012/10/04
[ "https://Stackoverflow.com/questions/12730524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
You certainly don't want to call `db_properties()` 4 times; just call it once and store the result. It's also almost certainly better to return a dict rather than a tuple, since as it is the caller needs to know what the method returns in order, rather than just having access to the values by their names. As the numbe...
I'd suggest returning a namedtuple: ``` from collections import namedtuple # in db_properties() return namedtuple("dbconfig", "host name user password")( parser.get('database','db_host'), parser.get('database','db_name'), parser.get('database','db_login'), parser.ge...
12,730,524
On this sample code i want to use the variables on the `function db_properties` at the function `connect_and_query`. To accomplish that I choose the `return`. So, using that strategy the code works perfectly. But, in this example the db.properties files only has 4 variables. That said, if the properties file had 20+ va...
2012/10/04
[ "https://Stackoverflow.com/questions/12730524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
If there are a lot of variables, or if you want to easily change the variables being read, return a dictionary. ``` def db_properties(self, *variables): cfgFile='c:\test\db.properties' parser = SafeConfigParser() parser.read(cfgFile) return { variable: parser.get('database', variable) for varia...
NB: untested You could change your db\_properties to return a dict: ``` from functools import partial # call as db_properties('db_host', 'db_name'...) def db_properties(self, *args): parser = SafeConfigParser() parser.read('config file') getter = partial(parser.get, 'database') return dict(zip(args, ...
12,730,524
On this sample code i want to use the variables on the `function db_properties` at the function `connect_and_query`. To accomplish that I choose the `return`. So, using that strategy the code works perfectly. But, in this example the db.properties files only has 4 variables. That said, if the properties file had 20+ va...
2012/10/04
[ "https://Stackoverflow.com/questions/12730524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1323826/" ]
If there are a lot of variables, or if you want to easily change the variables being read, return a dictionary. ``` def db_properties(self, *variables): cfgFile='c:\test\db.properties' parser = SafeConfigParser() parser.read(cfgFile) return { variable: parser.get('database', variable) for varia...
I'd suggest returning a namedtuple: ``` from collections import namedtuple # in db_properties() return namedtuple("dbconfig", "host name user password")( parser.get('database','db_host'), parser.get('database','db_name'), parser.get('database','db_login'), parser.ge...
405,282
I am trying to write a life simulation in python with a variety of animals. It is impossible to name each instance of the classes I am going to use because I have no way of knowing how many there will be. So, my question: How can I automatically give a name to an object? I was thinking of creating a "Herd" class whi...
2009/01/01
[ "https://Stackoverflow.com/questions/405282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hm, well you normally just stuff all those instances in a list and then iterate over that list if you want to do something with them. If you want to automatically keep track of each instance created you can also make the adding to the list implicit in the class' constructor or create a factory method that keeps track o...
you could make an 'animal' class with a name attribute. Or you could programmically define the class like so: ``` from new import classobj my_class=classobj('Foo',(object,),{}) ``` Found this: <http://www.gamedev.net/community/forums/topic.asp?topic_id=445037>
405,282
I am trying to write a life simulation in python with a variety of animals. It is impossible to name each instance of the classes I am going to use because I have no way of knowing how many there will be. So, my question: How can I automatically give a name to an object? I was thinking of creating a "Herd" class whi...
2009/01/01
[ "https://Stackoverflow.com/questions/405282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hm, well you normally just stuff all those instances in a list and then iterate over that list if you want to do something with them. If you want to automatically keep track of each instance created you can also make the adding to the list implicit in the class' constructor or create a factory method that keeps track o...
If you need a way to refer to them individually, it's relatively common to have the class give each instance a unique identifier on initialization: ``` >>> import itertools >>> class Animal(object): ... id_iter = itertools.count(1) ... def __init__(self): ... self.id = self.id_iter.next() ... >>> ...
405,282
I am trying to write a life simulation in python with a variety of animals. It is impossible to name each instance of the classes I am going to use because I have no way of knowing how many there will be. So, my question: How can I automatically give a name to an object? I was thinking of creating a "Herd" class whi...
2009/01/01
[ "https://Stackoverflow.com/questions/405282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hm, well you normally just stuff all those instances in a list and then iterate over that list if you want to do something with them. If you want to automatically keep track of each instance created you can also make the adding to the list implicit in the class' constructor or create a factory method that keeps track o...
Any instance could have a name attribute. So it sounds like you may be asking how to dynamically name a *class*, not an *instance*. If that's the case, you can explicitly set the \_\_name\_\_ attribute of a class, or better yet just create the class with the builtin [type](http://docs.python.org/library/functions.html#...
405,282
I am trying to write a life simulation in python with a variety of animals. It is impossible to name each instance of the classes I am going to use because I have no way of knowing how many there will be. So, my question: How can I automatically give a name to an object? I was thinking of creating a "Herd" class whi...
2009/01/01
[ "https://Stackoverflow.com/questions/405282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Like this? ``` class Animal( object ): pass # lots of details omitted herd= [ Animal() for i in range(10000) ] ``` At this point, herd will have 10,000 distinct instances of the `Animal` class.
you could make an 'animal' class with a name attribute. Or you could programmically define the class like so: ``` from new import classobj my_class=classobj('Foo',(object,),{}) ``` Found this: <http://www.gamedev.net/community/forums/topic.asp?topic_id=445037>