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
50,653,208
What I want to achieve is simple, in R I can do things like `paste0("https\\",1:10,"whatever",11:20)`, how to do such in Python? I found some things [here](https://stackoverflow.com/questions/28046408/equivalent-of-rs-paste-command-for-vector-of-numbers-in-python), but only allow for : `paste0("https\\",1:10)`. Any...
2018/06/02
[ "https://Stackoverflow.com/questions/50653208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6113825/" ]
**@Jason**, I will suggest you to use any of these following 2 ways to do this task. ✓ By creating a list of texts using **list comprehension** and **zip()** function. > > **Note:** To print `\` on screen, use escape sequence `\\`. See [List of escape sequences and their use](https://msdn.microsoft.com/en-us/library...
**Based on the link you provided,** this should work: ``` ["https://" + str(i) + "whatever" + str(i) for i in xrange(1,11)] ``` Gives the following output: ``` ['https://1whatever1', 'https://2whatever2', 'https://3whatever3', 'https://4whatever4', 'https://5whatever5', 'https://6whatever6', 'https://7whatever7',...
29,219,814
Im kinda new to python, im trying to the basic task of splitting string data from a file using a double backslash (\\) delimiter. Its failing, so far: ``` from tkinter import filedialog import string import os #remove previous finalhostlist try: os.remove("finalhostlist.txt") except E...
2015/03/23
[ "https://Stackoverflow.com/questions/29219814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3014488/" ]
write expects a string and you have passed it a list, if you want the contents written use `str.join`. ``` rawhostlist.write("\n".join(line.split("\\"))) ``` You also don't need to call close when you use `with`, it closes your file automatically and you actually never call close anyway as you are missing parens `ra...
if you want them written on separate lines: ``` for sub in line.split("\\"):rawhostlist.write(sub) ```
29,219,814
Im kinda new to python, im trying to the basic task of splitting string data from a file using a double backslash (\\) delimiter. Its failing, so far: ``` from tkinter import filedialog import string import os #remove previous finalhostlist try: os.remove("finalhostlist.txt") except E...
2015/03/23
[ "https://Stackoverflow.com/questions/29219814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3014488/" ]
write expects a string and you have passed it a list, if you want the contents written use `str.join`. ``` rawhostlist.write("\n".join(line.split("\\"))) ``` You also don't need to call close when you use `with`, it closes your file automatically and you actually never call close anyway as you are missing parens `ra...
I would do `rawhostlist.write(line.replace(r'\\', '\n'))`. If you want a little more efficiency feel free to use `re.sub()` instead, but I don't think it will make much of a difference here. There's no need to call `.write()` for each line. And there is definitely no need to convert the string into a list -- just to co...
29,219,814
Im kinda new to python, im trying to the basic task of splitting string data from a file using a double backslash (\\) delimiter. Its failing, so far: ``` from tkinter import filedialog import string import os #remove previous finalhostlist try: os.remove("finalhostlist.txt") except E...
2015/03/23
[ "https://Stackoverflow.com/questions/29219814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3014488/" ]
I would do `rawhostlist.write(line.replace(r'\\', '\n'))`. If you want a little more efficiency feel free to use `re.sub()` instead, but I don't think it will make much of a difference here. There's no need to call `.write()` for each line. And there is definitely no need to convert the string into a list -- just to co...
if you want them written on separate lines: ``` for sub in line.split("\\"):rawhostlist.write(sub) ```
20,369,642
I'm trying to get the keyboard code of a character pressed in python. For this, I need to see if a keypad number is pressed. *This is not what I'm looking for*: ``` import tty, sys tty.setcbreak(sys.stdin) def main(): tty.setcbreak(sys.stdin) while True: c = ord(sys.stdin.read(1)) if c == or...
2013/12/04
[ "https://Stackoverflow.com/questions/20369642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1224926/" ]
As synthesizerpatel said, I need to go to a lower level. Using pyusb: ``` import usb.core, usb.util, usb.control dev = usb.core.find(idVendor=0x045e, idProduct=0x0780) try: if dev is None: raise ValueError('device not found') cfg = dev.get_active_configuration() interface_number = cfg[(0,0)].b...
To get raw keyboard input from Python you need to snoop at a lower level than reading stdin. For OSX check this answer: [OS X - Python Keylogger - letters in double](https://stackoverflow.com/questions/13806829/os-x-python-keylogger-letters-in-double) For Windows, this might work: <http://www.daniweb.com/software-d...
20,369,642
I'm trying to get the keyboard code of a character pressed in python. For this, I need to see if a keypad number is pressed. *This is not what I'm looking for*: ``` import tty, sys tty.setcbreak(sys.stdin) def main(): tty.setcbreak(sys.stdin) while True: c = ord(sys.stdin.read(1)) if c == or...
2013/12/04
[ "https://Stackoverflow.com/questions/20369642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1224926/" ]
To get raw keyboard input from Python you need to snoop at a lower level than reading stdin. For OSX check this answer: [OS X - Python Keylogger - letters in double](https://stackoverflow.com/questions/13806829/os-x-python-keylogger-letters-in-double) For Windows, this might work: <http://www.daniweb.com/software-d...
if you have opencv check this simple code: ``` import cv2, numpy as np img = np.ones((100,100))*100 while True: cv2.imshow('tracking',img) keyboard = cv2.waitKey(1) & 0xFF if keyboard !=255: print keyboard if keyboard==27: break cv2.destroyAllWindows() ``` now when the blank window ...
20,369,642
I'm trying to get the keyboard code of a character pressed in python. For this, I need to see if a keypad number is pressed. *This is not what I'm looking for*: ``` import tty, sys tty.setcbreak(sys.stdin) def main(): tty.setcbreak(sys.stdin) while True: c = ord(sys.stdin.read(1)) if c == or...
2013/12/04
[ "https://Stackoverflow.com/questions/20369642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1224926/" ]
As synthesizerpatel said, I need to go to a lower level. Using pyusb: ``` import usb.core, usb.util, usb.control dev = usb.core.find(idVendor=0x045e, idProduct=0x0780) try: if dev is None: raise ValueError('device not found') cfg = dev.get_active_configuration() interface_number = cfg[(0,0)].b...
if you have opencv check this simple code: ``` import cv2, numpy as np img = np.ones((100,100))*100 while True: cv2.imshow('tracking',img) keyboard = cv2.waitKey(1) & 0xFF if keyboard !=255: print keyboard if keyboard==27: break cv2.destroyAllWindows() ``` now when the blank window ...
54,229,785
How to check whether a folder exists in google drive with name using python? I have tried with the following code: ``` import requests import json access_token = 'token' url = 'https://www.googleapis.com/drive/v3/files' headers = { 'Authorization': 'Bearer' + access_token } response = requests.get(url, headers=h...
2019/01/17
[ "https://Stackoverflow.com/questions/54229785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10506357/" ]
* You want to know whether a folder is existing in Google Drive using the folder name. * You want to achieve it using the access token and `requests.get()`. If my understanding is correct, how about this modification? Please think of this as just one of several answers. ### Modification points: * You can search the ...
You may see this [sample code](https://gist.github.com/jmlrt/f524e1a45205a0b9f169eb713a223330) on how to check if destination folder exists and return its ID. ``` def get_folder_id(drive, parent_folder_id, folder_name): """ Check if destination folder exists and return it's ID """ # Auto-iterate ...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
Write a simple for loop with zip will help you learn a lot. for example: ``` for a, b, c in zip([1,2,3], [4,5,6], [7,8,9]): print a print b print c print "/" ``` This function will print: 1 4 7 / 2 5 8 / 3 6 7 So that the zip function just put those three lis...
Python treats the variables merely as *labels* or name tags. Since you have zipped those inside a `list` of lists, it doesn't matter where they are, as long as you address them by their name / label correctly. Kindly note, this may not work for immutable types like `int` or `str`, etc. Refer to this answer for more exp...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
What does `zip` do? Quoting from the official documentation: > > Zip returns a list of tuples, where the i-th tuple contains the i-th > element from each of the argument sequences or iterables. The returned > list is truncated in length to the length of the shortest argument > sequence. > > > It means, ``` ...
Python treats the variables merely as *labels* or name tags. Since you have zipped those inside a `list` of lists, it doesn't matter where they are, as long as you address them by their name / label correctly. Kindly note, this may not work for immutable types like `int` or `str`, etc. Refer to this answer for more exp...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
Any sequence (or iterable) can be unpacked into variables using a simple assignment operation. The only requirement is that the number of variables and structure match the sequence. For example: ``` t = (2, 4) x, y = t ``` In this case zip() as per standard documentation is " zip() Make an iterator that aggregates e...
Python treats the variables merely as *labels* or name tags. Since you have zipped those inside a `list` of lists, it doesn't matter where they are, as long as you address them by their name / label correctly. Kindly note, this may not work for immutable types like `int` or `str`, etc. Refer to this answer for more exp...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
Any sequence (or iterable) can be unpacked into variables using a simple assignment operation. The only requirement is that the number of variables and structure match the sequence. For example: ``` t = (2, 4) x, y = t ``` In this case zip() as per standard documentation is " zip() Make an iterator that aggregates e...
Write a simple for loop with zip will help you learn a lot. for example: ``` for a, b, c in zip([1,2,3], [4,5,6], [7,8,9]): print a print b print c print "/" ``` This function will print: 1 4 7 / 2 5 8 / 3 6 7 So that the zip function just put those three lis...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
Write a simple for loop with zip will help you learn a lot. for example: ``` for a, b, c in zip([1,2,3], [4,5,6], [7,8,9]): print a print b print c print "/" ``` This function will print: 1 4 7 / 2 5 8 / 3 6 7 So that the zip function just put those three lis...
Thank you all for excellent answers! My python skill is poor, so I am sorry for that! ``` import numpy as np print('----------------------------------------') print('Before modification:') a = np.random.randn(1, 3) * 1.0 print('a: ', a) b = np.random.randn(1, 3) * 1.0 print('b: ', b) c = np.random.randn(1, 3) * 1.0 ...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
Any sequence (or iterable) can be unpacked into variables using a simple assignment operation. The only requirement is that the number of variables and structure match the sequence. For example: ``` t = (2, 4) x, y = t ``` In this case zip() as per standard documentation is " zip() Make an iterator that aggregates e...
What does `zip` do? Quoting from the official documentation: > > Zip returns a list of tuples, where the i-th tuple contains the i-th > element from each of the argument sequences or iterables. The returned > list is truncated in length to the length of the shortest argument > sequence. > > > It means, ``` ...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
What does `zip` do? Quoting from the official documentation: > > Zip returns a list of tuples, where the i-th tuple contains the i-th > element from each of the argument sequences or iterables. The returned > list is truncated in length to the length of the shortest argument > sequence. > > > It means, ``` ...
Thank you all for excellent answers! My python skill is poor, so I am sorry for that! ``` import numpy as np print('----------------------------------------') print('Before modification:') a = np.random.randn(1, 3) * 1.0 print('a: ', a) b = np.random.randn(1, 3) * 1.0 print('b: ', b) c = np.random.randn(1, 3) * 1.0 ...
43,223,017
I am attempting to understand the excellent Code given as a guide by Andrej Karpathy: <https://gist.github.com/karpathy/d4dee566867f8291f086> I am new to python, still learning! I am doing the best I can to understand the following code from the link: ``` # perform parameter update with Adagrad for param, dparam, me...
2017/04/05
[ "https://Stackoverflow.com/questions/43223017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1183804/" ]
Any sequence (or iterable) can be unpacked into variables using a simple assignment operation. The only requirement is that the number of variables and structure match the sequence. For example: ``` t = (2, 4) x, y = t ``` In this case zip() as per standard documentation is " zip() Make an iterator that aggregates e...
Thank you all for excellent answers! My python skill is poor, so I am sorry for that! ``` import numpy as np print('----------------------------------------') print('Before modification:') a = np.random.randn(1, 3) * 1.0 print('a: ', a) b = np.random.randn(1, 3) * 1.0 print('b: ', b) c = np.random.randn(1, 3) * 1.0 ...
73,425,359
I am running Ubuntu 22.04 with xorg. I need to find a way to compile microbit python code locally to a firmware hex file. Firstly, I followed the guide here <https://microbit-micropython.readthedocs.io/en/latest/devguide/flashfirmware.html>. After a lot of debugging, I got to this point: <https://pastebin.com/MGShD31N...
2022/08/20
[ "https://Stackoverflow.com/questions/73425359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12625930/" ]
Mu and the uflash command are able to retrieve your Python code from .hex files. Using uflash you can do the following for example: ``` uflash my_script.py ``` I think that you want is somehow possible to do, but its harder than just using their web python editor: <https://python.microbit.org/v/2>
**Working Ubuntu 22.04 host CLI setup with Carlos Atencio's Docker to build your own firmware** After trying to setup the toolchain for a while, I finally decided to Google for a Docker image with the toolchain, and found <https://github.com/carlosperate/docker-microbit-toolchain> [at this commit](https://github.com/c...
73,425,359
I am running Ubuntu 22.04 with xorg. I need to find a way to compile microbit python code locally to a firmware hex file. Firstly, I followed the guide here <https://microbit-micropython.readthedocs.io/en/latest/devguide/flashfirmware.html>. After a lot of debugging, I got to this point: <https://pastebin.com/MGShD31N...
2022/08/20
[ "https://Stackoverflow.com/questions/73425359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12625930/" ]
Okay, so elaborating on Peter Till's answer. Firstly, you can use uflash: ``` uflash path/to/your/code . ``` Or, you can use microfs: ``` ufs put path/to/main.py ```
**Working Ubuntu 22.04 host CLI setup with Carlos Atencio's Docker to build your own firmware** After trying to setup the toolchain for a while, I finally decided to Google for a Docker image with the toolchain, and found <https://github.com/carlosperate/docker-microbit-toolchain> [at this commit](https://github.com/c...
73,425,359
I am running Ubuntu 22.04 with xorg. I need to find a way to compile microbit python code locally to a firmware hex file. Firstly, I followed the guide here <https://microbit-micropython.readthedocs.io/en/latest/devguide/flashfirmware.html>. After a lot of debugging, I got to this point: <https://pastebin.com/MGShD31N...
2022/08/20
[ "https://Stackoverflow.com/questions/73425359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12625930/" ]
Peter Till answers the original question. The additional below adds to this answer by showing how to automate the build and load process. I use Debian. The original question states that Ubuntu is used, which is built on Debian. A script to find and mount the micro:bit ======================================== When cod...
**Working Ubuntu 22.04 host CLI setup with Carlos Atencio's Docker to build your own firmware** After trying to setup the toolchain for a while, I finally decided to Google for a Docker image with the toolchain, and found <https://github.com/carlosperate/docker-microbit-toolchain> [at this commit](https://github.com/c...
9,725,737
> > **Possible Duplicate:** > > [Tool to convert python indentation from spaces to tabs?](https://stackoverflow.com/questions/338767/tool-to-convert-python-indentation-from-spaces-to-tabs) > > > I have a number of python files (>1000) that need to be reformatted so indentation is done only with tabs (yes, i kn...
2012/03/15
[ "https://Stackoverflow.com/questions/9725737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/69882/" ]
I would suggest using this [Reindent](http://pypi.python.org/pypi/Reindent/0.1.0) script on PyPI to convert all of your horribly inconsistent files to a consistent PEP-8 (4-space indents) version. At this point try one more time to convince whoever decided on tabs that the company coding standard is stupid and PEP-8 s...
How about ``` find . -type f -iname \*.py -print0 | xargs -0 sed -i 's/^ /\t/' ``` This command finds all .py files below the current directory and replaces every four consecutive spaces it finds inside of them with a tab. Just noticed Spacedman's comment. This approach will not handle spaces at the beginning of...
37,817,559
I've packaged a [this simple flask app](https://github.com/SimplyAhmazing/pyinstaller-tut) using PyInstaller but my OSX executable fails to run and shows the following executable, ``` Error loading Python lib '/Users/ahmed/Code/play/py-install-tut/dist/myscript.app/Contents/MacOS/Python': dlopen(/Users/ahmed/Code/play...
2016/06/14
[ "https://Stackoverflow.com/questions/37817559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/772401/" ]
The minimum deployment target with Xcode 8 is iOS 8. To support target the iOS SDK 7.x and below, use Xcode 7. If you try to use a deployment target of iOS 7.x or below, Xcode will suggest you change your target to iOS 8: [![Xcode Warning](https://i.stack.imgur.com/LGe5e.png)](https://i.stack.imgur.com/LGe5e.png)
Apple has changed so much since iOS 7 until now. The easiest way of not having to deal with backward compatibility is to make the old OS's obsolete. ~~So you have 2 choices. You can leave the setting as is and deal with the warning message,~~ or you can change the setting and not support iOS 7 or lower any longer. Ther...
37,817,559
I've packaged a [this simple flask app](https://github.com/SimplyAhmazing/pyinstaller-tut) using PyInstaller but my OSX executable fails to run and shows the following executable, ``` Error loading Python lib '/Users/ahmed/Code/play/py-install-tut/dist/myscript.app/Contents/MacOS/Python': dlopen(/Users/ahmed/Code/play...
2016/06/14
[ "https://Stackoverflow.com/questions/37817559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/772401/" ]
I think if the app has many users who are using iOS 7, it would be necessary to adjust project to support iOS 7. I have tried build, debug, archive with deployment target 7.0 using Xcode 8 Beta(8S128d). All succeeded. Also successfully export and install the ipa on my iPhone 4 (iOS 7.1.2(11D257)) . I did the fol...
The minimum deployment target with Xcode 8 is iOS 8. To support target the iOS SDK 7.x and below, use Xcode 7. If you try to use a deployment target of iOS 7.x or below, Xcode will suggest you change your target to iOS 8: [![Xcode Warning](https://i.stack.imgur.com/LGe5e.png)](https://i.stack.imgur.com/LGe5e.png)
37,817,559
I've packaged a [this simple flask app](https://github.com/SimplyAhmazing/pyinstaller-tut) using PyInstaller but my OSX executable fails to run and shows the following executable, ``` Error loading Python lib '/Users/ahmed/Code/play/py-install-tut/dist/myscript.app/Contents/MacOS/Python': dlopen(/Users/ahmed/Code/play...
2016/06/14
[ "https://Stackoverflow.com/questions/37817559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/772401/" ]
The minimum deployment target with Xcode 8 is iOS 8. To support target the iOS SDK 7.x and below, use Xcode 7. If you try to use a deployment target of iOS 7.x or below, Xcode will suggest you change your target to iOS 8: [![Xcode Warning](https://i.stack.imgur.com/LGe5e.png)](https://i.stack.imgur.com/LGe5e.png)
If you don't want to fiddle with XCode just update your project file for iOS 6 or 7. Right click .xcodeproj choose "Show package contents" and edit project.pbxproj in favorite text editor. Search for IPHONEOS\_DEPLOYMENT\_TARGET = 7.0;
37,817,559
I've packaged a [this simple flask app](https://github.com/SimplyAhmazing/pyinstaller-tut) using PyInstaller but my OSX executable fails to run and shows the following executable, ``` Error loading Python lib '/Users/ahmed/Code/play/py-install-tut/dist/myscript.app/Contents/MacOS/Python': dlopen(/Users/ahmed/Code/play...
2016/06/14
[ "https://Stackoverflow.com/questions/37817559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/772401/" ]
I think if the app has many users who are using iOS 7, it would be necessary to adjust project to support iOS 7. I have tried build, debug, archive with deployment target 7.0 using Xcode 8 Beta(8S128d). All succeeded. Also successfully export and install the ipa on my iPhone 4 (iOS 7.1.2(11D257)) . I did the fol...
Apple has changed so much since iOS 7 until now. The easiest way of not having to deal with backward compatibility is to make the old OS's obsolete. ~~So you have 2 choices. You can leave the setting as is and deal with the warning message,~~ or you can change the setting and not support iOS 7 or lower any longer. Ther...
37,817,559
I've packaged a [this simple flask app](https://github.com/SimplyAhmazing/pyinstaller-tut) using PyInstaller but my OSX executable fails to run and shows the following executable, ``` Error loading Python lib '/Users/ahmed/Code/play/py-install-tut/dist/myscript.app/Contents/MacOS/Python': dlopen(/Users/ahmed/Code/play...
2016/06/14
[ "https://Stackoverflow.com/questions/37817559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/772401/" ]
Apple has changed so much since iOS 7 until now. The easiest way of not having to deal with backward compatibility is to make the old OS's obsolete. ~~So you have 2 choices. You can leave the setting as is and deal with the warning message,~~ or you can change the setting and not support iOS 7 or lower any longer. Ther...
If you don't want to fiddle with XCode just update your project file for iOS 6 or 7. Right click .xcodeproj choose "Show package contents" and edit project.pbxproj in favorite text editor. Search for IPHONEOS\_DEPLOYMENT\_TARGET = 7.0;
37,817,559
I've packaged a [this simple flask app](https://github.com/SimplyAhmazing/pyinstaller-tut) using PyInstaller but my OSX executable fails to run and shows the following executable, ``` Error loading Python lib '/Users/ahmed/Code/play/py-install-tut/dist/myscript.app/Contents/MacOS/Python': dlopen(/Users/ahmed/Code/play...
2016/06/14
[ "https://Stackoverflow.com/questions/37817559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/772401/" ]
I think if the app has many users who are using iOS 7, it would be necessary to adjust project to support iOS 7. I have tried build, debug, archive with deployment target 7.0 using Xcode 8 Beta(8S128d). All succeeded. Also successfully export and install the ipa on my iPhone 4 (iOS 7.1.2(11D257)) . I did the fol...
If you don't want to fiddle with XCode just update your project file for iOS 6 or 7. Right click .xcodeproj choose "Show package contents" and edit project.pbxproj in favorite text editor. Search for IPHONEOS\_DEPLOYMENT\_TARGET = 7.0;
67,117,219
i am new to coding and python and i was wondering how to create a regex that will match all ip addresses that start with 192.168.1.xxx I have been looking online and have not yet been able to find a match. Here is some some sample data that i am trying to match them from. ``` /index.html HTTP/1.1" 404 208 "-" "Mozill...
2021/04/15
[ "https://Stackoverflow.com/questions/67117219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12920080/" ]
Here you go. Also, checkout <https://regexr.com/> `^192\.168\.1\.[0-9]{1,3}$`
I think here its best to use a combination of `regex` to grab any valid IP address from your data, row by row. Then use `ipaddress` to check if the address sits within the network you're looking for. This will provide much more flexibility in the case you need to check different networks, instead of rewriting the `reg...
67,117,219
i am new to coding and python and i was wondering how to create a regex that will match all ip addresses that start with 192.168.1.xxx I have been looking online and have not yet been able to find a match. Here is some some sample data that i am trying to match them from. ``` /index.html HTTP/1.1" 404 208 "-" "Mozill...
2021/04/15
[ "https://Stackoverflow.com/questions/67117219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12920080/" ]
If you really only want to match '192.168.1.xxx', then you can use this regex to use this in python specifically: "192\.168\.1\.[0-9]{1,3}". I personally recommend using [regexr](https://regexr.com/) to get more familiar with regex. You can enter your data and on the left you can look at a cheatsheet to help you learn...
I think here its best to use a combination of `regex` to grab any valid IP address from your data, row by row. Then use `ipaddress` to check if the address sits within the network you're looking for. This will provide much more flexibility in the case you need to check different networks, instead of rewriting the `reg...
16,024,041
I'm having issues sending unicode to SQL Server via pymssql: ``` In [1]: import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() In [2]: s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' In [3]: s...
2013/04/15
[ "https://Stackoverflow.com/questions/16024041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599229/" ]
Ended up using pypyodbc instead. Needed some assistance to [connect](https://stackoverflow.com/questions/16024956/connecting-to-sql-server-with-pypyodbc), then used the [doc recipe](https://code.google.com/p/pypyodbc/wiki/A_HelloWorld_sample_to_access_mssql_with_python) for executing statements: ``` import pypyodbc co...
Here is something which worked for me: ``` # -*- coding: utf-8 -*- import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' cursor.execute("INSERT INTO MyTable(col1) VALUES(%s)", s.en...
16,024,041
I'm having issues sending unicode to SQL Server via pymssql: ``` In [1]: import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() In [2]: s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' In [3]: s...
2013/04/15
[ "https://Stackoverflow.com/questions/16024041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599229/" ]
Ran into the same issue with pymssql and did not want to switch to pypyodbc For me, there was no issue in removing any accents seeing that I only needed first names as a reference. So this solution may not be for everyone. ``` import unicodedate firstName = u'René' firstName = unicodedata.normalize('NFKD', firstName)...
Here is something which worked for me: ``` # -*- coding: utf-8 -*- import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' cursor.execute("INSERT INTO MyTable(col1) VALUES(%s)", s.en...
16,024,041
I'm having issues sending unicode to SQL Server via pymssql: ``` In [1]: import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() In [2]: s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' In [3]: s...
2013/04/15
[ "https://Stackoverflow.com/questions/16024041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599229/" ]
The following code samples have been tested and verified to work with both Python 2.7.5 and Python 3.4.3 using pymssql 2.1.1. For a Python source file saved with UTF-8 encoding: ```python # -*- coding: utf-8 -*- import pymssql cnxn = pymssql.connect( server='localhost', port='52865', user='sa', passw...
Here is something which worked for me: ``` # -*- coding: utf-8 -*- import pymssql conn = pymssql.connect(host='hostname', user='me', password='password', database='db') cursor = conn.cursor() s = u'Monsieur le Curé of the «Notre-Dame-de-Grâce» neighborhood' cursor.execute("INSERT INTO MyTable(col1) VALUES(%s)", s.en...
40,700,192
The Virt-Manager is capable of modifying network interfaces of running domains, for example changing the connected network. I want to script this in python with the libvirt-API. ``` import libvirt conn = libvirt.open('qemu:///system') deb = conn.lookupByName('Testdebian') xml = deb.XMLDesc() xml = replace('old-netwo...
2016/11/20
[ "https://Stackoverflow.com/questions/40700192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6204346/" ]
This is very easy in [c++17](/questions/tagged/c%2b%2b17 "show questions tagged 'c++17'"). ``` template<class Tuple> decltype(auto) sum_components(Tuple const& tuple) { auto sum_them = [](auto const&... e)->decltype(auto) { return (e+...); }; return std::apply( sum_them, tuple ); }; ``` or `(...+e)` for th...
With C++1z it's pretty simple with [fold expressions](http://en.cppreference.com/w/cpp/language/fold). First, forward the tuple to an `_impl` function and provide it with index sequence to access all tuple elements, then sum: ``` template<typename T, size_t... Is> auto sum_components_impl(T const& t, std::index_sequen...
43,628,733
I wrote this code to display contents of a list in grid form . It works fine for the alphabet list . But when i try to run it with a randomly generated list it gives an list index out of range error . Here is the full code: import random ``` #barebones 2d shell grid generator ''' Following list is a place holder...
2017/04/26
[ "https://Stackoverflow.com/questions/43628733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5698361/" ]
I suggest you use the function '.load' rather than '.csv', something like this: ``` data = sc.read.load(path_to_file, format='com.databricks.spark.csv', header='true', inferSchema='true').cache() ``` Of you course you can add more options. Then you can si...
It would be good if you can provide some sample data next time. How should we know how your csv looks like. Concerning your question, it looks like that your csv column is not a decimal all the time. InferSchema takes the first row and assign a datatype, in your case, it is a [DecimalType](http://spark.apache.org/docs/...
43,628,733
I wrote this code to display contents of a list in grid form . It works fine for the alphabet list . But when i try to run it with a randomly generated list it gives an list index out of range error . Here is the full code: import random ``` #barebones 2d shell grid generator ''' Following list is a place holder...
2017/04/26
[ "https://Stackoverflow.com/questions/43628733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5698361/" ]
Please try the below code and this infers the schema along with header ``` from pyspark.sql import SparkSession spark=SparkSession.builder.appName('operation').getOrCreate() df=spark.read.csv("C:/LEARNING//Spark_DataFrames/stock.csv ",inferSchema=True, header=True) df.show() ```
It would be good if you can provide some sample data next time. How should we know how your csv looks like. Concerning your question, it looks like that your csv column is not a decimal all the time. InferSchema takes the first row and assign a datatype, in your case, it is a [DecimalType](http://spark.apache.org/docs/...
43,628,733
I wrote this code to display contents of a list in grid form . It works fine for the alphabet list . But when i try to run it with a randomly generated list it gives an list index out of range error . Here is the full code: import random ``` #barebones 2d shell grid generator ''' Following list is a place holder...
2017/04/26
[ "https://Stackoverflow.com/questions/43628733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5698361/" ]
I suggest you use the function '.load' rather than '.csv', something like this: ``` data = sc.read.load(path_to_file, format='com.databricks.spark.csv', header='true', inferSchema='true').cache() ``` Of you course you can add more options. Then you can si...
Please try the below code and this infers the schema along with header ``` from pyspark.sql import SparkSession spark=SparkSession.builder.appName('operation').getOrCreate() df=spark.read.csv("C:/LEARNING//Spark_DataFrames/stock.csv ",inferSchema=True, header=True) df.show() ```
48,761,673
I want to solve a case where i know what all will be contents of the string output.. but i am not sure about the order of the contents inside the output.. say, the expected contents of my output are `['this','output','can','be','jumbled','in','any','order']`.. and the output can be `'this can in any order jumbled out...
2018/02/13
[ "https://Stackoverflow.com/questions/48761673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7534349/" ]
Use [`contains(where:)`](https://developer.apple.com/documentation/swift/sequence/2905153-contains) on the dictionary values: ``` // Enable button if at least one value is not nil: button.isEnabled = dict.values.contains(where: { $0 != nil }) ``` Or ``` // Enable button if no value is nil: button.isEnabled = !dict....
You can use [`filter`](https://developer.apple.com/documentation/swift/sequence/2905694-filter) to check if any value is nil in a dictionary. ``` button.isEnabled = dict.filter { $1 == nil }.isEmpty ```
48,761,673
I want to solve a case where i know what all will be contents of the string output.. but i am not sure about the order of the contents inside the output.. say, the expected contents of my output are `['this','output','can','be','jumbled','in','any','order']`.. and the output can be `'this can in any order jumbled out...
2018/02/13
[ "https://Stackoverflow.com/questions/48761673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7534349/" ]
You can use [`filter`](https://developer.apple.com/documentation/swift/sequence/2905694-filter) to check if any value is nil in a dictionary. ``` button.isEnabled = dict.filter { $1 == nil }.isEmpty ```
I recommend to conform to the standard dictionary definition that a `nil` value indicates *no key* and declare the dictionary non-optional (`[String:Double]`). In this case the button will be enabled if all 12 keys are present. This is more efficient than `filter` or `contains` ``` button.isEnabled = dict.count == 1...
48,761,673
I want to solve a case where i know what all will be contents of the string output.. but i am not sure about the order of the contents inside the output.. say, the expected contents of my output are `['this','output','can','be','jumbled','in','any','order']`.. and the output can be `'this can in any order jumbled out...
2018/02/13
[ "https://Stackoverflow.com/questions/48761673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7534349/" ]
Use [`contains(where:)`](https://developer.apple.com/documentation/swift/sequence/2905153-contains) on the dictionary values: ``` // Enable button if at least one value is not nil: button.isEnabled = dict.values.contains(where: { $0 != nil }) ``` Or ``` // Enable button if no value is nil: button.isEnabled = !dict....
You've already been provided with similar solutions, but here you go: ``` dict.filter({$0.value == nil}).count != 0 ```
48,761,673
I want to solve a case where i know what all will be contents of the string output.. but i am not sure about the order of the contents inside the output.. say, the expected contents of my output are `['this','output','can','be','jumbled','in','any','order']`.. and the output can be `'this can in any order jumbled out...
2018/02/13
[ "https://Stackoverflow.com/questions/48761673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7534349/" ]
Use [`contains(where:)`](https://developer.apple.com/documentation/swift/sequence/2905153-contains) on the dictionary values: ``` // Enable button if at least one value is not nil: button.isEnabled = dict.values.contains(where: { $0 != nil }) ``` Or ``` // Enable button if no value is nil: button.isEnabled = !dict....
I recommend to conform to the standard dictionary definition that a `nil` value indicates *no key* and declare the dictionary non-optional (`[String:Double]`). In this case the button will be enabled if all 12 keys are present. This is more efficient than `filter` or `contains` ``` button.isEnabled = dict.count == 1...
48,761,673
I want to solve a case where i know what all will be contents of the string output.. but i am not sure about the order of the contents inside the output.. say, the expected contents of my output are `['this','output','can','be','jumbled','in','any','order']`.. and the output can be `'this can in any order jumbled out...
2018/02/13
[ "https://Stackoverflow.com/questions/48761673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7534349/" ]
You've already been provided with similar solutions, but here you go: ``` dict.filter({$0.value == nil}).count != 0 ```
I recommend to conform to the standard dictionary definition that a `nil` value indicates *no key* and declare the dictionary non-optional (`[String:Double]`). In this case the button will be enabled if all 12 keys are present. This is more efficient than `filter` or `contains` ``` button.isEnabled = dict.count == 1...
53,140,438
How to create cumulative sum (new\_supply)in dataframe python from demand column from table ``` item Date supply demand A 2018-01-01 0 10 A 2018-01-02 0 15 A 2018-01-03 100 30 A 2018-01-04 0 10 A 2018-01-05 0 40 A 2018-01-06 50 50 A 2018-01-07...
2018/11/04
[ "https://Stackoverflow.com/questions/53140438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10603056/" ]
Make the python file executable chmod +x Test.py
Why do you have to include the logic inside a class? note = 10 if note >= 10: print("yes") else: print("NO") Just this will do, remove the class
53,140,438
How to create cumulative sum (new\_supply)in dataframe python from demand column from table ``` item Date supply demand A 2018-01-01 0 10 A 2018-01-02 0 15 A 2018-01-03 100 30 A 2018-01-04 0 10 A 2018-01-05 0 40 A 2018-01-06 50 50 A 2018-01-07...
2018/11/04
[ "https://Stackoverflow.com/questions/53140438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10603056/" ]
Make the python file executable chmod +x Test.py
Why you use "env" from system directory? If you change first line of script code will working. May be some strange settings in you OS or you try strange using python env. ``` #!/usr/bin/python2.7 class Test: note = 10 if note >= 10: print("yes") else: print("NO") ```
3,885,846
I'd like to call a .py file from within python. It is in the same directory. Effectivly, I would like the same behavior as calling python foo.py from the command line without using any of the command line tools. How should I do this?
2010/10/07
[ "https://Stackoverflow.com/questions/3885846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450054/" ]
It's not quite clear (at least to me) what you mean by using "none of the command-line tools". To run a program in a subprocess, one usually uses the `subprocess` module. However, if both the calling and the callee are python scripts, there is another alternative, which is to use the `multiprocessing` module. For e...
``` execfile('foo.py') ``` See also: * [Further reading on execfile](http://docs.python.org/library/functions.html#execfile)
3,885,846
I'd like to call a .py file from within python. It is in the same directory. Effectivly, I would like the same behavior as calling python foo.py from the command line without using any of the command line tools. How should I do this?
2010/10/07
[ "https://Stackoverflow.com/questions/3885846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450054/" ]
It's not quite clear (at least to me) what you mean by using "none of the command-line tools". To run a program in a subprocess, one usually uses the `subprocess` module. However, if both the calling and the callee are python scripts, there is another alternative, which is to use the `multiprocessing` module. For e...
`import module` or `__import__("module")`, to load module.py. * [Modules - Python v2.7 documentation](http://docs.python.org/tutorial/modules.html) * [Importing Python modules](http://effbot.org/zone/import-confusion.htm)
61,270,154
I used to have my app on Heroku and the way it worked there was that I had 2 buildpacks. One for NodeJS and one for Python. Heroku ran `npm run build` and then Django served the files from the `build` folder. I use Code Pipeline on AWS to deploy a new version of my app every time there is a new push on my GitHub repos...
2020/04/17
[ "https://Stackoverflow.com/questions/61270154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11804213/" ]
So I figured out one solution that worked for me. Since I want to create the build version of my app on the server the way Heroku does it with the NodeJS buildpack, I had to create a command that installs node like this: ``` container_commands: 01_install_node: command: "curl -sL https://rpm.nodesource.com/setu...
I don't know exactly Python but I guess you can adapt for you case. Elastic Beanstalk for Node.js platform use by default `app.js`, then `server.js`, and then `npm start` (in that order) to start your application. You can change this behavior with **configuration files**. Below the steps to accomplish with Node.js: ...
29,648,412
I have a Python 3 installation of Anaconda and want to be able to switch quickly between python2 and 3 kernels. This is on OSX. My steps so far involved: ``` conda create -p ~/anaconda/envs/python2 python=2.7 source activate python2 conda install ipython ipython kernelspec install-self source deactivate ``` After t...
2015/04/15
[ "https://Stackoverflow.com/questions/29648412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1217949/" ]
Apparently IPython expects explicit pathnames, so no '~' instead of the home directory. It worked after changing the kernel.json to: ``` { "display_name": "Python 2", "language": "python", "argv": [ "/Users/sonium/anaconda/envs/python2/bin/python2.7", "-m", "IPython.kernel", "-f", "{connection_file}" ], ...
I install the Anaconda 3 in Win10. I am now focus on python 3, but I have lot projects written in python 2. If I want check them in juypter in python environment it's will failed, and shows "kernel error". The solution is almost like above, but something different. The path to find those two json files is : `C:\Progra...
16,033,348
I have a list of items that relate to each other, I know they end up building a graph but the data is not sorted in any way. ``` PMO-100 -> SA-300 SA-100 -> SA-300 SA-100 -> SA-200 PMO-100 -> SA-100 ``` In python examples for graphViz api I realize that you can pretty much generate a graph if you know it's top node ...
2013/04/16
[ "https://Stackoverflow.com/questions/16033348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/220255/" ]
There is no need to identify a top node for graphviz. Just add all Nodes and edges and let it do the rest. For example: ``` import pydot graph = pydot.Dot('graphname', graph_type='digraph') pmo100 = pydot.Node("PMO-100") sa300 = pydot.Node("SA-300") sa100 = pydot.Node("SA-100") sa200 = pydot.Node("SA-200") graph.add_...
Try out [pygraph](http://github.com/iamaziz/pygraph) package, it produces a directed graph based on relation statements (data). No matter if the data are sorted or not. So (as in your case) if we have the following data (in a triple relation), it is easy to produce the corresponding graph: ### First way ``` s1 = "PM...
16,033,348
I have a list of items that relate to each other, I know they end up building a graph but the data is not sorted in any way. ``` PMO-100 -> SA-300 SA-100 -> SA-300 SA-100 -> SA-200 PMO-100 -> SA-100 ``` In python examples for graphViz api I realize that you can pretty much generate a graph if you know it's top node ...
2013/04/16
[ "https://Stackoverflow.com/questions/16033348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/220255/" ]
How to change color of nodes: node.attr["color"] = 'red' to change the shape of arrowhead, same method edge.attr["arrowhead"] = "..."
Try out [pygraph](http://github.com/iamaziz/pygraph) package, it produces a directed graph based on relation statements (data). No matter if the data are sorted or not. So (as in your case) if we have the following data (in a triple relation), it is easy to produce the corresponding graph: ### First way ``` s1 = "PM...
50,860,578
I have the following situation: ``` for x1 in range(x1, x2): for x2 in range(x3, x4): for x3 ... ... f(x1, x2, x3, ...) ``` How to convert this to a mechanism in which I only tell python to make *n* nested loops where the variable name is x1, x2, x3, x4, ...? I don't want to w...
2018/06/14
[ "https://Stackoverflow.com/questions/50860578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8472333/" ]
What you want to do is iterate over a product. Use [`itertools.product`](https://docs.python.org/3/library/itertools.html#itertools.product). ``` import itertools ranges = [range(x1, x2), range(x3, x4), ...] for xs in itertools.product(*ranges): f(*xs) ``` Example ------- ``` import itertools ranges = [range...
Recommended: itertools ---------------------- [`itertools`](https://docs.python.org/3/library/itertools.html) is an awesome package for everything related to iteration: ``` from itertools import product x1 = 3; x2 = 4 x3 = 0; x4 = 2 x5 = 42; x6 = 42 for x, y, z in product(range(x1, x2), range(x3, x4), range(x4, x5))...
50,860,578
I have the following situation: ``` for x1 in range(x1, x2): for x2 in range(x3, x4): for x3 ... ... f(x1, x2, x3, ...) ``` How to convert this to a mechanism in which I only tell python to make *n* nested loops where the variable name is x1, x2, x3, x4, ...? I don't want to w...
2018/06/14
[ "https://Stackoverflow.com/questions/50860578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8472333/" ]
What you want to do is iterate over a product. Use [`itertools.product`](https://docs.python.org/3/library/itertools.html#itertools.product). ``` import itertools ranges = [range(x1, x2), range(x3, x4), ...] for xs in itertools.product(*ranges): f(*xs) ``` Example ------- ``` import itertools ranges = [range...
Use multiprocessing! ``` import multiprocessing from itertools import product results = [] def callback(return_value): # this stores results results.append(return_value) if __name__=="__main__" : pool = multiprocessing.Pool(4) args = product(range1, range2, range) for x, y, z in args: po...
50,860,578
I have the following situation: ``` for x1 in range(x1, x2): for x2 in range(x3, x4): for x3 ... ... f(x1, x2, x3, ...) ``` How to convert this to a mechanism in which I only tell python to make *n* nested loops where the variable name is x1, x2, x3, x4, ...? I don't want to w...
2018/06/14
[ "https://Stackoverflow.com/questions/50860578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8472333/" ]
What you want to do is iterate over a product. Use [`itertools.product`](https://docs.python.org/3/library/itertools.html#itertools.product). ``` import itertools ranges = [range(x1, x2), range(x3, x4), ...] for xs in itertools.product(*ranges): f(*xs) ``` Example ------- ``` import itertools ranges = [range...
You could also use [`numpy.ndindex`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndindex.html) to achieve what you are looking for: ``` import numpy for y1, y2, y3 in numpy.ndindex(x2, x4, ...): ... ``` Thats especially useful when you are already using numpy for something else in your script. You...
50,860,578
I have the following situation: ``` for x1 in range(x1, x2): for x2 in range(x3, x4): for x3 ... ... f(x1, x2, x3, ...) ``` How to convert this to a mechanism in which I only tell python to make *n* nested loops where the variable name is x1, x2, x3, x4, ...? I don't want to w...
2018/06/14
[ "https://Stackoverflow.com/questions/50860578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8472333/" ]
Recommended: itertools ---------------------- [`itertools`](https://docs.python.org/3/library/itertools.html) is an awesome package for everything related to iteration: ``` from itertools import product x1 = 3; x2 = 4 x3 = 0; x4 = 2 x5 = 42; x6 = 42 for x, y, z in product(range(x1, x2), range(x3, x4), range(x4, x5))...
Use multiprocessing! ``` import multiprocessing from itertools import product results = [] def callback(return_value): # this stores results results.append(return_value) if __name__=="__main__" : pool = multiprocessing.Pool(4) args = product(range1, range2, range) for x, y, z in args: po...
50,860,578
I have the following situation: ``` for x1 in range(x1, x2): for x2 in range(x3, x4): for x3 ... ... f(x1, x2, x3, ...) ``` How to convert this to a mechanism in which I only tell python to make *n* nested loops where the variable name is x1, x2, x3, x4, ...? I don't want to w...
2018/06/14
[ "https://Stackoverflow.com/questions/50860578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8472333/" ]
Recommended: itertools ---------------------- [`itertools`](https://docs.python.org/3/library/itertools.html) is an awesome package for everything related to iteration: ``` from itertools import product x1 = 3; x2 = 4 x3 = 0; x4 = 2 x5 = 42; x6 = 42 for x, y, z in product(range(x1, x2), range(x3, x4), range(x4, x5))...
You could also use [`numpy.ndindex`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndindex.html) to achieve what you are looking for: ``` import numpy for y1, y2, y3 in numpy.ndindex(x2, x4, ...): ... ``` Thats especially useful when you are already using numpy for something else in your script. You...
50,860,578
I have the following situation: ``` for x1 in range(x1, x2): for x2 in range(x3, x4): for x3 ... ... f(x1, x2, x3, ...) ``` How to convert this to a mechanism in which I only tell python to make *n* nested loops where the variable name is x1, x2, x3, x4, ...? I don't want to w...
2018/06/14
[ "https://Stackoverflow.com/questions/50860578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8472333/" ]
You could also use [`numpy.ndindex`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndindex.html) to achieve what you are looking for: ``` import numpy for y1, y2, y3 in numpy.ndindex(x2, x4, ...): ... ``` Thats especially useful when you are already using numpy for something else in your script. You...
Use multiprocessing! ``` import multiprocessing from itertools import product results = [] def callback(return_value): # this stores results results.append(return_value) if __name__=="__main__" : pool = multiprocessing.Pool(4) args = product(range1, range2, range) for x, y, z in args: po...
55,138,466
I'm scraping a [website](https://www.cofidis.es/es/creditos-prestamos/financiacion-coche.html). I'm trying to click on a link under `<li>` but it throws `NoSuchElementException` exception. And the links I want to click: [![enter image description here](https://i.stack.imgur.com/2BVsw.png)](https://i.stack.imgur.com/2...
2019/03/13
[ "https://Stackoverflow.com/questions/55138466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11155464/" ]
onchange of the radio button select the input using document.querySelector and using setAttribute set the required attribute to the elements ```js function a() { document.querySelector('.one').setAttribute('required','required'); document.querySelector('.five').setAttribute('required','required'); } ``` ```html ...
You can add class to the input elements by matching the id of the radio button. Then on clicking on the button add the *required* attribute with that class name: ```js var radio = [].slice.call(document.querySelectorAll('[name=customer]')); radio.forEach(function(r){ r.addEventListener('click', function(){ va...
55,138,466
I'm scraping a [website](https://www.cofidis.es/es/creditos-prestamos/financiacion-coche.html). I'm trying to click on a link under `<li>` but it throws `NoSuchElementException` exception. And the links I want to click: [![enter image description here](https://i.stack.imgur.com/2BVsw.png)](https://i.stack.imgur.com/2...
2019/03/13
[ "https://Stackoverflow.com/questions/55138466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11155464/" ]
onchange of the radio button select the input using document.querySelector and using setAttribute set the required attribute to the elements ```js function a() { document.querySelector('.one').setAttribute('required','required'); document.querySelector('.five').setAttribute('required','required'); } ``` ```html ...
```html <form id="my-form"> <input type="radio" name="customer" id="customer" value="A customer">Customer<br> <input type="radio" name="customer" id="client" value="A client">Client<br> <input type="radio" name="customer" id="other" value="Other">Other<br> <input type="text" placeholder="reference no" name="re...
55,138,466
I'm scraping a [website](https://www.cofidis.es/es/creditos-prestamos/financiacion-coche.html). I'm trying to click on a link under `<li>` but it throws `NoSuchElementException` exception. And the links I want to click: [![enter image description here](https://i.stack.imgur.com/2BVsw.png)](https://i.stack.imgur.com/2...
2019/03/13
[ "https://Stackoverflow.com/questions/55138466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11155464/" ]
onchange of the radio button select the input using document.querySelector and using setAttribute set the required attribute to the elements ```js function a() { document.querySelector('.one').setAttribute('required','required'); document.querySelector('.five').setAttribute('required','required'); } ``` ```html ...
``` <!DOCTYPE html> <html> <head> <title>Page Title</title> <style> body { background-color: black; text-align: center; color: white; font-family: Arial, Helvetica, sans-serif; } </style> </head> <body id="container_id"> <form> <input type="radio" name="customer" id="customer" value="A customer">Customer<br...
55,138,466
I'm scraping a [website](https://www.cofidis.es/es/creditos-prestamos/financiacion-coche.html). I'm trying to click on a link under `<li>` but it throws `NoSuchElementException` exception. And the links I want to click: [![enter image description here](https://i.stack.imgur.com/2BVsw.png)](https://i.stack.imgur.com/2...
2019/03/13
[ "https://Stackoverflow.com/questions/55138466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11155464/" ]
You can add class to the input elements by matching the id of the radio button. Then on clicking on the button add the *required* attribute with that class name: ```js var radio = [].slice.call(document.querySelectorAll('[name=customer]')); radio.forEach(function(r){ r.addEventListener('click', function(){ va...
```html <form id="my-form"> <input type="radio" name="customer" id="customer" value="A customer">Customer<br> <input type="radio" name="customer" id="client" value="A client">Client<br> <input type="radio" name="customer" id="other" value="Other">Other<br> <input type="text" placeholder="reference no" name="re...
55,138,466
I'm scraping a [website](https://www.cofidis.es/es/creditos-prestamos/financiacion-coche.html). I'm trying to click on a link under `<li>` but it throws `NoSuchElementException` exception. And the links I want to click: [![enter image description here](https://i.stack.imgur.com/2BVsw.png)](https://i.stack.imgur.com/2...
2019/03/13
[ "https://Stackoverflow.com/questions/55138466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11155464/" ]
You can add class to the input elements by matching the id of the radio button. Then on clicking on the button add the *required* attribute with that class name: ```js var radio = [].slice.call(document.querySelectorAll('[name=customer]')); radio.forEach(function(r){ r.addEventListener('click', function(){ va...
``` <!DOCTYPE html> <html> <head> <title>Page Title</title> <style> body { background-color: black; text-align: center; color: white; font-family: Arial, Helvetica, sans-serif; } </style> </head> <body id="container_id"> <form> <input type="radio" name="customer" id="customer" value="A customer">Customer<br...
69,086,563
i am trying to read CT scan Dicom file using pydicom python library but i just can't get rid of this below error even when i install gdcm and pylibjpeg ``` RuntimeError: The following handlers are available to decode the pixel data however they are missing required dependencies: GDCM (req. ), pylibjpeg (req. ) ``` H...
2021/09/07
[ "https://Stackoverflow.com/questions/69086563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15054164/" ]
Try running the following: ``` !pip install pylibjpeg !pip install gdcm ```
In a [similar problem](https://stackoverflow.com/questions/62159709/pydicom-read-file-is-only-working-with-some-dicom-images) as yours, we could see that the problem persists at the *Pixel Data* level. You need to [install one or more optional libraries](https://pydicom.github.io/pydicom/stable/tutorials/installation.h...
52,478,863
I have an input file *div.txt* that looks like this: ``` <div>a</div>b<div>c</div> <div>d</div> ``` Now I want to pick all the *div* tags and the text between them using *sed*: ``` sed -n 's:.*\(<div>.*</div>\).*:\1:p' < div.txt ``` The result I get: ``` <div>c</div> <div>d</div> ``` What I really want: ``` <...
2018/09/24
[ "https://Stackoverflow.com/questions/52478863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5459536/" ]
This might work for you (GNU sed): ``` sed 's/\(<\/div>\)[^<]*/\1\n/;/^</P;D' file ``` Replace a `</div>` followed by zero or more characters that are not a `<` by itself and a newline. Print only lines that begin with a `<`.
Sed is not the right tool to handle HTML. But if you really insist, and you know your input will always have properly closed pairs of div tags, you can just replace everything that's not inside a div by a newline: ``` sed 's=</div>.*<div>=</div>\n<div>=' ```
62,026,087
I have a simple Glue pythonshell job and for testing purpose I just have print("Hello World") in it. I have given it the required AWSGlueServiceRole. When I am trying to run the job it throws the following error: ``` Traceback (most recent call last): File "/tmp/runscript.py", line 114, in <module> temp_file_pa...
2020/05/26
[ "https://Stackoverflow.com/questions/62026087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10133469/" ]
In Glue you need to attach S3 policies to the Amazon Glue Role that you are using to run the job. When you define the job you select the role. In this example it is AWSGlueServiceRole-S3IAMRole. That does not have S3 access until you assign it. [![enter image description here](https://i.stack.imgur.com/AzqTa.png)](htt...
You need to have the permissions to the bucket **and** the script resource. Try adding the following inline policy: ``` { "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:*" ], "Resource": "arn:aws:s3:::myBucket/*", "Effect": "Al...
69,455,665
In python, if class C inherits from two other classes C(A,B), and A and B have methods with identical names but different return values, which value will that method return on C?
2021/10/05
[ "https://Stackoverflow.com/questions/69455665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
"Inherits two methods" isn't quite accurate. What happens is that `C` has a *method resolution order* (MRO), which is the list `[C, A, B, object]`. If you attempt to access a method that `C` does not define or override, the MRO determines which class will be checked next. If the desired method is defined in `A`, it sha...
MRO order will be followed now, if you inherit A and B in C, then preference order goes from left to right, so, A will be prefered and method of A will be called instead of B
28,747,456
I am trying to install a python package using pip in linux mint but keep getting this error message. Anyone know how to fix this? ``` alex@alex-Satellite-C660D ~ $ pip install django-registration-redux Downloading/unpacking django-registration-redux Downloading django-registration-redux-1.1.tar.gz (63kB): 63kB downl...
2015/02/26
[ "https://Stackoverflow.com/questions/28747456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3541209/" ]
Autoprefixer doesn't run on it's own. It needs to be run as part of postcss-cli like so: `postcss --use autoprefixer *.css -d build/` (from <https://github.com/postcss/autoprefixer#cli>) Save-dev postcss-cli and then reformat your build:css to match `postcss --use autoprefixer -b 'last 2 versions' <assets/styles...
Installation: `npm install -g postcss-cli autoprefixer` Usage (order matters!): `postcss main.css -u autoprefixer -d dist/`
28,747,456
I am trying to install a python package using pip in linux mint but keep getting this error message. Anyone know how to fix this? ``` alex@alex-Satellite-C660D ~ $ pip install django-registration-redux Downloading/unpacking django-registration-redux Downloading django-registration-redux-1.1.tar.gz (63kB): 63kB downl...
2015/02/26
[ "https://Stackoverflow.com/questions/28747456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3541209/" ]
Autoprefixer doesn't run on it's own. It needs to be run as part of postcss-cli like so: `postcss --use autoprefixer *.css -d build/` (from <https://github.com/postcss/autoprefixer#cli>) Save-dev postcss-cli and then reformat your build:css to match `postcss --use autoprefixer -b 'last 2 versions' <assets/styles...
In the case of autoprefixer 10 and before postcss-cli v8 released, just downgrade autoprefixer to ^9.8.6.
28,747,456
I am trying to install a python package using pip in linux mint but keep getting this error message. Anyone know how to fix this? ``` alex@alex-Satellite-C660D ~ $ pip install django-registration-redux Downloading/unpacking django-registration-redux Downloading django-registration-redux-1.1.tar.gz (63kB): 63kB downl...
2015/02/26
[ "https://Stackoverflow.com/questions/28747456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3541209/" ]
Installation: `npm install -g postcss-cli autoprefixer` Usage (order matters!): `postcss main.css -u autoprefixer -d dist/`
In the case of autoprefixer 10 and before postcss-cli v8 released, just downgrade autoprefixer to ^9.8.6.
11,729,662
``` print'Personal information, journal and more to come' x = raw_input() if x ==("Personal Information"): # wont print print' Edward , Height: 5,10 , EYES: brown , STATE: IL TOWN: , SS:' elif x ==("Journal"): # wont print read = open('C:\\python\\foo.txt' , 'r') name = read.readline() print (name) ``` I star...
2012/07/30
[ "https://Stackoverflow.com/questions/11729662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1564130/" ]
> > when i type either Personal information or journal > > > Well, yeah. It isn't expecting either of those; your case is wrong. To perform a case-insensitive comparison, convert both to the same case first. ``` if foo.lower() == bar.lower(): ```
Works for me. Are you writing "Personal Information" with a capital I? ``` print'Personal information, journal and more to come' x = raw_input() if x == ("Personal Information"): # wont print print' Edward , Height: 5,10 , EYES: brown , STATE: IL TOWN: , SS:' elif x ==("Journal"): # wont print read = open('C...
11,729,662
``` print'Personal information, journal and more to come' x = raw_input() if x ==("Personal Information"): # wont print print' Edward , Height: 5,10 , EYES: brown , STATE: IL TOWN: , SS:' elif x ==("Journal"): # wont print read = open('C:\\python\\foo.txt' , 'r') name = read.readline() print (name) ``` I star...
2012/07/30
[ "https://Stackoverflow.com/questions/11729662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1564130/" ]
> > when i type either Personal information or journal > > > Well, yeah. It isn't expecting either of those; your case is wrong. To perform a case-insensitive comparison, convert both to the same case first. ``` if foo.lower() == bar.lower(): ```
You are typing in Personal information, when the if statement is expecting Personal Information (with a capital I for information). What you can do (what Ignacio above is eluding to) is do: ``` if x.lower() == ("Personal Information").lower(): ``` instead of: ``` if x == ("Personal Information"): ``` then any ca...
47,705,274
I am learning bare metal programming in c++ and it often involves setting a portion of a 32 bit hardware register address to some combination. For example for an IO pin, I can set the 15th to 17th bit in a 32 bit address to `001` to mark the pin as an output pin. I have seen code that does this and I half understand ...
2017/12/07
[ "https://Stackoverflow.com/questions/47705274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1158977/" ]
The 7 (base 10) is chosen as its binary representation is 111 (7 in base 2). As for why it's bits 8, 9 and 10 set it's because you're reading from the wrong direction. Binary, just as normal base 10, counts right to left. (I'd left this as a comment but reputation isn't high enough.)
> > How do I choose the 7 > > > You want to clear three adjacent bits. Three adjacent bits at the bottom of a word is 1+2+4=7. > > and how do I choose the number of bits to shift left > > > You want to clear bits 21-23, not bits 1-3, so you shift left another 20. Both your examples are wrong. To clear 15-1...
47,705,274
I am learning bare metal programming in c++ and it often involves setting a portion of a 32 bit hardware register address to some combination. For example for an IO pin, I can set the 15th to 17th bit in a 32 bit address to `001` to mark the pin as an output pin. I have seen code that does this and I half understand ...
2017/12/07
[ "https://Stackoverflow.com/questions/47705274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1158977/" ]
If you want to isolate and change some bits in a register but not all you need to understand the bitwise operations like and and or and xor and not operate on a single bit column, bit 3 of each operand is used to determine bit 3 of the result, no other bits are involved. So I have some bits in binary represented by let...
> > How do I choose the 7 > > > You want to clear three adjacent bits. Three adjacent bits at the bottom of a word is 1+2+4=7. > > and how do I choose the number of bits to shift left > > > You want to clear bits 21-23, not bits 1-3, so you shift left another 20. Both your examples are wrong. To clear 15-1...
32,625,597
I am having trouble getting this python code to work right. it is a code to display pascal's triangle using binomials. I do not know what is wrong. The code looks like this ``` from math import factorial def binomial (n,k): if k==0: return 1 else: return int((factorial(n)//factorial(k))*factori...
2015/09/17
[ "https://Stackoverflow.com/questions/32625597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345562/" ]
You can use ``` SELECT id, date, product_id, sales FROM sales LIMIT X OFFSET Y; ``` where X is the size of the batch you need and Y is current offset (X times number of current iterations for example)
To expand on akalikin's answer, you can use a stepped iteration to split the query into chunks, and then use LIMIT and OFFSET to execute the query. ``` cur = con.cursor(mdb.cursors.DictCursor) cur.execute("SELECT COUNT(*) FROM sales") for i in range(0,cur.fetchall(),5): cur2 = con.cursor(mdb.cursors.DictCursor) ...
32,625,597
I am having trouble getting this python code to work right. it is a code to display pascal's triangle using binomials. I do not know what is wrong. The code looks like this ``` from math import factorial def binomial (n,k): if k==0: return 1 else: return int((factorial(n)//factorial(k))*factori...
2015/09/17
[ "https://Stackoverflow.com/questions/32625597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345562/" ]
First point: a python `db-api.cursor` is an iterator, so unless you really **need** to load a whole batch in memory at once, you can just start with using this feature, ie instead of: ``` cursor.execute("SELECT * FROM mytable") rows = cursor.fetchall() for row in rows: do_something_with(row) ``` you could just: ...
You can use ``` SELECT id, date, product_id, sales FROM sales LIMIT X OFFSET Y; ``` where X is the size of the batch you need and Y is current offset (X times number of current iterations for example)
32,625,597
I am having trouble getting this python code to work right. it is a code to display pascal's triangle using binomials. I do not know what is wrong. The code looks like this ``` from math import factorial def binomial (n,k): if k==0: return 1 else: return int((factorial(n)//factorial(k))*factori...
2015/09/17
[ "https://Stackoverflow.com/questions/32625597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345562/" ]
You can use ``` SELECT id, date, product_id, sales FROM sales LIMIT X OFFSET Y; ``` where X is the size of the batch you need and Y is current offset (X times number of current iterations for example)
Thank you, here's how I implement it with your suggestions: ``` control = True index = 0 while control==True: getconn = conexiones() con = getconn.mysqlDWconnect() with con: cur = con.cursor(mdb.cursors.DictCursor) query = "SELECT id, date, product_id, sales FROM sales limit 10 OFFSET " + str...
32,625,597
I am having trouble getting this python code to work right. it is a code to display pascal's triangle using binomials. I do not know what is wrong. The code looks like this ``` from math import factorial def binomial (n,k): if k==0: return 1 else: return int((factorial(n)//factorial(k))*factori...
2015/09/17
[ "https://Stackoverflow.com/questions/32625597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345562/" ]
First point: a python `db-api.cursor` is an iterator, so unless you really **need** to load a whole batch in memory at once, you can just start with using this feature, ie instead of: ``` cursor.execute("SELECT * FROM mytable") rows = cursor.fetchall() for row in rows: do_something_with(row) ``` you could just: ...
To expand on akalikin's answer, you can use a stepped iteration to split the query into chunks, and then use LIMIT and OFFSET to execute the query. ``` cur = con.cursor(mdb.cursors.DictCursor) cur.execute("SELECT COUNT(*) FROM sales") for i in range(0,cur.fetchall(),5): cur2 = con.cursor(mdb.cursors.DictCursor) ...
32,625,597
I am having trouble getting this python code to work right. it is a code to display pascal's triangle using binomials. I do not know what is wrong. The code looks like this ``` from math import factorial def binomial (n,k): if k==0: return 1 else: return int((factorial(n)//factorial(k))*factori...
2015/09/17
[ "https://Stackoverflow.com/questions/32625597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345562/" ]
To expand on akalikin's answer, you can use a stepped iteration to split the query into chunks, and then use LIMIT and OFFSET to execute the query. ``` cur = con.cursor(mdb.cursors.DictCursor) cur.execute("SELECT COUNT(*) FROM sales") for i in range(0,cur.fetchall(),5): cur2 = con.cursor(mdb.cursors.DictCursor) ...
Thank you, here's how I implement it with your suggestions: ``` control = True index = 0 while control==True: getconn = conexiones() con = getconn.mysqlDWconnect() with con: cur = con.cursor(mdb.cursors.DictCursor) query = "SELECT id, date, product_id, sales FROM sales limit 10 OFFSET " + str...
32,625,597
I am having trouble getting this python code to work right. it is a code to display pascal's triangle using binomials. I do not know what is wrong. The code looks like this ``` from math import factorial def binomial (n,k): if k==0: return 1 else: return int((factorial(n)//factorial(k))*factori...
2015/09/17
[ "https://Stackoverflow.com/questions/32625597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5345562/" ]
First point: a python `db-api.cursor` is an iterator, so unless you really **need** to load a whole batch in memory at once, you can just start with using this feature, ie instead of: ``` cursor.execute("SELECT * FROM mytable") rows = cursor.fetchall() for row in rows: do_something_with(row) ``` you could just: ...
Thank you, here's how I implement it with your suggestions: ``` control = True index = 0 while control==True: getconn = conexiones() con = getconn.mysqlDWconnect() with con: cur = con.cursor(mdb.cursors.DictCursor) query = "SELECT id, date, product_id, sales FROM sales limit 10 OFFSET " + str...
35,894,511
When i run ``` pip install --upgrade pip ``` I get this error message: ``` Collecting pip Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 371kB/s Installing collected packages: pip Found existing installation: pip 8.0.2 Uninstalling pip-...
2016/03/09
[ "https://Stackoverflow.com/questions/35894511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827690/" ]
A permission issue means your user privileges don't allow you to write on the desired folder(`/Library/Python/2.7/site-packages/pip/`). There's basically two things you can do: 1. run pip as sudo: ``` sudo pip install --upgrade pip ``` 2. Configure pip to install only for the current user, as covered [here](https://...
From administrator mode command prompt, you can run the following command, that should fix the issue: ``` python -m ensurepip --user ``` Replace python3 if your version supports that.
35,894,511
When i run ``` pip install --upgrade pip ``` I get this error message: ``` Collecting pip Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 371kB/s Installing collected packages: pip Found existing installation: pip 8.0.2 Uninstalling pip-...
2016/03/09
[ "https://Stackoverflow.com/questions/35894511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827690/" ]
A permission issue means your user privileges don't allow you to write on the desired folder(`/Library/Python/2.7/site-packages/pip/`). There's basically two things you can do: 1. run pip as sudo: ``` sudo pip install --upgrade pip ``` 2. Configure pip to install only for the current user, as covered [here](https://...
The best way to do it is as follows: ``` $ python3 -m pip install --upgrade pip ``` as it's generally not advised to use ``` $ sudo pip install ``` More answers can be found here: <https://github.com/pypa/pip/issues/5599>
35,894,511
When i run ``` pip install --upgrade pip ``` I get this error message: ``` Collecting pip Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 371kB/s Installing collected packages: pip Found existing installation: pip 8.0.2 Uninstalling pip-...
2016/03/09
[ "https://Stackoverflow.com/questions/35894511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827690/" ]
A permission issue means your user privileges don't allow you to write on the desired folder(`/Library/Python/2.7/site-packages/pip/`). There's basically two things you can do: 1. run pip as sudo: ``` sudo pip install --upgrade pip ``` 2. Configure pip to install only for the current user, as covered [here](https://...
``` DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/r...
35,894,511
When i run ``` pip install --upgrade pip ``` I get this error message: ``` Collecting pip Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 371kB/s Installing collected packages: pip Found existing installation: pip 8.0.2 Uninstalling pip-...
2016/03/09
[ "https://Stackoverflow.com/questions/35894511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827690/" ]
The best way to do it is as follows: ``` $ python3 -m pip install --upgrade pip ``` as it's generally not advised to use ``` $ sudo pip install ``` More answers can be found here: <https://github.com/pypa/pip/issues/5599>
From administrator mode command prompt, you can run the following command, that should fix the issue: ``` python -m ensurepip --user ``` Replace python3 if your version supports that.
35,894,511
When i run ``` pip install --upgrade pip ``` I get this error message: ``` Collecting pip Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 371kB/s Installing collected packages: pip Found existing installation: pip 8.0.2 Uninstalling pip-...
2016/03/09
[ "https://Stackoverflow.com/questions/35894511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827690/" ]
From administrator mode command prompt, you can run the following command, that should fix the issue: ``` python -m ensurepip --user ``` Replace python3 if your version supports that.
``` DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/r...
35,894,511
When i run ``` pip install --upgrade pip ``` I get this error message: ``` Collecting pip Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 371kB/s Installing collected packages: pip Found existing installation: pip 8.0.2 Uninstalling pip-...
2016/03/09
[ "https://Stackoverflow.com/questions/35894511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827690/" ]
The best way to do it is as follows: ``` $ python3 -m pip install --upgrade pip ``` as it's generally not advised to use ``` $ sudo pip install ``` More answers can be found here: <https://github.com/pypa/pip/issues/5599>
``` DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/r...
10,838,596
The below piece of code is giving me a error for some reason, Can someone tell me what would be the problem.. Basically, I create 2 classes Point & Circle..THe circle is trying to inherit the Point class. ``` Code: class Point(): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self...
2012/05/31
[ "https://Stackoverflow.com/questions/10838596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1050619/" ]
It looks like you already may have fixed the original error, which was caused by `super().__init__(x,y)` as the error message indicates, although your fix was slightly incorrect, instead of `super(Point, self)` from the `Circle` class you should use `super(Circle, self)`. Note that there is another place that calls `s...
`super(..)` takes only new-style classes. To fix it, extend Point class from `object`. Like this: ``` class Point(object): ``` Also the correct way of using super(..) is like: ``` super(Circle,self).__init__(x,y) ```
10,838,596
The below piece of code is giving me a error for some reason, Can someone tell me what would be the problem.. Basically, I create 2 classes Point & Circle..THe circle is trying to inherit the Point class. ``` Code: class Point(): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self...
2012/05/31
[ "https://Stackoverflow.com/questions/10838596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1050619/" ]
It looks like you already may have fixed the original error, which was caused by `super().__init__(x,y)` as the error message indicates, although your fix was slightly incorrect, instead of `super(Point, self)` from the `Circle` class you should use `super(Circle, self)`. Note that there is another place that calls `s...
``` class Point(object): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self.y = y print("Point constructor") def ToString(self): return "{X:" + str(self.x) + ",Y:" + str(self.y) + "}" class Circle(Point,object): radius = 0.0 def __init__(self, x, y, radius): super(Circle,self).__init__(x...
10,838,596
The below piece of code is giving me a error for some reason, Can someone tell me what would be the problem.. Basically, I create 2 classes Point & Circle..THe circle is trying to inherit the Point class. ``` Code: class Point(): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self...
2012/05/31
[ "https://Stackoverflow.com/questions/10838596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1050619/" ]
`super(..)` takes only new-style classes. To fix it, extend Point class from `object`. Like this: ``` class Point(object): ``` Also the correct way of using super(..) is like: ``` super(Circle,self).__init__(x,y) ```
``` class Point(object): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self.y = y print("Point constructor") def ToString(self): return "{X:" + str(self.x) + ",Y:" + str(self.y) + "}" class Circle(Point,object): radius = 0.0 def __init__(self, x, y, radius): super(Circle,self).__init__(x...
71,391,688
pip install pygame==2.0.0.dev10 this package not installed in python 3.8.2 version.so when I run the gaming project so that time this error showing.instead of this I am install pip install pygame==2.0.0.dev12,this package is install but same error is showing. so can anyone give me a solution
2022/03/08
[ "https://Stackoverflow.com/questions/71391688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18405878/" ]
Redirect in htaccess does not matter if it is a pdf file or anything else just a **valid link**. This is an example of a 301 redirect code to the link you want `RedirectMatch 301 /subpage/ <https://www.mywebsite.com/upload/files/file.pdf>`
To target an HTML link to a specific page in a PDF file, add #page=[page number] to the end of the link's URL. For example, this HTML tag opens page 4 of a PDF file named myfile.pdf: ``` <A HREF="http://www.example.com/myfile.pdf#page=4"> ``` --- And If you want to redirect a single page to another you just need t...
71,391,688
pip install pygame==2.0.0.dev10 this package not installed in python 3.8.2 version.so when I run the gaming project so that time this error showing.instead of this I am install pip install pygame==2.0.0.dev12,this package is install but same error is showing. so can anyone give me a solution
2022/03/08
[ "https://Stackoverflow.com/questions/71391688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18405878/" ]
You are getting a `404` probably because the URI `/subpage` doesn't exist or map to an existent file. The `Redirect` you are using doesn't redirect the `/subpage` to the PDF location because your WordPress `RewriteRules` override it. If you want to fix it , you will need to use `RewriteRule` directive instead of `Redir...
To target an HTML link to a specific page in a PDF file, add #page=[page number] to the end of the link's URL. For example, this HTML tag opens page 4 of a PDF file named myfile.pdf: ``` <A HREF="http://www.example.com/myfile.pdf#page=4"> ``` --- And If you want to redirect a single page to another you just need t...
71,391,688
pip install pygame==2.0.0.dev10 this package not installed in python 3.8.2 version.so when I run the gaming project so that time this error showing.instead of this I am install pip install pygame==2.0.0.dev12,this package is install but same error is showing. so can anyone give me a solution
2022/03/08
[ "https://Stackoverflow.com/questions/71391688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18405878/" ]
You are getting a `404` probably because the URI `/subpage` doesn't exist or map to an existent file. The `Redirect` you are using doesn't redirect the `/subpage` to the PDF location because your WordPress `RewriteRules` override it. If you want to fix it , you will need to use `RewriteRule` directive instead of `Redir...
Redirect in htaccess does not matter if it is a pdf file or anything else just a **valid link**. This is an example of a 301 redirect code to the link you want `RedirectMatch 301 /subpage/ <https://www.mywebsite.com/upload/files/file.pdf>`
33,813,848
I only started using python, so i don't know it very well.Can you help how to say that the number should not be divisible by another integer given by me ? For example, if a is not divisible by 2.
2015/11/19
[ "https://Stackoverflow.com/questions/33813848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5583129/" ]
Check out the % operator. ``` if x%2 == 0: # x is divisible by 2 print x ```
"a is not divisible by 2": `(a % 2) != 0`
33,813,848
I only started using python, so i don't know it very well.Can you help how to say that the number should not be divisible by another integer given by me ? For example, if a is not divisible by 2.
2015/11/19
[ "https://Stackoverflow.com/questions/33813848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5583129/" ]
``` >>> def isDivis(divisor,num): return not num%divisor >>> isDivis(2,12) True >>> isDivis(2,21) False >>> isDivis(3,21) True >>> isDivis(3,14) False ```
"a is not divisible by 2": `(a % 2) != 0`
49,626,707
``` from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.options import Options import time chrome_options = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notifications" : 2} chrome_options.add_experimental_option("prefs",prefs) drive...
2018/04/03
[ "https://Stackoverflow.com/questions/49626707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9575127/" ]
As you have created an instance of `ChromeOptions()` as **chrome\_options** you need to pass it as an argument to put the configurations in effect while invoking `webdriver.Chrome()` as follows : ``` from selenium import webdriver from selenium.webdriver.chrome.options import Options import time chrome_options = webd...
``` driver.switch_to_alert().dismiss() driver.switch_to_alert().accept() ``` These can be used dismiss-right and accept-left
22,418,816
I'm trying to use multiprocessing to get a handle on my memory issues, however I can't get a function to pickle, and I have no idea why. My main code starts with ``` def main(): print "starting main" q = Queue() p = Process(target=file_unpacking,args=("hellow world",q)) p.start() p.join() if p...
2014/03/15
[ "https://Stackoverflow.com/questions/22418816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2352742/" ]
Pickling a function is a very very relevant thing to do if you want to do any parallel computing. Python's `pickle` and `multiprocessing` are pretty broken for doing parallel computing, so if you aren't adverse to going outside of the standard library, I'd suggest `dill` for serialization, and `pathos.multiprocessing` ...
You can technically pickle a function. But, it's only a name reference that's being saved. When you unpickle, you must set up the environment so that the name reference makes sense to python. Make sure to read [What can be pickled and unpicked](http://docs.python.org/2/library/pickle.html#what-can-be-pickled-and-unpick...
38,947,967
I'm trying to mungle my data from the following data frame to the one following it where the values in column B and C are combined to column names for the values in D grouped by the values in A. Below is a reproducible example. ``` set.seed(10) fooDF <- data.frame(A = sample(1:4, 10, replace=TRUE), B = sample(letter...
2016/08/15
[ "https://Stackoverflow.com/questions/38947967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3329254/" ]
`my Tuple $t` creates a `$t` variable such that any (re)assignment or (re)binding to it must (re)pass the `Tuple` type check. `= [1, 2]` assigns a reference to an `Array` object. The `Tuple` type check is applied (and passes). `$t.append(3)` modifies the contents of the `Array` object held in `$t` but does not reassi...
The type constraint is bound to the scalar container, but the object it contains is just a plain old array - and an array's `append` method is unaware you want it to trigger a type check. If you want to explicitly trigger the check again, you could do a reassignment like `$t = $t`.
38,947,967
I'm trying to mungle my data from the following data frame to the one following it where the values in column B and C are combined to column names for the values in D grouped by the values in A. Below is a reproducible example. ``` set.seed(10) fooDF <- data.frame(A = sample(1:4, 10, replace=TRUE), B = sample(letter...
2016/08/15
[ "https://Stackoverflow.com/questions/38947967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3329254/" ]
The type constraint is bound to the scalar container, but the object it contains is just a plain old array - and an array's `append` method is unaware you want it to trigger a type check. If you want to explicitly trigger the check again, you could do a reassignment like `$t = $t`.
If you really want an altered version of an [`Array`](https://docs.perl6.org/type/Array), you can simply create a class that inherits from it and overrides the methods that you want to behave differently. (There are probably much more elegant ways to do this, but this does work): ``` class Tuple is Array { method ...
38,947,967
I'm trying to mungle my data from the following data frame to the one following it where the values in column B and C are combined to column names for the values in D grouped by the values in A. Below is a reproducible example. ``` set.seed(10) fooDF <- data.frame(A = sample(1:4, 10, replace=TRUE), B = sample(letter...
2016/08/15
[ "https://Stackoverflow.com/questions/38947967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3329254/" ]
`my Tuple $t` creates a `$t` variable such that any (re)assignment or (re)binding to it must (re)pass the `Tuple` type check. `= [1, 2]` assigns a reference to an `Array` object. The `Tuple` type check is applied (and passes). `$t.append(3)` modifies the contents of the `Array` object held in `$t` but does not reassi...
If you really want an altered version of an [`Array`](https://docs.perl6.org/type/Array), you can simply create a class that inherits from it and overrides the methods that you want to behave differently. (There are probably much more elegant ways to do this, but this does work): ``` class Tuple is Array { method ...
64,318,676
I am trying to scrape all email addresses from this index page - <http://www.uschess.org/assets/msa_joomla/AffiliateSearch/clubresultsnew.php?st=AL> I modified a python script to define the string, parse content with BS4 and save each unique address to an xls file: ``` import requests from bs4 import BeautifulSoup im...
2020/10/12
[ "https://Stackoverflow.com/questions/64318676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5705012/" ]
Your insert has 2 issues. Assuming the string '1,2,3,4' is the result of your decode (not at all clear on that) there is no new line ( chr(10)||chr(13) ) data in it. As a result there is only 1 value to be extracted. Perhaps the decoded result is actually a CSV. I proceed with that assumption. Your second issue is ...
``` PROCEDURE LOAD_SPM_ITEM_SYNC(P_ENCODED_STRING IN CLOB,truncateflag in varchar2) IS r_records varchar2(3000); BEGIN declare cursor c_records IS select regexp_substr(utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw(P_ENCODED_STRING))), '[^'||CHR(10)||CHR(13)||']+', 1, level) from dual connect b...
50,330,893
I use python-telegram-bot and I don't understand how forward a message from the user to a telegram group, I have something like this: ``` def feed(bot, update): bot.send_message(chat_id=update.message.chat_id, text="reply this message" bot.forward_message(chat_id="telegram group", from_chat_id="username bot", mess...
2018/05/14
[ "https://Stackoverflow.com/questions/50330893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9788313/" ]
From [documentation](https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html#telegram.Bot.forward_message): **chat\_id** - Unique identifier for the target chat ... **from\_chat\_id** - Unique identifier for the ***chat where the original message was sent*** ... **message\_id** - Message identif...
Its easy with `Telethon`. You need the `chat_id`, `from_chat_id`. You can add a bot and you will need the token.
25,044,403
I've had success with `mvn deploy` for about a week now, and suddenly it's not working. It used to prompt me for my passphrase (in a dialog window--I'm using Kleopatra on Windows 7, 32bit), but it's not any more. The only thing that's changed in the POM is the project's version number. There are two random outcomes, b...
2014/07/30
[ "https://Stackoverflow.com/questions/25044403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2736496/" ]
Set your gpg.passphrase in your ~/.m2/settings.xml like so: ``` <server> <id>gpg.passphrase</id> <passphrase>clear or encrypted text</passphrase> </server> ``` Or pass it as a parameter when calling maven: ``` mvn -Dgpg.passphrase=yourpassphrase deploy ```
I uninstalled gpg4win (of which Kleopatra is part), restarted my computer, and re-installed gpg4win, and the passphrase issue went away. The dialog popped up and prompted me for my password. ``` R:\jeffy\programming\sandbox\z__for_git_commit_only\xbnjava>mvn deploy [INFO] Scanning for projects... [INFO] ...
25,044,403
I've had success with `mvn deploy` for about a week now, and suddenly it's not working. It used to prompt me for my passphrase (in a dialog window--I'm using Kleopatra on Windows 7, 32bit), but it's not any more. The only thing that's changed in the POM is the project's version number. There are two random outcomes, b...
2014/07/30
[ "https://Stackoverflow.com/questions/25044403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2736496/" ]
Set your gpg.passphrase in your ~/.m2/settings.xml like so: ``` <server> <id>gpg.passphrase</id> <passphrase>clear or encrypted text</passphrase> </server> ``` Or pass it as a parameter when calling maven: ``` mvn -Dgpg.passphrase=yourpassphrase deploy ```
Definily it will work: GPG version: ------------ ``` C:\Users\joao.almeida>gpg --version gpg (GnuPG) 2.2.3 libgcrypt 1.8.1 Copyright (C) 2017 Free Software Foundation, Inc. ``` --- pom.xml ------- ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg...
62,327,106
I am trying to make a class consisting of several methods and I want to use return values from methods as parameters for other methods within the same class. Is it possible to do so? ``` class Result_analysis(): def __init__(self, confidence_interval): self.confidence_interval = confidence_interval d...
2020/06/11
[ "https://Stackoverflow.com/questions/62327106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13628325/" ]
You didn't include all your code, and you should have updated the question with the traceback, but did you mean this: ``` n = ... # I don't know what n is. d = Result_analysis(0.95) print(d.extract_arrays(d.read_file(n)) ```
If you don't want to call the function read\_file explicitly from outside class. then you can convert the program as: ``` class Result_analysis(): def __init__(self, confidence_interval): self.confidence_interval = confidence_interval def read_file(self, file_number): dict_ = {1: 'Ten_Runs_avg...