qid
int64
469
74.7M
question
stringlengths
36
37.8k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
5
31.5k
response_k
stringlengths
10
31.6k
2,686,520
For what I've read I need Python-Dev, how do I install it on OSX? I think the problem I have, is, my Xcode was not properly installed, and I don't have the paths where I should. This previous question: [Where is gcc on OSX? I have installed Xcode already](https://stackoverflow.com/questions/2685887/where-is-gcc-on...
2010/04/21
[ "https://Stackoverflow.com/questions/2686520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
I was struggling with this problem all day today. I eventually discovered a [site](https://web.archive.org/web/20141221052542/http://www.jaharmi.com/2011/11/12/reinstall_xcode_if_easy_install_fails_with_missing_files_like_python_h) that claimed that all one needed to do was to reinstall Xcode, or install the latest ve...
Might depend on what version of Mac OSX you have, I have it in these spots: ``` /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h /System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h ``` Also I believe the version of pyth...
2,686,520
For what I've read I need Python-Dev, how do I install it on OSX? I think the problem I have, is, my Xcode was not properly installed, and I don't have the paths where I should. This previous question: [Where is gcc on OSX? I have installed Xcode already](https://stackoverflow.com/questions/2685887/where-is-gcc-on...
2010/04/21
[ "https://Stackoverflow.com/questions/2686520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
I was struggling with this problem all day today. I eventually discovered a [site](https://web.archive.org/web/20141221052542/http://www.jaharmi.com/2011/11/12/reinstall_xcode_if_easy_install_fails_with_missing_files_like_python_h) that claimed that all one needed to do was to reinstall Xcode, or install the latest ve...
Are you sure you want to build Mercurial from source? There are [binary packages available](https://www.mercurial-scm.org/downloads), including the nice [MacHg](http://jasonfharris.com/machg/) which comes with a bundled Mercurial.
67,211,732
I'm trying to update my Heroku DB from a Python script I have on my computer. I set up my app on Heroku with NodeJS (because I just like Javascript for that sort of thing), and I'm not sure I can add in a Python script to manage everything. I was able to fill out the DB once, with the script, and it had no hangups. Whe...
2021/04/22
[ "https://Stackoverflow.com/questions/67211732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11790979/" ]
The "month" view provided by fullCalendar does not have this flexibility - it always starts at the beginning of the month, like a traditional paper calendar. IMHO it would be confusing to many users if it appeared differently. Other types of view are more flexible - they will respond to the `visibleRange` setting if y...
Change **type: 'dayGridMonth'** to **type: 'dayGrid'**
66,214,454
Ansible version: 2.8.3 or Any I'm using `-m <module>` Ansible's **ad-hoc** command to ensure the following package is installed **--OR--** let's say if I have a task to install few yum packages, like (i.e. How can I do the same within a task (possibly when ***I'm not using ansible's shell / command*** modules): ``` ...
2021/02/15
[ "https://Stackoverflow.com/questions/66214454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1499296/" ]
You should add this line to your **MouseArea** to work: ``` anchors.fill: parent ```
thanks @Farshid616 for the help. The problem was that my MouseArea wasn't inside the Rectangular. So only I needed is open code and move Mouse Area into Rectangular area, so that the MouseArea would be child of the Rectangular.
67,484,068
I have a model with a unique "code" field and a form for the same model where the "code" field is hidden. I need to set the "code" value in the view after the user has copied the form, but I get an IntegrityError exception. **model** ``` class Ticket(models.Model): codice = models.CharField(unique=True, max_lengt...
2021/05/11
[ "https://Stackoverflow.com/questions/67484068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14293891/" ]
To check for email and operate on it you are probably better of using Spring Integration which has out-of-the-box [email support](https://docs.spring.io/spring-integration/docs/current/reference/html/mail.html). Regarding your question I suspect you misunderstood the [`ApplicationListener`](https://docs.spring.io/spri...
I think you misunderstood the concept of spring context listeners. Spring application context starts during the startup of spring driven application. It has various "hooks" - points that you could listen to and be notified once they happen. So yes, context can be refreshed and when it happens, the listener "fires" and...
1,487,022
HI All, Has anybody been able to extract the device tokens from the binary data that iPhone APNS feedback service returns using PHP? I am looking for something similar to what is been implementented using python here [http://www.google.com/codesearch/p?hl=en&sa=N&cd=2&ct=rc#m5eOMDWiKUs/APNSWrapper/**init**.py&q=feedba...
2009/09/28
[ "https://Stackoverflow.com/questions/1487022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130985/" ]
[PHP technique to query the APNs Feedback Server](https://stackoverflow.com/questions/1278834/php-technique-to-query-the-apns-feedback-server)
The best place to go for this is actually the Apple developer forums in internal to the iPhone portal - the have a bunch of examples in different languages for working with these push requests. I'm also currently at an 360iDev push session, and they noted an open source PHP server can be found at: <http://code.google...
1,487,022
HI All, Has anybody been able to extract the device tokens from the binary data that iPhone APNS feedback service returns using PHP? I am looking for something similar to what is been implementented using python here [http://www.google.com/codesearch/p?hl=en&sa=N&cd=2&ct=rc#m5eOMDWiKUs/APNSWrapper/**init**.py&q=feedba...
2009/09/28
[ "https://Stackoverflow.com/questions/1487022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130985/" ]
[PHP technique to query the APNs Feedback Server](https://stackoverflow.com/questions/1278834/php-technique-to-query-the-apns-feedback-server)
Once you have your binary stream, you can process it like this: ``` while ($data = fread($stream, 38)) { $feedback = unpack("N1timestamp/n1length/H*devtoken", $data); // Do something } ``` $feedback will be an associative array containing elements "timestamp", "length" and "devtoken".
13,336,623
I'm using Python 2.6.2. I have a list of tuples `pair` which I like to sort using two nested conditions. 1. The tuples are first sorted in descending count order of `fwd_count`, 2. If the value of count is the same for more than one tuple in `fwd_count`, only those tuples having equal count need to be sorted in desce...
2012/11/11
[ "https://Stackoverflow.com/questions/13336623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1611813/" ]
If you require to swap *all* first (of pair) elements (and not just `(1, 36)` and `(0, 36)`), you can do `fwd_count_sort=sorted(rvs_count.items(), key=lambda x: (x[0][1],-x[0][0]), reverse=True)`
I'm not exactly sure on the definition of your sorting criteria, but this is a method to sort the `pair` list according to the values in `fwd_count` and `rvs_count`. Hopefully you can use this to get to the result you want. ``` def keyFromPair(pair): """Return a tuple (f, r) to be used for sorting the pairs by fre...
69,281,148
I have around 30000 Urls in my csv. I need to check if it has meta content is present or not, for each url. I am using request\_cache to basically cache the response to a sqlite db. It was taking about 24hrs even after using a caching sys. Therefore I moved to concurrency. I think I have done something wrong with `out ...
2021/09/22
[ "https://Stackoverflow.com/questions/69281148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16433326/" ]
I have tried to emulate your functionality. The following code executes in under 4 minutes:- ``` from bs4 import BeautifulSoup as BS import concurrent.futures import time import queue import requests URLs = [ "https://www.jython.org", "http://olympus.realpython.org/dice" ] * 15_000 user_agent = 'Mozilla/5.0 ...
AttributeError: 'str' object has no attribute 'items' ===================================================== This error is happening in `requests.models.PrepareRequest.prepare_headers()`. When you call `executor.map(networkCall, sites, headers)`, it's casting `headers` to a list, so you end up with `request.headers = '...
69,281,148
I have around 30000 Urls in my csv. I need to check if it has meta content is present or not, for each url. I am using request\_cache to basically cache the response to a sqlite db. It was taking about 24hrs even after using a caching sys. Therefore I moved to concurrency. I think I have done something wrong with `out ...
2021/09/22
[ "https://Stackoverflow.com/questions/69281148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16433326/" ]
I have tried to emulate your functionality. The following code executes in under 4 minutes:- ``` from bs4 import BeautifulSoup as BS import concurrent.futures import time import queue import requests URLs = [ "https://www.jython.org", "http://olympus.realpython.org/dice" ] * 15_000 user_agent = 'Mozilla/5.0 ...
Just recently stumbled upon a library for making async requests, it is called [requests-futures](https://github.com/ross/requests-futures). The syntax is pretty simple: ``` from concurrent.futures import as_completed from requests_futures.sessions import FuturesSession from bs4 import BeautifulSoup import time URLs ...
69,281,148
I have around 30000 Urls in my csv. I need to check if it has meta content is present or not, for each url. I am using request\_cache to basically cache the response to a sqlite db. It was taking about 24hrs even after using a caching sys. Therefore I moved to concurrency. I think I have done something wrong with `out ...
2021/09/22
[ "https://Stackoverflow.com/questions/69281148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16433326/" ]
Just recently stumbled upon a library for making async requests, it is called [requests-futures](https://github.com/ross/requests-futures). The syntax is pretty simple: ``` from concurrent.futures import as_completed from requests_futures.sessions import FuturesSession from bs4 import BeautifulSoup import time URLs ...
AttributeError: 'str' object has no attribute 'items' ===================================================== This error is happening in `requests.models.PrepareRequest.prepare_headers()`. When you call `executor.map(networkCall, sites, headers)`, it's casting `headers` to a list, so you end up with `request.headers = '...
18,937,057
I am searching for items that are not repeated in a list in python. The current way I do it is, ``` python -mtimeit -s'l=[1,2,3,4,5,6,7,8,9]*99' '[x for x in l if l.count(x) == 1]' 100 loops, best of 3: 12.9 msec per loop ``` Is it possible to do it faster? This is the output. ``` >>> l = [1,2,3,4,5,6,7,8,9]*99+[...
2013/09/21
[ "https://Stackoverflow.com/questions/18937057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/994176/" ]
You can use [the `Counter` class](http://docs.python.org/dev/library/collections.html#collections.Counter) from `collections`: ``` from collections import Counter ... [item for item, count in Counter(l).items() if count == 1] ``` My results: ```none $ python -m timeit -s 'from collections import Counter; l = [1, 2,...
Basically you want to remove duplicate entries, so there are some answers here: * [How do you remove duplicates from a list in Python whilst preserving order?](https://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order) * [Remove duplicates in a list while kee...
66,093,541
Is there a way in C++ to pass arguments by name like in python? For example I have a function: ``` void foo(int a, int b = 1, int c = 3, int d = 5); ``` Can I somehow call it like: ``` foo(5 /* a */, c = 5, d = 8); ``` Or ``` foo(5, /* a */, d = 1); ```
2021/02/07
[ "https://Stackoverflow.com/questions/66093541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15114707/" ]
There are no named function parameters in C++, but you can achieve a similar effect with designated initializers from C++20. Take all the function parameters and put them into a struct: ``` struct S { int a{}, b{}, c{}, d{}; }; ``` Now modify your function to take an instance of that struct (by `const&` for ef...
**No** You have to pass the arguments by order, so, to specify a value for *d*, you must also specify one for *c* since it's declared before it, for example
64,972,907
Output: ```none pygame 2.0.0 (SDL 2.0.12, python 3.8.6) Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "C:\Users\New User\Python Projects\Aliens Invasion Game\alien_invasion.py", line 5, in <module> class AlienInvasion: File "C:\Users\New User\Py...
2020/11/23
[ "https://Stackoverflow.com/questions/64972907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14625233/" ]
The original code you posted has an indentation issue - your `if __name__ == '__main__'` block is indented, meaning it's actually considered to be within the scope of `class AlienInvasion`: ``` import ... class AlienInvasion: def __init__(self): ... def run_game(self): ... # IMPORPERLY ...
You should remove your main block from the definition of the `AlienInvasion` class. Your `.py` file should look like this: ``` import sys import pygame class AlienInvasion: """Overall class to manage game assets and behaviour.""" def __init__(self): """Initialize the game, and create game resources....
62,657,469
I want to search for the word in the file and print next value of it using any way using python Following is the code : ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite: remove_comment=line.split('#')[0] ...
2020/06/30
[ "https://Stackoverflow.com/questions/62657469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032819/" ]
``` def matchTest(testsuite, testList): hashfile = open("hash.txt", 'a') with open ('text.txt', 'r') as suite: lines = [line.strip() for line in suite.readlines() if line.strip()] print(lines) for line in lines: f = re.search(r'component=>"(.*?)"', line) # find part you need...
Try this: ``` import re remove_comment = '''{:component=>"Cloud Tier Mgmt", :script=>"b.py", :testname=>"c", --clients=$LOAD_CLIENT --log_level=DEBUG --config_file=a.yaml"} {:skipfilesyscheck=>1, :component=>"Content Store", :script=>"b.py", --clients=$LOAD_CLIENT --log_level=DEBUG --config_file=a.yaml -s"} {:scrip...
62,657,469
I want to search for the word in the file and print next value of it using any way using python Following is the code : ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite: remove_comment=line.split('#')[0] ...
2020/06/30
[ "https://Stackoverflow.com/questions/62657469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032819/" ]
Assuming the rest of the code is correct (we can't see what regular expressions you are using), you need to change only one line to: ``` search_word = remove_comment.split(':component=>"', maxsplit=1)[-1].split('"', maxsplit=1)[0] ```
Try this: ``` import re remove_comment = '''{:component=>"Cloud Tier Mgmt", :script=>"b.py", :testname=>"c", --clients=$LOAD_CLIENT --log_level=DEBUG --config_file=a.yaml"} {:skipfilesyscheck=>1, :component=>"Content Store", :script=>"b.py", --clients=$LOAD_CLIENT --log_level=DEBUG --config_file=a.yaml -s"} {:scrip...
62,657,469
I want to search for the word in the file and print next value of it using any way using python Following is the code : ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite: remove_comment=line.split('#')[0] ...
2020/06/30
[ "https://Stackoverflow.com/questions/62657469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032819/" ]
Try this function ``` def get_component(file_path): word_list = [] file = open(file_path, 'r') i = 0; for line in file: for word in line.split(','): word = word[1:] if word.startswith(":component=>"): word = word[13:-1] word_list.append(word) print(word) ...
Try this: ``` import re remove_comment = '''{:component=>"Cloud Tier Mgmt", :script=>"b.py", :testname=>"c", --clients=$LOAD_CLIENT --log_level=DEBUG --config_file=a.yaml"} {:skipfilesyscheck=>1, :component=>"Content Store", :script=>"b.py", --clients=$LOAD_CLIENT --log_level=DEBUG --config_file=a.yaml -s"} {:scrip...
62,657,469
I want to search for the word in the file and print next value of it using any way using python Following is the code : ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite: remove_comment=line.split('#')[0] ...
2020/06/30
[ "https://Stackoverflow.com/questions/62657469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032819/" ]
``` def matchTest(testsuite, testList): hashfile = open("hash.txt", 'a') with open ('text.txt', 'r') as suite: lines = [line.strip() for line in suite.readlines() if line.strip()] print(lines) for line in lines: f = re.search(r'component=>"(.*?)"', line) # find part you need...
You can try ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite.split("\n"): remove_comment=line.split('#')[0] for i in remove_comment.split(","): if "component=>" in i: search_w...
62,657,469
I want to search for the word in the file and print next value of it using any way using python Following is the code : ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite: remove_comment=line.split('#')[0] ...
2020/06/30
[ "https://Stackoverflow.com/questions/62657469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032819/" ]
Assuming the rest of the code is correct (we can't see what regular expressions you are using), you need to change only one line to: ``` search_word = remove_comment.split(':component=>"', maxsplit=1)[-1].split('"', maxsplit=1)[0] ```
You can try ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite.split("\n"): remove_comment=line.split('#')[0] for i in remove_comment.split(","): if "component=>" in i: search_w...
62,657,469
I want to search for the word in the file and print next value of it using any way using python Following is the code : ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite: remove_comment=line.split('#')[0] ...
2020/06/30
[ "https://Stackoverflow.com/questions/62657469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032819/" ]
Try this function ``` def get_component(file_path): word_list = [] file = open(file_path, 'r') i = 0; for line in file: for word in line.split(','): word = word[1:] if word.startswith(":component=>"): word = word[13:-1] word_list.append(word) print(word) ...
You can try ``` def matchTest(testsuite, testList): hashfile = open("/auto/file.txt", 'a') with open (testsuite, 'r') as suite: for line in suite.split("\n"): remove_comment=line.split('#')[0] for i in remove_comment.split(","): if "component=>" in i: search_w...
52,451,119
I have few text files which contain URLs. I am trying to create a SQLite database to store these URLs in a table. The URL table has two columns i.e. primary key(INTEGER) and URL(TEXT). I try to insert 100,000 entries in one insert command and loop till I finish the URL list. Basically, read all the text files content ...
2018/09/21
[ "https://Stackoverflow.com/questions/52451119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139406/" ]
SQLite uses auto-commit mode by default. This permits `begin transaction` be to omitted. But here we want all the inserts to be in a transaction and the only way to do that is to start a transaction with `begin transaction` so that all the statements that are going to be ran are all in that transaction. The method `ex...
The UNIQUE constraint on column "url" is creating an implicit index on the URL. That would explain the size increase. I don't think you can populate the table and afterwards add the unique constraint. Your bottleneck is surely the CPU. Try the following: 1. Install toolz: `pip install toolz` 2. Use this method: ```...
26,214,328
After long debugging I found why my application using python regexps is slow. Here is something I find surprising: ``` import datetime import re pattern = re.compile('(.*)sol(.*)') lst = ["ciao mandi "*10000 + "sol " + "ciao mandi "*10000, "ciao mandi "*1000 + "sal " + "ciao mandi "*1000] for s in lst: pr...
2014/10/06
[ "https://Stackoverflow.com/questions/26214328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1221660/" ]
The Thompson NFA approach changes regular expressions from default greedy to default non-greedy. Normal regular expression engines can do the same; simply change `.*` to `.*?`. You should not use greedy expressions when non-greedy will do. Someone already built an NFA regular expression parser for Python: <https://git...
``` ^(?=(.*?sol))\1(.*)$ ``` You can try this.This reduces backtracking and fails faster.Try your string here. <http://regex101.com/r/hQ1rP0/22>
26,214,328
After long debugging I found why my application using python regexps is slow. Here is something I find surprising: ``` import datetime import re pattern = re.compile('(.*)sol(.*)') lst = ["ciao mandi "*10000 + "sol " + "ciao mandi "*10000, "ciao mandi "*1000 + "sal " + "ciao mandi "*1000] for s in lst: pr...
2014/10/06
[ "https://Stackoverflow.com/questions/26214328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1221660/" ]
I think this has nothing to do with catastrophic backtracking (or at least my own understanding of it). The problem is caused by the first `(.*)` in `(.*)sol(.*)`, and the fact that the regex is not anchored anywhere. `re.findall()`, after failing at index 0, would retry at index 1, 2, etc. until the end of the strin...
``` ^(?=(.*?sol))\1(.*)$ ``` You can try this.This reduces backtracking and fails faster.Try your string here. <http://regex101.com/r/hQ1rP0/22>
26,214,328
After long debugging I found why my application using python regexps is slow. Here is something I find surprising: ``` import datetime import re pattern = re.compile('(.*)sol(.*)') lst = ["ciao mandi "*10000 + "sol " + "ciao mandi "*10000, "ciao mandi "*1000 + "sal " + "ciao mandi "*1000] for s in lst: pr...
2014/10/06
[ "https://Stackoverflow.com/questions/26214328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1221660/" ]
The Thompson NFA approach changes regular expressions from default greedy to default non-greedy. Normal regular expression engines can do the same; simply change `.*` to `.*?`. You should not use greedy expressions when non-greedy will do. Someone already built an NFA regular expression parser for Python: <https://git...
I think this has nothing to do with catastrophic backtracking (or at least my own understanding of it). The problem is caused by the first `(.*)` in `(.*)sol(.*)`, and the fact that the regex is not anchored anywhere. `re.findall()`, after failing at index 0, would retry at index 1, 2, etc. until the end of the strin...
48,568,283
Here's an example to find the greatest common divisor for positive integers `a` and `b`, and `a <= b`. I started from the smaller `a` and minus one by one to check if it's the divisor of both numbers. ``` def gcdFinder(a, b): testerNum = a def tester(a, b): if b % testerNum == 0 and a % testerNum ...
2018/02/01
[ "https://Stackoverflow.com/questions/48568283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4860812/" ]
Answers to **Q2** and **Q4**. As I wrote in the comments, you can parse the testerNum as parameter. Your code would then look like this: ``` def gcdFinder(a, b): testerNum = a def tester(a, b, testerNum): if b % testerNum == 0 and a % testerNum == 0: return testerNum else: ...
TO hit only question 4, yes, it's better not to use `global` at all. `global` generally highlights poor code design. You're going to a lot of trouble; I strongly recommend that you look up standard methods of calculating the GCD, and implement Euclid's Algorithm instead. Coding details left as an exercise for the stud...
48,568,283
Here's an example to find the greatest common divisor for positive integers `a` and `b`, and `a <= b`. I started from the smaller `a` and minus one by one to check if it's the divisor of both numbers. ``` def gcdFinder(a, b): testerNum = a def tester(a, b): if b % testerNum == 0 and a % testerNum ...
2018/02/01
[ "https://Stackoverflow.com/questions/48568283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4860812/" ]
**The Problem:** When trying to resolve a variable reference, Python first checks in the local scope and then in the local scope of any enclosing functions. For example this code: ``` def foo(): x=23 def bar(): return x +1 return bar print(foo()()) ``` Will run and print out `24` because when `...
Answers to **Q2** and **Q4**. As I wrote in the comments, you can parse the testerNum as parameter. Your code would then look like this: ``` def gcdFinder(a, b): testerNum = a def tester(a, b, testerNum): if b % testerNum == 0 and a % testerNum == 0: return testerNum else: ...
48,568,283
Here's an example to find the greatest common divisor for positive integers `a` and `b`, and `a <= b`. I started from the smaller `a` and minus one by one to check if it's the divisor of both numbers. ``` def gcdFinder(a, b): testerNum = a def tester(a, b): if b % testerNum == 0 and a % testerNum ...
2018/02/01
[ "https://Stackoverflow.com/questions/48568283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4860812/" ]
**The Problem:** When trying to resolve a variable reference, Python first checks in the local scope and then in the local scope of any enclosing functions. For example this code: ``` def foo(): x=23 def bar(): return x +1 return bar print(foo()()) ``` Will run and print out `24` because when `...
TO hit only question 4, yes, it's better not to use `global` at all. `global` generally highlights poor code design. You're going to a lot of trouble; I strongly recommend that you look up standard methods of calculating the GCD, and implement Euclid's Algorithm instead. Coding details left as an exercise for the stud...
70,643,142
Say I have this array: ```python array = np.array([[1,2,3],[4,5,6],[7,8,9]]) ``` Returns: ```none 123 456 789 ``` How should I go about getting it to return something like this? ```none 111222333 111222333 111222333 444555666 444555666 444555666 777888999 777888999 777888999 ```
2022/01/09
[ "https://Stackoverflow.com/questions/70643142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16809168/" ]
You'd have to use [`np.repeat`](https://numpy.org/doc/stable/reference/generated/numpy.repeat.html#numpy-repeat) twice here. ``` np.repeat(np.repeat(array, 3, axis=1), 3, axis=0) # [[1 1 1 2 2 2 3 3 3] # [1 1 1 2 2 2 3 3 3] # [1 1 1 2 2 2 3 3 3] # [4 4 4 5 5 5 6 6 6] # [4 4 4 5 5 5 6 6 6] # [4 4 4 5 5 5 6 6 6] #...
For fun (because the nested `repeat` will be more efficient), you could use `einsum` on the input array and an array of `ones` that has extra dimensions to create a multidimensional array with the dimensions in an ideal order to `reshape` to the expected 2D shape: ``` np.einsum('ij,ikjl->ikjl', array, np.ones((3,3,3,3...
53,080,894
I am trying to make a GUI where the quantity of tkinter entries is decided by the user. My Code: ``` from tkinter import* root = Tk() def createEntries(quantity): for num in range(quantity): usrInput = Entry(root, text = num) usrInput.pack() createEntries(10) root.mainloop() ``` This code is...
2018/10/31
[ "https://Stackoverflow.com/questions/53080894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10585009/" ]
The solution is to store the widgets in a data structure such as a list or dictionary. For example: ``` entries = [] for num in range(quantity): usrInput = Entry(root, text = num) usrInput.pack() entries.append(usrInput) ``` Later, you can iterate over this list to get the values: ``` for entry in entri...
With the following Code you can adjust the number of Buttons and Entrys depending on the Var "fields". I hope it helps ``` from tkinter import * fields = 'Last Name', 'First Name', 'Job', 'Country' def fetch(entries): for entry in entries: field = entry[0] text = entry[1].get() print('%s: "%s"' ...
67,878,084
I'm trying to teach myself python and I am stuck in the for/while loops. Now I know the difference between the two but once nested loops get involved, i'm left feeling all over the place in terms of determining the hierarchy of the loops. Is there a way that I can get better at this? and how do I troubleshoot my loops ...
2021/06/07
[ "https://Stackoverflow.com/questions/67878084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16078295/" ]
If you want it to be a `dm` command we can use the restriction `@commands.dm_only()` However we then also have to check where the `answer` was given, we do that via some kind of custom `check`. I have modified your command a bit, but you can make the changes again personally. **Take a look at the following code:** `...
Edited to show full answer. Hey ho done it lol. Basically the message object contains a lot of data, so you need to pull the content of the message using answer.conent. <https://discordpy.readthedocs.io/en/latest/api.html?highlight=message#discord.Message.content> for reference ``` @bot.command() async def verify(ct...
1,205,449
Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out if someone could provide examples in python that would be a bi...
2009/07/30
[ "https://Stackoverflow.com/questions/1205449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147602/" ]
You have to encode your input and your output to something that can be represented by the neural network units. ( for example 1 for "x has a certain property p" -1 for "x doesn't have the property p" if your units' range is in [-1, 1]) The way you encode your input and the way you decode your output depends on what yo...
More complex data usually means adding more neurons in the input and output layers. You can feed each "field" of your register, properly encoded as a real value (normalized, etc.) to each input neuron, or maybe you can even decompose even further into bit fields, assigning saturated inputs of 1 or 0 to the neurons... ...
1,205,449
Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out if someone could provide examples in python that would be a bi...
2009/07/30
[ "https://Stackoverflow.com/questions/1205449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147602/" ]
You have to encode your input and your output to something that can be represented by the neural network units. ( for example 1 for "x has a certain property p" -1 for "x doesn't have the property p" if your units' range is in [-1, 1]) The way you encode your input and the way you decode your output depends on what yo...
Your features must be decomposed into parts that can be represented as real numbers. The magic of a Neural Net is it's a black box, the correct associations will be made (with internal weights) during the training --- **Inputs** Choose as few features as are needed to accurately describe the situation, then decompos...
1,205,449
Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out if someone could provide examples in python that would be a bi...
2009/07/30
[ "https://Stackoverflow.com/questions/1205449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147602/" ]
You have to encode your input and your output to something that can be represented by the neural network units. ( for example 1 for "x has a certain property p" -1 for "x doesn't have the property p" if your units' range is in [-1, 1]) The way you encode your input and the way you decode your output depends on what yo...
You have to add the number of units for input and output you need for the problem. If the unknown function to approximate depends on *n* parameter, you will have n input units. The number of output units depends on the nature of the funcion. For real functions with n real parameters you will have one output unit. Some...
1,205,449
Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out if someone could provide examples in python that would be a bi...
2009/07/30
[ "https://Stackoverflow.com/questions/1205449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147602/" ]
Your features must be decomposed into parts that can be represented as real numbers. The magic of a Neural Net is it's a black box, the correct associations will be made (with internal weights) during the training --- **Inputs** Choose as few features as are needed to accurately describe the situation, then decompos...
More complex data usually means adding more neurons in the input and output layers. You can feed each "field" of your register, properly encoded as a real value (normalized, etc.) to each input neuron, or maybe you can even decompose even further into bit fields, assigning saturated inputs of 1 or 0 to the neurons... ...
1,205,449
Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out if someone could provide examples in python that would be a bi...
2009/07/30
[ "https://Stackoverflow.com/questions/1205449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147602/" ]
Your features must be decomposed into parts that can be represented as real numbers. The magic of a Neural Net is it's a black box, the correct associations will be made (with internal weights) during the training --- **Inputs** Choose as few features as are needed to accurately describe the situation, then decompos...
You have to add the number of units for input and output you need for the problem. If the unknown function to approximate depends on *n* parameter, you will have n input units. The number of output units depends on the nature of the funcion. For real functions with n real parameters you will have one output unit. Some...
2,120,332
I think this is more a python question than Django. But basically I'm doing at Model A: ``` from myproject.modelb.models import ModelB ``` and at Model B: ``` from myproject.modela.models import ModelA ``` Result: > > cannot import name ModelA > > > Am I doing something forbidden? Thanks
2010/01/22
[ "https://Stackoverflow.com/questions/2120332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234167/" ]
A Python module is imported by executing it top to bottom in a new namespace. When module A imports module B, the evaluation of A.py is paused until module B is loaded. When module B then imports module A, it gets the partly-initialized namespace of module A -- in your case, it lacks the `ModelA` class because the impo...
Mutual imports usually mean you've designed your models incorrectly. When A depends on B, you should not have B also depending on A. Break B into two parts. B1 - depends on A. B2 - does not depend on A. A depends on B1. B1 depends on B2. Circularity removed.
5,425,725
I have created an objective-C framework that I would like to import and access through a python script. I understand how to import this stuff in Python, but what do i need to do on the obj-c side to make that framework importable? Thanks
2011/03/24
[ "https://Stackoverflow.com/questions/5425725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202431/" ]
You can just use [PyObjC](http://pyobjc.sourceforge.net/), which is included in Mac OS X 10.5 and later.
I'm not sure if this particular combination works, but you might be able to use [SWIG](http://swig.org/) to create a Python module out of your Objective-C which can then be imported into Python.
5,425,725
I have created an objective-C framework that I would like to import and access through a python script. I understand how to import this stuff in Python, but what do i need to do on the obj-c side to make that framework importable? Thanks
2011/03/24
[ "https://Stackoverflow.com/questions/5425725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202431/" ]
You'll want to use [PyObjC](http://pyobjc.sourceforge.net/), as Chuck said. Specifically, I'd suggest getting the [source](http://svn.red-bean.com/pyobjc/trunk/), which contains a collection of scripts, pyobjc-metadata (here's the [readme](http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-metadata/ReadMe.txt)), that d...
I'm not sure if this particular combination works, but you might be able to use [SWIG](http://swig.org/) to create a Python module out of your Objective-C which can then be imported into Python.
5,425,725
I have created an objective-C framework that I would like to import and access through a python script. I understand how to import this stuff in Python, but what do i need to do on the obj-c side to make that framework importable? Thanks
2011/03/24
[ "https://Stackoverflow.com/questions/5425725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202431/" ]
You'll want to use [PyObjC](http://pyobjc.sourceforge.net/), as Chuck said. Specifically, I'd suggest getting the [source](http://svn.red-bean.com/pyobjc/trunk/), which contains a collection of scripts, pyobjc-metadata (here's the [readme](http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-metadata/ReadMe.txt)), that d...
You can just use [PyObjC](http://pyobjc.sourceforge.net/), which is included in Mac OS X 10.5 and later.
11,842,202
I am trying to upgrade my plone version from 3.3.5 to 4.0. For this I went to this site: [updating plone](http://plone.org/documentation/manual/upgrade-guide/version/upgrading-plone-3-x-to-4.0/buildout-3-4). But I got stuck in the first point. In plone 3, I have python version of 2.4. But for plone 4.x I will need pyth...
2012/08/07
[ "https://Stackoverflow.com/questions/11842202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/596757/" ]
To upgrade python it really depends on the underlying OS (operating system). If a OS specific upgrade fails, download python from <http://www.python.org/download/> and install it from source. You might have to upgrade some of the paths in your buildout.cfg
You don't upgrade Python, you install a new version in parallell.
26,230,028
I just started using Crossbar.io to implement a live stats page. I've looked at a lot of code examples, but I can't figure out how to do this: I have a Django service (to avoid confusion, you can assume I´m talking about a function in views.py) and I'd like it to publish messages in a specific topic, whenever it gets ...
2014/10/07
[ "https://Stackoverflow.com/questions/26230028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1445416/" ]
Django is a blocking WSGI application, and that does not blend well with AutobahnPython, which is non-blocking (runs on top of Twisted or asyncio). However, Crossbar.io has a built-in REST bridge, which includes a [HTTP Pusher](https://github.com/crossbario/crossbar/wiki/HTTP%20Pusher%20Service) to which you can submi...
I found what I needed: It is possible to do a HTTP POST request to publish on a topic. You can read the doc for more information: <https://github.com/crossbario/crossbar/wiki/Using-the-REST-to-WebSocket-Pusher>
21,834,702
Like I said in the title, my script only seems to work on the first line. Here is my script: ``` #!/usr/bin/python import sys def main(): a = sys.argv[1] f = open(a,'r') lines = f.readlines() w = 0 for line in lines: spot = 0 cp = line for char in reversed(cp): x = -1 if char ==...
2014/02/17
[ "https://Stackoverflow.com/questions/21834702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2353168/" ]
The following script do the same thing as your program, more compactly: ``` import fileinput deleted = 0 for line in fileinput.input(inplace=True): stripped = line.rstrip() deleted += len(line) - len(stripped) + 1 # don't count the newline print(stripped) print("Whitespace deleted: {}".format(deleted)) ...
`rstrip()` is probably what you want to use to achieve this. ``` >>> 'Here is my string '.rstrip() 'Here is my string' ``` A more compact way to iterate backwards over stings is ``` >>> for c in 'Thing'[::-1]: print(c) g n i h T ``` `[::-1]` is slice notation. SLice notaion can be represented as `[...
21,834,702
Like I said in the title, my script only seems to work on the first line. Here is my script: ``` #!/usr/bin/python import sys def main(): a = sys.argv[1] f = open(a,'r') lines = f.readlines() w = 0 for line in lines: spot = 0 cp = line for char in reversed(cp): x = -1 if char ==...
2014/02/17
[ "https://Stackoverflow.com/questions/21834702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2353168/" ]
The following script do the same thing as your program, more compactly: ``` import fileinput deleted = 0 for line in fileinput.input(inplace=True): stripped = line.rstrip() deleted += len(line) - len(stripped) + 1 # don't count the newline print(stripped) print("Whitespace deleted: {}".format(deleted)) ...
Just use `rstrip`: ``` f = open(a,'r') lines = f.readlines() f.close() f = open(a,'w') for line in lines: f.write(line.rstrip()+'\n') f.close() ```
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
**If you have conda installed in your system then follow these steps:** * conda create -n py36 python=3.6 * activate py36 * conda config --add channels conda-forge * conda install numpy * conda install scipy * conda install dlib * pip install --no-dependencies face\_recognition
if your OS is windows7 : 1. download and install dlib.whl x64 or x86 2. download and install cmake app and add it to path 3. pip install cmake 4. pip install dlib only on python 3.6 to 3.7 with ".whl" file 5. pip install face\_recognotion enjoy face\_recognition
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
First of all, install Cmake. ``` pip install cmake ``` After that, install the dlib. If pip is not working, install dlib via the wheel file. ``` pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d4642034...
if your OS is windows7 : 1. download and install dlib.whl x64 or x86 2. download and install cmake app and add it to path 3. pip install cmake 4. pip install dlib only on python 3.6 to 3.7 with ".whl" file 5. pip install face\_recognotion enjoy face\_recognition
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
**If you have conda installed in your system then follow these steps:** * conda create -n py36 python=3.6 * activate py36 * conda config --add channels conda-forge * conda install numpy * conda install scipy * conda install dlib * pip install --no-dependencies face\_recognition
My Env details : > > python 3.7 & > ubuntu 16.04 > > > --- **1)** Assign root permission and update ubuntu first ``` sudo su apt-get update ``` **2)** Check your version & path for python & pip. ``` which python3 python3 -V which pip3 pip3 -V ``` **3)** ``` pip3 install cmake ``` **4)** ``` apt-get ...
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
First of all, install Cmake. ``` pip install cmake ``` After that, install the dlib. If pip is not working, install dlib via the wheel file. ``` pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d4642034...
I have got the same problem. I have installed CMake but it shows the same problem. This is the solution that worked for me, ``` conda install -c conda-forge dlib ```
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
First of all, install Cmake. ``` pip install cmake ``` After that, install the dlib. If pip is not working, install dlib via the wheel file. ``` pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d4642034...
Install Cmake with: ``` sudo apt install cmake ``` And for python3 don't use pip alone, use pip3 to install future python3 modules: ``` pip3 install face_recognition ```
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
**If you have conda installed in your system then follow these steps:** * conda create -n py36 python=3.6 * activate py36 * conda config --add channels conda-forge * conda install numpy * conda install scipy * conda install dlib * pip install --no-dependencies face\_recognition
I just overcame the challenge. You can let VS Code do the hard work for you. 1. Download Visual Studio 2022. 2. When installing, make sure to install **Desktop Development with C++**. It automatically downloads CMake. 3. Once it is complete, clone face\_recognition. Simply navigate to a folder of your choice in Comman...
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
First of all, install Cmake. ``` pip install cmake ``` After that, install the dlib. If pip is not working, install dlib via the wheel file. ``` pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d4642034...
I just overcame the challenge. You can let VS Code do the hard work for you. 1. Download Visual Studio 2022. 2. When installing, make sure to install **Desktop Development with C++**. It automatically downloads CMake. 3. Once it is complete, clone face\_recognition. Simply navigate to a folder of your choice in Comman...
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
First of all, install Cmake. ``` pip install cmake ``` After that, install the dlib. If pip is not working, install dlib via the wheel file. ``` pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d4642034...
My Env details : > > python 3.7 & > ubuntu 16.04 > > > --- **1)** Assign root permission and update ubuntu first ``` sudo su apt-get update ``` **2)** Check your version & path for python & pip. ``` which python3 python3 -V which pip3 pip3 -V ``` **3)** ``` pip3 install cmake ``` **4)** ``` apt-get ...
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
**If you have conda installed in your system then follow these steps:** * conda create -n py36 python=3.6 * activate py36 * conda config --add channels conda-forge * conda install numpy * conda install scipy * conda install dlib * pip install --no-dependencies face\_recognition
I have got the same problem. I have installed CMake but it shows the same problem. This is the solution that worked for me, ``` conda install -c conda-forge dlib ```
56,696,940
i have installed the cmake but still dlib is not installing which is required for the installation of face\_recognition module the below mentioned error i am getting whenever i try to install the dlib by using the pip install dlib ``` ERROR: Complete output from command 'c:\users\sunil\appdata\local\programs\python\p...
2019/06/21
[ "https://Stackoverflow.com/questions/56696940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628342/" ]
First of all, install Cmake. ``` pip install cmake ``` After that, install the dlib. If pip is not working, install dlib via the wheel file. ``` pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d4642034...
**Simple steps:-** 1. install python 3.8 [here](https://www.python.org/downloads/release/python-380/) 2. `pip install cmake` (or) `pip3 install cmake` (#make sure you installing cmake on python3.8 pip) 3. download cmake softwre [here](https://cmake.org/downloads) 4.install c,c++ build tools [here](https://visualstudi...
71,822,376
Is there any way I can make **Excel** add-ins/extensions using Python? I have tried javascript but haven't found any result about making add-ins on python.
2022/04/11
[ "https://Stackoverflow.com/questions/71822376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17767517/" ]
Try this code ``` nav .wrapper{ display: flex; justify-content: space-between; } nav ul{ display: flex; } ```
It should contain http For example href="https://classroom.udacity.com/nanodegrees/nd004-1mac-v2/dashboard/overview"
71,822,376
Is there any way I can make **Excel** add-ins/extensions using Python? I have tried javascript but haven't found any result about making add-ins on python.
2022/04/11
[ "https://Stackoverflow.com/questions/71822376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17767517/" ]
Try this code ``` nav .wrapper{ display: flex; justify-content: space-between; } nav ul{ display: flex; } ```
Maybe something like this?? ```css .wrapper { display:flex; flex-direction:row; justify-content:space-evenly; width:100%; height:40px; background-color:black; padding-top:10px; } .wrapper > a{ color:white; text-decoration:none; } a:hover { text-decoration:underline } ``` ```html <body> <n...
68,384,185
Hi I'm trying to build out a basic app django within a python/alpine image. I am getting en error telling me that there is no matching image for the version of Django that I am looking for. The Dockerfile in using a `python:3.9-alpine3.14` image and my requirements file is targeting `Django>=3.2.5,<3.3`. From what i...
2021/07/14
[ "https://Stackoverflow.com/questions/68384185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3346752/" ]
Continuing a list over multiple section is not a standard task, I think the clean way to go is definitely with a [counter](https://docs.asciidoctor.org/asciidoc/latest/attributes/counters/). Instead of an ordered list you could instead use a [Description list](https://docs.asciidoctor.org/asciidoc/latest/lists/descrip...
Here's another hack: ``` = Document == Section A . item 1 . item 2 + [discrete] == Section B . item 3 . item 4 + [discrete] == Section C . item 5 . item 6 ``` That gets the list items to have the correct item numbers, but the "discrete" headings are indented. You could use some CSS customization (say via [docinf...
41,204,071
I have implemented the [python-social-auth](https://github.com/python-social-auth) library for Google OAuth2 in my Django project, and am successfully able to log users in with it. The library stores the `access_token` received in the response for Google's OAuth2 flow. My question is: use of the [google-api-python-cli...
2016/12/17
[ "https://Stackoverflow.com/questions/41204071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/306374/" ]
Given you already have the OAuth2 access token you can use the [`AccessTokenCredentials`](https://developers.google.com/api-client-library/python/guide/aaa_oauth#AccessTokenCredentials) class. > > The oauth2client.client.AccessTokenCredentials class is used when you have already obtained an access token by some othe...
You can check examples provided by Google Guide API, for example: sending email via gmail application, <https://developers.google.com/gmail/api/guides/sending>
41,204,071
I have implemented the [python-social-auth](https://github.com/python-social-auth) library for Google OAuth2 in my Django project, and am successfully able to log users in with it. The library stores the `access_token` received in the response for Google's OAuth2 flow. My question is: use of the [google-api-python-cli...
2016/12/17
[ "https://Stackoverflow.com/questions/41204071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/306374/" ]
Given you already have the OAuth2 access token you can use the [`AccessTokenCredentials`](https://developers.google.com/api-client-library/python/guide/aaa_oauth#AccessTokenCredentials) class. > > The oauth2client.client.AccessTokenCredentials class is used when you have already obtained an access token by some othe...
If you have an already refreshed latest access token which is not expired, then you can get `service` variable as: ``` from googleapiclient.discovery import build from google.oauth2.credentials import Credentials creds = Credentials("<ACCESS_TOKEN>") service = build('gmail', 'v1', credentials=creds) # Call the Gmail...
52,221,769
I have two floats `no_a` and `no_b` and a couple of ranges represented as two element lists holding the lower and upper border. I want to check if the numbers are both in one of the following ranges: `[0, 0.33]`, `[0.33, 0.66]`, or `[0.66, 1.0]`. How can I write that statement neatly in python code?
2018/09/07
[ "https://Stackoverflow.com/questions/52221769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682455/" ]
If you just want to get a `True` or `False` result, consider the following. ``` >>> a = 0.4 >>> b = 0.6 >>> >>> ranges = [[0,0.33], [0.33,0.66], [0.66,1.0]] >>> >>> any(low <= a <= high and low <= b <= high for low, high in ranges) True ``` If you have an arbitrary amount of numbers to check (not just `a` and `b`)...
Have a look at [here](https://docs.scipy.org/doc/numpy/reference/generated/numpy.all.html). Put your `no_a` and `no_b` into an array and check if all events pass your statement. --- Second Edit: As pointed out, the built-in `all` function outperforms the numpy version for this small dataset, so the usage of numpy ha...
52,221,769
I have two floats `no_a` and `no_b` and a couple of ranges represented as two element lists holding the lower and upper border. I want to check if the numbers are both in one of the following ranges: `[0, 0.33]`, `[0.33, 0.66]`, or `[0.66, 1.0]`. How can I write that statement neatly in python code?
2018/09/07
[ "https://Stackoverflow.com/questions/52221769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682455/" ]
If you just want to get a `True` or `False` result, consider the following. ``` >>> a = 0.4 >>> b = 0.6 >>> >>> ranges = [[0,0.33], [0.33,0.66], [0.66,1.0]] >>> >>> any(low <= a <= high and low <= b <= high for low, high in ranges) True ``` If you have an arbitrary amount of numbers to check (not just `a` and `b`)...
Like this: ``` RANGES = [[0,0.33], [0.33,0.66], [0.66,1.0]] def check(no_a, no_b): for rng in RANGES: if rng[0] < no_a < rng[1] and rng[0] < no_b < rng[1]: return True else: return False print(check(.1, .2)) print(check(.1, .4)) ``` Output is: ``` True False ``` Or like this:...
52,221,769
I have two floats `no_a` and `no_b` and a couple of ranges represented as two element lists holding the lower and upper border. I want to check if the numbers are both in one of the following ranges: `[0, 0.33]`, `[0.33, 0.66]`, or `[0.66, 1.0]`. How can I write that statement neatly in python code?
2018/09/07
[ "https://Stackoverflow.com/questions/52221769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682455/" ]
If you just want to get a `True` or `False` result, consider the following. ``` >>> a = 0.4 >>> b = 0.6 >>> >>> ranges = [[0,0.33], [0.33,0.66], [0.66,1.0]] >>> >>> any(low <= a <= high and low <= b <= high for low, high in ranges) True ``` If you have an arbitrary amount of numbers to check (not just `a` and `b`)...
### Numpy Using Broadcasting ``` import numpy as np check = np.array([[0.4], [0.6]]) ranges = np.array([[0,0.33], [0.33,0.66], [0.66,1.0]]) ((check >= ranges[:, 0]) & (check <= ranges[:, 1])).all(0).any() True ``` --- ### Details ``` check >= ranges[:, 0] # 0.00 0.33 0.66 < [[ True True False] # 0.4 ...
52,221,769
I have two floats `no_a` and `no_b` and a couple of ranges represented as two element lists holding the lower and upper border. I want to check if the numbers are both in one of the following ranges: `[0, 0.33]`, `[0.33, 0.66]`, or `[0.66, 1.0]`. How can I write that statement neatly in python code?
2018/09/07
[ "https://Stackoverflow.com/questions/52221769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682455/" ]
Like this: ``` RANGES = [[0,0.33], [0.33,0.66], [0.66,1.0]] def check(no_a, no_b): for rng in RANGES: if rng[0] < no_a < rng[1] and rng[0] < no_b < rng[1]: return True else: return False print(check(.1, .2)) print(check(.1, .4)) ``` Output is: ``` True False ``` Or like this:...
Have a look at [here](https://docs.scipy.org/doc/numpy/reference/generated/numpy.all.html). Put your `no_a` and `no_b` into an array and check if all events pass your statement. --- Second Edit: As pointed out, the built-in `all` function outperforms the numpy version for this small dataset, so the usage of numpy ha...
52,221,769
I have two floats `no_a` and `no_b` and a couple of ranges represented as two element lists holding the lower and upper border. I want to check if the numbers are both in one of the following ranges: `[0, 0.33]`, `[0.33, 0.66]`, or `[0.66, 1.0]`. How can I write that statement neatly in python code?
2018/09/07
[ "https://Stackoverflow.com/questions/52221769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682455/" ]
Like this: ``` RANGES = [[0,0.33], [0.33,0.66], [0.66,1.0]] def check(no_a, no_b): for rng in RANGES: if rng[0] < no_a < rng[1] and rng[0] < no_b < rng[1]: return True else: return False print(check(.1, .2)) print(check(.1, .4)) ``` Output is: ``` True False ``` Or like this:...
### Numpy Using Broadcasting ``` import numpy as np check = np.array([[0.4], [0.6]]) ranges = np.array([[0,0.33], [0.33,0.66], [0.66,1.0]]) ((check >= ranges[:, 0]) & (check <= ranges[:, 1])).all(0).any() True ``` --- ### Details ``` check >= ranges[:, 0] # 0.00 0.33 0.66 < [[ True True False] # 0.4 ...
17,604,130
I need help figuring out this code. This is my first programming class and we have a exam next week and I am trying to do the old exams. There is one class with nested list that I am having trouble understanding. It basically says to convert `(list of [list of ints]) -> int`. Basically given a list of list which ev...
2013/07/11
[ "https://Stackoverflow.com/questions/17604130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2574430/" ]
If I understand correctly and you want to return the index of the first list that contains at least one even number: ``` In [1]: def first_even(nl): ...: for i, l in enumerate(nl): ...: if not all(x%2 for x in l): ...: return i ...: return -1 ...: In [2]: first_even([[9, 1,...
There are some minor problems with your code: * `L1[i] % 2 = 0` is using the wrong operator. `=` is for assigning variables a value, while `==` is used for equality. * You probably meant `range(len(L1))`, as range expects an integer. * Lastly, you're adding the whole list to the count, when you only wanted to add the ...
17,604,130
I need help figuring out this code. This is my first programming class and we have a exam next week and I am trying to do the old exams. There is one class with nested list that I am having trouble understanding. It basically says to convert `(list of [list of ints]) -> int`. Basically given a list of list which ev...
2013/07/11
[ "https://Stackoverflow.com/questions/17604130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2574430/" ]
If I understand correctly and you want to return the index of the first list that contains at least one even number: ``` In [1]: def first_even(nl): ...: for i, l in enumerate(nl): ...: if not all(x%2 for x in l): ...: return i ...: return -1 ...: In [2]: first_even([[9, 1,...
So here's what I came up with. ``` def first_even(L1): for aList in range(len(L1)): for anItem in range(len(L1[aList])): if L1[aList][anItem] % 2 == 0: return aList return -1 ``` First a fix. You need to use == for "equal to", '=' is for assigning variables. ``` L1[i] % 2 =...
17,604,130
I need help figuring out this code. This is my first programming class and we have a exam next week and I am trying to do the old exams. There is one class with nested list that I am having trouble understanding. It basically says to convert `(list of [list of ints]) -> int`. Basically given a list of list which ev...
2013/07/11
[ "https://Stackoverflow.com/questions/17604130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2574430/" ]
If I understand correctly and you want to return the index of the first list that contains at least one even number: ``` In [1]: def first_even(nl): ...: for i, l in enumerate(nl): ...: if not all(x%2 for x in l): ...: return i ...: return -1 ...: In [2]: first_even([[9, 1,...
``` def first_even(L1): return ''.join('o' if all(n%2 for n in sl) else 'e' for sl in L1).find('e') ```
62,984,417
I am trying to format a string in python, but the values are not being replaced. Here is my example... ``` uid = results[0][0] query = """ SELECT m.whiteUid, m.blackUid, u1.displayName AS whiteDisplayName, u2.displayName AS blackDisplayName, m.created, m.modifie...
2020/07/19
[ "https://Stackoverflow.com/questions/62984417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3321579/" ]
You should do this: `query = query.format(...)`. The format method just returns the formatted string, it doesn't change `self`.
String is immutable. Use f string. It's recommended. ``` query = f""" SELECT m.whiteUid, m.blackUid, u1.displayName AS whiteDisplayName, u2.displayName AS blackDisplayName, m.created, m.modified FROM matches m INNER JOIN users u1 ON u1.uid = m.whiteUid INNER JOIN users u2 ON u2.uid ...
62,984,417
I am trying to format a string in python, but the values are not being replaced. Here is my example... ``` uid = results[0][0] query = """ SELECT m.whiteUid, m.blackUid, u1.displayName AS whiteDisplayName, u2.displayName AS blackDisplayName, m.created, m.modifie...
2020/07/19
[ "https://Stackoverflow.com/questions/62984417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3321579/" ]
You should do this: `query = query.format(...)`. The format method just returns the formatted string, it doesn't change `self`.
If using python3 I would recommend f-Strings (<https://docs.python.org/3/reference/lexical_analysis.html#f-strings>): ``` uid = results[0][0] query = f""" SELECT m.whiteUid, m.blackUid, u1.displayName AS whiteDisplayName, u2.displayName AS blackDisplayName, m.created, m.modified FROM mat...
62,984,417
I am trying to format a string in python, but the values are not being replaced. Here is my example... ``` uid = results[0][0] query = """ SELECT m.whiteUid, m.blackUid, u1.displayName AS whiteDisplayName, u2.displayName AS blackDisplayName, m.created, m.modifie...
2020/07/19
[ "https://Stackoverflow.com/questions/62984417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3321579/" ]
String is immutable. Use f string. It's recommended. ``` query = f""" SELECT m.whiteUid, m.blackUid, u1.displayName AS whiteDisplayName, u2.displayName AS blackDisplayName, m.created, m.modified FROM matches m INNER JOIN users u1 ON u1.uid = m.whiteUid INNER JOIN users u2 ON u2.uid ...
If using python3 I would recommend f-Strings (<https://docs.python.org/3/reference/lexical_analysis.html#f-strings>): ``` uid = results[0][0] query = f""" SELECT m.whiteUid, m.blackUid, u1.displayName AS whiteDisplayName, u2.displayName AS blackDisplayName, m.created, m.modified FROM mat...
37,724,694
I am just trying to pass random arguments for below python script. Code: ``` import json,sys,os,subprocess arg1 = 'Site1' arg2 = "443" arg3 = 'admin@example.com' arg4 = 'example@123' arg5 = '--output req.txt' arg6 = '-h' obj=json.load(sys.stdin) for i in range(len(obj['data'])): print obj['data'][i]['value'] ...
2016/06/09
[ "https://Stackoverflow.com/questions/37724694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5005270/" ]
It looks to me like you're passing the entire `obj` dictionary into the command. To get the desired invocation, pass `obj['data'][i]['value']` in the arguments list to `subprocess.call`. So, the final line of your script should be ``` subprocess.call(['./malopinfo.py', arg1, arg2, arg3, arg4, obj['data'][i]['value...
You are directly passing an object. Beforehand you need to convert that into string as `subprocess.call` will expect obj to be a string. Get the string value of one of the obj properties like you already have done `obj['data'][i]['value']` and pass it into your `subprocess.call`.
51,492,621
I've recently attempted google's iot end-to-end example (<https://cloud.google.com/iot/docs/samples/end-to-end-sample>) out of pure interest. However, towards the final part of the process where I had to connect devices, I kept running into a run time error. ``` Creating JWT using RS256 from private key file rsa_priv...
2018/07/24
[ "https://Stackoverflow.com/questions/51492621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10126223/" ]
To solve this, just pass the correct cloud region parameter to the command --cloud\_region=asia-east1
You can try giving cloud region when running device script Ex : "--cloud\_region=asia-east1" python cloudiot\_pubsub\_example\_mqtt\_device.py --project\_id=applied-grove-246108 --registry\_id=my-registry --device\_id=my-device --private\_key\_file=rsa\_private.pem --algorithm=RS256 --cloud\_region=asia-east1
30,103,965
Not by word boundaries, that is solvable. Example: ``` #!/usr/bin/env python3 text = 'เมื่อแรกเริ่ม' for char in text: print(char) ``` This produces: เ ม อ แ ร ก เ ร ม Which obviously is not the desired output. Any ideas? A portable representation of text is: ``` text = u'\...
2015/05/07
[ "https://Stackoverflow.com/questions/30103965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2397101/" ]
tl;dr: Use `\X` regular expression to extract user-perceived characters: ``` >>> import regex # $ pip install regex >>> regex.findall(u'\\X', u'เมื่อแรกเริ่ม') ['เ', 'มื่', 'อ', 'แ', 'ร', 'ก', 'เ', 'ริ่', 'ม'] ``` --- While I do not know Thai, I know a little French. Consider the letter `è`. Let `s` and `s2` equal...
I cannot exactly reproduce, but here is a slight modified version of you script, with the output on IDLE 3.4 on a Windows7 64 system : ``` >>> for char in text: print(char, hex(ord(char)), unicodedata.name(char),'-', unicodedata.category(char), '-', unicodedata.combining(char), '-', unicodedata...
30,103,965
Not by word boundaries, that is solvable. Example: ``` #!/usr/bin/env python3 text = 'เมื่อแรกเริ่ม' for char in text: print(char) ``` This produces: เ ม อ แ ร ก เ ร ม Which obviously is not the desired output. Any ideas? A portable representation of text is: ``` text = u'\...
2015/05/07
[ "https://Stackoverflow.com/questions/30103965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2397101/" ]
tl;dr: Use `\X` regular expression to extract user-perceived characters: ``` >>> import regex # $ pip install regex >>> regex.findall(u'\\X', u'เมื่อแรกเริ่ม') ['เ', 'มื่', 'อ', 'แ', 'ร', 'ก', 'เ', 'ริ่', 'ม'] ``` --- While I do not know Thai, I know a little French. Consider the letter `è`. Let `s` and `s2` equal...
For clarification of the previous answers, the issue you have is that the missing characters are "combining characters" - vowels and diacritics that must be combined with other characters in order to be displayed properly. There is no standard way to display these characters by themselves, although the most common conv...
20,294,693
In the following example, I want to change the `a1` key of `d` in place by calling the `set_x()` function of the class `A`. But I don't see how to access a key in a `dict`. ``` #!/usr/bin/env python class A(object): def __init__(self, data=''): self.data = data self.x = '' def set_x(self, x): self.x =...
2013/11/29
[ "https://Stackoverflow.com/questions/20294693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1424739/" ]
You need to refer to the object itself, and modify it there. Take a look at this console session: ``` >>> a = A("foo") >>> d = {a:10} >>> d {A(foo:): 10} >>> a.set_x('word') >>> d {A(foo:word): 10} ``` You can also get the key-value pair from `dict.items()`: ``` a, v = d.items()[0] a.set_x("word") ``` Hope this...
You can keep the reference to the object and modify it. If you can't keep a reference to the key object, you can still iterate over the dict using `for k, v in d.items():` and then use the value to know which key you have (although this is somewhat backward in how to use a dict and highly ineficient) ``` a1 = A('foo')...
59,876,292
I want to run gs command to copy data using python function in cloud function, is it possible to run a shell command inside the cloud function??.
2020/01/23
[ "https://Stackoverflow.com/questions/59876292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12309624/" ]
According to the official documentation [Cloud Functions Execution Environment](https://cloud.google.com/functions/docs/concepts/exec): > > Cloud Functions run in a fully-managed, serverless environment where > Google handles infrastructure, operating systems, and runtime > environments completely on your behalf. ...
Have tried using [subprocess](https://docs.python.org/3/library/subprocess.html) module to see if it helps you achieve what you need? I haven't tried this myself so I can't be sure if it will work. ``` import subprocess subprocess.run(["ls", "-l"]) ``` Alternatively you can also use CloudRun to run [Docker image wi...
59,876,292
I want to run gs command to copy data using python function in cloud function, is it possible to run a shell command inside the cloud function??.
2020/01/23
[ "https://Stackoverflow.com/questions/59876292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12309624/" ]
According to the official documentation [Cloud Functions Execution Environment](https://cloud.google.com/functions/docs/concepts/exec): > > Cloud Functions run in a fully-managed, serverless environment where > Google handles infrastructure, operating systems, and runtime > environments completely on your behalf. ...
To interact with Google APIs from a Cloud function(Python runtime), shell command is not the ideal choice. Google Cloud Platform has [Python libraries](https://cloud.google.com/storage/docs/reference/libraries#client-libraries-install-python) to interact with its service and I suggest to you them. Sample Python code t...
26,292,102
Because of inherited html parts when using template engines such as twig (PHP) or jinja2 (python), I may need to nest rows like below: ``` <div class="container"> <div class="row"> <div class="row"> </div> ... <div class="row"> </div> </div> <div class="row"> ...
2014/10/10
[ "https://Stackoverflow.com/questions/26292102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85443/" ]
You shouldn't wrap the nested rows in `.container` elements, but you *should* nest them in columns. Bootstrap's `row` class has negative left and right margins that are negated by the `col-X` classes' positive left and right margins. If you nest two `row` classes without intermediate `col-X` classes, you get double the...
You shouldn't wrap them in another [container](http://getbootstrap.com/css/#grid) - containers are designed for a typical one-page layout. Unless it would look good / work well with your layout, you may want to look into `container-fluid` if you really want to do this. **tl;dr** don't wrap in another container.
30,631,299
First i'm developing a django app, when i try to run the server with: python manage.py runserver 0.0.0.0:8000 The terminal shows: ``` "django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb" ``` So, i need to install that package: ``` (app1)Me% pip install MySQL-python...
2015/06/03
[ "https://Stackoverflow.com/questions/30631299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2544076/" ]
The solution was in reinstalling the developer tools: ``` xcode-select --install ```
What fixed it for me was: `sudo pip install --upgrade setuptools` Make sure you have mysql installed: ``` brew install mysql ```
30,631,299
First i'm developing a django app, when i try to run the server with: python manage.py runserver 0.0.0.0:8000 The terminal shows: ``` "django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb" ``` So, i need to install that package: ``` (app1)Me% pip install MySQL-python...
2015/06/03
[ "https://Stackoverflow.com/questions/30631299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2544076/" ]
The solution was in reinstalling the developer tools: ``` xcode-select --install ```
Based on [a solution to a seemingly unrelated problem](https://github.com/SOHU-Co/kafka-node/issues/881#issuecomment-377109841), I was able to solve the problem here by running `brew doctor` and cleaning up all the stray header files it called out.
30,631,299
First i'm developing a django app, when i try to run the server with: python manage.py runserver 0.0.0.0:8000 The terminal shows: ``` "django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb" ``` So, i need to install that package: ``` (app1)Me% pip install MySQL-python...
2015/06/03
[ "https://Stackoverflow.com/questions/30631299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2544076/" ]
What fixed it for me was: `sudo pip install --upgrade setuptools` Make sure you have mysql installed: ``` brew install mysql ```
Based on [a solution to a seemingly unrelated problem](https://github.com/SOHU-Co/kafka-node/issues/881#issuecomment-377109841), I was able to solve the problem here by running `brew doctor` and cleaning up all the stray header files it called out.
69,685,355
I'm sorry if that didn't make any sense! I'm very new to python and I could really use some help. I don't want the question to be solved for me, but I would appreciate some advice as a starting point. ``` listA = [("Aleah", [74, 100, 120, 67]), ("Hannah", [95, 110, 110, 67]), ("Timothy...
2021/10/23
[ "https://Stackoverflow.com/questions/69685355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17225072/" ]
You put your listelement inside the same container - so expanding the list would also expand everything. You can put your listelement outside and/or give it an absolute position. Minimal changes can be found here: [codepen](https://codepen.io/coyer/pen/KKvapbv) Basically I wrapped the inputfield in a relative-positio...
Try This -------- --- ``` ul { max-height: 250px; overflow-y: scroll; } ```
69,685,355
I'm sorry if that didn't make any sense! I'm very new to python and I could really use some help. I don't want the question to be solved for me, but I would appreciate some advice as a starting point. ``` listA = [("Aleah", [74, 100, 120, 67]), ("Hannah", [95, 110, 110, 67]), ("Timothy...
2021/10/23
[ "https://Stackoverflow.com/questions/69685355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17225072/" ]
Try This -------- --- ``` ul { max-height: 250px; overflow-y: scroll; } ```
it is better use another Units for declaring height. "vh" unit can make some problems specially in mobile devices. ``` and also use ul{ overflow-y: scroll; } ```
69,685,355
I'm sorry if that didn't make any sense! I'm very new to python and I could really use some help. I don't want the question to be solved for me, but I would appreciate some advice as a starting point. ``` listA = [("Aleah", [74, 100, 120, 67]), ("Hannah", [95, 110, 110, 67]), ("Timothy...
2021/10/23
[ "https://Stackoverflow.com/questions/69685355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17225072/" ]
You put your listelement inside the same container - so expanding the list would also expand everything. You can put your listelement outside and/or give it an absolute position. Minimal changes can be found here: [codepen](https://codepen.io/coyer/pen/KKvapbv) Basically I wrapped the inputfield in a relative-positio...
This behaviour is because your body's `display:flex` and you have applied `justify-content:space-evenly`. Which automatically adjust the available space between elements. When the suggestions' list appears, it increases the size of your select element and occupies more space on the screen which eventually appears to mo...
69,685,355
I'm sorry if that didn't make any sense! I'm very new to python and I could really use some help. I don't want the question to be solved for me, but I would appreciate some advice as a starting point. ``` listA = [("Aleah", [74, 100, 120, 67]), ("Hannah", [95, 110, 110, 67]), ("Timothy...
2021/10/23
[ "https://Stackoverflow.com/questions/69685355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17225072/" ]
You put your listelement inside the same container - so expanding the list would also expand everything. You can put your listelement outside and/or give it an absolute position. Minimal changes can be found here: [codepen](https://codepen.io/coyer/pen/KKvapbv) Basically I wrapped the inputfield in a relative-positio...
it is better use another Units for declaring height. "vh" unit can make some problems specially in mobile devices. ``` and also use ul{ overflow-y: scroll; } ```
69,685,355
I'm sorry if that didn't make any sense! I'm very new to python and I could really use some help. I don't want the question to be solved for me, but I would appreciate some advice as a starting point. ``` listA = [("Aleah", [74, 100, 120, 67]), ("Hannah", [95, 110, 110, 67]), ("Timothy...
2021/10/23
[ "https://Stackoverflow.com/questions/69685355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17225072/" ]
This behaviour is because your body's `display:flex` and you have applied `justify-content:space-evenly`. Which automatically adjust the available space between elements. When the suggestions' list appears, it increases the size of your select element and occupies more space on the screen which eventually appears to mo...
it is better use another Units for declaring height. "vh" unit can make some problems specially in mobile devices. ``` and also use ul{ overflow-y: scroll; } ```
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
We usually use `$ python3 -m venv myvenv` to create a new virtualenv (Here `myvenv` is the name of our virtualenv). Similar to my case, if you have both `python3.5` as well as `python3.6` on your system, then you might get some errors. **NOTE:** On some versions of Debian/Ubuntu you may receive the following error: ...
Installing `python3.6` and `python3.6-venv` via `ppa:deadsnakes/ppa` instead of `ppa:jonathonf/python-3.6` worked for me ``` apt-get update \ && apt-get install -y software-properties-common curl \ && add-apt-repository ppa:deadsnakes/ppa \ && apt-get update \ && apt-get install -y python3.6 python3.6-venv ```
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
We usually use `$ python3 -m venv myvenv` to create a new virtualenv (Here `myvenv` is the name of our virtualenv). Similar to my case, if you have both `python3.5` as well as `python3.6` on your system, then you might get some errors. **NOTE:** On some versions of Debian/Ubuntu you may receive the following error: ...
I think that a problem could be related to the wrong locale. I added to the `/etc/environment` the following lines to fix it: ``` LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 ``` You need to source the file from you bash with this command: ``` source /etc/environment ```
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
We usually use `$ python3 -m venv myvenv` to create a new virtualenv (Here `myvenv` is the name of our virtualenv). Similar to my case, if you have both `python3.5` as well as `python3.6` on your system, then you might get some errors. **NOTE:** On some versions of Debian/Ubuntu you may receive the following error: ...
First make sure you have python3.6 installed, otherwise you can install it with command: ``` sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt install python3.6 ``` Now install venv i.e ``` sudo apt-get install python3.6-venv python3.6-dev python3.6 -m venv venv_name ``` You can instal...
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
We usually use `$ python3 -m venv myvenv` to create a new virtualenv (Here `myvenv` is the name of our virtualenv). Similar to my case, if you have both `python3.5` as well as `python3.6` on your system, then you might get some errors. **NOTE:** On some versions of Debian/Ubuntu you may receive the following error: ...
if you get following irritating error: ``` E: Unable to locate package python3-venv ``` try this commands: ``` sudo apt-get update sudo apt-get install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.6 ``` those worked for me.hope it helps...
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
Installing `python3.6` and `python3.6-venv` via `ppa:deadsnakes/ppa` instead of `ppa:jonathonf/python-3.6` worked for me ``` apt-get update \ && apt-get install -y software-properties-common curl \ && add-apt-repository ppa:deadsnakes/ppa \ && apt-get update \ && apt-get install -y python3.6 python3.6-venv ```
I think that a problem could be related to the wrong locale. I added to the `/etc/environment` the following lines to fix it: ``` LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 ``` You need to source the file from you bash with this command: ``` source /etc/environment ```
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
Installing `python3.6` and `python3.6-venv` via `ppa:deadsnakes/ppa` instead of `ppa:jonathonf/python-3.6` worked for me ``` apt-get update \ && apt-get install -y software-properties-common curl \ && add-apt-repository ppa:deadsnakes/ppa \ && apt-get update \ && apt-get install -y python3.6 python3.6-venv ```
if you get following irritating error: ``` E: Unable to locate package python3-venv ``` try this commands: ``` sudo apt-get update sudo apt-get install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.6 ``` those worked for me.hope it helps...
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
First make sure you have python3.6 installed, otherwise you can install it with command: ``` sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt install python3.6 ``` Now install venv i.e ``` sudo apt-get install python3.6-venv python3.6-dev python3.6 -m venv venv_name ``` You can instal...
I think that a problem could be related to the wrong locale. I added to the `/etc/environment` the following lines to fix it: ``` LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 ``` You need to source the file from you bash with this command: ``` source /etc/environment ```
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
I think that a problem could be related to the wrong locale. I added to the `/etc/environment` the following lines to fix it: ``` LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 ``` You need to source the file from you bash with this command: ``` source /etc/environment ```
if you get following irritating error: ``` E: Unable to locate package python3-venv ``` try this commands: ``` sudo apt-get update sudo apt-get install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.6 ``` those worked for me.hope it helps...
47,822,740
I'm using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I've installed Python 3.6 on it and symlink python3 to python3.6 through `alias python3=python3.6`. Then, I've installed `virtualenv` using `sudo -H pip3 install virtualenv`. When I checked, the virtualenv got installed in `"/usr/local/lib/python3.5/d...
2017/12/14
[ "https://Stackoverflow.com/questions/47822740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6609613/" ]
First make sure you have python3.6 installed, otherwise you can install it with command: ``` sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt install python3.6 ``` Now install venv i.e ``` sudo apt-get install python3.6-venv python3.6-dev python3.6 -m venv venv_name ``` You can instal...
if you get following irritating error: ``` E: Unable to locate package python3-venv ``` try this commands: ``` sudo apt-get update sudo apt-get install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.6 ``` those worked for me.hope it helps...
14,110,709
Using the python library matplotlib, I've found what suggests to be a solution to this question: [Displaying (nicely) an algebraic expression in PyQt](https://stackoverflow.com/questions/14097463/displaying-nicely-an-algebraic-expression-in-pyqt) by utilising matplotlibs [TeX markup](http://matplotlib.org/users/math...
2013/01/01
[ "https://Stackoverflow.com/questions/14110709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/848292/" ]
The trick is to render the text, then get its bounding box, and finally adjust the figure size and the vertical positioning of text in the new figure. This saves the figure twice, but as is common in any text engine, the correct bounding box and other parameters can only be correctly obtained after the text has been re...
what about ``` import matplotlib.pyplot as plt params = { 'figure.figsize': [2,2], } plt.rcParams.update(params) formula = r'$x=\frac{3}{100}$' fig = plt.figure() fig.text(0.5,0.5,formula) plt.savefig('formula.png') ``` The first two arguments of the matplotlib text() function set the position of the ...
14,110,709
Using the python library matplotlib, I've found what suggests to be a solution to this question: [Displaying (nicely) an algebraic expression in PyQt](https://stackoverflow.com/questions/14097463/displaying-nicely-an-algebraic-expression-in-pyqt) by utilising matplotlibs [TeX markup](http://matplotlib.org/users/math...
2013/01/01
[ "https://Stackoverflow.com/questions/14110709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/848292/" ]
The text in the figure can be placed correctly using `figure.suptitle` and specifying sensible alignments, such that the text sits in the top left corner and runs down and to the right (relative to the x and y coordinates specified). ``` fig = plt.Figure() fig.suptitle('TeX', horizontalalignment = 'left'...
what about ``` import matplotlib.pyplot as plt params = { 'figure.figsize': [2,2], } plt.rcParams.update(params) formula = r'$x=\frac{3}{100}$' fig = plt.figure() fig.text(0.5,0.5,formula) plt.savefig('formula.png') ``` The first two arguments of the matplotlib text() function set the position of the ...
14,110,709
Using the python library matplotlib, I've found what suggests to be a solution to this question: [Displaying (nicely) an algebraic expression in PyQt](https://stackoverflow.com/questions/14097463/displaying-nicely-an-algebraic-expression-in-pyqt) by utilising matplotlibs [TeX markup](http://matplotlib.org/users/math...
2013/01/01
[ "https://Stackoverflow.com/questions/14110709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/848292/" ]
The trick is to render the text, then get its bounding box, and finally adjust the figure size and the vertical positioning of text in the new figure. This saves the figure twice, but as is common in any text engine, the correct bounding box and other parameters can only be correctly obtained after the text has been re...
The text in the figure can be placed correctly using `figure.suptitle` and specifying sensible alignments, such that the text sits in the top left corner and runs down and to the right (relative to the x and y coordinates specified). ``` fig = plt.Figure() fig.suptitle('TeX', horizontalalignment = 'left'...
23,012,931
How to generate something like ``` [(), (1,), (1,2), (1,2,3)..., (1,2,3,...n)] ``` and ``` [(), (4,), (4,5), (4,5,6)..., (4,5,6,...m)] ``` then take the product of them and merge into ``` [(), (1,), (1,4), (1,4,5), (1,4,5,6), (1,2), (1,2,4)....(1,2,3,...n,4,5,6,...m)] ``` ? For the first two lists I've tried ...
2014/04/11
[ "https://Stackoverflow.com/questions/23012931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1886382/" ]
Please note that, single element tuples are denoted like this `(1,)`. ``` a = [(), (1,), (1, 2), (1, 2, 3)] b = [(), (4,), (4, 5), (4, 5, 6)] from itertools import product for item1, item2 in product(a, b): print item1 + item2 ``` **Output** ``` () (4,) (4, 5) (4, 5, 6) (1,) (1, 4) (1, 4, 5) (1, 4, 5, 6) (1, 2...
If you don't want to use any special imports: ``` start = 1; limit = 10 [ range(start, start + x) for x in range(limit) ] ``` With `start = 1` the output is: `[[], [1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9...
23,012,931
How to generate something like ``` [(), (1,), (1,2), (1,2,3)..., (1,2,3,...n)] ``` and ``` [(), (4,), (4,5), (4,5,6)..., (4,5,6,...m)] ``` then take the product of them and merge into ``` [(), (1,), (1,4), (1,4,5), (1,4,5,6), (1,2), (1,2,4)....(1,2,3,...n,4,5,6,...m)] ``` ? For the first two lists I've tried ...
2014/04/11
[ "https://Stackoverflow.com/questions/23012931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1886382/" ]
Please note that, single element tuples are denoted like this `(1,)`. ``` a = [(), (1,), (1, 2), (1, 2, 3)] b = [(), (4,), (4, 5), (4, 5, 6)] from itertools import product for item1, item2 in product(a, b): print item1 + item2 ``` **Output** ``` () (4,) (4, 5) (4, 5, 6) (1,) (1, 4) (1, 4, 5) (1, 4, 5, 6) (1, 2...
You can try like this, ``` >>> a=[(), (1,), (1,2), (1,2,3)] >>> b=[(), (4,), (4,5), (4,5,6)] >>> for ix in a: ... for iy in b: ... print ix + iy ... () (4,) (4, 5) (4, 5, 6) (1,) (1, 4) (1, 4, 5) (1, 4, 5, 6) (1, 2) (1, 2, 4) (1, 2, 4, 5) (1, 2, 4, 5, 6) (1, 2, 3) (1, 2, 3, 4) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5, 6...
15,920,413
I have a large ASCII file (~100GB) which consists of roughly 1.000.000 lines of known formatted numbers which I try to process with python. The file is too large to read in completely into memory, so I decided to process the file line by line: ``` fp = open(file_name) for count,line in enumerate(fp): data = np.arr...
2013/04/10
[ "https://Stackoverflow.com/questions/15920413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2010845/" ]
Have you tried [`numpyp.fromstring`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.fromstring.html)? ``` np.fromstring(line, dtype=np.float, sep=" ") ```
The [*np.genfromtxt*](http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html) function is a speed champion if you can get it to match you input format. If not, then you may already be using the fastest method. Your line-by-line split-into-array approach exactly matches the [SciPy Cookbook examples](...