qid
int64
46k
74.7M
question
stringlengths
54
37.8k
date
stringlengths
10
10
metadata
listlengths
3
3
response_j
stringlengths
17
26k
response_k
stringlengths
26
26k
4,591,125
I did several Boolean Comparisons: ``` >>> (True or False) is True True >>> (True or False) == True True ``` It sounds like `==` and `is` are interchangeable for Boolean-values. Sometimes it's more clear to use `is` I want to know that: Are `True` and `False` pre-allocated in python? Is `bool(var)` always retur...
2011/01/04
[ "https://Stackoverflow.com/questions/4591125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348785/" ]
You probably shouldn't ever need to compare booleans. If you are doing something like: ``` if some_bool == True: ... ``` ...just change it to: ``` if some_bool: ... ``` No `is` or `==` needed. As commenters have pointed out, there are valid reasons to compare booleans. If both booleans are unknown and you wa...
`==` and `is` are both comparison operators, which would return a boolean value - `True` or `False`. True has a numeric value of 1 and False has a numeric value of 0. The operator `==` compare the values of two objects and objects compared are most often are the same types (int vs int, float vs float), If you compare ...
4,591,125
I did several Boolean Comparisons: ``` >>> (True or False) is True True >>> (True or False) == True True ``` It sounds like `==` and `is` are interchangeable for Boolean-values. Sometimes it's more clear to use `is` I want to know that: Are `True` and `False` pre-allocated in python? Is `bool(var)` always retur...
2011/01/04
[ "https://Stackoverflow.com/questions/4591125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348785/" ]
Watch out for what else you may be comparing. ``` >>> 1 == True True >>> 1 is True False ``` True and False will have stable object ids for their lifetime in your python instance. ``` >>> id(True) 4296106928 >>> id(True) 4296106928 ``` `is` compares the id of an object EDIT: adding `or` Since OP is using `or` i...
`==` and `is` are both comparison operators, which would return a boolean value - `True` or `False`. True has a numeric value of 1 and False has a numeric value of 0. The operator `==` compare the values of two objects and objects compared are most often are the same types (int vs int, float vs float), If you compare ...
4,591,125
I did several Boolean Comparisons: ``` >>> (True or False) is True True >>> (True or False) == True True ``` It sounds like `==` and `is` are interchangeable for Boolean-values. Sometimes it's more clear to use `is` I want to know that: Are `True` and `False` pre-allocated in python? Is `bool(var)` always retur...
2011/01/04
[ "https://Stackoverflow.com/questions/4591125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348785/" ]
It seems that all answers deal with `True` and `False` as defined after an interpreter startup. Before booleans became part of Python they were often defined as part of a program. Even now (Python 2.6.6) they are only names that can be pointed to different objects: ``` >>> True = 1 >>> (2 > 1) True >>> (2 > 1) == True...
[The == operator tests for equality The is keyword tests for object identity. Whether we are talking about the same object. Note, that more variables may refer to the same object.](http://zetcode.com/tutorials/pythontutorial/keywords/)
4,591,125
I did several Boolean Comparisons: ``` >>> (True or False) is True True >>> (True or False) == True True ``` It sounds like `==` and `is` are interchangeable for Boolean-values. Sometimes it's more clear to use `is` I want to know that: Are `True` and `False` pre-allocated in python? Is `bool(var)` always retur...
2011/01/04
[ "https://Stackoverflow.com/questions/4591125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348785/" ]
You probably shouldn't ever need to compare booleans. If you are doing something like: ``` if some_bool == True: ... ``` ...just change it to: ``` if some_bool: ... ``` No `is` or `==` needed. As commenters have pointed out, there are valid reasons to compare booleans. If both booleans are unknown and you wa...
Yes. There are [guaranteed](http://docs.python.org/library/functions.html#bool) to be exactly two `bool`s, True and False: > > Class bool cannot be subclassed > further. Its only instances are False > and True. > > > That means *if* you know both operands are `bool`, `==` and `is` are equivalent. However, as de...
4,591,125
I did several Boolean Comparisons: ``` >>> (True or False) is True True >>> (True or False) == True True ``` It sounds like `==` and `is` are interchangeable for Boolean-values. Sometimes it's more clear to use `is` I want to know that: Are `True` and `False` pre-allocated in python? Is `bool(var)` always retur...
2011/01/04
[ "https://Stackoverflow.com/questions/4591125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348785/" ]
Yes. There are [guaranteed](http://docs.python.org/library/functions.html#bool) to be exactly two `bool`s, True and False: > > Class bool cannot be subclassed > further. Its only instances are False > and True. > > > That means *if* you know both operands are `bool`, `==` and `is` are equivalent. However, as de...
It seems that all answers deal with `True` and `False` as defined after an interpreter startup. Before booleans became part of Python they were often defined as part of a program. Even now (Python 2.6.6) they are only names that can be pointed to different objects: ``` >>> True = 1 >>> (2 > 1) True >>> (2 > 1) == True...
4,591,125
I did several Boolean Comparisons: ``` >>> (True or False) is True True >>> (True or False) == True True ``` It sounds like `==` and `is` are interchangeable for Boolean-values. Sometimes it's more clear to use `is` I want to know that: Are `True` and `False` pre-allocated in python? Is `bool(var)` always retur...
2011/01/04
[ "https://Stackoverflow.com/questions/4591125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348785/" ]
Yes. There are [guaranteed](http://docs.python.org/library/functions.html#bool) to be exactly two `bool`s, True and False: > > Class bool cannot be subclassed > further. Its only instances are False > and True. > > > That means *if* you know both operands are `bool`, `==` and `is` are equivalent. However, as de...
[The == operator tests for equality The is keyword tests for object identity. Whether we are talking about the same object. Note, that more variables may refer to the same object.](http://zetcode.com/tutorials/pythontutorial/keywords/)
4,591,125
I did several Boolean Comparisons: ``` >>> (True or False) is True True >>> (True or False) == True True ``` It sounds like `==` and `is` are interchangeable for Boolean-values. Sometimes it's more clear to use `is` I want to know that: Are `True` and `False` pre-allocated in python? Is `bool(var)` always retur...
2011/01/04
[ "https://Stackoverflow.com/questions/4591125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/348785/" ]
Watch out for what else you may be comparing. ``` >>> 1 == True True >>> 1 is True False ``` True and False will have stable object ids for their lifetime in your python instance. ``` >>> id(True) 4296106928 >>> id(True) 4296106928 ``` `is` compares the id of an object EDIT: adding `or` Since OP is using `or` i...
[The == operator tests for equality The is keyword tests for object identity. Whether we are talking about the same object. Note, that more variables may refer to the same object.](http://zetcode.com/tutorials/pythontutorial/keywords/)
62,745,685
I am a beginner in Python. Here's what I am trying to do : ```python import numpy as np r10 = np.array([[i for i in range(0,10)],[i*10 for i in range(0,10)]]).T r6 = np.array([[i for i in range(0,6)],[i*10 for i in range(0,6)]]).T r_comb = np.array([[r10],[r6]]).T np.savetxt('out.txt',r_comb) ``` Using np.savetxt g...
2020/07/05
[ "https://Stackoverflow.com/questions/62745685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13872751/" ]
How about using a ref as the gatekeepr ``` function useEffectIfReady(fn, deps = [], isReady = true) { const readyWasToggled = useRef(isReady); /* There are 2 states: 0 - initial 1 - ready was toggled */ const getDep = () => { if (readyWasToggled.current) { return 1; } if (isReady...
Try splitting the useEffect in this case for each state, just an idea based on your codes ``` useEffect(() => { // your codes here if (!isTrue) { return; } }, [isTrue]); useEffect(() => { // your another set of codes here someFunction(dep); }, [dep]) ```
62,745,685
I am a beginner in Python. Here's what I am trying to do : ```python import numpy as np r10 = np.array([[i for i in range(0,10)],[i*10 for i in range(0,10)]]).T r6 = np.array([[i for i in range(0,6)],[i*10 for i in range(0,6)]]).T r_comb = np.array([[r10],[r6]]).T np.savetxt('out.txt',r_comb) ``` Using np.savetxt g...
2020/07/05
[ "https://Stackoverflow.com/questions/62745685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13872751/" ]
How about using a ref as the gatekeepr ``` function useEffectIfReady(fn, deps = [], isReady = true) { const readyWasToggled = useRef(isReady); /* There are 2 states: 0 - initial 1 - ready was toggled */ const getDep = () => { if (readyWasToggled.current) { return 1; } if (isReady...
If I have understood your query correctly, you need to execute the `someFn()` depending on the value of isTrue. Though there are ways using custom hooks to compare old and new values and that can be used to solve your problem here, I think there is a much simpler solution to it. Simply, removing the `isTrue` from the...
62,745,685
I am a beginner in Python. Here's what I am trying to do : ```python import numpy as np r10 = np.array([[i for i in range(0,10)],[i*10 for i in range(0,10)]]).T r6 = np.array([[i for i in range(0,6)],[i*10 for i in range(0,6)]]).T r_comb = np.array([[r10],[r6]]).T np.savetxt('out.txt',r_comb) ``` Using np.savetxt g...
2020/07/05
[ "https://Stackoverflow.com/questions/62745685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13872751/" ]
How about using a ref as the gatekeepr ``` function useEffectIfReady(fn, deps = [], isReady = true) { const readyWasToggled = useRef(isReady); /* There are 2 states: 0 - initial 1 - ready was toggled */ const getDep = () => { if (readyWasToggled.current) { return 1; } if (isReady...
If I've understood correctly then the behaviour you're looking for is: * if `isReady` becomes true for the first time, run `fn()` * if `isReady` flips from false to true: 1. `deps` have changed since last time ready, run `fn()` 2. `deps` have not changed since last time ready, do not run `fn()` * if `deps` change an...
62,745,685
I am a beginner in Python. Here's what I am trying to do : ```python import numpy as np r10 = np.array([[i for i in range(0,10)],[i*10 for i in range(0,10)]]).T r6 = np.array([[i for i in range(0,6)],[i*10 for i in range(0,6)]]).T r_comb = np.array([[r10],[r6]]).T np.savetxt('out.txt',r_comb) ``` Using np.savetxt g...
2020/07/05
[ "https://Stackoverflow.com/questions/62745685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13872751/" ]
If I have understood your query correctly, you need to execute the `someFn()` depending on the value of isTrue. Though there are ways using custom hooks to compare old and new values and that can be used to solve your problem here, I think there is a much simpler solution to it. Simply, removing the `isTrue` from the...
Try splitting the useEffect in this case for each state, just an idea based on your codes ``` useEffect(() => { // your codes here if (!isTrue) { return; } }, [isTrue]); useEffect(() => { // your another set of codes here someFunction(dep); }, [dep]) ```
62,745,685
I am a beginner in Python. Here's what I am trying to do : ```python import numpy as np r10 = np.array([[i for i in range(0,10)],[i*10 for i in range(0,10)]]).T r6 = np.array([[i for i in range(0,6)],[i*10 for i in range(0,6)]]).T r_comb = np.array([[r10],[r6]]).T np.savetxt('out.txt',r_comb) ``` Using np.savetxt g...
2020/07/05
[ "https://Stackoverflow.com/questions/62745685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13872751/" ]
If I've understood correctly then the behaviour you're looking for is: * if `isReady` becomes true for the first time, run `fn()` * if `isReady` flips from false to true: 1. `deps` have changed since last time ready, run `fn()` 2. `deps` have not changed since last time ready, do not run `fn()` * if `deps` change an...
Try splitting the useEffect in this case for each state, just an idea based on your codes ``` useEffect(() => { // your codes here if (!isTrue) { return; } }, [isTrue]); useEffect(() => { // your another set of codes here someFunction(dep); }, [dep]) ```
66,015,125
I am running python3.9 on ubuntu 18.04. I already went ahead and rand the command `sudo apt-get install python-scipy` and got the message: ``` Reading package lists... Done Building dependency tree Reading state information... Done python-scipy is already the newest version (0.19.1-2ubuntu1). The following pack...
2021/02/02
[ "https://Stackoverflow.com/questions/66015125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13972346/" ]
Maybe try ```sh python3.9 -m pip install scipy --user ``` which would use pip of python3.9 to install the package to a place without sudo privilege
Try `pip3 install scipy`, if that returns an `ERRNO 13: access denied` then try `pip3 install scipy --user`
66,015,125
I am running python3.9 on ubuntu 18.04. I already went ahead and rand the command `sudo apt-get install python-scipy` and got the message: ``` Reading package lists... Done Building dependency tree Reading state information... Done python-scipy is already the newest version (0.19.1-2ubuntu1). The following pack...
2021/02/02
[ "https://Stackoverflow.com/questions/66015125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13972346/" ]
Maybe try ```sh python3.9 -m pip install scipy --user ``` which would use pip of python3.9 to install the package to a place without sudo privilege
use pipwin ``` pip install pipwin ``` after download ``` pipwin install scipy ```
66,015,125
I am running python3.9 on ubuntu 18.04. I already went ahead and rand the command `sudo apt-get install python-scipy` and got the message: ``` Reading package lists... Done Building dependency tree Reading state information... Done python-scipy is already the newest version (0.19.1-2ubuntu1). The following pack...
2021/02/02
[ "https://Stackoverflow.com/questions/66015125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13972346/" ]
use pipwin ``` pip install pipwin ``` after download ``` pipwin install scipy ```
Try `pip3 install scipy`, if that returns an `ERRNO 13: access denied` then try `pip3 install scipy --user`
31,568,936
I am using Selenium webdriver with firefox. I am wondering if there is a setting i can change such that it to only requesting resources from certain domains. (Specifically i want it only to request content which is on the same domain as the webpage itself). My current set up, written in Python, is: ```python from se...
2015/07/22
[ "https://Stackoverflow.com/questions/31568936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2801069/" ]
With thanks to Vicky, (who's approach of using Proxy settings i followed - although directly from Selenium), the code below will change the proxy settings in firefox such that it will not connect to a domain except that on the white-list. I suspect several setting changes are unnecessary and can be omitted for most pu...
I think it is still impossible in selenium.But you can still achieve this by using proxies like browsermob. Webdriver integrates well with [browsermob](https://github.com/lightbody/browsermob-proxy) proxy. **Sample pseudeocode in java** ```java //LittleProxy-powered 2.1.0 release LegacyProxyServer server = n...
61,424,762
I am a beginner in python. I am currently building an online video study website like Udemy and Treehouse using Flask. The little issue is that, the videos on the site can be downloaded by viewing or inspecting the source code. Browsers with video download extension (firefox, Chrome etc) can easily download videos when...
2020/04/25
[ "https://Stackoverflow.com/questions/61424762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12172995/" ]
I don't think the problem comes from the flask side, but from the frontend side. So you might check if this is possible through javascript. I quickly looked into it and saw the question below: I think you are facing a problem related to that mentioned in - [Prevent HTML5 video from being downloaded (right-click saved)...
You have a couple of options here to make it more difficult, in order of difficulty: 1. You absolutely can use .htaccess (it is a web server feature--nothing to do with PHP) to require the referrer to be your site. Don't allow access to the video file if the referrer doesn't contain your site. ([See here for how to do...
58,487,038
I have a `while` loop that exits when an `if(condition){break;}` is met, after an unknown number of iterations. Inside the `while` loop, a function is called, that will return an array of variable size at every iteration. I know in `python` I could just append the arrays one to each other, and in the end I would have a...
2019/10/21
[ "https://Stackoverflow.com/questions/58487038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9104884/" ]
You need to store store the zeros in `foo` independently from the values returned by `find_zeros`, as you would in Python, where you'd have separate variables `zeros_list` and `zeros`. Python's `list.append` method is realized in two steps: first the array is reallocated to new capacity with `realloc` (you already hav...
regarding your question: *// append the zeros somewhere (how?!)* the easiest way is a call to `memcpy()` similar to: ``` memcpy( &zeros[ last used offset ], newXeros, sizeof( newzeros ) ); ```
35,241,760
I'm running this every minute to debug and it keeps returning with `com.apple.xpc.launchd[1] (com.me.DesktopChanger[16390]): Service exited with abnormal code: 2` ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist ver...
2016/02/06
[ "https://Stackoverflow.com/questions/35241760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3042759/" ]
You can use the `reduce` method. ``` let placeNames = results.reduce("") { (placeNames, place) -> String in return placeNames + place.name + " " } ``` Now you have a single `String` with the concatenation of all the place names. Short notation -------------- You can also write it as follow ``` let placeNames ...
You can do it without a loop: (the '$0' is the argument in the closure) ``` results.forEach{ print($0, terminator:" ") } ```
35,241,760
I'm running this every minute to debug and it keeps returning with `com.apple.xpc.launchd[1] (com.me.DesktopChanger[16390]): Service exited with abnormal code: 2` ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist ver...
2016/02/06
[ "https://Stackoverflow.com/questions/35241760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3042759/" ]
You can use the `reduce` method. ``` let placeNames = results.reduce("") { (placeNames, place) -> String in return placeNames + place.name + " " } ``` Now you have a single `String` with the concatenation of all the place names. Short notation -------------- You can also write it as follow ``` let placeNames ...
If you want the put the results right into one string you can do: ``` let results = (try? myContext.executeFetchRequest(fetchRequest)) as? [Places] ?? [] let places = results.flatMap { $0.name }.joinWithSeparator(" ") ```
35,241,760
I'm running this every minute to debug and it keeps returning with `com.apple.xpc.launchd[1] (com.me.DesktopChanger[16390]): Service exited with abnormal code: 2` ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist ver...
2016/02/06
[ "https://Stackoverflow.com/questions/35241760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3042759/" ]
You can use the `reduce` method. ``` let placeNames = results.reduce("") { (placeNames, place) -> String in return placeNames + place.name + " " } ``` Now you have a single `String` with the concatenation of all the place names. Short notation -------------- You can also write it as follow ``` let placeNames ...
I wanted to specify 2 things FRP === You can use function style on sequence types. In this can you want to transform an array of `Places` in a array of `name` of the places. To do that you can use the `map` function. `places.map{$0.name}` will returns an array of name. As name is optional, use `flatMap` instead ...
35,241,760
I'm running this every minute to debug and it keeps returning with `com.apple.xpc.launchd[1] (com.me.DesktopChanger[16390]): Service exited with abnormal code: 2` ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist ver...
2016/02/06
[ "https://Stackoverflow.com/questions/35241760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3042759/" ]
If you want the put the results right into one string you can do: ``` let results = (try? myContext.executeFetchRequest(fetchRequest)) as? [Places] ?? [] let places = results.flatMap { $0.name }.joinWithSeparator(" ") ```
You can do it without a loop: (the '$0' is the argument in the closure) ``` results.forEach{ print($0, terminator:" ") } ```
35,241,760
I'm running this every minute to debug and it keeps returning with `com.apple.xpc.launchd[1] (com.me.DesktopChanger[16390]): Service exited with abnormal code: 2` ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist ver...
2016/02/06
[ "https://Stackoverflow.com/questions/35241760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3042759/" ]
If you want the put the results right into one string you can do: ``` let results = (try? myContext.executeFetchRequest(fetchRequest)) as? [Places] ?? [] let places = results.flatMap { $0.name }.joinWithSeparator(" ") ```
I wanted to specify 2 things FRP === You can use function style on sequence types. In this can you want to transform an array of `Places` in a array of `name` of the places. To do that you can use the `map` function. `places.map{$0.name}` will returns an array of name. As name is optional, use `flatMap` instead ...
18,782,620
(disclaimer: this is my first stackoverflow question so forgive me in advance if I'm not too clear) **Expected results:** My task is to find company legal identifiers in a string representing a company name, then separate them from it and save them in a separate string. The company names have already been cleaned so...
2013/09/13
[ "https://Stackoverflow.com/questions/18782620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2775630/" ]
Non-Regex solution would be easier here, and this is how, I would do it ``` legal_ids = """gmbh gesmbh""" def foo(name, legal_ids): #Remove all spaces from the string name_stream = name.replace(' ','') #Now iterate through the legal_ids for id in legal_ids: #Remove the legal ID's from the s...
Here's the code I came up with: ``` company_1 = 'uber wien abcd gmbh' company_2 = 'uber wien abcd g m b h' company_3 = 'uber wien abcd ges mbh' legalids = ["gmbh", "gesmbh"] def info(company, legalids): for legalid in legalids: found = [] last_pos = len(company)-1 pos = len(legalid)-1 ...
18,782,620
(disclaimer: this is my first stackoverflow question so forgive me in advance if I'm not too clear) **Expected results:** My task is to find company legal identifiers in a string representing a company name, then separate them from it and save them in a separate string. The company names have already been cleaned so...
2013/09/13
[ "https://Stackoverflow.com/questions/18782620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2775630/" ]
I think I got to an acceptable solution. I used part of my original code, part of the code by @Abhijit and the main idea behind @wei2912 's code. Thank you all Here is the code I am going to use: ``` legal_ids = '^ltd|ltd$|^gmbh|gmbh$|^gesmbh|gesmbh$' def foo(name, legal_ids): #initialize re (company id at begin...
Here's the code I came up with: ``` company_1 = 'uber wien abcd gmbh' company_2 = 'uber wien abcd g m b h' company_3 = 'uber wien abcd ges mbh' legalids = ["gmbh", "gesmbh"] def info(company, legalids): for legalid in legalids: found = [] last_pos = len(company)-1 pos = len(legalid)-1 ...
51,030,872
Using Tensorflow 1.8.0, we are running into an issue whenever we attempt to build a categorical column. Here is a full example demonstrating the problem. It runs as-is (using only numeric columns). Uncommenting the indicator column definition and data generates a stack trace ending in `tensorflow.python.framework.error...
2018/06/25
[ "https://Stackoverflow.com/questions/51030872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3955068/" ]
The issue here is related to the ragged shape of the "indicator" input array (some elements are of length 1, one is length 2, one is length 3). If you pad your input lists with some non-vocabulary string (I used "Z" for example since your vocabulary is "A", "B", "C"), you'll get the expected results: ``` inputs = { ...
From what I can tell, the difficulty is that you are trying to make an indicator column from an array of arrays. I collapsed your indicator array to ``` "indicator": np.array([ "A", "B", "C", "AA", "ABC", ]) ``` ... and the thing ran. More, I can't find any example where the vocabulary array is anythin...
28,654,247
I want to remove the heteroatoms (HETATM)s from PDB text files that I have locally. I found a perl script that apparently needs a quick tweak to make it do what I want but I'm unsure of what that tweak is. ``` !#/usr/bin/env perl open(FILE,"file.pdb"); @file=<FILE>; foreach (@file){ if (/^HETATM/){ print $_,"\n"; }}...
2015/02/22
[ "https://Stackoverflow.com/questions/28654247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4589414/" ]
In R you can use the [Bio3D package](http://thegrantlab.org/bio3d/): ``` library(bio3d) # read pdb pdb <- read.pdb("1hel") # make a subset based on TYPE new <- trim.pdb(pdb, type="ATOM") # write new pdb to disk write.pdb(new, file="1hel_ATOM.pdb") ``` This can also be combined with various other selection criteri...
In PERL Try this ``` use warnings; use strict; my $filename = "4BI7.pdb"; die "Error opening file" unless (open my $handler , '<' , "$filename"); open my $newfile, '>', "filename.pdb" or die "New file not create"; while($_ = <$handler>){ print $newfile "$_" unless /^HETATM.*/; } ```
57,771,019
I want to write something like this when expressed in python. ``` a = int(input()) for i in range(a): b = input() print(b) ``` And this is what I actually wrote. ``` (let [a][(read-line)] (for[i (range [a])] (defn b[string] (= (read-line) b) (println [b]))))...
2019/09/03
[ "https://Stackoverflow.com/questions/57771019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5237648/" ]
Similar to the Python flow. ``` (doseq [_ (range (Integer. (read-line))) :let [b (read-line)]] (println b)) ``` Even closer to Python code: ``` (let [a (Integer. (read-line))] (doseq [i (range a) :let [b (read-line)]] (println b))) ``` More functional Code ``` (mapv println (repeatedly ...
Off the top of my head, you could do something like: `(map (fn [_] (println (read-line))) (range (Integer/parseInt (read-line))))` There may be something more appropriate than a map here, read the clojure documentation. The clojure standard library has a lot of cool stuff :) Edit: @SeanCorfield brought up a good po...
57,771,019
I want to write something like this when expressed in python. ``` a = int(input()) for i in range(a): b = input() print(b) ``` And this is what I actually wrote. ``` (let [a][(read-line)] (for[i (range [a])] (defn b[string] (= (read-line) b) (println [b]))))...
2019/09/03
[ "https://Stackoverflow.com/questions/57771019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5237648/" ]
Similar to the Python flow. ``` (doseq [_ (range (Integer. (read-line))) :let [b (read-line)]] (println b)) ``` Even closer to Python code: ``` (let [a (Integer. (read-line))] (doseq [i (range a) :let [b (read-line)]] (println b))) ``` More functional Code ``` (mapv println (repeatedly ...
or this... ```clj (repeatedly (read-string (read-line)) (comp println read-line)) ```
36,267,936
Given a 2-dimensional array in python, I would like to normalize each row with the following norms: * Norm 1: **L\_1** * Norm 2: **L\_2** * Norm Inf: **L\_Inf** I have started this code: ``` from numpy import linalg as LA X = np.array([[1, 2, 3, 6], [4, 5, 6, 5], [1, 2, 5, 5], ...
2016/03/28
[ "https://Stackoverflow.com/questions/36267936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4208169/" ]
This is the L₁ norm: ``` >>> np.abs(X).sum(axis=1) array([12, 20, 13, 44, 42]) ``` This is the L₂ norm: ``` >>> np.sqrt((X * X).sum(axis=1)) array([ 7.07106781, 10.09950494, 7.41619849, 27.67670501, 27.45906044]) ``` This is the L∞ norm: ``` >>> np.abs(X).max(axis=1) array([ 6, 6, 5, 25, 25]) ``` To no...
You can pass `axis=1` parameter: ``` In [58]: LA.norm(X, axis=1, ord=1) Out[58]: array([12, 20, 13, 44, 42]) In [59]: LA.norm(X, axis=1, ord=2) Out[59]: array([ 7.07106781, 10.09950494, 7.41619849, 27.67670501, 27.45906044]) ```
28,975,468
When I run ipython notebook; I get "ImportError: IPython.html requires pyzmq >= 13" error message in console. I already run " pip install "ipython[notebook]" " but I can not run the notebook. Could you pls assist how to solve this issue. ``` C:\Python27\Scripts>ipython notebook Traceback (most recent call last): File ...
2015/03/10
[ "https://Stackoverflow.com/questions/28975468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2993130/" ]
Looks like you need the pyzmq package (version >= 13). You can try installing it (or upgrading if need be) with : `pip install --upgrade pyzmq`
These works for me ( win8 + anaconda 2.7.10 ) * Uninstall zmq 4.0.4. * Install zmq 3.2.4. * pip uninstall ipython * pip install "ipython[all]" * pip uninstall pyzmq * pip install pyzmq
37,888,923
I have a datafile like this: ``` # coating file for detector A/R # column 1 is the angle of incidence (degrees) # column 2 is the wavelength (microns) # column 3 is the transmission probability # column 4 is the reflection probability 14.2000 0.531000 0.0618000 0.938200 14.2000 0.532000 0...
2016/06/17
[ "https://Stackoverflow.com/questions/37888923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5200329/" ]
`inline-block` by default is `vertical-aligne`d `baseline`, and you are setting it to `middle` the first but you need to set it to `top` ```css .logo-letter-text { width: 1em; text-align: center; font-family: "Bebas Kai"; font-weight: 400; color: rgba(246, 244, 229, 1.0); } .nav-menu { position: re...
Instead of using `.nav-menu ul li {display: inline-block}` Use `.nav-menu ul li {float: left;}` See fiddle <https://jsfiddle.net/4uggcyro/4/> Or another solution would be to use `display: flex;` ``` .nav-menu ul { display: flex; flex-direction: row; } ``` See fiddle <https://jsfiddle.net/4uggcyro/6/>
12,405,322
I have written a code for parallel programming in python.I am using pp module for this. job\_server = pp.Server(ncpus, ppservers=ppservers) where ncpus=8 which is no. of core in my system. python version:2.6.5. pp version:1.6.2. But I am facing an error as follows, ``` Traceback (most recent call last): File "/ho...
2012/09/13
[ "https://Stackoverflow.com/questions/12405322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1372331/" ]
The theme is not used as part of the FPC uri and therefore there is only one cache per package. I wrote a little extension to fix the issue and you can grab it on Github. <https://github.com/benjy14/MobileFpcFix>
I have a feeling that the design exceptions support in Enterprise/PageCache work at the *package* level and not the *theme* level. Take a look at the code referencing design exceptions in app/code/core/Enterprise/PageCache/Model/Observer.php. My first suggestion would be to contact EE support, perhaps they can provide ...
12,405,322
I have written a code for parallel programming in python.I am using pp module for this. job\_server = pp.Server(ncpus, ppservers=ppservers) where ncpus=8 which is no. of core in my system. python version:2.6.5. pp version:1.6.2. But I am facing an error as follows, ``` Traceback (most recent call last): File "/ho...
2012/09/13
[ "https://Stackoverflow.com/questions/12405322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1372331/" ]
The theme is not used as part of the FPC uri and therefore there is only one cache per package. I wrote a little extension to fix the issue and you can grab it on Github. <https://github.com/benjy14/MobileFpcFix>
A simple solution that does not require any patching of code: Add an exception with the same regex-expression as you have in the themes-section into the package section and link it to the exact same package name as the "Current Package Name" is set to. **Prereqs:** Only one exception per section on the theme leve...
66,209,089
The problem: ------------ I have a column with a list of redundant values, which I need to be converted into a dictionary-like format in a new column of a PySpark dataframe. The scenario: Here's my PySpark dataframe: | A | C | all\_classes | | --- | --- | --- | | 10 | RDK | [1, 1, 1, 2, 2] | | 10 | USW | [1, 2, 2, ...
2021/02/15
[ "https://Stackoverflow.com/questions/66209089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8046443/" ]
Just introduce extra variables: ``` int main() { int a, b; std::cin >> a >> b; const int sum = a + b; const int diff = a - b; std::cout << sum << std::endl; std::cout << diff; } ``` or use computation when needed: ``` int main() { int a, b; std::cin >> a >> b; std::cout << a + b...
If you want to have: ``` a = a + b b = a - b ``` in the end and not to use any other variable you can also do it like: ``` #include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; a = a + b; b = a - ( 2 * b); cout<<a<<endl; cout<<b; } ``` but please note that it is not a good practice to use `usi...
66,209,089
The problem: ------------ I have a column with a list of redundant values, which I need to be converted into a dictionary-like format in a new column of a PySpark dataframe. The scenario: Here's my PySpark dataframe: | A | C | all\_classes | | --- | --- | --- | | 10 | RDK | [1, 1, 1, 2, 2] | | 10 | USW | [1, 2, 2, ...
2021/02/15
[ "https://Stackoverflow.com/questions/66209089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8046443/" ]
Just introduce extra variables: ``` int main() { int a, b; std::cin >> a >> b; const int sum = a + b; const int diff = a - b; std::cout << sum << std::endl; std::cout << diff; } ``` or use computation when needed: ``` int main() { int a, b; std::cin >> a >> b; std::cout << a + b...
For starters if you are going just to output values of the expressions `a + b` and `a - b` then it is enough to write one statement as for example ``` std::cout << "a + b = " << a + b << ", a - b = " << a - b << '\n'; ``` If you indeed need to assign new values to the variables `a` and `b` then you can use for examp...
66,209,089
The problem: ------------ I have a column with a list of redundant values, which I need to be converted into a dictionary-like format in a new column of a PySpark dataframe. The scenario: Here's my PySpark dataframe: | A | C | all\_classes | | --- | --- | --- | | 10 | RDK | [1, 1, 1, 2, 2] | | 10 | USW | [1, 2, 2, ...
2021/02/15
[ "https://Stackoverflow.com/questions/66209089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8046443/" ]
For starters if you are going just to output values of the expressions `a + b` and `a - b` then it is enough to write one statement as for example ``` std::cout << "a + b = " << a + b << ", a - b = " << a - b << '\n'; ``` If you indeed need to assign new values to the variables `a` and `b` then you can use for examp...
If you want to have: ``` a = a + b b = a - b ``` in the end and not to use any other variable you can also do it like: ``` #include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; a = a + b; b = a - ( 2 * b); cout<<a<<endl; cout<<b; } ``` but please note that it is not a good practice to use `usi...
70,134,739
I'm new to python and would appreciate any help i can I'm looking at this code : ``` if left[0] < right[0]: result.append(left[0]) left = left[1:] elif left[0] > right[0]: result.append(right[0]) right = right[1:] max_iter -= 1 ``` it doesn't make se...
2021/11/27
[ "https://Stackoverflow.com/questions/70134739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17303354/" ]
The `%y` code matches a two-digit year - for a four-digit year, you should use `%Y` instead. ``` date = datetime.strptime('2021-11-27 00:00', '%Y-%m-%d %H:%M') ```
as per the [documentation](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior), `%y` is > > Year without century as a zero-padded decimal number. > > > and `%Y` is > > Year with century as a decimal number. > > > so ``` from datetime import datetime date = datetime.strptime('2021-11...
70,134,739
I'm new to python and would appreciate any help i can I'm looking at this code : ``` if left[0] < right[0]: result.append(left[0]) left = left[1:] elif left[0] > right[0]: result.append(right[0]) right = right[1:] max_iter -= 1 ``` it doesn't make se...
2021/11/27
[ "https://Stackoverflow.com/questions/70134739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17303354/" ]
The `%y` code matches a two-digit year - for a four-digit year, you should use `%Y` instead. ``` date = datetime.strptime('2021-11-27 00:00', '%Y-%m-%d %H:%M') ```
I'm not familiar with python too much but [this documentation says](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) `%y` is for year **without** century but `%Y` is for year **with** century: | Directive | Meaning | | --- | --- | | %y | Year without century as a zero-padded decimal ...
60,610,009
I tried to do a choice menu, each menu make different things, for example if you choice the number 1, will work good, but if you try to choose 2 or other number, first will try to run 1, and I don't want this. Is there a way to become "independent" for each option? Example (this will work): ``` choice = input (""" ...
2020/03/10
[ "https://Stackoverflow.com/questions/60610009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13025132/" ]
Python lacks a switch/case statement (like C/C++) in which you CAN have it perform multiple (adjacent) case conditions, and then have it `break` before processing further cases. In Python you'll need to simulate using if-elif-else statements, perhaps utilizing comparison operators (like `==`, `<`) and/or boolean operat...
Good news for you, if you are still interested in using the switch case in Python. you can now use `match` with Python 3.10 like this: ```py match n: case 0: print("You typed zero.\n") case "1": print("thing 1") case "2": print("thing 2") case "3...
40,332,032
I'm thinking about writing a desktop application that the GUI is made with either HTML or PHP, but the functions are run by a separate Java or python code, is there any heads up that I can look into?
2016/10/30
[ "https://Stackoverflow.com/questions/40332032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5517067/" ]
There are a couple of possible options: 1. Run your backend code as an embedded HTTP-server (like Jetty\* for Java or Tornado\* for Python). If the user starts the application, the backend runs the server and automatically starts the web browser with the URL of your server. This, however, may cause problems with the o...
You could expose data from Java or Python as JSON via GET request and use PHP to access it. There are multiple libraries for each of these languages both for writing and reading JSON. GET request can take parameters if needed.
12,311,348
I am trying to implement a class in which an attempt to access any attributes that do not exist in the current class or any of its ancestors will attempt to access those attributes from a member. Below is a trivial version of what I am trying to do. ``` class Foo: def __init__(self, value): self._value = v...
2012/09/07
[ "https://Stackoverflow.com/questions/12311348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/652722/" ]
If I understand you correctly, what you are doing is correct, but it still won't work for what you're trying to use it for. The reason is that implicit magic-method lookup does not use `__getattr__` (or `__getattribute__` or any other such thing). The methods have to actually explicitly be there with their magic names....
`__*__` methods will not work unless they actually exist - so neither `__getattr__` nor `__getattribute__` will allow you to proxy those calls. You must create every single methods manually. Yes, this does involve quite a bit of copy&paste. And yes, it's perfectly fine in this case. You might be able to use the [werk...
3,905,179
I'm struggling with setting my scons environment variables for visual studio 2008. Normally I do following: ``` %VS90COMNTOOLS%vsvars32.bat or call %VS90COMNTOOLS%vsvars32.bat ``` And this works in my shell. I try to do that in python using subprocess ``` subprocess.call([os.environ['VS90COMNTOOLS']+r"\vsvar...
2010/10/11
[ "https://Stackoverflow.com/questions/3905179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/112496/" ]
Write a batch file that runs `vsvars32.bat` and then outputs the values in the form `VARNAME=value`, then have your Python script parse the values and inject them into `os.environ`. This is done in python's own distutils module, [see the source here](http://hg.python.org/distutils2/file/0291648eb2b2/distutils2/compile...
In addition to the previous answer. An excerpt of my SConstruct: ``` for key in ['INCLUDE','LIB']: if os.environ.has_key(key): env.Prepend(ENV = {key.upper():os.environ[key]}) ``` Please take care that variable names in Python are case-sensitive. Ensure that your `env['ENV']` dict has no duplicate variab...
3,905,179
I'm struggling with setting my scons environment variables for visual studio 2008. Normally I do following: ``` %VS90COMNTOOLS%vsvars32.bat or call %VS90COMNTOOLS%vsvars32.bat ``` And this works in my shell. I try to do that in python using subprocess ``` subprocess.call([os.environ['VS90COMNTOOLS']+r"\vsvar...
2010/10/11
[ "https://Stackoverflow.com/questions/3905179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/112496/" ]
Write a batch file that runs `vsvars32.bat` and then outputs the values in the form `VARNAME=value`, then have your Python script parse the values and inject them into `os.environ`. This is done in python's own distutils module, [see the source here](http://hg.python.org/distutils2/file/0291648eb2b2/distutils2/compile...
A short code (Python 3) addition to the accepted answer: ```py def vs_env_dict(): vsvar32 = '{vscomntools}vsvars32.bat'.format(vscomntools=os.environ['VS140COMNTOOLS']) cmd = [vsvar32, '&&', 'set'] popen = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = popen....
24,024,920
I have a python script which runs a fabfile. My issue is that I am asked for a password whenever I run the fabfile from my script. However, the login works fine with the specified key when I run the fabfile manually from the command line even though I am using the same fab parameters. Here is the contents of my fabfile...
2014/06/03
[ "https://Stackoverflow.com/questions/24024920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3507094/" ]
You can use [ssh-agent](http://www.openbsd.org/cgi-bin/man.cgi?query=ssh-agent&sektion=1): ``` $ eval `ssh-agent -s` $ ssh-add /home/myhome/scripts/bakery/id_rsa $ fab -H 10.10.15.185 deploy ```
I was being asked for a password even though I had specified a key because there was an extra space between the "u" and "ec2-user". Here is the snippet before: ``` '-u ec2-user' ``` And here it is after: ``` '-uec2-user' ``` The extra space meant that fab was trying to authenticate with " ec2-user" instead of "ec...
70,386,636
I'm trying to load a large CSV file into Pandas, which I'm new to. The input file should have 13 columns. Howeever, Pandas is reading all of the column headings as one heading, and then just collecting the first few columns of data. The code I am using is;- leases=pd.read\_csv("/content/LEASES\_FULL\_2021\_12.csv", ...
2021/12/16
[ "https://Stackoverflow.com/questions/70386636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16950273/" ]
The problem is that through type erasure, the compiler will produce the method below for your generic method. ``` public static JsonNode of(String key, Object value) { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode root = objectMapper.createObjectNode(); root.put(key, value); //...
There is another approach that works for any json object: ``` Map<String, Object> map = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {}); ``` The object in the value can be any value object (`String`, `Integer`, etc), another `Map<String, Object>` as a nested object or a `List<Objec...
70,386,636
I'm trying to load a large CSV file into Pandas, which I'm new to. The input file should have 13 columns. Howeever, Pandas is reading all of the column headings as one heading, and then just collecting the first few columns of data. The code I am using is;- leases=pd.read\_csv("/content/LEASES\_FULL\_2021\_12.csv", ...
2021/12/16
[ "https://Stackoverflow.com/questions/70386636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16950273/" ]
If you look at the signature of the *ObjectNode#put* method you will see that ``` public JsonNode put(String fieldName, JsonNode value) ``` the second argument is actually bound to a specific type and it is `JsonNode` , not just any `T` (much like your method allows). So, because of the type erasure - the compiler ...
The problem is that through type erasure, the compiler will produce the method below for your generic method. ``` public static JsonNode of(String key, Object value) { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode root = objectMapper.createObjectNode(); root.put(key, value); //...
70,386,636
I'm trying to load a large CSV file into Pandas, which I'm new to. The input file should have 13 columns. Howeever, Pandas is reading all of the column headings as one heading, and then just collecting the first few columns of data. The code I am using is;- leases=pd.read\_csv("/content/LEASES\_FULL\_2021\_12.csv", ...
2021/12/16
[ "https://Stackoverflow.com/questions/70386636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16950273/" ]
If you look at the signature of the *ObjectNode#put* method you will see that ``` public JsonNode put(String fieldName, JsonNode value) ``` the second argument is actually bound to a specific type and it is `JsonNode` , not just any `T` (much like your method allows). So, because of the type erasure - the compiler ...
There is another approach that works for any json object: ``` Map<String, Object> map = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {}); ``` The object in the value can be any value object (`String`, `Integer`, etc), another `Map<String, Object>` as a nested object or a `List<Objec...
6,866,802
Im fairly proficient in php and am also learning python. I have been wanting to create a basic game for some time now and would like to create it in python. But in order to have a fancy smooth interface I need to use javascript (i dont much care for the flash/silverlight route). So I decided to start looking up game de...
2011/07/28
[ "https://Stackoverflow.com/questions/6866802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519990/" ]
I found that splitting the collection view item view into its own XIB and then rewiring the connections so that the collection view item prototype loads the new XIB will allow for you to create the bindings in interface builder without it crashing. I followed these steps... 1. Delete the collection view item view from...
Yup, I can confirm this bug too, even on Interface Builder 3. The only workaround is to do the binding programmatically: ``` [textField bind:@"value" toObject:collectionViewItem withKeyPath:@"representedObject.foo" options:nil]; ```
6,866,802
Im fairly proficient in php and am also learning python. I have been wanting to create a basic game for some time now and would like to create it in python. But in order to have a fancy smooth interface I need to use javascript (i dont much care for the flash/silverlight route). So I decided to start looking up game de...
2011/07/28
[ "https://Stackoverflow.com/questions/6866802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519990/" ]
I've found a temporary work around: Select the "Collection View Item" and under the "Attributes Inspector" → "View Controller" settings, set "Nib Name" to "MainMenu". Once you've done this, it won't crash, and you can set the bindings. Be sure to clear the "Nib Name" setting when building your app.
Yup, I can confirm this bug too, even on Interface Builder 3. The only workaround is to do the binding programmatically: ``` [textField bind:@"value" toObject:collectionViewItem withKeyPath:@"representedObject.foo" options:nil]; ```
6,866,802
Im fairly proficient in php and am also learning python. I have been wanting to create a basic game for some time now and would like to create it in python. But in order to have a fancy smooth interface I need to use javascript (i dont much care for the flash/silverlight route). So I decided to start looking up game de...
2011/07/28
[ "https://Stackoverflow.com/questions/6866802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519990/" ]
I found that splitting the collection view item view into its own XIB and then rewiring the connections so that the collection view item prototype loads the new XIB will allow for you to create the bindings in interface builder without it crashing. I followed these steps... 1. Delete the collection view item view from...
I've found a temporary work around: Select the "Collection View Item" and under the "Attributes Inspector" → "View Controller" settings, set "Nib Name" to "MainMenu". Once you've done this, it won't crash, and you can set the bindings. Be sure to clear the "Nib Name" setting when building your app.
63,345,527
I am trying to build a Docker application that uses Python's gensim library, version 3.8.3, which is being installed via pip from a requirements.txt file. However, Docker seems to have trouble while trying to do RUN pip install -r requirements.txt My Requirement.txt for reference - ``` boto==2.49.0 boto3==1.14.33 bo...
2020/08/10
[ "https://Stackoverflow.com/questions/63345527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12138506/" ]
in the post you mension, thye install `libc-dev` to compile packs ... you dont. ``` RUN apt-get -y install libc-dev RUN apt-get -y install build-essential ``` I have problems trying to use "alpine" with Python... so we choose ["slim-buster"](https://hub.docker.com/_/python) as docker image for Python. so if you ...
To install `numpy` on an alpine image, you typically need a few more dependencies: ``` RUN apk update && apk add gfortran build-base openblas-dev libffi-dev ``` Namely the openblas-dev, which you are missing. That will at least get `numpy` to install
54,299,203
I've looked around and haven't found anything just yet. I'm going through emails in an inbox and checking for a specific word set. It works on most emails but some of them don't parse. I checked the broken emails using. ``` print (msg.Body.encode('utf8')) ``` and my problem messages all start with **b'**. like thi...
2019/01/21
[ "https://Stackoverflow.com/questions/54299203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6054714/" ]
Is the dropdown populated on the server or after an ajax call? It might be that you've tried to select a value before any are available as it's still waiting on for a response to provide data. You could wait until that response is received and then select the first option from that data set. You could reference thi...
if you used jquery ajax you should do this ```js $(document).on("click", 'button', function() { $(".modal-body").load(YOURURL, function() { $("#MyDropDown").prop('selectedIndex', 1); }); $("#myModal").modal(); }); ```
15,995,987
In python, I have this list containing ``` ['HELLO', 'WORLD'] ``` how do I turn that list into ``` ['OLLEH', 'DLROW'] ```
2013/04/14
[ "https://Stackoverflow.com/questions/15995987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2278906/" ]
``` >>> words = ['HELLO', 'WORLD'] >>> [word[::-1] for word in words] ['OLLEH', 'DLROW'] ```
Using a list comprehension: ``` reversed_list = [x[::-1] for x in old_list] ```
15,995,987
In python, I have this list containing ``` ['HELLO', 'WORLD'] ``` how do I turn that list into ``` ['OLLEH', 'DLROW'] ```
2013/04/14
[ "https://Stackoverflow.com/questions/15995987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2278906/" ]
``` >>> words = ['HELLO', 'WORLD'] >>> [word[::-1] for word in words] ['OLLEH', 'DLROW'] ```
Using `map` and `lambda`(lambdas are slow): ``` >>> lis=['HELLO', 'WORLD'] >>> map(lambda x:x[::-1],lis) ['OLLEH', 'DLROW'] ```
15,995,987
In python, I have this list containing ``` ['HELLO', 'WORLD'] ``` how do I turn that list into ``` ['OLLEH', 'DLROW'] ```
2013/04/14
[ "https://Stackoverflow.com/questions/15995987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2278906/" ]
``` >>> words = ['HELLO', 'WORLD'] >>> [word[::-1] for word in words] ['OLLEH', 'DLROW'] ```
Arguably using the builtin `reversed` is more clear than slice notation `x[::-1]`. ``` [reversed(word) for word in words] ``` or ``` map(reversed, words) ``` Map is fast without the lambda. I just wish it was easier to get the string out of the resulting iterator. Is there anything better than `''.join()` to pu...
15,995,987
In python, I have this list containing ``` ['HELLO', 'WORLD'] ``` how do I turn that list into ``` ['OLLEH', 'DLROW'] ```
2013/04/14
[ "https://Stackoverflow.com/questions/15995987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2278906/" ]
Using a list comprehension: ``` reversed_list = [x[::-1] for x in old_list] ```
Using `map` and `lambda`(lambdas are slow): ``` >>> lis=['HELLO', 'WORLD'] >>> map(lambda x:x[::-1],lis) ['OLLEH', 'DLROW'] ```
15,995,987
In python, I have this list containing ``` ['HELLO', 'WORLD'] ``` how do I turn that list into ``` ['OLLEH', 'DLROW'] ```
2013/04/14
[ "https://Stackoverflow.com/questions/15995987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2278906/" ]
Using a list comprehension: ``` reversed_list = [x[::-1] for x in old_list] ```
Arguably using the builtin `reversed` is more clear than slice notation `x[::-1]`. ``` [reversed(word) for word in words] ``` or ``` map(reversed, words) ``` Map is fast without the lambda. I just wish it was easier to get the string out of the resulting iterator. Is there anything better than `''.join()` to pu...
15,995,987
In python, I have this list containing ``` ['HELLO', 'WORLD'] ``` how do I turn that list into ``` ['OLLEH', 'DLROW'] ```
2013/04/14
[ "https://Stackoverflow.com/questions/15995987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2278906/" ]
Arguably using the builtin `reversed` is more clear than slice notation `x[::-1]`. ``` [reversed(word) for word in words] ``` or ``` map(reversed, words) ``` Map is fast without the lambda. I just wish it was easier to get the string out of the resulting iterator. Is there anything better than `''.join()` to pu...
Using `map` and `lambda`(lambdas are slow): ``` >>> lis=['HELLO', 'WORLD'] >>> map(lambda x:x[::-1],lis) ['OLLEH', 'DLROW'] ```
16,560,497
I am new at Python so this may seem to be very easy. I am trying to remove all **#**, numbers and if the same letter is repeated more then two times in a row, I need to change it to only two letters. This work perfectly but not with ØÆÅ. *Any ideas how this can be done with ØÆÅ letters?* ``` #!/usr/bin/python # -*- ...
2013/05/15
[ "https://Stackoverflow.com/questions/16560497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/871742/" ]
You need to work with Unicode values, not with byte strings. UTF-8 encoded `å` is *two* bytes, and a regular expression matching `\w` *only* matches ascii letters, digits and underscores when operating in the default non-Unicode-aware mode. From the [`re` module documentation](http://docs.python.org/2/library/re.html)...
Change: ``` text = u"ån9d ånd åååååååånd d9d flllllløde... :)asd " ``` and ``` text = re.sub(r'(\w)\1+', r'\1\1', text) ``` **COMPELTE SOLUTION** ``` import math, re, sys, os, codecs reload(sys) sys.setdefaultencoding('utf-8') text = u"ån9d ånd åååååååånd d9d flllllløde... :)asd " # Remove anything other than ...
40,664,786
I'm a beginner using python, and am writing a "guess my number game". So far I have everything working fine. The computer picks a random number between 1 and 3 and asks the player to guess the number. If the guess is higher than the random number, the program prints "Lower", and vice versa. The player only has 5 tries,...
2016/11/17
[ "https://Stackoverflow.com/questions/40664786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6912990/" ]
To answer your original question about the lack of congratulatory message for correct number, end the code with input(), to ensure it does not terminate before displaying the last message. Order of calculation: 1. give input guess 2. reduce guesses (starting at 5), increase tries (starting at 1) 3. immediate break if...
Assuming everything else works, un-indent the final check. You can't check `guess == the_number` while it isn't equal ``` #guessing loop while guess != the_number: # do logic # outside guessing loop if guesses > 0: print("You guessed it! The number was", the_number) print("And it only took you", tries, "t...
40,664,786
I'm a beginner using python, and am writing a "guess my number game". So far I have everything working fine. The computer picks a random number between 1 and 3 and asks the player to guess the number. If the guess is higher than the random number, the program prints "Lower", and vice versa. The player only has 5 tries,...
2016/11/17
[ "https://Stackoverflow.com/questions/40664786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6912990/" ]
To answer your original question about the lack of congratulatory message for correct number, end the code with input(), to ensure it does not terminate before displaying the last message. Order of calculation: 1. give input guess 2. reduce guesses (starting at 5), increase tries (starting at 1) 3. immediate break if...
If you guess the number in your first try, the program will require another guess nevertheless since ``` guess = int(input("Take a guess: ")) tries += 1 guesses -= 1 ``` comes before ``` if guess == the_number: print("You guessed it! The number was", the_number) print("And it only took you", tries, "tries!\...
11,055,921
I am using mongoexport to export mongodb data which also has Image data in Binary format. Export is done in csv format. I tried to read image data from csv file into python and tried to store as in Image File in .jpg format on disk. But it seems that, data is corrupt and image is not getting stored. Has anybody com...
2012/06/15
[ "https://Stackoverflow.com/questions/11055921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459413/" ]
One thing to watch out for is an arbitrary 2MB BSON Object size limit in several of 10gen's implementations. You might have to denormalize your image data and store it across multiple objects.
Depending how you stored the data, it may be prefixed with 4 bytes of size. Are the corrupt exports 4 bytes/GridFS chunk longer than you'd expect?
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
Vim 8 ( and a number of Vim emulations ) I'd start with ``` <h1>This is h0</h1> <h2>This is h0</h2> <h3>This is h0</h3> <h4>This is h0</h4> <h5>This is h0</h5> <h6>This is h0</h6> ``` then on the top 0 of h0. I'd block highlight with `CTRL-V` go down to the bottom 0 of the h6 tag with `5j` then type `g` and then ...
With my [UnconditionalPaste plugin](http://www.vim.org/scripts/script.php?script_id=3355), you just need to yank the first `<h1>This is h1</h1>` line, and then paste 5 times with `5gPp`, which pastes with all decimal numbers incremented by 1. This also is repeatable via `.`, so you could have also pasted just once and ...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
Vim 8 ( and a number of Vim emulations ) I'd start with ``` <h1>This is h0</h1> <h2>This is h0</h2> <h3>This is h0</h3> <h4>This is h0</h4> <h5>This is h0</h5> <h6>This is h0</h6> ``` then on the top 0 of h0. I'd block highlight with `CTRL-V` go down to the bottom 0 of the h6 tag with `5j` then type `g` and then ...
I would do this ``` :for i in range(1,6) | put='<h'.i'.'>This is h'.i.'</h'.i.'>' | endfor :1d ``` We are concatening string with the variable 'i'. Tha's why we are using the dot on the put statement More explanation - If you want simple to put a string on the first line: ``` :0put='my string' ``` A second w...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
Vim 8 ( and a number of Vim emulations ) I'd start with ``` <h1>This is h0</h1> <h2>This is h0</h2> <h3>This is h0</h3> <h4>This is h0</h4> <h5>This is h0</h5> <h6>This is h0</h6> ``` then on the top 0 of h0. I'd block highlight with `CTRL-V` go down to the bottom 0 of the h6 tag with `5j` then type `g` and then ...
Normally I'll use macro to generate numbers in order. In this case, I'll write `<h1>This is h1</h1>` first. 1. `qq`, (first `q` is to start recording your keystroke and store it as a macro in key `q`) 2. `yyp`, to duplicate the line (`yy` to copy current line, `p` to paste) 3. `ctrl-a`, to increase first occurred num...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
Vim 8 ( and a number of Vim emulations ) I'd start with ``` <h1>This is h0</h1> <h2>This is h0</h2> <h3>This is h0</h3> <h4>This is h0</h4> <h5>This is h0</h5> <h6>This is h0</h6> ``` then on the top 0 of h0. I'd block highlight with `CTRL-V` go down to the bottom 0 of the h6 tag with `5j` then type `g` and then ...
Will it be okay to copy the `h1, h2, ...` column and paste? Use `Ctrl` + `v` and select `h1` and then `5j`. This will block select next 5 line, Change number accordingly. Copy the selected lines using y. Now, nagivate to `h` where you want to past and repeat `Ctrl` + `v` and `5j`, Thereafter finish the paste with `...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
I would do this ``` :for i in range(1,6) | put='<h'.i'.'>This is h'.i.'</h'.i.'>' | endfor :1d ``` We are concatening string with the variable 'i'. Tha's why we are using the dot on the put statement More explanation - If you want simple to put a string on the first line: ``` :0put='my string' ``` A second w...
With my [UnconditionalPaste plugin](http://www.vim.org/scripts/script.php?script_id=3355), you just need to yank the first `<h1>This is h1</h1>` line, and then paste 5 times with `5gPp`, which pastes with all decimal numbers incremented by 1. This also is repeatable via `.`, so you could have also pasted just once and ...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
With my [UnconditionalPaste plugin](http://www.vim.org/scripts/script.php?script_id=3355), you just need to yank the first `<h1>This is h1</h1>` line, and then paste 5 times with `5gPp`, which pastes with all decimal numbers incremented by 1. This also is repeatable via `.`, so you could have also pasted just once and ...
Normally I'll use macro to generate numbers in order. In this case, I'll write `<h1>This is h1</h1>` first. 1. `qq`, (first `q` is to start recording your keystroke and store it as a macro in key `q`) 2. `yyp`, to duplicate the line (`yy` to copy current line, `p` to paste) 3. `ctrl-a`, to increase first occurred num...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
With my [UnconditionalPaste plugin](http://www.vim.org/scripts/script.php?script_id=3355), you just need to yank the first `<h1>This is h1</h1>` line, and then paste 5 times with `5gPp`, which pastes with all decimal numbers incremented by 1. This also is repeatable via `.`, so you could have also pasted just once and ...
Will it be okay to copy the `h1, h2, ...` column and paste? Use `Ctrl` + `v` and select `h1` and then `5j`. This will block select next 5 line, Change number accordingly. Copy the selected lines using y. Now, nagivate to `h` where you want to past and repeat `Ctrl` + `v` and `5j`, Thereafter finish the paste with `...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
I would do this ``` :for i in range(1,6) | put='<h'.i'.'>This is h'.i.'</h'.i.'>' | endfor :1d ``` We are concatening string with the variable 'i'. Tha's why we are using the dot on the put statement More explanation - If you want simple to put a string on the first line: ``` :0put='my string' ``` A second w...
Normally I'll use macro to generate numbers in order. In this case, I'll write `<h1>This is h1</h1>` first. 1. `qq`, (first `q` is to start recording your keystroke and store it as a macro in key `q`) 2. `yyp`, to duplicate the line (`yy` to copy current line, `p` to paste) 3. `ctrl-a`, to increase first occurred num...
58,851,954
Im trying to do the obeythetestinggoat tutorial and cant set my geckodriver, Im working in Win10 64bits my pip freeze shows: Django==1.7,selenium==3.141.0,urllib3==1.25.7 i download the geckodriver (geckodriver-v0.26.0-win64) when i try to get the geckodriver version (via `$geckodriver --version`) stops and show me...
2019/11/14
[ "https://Stackoverflow.com/questions/58851954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7663963/" ]
I would do this ``` :for i in range(1,6) | put='<h'.i'.'>This is h'.i.'</h'.i.'>' | endfor :1d ``` We are concatening string with the variable 'i'. Tha's why we are using the dot on the put statement More explanation - If you want simple to put a string on the first line: ``` :0put='my string' ``` A second w...
Will it be okay to copy the `h1, h2, ...` column and paste? Use `Ctrl` + `v` and select `h1` and then `5j`. This will block select next 5 line, Change number accordingly. Copy the selected lines using y. Now, nagivate to `h` where you want to past and repeat `Ctrl` + `v` and `5j`, Thereafter finish the paste with `...
82,607
I get DNS records from a Python program, using [DNS Python](http://www.dnspython.org/) I can get various DNSSEC-related records: ``` >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0...
2008/09/17
[ "https://Stackoverflow.com/questions/82607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
You probably mean RRSIG ANY (otherwise, the order is wrong, the class needs to be after the type) ``` >>> print myresolver.query('sources.org', 'RRSIG', 'ANY') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/dns/resolver.py", line 664, in query answ...
If you try this, what happens? ``` print myresolver.query('sources.org', 'ANY', 'RRSIG') ```
82,607
I get DNS records from a Python program, using [DNS Python](http://www.dnspython.org/) I can get various DNSSEC-related records: ``` >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0...
2008/09/17
[ "https://Stackoverflow.com/questions/82607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
RRSIG is not a record, it's a hashed digest of a valid DNS Record. You can query a DNSKEY record, set want\_dnssec=True and get a DNSKEY Record, and an "RRSIG of a DNSKEY Record". More generally, RRSIG is just a signature of a valid record (such as a DS Record). So when you ask the server ``` myresolver.query('sour...
If you try this, what happens? ``` print myresolver.query('sources.org', 'ANY', 'RRSIG') ```
82,607
I get DNS records from a Python program, using [DNS Python](http://www.dnspython.org/) I can get various DNSSEC-related records: ``` >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0...
2008/09/17
[ "https://Stackoverflow.com/questions/82607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
You probably mean RRSIG ANY (otherwise, the order is wrong, the class needs to be after the type) ``` >>> print myresolver.query('sources.org', 'RRSIG', 'ANY') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/dns/resolver.py", line 664, in query answ...
This looks like a probable bug in the Python DNS library, although I don't read Python well enough to find it. Note that in any case your EDNS0 buffer size parameter is not large enough to handle the RRSIG records for sources.org, so your client and server would have to fail over to TCP/IP.
82,607
I get DNS records from a Python program, using [DNS Python](http://www.dnspython.org/) I can get various DNSSEC-related records: ``` >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0...
2008/09/17
[ "https://Stackoverflow.com/questions/82607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
You probably mean RRSIG ANY (otherwise, the order is wrong, the class needs to be after the type) ``` >>> print myresolver.query('sources.org', 'RRSIG', 'ANY') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/dns/resolver.py", line 664, in query answ...
You may want to use `raise_on_no_answer=False` and you will get the correct response: ``` resolver.query(hostname, dnsrecord, raise_on_no_answer=False) ```
82,607
I get DNS records from a Python program, using [DNS Python](http://www.dnspython.org/) I can get various DNSSEC-related records: ``` >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0...
2008/09/17
[ "https://Stackoverflow.com/questions/82607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
You probably mean RRSIG ANY (otherwise, the order is wrong, the class needs to be after the type) ``` >>> print myresolver.query('sources.org', 'RRSIG', 'ANY') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/dns/resolver.py", line 664, in query answ...
RRSIG is not a record, it's a hashed digest of a valid DNS Record. You can query a DNSKEY record, set want\_dnssec=True and get a DNSKEY Record, and an "RRSIG of a DNSKEY Record". More generally, RRSIG is just a signature of a valid record (such as a DS Record). So when you ask the server ``` myresolver.query('sour...
82,607
I get DNS records from a Python program, using [DNS Python](http://www.dnspython.org/) I can get various DNSSEC-related records: ``` >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0...
2008/09/17
[ "https://Stackoverflow.com/questions/82607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
RRSIG is not a record, it's a hashed digest of a valid DNS Record. You can query a DNSKEY record, set want\_dnssec=True and get a DNSKEY Record, and an "RRSIG of a DNSKEY Record". More generally, RRSIG is just a signature of a valid record (such as a DS Record). So when you ask the server ``` myresolver.query('sour...
This looks like a probable bug in the Python DNS library, although I don't read Python well enough to find it. Note that in any case your EDNS0 buffer size parameter is not large enough to handle the RRSIG records for sources.org, so your client and server would have to fail over to TCP/IP.
82,607
I get DNS records from a Python program, using [DNS Python](http://www.dnspython.org/) I can get various DNSSEC-related records: ``` >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0...
2008/09/17
[ "https://Stackoverflow.com/questions/82607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
RRSIG is not a record, it's a hashed digest of a valid DNS Record. You can query a DNSKEY record, set want\_dnssec=True and get a DNSKEY Record, and an "RRSIG of a DNSKEY Record". More generally, RRSIG is just a signature of a valid record (such as a DS Record). So when you ask the server ``` myresolver.query('sour...
You may want to use `raise_on_no_answer=False` and you will get the correct response: ``` resolver.query(hostname, dnsrecord, raise_on_no_answer=False) ```
45,368,847
Very related to this post but I don't have the priviledge to comment there so I had to make a new post. [Deploy a simple VS2017 Django app to Azure - server error](https://stackoverflow.com/questions/43506691/deploy-a-simple-vs2017-django-app-to-azure-server-error) I followed Silencer's tutorial there and I am getting...
2017/07/28
[ "https://Stackoverflow.com/questions/45368847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335827/" ]
I had the same problem and finally it was fixed by changing this line in app config: ``` <add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_virtualenv_handler()" /> ``` to this: ``` <add key="WSGI_HANDLER" value="myProject.wsgi.application" /> ``` myProject is the name of my django project so you should put...
I get the same errors in python 3.4. For python 2.7 there is an activate\_this.py script, which can help in some way. Just put the activate\_this.py from a python 2.7 virtual environment in the .\env\Scripts folder and changed the path in web.config to point to activate\_this.py. It seems to work. I am just not sure ...
45,368,847
Very related to this post but I don't have the priviledge to comment there so I had to make a new post. [Deploy a simple VS2017 Django app to Azure - server error](https://stackoverflow.com/questions/43506691/deploy-a-simple-vs2017-django-app-to-azure-server-error) I followed Silencer's tutorial there and I am getting...
2017/07/28
[ "https://Stackoverflow.com/questions/45368847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335827/" ]
I had the same problem and finally it was fixed by changing this line in app config: ``` <add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_virtualenv_handler()" /> ``` to this: ``` <add key="WSGI_HANDLER" value="myProject.wsgi.application" /> ``` myProject is the name of my django project so you should put...
I had same problem, I was wrong in WSGI\_HANDLER, for python 3.4 must be: ``` <add key="WSGI_HANDLER" value="ptvs_virtualenv_proxy.get_venv_handler()" /> ```
31,096,631
I am currently writing a script that installs my software-under-test then automatically runs my smoke tests using py.test. If a failure occurs during any of these tests, I would like to tell my software to not publish the software to the build servers. This is basically how it goes in pseudo-code: ``` def install_buil...
2015/06/28
[ "https://Stackoverflow.com/questions/31096631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4621806/" ]
Approach #1 =========== This is I think the road you were heading down. Basically, just treat test.py as a black box process and use the exit code to determine if there were any test failures (e.g. if there is a non-zero exit code) ``` exit_code = subprocess.Popen(["py.test", "smoke_test_suite.py"]).wait() test_failu...
py.test must return a non-zero exit code if the tests fail. The simplest way to handle that would be using [`subprocess.check_call()`](https://docs.python.org/2/library/subprocess.html#subprocess.check_call): ``` try: subprocess.check_call(["py.test", "smoke_test_suite.py"]) except subprocess.CalledProcessError: ...
41,724,259
Happy new year 2017! Hello everybody! I have some issues when I try to deploy my docker image in a BlueMix container (where `cf ic run = docker run`) I can't access the container from web even if the image is running well inside. I pinged the binded adress: ``` ping 169.46.18.91 PING 169.46.18.91 (169.46.18.91):...
2017/01/18
[ "https://Stackoverflow.com/questions/41724259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7365430/" ]
Hmm - I see that you published port 3000 (the -p 3000 parameter in the run command), but the default port would be 5000. In the dockerfile, you switched that to 12345, so that's presumably what you're actually listening on there. Guessing that's the reason you want to open all ports? Docker only exposes the ports that...
Looks like Bluemix single container service is a bit touchy, it was hard to reach from web until I added a "scalable" container which asks for the required HTTP port. I think the problem was this http port wasn't exposed, but now problem is solved the way I said above.
28,478,279
Hi I have this sample path "\10.81.67.162" which is a remote server (windows OS) I want to be able to transfer files (local) to the remote server using paramiko in python. I can make it work if the server is in linux. This is my sample code ``` import paramiko import base64 username = 'username' password = 'pass...
2015/02/12
[ "https://Stackoverflow.com/questions/28478279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3728094/" ]
If you are asking about method argument and method internal variables the answer is no. These variables are allocated on stack and are different for each thread. EDIT: Issues may happen when passing shared (among several threads) not thread safe objects. For example your method `foo()` accepts parameter of type `MyC...
There shouldn't be any problems with your code since you don't manipulate the `parameters` (e.g. `adding/removing` stuff from the maps ). of course there is this assumption that those maps are not related (e.g `sharing same resources`) **AND** no where else in you program you will manipulate those objects at the same ...
54,675,259
I am answering the Euler project questions in python and I don't know how to multiply a list by itself I can get a list within the range though
2019/02/13
[ "https://Stackoverflow.com/questions/54675259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11051957/" ]
Seems like this should do it: ``` SET Row1 = CASE WHEN Row1 = 'From1' THEN 'To1' WHEN Row1 = 'From2' THEN 'To2' etc END ```
Are you simply looking for a `case` expression? ``` UPDATE TOP (@batchsize) Table1 SET Row1 = (CASE table1.Row1 WHEN 'From1' THEN 'To1' WHEN 'From2' THEN 'To2' WHEN 'From3' THEN 'To3' WHEN 'From4' THEN 'To4' ...
69,067,530
I installed several files based upon `https://pbpython.com/pdf-reports.htm to create reports. However the following error messages ``` Traceback (most recent call last): File "C:\histdata\test02.py", line 10, in <module> from weasyprint import HTML File "C:\Users\AquaTrader\AppData\Local\Programs\Python\Python...
2021/09/05
[ "https://Stackoverflow.com/questions/69067530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6090578/" ]
The error means that the `gobject-2.0.0` library, which is part of GTK3+, cannot be found. Did you follow the installation instructions (<https://doc.courtbouillon.org/weasyprint/stable/first_steps.html>), which include installation of GTK3+? If no, do that. If yes, then the problem is, that the GTK3+ DLLs are not wher...
As @mad said, you need the GTK3 library to have the `libobject-2.0.0` DLL. In Github Actions for example, you might be interested to use the [tschoonj/GTK-for-Windows](https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer) repository : ```sh # Download GTK3 resources git clone -b 2022-01-04 https:/...
16,819,938
I have a class which would be a container for a number of variables of different types. The collection is finite and not very large so I didn't use a dictionary. Is there a way to automate, or shorten the creation of variables based on whether or not they are requested (specified as True/False) in the constructor? Her...
2013/05/29
[ "https://Stackoverflow.com/questions/16819938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2433420/" ]
Maybe something like: ``` def __init__(self,*args,**kwargs): default_values = {a:{},b:34,c:"generic string"} for k,v in kwargs.iteritems(): try: if not v is False: setattr(self,k,default_values[k]) except Exception, e: print "Argument has no default valu...
You can subclass `dict` (if you aren't using positional arguments): ``` class Test(dict): def your_method(self): return self['foo'] * 4 ``` You can also override `__getattr__` and `__setattr__` if the `self['foo']` syntax bothers you: ``` class Test(dict): def __getattr__(self, key): return ...
50,271,354
Consider the following python snippet (I am running Python 3) ``` name = "Sammy" def greet(): name = 'johny' def hello(): print('hello ' + name) # gets 'name' from the enclosing 'greet' hello() greet() ``` This produces the output `hello johny` as expected However, ``` x = 50 def func1(): ...
2018/05/10
[ "https://Stackoverflow.com/questions/50271354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5157905/" ]
The error is actually caused (indirectly) by the following line, i.e. `x = 2`. Try commenting out that line and you'll see that the function works. The fact that there is an assignment to a variable named `x` makes `x` local to the function at *compile time*, however, at *execution time* the first reference to `x` fai...
In a given scope, *you can only reference a variable's name from one given scope*. Your variable cannot be global at some point and local later on or vice versa. For that reason, if `x` is ever to be declared in a scope, Python will assume that you are refering to the local variable everywhere in that scope, unless yo...
55,717,203
I wrote this small function: ``` def sets(): set1 = random.sample(range(1, 50), 10) set2 = random.sample(range(1, 50), 10) return(set1,set2) sets() ``` The output of this function looks like this: ``` ([24, 29, 43, 42, 45, 28, 26, 3, 8, 21], [22, 37, 38, 44, 25, 42, 29, 7, 35, 9]) ``` I want to plot...
2019/04/16
[ "https://Stackoverflow.com/questions/55717203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8407951/" ]
A possible solution is to output the labels instead of the set size. With the [matplotlib\_venn](https://pypi.org/project/matplotlib-venn/) package, you can do something like this: ``` import matplotlib.pyplot as plt from matplotlib_venn import venn2 import random set1 = set(random.sample(range(1, 50), 10)) set2 = se...
The default behaviour of the venn2 package is to print the size of the overlap of the two sets. Here's the line of the source code where those sizes are added to the Venn diagram plot: <https://github.com/konstantint/matplotlib-venn/blob/master/matplotlib_venn/_venn2.py#L247> To make this print the overlapping numbers...
63,416,534
I've recently tried to create a simple bot in discord with Python Code. I'm testing just the first features to DM a user when he joins the server Here is my code: ``` import os import discord from dotenv import load_dotenv load_dotenv() #load .env files TOKEN = os.getenv('DISCORD_TOKEN') GUILD = os.getenv('D...
2020/08/14
[ "https://Stackoverflow.com/questions/63416534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13461081/" ]
So You Need To Edit Your Code Sligitly Store Orginal Image To a temp for a while ``` originalBlue = image[i][j].rgbtBlue; originalRed = image[i][j].rgbtRed; originalGreen = image[i][j].rgbtGreen; ``` the result of each of these formulas may not be an integer so use float and rou...
You need to use "saturation math". For near white colors, your intermediate values (e.g. `sepiared`) can exceed 255. 255 (0xFF) is the maximum value that can fit in an `unsigned char` For example, if `sepiared` were 256 (0x100), when it gets put into `rgbtRed`, only the rightmost 8 bits will be retained and the valu...
63,416,534
I've recently tried to create a simple bot in discord with Python Code. I'm testing just the first features to DM a user when he joins the server Here is my code: ``` import os import discord from dotenv import load_dotenv load_dotenv() #load .env files TOKEN = os.getenv('DISCORD_TOKEN') GUILD = os.getenv('D...
2020/08/14
[ "https://Stackoverflow.com/questions/63416534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13461081/" ]
First, as an aside, when you have a CS50 question, please search for the keywords in StackOverflow before asking. The answer is probably there. If you search for `sepia RGBTRIPLE cs50` you get quite a few hits. After doing a lot of pixel processing, you'll hone some useful debugging intuitions. Among those: * If you ...
You need to use "saturation math". For near white colors, your intermediate values (e.g. `sepiared`) can exceed 255. 255 (0xFF) is the maximum value that can fit in an `unsigned char` For example, if `sepiared` were 256 (0x100), when it gets put into `rgbtRed`, only the rightmost 8 bits will be retained and the valu...
63,416,534
I've recently tried to create a simple bot in discord with Python Code. I'm testing just the first features to DM a user when he joins the server Here is my code: ``` import os import discord from dotenv import load_dotenv load_dotenv() #load .env files TOKEN = os.getenv('DISCORD_TOKEN') GUILD = os.getenv('D...
2020/08/14
[ "https://Stackoverflow.com/questions/63416534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13461081/" ]
You need to use "saturation math". For near white colors, your intermediate values (e.g. `sepiared`) can exceed 255. 255 (0xFF) is the maximum value that can fit in an `unsigned char` For example, if `sepiared` were 256 (0x100), when it gets put into `rgbtRed`, only the rightmost 8 bits will be retained and the valu...
For me it worked when I kept all the variables outside the loop and rounded off in the end after checking the value of each R G B less than 255.
63,416,534
I've recently tried to create a simple bot in discord with Python Code. I'm testing just the first features to DM a user when he joins the server Here is my code: ``` import os import discord from dotenv import load_dotenv load_dotenv() #load .env files TOKEN = os.getenv('DISCORD_TOKEN') GUILD = os.getenv('D...
2020/08/14
[ "https://Stackoverflow.com/questions/63416534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13461081/" ]
So You Need To Edit Your Code Sligitly Store Orginal Image To a temp for a while ``` originalBlue = image[i][j].rgbtBlue; originalRed = image[i][j].rgbtRed; originalGreen = image[i][j].rgbtGreen; ``` the result of each of these formulas may not be an integer so use float and rou...
For me it worked when I kept all the variables outside the loop and rounded off in the end after checking the value of each R G B less than 255.
63,416,534
I've recently tried to create a simple bot in discord with Python Code. I'm testing just the first features to DM a user when he joins the server Here is my code: ``` import os import discord from dotenv import load_dotenv load_dotenv() #load .env files TOKEN = os.getenv('DISCORD_TOKEN') GUILD = os.getenv('D...
2020/08/14
[ "https://Stackoverflow.com/questions/63416534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13461081/" ]
First, as an aside, when you have a CS50 question, please search for the keywords in StackOverflow before asking. The answer is probably there. If you search for `sepia RGBTRIPLE cs50` you get quite a few hits. After doing a lot of pixel processing, you'll hone some useful debugging intuitions. Among those: * If you ...
For me it worked when I kept all the variables outside the loop and rounded off in the end after checking the value of each R G B less than 255.
18,296,394
I've got a list of instances of a particular class Foo, that has a field bar: ``` foo[1..n].bar ``` I'd like to "convert" this to just a list of bar items, so that I have `bar[1..n]` Sorry for the 1..n notation - I'm just trying to indicate I have an arbitrarily long list. Be gentle - I'm new to python.
2013/08/18
[ "https://Stackoverflow.com/questions/18296394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8478/" ]
Use a list comprehension ``` bar = [ i.bar for i in foo ] ``` Also, list indices in python start from 0, so a list of N elements would have items from `0` to `n - 1`.
> > Be gentle - I'm new to python. > > > Okay. > > I've got a list of items: > > > > ``` > foo[1..n].bar > > ``` > > How in the heck is that a list? A list looks like this: ``` [1, 2, 3] ``` How does `foo[1..n].bar` fit that format? Like this? ``` foo[1, 2, 3].bar ``` That's nonsensical. > > I'd l...
41,778,173
I have been using turtle package in python idle. Now I have switched to using Jupyter notebook. How can I make turtle inline instead of opening a separate graphic screen. I am totally clueless about. Any pointers and advice will be highly appreciated.
2017/01/21
[ "https://Stackoverflow.com/questions/41778173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3668042/" ]
I found the following library that has a Turtle implementation working in Jupyter notebooks: <https://github.com/takluyver/mobilechelonian>
It seems you can get turtle module to work, if you run the Jupyter Notebook cell containing the code twice. Not sure why it works, but it does!
41,778,173
I have been using turtle package in python idle. Now I have switched to using Jupyter notebook. How can I make turtle inline instead of opening a separate graphic screen. I am totally clueless about. Any pointers and advice will be highly appreciated.
2017/01/21
[ "https://Stackoverflow.com/questions/41778173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3668042/" ]
I am a windows user, so run the CMD as an administrator and run this: ``` jupyter nbextension enable --py --sys-prefix ipyturtle ``` Run the above after installing the ipyturtle ``` pip3 install ipyturtle ```
It seems you can get turtle module to work, if you run the Jupyter Notebook cell containing the code twice. Not sure why it works, but it does!
41,778,173
I have been using turtle package in python idle. Now I have switched to using Jupyter notebook. How can I make turtle inline instead of opening a separate graphic screen. I am totally clueless about. Any pointers and advice will be highly appreciated.
2017/01/21
[ "https://Stackoverflow.com/questions/41778173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3668042/" ]
With python3.6+: ``` python -m pip install ipyturtle3 ``` Try the examples listed in this repo: <https://github.com/williamnavaraj/ipyturtle3> <https://pypi.org/project/ipyturtle3/> I found this to work in JupyterLab and VSCode
It seems you can get turtle module to work, if you run the Jupyter Notebook cell containing the code twice. Not sure why it works, but it does!
41,778,173
I have been using turtle package in python idle. Now I have switched to using Jupyter notebook. How can I make turtle inline instead of opening a separate graphic screen. I am totally clueless about. Any pointers and advice will be highly appreciated.
2017/01/21
[ "https://Stackoverflow.com/questions/41778173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3668042/" ]
I found the following library that has a Turtle implementation working in Jupyter notebooks: <https://github.com/takluyver/mobilechelonian>
I am a windows user, so run the CMD as an administrator and run this: ``` jupyter nbextension enable --py --sys-prefix ipyturtle ``` Run the above after installing the ipyturtle ``` pip3 install ipyturtle ```
41,778,173
I have been using turtle package in python idle. Now I have switched to using Jupyter notebook. How can I make turtle inline instead of opening a separate graphic screen. I am totally clueless about. Any pointers and advice will be highly appreciated.
2017/01/21
[ "https://Stackoverflow.com/questions/41778173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3668042/" ]
With python3.6+: ``` python -m pip install ipyturtle3 ``` Try the examples listed in this repo: <https://github.com/williamnavaraj/ipyturtle3> <https://pypi.org/project/ipyturtle3/> I found this to work in JupyterLab and VSCode
I am a windows user, so run the CMD as an administrator and run this: ``` jupyter nbextension enable --py --sys-prefix ipyturtle ``` Run the above after installing the ipyturtle ``` pip3 install ipyturtle ```