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
56,145,426
I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found". I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name. I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18...
2019/05/15
[ "https://Stackoverflow.com/questions/56145426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39242/" ]
I already suggested it in the comments: You can use a map to count all the values. Here is an **intentionally verbose** example (to make clear what happens): ``` String[] names = {"a","b","a","a","c","b"}; Integer[] numbers = {5,2,3,1,2,1}; Map<String, Integer> totals = new HashMap<String, Integer>(); ...
Using Map will suffice your requirement. It could be done as below String[] names = {"a", "b", "a", "a", "c", "b"}; Integer[] numbers = {5, 2, 3, 1, 2, 1}; Map expectedOut = new HashMap(); ``` for (int i = 0; i < names.length; i++) { if (expectedOut.containsKey(names[i])) expectedOut.put(names[i], expectedOut...
56,145,426
I ran `pip3 install detect-secrets`; but running `detect-secrets` then gives "Command not found". I also tried variations, for example the switch `--user`; `sudo`; and even `pip` rather than `pip3`. Also with underscore in the name. I further added all directories shown in `python3.6 -m site` to my `PATH` (Ubuntu 18...
2019/05/15
[ "https://Stackoverflow.com/questions/56145426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39242/" ]
Here is a working example: ``` import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) { String[] names = {"a","b","a","a","c","b"}; Integer[] numbers = {5,2,3,1,2,1}; Map<String, Integer> occurrences = new HashMap<>(); for(int i ...
Using Map will suffice your requirement. It could be done as below String[] names = {"a", "b", "a", "a", "c", "b"}; Integer[] numbers = {5, 2, 3, 1, 2, 1}; Map expectedOut = new HashMap(); ``` for (int i = 0; i < names.length; i++) { if (expectedOut.containsKey(names[i])) expectedOut.put(names[i], expectedOut...
32,342,761
In my code pasted bellow (which is python 3 code) I expected the for loop to change the original objects (ie I expected NSTEPx to have been changed by the for loop). Since lists and arrays are mutable I should have edited the object by referring to it by the variable "data". However, after this code was run, and I call...
2015/09/02
[ "https://Stackoverflow.com/questions/32342761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5286344/" ]
In your loop, `data` refers to an array (some object). The object referred to is mutable. The variable `data` can be changed as well to refer to something else, but that won't change what's in `alldata` (values that refer to objects) or the variables whose contents you implicitly copied to construct `alldata`. Hence, a...
Python has **no** assignment! `data = value` is strictly a *binding* operation, not an assignment. This is really different then in eg C++ A Python variable is like a label, or a yellow sticky note: you can put it on *something* or move it to something else; it does not (**never**) change the *thing* (object) it is on...
1,381,739
First of all, thank you for taking the time to read this. I am new to developing applications for the Mac and I am having some problems. My application works fine, and that is not the focus of my question. Rather, I have a python program which essentially does this: ``` for i in values: os.system(java program_and...
2009/09/04
[ "https://Stackoverflow.com/questions/1381739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does running Java with headless mode = true fix it? <http://zzamboni.org/brt/2007/12/07/disable-dock-icon-for-java-programs-in-mac-osx-howto/>
As far as I am aware there is no way to disable the annoying double Java bounce without making your Java application a first class citizen on Mac OS X (much like NetBeans, or Eclipse). As for making certain programs not show in the dock, there are .plist modifications that can be made so that the program does not show ...
1,381,739
First of all, thank you for taking the time to read this. I am new to developing applications for the Mac and I am having some problems. My application works fine, and that is not the focus of my question. Rather, I have a python program which essentially does this: ``` for i in values: os.system(java program_and...
2009/09/04
[ "https://Stackoverflow.com/questions/1381739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does running Java with headless mode = true fix it? <http://zzamboni.org/brt/2007/12/07/disable-dock-icon-for-java-programs-in-mac-osx-howto/>
It's certainly possible to write a Java application which doesn't display in the Dock... in fact, it's the default. If your application *is* showing up, it must be doing something which triggers window server access -- your best bet is to try and figure out what that is.
47,314,905
I did import the module with a name, and import it again without a name and both seems to be working fine and gives the same class type. ``` >>> from collections import Counter as c >>> c <class 'collections.Counter'> >>> from collections import Counter >>> Counter <class 'collections.Counter'> ``` How does that wo...
2017/11/15
[ "https://Stackoverflow.com/questions/47314905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3950422/" ]
Using python 2.7.13: ``` >>> from collections import Counter as c >>> c <class 'collections.Counter'> >>> from collections import Counter >>> Counter <class 'collections.Counter'> >>> id(c), id(Counter) (140244739511392, 140244739511392) >>> id(c) == id(Counter) True ``` Yes, `c` and `Counter` are the same. Two vari...
As I remember , everything you define in python is an object belongs to a class. And yes if a variable object has assigned some value and if you create another variable with same value then python wont create a new reference for the second variable but it will use first variables reference for second variable as well. ...
47,314,905
I did import the module with a name, and import it again without a name and both seems to be working fine and gives the same class type. ``` >>> from collections import Counter as c >>> c <class 'collections.Counter'> >>> from collections import Counter >>> Counter <class 'collections.Counter'> ``` How does that wo...
2017/11/15
[ "https://Stackoverflow.com/questions/47314905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3950422/" ]
Using python 2.7.13: ``` >>> from collections import Counter as c >>> c <class 'collections.Counter'> >>> from collections import Counter >>> Counter <class 'collections.Counter'> >>> id(c), id(Counter) (140244739511392, 140244739511392) >>> id(c) == id(Counter) True ``` Yes, `c` and `Counter` are the same. Two vari...
If you take a look at the disassembled code, you can see that it does load the same object. (line 2 and line 14) ``` >>> import dis >>> codeObj = compile("from collections import Counter as c; from collections import Counter", "foo", "exec") >>> dis.dis(codeObj) 1 0 LOAD_CONST 0 (0) ...
24,584,441
I'm trying to execute an operation to each file found by find - with a specific file extension (wma). For example, in python, I would simply write the following script: ``` for file in os.listdir('.'): if file.endswith('wma'): name = file[:-4] command = "ffmpeg -i '{0}.wma' '{0}.mp3'".format(name) ...
2014/07/05
[ "https://Stackoverflow.com/questions/24584441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2014591/" ]
Try to use setMainView method ``` class IndexController extends ControllerBase { public function onConstruct(){ } public function indexAction() { return $this->view->setMainView("login/login"); } } ``` setMainView method use to set the default view. Just put the view name...
Remove the `return` keyword. I believe it is fetching the view you want and then returning it into the base template.
24,584,441
I'm trying to execute an operation to each file found by find - with a specific file extension (wma). For example, in python, I would simply write the following script: ``` for file in os.listdir('.'): if file.endswith('wma'): name = file[:-4] command = "ffmpeg -i '{0}.wma' '{0}.mp3'".format(name) ...
2014/07/05
[ "https://Stackoverflow.com/questions/24584441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2014591/" ]
Try to use setMainView method ``` class IndexController extends ControllerBase { public function onConstruct(){ } public function indexAction() { return $this->view->setMainView("login/login"); } } ``` setMainView method use to set the default view. Just put the view name...
There are two way to use view in phalcon ``` $this->view->pick(array('login/login')); // with layout $this->view->pick('login/login'); // without layout ```
24,584,441
I'm trying to execute an operation to each file found by find - with a specific file extension (wma). For example, in python, I would simply write the following script: ``` for file in os.listdir('.'): if file.endswith('wma'): name = file[:-4] command = "ffmpeg -i '{0}.wma' '{0}.mp3'".format(name) ...
2014/07/05
[ "https://Stackoverflow.com/questions/24584441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2014591/" ]
Try to use setMainView method ``` class IndexController extends ControllerBase { public function onConstruct(){ } public function indexAction() { return $this->view->setMainView("login/login"); } } ``` setMainView method use to set the default view. Just put the view name...
You can set action view only by `setRenderLevel` ``` public function indexAction() { $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); return $this->view->pick(array("login/login")); } ```
22,949,270
Is there a way how to switch off (and on later) this check at runtime? The motivation is that I need to use third party libraries which do not care about tabs and spaces mixing and thus running my code with [`-t` switch](https://docs.python.org/2/using/cmdline.html#cmdoption-t "switch") issues warnings. (I hope that ...
2014/04/08
[ "https://Stackoverflow.com/questions/22949270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/542196/" ]
Taking a straight percentage of views doesn't give an accurate representation of the item's popularity, either. Although 9 likes out of 18 is "stronger" than 9 likes out of 500, the fact that one video got 500 views and the other got only 18 is a much stronger indication of the video's popularity. A video that gets a ...
A simple approach would be to come up with a suitable scale factor for each average - and then sum the "weights". The difficult part would be tweaking the scale factors to produce the desired ordering. From your example data, a starting point might be something like: ``` Weighted Rating = (AV * (1 / 50)) + (AL * 3) -...
22,949,270
Is there a way how to switch off (and on later) this check at runtime? The motivation is that I need to use third party libraries which do not care about tabs and spaces mixing and thus running my code with [`-t` switch](https://docs.python.org/2/using/cmdline.html#cmdoption-t "switch") issues warnings. (I hope that ...
2014/04/08
[ "https://Stackoverflow.com/questions/22949270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/542196/" ]
Taking a straight percentage of views doesn't give an accurate representation of the item's popularity, either. Although 9 likes out of 18 is "stronger" than 9 likes out of 500, the fact that one video got 500 views and the other got only 18 is a much stronger indication of the video's popularity. A video that gets a ...
Every video have: * likes * dislikes * views * upload\_date So we can deduct the following parameters from them: * like\_rate = likes/views * dislike\_rate = likes/views * view\_rate = views/number\_of\_website\_users * video\_age = count\_days(upload\_date, today) * avg\_views = views/upload\_age * avg\_likes = lik...
22,949,270
Is there a way how to switch off (and on later) this check at runtime? The motivation is that I need to use third party libraries which do not care about tabs and spaces mixing and thus running my code with [`-t` switch](https://docs.python.org/2/using/cmdline.html#cmdoption-t "switch") issues warnings. (I hope that ...
2014/04/08
[ "https://Stackoverflow.com/questions/22949270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/542196/" ]
Taking a straight percentage of views doesn't give an accurate representation of the item's popularity, either. Although 9 likes out of 18 is "stronger" than 9 likes out of 500, the fact that one video got 500 views and the other got only 18 is a much stronger indication of the video's popularity. A video that gets a ...
Since no one has pointed it out yet (and I'm a bit surprised), I'll do it. The problem with any ranking algorithm ***we*** might come up with is that it's based on ***our*** point of view. What you're certainly looking for is an algorithm that accomodates the ***median user*** point of view. This is no new idea. Netf...
22,949,270
Is there a way how to switch off (and on later) this check at runtime? The motivation is that I need to use third party libraries which do not care about tabs and spaces mixing and thus running my code with [`-t` switch](https://docs.python.org/2/using/cmdline.html#cmdoption-t "switch") issues warnings. (I hope that ...
2014/04/08
[ "https://Stackoverflow.com/questions/22949270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/542196/" ]
I can point you to a non-parametric way to get the best ordering with respect to a weighted linear scoring system without knowing exactly what weights you want to use (just constraints on the weights). First though, note that average daily views might be misleading because movies are probably downloaded less in later y...
A simple approach would be to come up with a suitable scale factor for each average - and then sum the "weights". The difficult part would be tweaking the scale factors to produce the desired ordering. From your example data, a starting point might be something like: ``` Weighted Rating = (AV * (1 / 50)) + (AL * 3) -...
22,949,270
Is there a way how to switch off (and on later) this check at runtime? The motivation is that I need to use third party libraries which do not care about tabs and spaces mixing and thus running my code with [`-t` switch](https://docs.python.org/2/using/cmdline.html#cmdoption-t "switch") issues warnings. (I hope that ...
2014/04/08
[ "https://Stackoverflow.com/questions/22949270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/542196/" ]
I can point you to a non-parametric way to get the best ordering with respect to a weighted linear scoring system without knowing exactly what weights you want to use (just constraints on the weights). First though, note that average daily views might be misleading because movies are probably downloaded less in later y...
Every video have: * likes * dislikes * views * upload\_date So we can deduct the following parameters from them: * like\_rate = likes/views * dislike\_rate = likes/views * view\_rate = views/number\_of\_website\_users * video\_age = count\_days(upload\_date, today) * avg\_views = views/upload\_age * avg\_likes = lik...
22,949,270
Is there a way how to switch off (and on later) this check at runtime? The motivation is that I need to use third party libraries which do not care about tabs and spaces mixing and thus running my code with [`-t` switch](https://docs.python.org/2/using/cmdline.html#cmdoption-t "switch") issues warnings. (I hope that ...
2014/04/08
[ "https://Stackoverflow.com/questions/22949270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/542196/" ]
I can point you to a non-parametric way to get the best ordering with respect to a weighted linear scoring system without knowing exactly what weights you want to use (just constraints on the weights). First though, note that average daily views might be misleading because movies are probably downloaded less in later y...
Since no one has pointed it out yet (and I'm a bit surprised), I'll do it. The problem with any ranking algorithm ***we*** might come up with is that it's based on ***our*** point of view. What you're certainly looking for is an algorithm that accomodates the ***median user*** point of view. This is no new idea. Netf...
73,668,351
I have connected an Arduino to a raspberry pi so that a specific event is triggered when I send a signal(in this case a number). When I send a number with the script and tell it just to print in serial monitor it works, when I try and just have it run the motors on start it works fine, however when combining the two: h...
2022/09/09
[ "https://Stackoverflow.com/questions/73668351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12527861/" ]
Since you're using func `firstIndex` of an array in this `func indexOfItem(_ item: Item) -> Int?` therefore the `Item` has to be a concrete object (behind the scene of `firstIndex` func is comparing each element of an array and print out the index of the element). There are 2 ways to do this * First is using associat...
Finally find simple enough solution: То make protocol generic with associated type and constraint this type to Equatable. ``` public protocol Container { associatedtype EquatableItem: Item, Equatable var items: [EquatableItem] {get} } public protocol Item { var name: String {get} } public extension Cont...
59,796,680
I recently moved to a place with terrible internet connection. Ever since then I have been having huge issues getting my programming environments set up with all the tools I need - you don't realize how many things you need to download until each one of those things takes over a day. For this post I would like to try t...
2020/01/18
[ "https://Stackoverflow.com/questions/59796680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6036156/" ]
Use option `--timeout <sec>` to set socket time out. Also, as @Iain Shelvington mentioned, `timeout = <sec>` in [pip configuration](https://pip.pypa.io/en/stable/user_guide/#configuration) will also work. *TIP: Every time you want to know something (maybe an option) about a command (tool), before googling, check the ...
To set the `timeout` time to 30sec for example. The easiest way is executing: `pip config global.timeout 30` or going to the pip configuration file ***pip.ini*** located in the directory ***~\AppData\Roaming\pip*** in the case of Windows operating system. If the file does not exist there, create it and write: ``` [glo...
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
The traceback indicates the failure happens when trying to check for SDK updates, so you *should* be able to work around it by using `appcfg.py`'s `--skip_sdk_update_check` option. I'm not using the PHP SDK, but I found a similar failure in the SDK upgrade check for the python development server, my solution for that ...
If it is really a SSL handshake error than check to see if machine that you are using to access is behind a firewall. If you are than you will have a problem you might have to ask you network guys to open network up. alternatively you can try to get on to network that is not behind firewall. I might be wrong but I have...
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
Finally got it working. Using PHPstorm IDE for deploying don't work, but using gcloud in command line works perfectly for deploying. Maby PHPstorm adds some config or parameters when deploying but i used the command line and it worked like charm ``` gcloud app deploy app.yaml --project <project name> --promote --quie...
The traceback indicates the failure happens when trying to check for SDK updates, so you *should* be able to work around it by using `appcfg.py`'s `--skip_sdk_update_check` option. I'm not using the PHP SDK, but I found a similar failure in the SDK upgrade check for the python development server, my solution for that ...
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
The traceback indicates the failure happens when trying to check for SDK updates, so you *should* be able to work around it by using `appcfg.py`'s `--skip_sdk_update_check` option. I'm not using the PHP SDK, but I found a similar failure in the SDK upgrade check for the python development server, my solution for that ...
Scene is very clear. Google want you be moved to a premature version of Google cloud SDK CLI tool, for which even documentation is still half way. There are still basic features pending on Google Cloud SDK cli tool. Testing patience. What you can do now is flush current GAE version 57/58 and install a old version of G...
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
Finally got it working. Using PHPstorm IDE for deploying don't work, but using gcloud in command line works perfectly for deploying. Maby PHPstorm adds some config or parameters when deploying but i used the command line and it worked like charm ``` gcloud app deploy app.yaml --project <project name> --promote --quie...
If it is really a SSL handshake error than check to see if machine that you are using to access is behind a firewall. If you are than you will have a problem you might have to ask you network guys to open network up. alternatively you can try to get on to network that is not behind firewall. I might be wrong but I have...
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
Upgrading httplib2 fixed to me! ``` sudo pip2 install --upgrade httplib2 -t /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/httplib2/ ```
If it is really a SSL handshake error than check to see if machine that you are using to access is behind a firewall. If you are than you will have a problem you might have to ask you network guys to open network up. alternatively you can try to get on to network that is not behind firewall. I might be wrong but I have...
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
Finally got it working. Using PHPstorm IDE for deploying don't work, but using gcloud in command line works perfectly for deploying. Maby PHPstorm adds some config or parameters when deploying but i used the command line and it worked like charm ``` gcloud app deploy app.yaml --project <project name> --promote --quie...
Scene is very clear. Google want you be moved to a premature version of Google cloud SDK CLI tool, for which even documentation is still half way. There are still basic features pending on Google Cloud SDK cli tool. Testing patience. What you can do now is flush current GAE version 57/58 and install a old version of G...
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
Finally got it working. Using PHPstorm IDE for deploying don't work, but using gcloud in command line works perfectly for deploying. Maby PHPstorm adds some config or parameters when deploying but i used the command line and it worked like charm ``` gcloud app deploy app.yaml --project <project name> --promote --quie...
Upgrading httplib2 fixed to me! ``` sudo pip2 install --upgrade httplib2 -t /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/httplib2/ ```
45,934,259
I am working on a simple project on PhpStorm and installed GAE plugin and SDK. Running a server and show the project works, but when I try to deploy my application I get this kind of error: (This is a PHP project) ``` C:\Python27\python.exe "C:/Users/asim/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google...
2017/08/29
[ "https://Stackoverflow.com/questions/45934259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6428568/" ]
Upgrading httplib2 fixed to me! ``` sudo pip2 install --upgrade httplib2 -t /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/httplib2/ ```
Scene is very clear. Google want you be moved to a premature version of Google cloud SDK CLI tool, for which even documentation is still half way. There are still basic features pending on Google Cloud SDK cli tool. Testing patience. What you can do now is flush current GAE version 57/58 and install a old version of G...
42,081,376
I have exactly opposite issue described [here](https://stackoverflow.com/q/11489330/2215679). In my case I have: logging.py ``` import logging log = logging.getLogger(..) ``` I got this error: ``` AttributeError: 'module' object has no attribute 'getLogger' ``` This happens only on project with python 2.7 run u...
2017/02/07
[ "https://Stackoverflow.com/questions/42081376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2215679/" ]
I found solution, just putting: ``` from __future__ import absolute_import ``` on top of the file will resolve the issue. source: [https://docs.python.org/2/library/**future**.html](https://docs.python.org/2/library/__future__.html) As you may see, in python 3>= absolute import is by default
> > It is better to rename your local file to be different with builtin module name. > > >
44,395,941
OK, so I am currently messing around coding hangman in python and was wondering if I can clear what it says in the python shell as I don't just wan't the person to read the word. ``` import time keyword = input(" Please enter the word you want the person to guess") lives = int(input("How many lives would you like to h...
2017/06/06
[ "https://Stackoverflow.com/questions/44395941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8020756/" ]
if you are a windows user use this: ``` import os os.system("cls") ``` Mac/linux then : ``` import os os.system("clear") ```
Try this: ``` import subprocess import time tmp=subprocess.call('clear', shell=True) # 'cls' in windows keyword = input(" Please enter the word you want the person to guess") lives = int(input("How many lives would you like to have?")) print ("There are ", len(keyword), "letters in the word") time.sleep(2) ``` Sav...
44,395,941
OK, so I am currently messing around coding hangman in python and was wondering if I can clear what it says in the python shell as I don't just wan't the person to read the word. ``` import time keyword = input(" Please enter the word you want the person to guess") lives = int(input("How many lives would you like to h...
2017/06/06
[ "https://Stackoverflow.com/questions/44395941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8020756/" ]
if you are a windows user use this: ``` import os os.system("cls") ``` Mac/linux then : ``` import os os.system("clear") ```
``` print("\n" * 100) ``` There is no other way to do it then to just spam the console.
44,395,941
OK, so I am currently messing around coding hangman in python and was wondering if I can clear what it says in the python shell as I don't just wan't the person to read the word. ``` import time keyword = input(" Please enter the word you want the person to guess") lives = int(input("How many lives would you like to h...
2017/06/06
[ "https://Stackoverflow.com/questions/44395941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8020756/" ]
if you are a windows user use this: ``` import os os.system("cls") ``` Mac/linux then : ``` import os os.system("clear") ```
`os.system("cls")` for windows or `os.system("clear")` for mac/linux. Then put that line of code where you wish for the program to delete all the text in the shell.
67,611,765
``` i = SomeIndex() while mylist[i] is not None: if mylist[i] == name: return foo() i+=1 ``` I want foo() to always run on 1st iteration of loop, if mylist[i] isn't 'name', but never run if its any iteration but the first. I know I could the following, but I don't know if it's the most efficient and p...
2021/05/19
[ "https://Stackoverflow.com/questions/67611765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14725111/" ]
Let's "pythonize" your example, step by step. **1. Remove the `first_index` flag:** ``` start_idx = SomeIndex() i = start_idx while mylist[i] is not None: if mylist[i] == name: return if i == start_idx: foo() i += 1 ``` **2. Convert to `while True`:** ``` start_idx = SomeIndex() i = st...
You are trying to emulate a do-while, take a look at [this question](https://stackoverflow.com/questions/743164/how-to-emulate-a-do-while-loop) if you want. Since there is no do-while equivalent in Python, the simple idea is to move the first iteration out of the loop ``` i = SomeIndex() foo() while mylist[i] is not ...
67,611,765
``` i = SomeIndex() while mylist[i] is not None: if mylist[i] == name: return foo() i+=1 ``` I want foo() to always run on 1st iteration of loop, if mylist[i] isn't 'name', but never run if its any iteration but the first. I know I could the following, but I don't know if it's the most efficient and p...
2021/05/19
[ "https://Stackoverflow.com/questions/67611765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14725111/" ]
Personally I like `mark_ends` from the third party library `more-itertools` ``` from more_itertools import mark_ends i = SomeIndex() for first, last, elem in mark_ends(mylist[i:]): if elem == name: return if first: foo() ``` `mark_ends` gives you a 3-tuple for every element in your iterable,...
You are trying to emulate a do-while, take a look at [this question](https://stackoverflow.com/questions/743164/how-to-emulate-a-do-while-loop) if you want. Since there is no do-while equivalent in Python, the simple idea is to move the first iteration out of the loop ``` i = SomeIndex() foo() while mylist[i] is not ...
67,611,765
``` i = SomeIndex() while mylist[i] is not None: if mylist[i] == name: return foo() i+=1 ``` I want foo() to always run on 1st iteration of loop, if mylist[i] isn't 'name', but never run if its any iteration but the first. I know I could the following, but I don't know if it's the most efficient and p...
2021/05/19
[ "https://Stackoverflow.com/questions/67611765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14725111/" ]
Let's "pythonize" your example, step by step. **1. Remove the `first_index` flag:** ``` start_idx = SomeIndex() i = start_idx while mylist[i] is not None: if mylist[i] == name: return if i == start_idx: foo() i += 1 ``` **2. Convert to `while True`:** ``` start_idx = SomeIndex() i = st...
Simplify your logic to independent steps. Yes, you will make a Boolean value check a second time. This takes far less time than you spent with your design problem. ``` start = SomeIndex() if mylist[start] != name: foo() for idx in range(start, len(mylist)): if mylist[idx] == name: return # remainder...
67,611,765
``` i = SomeIndex() while mylist[i] is not None: if mylist[i] == name: return foo() i+=1 ``` I want foo() to always run on 1st iteration of loop, if mylist[i] isn't 'name', but never run if its any iteration but the first. I know I could the following, but I don't know if it's the most efficient and p...
2021/05/19
[ "https://Stackoverflow.com/questions/67611765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14725111/" ]
Personally I like `mark_ends` from the third party library `more-itertools` ``` from more_itertools import mark_ends i = SomeIndex() for first, last, elem in mark_ends(mylist[i:]): if elem == name: return if first: foo() ``` `mark_ends` gives you a 3-tuple for every element in your iterable,...
Simplify your logic to independent steps. Yes, you will make a Boolean value check a second time. This takes far less time than you spent with your design problem. ``` start = SomeIndex() if mylist[start] != name: foo() for idx in range(start, len(mylist)): if mylist[idx] == name: return # remainder...
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
`urlparse` quite happily takes invalid URLs, it is more a string string-splitting library than any kind of validator. For example: ``` from urlparse import urlparse urlparse('http://----') # returns: ParseResult(scheme='http', netloc='----', path='', params='', query='', fragment='') ``` Depending on the situation, ...
The regex provided should match any url of the form <http://www.ietf.org/rfc/rfc3986.txt>; and does when tested in the python interpreter. What format have the URLs you've been having trouble parsing had?
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
Nowadays, in 90% of case if you working with URL in Python you probably use python-requests. Hence the question here - why not reuse URL validation from requests? ``` from requests.models import PreparedRequest import requests.exceptions def check_url(url): prepared_request = PreparedRequest() try: pr...
The regex provided should match any url of the form <http://www.ietf.org/rfc/rfc3986.txt>; and does when tested in the python interpreter. What format have the URLs you've been having trouble parsing had?
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
Here's the complete regexp to parse a URL. ```none (?:https?://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?) \.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d +)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA -F\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),...
modified django url validation regex: ===================================== ``` import re ul = '\u00a1-\uffff' # unicode letters range (must not be a raw string) # IP patterns ipv4_re = r'(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}' ipv6_re = r'\[[0-9a-f:\.]+\]' # Host patterns hos...
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
<http://pypi.python.org/pypi/rfc3987> gives regular expressions for consistency with the rules in RFC 3986 and RFC 3987 (that is, not with scheme-specific rules). A regexp for IRI\_reference is: ``` (?P<scheme>[a-zA-Z][a-zA-Z0-9+.-]*):(?://(?P<iauthority>(?:(?P<iuserinfo>(?:(?:[ a-zA-Z0-9._~-]|[\xa0-\ud7ff\uf900-\ufd...
The regex provided should match any url of the form <http://www.ietf.org/rfc/rfc3986.txt>; and does when tested in the python interpreter. What format have the URLs you've been having trouble parsing had?
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
I admit, I find your regular expression totally incomprehensible. I wonder if you could use urlparse instead? Something like: ``` pieces = urlparse.urlparse(url) assert all([pieces.scheme, pieces.netloc]) assert set(pieces.netloc) <= set(string.letters + string.digits + '-.') # and others? assert pieces.scheme in ['h...
The regex provided should match any url of the form <http://www.ietf.org/rfc/rfc3986.txt>; and does when tested in the python interpreter. What format have the URLs you've been having trouble parsing had?
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
<http://pypi.python.org/pypi/rfc3987> gives regular expressions for consistency with the rules in RFC 3986 and RFC 3987 (that is, not with scheme-specific rules). A regexp for IRI\_reference is: ``` (?P<scheme>[a-zA-Z][a-zA-Z0-9+.-]*):(?://(?P<iauthority>(?:(?P<iuserinfo>(?:(?:[ a-zA-Z0-9._~-]|[\xa0-\ud7ff\uf900-\ufd...
I've needed to do this many times over the years and always end up copying someone else's regular expression who has thought about it way more than I *want* to think about it. Having said that, there is a regex in the Django forms code which should do the trick: <http://code.djangoproject.com/browser/django/trunk/dja...
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
Here's the complete regexp to parse a URL. ```none (?:https?://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?) \.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d +)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA -F\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),...
I've needed to do this many times over the years and always end up copying someone else's regular expression who has thought about it way more than I *want* to think about it. Having said that, there is a regex in the Django forms code which should do the trick: <http://code.djangoproject.com/browser/django/trunk/dja...
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
An easy way to parse (and validate) URL's is the `urlparse` ([py2](https://docs.python.org/2/library/urlparse.html), [py3](https://docs.python.org/3.0/library/urllib.parse.html)) module. A regex is too much work. --- There's no "validate" method because almost anything is a valid URL. There are some punctuation rul...
``` urlfinders = [ re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+)(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\),\\\"]"), re.compile("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]...
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
An easy way to parse (and validate) URL's is the `urlparse` ([py2](https://docs.python.org/2/library/urlparse.html), [py3](https://docs.python.org/3.0/library/urllib.parse.html)) module. A regex is too much work. --- There's no "validate" method because almost anything is a valid URL. There are some punctuation rul...
modified django url validation regex: ===================================== ``` import re ul = '\u00a1-\uffff' # unicode letters range (must not be a raw string) # IP patterns ipv4_re = r'(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}' ipv6_re = r'\[[0-9a-f:\.]+\]' # Host patterns hos...
827,557
I'm building an app on Google App Engine. I'm incredibly new to Python and have been beating my head against the following problem for the past 3 days. I have a class to represent an RSS Feed and in this class I have a method called setUrl. Input to this method is a URL. I'm trying to use the re python module to val...
2009/05/06
[ "https://Stackoverflow.com/questions/827557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91163/" ]
I'm using the one used by Django and it seems to work pretty well: ``` def is_valid_url(url): import re regex = re.compile( r'^https?://' # http:// or https:// r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' # domain... r'localhost|' # localhost... r'\d{1,3}\....
The regex provided should match any url of the form <http://www.ietf.org/rfc/rfc3986.txt>; and does when tested in the python interpreter. What format have the URLs you've been having trouble parsing had?
55,381,039
I am trying to get a dynamic text displayed in the system tray (this will be 2 numbers (from 1 to 100) changing every 2 minutes). I found this [script](http://code.activestate.com/recipes/475155-dynamic-system-tray-icon-wxpython/) as a starting point (but I am not commited to it!). But I get this error : ``` TypeE...
2019/03/27
[ "https://Stackoverflow.com/questions/55381039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154274/" ]
I think this issue was occurring due to using the OpenJDK and not the OracleJDK. I am no longer having this issue since changing the project SDK to the OracleJDK, so if anyone else ever has this issue in the future... that may be the fix.
* Be sure to see also the Swing/Seesaw section [from the Clojure Cookbook](https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-25_seesaw/4-25_making-a-window.asciidoc) * [The newer fn/fx lib](https://github.com/fn-fx/fn-fx) for using JavaFX from Clojure.
55,381,039
I am trying to get a dynamic text displayed in the system tray (this will be 2 numbers (from 1 to 100) changing every 2 minutes). I found this [script](http://code.activestate.com/recipes/475155-dynamic-system-tray-icon-wxpython/) as a starting point (but I am not commited to it!). But I get this error : ``` TypeE...
2019/03/27
[ "https://Stackoverflow.com/questions/55381039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154274/" ]
I've seen the `CompilerException java.awt.AWTError: Assistive Technology not found` when trying to run a PDF generation code (which uses AWT) on a linux server with OpenJDK 8. After a switch to JDK 10/11 the error went away. There might be lots of "fun" issues with graphics-related code, especially when you run on a s...
* Be sure to see also the Swing/Seesaw section [from the Clojure Cookbook](https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-25_seesaw/4-25_making-a-window.asciidoc) * [The newer fn/fx lib](https://github.com/fn-fx/fn-fx) for using JavaFX from Clojure.
50,431,371
I am trying to create a python program that uses user input in an equation. When I run the program, it gives this error code, "answer = ((((A\*10**A)\*\*2)**(B\*C))\*D\*\*E) TypeError: unsupported operand type(s) for \*\* or pow(): 'int' and 'str'". My code is: ``` import cmath A = input("Enter a number for A: ") B ...
2018/05/20
[ "https://Stackoverflow.com/questions/50431371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6754577/" ]
The [`input()`](https://docs.python.org/3/library/functions.html#input) function returns a string value: you need to convert to a number using `Decimal`: ``` from decimal import Decimal A = Decimal(input("Enter a number for A: ")) # ... etc ``` But your user might enter something that isn't a decimal number, so you...
The compiler thinks your inputs are of string type. You can wrap each of A, B, C, D, E with float() to cast the input into float type, provided you're actually inputting numbers at the terminal. This way, you're taking powers of float numbers instead of strings, which python doesn't know how to handle. ``` A = float(i...
50,431,371
I am trying to create a python program that uses user input in an equation. When I run the program, it gives this error code, "answer = ((((A\*10**A)\*\*2)**(B\*C))\*D\*\*E) TypeError: unsupported operand type(s) for \*\* or pow(): 'int' and 'str'". My code is: ``` import cmath A = input("Enter a number for A: ") B ...
2018/05/20
[ "https://Stackoverflow.com/questions/50431371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6754577/" ]
The [`input()`](https://docs.python.org/3/library/functions.html#input) function returns a string value: you need to convert to a number using `Decimal`: ``` from decimal import Decimal A = Decimal(input("Enter a number for A: ")) # ... etc ``` But your user might enter something that isn't a decimal number, so you...
[`input()`](https://docs.python.org/3/library/functions.html#input) returns a string, you have to convert your inputs to [integers](https://docs.python.org/3/library/functions.html#int) (or [floats](https://docs.python.org/3/library/functions.html#float), or [decimals](https://docs.python.org/3/library/decimal.html#dec...
50,431,371
I am trying to create a python program that uses user input in an equation. When I run the program, it gives this error code, "answer = ((((A\*10**A)\*\*2)**(B\*C))\*D\*\*E) TypeError: unsupported operand type(s) for \*\* or pow(): 'int' and 'str'". My code is: ``` import cmath A = input("Enter a number for A: ") B ...
2018/05/20
[ "https://Stackoverflow.com/questions/50431371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6754577/" ]
The [`input()`](https://docs.python.org/3/library/functions.html#input) function returns a string value: you need to convert to a number using `Decimal`: ``` from decimal import Decimal A = Decimal(input("Enter a number for A: ")) # ... etc ``` But your user might enter something that isn't a decimal number, so you...
That code would run fine for python 2.7 I think you are using python 3.5+ so you have to cast the variable so this would become like this ``` import cmath A = int(input("Enter a number for A: ")) B = int(input("Enter a number for B: ")) C = int(input("Enter a number for C: ")) D = int(input("Enter a number for D: "))...
50,431,371
I am trying to create a python program that uses user input in an equation. When I run the program, it gives this error code, "answer = ((((A\*10**A)\*\*2)**(B\*C))\*D\*\*E) TypeError: unsupported operand type(s) for \*\* or pow(): 'int' and 'str'". My code is: ``` import cmath A = input("Enter a number for A: ") B ...
2018/05/20
[ "https://Stackoverflow.com/questions/50431371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6754577/" ]
The [`input()`](https://docs.python.org/3/library/functions.html#input) function returns a string value: you need to convert to a number using `Decimal`: ``` from decimal import Decimal A = Decimal(input("Enter a number for A: ")) # ... etc ``` But your user might enter something that isn't a decimal number, so you...
there are three ways to fix it, either ``` A = int(input("Enter a number for A: ")) B = int(input("Enter a number for B: ")) C = int(input("Enter a number for C: ")) D = int(input("Enter a number for D: ")) E = int(input("Enter a number for E: ")) ``` which limits you to integers (whole numbers) or: ``` A = float...
14,228,659
I can add the XML node using the ElementTree, but this returns the output in one single line instead of a tree structure look alike when I open the xml file in text format. I also tried using the minidom.toprettyxml but I do not know how to add the output to original XML. Since I would like the script to be reproducibl...
2013/01/09
[ "https://Stackoverflow.com/questions/14228659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1027101/" ]
when dealing with element, you can do like this: `element.tail = '\n'` then,it will be written in single line.
write your xml in elementTree as: ``` import xml.etree.ElementTree as ET def serialize_xml(write, elem, encoding, qnames, namespaces): tag = elem.tag text = elem.text if tag is ET.Comment: write("<!--%s-->" % _encode(text, encoding)) elif tag is ET.ProcessingInstruction: write("<?%s?>"...
14,228,659
I can add the XML node using the ElementTree, but this returns the output in one single line instead of a tree structure look alike when I open the xml file in text format. I also tried using the minidom.toprettyxml but I do not know how to add the output to original XML. Since I would like the script to be reproducibl...
2013/01/09
[ "https://Stackoverflow.com/questions/14228659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1027101/" ]
when dealing with element, you can do like this: `element.tail = '\n'` then,it will be written in single line.
I think you must try [lxml library](http://lxml.de/tutorial.html). It's the best way to parse XML in Python. It has magic argument \*pretty\_print\* for such things. Here's an example: ``` import lxml.etree as etree root = etree.Element("root") for rn in range(10): etree.SubElement(root, "column_%s" % str(rn)).te...
2,565,415
What is the right way to forming in-memory table in python with direct lookups for rows and columns. I thought of using dict of dicts this way, ``` class Table(dict): def __getitem__(self, key): if key not in self: self[key]={} return dict.__getitem__(self, key) table = Table() tab...
2010/04/02
[ "https://Stackoverflow.com/questions/2565415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231295/" ]
I'd use an [in-memory database](http://www.sqlite.org/inmemorydb.html) with [SQLite](http://docs.python.org/library/sqlite3.html) for this. The sqlite module is even in the standard library since Python 2.5, which means this doesn't even add much to your requirements.
A nested list should be able to do the job here. I would only use nested dictionaries if elements are spread thin across the grid. ``` grid = [] for row in height: grid.append([]) for cell in width: grid[-1].append(value) ``` Checking rows is easy: ``` def valueInRow(value, row): return value in grid[...
2,565,415
What is the right way to forming in-memory table in python with direct lookups for rows and columns. I thought of using dict of dicts this way, ``` class Table(dict): def __getitem__(self, key): if key not in self: self[key]={} return dict.__getitem__(self, key) table = Table() tab...
2010/04/02
[ "https://Stackoverflow.com/questions/2565415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231295/" ]
I'd use an [in-memory database](http://www.sqlite.org/inmemorydb.html) with [SQLite](http://docs.python.org/library/sqlite3.html) for this. The sqlite module is even in the standard library since Python 2.5, which means this doesn't even add much to your requirements.
> > Now how do I do lookup if 'column1' has 'value11' > > > Are you asking about this? ``` found= False for r in table: if table[r]['column1'] == 'value11' found= True break ``` Is this what you're trying to do?
2,565,415
What is the right way to forming in-memory table in python with direct lookups for rows and columns. I thought of using dict of dicts this way, ``` class Table(dict): def __getitem__(self, key): if key not in self: self[key]={} return dict.__getitem__(self, key) table = Table() tab...
2010/04/02
[ "https://Stackoverflow.com/questions/2565415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231295/" ]
> > Now how do I do lookup if 'column1' > has 'value11' > > > `any(arow['column1'] == 'value11' for arow in table.iteritems())` > > Is this method of forming tables > wrong? > > > No, it's just very "exposed", perhaps too much -- it could usefully be encapsulated in a class which exposes the methods you ne...
I'd use an [in-memory database](http://www.sqlite.org/inmemorydb.html) with [SQLite](http://docs.python.org/library/sqlite3.html) for this. The sqlite module is even in the standard library since Python 2.5, which means this doesn't even add much to your requirements.
2,565,415
What is the right way to forming in-memory table in python with direct lookups for rows and columns. I thought of using dict of dicts this way, ``` class Table(dict): def __getitem__(self, key): if key not in self: self[key]={} return dict.__getitem__(self, key) table = Table() tab...
2010/04/02
[ "https://Stackoverflow.com/questions/2565415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231295/" ]
> > Now how do I do lookup if 'column1' > has 'value11' > > > `any(arow['column1'] == 'value11' for arow in table.iteritems())` > > Is this method of forming tables > wrong? > > > No, it's just very "exposed", perhaps too much -- it could usefully be encapsulated in a class which exposes the methods you ne...
A nested list should be able to do the job here. I would only use nested dictionaries if elements are spread thin across the grid. ``` grid = [] for row in height: grid.append([]) for cell in width: grid[-1].append(value) ``` Checking rows is easy: ``` def valueInRow(value, row): return value in grid[...
2,565,415
What is the right way to forming in-memory table in python with direct lookups for rows and columns. I thought of using dict of dicts this way, ``` class Table(dict): def __getitem__(self, key): if key not in self: self[key]={} return dict.__getitem__(self, key) table = Table() tab...
2010/04/02
[ "https://Stackoverflow.com/questions/2565415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231295/" ]
> > Now how do I do lookup if 'column1' > has 'value11' > > > `any(arow['column1'] == 'value11' for arow in table.iteritems())` > > Is this method of forming tables > wrong? > > > No, it's just very "exposed", perhaps too much -- it could usefully be encapsulated in a class which exposes the methods you ne...
> > Now how do I do lookup if 'column1' has 'value11' > > > Are you asking about this? ``` found= False for r in table: if table[r]['column1'] == 'value11' found= True break ``` Is this what you're trying to do?
6,184,079
Similar questions have been asked, but I have not come across an easy-to-do-it way We have some application logs of various kinds which fill up the space and we face other unwanted issues. How do I write a monitoring script(zipping files of particular size, moving them, watching them, etc..) for this maintenance? I am...
2011/05/31
[ "https://Stackoverflow.com/questions/6184079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/294714/" ]
The "standard" way of doing this (atleast on most Gnu/Linux distros) is to use [logrotate](http://www.linuxcommand.org/man_pages/logrotate8.html). I see a `/etc/logrotate.conf` on my Debian machine which has details on which files to rotate and at what frequency. It's triggered by a daily cron entry. This is what I'd r...
Use [logrotate](http://linuxcommand.org/man_pages/logrotate8.html) to do the work for you. Remember that there are few cases where it **may not work properly**, for example if the logging application keeps the log file always open and is not able to resume it if the file is removed and recreated. Over the years I enc...
54,446,492
I have a requirement where I have to trigger a dataset in a blob to my python code where processing will happen and then store the processed dataset to the blob? Where should I do it? Any notebooks? Azure functions dont have an option to write a Python code. Any help would be appreciated.
2019/01/30
[ "https://Stackoverflow.com/questions/54446492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9668890/" ]
The difference here is *really* subtle, and can only *easily* be appreciated in IL: ``` class MyBuilder1 { private MySynchronizer m_synchronizer = new MySynchronizer(); public MyBuilder1() { } } ``` gives us the constructor: ``` .method public hidebysig specialname rtspecialname instance void...
I almost always choose the second one option (initializing inside the constructor). In my point of view it keeps your code more readable and the control logic is inside the constructor which gives more flexibility to add logic in the future. But again, it is only my personal opinion.
54,446,492
I have a requirement where I have to trigger a dataset in a blob to my python code where processing will happen and then store the processed dataset to the blob? Where should I do it? Any notebooks? Azure functions dont have an option to write a Python code. Any help would be appreciated.
2019/01/30
[ "https://Stackoverflow.com/questions/54446492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9668890/" ]
The difference here is *really* subtle, and can only *easily* be appreciated in IL: ``` class MyBuilder1 { private MySynchronizer m_synchronizer = new MySynchronizer(); public MyBuilder1() { } } ``` gives us the constructor: ``` .method public hidebysig specialname rtspecialname instance void...
As @Marc already mentioned, the difference is in the order of the base constructor. I have added the base constructor ``` class Base { public Base() { Console.WriteLine("Inside Base constructor"); } } ``` and modified my class "MyBuilder" to derived from it as; ``` cl...
54,446,492
I have a requirement where I have to trigger a dataset in a blob to my python code where processing will happen and then store the processed dataset to the blob? Where should I do it? Any notebooks? Azure functions dont have an option to write a Python code. Any help would be appreciated.
2019/01/30
[ "https://Stackoverflow.com/questions/54446492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9668890/" ]
As @Marc already mentioned, the difference is in the order of the base constructor. I have added the base constructor ``` class Base { public Base() { Console.WriteLine("Inside Base constructor"); } } ``` and modified my class "MyBuilder" to derived from it as; ``` cl...
I almost always choose the second one option (initializing inside the constructor). In my point of view it keeps your code more readable and the control logic is inside the constructor which gives more flexibility to add logic in the future. But again, it is only my personal opinion.
60,538,059
I am trying to download MNIST data in PyTorch using the following code: ``` train_loader = torch.utils.data.DataLoader( datasets.MNIST('data', train=True, download=True, transform=transforms.Compose([ transforms.ToTensor()...
2020/03/05
[ "https://Stackoverflow.com/questions/60538059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4848812/" ]
This is a new bug, reported here: <https://github.com/pytorch/vision/issues/1938> See that thread for some potential workarounds until the issue is fixed in pytorch itself.
My workaround is: run on your local machine a simple program to download the MNIST dataset from the `torchvision.datasets` module, save with `pickle` a copy on your machine and upload it in your Google Drive. Is not proper fix but a viable and affordable workaround, hope it helps somehow
23,080,960
Here I'm trying to create a pie chart using **matplotlib** python library. But the dates are overlapping if the values are same "0.0" multiple times. My question is how I can display them separately. Thanks. ![enter image description here](https://i.stack.imgur.com/mBL5o.png) This is what I tried: ``` from pylab...
2014/04/15
[ "https://Stackoverflow.com/questions/23080960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3270800/" ]
You can adjust the label positions manually, although that results in a bit more code you would want to for such a simple request. You can detect groups of duplicate labels by examining the positions at which there are placed. Here is an example with some random data replicating the occurrence of overlapping labels: ...
I am not sure it there is a way to adjust "labeldistance" for every element, but I could solve this using a tricky-way. I added explode(0, 0.1, 0, 0) ``` from pylab import * labels = [ "05-02-2014", "23-02-2014","07-02-2014","08-02-2014"] values = [0, 0, 2, 10] explode = (0, 0.1, 0, 0) fig = plt.figure(figsize=(9.0,...
58,841,308
I need a domain validator and email validator, ie validate if both exist. The company I'm servicing has a website that validates this for them, ensuring they won't send email to a nonexistent mailbox. It would be an email marketing action anyway. They have something basic about excel, but they want a service to be runn...
2019/11/13
[ "https://Stackoverflow.com/questions/58841308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403338/" ]
There is a [documented](https://learn.microsoft.com/graph/api/channel-get-filesfolder?view=graph-rest-1.0&tabs=http) navigational property of the Channel resource called `filesFolder`. From the Graph v1.0 endpoint: ```xml <EntityType Name="channel" BaseType="microsoft.graph.entity"> <Property Name="displayName" Type...
Currently /filesFolder for Private Channels returns BadGateway
58,841,308
I need a domain validator and email validator, ie validate if both exist. The company I'm servicing has a website that validates this for them, ensuring they won't send email to a nonexistent mailbox. It would be an email marketing action anyway. They have something basic about excel, but they want a service to be runn...
2019/11/13
[ "https://Stackoverflow.com/questions/58841308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403338/" ]
There is a [documented](https://learn.microsoft.com/graph/api/channel-get-filesfolder?view=graph-rest-1.0&tabs=http) navigational property of the Channel resource called `filesFolder`. From the Graph v1.0 endpoint: ```xml <EntityType Name="channel" BaseType="microsoft.graph.entity"> <Property Name="displayName" Type...
The issue you are having is that the drive and site for the private channel is never generated until you actually visit the channel in the teams app. That one visit will trigger the creation of the drive and site. Im stuck here myself as i cannot trigger a private channel to created the SharePoint site and drive until ...
58,841,308
I need a domain validator and email validator, ie validate if both exist. The company I'm servicing has a website that validates this for them, ensuring they won't send email to a nonexistent mailbox. It would be an email marketing action anyway. They have something basic about excel, but they want a service to be runn...
2019/11/13
[ "https://Stackoverflow.com/questions/58841308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403338/" ]
The issue you are having is that the drive and site for the private channel is never generated until you actually visit the channel in the teams app. That one visit will trigger the creation of the drive and site. Im stuck here myself as i cannot trigger a private channel to created the SharePoint site and drive until ...
Currently /filesFolder for Private Channels returns BadGateway
27,554,484
I'm trying to use theano but I get an error when I import it. I've installed cuda\_6.5.14\_linux\_64.run, and passed all the recommended test in Chapter 6 of [this](http://developer.download.nvidia.com/compute/cuda/6_5/rel/docs/CUDA_Getting_Started_Linux.pdf) NVIDIA PDF. Ultimately I want to be able to install pylearn2...
2014/12/18
[ "https://Stackoverflow.com/questions/27554484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2423116/" ]
I encountered exactly the same question. My solution is to replace cuda-6.5 with cuda-5.5, and everything works fine.
We also saw this error. We found that putting /usr/local/cuda-6.5/bin in $PATH seemed to fix it (even with the root = ... line in .theanorc).
61,264,563
When I import numpy and pandas in jupyter it gives error same in spider but in spider works after starting new kernel. ``` import numpy as np ``` --- ``` NameError Traceback (most recent call last) <ipython-input-1-0aa0b027fcb6> in <module> ----> 1 import numpy as np ~\numpy.py in <...
2020/04/17
[ "https://Stackoverflow.com/questions/61264563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13287554/" ]
this is showing "NameError" which is due to the arr=array([1,2,3,4]) you should try something like this arr=np.array([1,2,3,4])
Try this: ``` arr=np.array([1,2,3,4]) ```
61,264,563
When I import numpy and pandas in jupyter it gives error same in spider but in spider works after starting new kernel. ``` import numpy as np ``` --- ``` NameError Traceback (most recent call last) <ipython-input-1-0aa0b027fcb6> in <module> ----> 1 import numpy as np ~\numpy.py in <...
2020/04/17
[ "https://Stackoverflow.com/questions/61264563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13287554/" ]
I found the error. It was a very bad mistake my c files have program numpy.py so while importing numpy python was accessing that file not the numpy module. So i deleted that and everything worked fine.
Try this: ``` arr=np.array([1,2,3,4]) ```
61,264,563
When I import numpy and pandas in jupyter it gives error same in spider but in spider works after starting new kernel. ``` import numpy as np ``` --- ``` NameError Traceback (most recent call last) <ipython-input-1-0aa0b027fcb6> in <module> ----> 1 import numpy as np ~\numpy.py in <...
2020/04/17
[ "https://Stackoverflow.com/questions/61264563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13287554/" ]
this is showing "NameError" which is due to the arr=array([1,2,3,4]) you should try something like this arr=np.array([1,2,3,4])
As you are using numpy as np, to create an array the following syntax is needed: arr=np.array([1,2,3])
61,264,563
When I import numpy and pandas in jupyter it gives error same in spider but in spider works after starting new kernel. ``` import numpy as np ``` --- ``` NameError Traceback (most recent call last) <ipython-input-1-0aa0b027fcb6> in <module> ----> 1 import numpy as np ~\numpy.py in <...
2020/04/17
[ "https://Stackoverflow.com/questions/61264563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13287554/" ]
I found the error. It was a very bad mistake my c files have program numpy.py so while importing numpy python was accessing that file not the numpy module. So i deleted that and everything worked fine.
As you are using numpy as np, to create an array the following syntax is needed: arr=np.array([1,2,3])
61,264,563
When I import numpy and pandas in jupyter it gives error same in spider but in spider works after starting new kernel. ``` import numpy as np ``` --- ``` NameError Traceback (most recent call last) <ipython-input-1-0aa0b027fcb6> in <module> ----> 1 import numpy as np ~\numpy.py in <...
2020/04/17
[ "https://Stackoverflow.com/questions/61264563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13287554/" ]
I found the error. It was a very bad mistake my c files have program numpy.py so while importing numpy python was accessing that file not the numpy module. So i deleted that and everything worked fine.
this is showing "NameError" which is due to the arr=array([1,2,3,4]) you should try something like this arr=np.array([1,2,3,4])
73,230,522
Hi I am new to python and I have a simple question, I have a list consisting of some user info and I want to know how can I write a program to find and update some of that info. ``` user_list = [ {'name': 'Alizom_12', 'gender': 'f', 'age': 34, 'active_day': 170}, {'name': 'Xzt4f', 'gender':...
2022/08/04
[ "https://Stackoverflow.com/questions/73230522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19686631/" ]
Even if you accepted the remote version you still created a merge commit which basically contains the information that the changes you made are integrated in the branch. The merge commit will have two parents: the commit you pulled and your local one. This new commit needs pushing. You'll see the commit when you insp...
If you haven't set `rebase=true` in `.gitconfig`, please set it up like this: ``` [pull] rebase = true ``` When you have conflicts you should resolve it and force push it: ``` git push -f ```
73,230,522
Hi I am new to python and I have a simple question, I have a list consisting of some user info and I want to know how can I write a program to find and update some of that info. ``` user_list = [ {'name': 'Alizom_12', 'gender': 'f', 'age': 34, 'active_day': 170}, {'name': 'Xzt4f', 'gender':...
2022/08/04
[ "https://Stackoverflow.com/questions/73230522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19686631/" ]
This is indeed one reason people use rebase. Remember that each Git commit: * is numbered: it has a raw hash ID like `4af7188bc97f70277d0f10d56d5373022b1fa385`, unique to that one particular commit; * is completely read-only: no part of `4af7blahblah` can ever change; * is mostly permanent: once you *have* `4af7blahb...
Even if you accepted the remote version you still created a merge commit which basically contains the information that the changes you made are integrated in the branch. The merge commit will have two parents: the commit you pulled and your local one. This new commit needs pushing. You'll see the commit when you insp...
73,230,522
Hi I am new to python and I have a simple question, I have a list consisting of some user info and I want to know how can I write a program to find and update some of that info. ``` user_list = [ {'name': 'Alizom_12', 'gender': 'f', 'age': 34, 'active_day': 170}, {'name': 'Xzt4f', 'gender':...
2022/08/04
[ "https://Stackoverflow.com/questions/73230522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19686631/" ]
This is indeed one reason people use rebase. Remember that each Git commit: * is numbered: it has a raw hash ID like `4af7188bc97f70277d0f10d56d5373022b1fa385`, unique to that one particular commit; * is completely read-only: no part of `4af7blahblah` can ever change; * is mostly permanent: once you *have* `4af7blahb...
If you haven't set `rebase=true` in `.gitconfig`, please set it up like this: ``` [pull] rebase = true ``` When you have conflicts you should resolve it and force push it: ``` git push -f ```
16,536,101
I read this on Python tutorial: (<http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files>) > > Python on Windows makes a distinction between text and binary files; > the end-of-line characters in text files are automatically altered slightly > when data is read or written. This behind-the-sc...
2013/05/14
[ "https://Stackoverflow.com/questions/16536101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769958/" ]
You just have to take care to open files on windows as binary (`open(filename, "rb")`) and not as text files. After that there is no problem using the data. Particularly the end-of-line on Windows is `'\r\n'`. And if you read a binary file as text file and write it back out, then single `'\n'` are transformed in `'\r\...
> > I feel binary data don't have such things like end-of-line. > > > Binary files can have ANY POSSIBLE character in them, including the character \n. You do not want python implicitly converting any characters in a binary file to something else. Python has no idea it is reading a binary file unless you tell it s...
16,536,101
I read this on Python tutorial: (<http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files>) > > Python on Windows makes a distinction between text and binary files; > the end-of-line characters in text files are automatically altered slightly > when data is read or written. This behind-the-sc...
2013/05/14
[ "https://Stackoverflow.com/questions/16536101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769958/" ]
> > I feel binary data don't have such things like end-of-line. > > > Binary files can have ANY POSSIBLE character in them, including the character \n. You do not want python implicitly converting any characters in a binary file to something else. Python has no idea it is reading a binary file unless you tell it s...
I suppose the "slightly alter" in Python manual means the conversion Unix end-of-line characters to Windows end-of-line characters. Because this is done only in Windows, so Unix and Linux don't have this trouble.
16,536,101
I read this on Python tutorial: (<http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files>) > > Python on Windows makes a distinction between text and binary files; > the end-of-line characters in text files are automatically altered slightly > when data is read or written. This behind-the-sc...
2013/05/14
[ "https://Stackoverflow.com/questions/16536101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769958/" ]
You just have to take care to open files on windows as binary (`open(filename, "rb")`) and not as text files. After that there is no problem using the data. Particularly the end-of-line on Windows is `'\r\n'`. And if you read a binary file as text file and write it back out, then single `'\n'` are transformed in `'\r\...
I suppose the "slightly alter" in Python manual means the conversion Unix end-of-line characters to Windows end-of-line characters. Because this is done only in Windows, so Unix and Linux don't have this trouble.
60,882,099
I have a redhat server with docker installed I want to create a docker image in which I want to run django with MySQL but the problem is django is unable to connect to MySQL server(remote server). I'm getting following error: ``` Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/pl...
2020/03/27
[ "https://Stackoverflow.com/questions/60882099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10386411/" ]
The primary reason is simplicity. The existing rule is easy to understand (you clearly understand it) and easy to implement. The data-flow analysis required (to distinguish between acceptable and unacceptable uses in general) is complex and not normally necessary for a compiler, so it was thought a bad idea to require ...
In Ada, when you try to think about accessibility, you have to do it in terms of access types instead of variables. There's no lifetime analysis of variables (contrarily to what Rust does, I think). So, what's the worst that could happen? If your pointer type level is less than the target variable level, accessibility ...
11,450,649
I'm having a really tough time with getting the results page of this url with python's urllib2: ``` http://www.google.com/search?tbs=sbi:AMhZZitAaz7goe6AsfVSmFw1sbwsmX0uIjeVnzKHjEXMck70H3j32Q-6FApxrhxdSyMo0OedyWkxk3-qYbyf0q1OqNspjLu8DlyNnWVbNjiKGo87QUjQHf2_1idZ1q_1vvm5gzOCMpChYiKsKYdMywOLjJzqmzYoJNOU2UsTs_1zZGWjU-...
2012/07/12
[ "https://Stackoverflow.com/questions/11450649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1488252/" ]
Your user-agent is not defined ! Take that one : ``` #!/usr/bin/python import urllib2 url = "http://www.google.com/search?q=mysearch"; opener = urllib2.build_opener() opener.addheaders = [('User-agent', 'Mozilla/5.0')] print opener.open(url).read() raw_input() ``` If you like find an other user-agent, you can wri...
Google has several anti-scraping techniques in place, since they don't want users to get to the results without the APIs or real browsers. If you are serious about scraping this kind of pages, I suggest you look into: [Selenium](http://seleniumhq.org/) or [Spynner](http://code.google.com/p/spynner/). Another advanta...
66,488,745
**PROBLEM ENCOUNTERED:** > > E/AndroidRuntime: FATAL EXCEPTION: main > Process: org.tensorflow.lite.examples.detection, PID: 14719 > java.lang.AssertionError: Error occurred when initializing ObjectDetector: Mobile SSD models are expected to have exactly 4 outputs, found 8 > > > **Problem Description** * Android...
2021/03/05
[ "https://Stackoverflow.com/questions/66488745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15334979/" ]
After further study, I believe the aforementioned issue was raised since the model has 8 tensors output but the Android application written in Java can only support 4 tensors output (at least the example provided by Google only supports 4 tensors output) I am not very certain about the number of tensors output on diff...
For those who will stumble on this problem/question later: limitations on the number of output tensors are part of Tensorflow Lite Object Detection API specification described [here](https://www.tensorflow.org/lite/inference_with_metadata/task_library/object_detector#model_compatibility_requirements) I don't know how t...
27,239,348
I am using photologue to create a photo gallery site with django. I installed django-tagging into my virtualenv, not knowing it was no longer supported by photologue. Now, after having performed migrations, whenever I try to add a photo or view the photo, I get FieldError at /admin/photologue/photo/upload\_zip/ Cannot ...
2014/12/01
[ "https://Stackoverflow.com/questions/27239348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4043633/" ]
The problem seems to arise from the fact, that django-tagging was somehow still present on the virtualenv. In your traceback after photologue saves a model, django-tagging reacts to the sent signal and tries to update any related tags: ``` File "/home/cameron/Envs/photologue/local/lib/python2.7/site-packages/django/d...
Well the error is simple -- in that you are requesting a field in the database that does not exist. Since you haven't posted code it is hard to be more specific than that. Was one of your templates built, referencing a field named 'items' that is no longer there? Please edit your question to include a FULL traceback ...
63,354,202
i am beginer of the python programming. i am creating simple employee salary calculation using python. **tax = salary \* 10 / 100** this line said wrong error displayed Unindent does not match outer indentation level this is the full code ``` salary = 60000 if(salary > 50000): tax = float(salary * 10 / 100) e...
2020/08/11
[ "https://Stackoverflow.com/questions/63354202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12932093/" ]
The error message is self explanatory. You can't indent your elif and else, they should be at the same level as the if condition. ``` salary = 60000 if(salary > 50000): tax = salary * 10 / 100 elif(salary > 35000): tax = salary * 5 / 100 else : tax = 0 netsal = salary - tax print(tax) print(netsa...
You just need to fix your indentation, I would suggest using an IDE ```py salary = 60000 if(salary > 50000): tax = salary * 10 / 100 elif(salary > 35000): tax = salary * 5 / 100 else: tax = 0 print(tax) >>> 6000.0 ```
59,467,023
``` C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR:...
2019/12/24
[ "https://Stackoverflow.com/questions/59467023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12590302/" ]
Currently, there are wheels compatible with the official distributions of **Python 2.7, 3.4, 3.5, and 3.6.** Apparently, there is no version of that library for Python 3.7, so I'd try downgrading the Python version. Download the wheel on this site: <https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio>. Choose: * Py...
You need to install Microsoft Visual C++ 14.0 This should work <https://visualstudio.microsoft.com/visual-cpp-build-tools/>
59,467,023
``` C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR:...
2019/12/24
[ "https://Stackoverflow.com/questions/59467023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12590302/" ]
You need to install Microsoft Visual C++ 14.0 This should work <https://visualstudio.microsoft.com/visual-cpp-build-tools/>
``` pip install pipwin ``` pipwin install pyaudio This worked straight away for me without installing any visual studio stuff, python --version is 3.9.5. I've just done a fresh install of windows 10 a few days ago on my machine
59,467,023
``` C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR:...
2019/12/24
[ "https://Stackoverflow.com/questions/59467023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12590302/" ]
Currently, there are wheels compatible with the official distributions of **Python 2.7, 3.4, 3.5, and 3.6.** Apparently, there is no version of that library for Python 3.7, so I'd try downgrading the Python version. Download the wheel on this site: <https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio>. Choose: * Py...
``` pip install pipwin pipwin install pyaudio ``` `pipwin` will automatically do the download of required wheel, as it installs unofficial Python package binaries for windows.
59,467,023
``` C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR:...
2019/12/24
[ "https://Stackoverflow.com/questions/59467023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12590302/" ]
Currently, there are wheels compatible with the official distributions of **Python 2.7, 3.4, 3.5, and 3.6.** Apparently, there is no version of that library for Python 3.7, so I'd try downgrading the Python version. Download the wheel on this site: <https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio>. Choose: * Py...
Whenever there is a build type error or say C++ 14.0 build tool required,just follow these simple steps- 1. Goto and scroll down for Pyaudio - [enter link description here](https://www.lfd.uci.edu/%7Egohlke/pythonlibs/#pyaudio) 2. Here you have to download wheel file according your python version and according to your...
59,467,023
``` C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR:...
2019/12/24
[ "https://Stackoverflow.com/questions/59467023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12590302/" ]
Currently, there are wheels compatible with the official distributions of **Python 2.7, 3.4, 3.5, and 3.6.** Apparently, there is no version of that library for Python 3.7, so I'd try downgrading the Python version. Download the wheel on this site: <https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio>. Choose: * Py...
``` pip install pipwin ``` pipwin install pyaudio This worked straight away for me without installing any visual studio stuff, python --version is 3.9.5. I've just done a fresh install of windows 10 a few days ago on my machine
59,467,023
``` C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR:...
2019/12/24
[ "https://Stackoverflow.com/questions/59467023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12590302/" ]
``` pip install pipwin pipwin install pyaudio ``` `pipwin` will automatically do the download of required wheel, as it installs unofficial Python package binaries for windows.
``` pip install pipwin ``` pipwin install pyaudio This worked straight away for me without installing any visual studio stuff, python --version is 3.9.5. I've just done a fresh install of windows 10 a few days ago on my machine
59,467,023
``` C:\Users\gabri\OneDrive\Desktop>pip3 install pyaudio Collecting pyaudio Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz Installing collected packages: pyaudio Running setup.py install for pyaudio ... error ERROR:...
2019/12/24
[ "https://Stackoverflow.com/questions/59467023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12590302/" ]
Whenever there is a build type error or say C++ 14.0 build tool required,just follow these simple steps- 1. Goto and scroll down for Pyaudio - [enter link description here](https://www.lfd.uci.edu/%7Egohlke/pythonlibs/#pyaudio) 2. Here you have to download wheel file according your python version and according to your...
``` pip install pipwin ``` pipwin install pyaudio This worked straight away for me without installing any visual studio stuff, python --version is 3.9.5. I've just done a fresh install of windows 10 a few days ago on my machine
18,041,050
I've got a py2.7 project which I want to test under py3.2. For this purpose, I want to use virtualenv. I wanted to create an environment that would run 3.2 version internally: ``` virtualenv 3.2 -p /usr/bin/python3.2 ``` but it failed. My default python version is `2.7` (ubuntu default settings). Here is `virtualenv...
2013/08/04
[ "https://Stackoverflow.com/questions/18041050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769384/" ]
To create a Python 3.2 virtual environment you should use the virtualenv you installed for Python 3.2. In your case that would be: ``` /usr/bin/virtualenv-3.2 ```
You'll have to use a Python 3 version of `virtualenv`; the version you are using is installing Python 2 tools into a Python 3 virtual environment and these are not compatible.
18,041,050
I've got a py2.7 project which I want to test under py3.2. For this purpose, I want to use virtualenv. I wanted to create an environment that would run 3.2 version internally: ``` virtualenv 3.2 -p /usr/bin/python3.2 ``` but it failed. My default python version is `2.7` (ubuntu default settings). Here is `virtualenv...
2013/08/04
[ "https://Stackoverflow.com/questions/18041050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769384/" ]
You'll have to use a Python 3 version of `virtualenv`; the version you are using is installing Python 2 tools into a Python 3 virtual environment and these are not compatible.
``` virtualenv --python=/usr/bin/python3.2 --no-site-packages ENV ```
18,041,050
I've got a py2.7 project which I want to test under py3.2. For this purpose, I want to use virtualenv. I wanted to create an environment that would run 3.2 version internally: ``` virtualenv 3.2 -p /usr/bin/python3.2 ``` but it failed. My default python version is `2.7` (ubuntu default settings). Here is `virtualenv...
2013/08/04
[ "https://Stackoverflow.com/questions/18041050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769384/" ]
To create a Python 3.2 virtual environment you should use the virtualenv you installed for Python 3.2. In your case that would be: ``` /usr/bin/virtualenv-3.2 ```
``` virtualenv --python=/usr/bin/python3.2 --no-site-packages ENV ```
68,762,785
I have the following dataframes. ``` Name | Data A foo A bar B foo B bar C foo C bar C cat Name | foo | bar | cat A 1 2 3 B 4 5 6 C 7 8 9 ``` I need to lookup the values present in the 2n...
2021/08/12
[ "https://Stackoverflow.com/questions/68762785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16652846/" ]
You can use `.melt` + `.merge`: ```py x = df1.merge(df2.melt("Name", var_name="Data"), on=["Name", "Data"]) print(x) ``` Prints: ```none Name Data value 0 A foo 1 1 A bar 2 2 B foo 4 3 B bar 5 4 C foo 7 5 C bar 8 6 C cat 9 ```
You can melt your second dataframe and then merge it with your first: ``` import pandas as pd df1 = pd.DataFrame({ 'Name': ['A', 'A', 'B', 'B', 'C', 'C', 'C'], 'Data': ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'cat'], }) df2 = pd.DataFrame({ 'Name': ['A', 'B', 'C'], 'foo': [1, 4, 7], 'bar': [2...
56,878,362
I'm trying to create a role wrapper which will allow me to restrict certain pages and content for different users. I already have methods implemented for checking this, but the wrapper/decorator for implementing this fails and sometimes doesn't, and I have no idea of what the cause could be. I've searched around looki...
2019/07/03
[ "https://Stackoverflow.com/questions/56878362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6912830/" ]
So to solve the problem that has been plaguing me for the last couple of hours, I've looked into how the `flask_login` module actually works, and after a bit of investigating, I found out that they use an import from `functools` called `wraps`. I imported that, copied how `flask_login` implemented it essentially, and ...
At first glance it looks like a conflict with your `run` function in the `require_role` decorator ([docs](http://flask.pocoo.org/docs/1.0/patterns/viewdecorators/)): ``` def require_role(roles=["User"]): def wrap(func): def wrapped_func(*args, **kwargs): ... ```
38,882,845
Anaconda for python 3.5 and python 2.7 seems to install just as a drop in folder inside my home folder on Ubuntu. Is there an installed version of Anaconda for Ubuntu 16? I'm not sure how to ask this but do I need python 3.5 that comes by default if I am also using Anaconda 3.5? It seems like the best solution is doc...
2016/08/10
[ "https://Stackoverflow.com/questions/38882845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/784304/" ]
My solution for Python 3.5 and Anaconda on Ubuntu 16.04 LTS (with the bonus of OpenCV 3) was to install Anaconda, then deprecate to 3.5. You have to be sure to update anaconda afterwards - that's the bit that got me at first. The commands I gave were: ``` bash Anaconda3-4.3.1-Linux-x86_64.sh conda install python=3.5 c...
Use anaconda version `Anaconda3-4.2.0-Linux-x86_64.sh` from the anaconda installer archive.This comes with `python 3.5`. This worked for me.
35,528,078
I have a Python code like this, ``` pyg = 'ay' original = raw_input('Enter a word:') if len(original) > 0 and original.isalpha(): word = original.lower() first = word[0] new_word = word+first+pyg new_word[1:] print original else: print 'empty' ``` The output of variable "new\_word" should b...
2016/02/20
[ "https://Stackoverflow.com/questions/35528078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1802617/" ]
You will need your own implementation of `ToString` in your `Employee` class. You just need to override it and put your code of `PrintEmployee` in the new method. Just to make it clear what I mean I give you a sample on how the override should look like: ``` public override string ToString() { return string.Forma...
Here's a simple solution ``` private void PrintRegistry() { foreach(Employee employee in Accounts) { Console.WriteLine("\nID:{0}\nFull Name: {1} {2}\nSocial Security Number: {3}\nWage: {4}\n", employee.ID, employee.FirstName, employee.LastName, employee.SocialNumber, employee.HourWage); } } ``` O...
16,946,684
Minimal working example that shows this error: ``` from os import listdir, getcwd from os.path import isfile, join, realpath, dirname import csv def gd(mypath, myfile): # Obtain the number of columns in the data file with open(myfile) as f: reader = csv.reader(f, delimiter=' ', skipinitialspace=True) ...
2013/06/05
[ "https://Stackoverflow.com/questions/16946684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1391441/" ]
The `u` just indicates that it is a unicode string and is not relevant to the problem. The file isn't found because you aren't adding the `mypath` in front of the filename - try `with open(join(mypath, myfile)) as f:`
Your problem is that `myfile` is just a filename, not the result of `join(mypath,myfile)`.
57,523,861
I'm attempting to install pymc on MacOS 10.14.5 Mojave. However, there seems to be a problem with the gfortran module. The error message is minimally helpful. I have attempted all the possible ways to install pymc as suggested here: <https://pymc-devs.github.io/pymc/INSTALL.html> I first came across a problem with no...
2019/08/16
[ "https://Stackoverflow.com/questions/57523861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11935431/" ]
I'm not familiar with mongoose, so I will take for granted that `"user_count": user_count++` works. For the rest, there are two things that won't work: * the `$` operator in `"users.$.id": req.user.id,` is known as the positional operator, and that's not what you want, it's used to update a specific element in an ar...
``` db.collection.findOneAndUpdate({_id: id}, {$set: {"user_count": user_count++},$addToSet: {"users": {"id": req.user.id,"action": true}}}, {returnOriginal:false}, (err, doc) => { if (err) { console.log("Something wrong when updating data!"); } console.log(doc); }); ```
25,113,767
I am programming in python which involves me implementing a shell in Python in Linux. I am trying to run standard unix commands by using os.execvp(). I need to keep asking the user for commands so I have used an infinite while loop. However, the infinite while loop doesn't work. I have tried searching online but they'r...
2014/08/04
[ "https://Stackoverflow.com/questions/25113767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3903472/" ]
Your code does not work because it uses [`os.execvp`](https://docs.python.org/3/library/os.html#os.execvp). `os.execvp` **replaces the current process image completely with the executing program**, your running process **becomes** the `ls`. To execute a **subprocess** use the aptly named [`subprocess`](https://docs.py...
If you want it to run like a shell you are looking for os.fork() . Call this before you call os.execvp() and it will create a child process. os.fork() returns the process id. If it is 0 then you are in the child process and can call os.execvp(), otherwise continue with the code. This will keep the while loop running. Y...