qid int64 46k 74.7M | question stringlengths 54 37.8k | date stringlengths 10 10 | metadata listlengths 3 3 | response_j stringlengths 17 26k | response_k stringlengths 26 26k |
|---|---|---|---|---|---|
820,671 | I want to create an object in python that has a few attributes and I want to protect myself from accidentally using the wrong attribute name. The code is as follows:
```
class MyClass( object ) :
m = None # my attribute
__slots__ = ( "m" ) # ensure that object has no _m etc
a = MyClass() # create one
a.m = "?... | 2009/05/04 | [
"https://Stackoverflow.com/questions/820671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69882/"
] | `__slots__` works with instance variables, whereas what you have there is a class variable. This is how you should be doing it:
```
class MyClass( object ) :
__slots__ = ( "m", )
def __init__(self):
self.m = None
a = MyClass()
a.m = "?" # No error
``` | ```
class MyClass( object ) :
m = None # my attribute
```
The `m` here is the class attributes, rather than the instance attribute. You need to connect it with your instance by self in `__init__`. |
820,671 | I want to create an object in python that has a few attributes and I want to protect myself from accidentally using the wrong attribute name. The code is as follows:
```
class MyClass( object ) :
m = None # my attribute
__slots__ = ( "m" ) # ensure that object has no _m etc
a = MyClass() # create one
a.m = "?... | 2009/05/04 | [
"https://Stackoverflow.com/questions/820671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69882/"
] | When you declare instance variables using `__slots__`, Python creates a [descriptor object](https://docs.python.org/2/howto/descriptor.html) as a class variable with the same name. In your case, this descriptor is overwritten by the class variable `m` that you are defining at the following line:
```
m = None # my at... | Consider this.
```
class SuperSafe( object ):
allowed= ( "this", "that" )
def __init__( self ):
self.this= None
self.that= None
def __setattr__( self, attr, value ):
if attr not in self.allowed:
raise Exception( "No such attribute: %s" % (attr,) )
super( SuperSaf... |
820,671 | I want to create an object in python that has a few attributes and I want to protect myself from accidentally using the wrong attribute name. The code is as follows:
```
class MyClass( object ) :
m = None # my attribute
__slots__ = ( "m" ) # ensure that object has no _m etc
a = MyClass() # create one
a.m = "?... | 2009/05/04 | [
"https://Stackoverflow.com/questions/820671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69882/"
] | When you declare instance variables using `__slots__`, Python creates a [descriptor object](https://docs.python.org/2/howto/descriptor.html) as a class variable with the same name. In your case, this descriptor is overwritten by the class variable `m` that you are defining at the following line:
```
m = None # my at... | You are completely misusing `__slots__`. It prevents the creation of `__dict__` for the instances. This only makes sense if you run into memory problems with many small objects, because getting rid of `__dict__` can reduce the footprint. This is a hardcore optimization that is not needed in 99.9% of all cases.
If you ... |
820,671 | I want to create an object in python that has a few attributes and I want to protect myself from accidentally using the wrong attribute name. The code is as follows:
```
class MyClass( object ) :
m = None # my attribute
__slots__ = ( "m" ) # ensure that object has no _m etc
a = MyClass() # create one
a.m = "?... | 2009/05/04 | [
"https://Stackoverflow.com/questions/820671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69882/"
] | When you declare instance variables using `__slots__`, Python creates a [descriptor object](https://docs.python.org/2/howto/descriptor.html) as a class variable with the same name. In your case, this descriptor is overwritten by the class variable `m` that you are defining at the following line:
```
m = None # my at... | ```
class MyClass( object ) :
m = None # my attribute
```
The `m` here is the class attributes, rather than the instance attribute. You need to connect it with your instance by self in `__init__`. |
820,671 | I want to create an object in python that has a few attributes and I want to protect myself from accidentally using the wrong attribute name. The code is as follows:
```
class MyClass( object ) :
m = None # my attribute
__slots__ = ( "m" ) # ensure that object has no _m etc
a = MyClass() # create one
a.m = "?... | 2009/05/04 | [
"https://Stackoverflow.com/questions/820671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69882/"
] | Consider this.
```
class SuperSafe( object ):
allowed= ( "this", "that" )
def __init__( self ):
self.this= None
self.that= None
def __setattr__( self, attr, value ):
if attr not in self.allowed:
raise Exception( "No such attribute: %s" % (attr,) )
super( SuperSaf... | ```
class MyClass( object ) :
m = None # my attribute
```
The `m` here is the class attributes, rather than the instance attribute. You need to connect it with your instance by self in `__init__`. |
820,671 | I want to create an object in python that has a few attributes and I want to protect myself from accidentally using the wrong attribute name. The code is as follows:
```
class MyClass( object ) :
m = None # my attribute
__slots__ = ( "m" ) # ensure that object has no _m etc
a = MyClass() # create one
a.m = "?... | 2009/05/04 | [
"https://Stackoverflow.com/questions/820671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69882/"
] | You are completely misusing `__slots__`. It prevents the creation of `__dict__` for the instances. This only makes sense if you run into memory problems with many small objects, because getting rid of `__dict__` can reduce the footprint. This is a hardcore optimization that is not needed in 99.9% of all cases.
If you ... | ```
class MyClass( object ) :
m = None # my attribute
```
The `m` here is the class attributes, rather than the instance attribute. You need to connect it with your instance by self in `__init__`. |
30,252,726 | I am generating pdf using html template with python `pisa.CreatePDF` API,
It works well with small html, but in case of huge html it takes lot of time. Is there any alternative ? | 2015/05/15 | [
"https://Stackoverflow.com/questions/30252726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2373367/"
] | I did few changes in html which results pisa.createPDF works fast for me.
I am using html of almost **2 MB**, contains single table with almost more than **10,000 rows**. So I break them into multiple tables and tried again. Its surprised me, initially with single table it took almost **40 minutes (2590 seconds)** to g... | You can try [pdfkit](https://pypi.python.org/pypi/pdfkit):
```
import pdfkit
pdfkit.from_file('test.html', 'out.pdf')
```
Also see [this question](https://stackoverflow.com/q/23359083/3489230) which describes solutions using PyQt. |
51,271,225 | header
output:
```
array(['Subject_ID', 'tube_label', 'sample_#', 'Relabel',
'sample_ID','cortisol_value', 'Group'], dtype='<U14')
```
body
output:
```
array([['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC'],], dtype=object)
testing = np.concaten... | 2018/07/10 | [
"https://Stackoverflow.com/questions/51271225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10029062/"
] | You need to align array dimensions first. You are currently trying to combine 1-dimensional and 2-dimensional arrays. After alignment, you can use [`numpy.vstack`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.vstack.html).
Note `np.array([A]).shape` returns `(1, 7)`, while `B.shape` returns `(2, 7)`. A m... | Look at numpy.vstack and hstack, as well as the axis argument in np.append. Here it looks like you want vstack (i.e. the output array will have 3 columns, each with the same number of rows). You can also look into numpy.reshape, to change the shape of the input arrays so you can concatenate them. |
51,271,225 | header
output:
```
array(['Subject_ID', 'tube_label', 'sample_#', 'Relabel',
'sample_ID','cortisol_value', 'Group'], dtype='<U14')
```
body
output:
```
array([['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC'],], dtype=object)
testing = np.concaten... | 2018/07/10 | [
"https://Stackoverflow.com/questions/51271225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10029062/"
] | You're right in trying to use [`numpy.concatenate()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html) but you've to *promote* the first array to 2D before concatenating. Here's a simple example:
```
In [1]: import numpy as np
In [2]: arr1 = np.array(['Subject_ID', 'tube_label', 'sample_#'... | You need to align array dimensions first. You are currently trying to combine 1-dimensional and 2-dimensional arrays. After alignment, you can use [`numpy.vstack`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.vstack.html).
Note `np.array([A]).shape` returns `(1, 7)`, while `B.shape` returns `(2, 7)`. A m... |
51,271,225 | header
output:
```
array(['Subject_ID', 'tube_label', 'sample_#', 'Relabel',
'sample_ID','cortisol_value', 'Group'], dtype='<U14')
```
body
output:
```
array([['STM002', '170714_STM002_1', 1, 1, 1, 1.98, 'HC'],
['STM002', '170714_STM002_2', 2, 2, 2, 2.44, 'HC'],], dtype=object)
testing = np.concaten... | 2018/07/10 | [
"https://Stackoverflow.com/questions/51271225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10029062/"
] | You're right in trying to use [`numpy.concatenate()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html) but you've to *promote* the first array to 2D before concatenating. Here's a simple example:
```
In [1]: import numpy as np
In [2]: arr1 = np.array(['Subject_ID', 'tube_label', 'sample_#'... | Look at numpy.vstack and hstack, as well as the axis argument in np.append. Here it looks like you want vstack (i.e. the output array will have 3 columns, each with the same number of rows). You can also look into numpy.reshape, to change the shape of the input arrays so you can concatenate them. |
67,044,398 | to import the absolute path from my laptop I type:
==================================================
```
import os
print(os.getcwd())
```
he gives me the path no problem, but when I create a Document "ayoub.txt" in the path absolute, and I #call this document with:
================================================... | 2021/04/11 | [
"https://Stackoverflow.com/questions/67044398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14819475/"
] | I ran your code with some dummy data, the `cast<String>` for `categories` works for me. However, you have not added the cast to `skills` and `otherLanguages`. Have you checked the line number of the error? If the problem is definitely with `categories`, could you please add some sample data to the question. | Try to replace `List<String> categories, skills, otherLanguages;` to dynamic and remove the casting
`List<dynamic> categories, skills, otherLanguages;` |
43,716,699 | ```
python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x03BBC1F0>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\d... | 2017/05/01 | [
"https://Stackoverflow.com/questions/43716699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7946534/"
] | You seem to have installed the JWT package, which is only compatible with Python 3.4+. The rest-framework-jwt app is trying to import that rather than PyJWT which is compatible with 2.7.
Remove that installation with `pip uninstall jwt`. Once removed you'll want to install PyJWT like so:
```
pip install PyJWT
``` | Not need to uninstall jwt. Just upgrade your PyJWT
```
pip install PyJWT --upgrade
``` |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | [@nosklo's twisted-based solution](https://stackoverflow.com/a/1507370/8053001) is elegant and workable, but if you want to avoid the dependency on twisted, the task is still doable, e.g:
```
import multiprocessing
def query_with_timeout(dbc, timeout, query, *a, **k):
conn1, conn2 = multiprocessing.Pipe(False)
su... | Use [adbapi](http://twistedmatrix.com/documents/current/api/twisted.enterprise.adbapi.html). It allows you to do a db call asynchronously.
```
from twisted.internet import reactor
from twisted.enterprise import adbapi
def bogusQuery():
return dbpool.runQuery("SELECT SLEEP(10)")
def printResult(l):
# function... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | [@nosklo's twisted-based solution](https://stackoverflow.com/a/1507370/8053001) is elegant and workable, but if you want to avoid the dependency on twisted, the task is still doable, e.g:
```
import multiprocessing
def query_with_timeout(dbc, timeout, query, *a, **k):
conn1, conn2 = multiprocessing.Pipe(False)
su... | ### Generic notes
I've experienced the same issue lately with several conditions I had to met:
* solution must be thread safe
* multiple connections to database from the same machine may be active at the same time, kill the exact one connection/query
* application contains connections to many different databases - po... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | Use [adbapi](http://twistedmatrix.com/documents/current/api/twisted.enterprise.adbapi.html). It allows you to do a db call asynchronously.
```
from twisted.internet import reactor
from twisted.enterprise import adbapi
def bogusQuery():
return dbpool.runQuery("SELECT SLEEP(10)")
def printResult(l):
# function... | >
> Why do I not get the signal until after execute finishes?
>
>
>
The process waiting for network I/O is in an uninterruptible state (UNIX thing, not related to Python or MySQL). It gets the signal after the system call finishes (probably as `EINTR` error code, although I am not sure).
>
> Is there another rel... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | Use [adbapi](http://twistedmatrix.com/documents/current/api/twisted.enterprise.adbapi.html). It allows you to do a db call asynchronously.
```
from twisted.internet import reactor
from twisted.enterprise import adbapi
def bogusQuery():
return dbpool.runQuery("SELECT SLEEP(10)")
def printResult(l):
# function... | >
> Why do I not get the signal until after execute finishes?
>
>
>
The query is executed through a C function, which blocks the Python VM from executing until it returns.
>
> Is there another reliable way to limit query execution time?
>
>
>
This is (IMO) a really ugly solution, but it *does* work. You coul... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | [@nosklo's twisted-based solution](https://stackoverflow.com/a/1507370/8053001) is elegant and workable, but if you want to avoid the dependency on twisted, the task is still doable, e.g:
```
import multiprocessing
def query_with_timeout(dbc, timeout, query, *a, **k):
conn1, conn2 = multiprocessing.Pipe(False)
su... | >
> I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does not get caught until after the call to execute finishes.
>
>
>
mysql library handles interrupted systems calls internally so you won't see side effects of SIGALRM until after API cal... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | >
> I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does not get caught until after the call to execute finishes.
>
>
>
mysql library handles interrupted systems calls internally so you won't see side effects of SIGALRM until after API cal... | >
> Why do I not get the signal until after execute finishes?
>
>
>
The query is executed through a C function, which blocks the Python VM from executing until it returns.
>
> Is there another reliable way to limit query execution time?
>
>
>
This is (IMO) a really ugly solution, but it *does* work. You coul... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | >
> I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does not get caught until after the call to execute finishes.
>
>
>
mysql library handles interrupted systems calls internally so you won't see side effects of SIGALRM until after API cal... | ### Generic notes
I've experienced the same issue lately with several conditions I had to met:
* solution must be thread safe
* multiple connections to database from the same machine may be active at the same time, kill the exact one connection/query
* application contains connections to many different databases - po... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | ### Generic notes
I've experienced the same issue lately with several conditions I had to met:
* solution must be thread safe
* multiple connections to database from the same machine may be active at the same time, kill the exact one connection/query
* application contains connections to many different databases - po... | >
> Why do I not get the signal until after execute finishes?
>
>
>
The process waiting for network I/O is in an uninterruptible state (UNIX thing, not related to Python or MySQL). It gets the signal after the system call finishes (probably as `EINTR` error code, although I am not sure).
>
> Is there another rel... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | >
> Why do I not get the signal until after execute finishes?
>
>
>
The query is executed through a C function, which blocks the Python VM from executing until it returns.
>
> Is there another reliable way to limit query execution time?
>
>
>
This is (IMO) a really ugly solution, but it *does* work. You coul... | >
> Why do I not get the signal until after execute finishes?
>
>
>
The process waiting for network I/O is in an uninterruptible state (UNIX thing, not related to Python or MySQL). It gets the signal after the system call finishes (probably as `EINTR` error code, although I am not sure).
>
> Is there another rel... |
1,507,091 | I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does no... | 2009/10/01 | [
"https://Stackoverflow.com/questions/1507091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4678/"
] | [@nosklo's twisted-based solution](https://stackoverflow.com/a/1507370/8053001) is elegant and workable, but if you want to avoid the dependency on twisted, the task is still doable, e.g:
```
import multiprocessing
def query_with_timeout(dbc, timeout, query, *a, **k):
conn1, conn2 = multiprocessing.Pipe(False)
su... | >
> Why do I not get the signal until after execute finishes?
>
>
>
The process waiting for network I/O is in an uninterruptible state (UNIX thing, not related to Python or MySQL). It gets the signal after the system call finishes (probably as `EINTR` error code, although I am not sure).
>
> Is there another rel... |
17,213,455 | Im kind of new to python. Im trying to remove the first sentence from a string using the full stop as the delimiter. Is split the right method to be using in this instance? Im not getting the desired result...
```
def get_summary(self):
if self.description:
s2 = self.description.split('.', 1)[1]
r... | 2013/06/20 | [
"https://Stackoverflow.com/questions/17213455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2342568/"
] | You can use [`String.split`](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String%29):
```
String cmd = "command atr1 art22 atr333 art4444";
String[] parts = cmd.split(" ");
```
The split method permits using a regular expression. This is useful for example if the amount of whitesp... | Here a few options, sorted from easy/annoying-in-the-end to powerful/hard-to-learn
* "your command pattern".split( " " ) gives you an array of strings
* [`java.util.Scanner`](http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html) lets you take out one token after the other, and it has some handy helpers ... |
17,213,455 | Im kind of new to python. Im trying to remove the first sentence from a string using the full stop as the delimiter. Is split the right method to be using in this instance? Im not getting the desired result...
```
def get_summary(self):
if self.description:
s2 = self.description.split('.', 1)[1]
r... | 2013/06/20 | [
"https://Stackoverflow.com/questions/17213455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2342568/"
] | You can use [`String.split`](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String%29):
```
String cmd = "command atr1 art22 atr333 art4444";
String[] parts = cmd.split(" ");
```
The split method permits using a regular expression. This is useful for example if the amount of whitesp... | Or try [this](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/StringTokenizer.html) StringTokenizer class
```
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
``` |
17,213,455 | Im kind of new to python. Im trying to remove the first sentence from a string using the full stop as the delimiter. Is split the right method to be using in this instance? Im not getting the desired result...
```
def get_summary(self):
if self.description:
s2 = self.description.split('.', 1)[1]
r... | 2013/06/20 | [
"https://Stackoverflow.com/questions/17213455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2342568/"
] | Here a few options, sorted from easy/annoying-in-the-end to powerful/hard-to-learn
* "your command pattern".split( " " ) gives you an array of strings
* [`java.util.Scanner`](http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html) lets you take out one token after the other, and it has some handy helpers ... | Or try [this](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/StringTokenizer.html) StringTokenizer class
```
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
``` |
44,486,483 | So I've begun working on this little translator program that translates English to German with an input. However, when I enter more than one word I get the words I've entered, followed by the correct translation.
This is what I have so far:
```
data = [input()]
dictionary = {'i':'ich', 'am':'bin', 'a':'ein', 'studen... | 2017/06/11 | [
"https://Stackoverflow.com/questions/44486483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8144709/"
] | Changing your code to this should provide a first step to what you're looking for.
```
data = raw_input()
dictionary = {'i':'ich', 'am':'bin', 'a':'ein', 'student':'schueler', 'of':'der', 'german':'deutschen', 'language': 'sprache'}
from itertools import takewhile
def find_suffix(s):
return ''.join(takewhile(str... | ```
data = [input()]
dictionary = {'i':'ich', 'am':'bin', 'a':'ein', 'student':'schueler', 'of the':'der', 'german':'deutschen', 'language': 'sprache'}
for word in data:
if word in dictionary:
print dictionary[word],
```
Explanation:
for every word in your input if that word in present in your dictiona... |
44,486,483 | So I've begun working on this little translator program that translates English to German with an input. However, when I enter more than one word I get the words I've entered, followed by the correct translation.
This is what I have so far:
```
data = [input()]
dictionary = {'i':'ich', 'am':'bin', 'a':'ein', 'studen... | 2017/06/11 | [
"https://Stackoverflow.com/questions/44486483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8144709/"
] | Changing your code to this should provide a first step to what you're looking for.
```
data = raw_input()
dictionary = {'i':'ich', 'am':'bin', 'a':'ein', 'student':'schueler', 'of':'der', 'german':'deutschen', 'language': 'sprache'}
from itertools import takewhile
def find_suffix(s):
return ''.join(takewhile(str... | I have noticed two things in your `input`. First thing is that you can have two words to be translated into one (two word `key` in `dictionary`) and the other thing is that `input` can have german words that shouldn't be translated. Having those two conditions I think the best approach is to `split()` the `input` and `... |
63,826,975 | I get the following error when I want to import matplotlib.pyplot on the Visual Studio's jupyter-notebook.
```
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 import matplotlib.pyplot as plt
~/minicond... | 2020/09/10 | [
"https://Stackoverflow.com/questions/63826975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12409079/"
] | If you want all Gold customers, then `Customers` should be the first table in the `LEFT JOIN`. There is also no need for a subquery on `customers`. However, MS Access does want one on `Transactions`:
```
SELECT c.CustId, NZ(SUM(t.Value)) AS Total
FROM Customers as c LEFT JOIN
(SELECT t.*
FROM Transactions a... | ***Edit:*** Simplified query
```
SELECT Customers.CustID, Sum(Transactions.tValue) AS Total
FROM Customers LEFT JOIN Transactions ON Customers.CustID = Transactions.CustID
WHERE (Transactions.xDate BETWEEN #2020/01/03# AND #2020/01/04#) AND (Customers.CustType='Gold')
GROUP BY Customers.CustID;
```
You can sum total... |
63,826,975 | I get the following error when I want to import matplotlib.pyplot on the Visual Studio's jupyter-notebook.
```
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 import matplotlib.pyplot as plt
~/minicond... | 2020/09/10 | [
"https://Stackoverflow.com/questions/63826975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12409079/"
] | If you want all Gold customers, then `Customers` should be the first table in the `LEFT JOIN`. There is also no need for a subquery on `customers`. However, MS Access does want one on `Transactions`:
```
SELECT c.CustId, NZ(SUM(t.Value)) AS Total
FROM Customers as c LEFT JOIN
(SELECT t.*
FROM Transactions a... | Consider:
Query1:
```
SELECT CustId, SUM(Value) AS Total
FROM Transactions
WHERE xDate BETWEEN #2020/02/01# AND #2020/03/01#
GROUP BY CustId;
```
Query2:
```
SELECT Customers.CustID, Query1.Total
FROM Customers LEFT JOIN Query1 ON Customers.CustID = Query1.CustId
WHERE (((Customers.[CustType])="Gold"));
``` |
63,826,975 | I get the following error when I want to import matplotlib.pyplot on the Visual Studio's jupyter-notebook.
```
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 import matplotlib.pyplot as plt
~/minicond... | 2020/09/10 | [
"https://Stackoverflow.com/questions/63826975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12409079/"
] | If you want all Gold customers, then `Customers` should be the first table in the `LEFT JOIN`. There is also no need for a subquery on `customers`. However, MS Access does want one on `Transactions`:
```
SELECT c.CustId, NZ(SUM(t.Value)) AS Total
FROM Customers as c LEFT JOIN
(SELECT t.*
FROM Transactions a... | `LEFT OUTER JOIN` is just called `LEFT JOIN` with Access-SQL, and works generally as expected.
See [here](https://support.microsoft.com/en-us/office/left-join-right-join-operations-ebb18b36-7976-4c6e-9ea1-c701e9f7f5fb#:%7E:text=Use%20a%20LEFT%20JOIN%20operation,create%20a%20right%20outer%20join.) for more information ... |
34,783,867 | I have two pandas series like following.
```
bulk_order_id
Out[283]:
3 523
Name: order_id, dtype: object
```
and
```
luster_6_loc
Out[285]:
3 Cluster 3
Name: Clusters, dtype: object
```
Now I want a new series which would look like this.
```
Cluster 3 523
```
I am doing following in python
```
cluste... | 2016/01/14 | [
"https://Stackoverflow.com/questions/34783867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2927983/"
] | You could pass to `pd.Series` values of `luster_6_loc` as index and values of `bulk_order_id` as values:
```
bulk_order_id = pd.Series(523, index=[3])
cluster_6_loc= pd.Series('Cluster 3', index=[3])
cluster_final = pd.Series(bulk_order_id.values, cluster_6_loc.values)
In [149]: cluster_final
Out[149]:
Cluster 3 ... | Not sure whether I'm understanding your question correctly, but what's wrong with `pd.concat()` ([see docs](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html)):
```
s1 = pd.Series(data=['523'], index=[3])
3 523
dtype: object
s2 = pd.Series(data=['Cluster 3'], index=[3])
3 Cluster 3
dtyp... |
34,783,867 | I have two pandas series like following.
```
bulk_order_id
Out[283]:
3 523
Name: order_id, dtype: object
```
and
```
luster_6_loc
Out[285]:
3 Cluster 3
Name: Clusters, dtype: object
```
Now I want a new series which would look like this.
```
Cluster 3 523
```
I am doing following in python
```
cluste... | 2016/01/14 | [
"https://Stackoverflow.com/questions/34783867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2927983/"
] | Maybe better is use [`concat`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html) and [`set_index`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html):
```
print bulk_order_id
1 523
2 528
3 527
4 573
Name: order_id, dtype: object
print cluster_6_... | Not sure whether I'm understanding your question correctly, but what's wrong with `pd.concat()` ([see docs](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html)):
```
s1 = pd.Series(data=['523'], index=[3])
3 523
dtype: object
s2 = pd.Series(data=['Cluster 3'], index=[3])
3 Cluster 3
dtyp... |
34,783,867 | I have two pandas series like following.
```
bulk_order_id
Out[283]:
3 523
Name: order_id, dtype: object
```
and
```
luster_6_loc
Out[285]:
3 Cluster 3
Name: Clusters, dtype: object
```
Now I want a new series which would look like this.
```
Cluster 3 523
```
I am doing following in python
```
cluste... | 2016/01/14 | [
"https://Stackoverflow.com/questions/34783867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2927983/"
] | Maybe better is use [`concat`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html) and [`set_index`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.set_index.html):
```
print bulk_order_id
1 523
2 528
3 527
4 573
Name: order_id, dtype: object
print cluster_6_... | You could pass to `pd.Series` values of `luster_6_loc` as index and values of `bulk_order_id` as values:
```
bulk_order_id = pd.Series(523, index=[3])
cluster_6_loc= pd.Series('Cluster 3', index=[3])
cluster_final = pd.Series(bulk_order_id.values, cluster_6_loc.values)
In [149]: cluster_final
Out[149]:
Cluster 3 ... |
67,434,998 | I'm new to python / pandas. I've got multiple csv files in a directory. I want to remove duplicates in all the files and save new files to another directory.
Below is what I've tried:
```
import pandas as pd
import glob
list_files = (glob.glob("directory path/*.csv"))
for file in list_files:
df = pd.read_csv(file... | 2021/05/07 | [
"https://Stackoverflow.com/questions/67434998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15862144/"
] | The problem is because of the `{}` that are around your file, pandas thinks that the first level of the JSON are the columns and thus it uses just Browser History as a column. You can use this code to solve your problem:
```
import pandas as pd
df = pd.DataFrame(json.load(open('BrowserHistory.json', encoding='cp850'))... | Because your objects are in a list at the second level down of your JSON, you can't read it directly into a dataframe using `read_json`. Instead, you could read the json into a variable, and then create the dataframe from that:
```py
import pandas as pd
import json
f = open("BrowserHistory.json")
js = json.load(f)
df... |
52,949,128 | I'm doing a project that involves analyzing WhatsApp log data.
After preprocessing the log file I have a table that looks like this:
```
DD/MM/YY | hh:mm | name | text |
```
I could build a graph where, using a chat with a friend of mine, I plotted a graph of the number of text per month and the mean number of word... | 2018/10/23 | [
"https://Stackoverflow.com/questions/52949128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8425613/"
] | Suppose that the table you have is a .csv file that looks like this (call it msgs.csv):
```
date;time;name;text
22/10/2018;11:30;Maria;Hello how are you
23/10/2018;11:30;Justin;Check this
23/10/2018;11:31;Justin;link
22/11/2018;11:30;Maria;Hello how are you
23/11/2018;11:30;Justin;Check this
23/12/2018;11:31;Justin;li... | It's best to convert the strings into datetime objects
```
from datetime import datetime
datetime_object = datetime.strptime('22/10/18', '%d/%m/%y')
```
When converting from a string, remember to use the correct seperators, ie "-" or "/" to match the string, and the letters in the format template on the right hand ... |
52,949,128 | I'm doing a project that involves analyzing WhatsApp log data.
After preprocessing the log file I have a table that looks like this:
```
DD/MM/YY | hh:mm | name | text |
```
I could build a graph where, using a chat with a friend of mine, I plotted a graph of the number of text per month and the mean number of word... | 2018/10/23 | [
"https://Stackoverflow.com/questions/52949128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8425613/"
] | Suppose that the table you have is a .csv file that looks like this (call it msgs.csv):
```
date;time;name;text
22/10/2018;11:30;Maria;Hello how are you
23/10/2018;11:30;Justin;Check this
23/10/2018;11:31;Justin;link
22/11/2018;11:30;Maria;Hello how are you
23/11/2018;11:30;Justin;Check this
23/12/2018;11:31;Justin;li... | A simple solution for adding missing dates and plotting the mean value of msg\_len is to create a date range your interested in then reindex:
```
df.set_index('date', inplace=True)
df1 = df[['msg_len','year']]
df1.index = df1.index.to_period('m')
msg_len year
date
2016-08 11 2016
2016-08 ... |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | In the **Language** menu select your corresponding language. For example **H** and then **html** | 1. Check, if you have saved the documents as .HTML and not as .txt
2. in the menu, choose Settings>Style configurator...
and in the list in the left pan select html, check if the colors for different tags are being shown in the color blocks. if yes, chosse a font and then save and exit.
3. Check only after you save the... |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | In the **Language** menu select your corresponding language. For example **H** and then **html** | The language setting solved the issue for (all) 3 Javascript files (.js) which suffered from it, which previously were all recognized correctly as Javascript. For some reason it forgot they were Javascript files apparently!? |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | I had the same problem and discovered it was because I had enabled global foreground color under Global Styles. | 1. Check, if you have saved the documents as .HTML and not as .txt
2. in the menu, choose Settings>Style configurator...
and in the list in the left pan select html, check if the colors for different tags are being shown in the color blocks. if yes, chosse a font and then save and exit.
3. Check only after you save the... |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | I had the same problem (I Googled "notepad++ file coloring quit" to find this discussion.) In my case the coloring quit mid file in a single file. I finally realized that adjacent string literals with one of them a macro was fooling Notepad++.
My code that broke it read:
Write\_Supplemental\_Configuration(privateData-... | If the coloring only stopped working for one file, you should check the extension name of your file. You might have accidentally saved the file as .txt |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | I had the same problem and discovered it was because I had enabled global foreground color under Global Styles. | First type any thing and Save the file in any format you are working with (i-e; .cpp if c++, .js if JavaScript....etc)
And make sure global foreground color is disabled.
And it should work fine. |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | In the **Language** menu select your corresponding language. For example **H** and then **html** | First type any thing and Save the file in any format you are working with (i-e; .cpp if c++, .js if JavaScript....etc)
And make sure global foreground color is disabled.
And it should work fine. |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | Make sure that when you save the file it's saved as an **.html** instead of a **.txt**. This make a difference because the **.html** allows you to see the different colour codes whereas **.txt** doesn't. | If the coloring only stopped working for one file, you should check the extension name of your file. You might have accidentally saved the file as .txt |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | Try out the following:
1. Select a language manually from the "Languages" menu.
2. In Settings/Preferences, check the File Associatons.
3. In worst case, reinstall. | Got to Setting -> Style Configuration and remove the global style checkbox
[](https://i.stack.imgur.com/JjGhl.png) |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | I had the same problem (I Googled "notepad++ file coloring quit" to find this discussion.) In my case the coloring quit mid file in a single file. I finally realized that adjacent string literals with one of them a macro was fooling Notepad++.
My code that broke it read:
Write\_Supplemental\_Configuration(privateData-... | If you want to display text in SQL format, then in menu select Language => S => SQL |
6,324,412 | After answering a question here on SO about finding a city in a
user-supplied question, I started thinking about the *best* way to
search for a string in a text when you have a limited data-set as this one.
`in` and `find` matches against a substring, which is not wanted. Reqular
expressions using "word boundaries" wo... | 2011/06/12 | [
"https://Stackoverflow.com/questions/6324412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297323/"
] | I had the same problem and discovered it was because I had enabled global foreground color under Global Styles. | Have a look in Settings -> Style Configurator. Maybe your styles got messed up somehow. You could try changing the selected style to see if it makes a difference.
I think the saved styles are stored in the "themes" directory under your Notepad++ installation directory, so you could also check that the files have not b... |
63,781,794 | I got this error message when I was installing python-binance.
Error message is in the link below please check
<https://docs.google.com/document/d/1VE0Ux_ji9RoK0NIrPD3BSbs60sTaxThk3boxsvh051c/edit>
Anyone knows how to fix it? | 2020/09/07 | [
"https://Stackoverflow.com/questions/63781794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14236836/"
] | You're trying to install [`email` from PyPI](https://pypi.org/project/email/) which is a very old outdated Python2-only package.
`email` is now [a module in the stdlib](https://docs.python.org/3/library/email.html). You don't need to install it, it must always be available. Just import and use. | You might have outdated setuptools, try:
```
pip install --upgrade setuptools
```
Then continue trying to install the module you want.
Usually these kinds of problems can be solved by googling the error: in this case you should try searching with "python setup.py egg\_info".
Also, try to give a more descriptive ti... |
63,781,794 | I got this error message when I was installing python-binance.
Error message is in the link below please check
<https://docs.google.com/document/d/1VE0Ux_ji9RoK0NIrPD3BSbs60sTaxThk3boxsvh051c/edit>
Anyone knows how to fix it? | 2020/09/07 | [
"https://Stackoverflow.com/questions/63781794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14236836/"
] | You're trying to install [`email` from PyPI](https://pypi.org/project/email/) which is a very old outdated Python2-only package.
`email` is now [a module in the stdlib](https://docs.python.org/3/library/email.html). You don't need to install it, it must always be available. Just import and use. | Thanks guys I already figured out what error message means, I downloaded twisted from third party website and installed it and it worked. |
16,375,251 | This is part of a project I am working on for work.
I want to automate a Sharepoint site, specifically to pull data out of a database that I and my coworkers only have front-end access to.
I FINALLY managed to get mechanize (in python) to accomplish this using Python-NTLM, and by patching part of it's source code to ... | 2013/05/04 | [
"https://Stackoverflow.com/questions/16375251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/629404/"
] | Well, in the end I came down to the following possible solutions:
* **Run Chrome headless** and collect the html output (thanks to koenp for the link!)
* **Run PhantomJS**, a headless browser with a javascript api
* **Run HTMLUnit**; same thing but for Java
* **Use Ghost.py**, a **python-based** headless browser (that... | Well you will need something that both understands the DOM and understand Javascript, so that comes down to a headless browser of some sort. Maybe you can take a look at the [selenium webdriver](http://docs.seleniumhq.org/docs/03_webdriver.jsp), but I guess you already did that. I don't hink there is an easy way of doi... |
59,591,862 | Essentially I'm trying to do something that is stated here [Changing variables in multiple Python instances](https://stackoverflow.com/questions/9302789/changing-variables-in-multiple-python-instances)
but in java.
I want to reset a variable in all instances of a certain class so something like:
```
public class New... | 2020/01/04 | [
"https://Stackoverflow.com/questions/59591862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12652681/"
] | This is probably far from a Todo but it'll give you some clarification of what to do.
```js
const box = document.querySelector('.box');
let inputTodo = document.getElementById('inputTodo');
const inputTodoHandler = (event) => {
if(event.which == 13 || event.keyCode == 13) {
addTodo(event.target.value);
... | use the Database system in your Website using sql or any server that stores the info in cloud that store/edit/delete and acess the database in your right/desired location |
59,591,862 | Essentially I'm trying to do something that is stated here [Changing variables in multiple Python instances](https://stackoverflow.com/questions/9302789/changing-variables-in-multiple-python-instances)
but in java.
I want to reset a variable in all instances of a certain class so something like:
```
public class New... | 2020/01/04 | [
"https://Stackoverflow.com/questions/59591862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12652681/"
] | There are a few concepts you should look up:
* how to assign a DOM element to a variable with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) or other methods:
```
const input = document.querySelector('input')
const div = document.querySelector('.box')
```
* events and even... | use the Database system in your Website using sql or any server that stores the info in cloud that store/edit/delete and acess the database in your right/desired location |
59,591,862 | Essentially I'm trying to do something that is stated here [Changing variables in multiple Python instances](https://stackoverflow.com/questions/9302789/changing-variables-in-multiple-python-instances)
but in java.
I want to reset a variable in all instances of a certain class so something like:
```
public class New... | 2020/01/04 | [
"https://Stackoverflow.com/questions/59591862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12652681/"
] | The shortest way to give you a direction of thoughts is roughly to use event listener for key pressed in the input field.
Also since you want to create some kind of list, you need to add input new value to destination content once Enter key was pressed, dividing lines with End-of-line character.
Note: You don't need... | use the Database system in your Website using sql or any server that stores the info in cloud that store/edit/delete and acess the database in your right/desired location |
59,591,862 | Essentially I'm trying to do something that is stated here [Changing variables in multiple Python instances](https://stackoverflow.com/questions/9302789/changing-variables-in-multiple-python-instances)
but in java.
I want to reset a variable in all instances of a certain class so something like:
```
public class New... | 2020/01/04 | [
"https://Stackoverflow.com/questions/59591862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12652681/"
] | something like this should do the trick. The event.preventDefault() stops the form from being submitted to your server.
```js
function moveit(){
event.preventDefault();
var inputs = document.getElementsByTagName('input');
var input = inputs[0].value;
var box = document.getElementById('box');
var before = box.i... | use the Database system in your Website using sql or any server that stores the info in cloud that store/edit/delete and acess the database in your right/desired location |
17,960,696 | I was trying to install a package using easy\_install, errors happened "processing dependencies", looks like it cannot locate a package, here's the error I got
---
```
Processing dependencies for python-pack==1.5.0beta2
Searching for python-pack==1.5.0beta2
Reading http://pypi.python.org/simple/python-pack/
Couldn't ... | 2013/07/31 | [
"https://Stackoverflow.com/questions/17960696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636377/"
] | It turned out that the jar files in ~/.m2/repository have been corrupted. This issue has been solved by deleting everything in the repository and do a:
>
> mvn clean install
>
>
>
All the classes can be resolved now. | The answer is more likely that you need to add the dependency to your pom.xml file:
```
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-hibernate</artifactId>
<version>${dropwizard.version}</version>
</dependency>
``` |
33,324,083 | I am having trouble learning to plot a function in python. For example I want to create a graph with these two functions:
```
y=10x
y=5x+20
```
The only way I found was to use the following code
```
import matplotlib.pyplot as plt
plt.plot([points go here], [points go here])
plt.plot([points go here], [points go he... | 2015/10/24 | [
"https://Stackoverflow.com/questions/33324083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5484597/"
] | There are quite a lot of answers here which exlain that, but let me give you another one.
A string is interned into the String literal pool only in two situations: when a class is loaded and the String was a literal or compile time constant. Otherwise only when you call `.intern()` on a String. Then a copy of this st... | One thing you have to know is, that Strings are Objects in Java. The variables s1 - s4 do not point directly to the text you stored. It is simply a pointer which says where to find the Text within your RAM.
1. It is false because you compare the Pointers, not the actual text. The text is the same, but these two String... |
33,324,083 | I am having trouble learning to plot a function in python. For example I want to create a graph with these two functions:
```
y=10x
y=5x+20
```
The only way I found was to use the following code
```
import matplotlib.pyplot as plt
plt.plot([points go here], [points go here])
plt.plot([points go here], [points go he... | 2015/10/24 | [
"https://Stackoverflow.com/questions/33324083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5484597/"
] | There are quite a lot of answers here which exlain that, but let me give you another one.
A string is interned into the String literal pool only in two situations: when a class is loaded and the String was a literal or compile time constant. Otherwise only when you call `.intern()` on a String. Then a copy of this st... | To start off with, s1, s2, and s3 are in the intern pool when they are declared, because they are declared by a literal. s4 is not in the intern pool to start off with. This is what the intern pool might look like to start off with:
```
"abc" (s1, s2)
"abcabc" (s3)
```
1. s4 does not match s3 because s3 is in the in... |
46,132,556 | When I try to install python3-tk for python3.5 on ubuntu 16.04 I get the following error, what should I do?
python3-tk : Depends: python3 (< 3.5) but 3.5.1-3 is to be installed | 2017/09/09 | [
"https://Stackoverflow.com/questions/46132556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3604079/"
] | Activity transition is always expensive and we should switch from one activity to another only when we are switching the context. A `fragment` is a portion of UI in an activity. Same fragment can be used with multiple activities. Just like activity a fragment has its own lifecycle and `setContentView(int layoutResID)` ... | Please refer to :-
<https://github.com/waleedsarwar86/BottomNavigationDemo>
and complete explanation in
<http://waleedsarwar.com/posts/2016-05-21-three-tabs-bottom-navigation/>
You will get a running code with the explanation here. |
46,132,556 | When I try to install python3-tk for python3.5 on ubuntu 16.04 I get the following error, what should I do?
python3-tk : Depends: python3 (< 3.5) but 3.5.1-3 is to be installed | 2017/09/09 | [
"https://Stackoverflow.com/questions/46132556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3604079/"
] | Please refer to :-
<https://github.com/waleedsarwar86/BottomNavigationDemo>
and complete explanation in
<http://waleedsarwar.com/posts/2016-05-21-three-tabs-bottom-navigation/>
You will get a running code with the explanation here. | ```
bottomNavigationView.setOnNavigationItemSelectedListener
(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment selectedFragment = null;
... |
46,132,556 | When I try to install python3-tk for python3.5 on ubuntu 16.04 I get the following error, what should I do?
python3-tk : Depends: python3 (< 3.5) but 3.5.1-3 is to be installed | 2017/09/09 | [
"https://Stackoverflow.com/questions/46132556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3604079/"
] | Activity transition is always expensive and we should switch from one activity to another only when we are switching the context. A `fragment` is a portion of UI in an activity. Same fragment can be used with multiple activities. Just like activity a fragment has its own lifecycle and `setContentView(int layoutResID)` ... | Bottom Navigation View is a navigation bar introduced in android library to make it easy to switch between views with a single tap. It can although be used for almost any purpose, but is most commonly used to switch between fragments with a single tap. Its use for opening activities is somewhat absurd, since it ignores... |
46,132,556 | When I try to install python3-tk for python3.5 on ubuntu 16.04 I get the following error, what should I do?
python3-tk : Depends: python3 (< 3.5) but 3.5.1-3 is to be installed | 2017/09/09 | [
"https://Stackoverflow.com/questions/46132556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3604079/"
] | Bottom Navigation View is a navigation bar introduced in android library to make it easy to switch between views with a single tap. It can although be used for almost any purpose, but is most commonly used to switch between fragments with a single tap. Its use for opening activities is somewhat absurd, since it ignores... | ```
bottomNavigationView.setOnNavigationItemSelectedListener
(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment selectedFragment = null;
... |
46,132,556 | When I try to install python3-tk for python3.5 on ubuntu 16.04 I get the following error, what should I do?
python3-tk : Depends: python3 (< 3.5) but 3.5.1-3 is to be installed | 2017/09/09 | [
"https://Stackoverflow.com/questions/46132556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3604079/"
] | Activity transition is always expensive and we should switch from one activity to another only when we are switching the context. A `fragment` is a portion of UI in an activity. Same fragment can be used with multiple activities. Just like activity a fragment has its own lifecycle and `setContentView(int layoutResID)` ... | ```
bottomNavigationView.setOnNavigationItemSelectedListener
(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment selectedFragment = null;
... |
27,713,681 | ```
10:01:36 adcli
10:01:36 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 adcli
10:01:37 runma
10:01:37 runma
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
1... | 2014/12/30 | [
"https://Stackoverflow.com/questions/27713681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4406840/"
] | As Respawned alluded to, there is no easy answer that will work in all cases. That being said, here are two approaches which seem to work fairly well. Both having upsides and downsides.
Approach 1
==========
Internally, the `getTextContent` method uses whats called an `EvaluatorPreprocessor` to parse the PDF operator... | This question is actually extremely hard if you want to do it to perfection... or it can be relatively easy if you can live with solutions that work only some of the time.
First of all, realize that `getTextContent` is intended for searchable text extraction and that's all it's intended to do.
It's been suggested in ... |
27,713,681 | ```
10:01:36 adcli
10:01:36 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 adcli
10:01:37 runma
10:01:37 runma
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
1... | 2014/12/30 | [
"https://Stackoverflow.com/questions/27713681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4406840/"
] | This question is actually extremely hard if you want to do it to perfection... or it can be relatively easy if you can live with solutions that work only some of the time.
First of all, realize that `getTextContent` is intended for searchable text extraction and that's all it's intended to do.
It's been suggested in ... | There's no need to patch pdfjs, the transform property gives the x and y, so you can go through the operator list and find the setFillColor op that precedes the text op at that point. |
27,713,681 | ```
10:01:36 adcli
10:01:36 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 sshd[
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
10:01:37 adcli
10:01:37 runma
10:01:37 runma
10:01:37 sshd[
10:01:37 adcli
10:01:37 adcli
1... | 2014/12/30 | [
"https://Stackoverflow.com/questions/27713681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4406840/"
] | As Respawned alluded to, there is no easy answer that will work in all cases. That being said, here are two approaches which seem to work fairly well. Both having upsides and downsides.
Approach 1
==========
Internally, the `getTextContent` method uses whats called an `EvaluatorPreprocessor` to parse the PDF operator... | There's no need to patch pdfjs, the transform property gives the x and y, so you can go through the operator list and find the setFillColor op that precedes the text op at that point. |
55,482,197 | I start to learn Django framework so I need to install latest python, pip, virtualenv and django packets on my mac.
I try to do it with brew, but I got some strange behavior.
At first, python3 installed not in /usr/bin/ but in /Library/Frameworks/Python.framework directory:
```
$ which python
/usr/bin/python
$ which... | 2019/04/02 | [
"https://Stackoverflow.com/questions/55482197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11301741/"
] | Instead of using brew you can simply use "venv".
To create a virtual environment you can run -->
```
python3 -m venv environment_name
```
Example: If you want to create an virtual environment for django with name django\_env
```
python3 -m venv django_env
```
"-m" flag checks for sys.path and executes main modul... | ### Python3 Virtualenv Setup
Requirements:
* Python3
* Pip3
```sh
$ brew install python3 #upgrade
```
Pip3 is installed with Python3
**Installation**
To install virtualenv via pip run:
```sh
$ pip3 install virtualenv
```
**Usage**
Creation of virtualenv:
```sh
$ virtualenv -p python3 <desired-path>
```
Ac... |
55,482,197 | I start to learn Django framework so I need to install latest python, pip, virtualenv and django packets on my mac.
I try to do it with brew, but I got some strange behavior.
At first, python3 installed not in /usr/bin/ but in /Library/Frameworks/Python.framework directory:
```
$ which python
/usr/bin/python
$ which... | 2019/04/02 | [
"https://Stackoverflow.com/questions/55482197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11301741/"
] | Instead of using brew you can simply use "venv".
To create a virtual environment you can run -->
```
python3 -m venv environment_name
```
Example: If you want to create an virtual environment for django with name django\_env
```
python3 -m venv django_env
```
"-m" flag checks for sys.path and executes main modul... | Just follow as below:
1. $ pip install virtualenv
Once installed, you can create a virtual environment with:
2. $ virtualenv [directory]
On MacOS, we activate our virtual environment with the source command. If you created your venv in the myvenv directory, the command would be
3. $ source myvenv/bin/activate |
55,482,197 | I start to learn Django framework so I need to install latest python, pip, virtualenv and django packets on my mac.
I try to do it with brew, but I got some strange behavior.
At first, python3 installed not in /usr/bin/ but in /Library/Frameworks/Python.framework directory:
```
$ which python
/usr/bin/python
$ which... | 2019/04/02 | [
"https://Stackoverflow.com/questions/55482197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11301741/"
] | ### Python3 Virtualenv Setup
Requirements:
* Python3
* Pip3
```sh
$ brew install python3 #upgrade
```
Pip3 is installed with Python3
**Installation**
To install virtualenv via pip run:
```sh
$ pip3 install virtualenv
```
**Usage**
Creation of virtualenv:
```sh
$ virtualenv -p python3 <desired-path>
```
Ac... | Just follow as below:
1. $ pip install virtualenv
Once installed, you can create a virtual environment with:
2. $ virtualenv [directory]
On MacOS, we activate our virtual environment with the source command. If you created your venv in the myvenv directory, the command would be
3. $ source myvenv/bin/activate |
71,020,555 | Like in other programing languages - python or JS, when we create a rest api specifically post for the request body we attract some JSON Object
EX:
url: .../employee (Post)
request body: {option: {filter: "suman"}}
In Python or JS we can just do request\_body.option.filter and get the data
How can I achieve the sa... | 2022/02/07 | [
"https://Stackoverflow.com/questions/71020555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9661967/"
] | What about this?
```
table1 %>%
left_join(cbind(table2, n = 1)) %>%
group_by(Col1, Col2, Col3) %>%
mutate(n = sum(n, na.rm = TRUE))
```
and we will see
```
Col1 Col2 Col3 n
<chr> <chr> <chr> <dbl>
1 Al F C 1
2 Al UF UC 1
3 Al P < 0
4 Cu F C ... | **1)** Append an n=1 column to table2 and an n=0 column to table 1 and then sum n by group.
```
table2 %>%
mutate(n = 1L) %>%
bind_rows(table1 %>% mutate(n = 0L)) %>%
group_by(Col1, Col2, Col3) %>%
summarize(n = sum(n), .groups = "drop")
```
giving:
```
# A tibble: 10 x 4
Col1 Col2 Col3 n
<chr... |
71,020,555 | Like in other programing languages - python or JS, when we create a rest api specifically post for the request body we attract some JSON Object
EX:
url: .../employee (Post)
request body: {option: {filter: "suman"}}
In Python or JS we can just do request\_body.option.filter and get the data
How can I achieve the sa... | 2022/02/07 | [
"https://Stackoverflow.com/questions/71020555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9661967/"
] | You can try `complete`
```
library(tidyverse)
table2 %>%
count(Col1, Col2, Col3, name = "sum") %>%
complete(distinct_all(table1), fill = list(sum=0))
# A tibble: 10 x 4
Col1 Col2 Col3 sum
<chr> <chr> <chr> <dbl>
1 Al F C 1
2 Al P < 0
3 Al UF UC 1
4 Cu ... | **1)** Append an n=1 column to table2 and an n=0 column to table 1 and then sum n by group.
```
table2 %>%
mutate(n = 1L) %>%
bind_rows(table1 %>% mutate(n = 0L)) %>%
group_by(Col1, Col2, Col3) %>%
summarize(n = sum(n), .groups = "drop")
```
giving:
```
# A tibble: 10 x 4
Col1 Col2 Col3 n
<chr... |
17,818,502 | Consider this sample python code. It reads from stdin and writes to a file.
```
import sys
arg1 = sys.argv[1]
f = open(arg1,'w')
f.write('<html><head><title></title></head><body>')
for line in sys.stdin:
f.write("<p>")
f.write(line)
f.write("</p>")
f.write("</body></html>")
f.close()
```
Suppose I ... | 2013/07/23 | [
"https://Stackoverflow.com/questions/17818502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199882/"
] | Just do
```
>>> import sys
>>> f = sys.stdout
>>> f.write('abc')
abc
```
Now you just need to do `f = sys.stdout` instead of `f = open(fileName)`. (And remove `f.close()`)
**Also**, Please consider using the following syntax for files.
```
with open(fileName, 'r') as f:
# Do Something
```
The file automatica... | Yes, in python, you can alias every class / function / method etc. Just assign the value you want to use to another variable:
```
import sys
f = sys.stdout
```
Now every method you call on `f` will get called on `sys.stdout`. You can do this with whatever you like, for example also with `i = sys.stdin` etc. |
17,818,502 | Consider this sample python code. It reads from stdin and writes to a file.
```
import sys
arg1 = sys.argv[1]
f = open(arg1,'w')
f.write('<html><head><title></title></head><body>')
for line in sys.stdin:
f.write("<p>")
f.write(line)
f.write("</p>")
f.write("</body></html>")
f.close()
```
Suppose I ... | 2013/07/23 | [
"https://Stackoverflow.com/questions/17818502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199882/"
] | Just do
```
>>> import sys
>>> f = sys.stdout
>>> f.write('abc')
abc
```
Now you just need to do `f = sys.stdout` instead of `f = open(fileName)`. (And remove `f.close()`)
**Also**, Please consider using the following syntax for files.
```
with open(fileName, 'r') as f:
# Do Something
```
The file automatica... | Names in Python are just bindings. Therefore:
```
f = sys.stdout
```
Just binds the name `f` to *the object* that's *also bound* to `sys.stdout`...
Note that since they're both the same object, any changes you make to `f` or `sys.stdout` at this point will affect *both*... So don't do `f.close()` as you normally w... |
17,818,502 | Consider this sample python code. It reads from stdin and writes to a file.
```
import sys
arg1 = sys.argv[1]
f = open(arg1,'w')
f.write('<html><head><title></title></head><body>')
for line in sys.stdin:
f.write("<p>")
f.write(line)
f.write("</p>")
f.write("</body></html>")
f.close()
```
Suppose I ... | 2013/07/23 | [
"https://Stackoverflow.com/questions/17818502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199882/"
] | Just do
```
>>> import sys
>>> f = sys.stdout
>>> f.write('abc')
abc
```
Now you just need to do `f = sys.stdout` instead of `f = open(fileName)`. (And remove `f.close()`)
**Also**, Please consider using the following syntax for files.
```
with open(fileName, 'r') as f:
# Do Something
```
The file automatica... | This is properly the job of a shell anyway; just send it to standard out and redirect it to a file using `>filename` when you invoke the script. |
17,818,502 | Consider this sample python code. It reads from stdin and writes to a file.
```
import sys
arg1 = sys.argv[1]
f = open(arg1,'w')
f.write('<html><head><title></title></head><body>')
for line in sys.stdin:
f.write("<p>")
f.write(line)
f.write("</p>")
f.write("</body></html>")
f.close()
```
Suppose I ... | 2013/07/23 | [
"https://Stackoverflow.com/questions/17818502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199882/"
] | Names in Python are just bindings. Therefore:
```
f = sys.stdout
```
Just binds the name `f` to *the object* that's *also bound* to `sys.stdout`...
Note that since they're both the same object, any changes you make to `f` or `sys.stdout` at this point will affect *both*... So don't do `f.close()` as you normally w... | Yes, in python, you can alias every class / function / method etc. Just assign the value you want to use to another variable:
```
import sys
f = sys.stdout
```
Now every method you call on `f` will get called on `sys.stdout`. You can do this with whatever you like, for example also with `i = sys.stdin` etc. |
17,818,502 | Consider this sample python code. It reads from stdin and writes to a file.
```
import sys
arg1 = sys.argv[1]
f = open(arg1,'w')
f.write('<html><head><title></title></head><body>')
for line in sys.stdin:
f.write("<p>")
f.write(line)
f.write("</p>")
f.write("</body></html>")
f.close()
```
Suppose I ... | 2013/07/23 | [
"https://Stackoverflow.com/questions/17818502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199882/"
] | Yes, in python, you can alias every class / function / method etc. Just assign the value you want to use to another variable:
```
import sys
f = sys.stdout
```
Now every method you call on `f` will get called on `sys.stdout`. You can do this with whatever you like, for example also with `i = sys.stdin` etc. | This is properly the job of a shell anyway; just send it to standard out and redirect it to a file using `>filename` when you invoke the script. |
17,818,502 | Consider this sample python code. It reads from stdin and writes to a file.
```
import sys
arg1 = sys.argv[1]
f = open(arg1,'w')
f.write('<html><head><title></title></head><body>')
for line in sys.stdin:
f.write("<p>")
f.write(line)
f.write("</p>")
f.write("</body></html>")
f.close()
```
Suppose I ... | 2013/07/23 | [
"https://Stackoverflow.com/questions/17818502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199882/"
] | Names in Python are just bindings. Therefore:
```
f = sys.stdout
```
Just binds the name `f` to *the object* that's *also bound* to `sys.stdout`...
Note that since they're both the same object, any changes you make to `f` or `sys.stdout` at this point will affect *both*... So don't do `f.close()` as you normally w... | This is properly the job of a shell anyway; just send it to standard out and redirect it to a file using `>filename` when you invoke the script. |
18,263,733 | I am new to python and django i am creating first tutorial app.
I created app file using following command:
```
C:\Python27\Scripts\django-admin.py startproject mysite
```
After that successfully created a file in directory
But how to run python manage.py runserver i am getting error `not recognized as an internal... | 2013/08/15 | [
"https://Stackoverflow.com/questions/18263733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2582761/"
] | You just need to `cd` into mysite from there.
Use `cd mysite` from the command line. Then run `python manage.py runserver` and the dev server will startup in the current (or a new if there inst a current) browser window.
To visualize this for you:
```
current_dir/ <-- your here now
mysite/ < -- use cd... | You need to go to the directory that the app you created resides in then run the command `manage.py runserver` on windows or `python manage.py runserver` in a Unix Terminal.
It is typical to create a separate directory for your Django projects. A typical directory would be:
```
C:\DjangoProjects\
```
You would then... |
27,692,051 | **Is there any way to disable the syntax highlighting in SublimeREPL-tabs when a script is running?**
Please see this question for context: [Red lines coming up after strings in SublimeREPL (python)?](https://stackoverflow.com/q/25693151/1426065)
For example, when python-scripts run in Sublime REPL, apostrophes (') i... | 2014/12/29 | [
"https://Stackoverflow.com/questions/27692051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4183985/"
] | Go to
Sublime Text > Preferences > Package Settings > SublimeREPL > Settings - User
(If your 'Settings - User' is empty, first copy in the contents of 'Settings - Default')
under "repl\_view\_settings": add:
```
,
"syntax": "Packages/Text/Plain text.tmLanguage"
```
so mine is now:
```
// standard sublime view... | As @joe.dawley wrote in the comments to the original question there is a way to manually disable syntax highlighting in SublimeREPL by using the go to anything-command **(Ctrl + Shift + P)** and enter **"sspl"** to set the syntax to plain text. |
44,549,369 | I am trying to calculate the Kullback-Leibler divergence from Gaussian#1 to Gaussian#2
I have the mean and the standard deviation for both Gaussians
I tried this code from <http://www.cs.cmu.edu/~chanwook/MySoftware/rm1_Spk-by-Spk_MLLR/rm1_PNCC_MLLR_1/rm1/python/sphinx/divergence.py>
```
def gau_kl(pm, pv, qm, qv):
... | 2017/06/14 | [
"https://Stackoverflow.com/questions/44549369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7879074/"
] | The following function computes the KL-Divergence between any two multivariate normal distributions (no need for the covariance matrices to be diagonal) (where numpy is imported as np)
```
def kl_mvn(m0, S0, m1, S1):
"""
Kullback-Liebler divergence from Gaussian pm,pv to Gaussian qm,qv.
Also computes KL di... | If you are still interested ...
That function expects diagonal entries of covariance matrix of multivariate Gaussians, not standard deviations as you mention. If your inputs are univariate Gaussians, then both `pv` and `qv` are vectors of length 1 for variances of corresponding Gaussians.
Besides, `len(pm)` correspo... |
55,537,213 | I'm following Adrian Rosebrock's tutorial on recognising digits on an RPi, so no tesseract or whatever:
<https://www.pyimagesearch.com/2017/02/13/recognizing-digits-with-opencv-and-python/>
But it doesn't recognise decimal points, so I've been trying really hard to create a part that would help to do that. I think I'v... | 2019/04/05 | [
"https://Stackoverflow.com/questions/55537213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2810806/"
] | If JSON is used to exchange data, it *must* use UTF-8 encoding (see [RFC8259](https://www.rfc-editor.org/rfc/rfc8259)). UTF-16 and UTF-32 encodings are no longer allowed. So it is not necessary to escape the degree character. And I strongly recommend against escaping unnecessarily.
*Correct and recommended*
```
{
"... | JSON uses unicode to be encoded, but it is specified that you can use `\uxxxx` escape codes to represent characters that don't map into your computer native environment, so it's perfectly valid to include such escape sequences and use only plain ascii encoding to transfer JSON serialized data. |
69,045,992 | So I am trying to install and import pynput in VSCode but its showing me an error every time I try to do it. I used VSCode's in-built terminal to install it using pip and typed the following :
`pip install pynput` but this error is shown : `Fatal error in launcher: Unable to create process using '"c:\users\vicks\appdat... | 2021/09/03 | [
"https://Stackoverflow.com/questions/69045992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16225182/"
] | you need to set a default lang in case there is no preferredLanguages or error occurred like this
```
static String lang ='';
List? languages = [];
languages = await Devicelocale.preferredLanguages;
if(languages?.isNotEmpty ==true){
lang = languages[0] ?? "en";
}else{
... | You should add the bang `!` at the end `languages[0]!` to remove the nullability. |
69,045,992 | So I am trying to install and import pynput in VSCode but its showing me an error every time I try to do it. I used VSCode's in-built terminal to install it using pip and typed the following :
`pip install pynput` but this error is shown : `Fatal error in launcher: Unable to create process using '"c:\users\vicks\appdat... | 2021/09/03 | [
"https://Stackoverflow.com/questions/69045992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16225182/"
] | You should try to never use a `!`. Variables are nullable for a reasons, they *can* be null and your compiler is very good at guiding you through this. Don't try to be smarter than your compiler by using a `!`.
You can use `if`s or null aware operators like `?` or `??`, but don't assume something *cannot* be null, whe... | You should add the bang `!` at the end `languages[0]!` to remove the nullability. |
69,045,992 | So I am trying to install and import pynput in VSCode but its showing me an error every time I try to do it. I used VSCode's in-built terminal to install it using pip and typed the following :
`pip install pynput` but this error is shown : `Fatal error in launcher: Unable to create process using '"c:\users\vicks\appdat... | 2021/09/03 | [
"https://Stackoverflow.com/questions/69045992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16225182/"
] | Use `whereType<String>` to filter the type you're looking for and create a new list of `List<String>` (non-null).
```dart
final List<dynamic> languages = await Devicelocale.preferredLanguages;
final preferredLangs = languages.whereType<String>();
```
Sample:
```dart
void main() {
final List<dynamic> fakeSource = ... | You should add the bang `!` at the end `languages[0]!` to remove the nullability. |
51,775,370 | I'm running Airflow on a clustered environment running on two AWS EC2-Instances. One for master and one for the worker. The worker node though periodically throws this error when running "$airflow worker":
```
[2018-08-09 16:15:43,553] {jobs.py:2574} WARNING - The recorded hostname ip-1.2.3.4 does not match this insta... | 2018/08/09 | [
"https://Stackoverflow.com/questions/51775370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299397/"
] | The hostname is set when the task instance runs, and is set to `self.hostname = socket.getfqdn()`, where socket is the python package `import socket`.
The comparison that triggers this error is:
```
fqdn = socket.getfqdn()
if fqdn != ti.hostname:
logging.warning("The recorded hostname {ti.hostname} "
"doe... | I had a similar problem on my Mac. It fixed it setting `hostname_callable = socket:gethostname` in `airflow.cfg`. |
51,775,370 | I'm running Airflow on a clustered environment running on two AWS EC2-Instances. One for master and one for the worker. The worker node though periodically throws this error when running "$airflow worker":
```
[2018-08-09 16:15:43,553] {jobs.py:2574} WARNING - The recorded hostname ip-1.2.3.4 does not match this insta... | 2018/08/09 | [
"https://Stackoverflow.com/questions/51775370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299397/"
] | The hostname is set when the task instance runs, and is set to `self.hostname = socket.getfqdn()`, where socket is the python package `import socket`.
The comparison that triggers this error is:
```
fqdn = socket.getfqdn()
if fqdn != ti.hostname:
logging.warning("The recorded hostname {ti.hostname} "
"doe... | Personally when running on my Mac, I found that I got similar errors to this when the Mac would sleep while I was running a long job. The solution was to go into System Preferences -> Energy Saver and then check "Prevent computer from sleeping automatically when the display is off." |
51,775,370 | I'm running Airflow on a clustered environment running on two AWS EC2-Instances. One for master and one for the worker. The worker node though periodically throws this error when running "$airflow worker":
```
[2018-08-09 16:15:43,553] {jobs.py:2574} WARNING - The recorded hostname ip-1.2.3.4 does not match this insta... | 2018/08/09 | [
"https://Stackoverflow.com/questions/51775370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3299397/"
] | I had a similar problem on my Mac. It fixed it setting `hostname_callable = socket:gethostname` in `airflow.cfg`. | Personally when running on my Mac, I found that I got similar errors to this when the Mac would sleep while I was running a long job. The solution was to go into System Preferences -> Energy Saver and then check "Prevent computer from sleeping automatically when the display is off." |
55,337,221 | I'm trying to connect another computer in local network via python (subprocesses module) with this commands from CMD.exe
* `net use \\\\ip\C$ password /user:username`
* `copy D:\file.txt \\ip\C$`
Then in python it look like below.
But when i try second command, I get:
>
> "FileNotFoundError: [WinError 2]"
>
>
>
... | 2019/03/25 | [
"https://Stackoverflow.com/questions/55337221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5299639/"
] | The issue is that `copy` is a built-in, not a real command in Windows.
Those Windows messages are awful, but `"FileNotFoundError: [WinError 2]"` doesn't mean one of source & destination files can't be accessed (if `copy` failed, you'd get a normal Windows message with explicit file names).
Here, it means that the *co... | you need make sure you have right to add a file.
i have testted successfully after i corrected the shared dirctory's right. |
50,777,013 | I am just a beginner to a tensorflow and trying to install TensorFlow with CPU support only.
Initially, I downloaded and installed Python 3.5.2 version from <https://www.python.org/downloads/release/python-352/>
After successful installation, I ran the command `pip3 install --upgrade tensorflow` which installed tenso... | 2018/06/09 | [
"https://Stackoverflow.com/questions/50777013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8141116/"
] | I copied ***msvcp140.dll*** to path ***C:\Users\PCName\AppData\Local\Programs\Python\Python35***
and it worked for me.
I also switched back to tensorflow 1.8 from 1.5. | You can download the package from the url <https://www.microsoft.com/en-us/download/details.aspx?id=53587> and install it. This will solve the issue. |
50,777,013 | I am just a beginner to a tensorflow and trying to install TensorFlow with CPU support only.
Initially, I downloaded and installed Python 3.5.2 version from <https://www.python.org/downloads/release/python-352/>
After successful installation, I ran the command `pip3 install --upgrade tensorflow` which installed tenso... | 2018/06/09 | [
"https://Stackoverflow.com/questions/50777013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8141116/"
] | I copied ***msvcp140.dll*** to path ***C:\Users\PCName\AppData\Local\Programs\Python\Python35***
and it worked for me.
I also switched back to tensorflow 1.8 from 1.5. | download msvcp140.dll or click <https://www.dll-files.com/msvcp140.dll.html>
find your python path
path will find easy from your error
error will show like this
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\sky network\AppData\Local\Programs\Python\Python36\lib\site- ... |
50,777,013 | I am just a beginner to a tensorflow and trying to install TensorFlow with CPU support only.
Initially, I downloaded and installed Python 3.5.2 version from <https://www.python.org/downloads/release/python-352/>
After successful installation, I ran the command `pip3 install --upgrade tensorflow` which installed tenso... | 2018/06/09 | [
"https://Stackoverflow.com/questions/50777013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8141116/"
] | download msvcp140.dll or click <https://www.dll-files.com/msvcp140.dll.html>
find your python path
path will find easy from your error
error will show like this
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\sky network\AppData\Local\Programs\Python\Python36\lib\site- ... | You can download the package from the url <https://www.microsoft.com/en-us/download/details.aspx?id=53587> and install it. This will solve the issue. |
57,473,982 | in vs code, for some reason, i cannot run any python code because vs code puts in python instead of py in cmd.
it shows this :
>
> [Running] python -u "c:\Users..."
>
>
>
but is supposed to show this :
>
> [Running] py -u "c:\Users\
>
>
>
i have tried searching online how to fix it, the error message:
**... | 2019/08/13 | [
"https://Stackoverflow.com/questions/57473982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11921290/"
] | Well you can change the interpreter that Code uses by pressing `Ctrl+Shift+P` and then searching for `Python: Select Interpreter`, this should help when it comes to running the code in the IDE. If that doesn't work you could just try and use the built in terminal in Code to run the code manually with the `py` command. | In VSCODE debug mode I have launch json as follows and then i can easily debug the code with breakpoints
```
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",... |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | If you do not want direct child selector, just add a parent reference for the nested elements.
This will make your thing work.
You can add the below.
```
.red .blue h1 {
color: blue;
}
```
**[WORKING DEMO](http://jsfiddle.net/N7FcB/1/)**
To enforce your div to render the color blue, you just need to add the re... | Or maybe like that:
```
.red > h1 {
color: red;
}
.blue h1 {
color: blue;
}
```
[fiddle](http://jsfiddle.net/sxVcL/3/).
This is 100%. |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | If you do not want direct child selector, just add a parent reference for the nested elements.
This will make your thing work.
You can add the below.
```
.red .blue h1 {
color: blue;
}
```
**[WORKING DEMO](http://jsfiddle.net/N7FcB/1/)**
To enforce your div to render the color blue, you just need to add the re... | hope it will help you
```
.red > h1 {
color: red;
}
.blue h1 {
color: blue;
}
```
select as direct child you will not face any more problem. |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | If you do not want direct child selector, just add a parent reference for the nested elements.
This will make your thing work.
You can add the below.
```
.red .blue h1 {
color: blue;
}
```
**[WORKING DEMO](http://jsfiddle.net/N7FcB/1/)**
To enforce your div to render the color blue, you just need to add the re... | ```
.blue > * {
color: blue;
}
.red > * {
color: red;
}
```
You can always try ">" selector combined with wildcard
[myfiddle](http://jsfiddle.net/9XtaM/2/) |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | If you do not want direct child selector, just add a parent reference for the nested elements.
This will make your thing work.
You can add the below.
```
.red .blue h1 {
color: blue;
}
```
**[WORKING DEMO](http://jsfiddle.net/N7FcB/1/)**
To enforce your div to render the color blue, you just need to add the re... | how about this?
```
div.red > h1 {
color: red !important;
}
div.blue > h1 {
color: blue !important;
}
```
or throw div element
```
.red > h1 {
color: red !important;
}
.blue > h1 {
color: blue !important;
}
```
<http://jsfiddle.net/N7FcB/6/> |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | If you do not want direct child selector, just add a parent reference for the nested elements.
This will make your thing work.
You can add the below.
```
.red .blue h1 {
color: blue;
}
```
**[WORKING DEMO](http://jsfiddle.net/N7FcB/1/)**
To enforce your div to render the color blue, you just need to add the re... | Actually how many H1 do you need inside a div? i say not much. so why don't why give the class to the H1.
```
h1.red { color: red; }
h1.green { color: green; }
h1.blue { color: blue; }
```
---
**Update**
How about having a box with depth level, see fiddle <http://jsfiddle.net/AnL7R/>
by having linked classes you ... |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | Browser reads your CSS from top to bottom and it will apply in the same way..
So first you have a rule called
```
.blue h1 {
color: blue;
}
```
So browser will parse this information and will color your `h1` as `blue`, but it goes ahead and it hits second selector which is
```
.red h1 {
color: red;
}
```
... | Or maybe like that:
```
.red > h1 {
color: red;
}
.blue h1 {
color: blue;
}
```
[fiddle](http://jsfiddle.net/sxVcL/3/).
This is 100%. |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | Browser reads your CSS from top to bottom and it will apply in the same way..
So first you have a rule called
```
.blue h1 {
color: blue;
}
```
So browser will parse this information and will color your `h1` as `blue`, but it goes ahead and it hits second selector which is
```
.red h1 {
color: red;
}
```
... | hope it will help you
```
.red > h1 {
color: red;
}
.blue h1 {
color: blue;
}
```
select as direct child you will not face any more problem. |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | Browser reads your CSS from top to bottom and it will apply in the same way..
So first you have a rule called
```
.blue h1 {
color: blue;
}
```
So browser will parse this information and will color your `h1` as `blue`, but it goes ahead and it hits second selector which is
```
.red h1 {
color: red;
}
```
... | ```
.blue > * {
color: blue;
}
.red > * {
color: red;
}
```
You can always try ">" selector combined with wildcard
[myfiddle](http://jsfiddle.net/9XtaM/2/) |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | Browser reads your CSS from top to bottom and it will apply in the same way..
So first you have a rule called
```
.blue h1 {
color: blue;
}
```
So browser will parse this information and will color your `h1` as `blue`, but it goes ahead and it hits second selector which is
```
.red h1 {
color: red;
}
```
... | how about this?
```
div.red > h1 {
color: red !important;
}
div.blue > h1 {
color: blue !important;
}
```
or throw div element
```
.red > h1 {
color: red !important;
}
.blue > h1 {
color: blue !important;
}
```
<http://jsfiddle.net/N7FcB/6/> |
20,047,117 | I have my code as below.
```
def test():
print num1
print num
num += 10
if __name__ == '__main__':
num = 0
num1 = 3
test()
```
When executing the above python code I get the following output.
```
3
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "<stdin>", line 2, in ... | 2013/11/18 | [
"https://Stackoverflow.com/questions/20047117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1939389/"
] | Browser reads your CSS from top to bottom and it will apply in the same way..
So first you have a rule called
```
.blue h1 {
color: blue;
}
```
So browser will parse this information and will color your `h1` as `blue`, but it goes ahead and it hits second selector which is
```
.red h1 {
color: red;
}
```
... | Actually how many H1 do you need inside a div? i say not much. so why don't why give the class to the H1.
```
h1.red { color: red; }
h1.green { color: green; }
h1.blue { color: blue; }
```
---
**Update**
How about having a box with depth level, see fiddle <http://jsfiddle.net/AnL7R/>
by having linked classes you ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.