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 |
|---|---|---|---|---|---|
1,817,183 | I'm trying to learn the super() function in Python.
I thought I had a grasp of it until I came over this example (2.6) and found myself stuck.
[http://www.cafepy.com/article/python\_attributes\_and\_methods/python\_attributes\_and\_methods.html#super-with-classmethod-example](https://web.archive.org/web/2017082006590... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1817183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169854/"
] | In Python 3, you can skip specifying arguments for `super`,
```
class A:
@classmethod
def f(cls):
return "A's f was called."
class B(A):
@classmethod
def f(cls):
return super().f()
assert B.f() == "A's f was called."
``` | The example from the web page seems to work as published. Did you create a `do_something` method for the superclass as well but not make it into a classmethod? Something like this will give you that error:
```
>>> class A(object):
... def do_something(cls):
... print cls
... # do_something = classmethod(... |
1,817,183 | I'm trying to learn the super() function in Python.
I thought I had a grasp of it until I came over this example (2.6) and found myself stuck.
[http://www.cafepy.com/article/python\_attributes\_and\_methods/python\_attributes\_and\_methods.html#super-with-classmethod-example](https://web.archive.org/web/2017082006590... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1817183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169854/"
] | Sometimes texts have to be read more for the flavor of the idea rather than for the details. This is one of those cases.
In the [linked page](http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#a-super-solution), Examples 2.5, 2.6 and 2.7 should all use one method, `do_your_s... | I think I've understood the point now thanks to this beatiful site and lovely community.
If you don't mind please correct me if I'm wrong on classmethods (which I am now trying to understand fully):
```
# EXAMPLE #1
>>> class A(object):
... def foo(cls):
... print cls
... foo = classmethod(foo)
.... |
1,817,183 | I'm trying to learn the super() function in Python.
I thought I had a grasp of it until I came over this example (2.6) and found myself stuck.
[http://www.cafepy.com/article/python\_attributes\_and\_methods/python\_attributes\_and\_methods.html#super-with-classmethod-example](https://web.archive.org/web/2017082006590... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1817183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169854/"
] | Sometimes texts have to be read more for the flavor of the idea rather than for the details. This is one of those cases.
In the [linked page](http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#a-super-solution), Examples 2.5, 2.6 and 2.7 should all use one method, `do_your_s... | I've updated the article to make it a bit clearer: [Python Attributes and Methods # Super](http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#a-super-solution)
Your example using classmethod above shows what a class method is - it passes the class itself instead of the insta... |
1,817,183 | I'm trying to learn the super() function in Python.
I thought I had a grasp of it until I came over this example (2.6) and found myself stuck.
[http://www.cafepy.com/article/python\_attributes\_and\_methods/python\_attributes\_and\_methods.html#super-with-classmethod-example](https://web.archive.org/web/2017082006590... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1817183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169854/"
] | Sometimes texts have to be read more for the flavor of the idea rather than for the details. This is one of those cases.
In the [linked page](http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#a-super-solution), Examples 2.5, 2.6 and 2.7 should all use one method, `do_your_s... | In Python 3, you can skip specifying arguments for `super`,
```
class A:
@classmethod
def f(cls):
return "A's f was called."
class B(A):
@classmethod
def f(cls):
return super().f()
assert B.f() == "A's f was called."
``` |
1,817,183 | I'm trying to learn the super() function in Python.
I thought I had a grasp of it until I came over this example (2.6) and found myself stuck.
[http://www.cafepy.com/article/python\_attributes\_and\_methods/python\_attributes\_and\_methods.html#super-with-classmethod-example](https://web.archive.org/web/2017082006590... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1817183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169854/"
] | I've updated the article to make it a bit clearer: [Python Attributes and Methods # Super](http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#a-super-solution)
Your example using classmethod above shows what a class method is - it passes the class itself instead of the insta... | I think I've understood the point now thanks to this beatiful site and lovely community.
If you don't mind please correct me if I'm wrong on classmethods (which I am now trying to understand fully):
```
# EXAMPLE #1
>>> class A(object):
... def foo(cls):
... print cls
... foo = classmethod(foo)
.... |
1,817,183 | I'm trying to learn the super() function in Python.
I thought I had a grasp of it until I came over this example (2.6) and found myself stuck.
[http://www.cafepy.com/article/python\_attributes\_and\_methods/python\_attributes\_and\_methods.html#super-with-classmethod-example](https://web.archive.org/web/2017082006590... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1817183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169854/"
] | In Python 3, you can skip specifying arguments for `super`,
```
class A:
@classmethod
def f(cls):
return "A's f was called."
class B(A):
@classmethod
def f(cls):
return super().f()
assert B.f() == "A's f was called."
``` | I think I've understood the point now thanks to this beatiful site and lovely community.
If you don't mind please correct me if I'm wrong on classmethods (which I am now trying to understand fully):
```
# EXAMPLE #1
>>> class A(object):
... def foo(cls):
... print cls
... foo = classmethod(foo)
.... |
1,817,183 | I'm trying to learn the super() function in Python.
I thought I had a grasp of it until I came over this example (2.6) and found myself stuck.
[http://www.cafepy.com/article/python\_attributes\_and\_methods/python\_attributes\_and\_methods.html#super-with-classmethod-example](https://web.archive.org/web/2017082006590... | 2009/11/29 | [
"https://Stackoverflow.com/questions/1817183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169854/"
] | In Python 3, you can skip specifying arguments for `super`,
```
class A:
@classmethod
def f(cls):
return "A's f was called."
class B(A):
@classmethod
def f(cls):
return super().f()
assert B.f() == "A's f was called."
``` | I've updated the article to make it a bit clearer: [Python Attributes and Methods # Super](http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html#a-super-solution)
Your example using classmethod above shows what a class method is - it passes the class itself instead of the insta... |
10,269,860 | Here is a simple code in python 2.7.2, which fetches site and gets all links from given site:
```
import urllib2
from bs4 import BeautifulSoup
def getAllLinks(url):
response = urllib2.urlopen(url)
content = response.read()
soup = BeautifulSoup(content, "html5lib")
return soup.find_all("a")
links1 = g... | 2012/04/22 | [
"https://Stackoverflow.com/questions/10269860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/808271/"
] | When a document claims to be XML, I find the lxml parser gives the best results. Trying your code but using the lxml parser instead of html5lib finds the 300 links. | You are precisely right that the problem is the `<?xml...` line. Disregarding it is very simple: just skip the first line of content, by replacing
```
content = response.read()
```
with something like
```
content = "\n".join(response.readlines()[1:])
```
Upon this change, `len(links2)` becomes 300.
ETA: ... |
73,494,380 | I have a script using `docker` python library or [Docker Client API](https://docker-py.readthedocs.io/en/1.8.0/api/#containers). I would like to limit each docker container to use only 10cpus (total 30cpus in the instance), but I couldn't find the solution to achieve that.
I know in docker, there is `--cpus` flag, but... | 2022/08/25 | [
"https://Stackoverflow.com/questions/73494380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16729348/"
] | cPanel has a feature called Multi-PHP, which does what you need (if your host has it enabled).
For each project, it puts a snippet like this in the `.htaccess` which sets the PHP version to use:
```
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming lang... | You can use as many different versions as you want.
Consider:
1. Install PHP versios with PHP-FPM
2. Create directory strucure for each version (website)
3. Configure Apache for Both Websites.
With the above configuration you have combined virtual hosts and PHP-FPM to serve multiple websites and multiple versions of ... |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | The Windows NT Resource Kit introduced the [Srvany.exe command-line utility](http://support.microsoft.com/kb/137890), which can be used to start any Windows NT/2000/2003 application as a service.
You can download Srvany.exe [here](http://www.microsoft.com/download/en/details.aspx?id=17657). | Use Visual Studio and just create yourself a Windows Service project. I think you'll find it very easy. |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | If you already have the executable you wish to run as a service you can use "sc" built into the OS already. Microsoft details the procedure here: <http://support.microsoft.com/kb/251192>
```
example: sc create "My Service" c:\temp\executable.exe
```
>
> C:\Users\somebody>sc create
>
>
>
```
DESCRIPTION: C... | Use Visual Studio and just create yourself a Windows Service project. I think you'll find it very easy. |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | Use Visual Studio and just create yourself a Windows Service project. I think you'll find it very easy. | Can you [schedule a task](http://windows.microsoft.com/en-US/windows7/schedule-a-task)? More info [here](http://technet.microsoft.com/en-us/library/cc770904.aspx). |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | Use Visual Studio and just create yourself a Windows Service project. I think you'll find it very easy. | You can create a startup script and globally apply it to your machines via group policy - just add it via gpedit.msc:
 |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | If you already have the executable you wish to run as a service you can use "sc" built into the OS already. Microsoft details the procedure here: <http://support.microsoft.com/kb/251192>
```
example: sc create "My Service" c:\temp\executable.exe
```
>
> C:\Users\somebody>sc create
>
>
>
```
DESCRIPTION: C... | The Windows NT Resource Kit introduced the [Srvany.exe command-line utility](http://support.microsoft.com/kb/137890), which can be used to start any Windows NT/2000/2003 application as a service.
You can download Srvany.exe [here](http://www.microsoft.com/download/en/details.aspx?id=17657). |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | The Windows NT Resource Kit introduced the [Srvany.exe command-line utility](http://support.microsoft.com/kb/137890), which can be used to start any Windows NT/2000/2003 application as a service.
You can download Srvany.exe [here](http://www.microsoft.com/download/en/details.aspx?id=17657). | Can you [schedule a task](http://windows.microsoft.com/en-US/windows7/schedule-a-task)? More info [here](http://technet.microsoft.com/en-us/library/cc770904.aspx). |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | The Windows NT Resource Kit introduced the [Srvany.exe command-line utility](http://support.microsoft.com/kb/137890), which can be used to start any Windows NT/2000/2003 application as a service.
You can download Srvany.exe [here](http://www.microsoft.com/download/en/details.aspx?id=17657). | You can create a startup script and globally apply it to your machines via group policy - just add it via gpedit.msc:
 |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | If you already have the executable you wish to run as a service you can use "sc" built into the OS already. Microsoft details the procedure here: <http://support.microsoft.com/kb/251192>
```
example: sc create "My Service" c:\temp\executable.exe
```
>
> C:\Users\somebody>sc create
>
>
>
```
DESCRIPTION: C... | Can you [schedule a task](http://windows.microsoft.com/en-US/windows7/schedule-a-task)? More info [here](http://technet.microsoft.com/en-us/library/cc770904.aspx). |
7,073,557 | Question: Is there a way to make a program run with out logging in that doesn't involve the long painful task of creating a windows service, or is there an easy way to make a simple service?
---
Info: I'm working on a little project for college which is a simple distributed processing program. I'm going to harness th... | 2011/08/16 | [
"https://Stackoverflow.com/questions/7073557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186608/"
] | If you already have the executable you wish to run as a service you can use "sc" built into the OS already. Microsoft details the procedure here: <http://support.microsoft.com/kb/251192>
```
example: sc create "My Service" c:\temp\executable.exe
```
>
> C:\Users\somebody>sc create
>
>
>
```
DESCRIPTION: C... | You can create a startup script and globally apply it to your machines via group policy - just add it via gpedit.msc:
 |
26,044,173 | I made a program in python which allows you to type commands (e.g: if you type clock, it shows you the date and time). But, I want it to be fullscreen. The problem is that my software doesnt have gui and I dont want it to so that probably means that I wont be using tkinter or pygame. Can some of you write a whole 'hell... | 2014/09/25 | [
"https://Stackoverflow.com/questions/26044173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4061311/"
] | Since Vista, cmd.exe can no longer go to full-screen mode. You'll need to implement a full-screen console emulator yourself or look for another existing solution. E.g. [ConEmu](http://www.hanselman.com/blog/conemuthewindowsterminalconsolepromptwevebeenwaitingfor.aspx) appears to be able to do it. | Solution
--------
Use your Operating System services to configure parameters.
```
<_aMouseRightClick_>->[Properties]->[Layout]
```
Kindly notice, that some of the `python` interpreter process window parameters are given in [char]-s, while some other in [px]:
```
size.Width [char]-s
size.Height[char]-s
loc.X [... |
40,265,591 | I have a data frame that in which every row represents a day of the week, and every column represents the serial number of an internet-connected device that failed to communicate with the server on that day.
I am trying to get a Series of serial numbers that have failed to communicate for a full week.
The code block:... | 2016/10/26 | [
"https://Stackoverflow.com/questions/40265591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3285817/"
] | You could try something like this, if you pass in the name of the controller as a string. This solution assumes that your models are using `ActiveRecord` prior to rails 5 where `ApplicationRecord` was used to define models; in that case just switch `ActiveRecord::Base` with `ApplicationRecord`. Also if you have models ... | This method doesn't rely on exceptions, and works with input as Class or String. It should work for any Rails version :
```
def has_model?(controller_klass)
all_models = ActiveRecord::Base.descendants.map(&:to_s)
model_klass_string = controller_klass.to_s.sub(/Controller$/,'').singularize
all_models.include?(mod... |
66,942,621 | Im attempting to launch a python script from my Java program - The python script listens for socket connections from the Java program and responds with data.
In order to do this I have attempted to use the ProcessBuilder API to:
1. activate a python virtualenv (located in my working directory)
2. run my python script ... | 2021/04/04 | [
"https://Stackoverflow.com/questions/66942621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15539237/"
] | If your Java program exits, the Python process you launched will exit as well as child processes are killed when a parent process dies unless they have been detached from that process.
If you want your Java program to keep running until the Python program has completed execution, then you need to have the Java code wa... | In the end the solution was simple:
```
Process process = Runtime.getRuntime().exec("<path/to/venv/python_interpreter> "+"path/to/scripytorun.py)
```
In my case the succcessful command was
```
Process process = Runtime.getRuntime().exec( System.getProperty("user.dir")+"/env/bin/python "+System.getProperty("use... |
51,783,232 | I am using python regular expressions. I want all colon separated values in a line.
e.g.
```
input = 'a:b c:d e:f'
expected_output = [('a','b'), ('c', 'd'), ('e', 'f')]
```
But when I do
```
>>> re.findall('(.*)\s?:\s?(.*)','a:b c:d')
```
I get
```
[('a:b c', 'd')]
```
I have also tried
```
>>> re.findall(... | 2018/08/10 | [
"https://Stackoverflow.com/questions/51783232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217998/"
] | Use split instead of regex, also avoid giving variable name like keywords
:
```
inpt = 'a:b c:d e:f'
k= [tuple(i.split(':')) for i in inpt.split()]
print(k)
# [('a', 'b'), ('c', 'd'), ('e', 'f')]
``` | The easiest way using `list comprehension` and `split` :
```
[tuple(ele.split(':')) for ele in input.split(' ')]
```
#driver values :
```
IN : input = 'a:b c:d e:f'
OUT : [('a', 'b'), ('c', 'd'), ('e', 'f')]
``` |
51,783,232 | I am using python regular expressions. I want all colon separated values in a line.
e.g.
```
input = 'a:b c:d e:f'
expected_output = [('a','b'), ('c', 'd'), ('e', 'f')]
```
But when I do
```
>>> re.findall('(.*)\s?:\s?(.*)','a:b c:d')
```
I get
```
[('a:b c', 'd')]
```
I have also tried
```
>>> re.findall(... | 2018/08/10 | [
"https://Stackoverflow.com/questions/51783232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217998/"
] | The following code works for me:
```
inpt = 'a:b c:d e:f'
re.findall('(\S+):(\S+)',inpt)
```
Output:
```
[('a', 'b'), ('c', 'd'), ('e', 'f')]
``` | Use split instead of regex, also avoid giving variable name like keywords
:
```
inpt = 'a:b c:d e:f'
k= [tuple(i.split(':')) for i in inpt.split()]
print(k)
# [('a', 'b'), ('c', 'd'), ('e', 'f')]
``` |
51,783,232 | I am using python regular expressions. I want all colon separated values in a line.
e.g.
```
input = 'a:b c:d e:f'
expected_output = [('a','b'), ('c', 'd'), ('e', 'f')]
```
But when I do
```
>>> re.findall('(.*)\s?:\s?(.*)','a:b c:d')
```
I get
```
[('a:b c', 'd')]
```
I have also tried
```
>>> re.findall(... | 2018/08/10 | [
"https://Stackoverflow.com/questions/51783232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217998/"
] | Use split instead of regex, also avoid giving variable name like keywords
:
```
inpt = 'a:b c:d e:f'
k= [tuple(i.split(':')) for i in inpt.split()]
print(k)
# [('a', 'b'), ('c', 'd'), ('e', 'f')]
``` | You may use
```
list(map(lambda x: tuple(x.split(':')), input.split()))
```
where
`input.split()` is
```
>>> input.split()
['a:b', 'c:d', 'e:f']
```
`lambda x: tuple(x.split(':'))` is function to convert string to tuple `'a:b' => (a, b)`
`map` applies above function to all list elements and returns a map object... |
51,783,232 | I am using python regular expressions. I want all colon separated values in a line.
e.g.
```
input = 'a:b c:d e:f'
expected_output = [('a','b'), ('c', 'd'), ('e', 'f')]
```
But when I do
```
>>> re.findall('(.*)\s?:\s?(.*)','a:b c:d')
```
I get
```
[('a:b c', 'd')]
```
I have also tried
```
>>> re.findall(... | 2018/08/10 | [
"https://Stackoverflow.com/questions/51783232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217998/"
] | The following code works for me:
```
inpt = 'a:b c:d e:f'
re.findall('(\S+):(\S+)',inpt)
```
Output:
```
[('a', 'b'), ('c', 'd'), ('e', 'f')]
``` | The easiest way using `list comprehension` and `split` :
```
[tuple(ele.split(':')) for ele in input.split(' ')]
```
#driver values :
```
IN : input = 'a:b c:d e:f'
OUT : [('a', 'b'), ('c', 'd'), ('e', 'f')]
``` |
51,783,232 | I am using python regular expressions. I want all colon separated values in a line.
e.g.
```
input = 'a:b c:d e:f'
expected_output = [('a','b'), ('c', 'd'), ('e', 'f')]
```
But when I do
```
>>> re.findall('(.*)\s?:\s?(.*)','a:b c:d')
```
I get
```
[('a:b c', 'd')]
```
I have also tried
```
>>> re.findall(... | 2018/08/10 | [
"https://Stackoverflow.com/questions/51783232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217998/"
] | The following code works for me:
```
inpt = 'a:b c:d e:f'
re.findall('(\S+):(\S+)',inpt)
```
Output:
```
[('a', 'b'), ('c', 'd'), ('e', 'f')]
``` | You may use
```
list(map(lambda x: tuple(x.split(':')), input.split()))
```
where
`input.split()` is
```
>>> input.split()
['a:b', 'c:d', 'e:f']
```
`lambda x: tuple(x.split(':'))` is function to convert string to tuple `'a:b' => (a, b)`
`map` applies above function to all list elements and returns a map object... |
36,563,002 | I have a python code. I need to execute the python script from my c# program. After searching a bit about this, I came to know that there is mainly two ways of executing a python script from c#.
One by using 'Process' command and
the other by using Iron Python.
My question might seem dumb, is there any other way th... | 2016/04/12 | [
"https://Stackoverflow.com/questions/36563002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5743035/"
] | The constants you're looking for are not called `LONG_LONG_...`. Check your `limits.h` header. Most likely you're after `ULLONG_MAX`, `LLONG_MAX`, etc. | >
> Why do the integers and long integers have the same limits? Shouldn't the long integers have a larger range of values?
>
>
>
You have stepped into one of the hallmarks of the C language - its adaptability.
C defines the range of `int` to be at least as wide as `short` and the range of `long` to be at least as... |
36,563,002 | I have a python code. I need to execute the python script from my c# program. After searching a bit about this, I came to know that there is mainly two ways of executing a python script from c#.
One by using 'Process' command and
the other by using Iron Python.
My question might seem dumb, is there any other way th... | 2016/04/12 | [
"https://Stackoverflow.com/questions/36563002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5743035/"
] | The constants you're looking for are not called `LONG_LONG_...`. Check your `limits.h` header. Most likely you're after `ULLONG_MAX`, `LLONG_MAX`, etc. | Besides limits.h on a system with specific implementation, also check out what the C standard defines the limits of the various integers:
The values given below shall be replaced by constant expressions suitable for use in #if
preprocessing directives. Moreover, except for CHAR\_BIT and MB\_LEN\_MAX, the
following s... |
36,563,002 | I have a python code. I need to execute the python script from my c# program. After searching a bit about this, I came to know that there is mainly two ways of executing a python script from c#.
One by using 'Process' command and
the other by using Iron Python.
My question might seem dumb, is there any other way th... | 2016/04/12 | [
"https://Stackoverflow.com/questions/36563002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5743035/"
] | The constants are `LLONG_MAX`, `ULLONG_MAX`, etc.
As to why `int` and `long int` have the same value, blame the C standard: it does not define a fixed number of bits for each data type, only the minimum number of bits:
* `int` must be at least 16 bits
* `long int` must be at least 32 bits
* `long long int` must be at... | >
> Why do the integers and long integers have the same limits? Shouldn't the long integers have a larger range of values?
>
>
>
You have stepped into one of the hallmarks of the C language - its adaptability.
C defines the range of `int` to be at least as wide as `short` and the range of `long` to be at least as... |
36,563,002 | I have a python code. I need to execute the python script from my c# program. After searching a bit about this, I came to know that there is mainly two ways of executing a python script from c#.
One by using 'Process' command and
the other by using Iron Python.
My question might seem dumb, is there any other way th... | 2016/04/12 | [
"https://Stackoverflow.com/questions/36563002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5743035/"
] | The constants are `LLONG_MAX`, `ULLONG_MAX`, etc.
As to why `int` and `long int` have the same value, blame the C standard: it does not define a fixed number of bits for each data type, only the minimum number of bits:
* `int` must be at least 16 bits
* `long int` must be at least 32 bits
* `long long int` must be at... | Besides limits.h on a system with specific implementation, also check out what the C standard defines the limits of the various integers:
The values given below shall be replaced by constant expressions suitable for use in #if
preprocessing directives. Moreover, except for CHAR\_BIT and MB\_LEN\_MAX, the
following s... |
36,563,002 | I have a python code. I need to execute the python script from my c# program. After searching a bit about this, I came to know that there is mainly two ways of executing a python script from c#.
One by using 'Process' command and
the other by using Iron Python.
My question might seem dumb, is there any other way th... | 2016/04/12 | [
"https://Stackoverflow.com/questions/36563002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5743035/"
] | >
> Why do the integers and long integers have the same limits? Shouldn't the long integers have a larger range of values?
>
>
>
You have stepped into one of the hallmarks of the C language - its adaptability.
C defines the range of `int` to be at least as wide as `short` and the range of `long` to be at least as... | Besides limits.h on a system with specific implementation, also check out what the C standard defines the limits of the various integers:
The values given below shall be replaced by constant expressions suitable for use in #if
preprocessing directives. Moreover, except for CHAR\_BIT and MB\_LEN\_MAX, the
following s... |
19,940,549 | I am using the [NakedMUD](http://homepages.uc.edu/~hollisgf/nakedmud.html) code base for a project. I am running into an issue in importing modules.
In \*.py (Python files) they import modules with the following syntax:
```
import mudsys, mud, socket, char, hooks
```
and in C to embed Python they use:
```
mudmod =... | 2013/11/12 | [
"https://Stackoverflow.com/questions/19940549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583608/"
] | You may want to enable WCF Tracing and Message Logging, which will allow you to monitor/review communication to/from the WCF service and hopefully isolate the issue (which, based on the provided error message, may likely be a timeout issue.)
The following links provide a good overview:
<http://msdn.microsoft.com/e... | adkSerenity and shambulator,
Thank you. I found the problem. It turned out to be a buffer size. I was pretty sure it wasn't a timeout because the shortest timeout was set to one minute and I could reproduce the error in thirty seconds.
I had been avoiding WCF Tracing and Message Logging because it was so intimidating... |
12,993,175 | I'm having a problem with python keyring after the installation.
here are my steps:
```
$ python
>>> import keyring
>>> keyring.set_password('something','otherSomething','lotOfMoreSomethings')
```
and then throws this:
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/p... | 2012/10/20 | [
"https://Stackoverflow.com/questions/12993175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1715386/"
] | For each market where you have specific requirements due to market-specific licensing or legal issues, you can create a separate app in iTunes Connect and make it available for download only in the relevant market. And if you need to, this also allows you to provide a market-specific EULA. It's a big maintenance burden... | A 3rd party app has no access whatsoever to any information about the user of the device or access to the iTunes account. There is no way to know the user's true country. At any given time, the device may not even be associated with any one person. An iPod touch, for example, may have no user logged into any iTunes acc... |
38,156,681 | I create a custom Authentication backends for my login system. Surely, the custom backends works when I try it in python shell. However, I got error when I run it in the server. The error says "The following fields do not exist in this model or are m2m fields: last\_login". Do I need include the last\_login field in cu... | 2016/07/02 | [
"https://Stackoverflow.com/questions/38156681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5458894/"
] | This is happening because you are using django's [`login()`](https://docs.djangoproject.com/en/1.9/topics/auth/default/#django.contrib.auth.login) function to log the user in.
Django's `login` function emits a signal named `user_logged_in` with the `user` instance you supplied as argument. [See `login()` source](https... | Thanks, I defined a custom `login` method as follows to get through this issue in my automated tests in which I by default keep the signals off.
Here's a working code example.
```
def login(client: Client, user: User) -> None:
"""
Disconnect the update_last_login signal and force_login as `user`
Ref: http... |
50,092,608 | I've defined a helper method to load json from a string or file like so:
```
def get_json_from_string_or_file(obj):
if type(obj) is str:
return json.loads(obj)
return json.load(obj)
```
When I try it with a file it fails on the `load` call with the following exception:
```
File "/usr/local/Cellar/py... | 2018/04/30 | [
"https://Stackoverflow.com/questions/50092608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2155605/"
] | Following code works.
```
import os
import json
def get_json_from_string_or_file(obj):
if type(obj) is str:
return json.loads(obj)
return json.load(obj)
filename = os.path.join(os.path.dirname(__file__), "..", "test.json")
with open(filename, 'r') as f:
result = get_json_from_string_or_file(f)
... | Sorry, I'd comment but I lack the rep. Can you paste a sample JSON file that doesn't work into a pastebin? I'll edit this into an answer after that if I can. |
67,103,105 | I'm trying to upload PDF-file in the Xero account using the python request library (POST method) and Xeros FilesAPI said "Requests must be formatted as multipart MIME" and have some required fields ([link](https://developer.xero.com/documentation/files-api/files#POST)) but I don't how to do that exactly...If I do GET-r... | 2021/04/15 | [
"https://Stackoverflow.com/questions/67103105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9025820/"
] | As I see you're improperly set the boundary. You set it in the headers but not tell to `requests` library to use custom boundary. Let me show you an example:
```
>>> import requests
>>> post_url = 'https://api.xero.com/files.xro/1.0/Files/'
>>> files = {'file': open('/tmp/test.txt', 'rb')}
>>> headers = {
... 'Auth... | I've tested this with Xero's Files API to upload a file called "helloworld.rtf" in the same directory as my main app.py file.
```
var1 = "Bearer "
var2 = YOUR_ACCESS_TOKEN
access_token_header = var1 + var2
body = open('helloworld.rtf', 'rb')
mp_encoder = MultipartEncoder(
fields={
'helloworld.rtf': ('helloworld.... |
67,103,105 | I'm trying to upload PDF-file in the Xero account using the python request library (POST method) and Xeros FilesAPI said "Requests must be formatted as multipart MIME" and have some required fields ([link](https://developer.xero.com/documentation/files-api/files#POST)) but I don't how to do that exactly...If I do GET-r... | 2021/04/15 | [
"https://Stackoverflow.com/questions/67103105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9025820/"
] | As I see you're improperly set the boundary. You set it in the headers but not tell to `requests` library to use custom boundary. Let me show you an example:
```
>>> import requests
>>> post_url = 'https://api.xero.com/files.xro/1.0/Files/'
>>> files = {'file': open('/tmp/test.txt', 'rb')}
>>> headers = {
... 'Auth... | looks like you got it solved. For reference and any future developers who are using the Xero supported package (<https://github.com/XeroAPI/xero-python>)
We just added the files\_api example code to the sample app so the following would upload a file if you were using the Python SDK
<https://github.com/XeroAPI/xero-p... |
19,829,952 | Objective:
Trying to run SL4A facade APIs from python shell on the host system (windows 7 PC)
My environment:
1. On my windows 7 PC, i have python 2.6.2
2. Android sdk tools rev 21, platform tools rev 16
3. API level 17 supported for JB 4.2
4. I have 2 devices ( one running android 2.3.3 and another android 4.2.2) b... | 2013/11/07 | [
"https://Stackoverflow.com/questions/19829952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2949720/"
] | ***You can create your own Video Recording Screen***
Try like this, First Create a Custom Recorder using `SurfaceView`
```
public class VideoCapture extends SurfaceView implements SurfaceHolder.Callback {
private MediaRecorder recorder;
private SurfaceHolder holder;
public Context context;
private C... | This way is using fragments:
```
public class CaptureVideo extends Fragment implements OnClickListener, SurfaceHolder.Callback{
private Button btnStartRec;
MediaRecorder recorder;
SurfaceHolder holder;
boolean recording = false;
private int randomNum;
public void onCreate(Bundle savedInstanc... |
19,829,952 | Objective:
Trying to run SL4A facade APIs from python shell on the host system (windows 7 PC)
My environment:
1. On my windows 7 PC, i have python 2.6.2
2. Android sdk tools rev 21, platform tools rev 16
3. API level 17 supported for JB 4.2
4. I have 2 devices ( one running android 2.3.3 and another android 4.2.2) b... | 2013/11/07 | [
"https://Stackoverflow.com/questions/19829952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2949720/"
] | This is how I achieved it:
```
public class MainActivity extends Activity implements SurfaceHolder.Callback {
private MediaRecorder recorder;
private SurfaceHolder surfaceHolder;
private CamcorderProfile camcorderProfile;
private Camera camera;
boolean recording = false;
boolean usecamera = tru... | ***You can create your own Video Recording Screen***
Try like this, First Create a Custom Recorder using `SurfaceView`
```
public class VideoCapture extends SurfaceView implements SurfaceHolder.Callback {
private MediaRecorder recorder;
private SurfaceHolder holder;
public Context context;
private C... |
19,829,952 | Objective:
Trying to run SL4A facade APIs from python shell on the host system (windows 7 PC)
My environment:
1. On my windows 7 PC, i have python 2.6.2
2. Android sdk tools rev 21, platform tools rev 16
3. API level 17 supported for JB 4.2
4. I have 2 devices ( one running android 2.3.3 and another android 4.2.2) b... | 2013/11/07 | [
"https://Stackoverflow.com/questions/19829952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2949720/"
] | This is how I achieved it:
```
public class MainActivity extends Activity implements SurfaceHolder.Callback {
private MediaRecorder recorder;
private SurfaceHolder surfaceHolder;
private CamcorderProfile camcorderProfile;
private Camera camera;
boolean recording = false;
boolean usecamera = tru... | This way is using fragments:
```
public class CaptureVideo extends Fragment implements OnClickListener, SurfaceHolder.Callback{
private Button btnStartRec;
MediaRecorder recorder;
SurfaceHolder holder;
boolean recording = false;
private int randomNum;
public void onCreate(Bundle savedInstanc... |
64,018,103 | I've been working in a project for about 6 months, and I've been adding more urls each time. Right now, I'm coming into the problem that when I'm using `extend 'base.html'` into another pages, the CSS overlap, and I'm getting a mess.
My question is: Which are the best practices when using `extend` for CSS files? Shoul... | 2020/09/22 | [
"https://Stackoverflow.com/questions/64018103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13821665/"
] | Django provides django.contrib.staticfiles which is tasked with static files(CSS,JavaScript,media).In a nut shell each template in the app will inherit the base static folder in your app
[Read the below doc and see how to configure the static files](https://docs.djangoproject.com/en/3.1/howto/static-files/) | you can add your static files in your template:
```
{% extends 'pythonApp/base.html' %}
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'pathtostaticfile' %}" />
...
``` |
64,018,103 | I've been working in a project for about 6 months, and I've been adding more urls each time. Right now, I'm coming into the problem that when I'm using `extend 'base.html'` into another pages, the CSS overlap, and I'm getting a mess.
My question is: Which are the best practices when using `extend` for CSS files? Shoul... | 2020/09/22 | [
"https://Stackoverflow.com/questions/64018103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13821665/"
] | In your base.html I'd only include styles that are applied to all/several pages on your website.
And then include page-specific styles in that page HTML file.
Storing all styles in 1 file is definitely not a good practice.
Also, I see that you write your CSS selectors using tags like `li` or `nav`, this is generally... | you can add your static files in your template:
```
{% extends 'pythonApp/base.html' %}
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'pathtostaticfile' %}" />
...
``` |
65,278,114 | I'm a beginner currently working on a small python project. It's a dice game in which there is player 1 and player 2. Players take turns to roll the dice and a game is 10 rounds in total(5 rounds for each player). The player with the highest number of points wins.
I am trying to validate the first input so that when f... | 2020/12/13 | [
"https://Stackoverflow.com/questions/65278114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13824901/"
] | Wrap that section of input in a `while True` loop. break the loop when the input is correct, otherwise keep looping for more input.
```
while True:
b = int(input ("is player a Computer (0) or a human (1)?"))
if b == 0:
# player is a computer ...
# do computer stuff
break
elif b == 1... | Because elif is not a loop , compiler just checks the condition and then it moves forward executing the statement.
You can solve this by just adding a \*\*\*while loop \*\*\* before first if condition like this :
for i in range (players):
a = input("name of player: ")
b = int(input ("is player a Computer (0) or a hum... |
65,278,114 | I'm a beginner currently working on a small python project. It's a dice game in which there is player 1 and player 2. Players take turns to roll the dice and a game is 10 rounds in total(5 rounds for each player). The player with the highest number of points wins.
I am trying to validate the first input so that when f... | 2020/12/13 | [
"https://Stackoverflow.com/questions/65278114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13824901/"
] | Wrap that section of input in a `while True` loop. break the loop when the input is correct, otherwise keep looping for more input.
```
while True:
b = int(input ("is player a Computer (0) or a human (1)?"))
if b == 0:
# player is a computer ...
# do computer stuff
break
elif b == 1... | You can also try to split your code and create a new `checkInput` function as implemented below.
```js
list_2 = []
players = int(input("number of players: "))
def checkInput(value):
if value == 0:
list_2.append([a] + [True])
return True
elif value == 1:
list_2.append([a] + [False])
... |
65,940,602 | I'm new to python and I'm using the book called "Automate the Boring Stuff with Python".
I was entering the following code (which was the same as the book):
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
``... | 2021/01/28 | [
"https://Stackoverflow.com/questions/65940602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14883326/"
] | Its perfectly fine just check your indentation | I think it's because of an **indentation**'s mistake.
copy & paste the code below and check if it solves your problem or not.
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
```
indentations are so critical in python programming. you should a... |
65,940,602 | I'm new to python and I'm using the book called "Automate the Boring Stuff with Python".
I was entering the following code (which was the same as the book):
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
``... | 2021/01/28 | [
"https://Stackoverflow.com/questions/65940602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14883326/"
] | Its perfectly fine just check your indentation | Replace string *your name* with your actual name in `if name == 'your name':`This name is what you enter as input, Since your input is not matching with if condition it will fail and break statement is never executed
```
while True:
print('Please type your name.')
name = input()
if name == 'ajay':
... |
65,940,602 | I'm new to python and I'm using the book called "Automate the Boring Stuff with Python".
I was entering the following code (which was the same as the book):
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
``... | 2021/01/28 | [
"https://Stackoverflow.com/questions/65940602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14883326/"
] | Its perfectly fine just check your indentation | The code is correct. Until the if condition is satisfied, it will keep on asking you to type your name. Once the name you entered as input matches with the name in if condition, the loop will come to an end.
Input
```
while True:
print('Please type your name.')
name = input()
if name == 'your ... |
65,940,602 | I'm new to python and I'm using the book called "Automate the Boring Stuff with Python".
I was entering the following code (which was the same as the book):
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
``... | 2021/01/28 | [
"https://Stackoverflow.com/questions/65940602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14883326/"
] | I think it's because of an **indentation**'s mistake.
copy & paste the code below and check if it solves your problem or not.
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
```
indentations are so critical in python programming. you should a... | Replace string *your name* with your actual name in `if name == 'your name':`This name is what you enter as input, Since your input is not matching with if condition it will fail and break statement is never executed
```
while True:
print('Please type your name.')
name = input()
if name == 'ajay':
... |
65,940,602 | I'm new to python and I'm using the book called "Automate the Boring Stuff with Python".
I was entering the following code (which was the same as the book):
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
``... | 2021/01/28 | [
"https://Stackoverflow.com/questions/65940602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14883326/"
] | I think it's because of an **indentation**'s mistake.
copy & paste the code below and check if it solves your problem or not.
```
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
```
indentations are so critical in python programming. you should a... | The code is correct. Until the if condition is satisfied, it will keep on asking you to type your name. Once the name you entered as input matches with the name in if condition, the loop will come to an end.
Input
```
while True:
print('Please type your name.')
name = input()
if name == 'your ... |
61,011,373 | I'm trying to install indy-node on a fresh Ubuntu 18.04 machine in order to create a small network with 4 nodes.
when following the [installation instructions](https://github.com/hyperledger/indy-node/blob/master/docs/source/start-nodes.md) I get the following error:
```
localhost:~$ sudo apt-get install indy-node
T... | 2020/04/03 | [
"https://Stackoverflow.com/questions/61011373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786712/"
] | We've generated Docker images for Indy-Node using Ubuntu 18.04, but had to build libsodium from source. You can see the source dockerfile here although there are git URLs that get replaced by the build script: <https://github.com/PSPC-SPAC-buyandsell/von-image/blob/master/node-1.9/Dockerfile.ubuntu>
The final images a... | The solution in the end was to downgrade to Ubuntu 16.04 |
49,738,443 | I'm attempting to convert an array of strings to array of floats using :
```
arr_str = '[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]'
a1 = arr_str.split()
[int(x) for x in a1]
```
but throws error :
<
```
ipython-input-57-f7f1eaba7ebd> in <listcomp>(.0)
3 a1 = arr_str.split()
4
----> 5 [int(x) for x in a1]... | 2018/04/09 | [
"https://Stackoverflow.com/questions/49738443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/470184/"
] | One way is to use `ast.literal_eval`.
If you need a `numpy` integer array, the conversion is trivial.
```
import numpy as np
from ast import literal_eval
arr_str = '[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]'
res = literal_eval(arr_str.replace(' ', ','))
# [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
res_np = np.... | ```
arr_str = arr_str.strip("[]")
voila = [int(x) for x in arr_str.split()]
```
Edit 1: Being pedantic about variable assignment. |
49,738,443 | I'm attempting to convert an array of strings to array of floats using :
```
arr_str = '[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]'
a1 = arr_str.split()
[int(x) for x in a1]
```
but throws error :
<
```
ipython-input-57-f7f1eaba7ebd> in <listcomp>(.0)
3 a1 = arr_str.split()
4
----> 5 [int(x) for x in a1]... | 2018/04/09 | [
"https://Stackoverflow.com/questions/49738443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/470184/"
] | One way is to use `ast.literal_eval`.
If you need a `numpy` integer array, the conversion is trivial.
```
import numpy as np
from ast import literal_eval
arr_str = '[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]'
res = literal_eval(arr_str.replace(' ', ','))
# [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
res_np = np.... | You can use the `ast` module:
```
import ast
arr_str = '[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]'
arr = ast.literal_eval(arr_str.replace(" ",", "))
arr = list(map(float,arr)) #Remove this line if you wish integer conversion.
print(arr)
```
Output:
```
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1... |
27,532,112 | I'm using two python packages that have the same name.
* <http://www.alembic.io/updates.html>
* <https://pypi.python.org/pypi/alembic>
Is there a canonical or pythonic way to handle installing two packages with conflicting names? So far, I've only occasionally needed one of the packages during development/building, ... | 2014/12/17 | [
"https://Stackoverflow.com/questions/27532112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1547004/"
] | You could use the --target option for pip and install to an alternate location:
```
pip install --target=/tmp/test/lib/python3.6/site-packages/alt_alembic alembic
```
Then when you import in python, do the first as usual and for the alt do an import from that namespace like this:
```
import alembic # alembic.io ve... | how about **absolute and relative imports.**
<https://docs.python.org/2/whatsnew/2.5.html#pep-328-absolute-and-relative-imports> |
43,429,018 | i have the following link:
<https://webcache.googleusercontent.com/search?q=cache:jAc7OJyyQboJ>:**<https://cooking.nytimes.com/learn-to-cook>**+&cd=5&hl=en&ct=clnk
I have multiple links in a dataset. Each link is of same pattern. I want to get a specific part of the link, for the above link i would be the bold part of... | 2017/04/15 | [
"https://Stackoverflow.com/questions/43429018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7872059/"
] | Instead of `var c = new Audio(src);` use `var c = document.createElement('audio'); c.src=src; c.play();` | You have to wait for the DOM to be ready. Since your are using jQuery, please encapsulate your code in that:
```
$(document).ready(function () {
// Your code...
});
```
You can also use this syntax:
```
$(function () {
// Your code...
});
```
*(Bonus tip: use the `switch` instruction in your code. `RoNBeta.js... |
43,429,018 | i have the following link:
<https://webcache.googleusercontent.com/search?q=cache:jAc7OJyyQboJ>:**<https://cooking.nytimes.com/learn-to-cook>**+&cd=5&hl=en&ct=clnk
I have multiple links in a dataset. Each link is of same pattern. I want to get a specific part of the link, for the above link i would be the bold part of... | 2017/04/15 | [
"https://Stackoverflow.com/questions/43429018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7872059/"
] | The accepted answer doesn't look like the best way to address that issue to me. You should either change your `JSLint` options or disable that rule on that specific line.
### Add it as a global
In both `JSLint` and [`ESLint`](https://eslint.org/docs/user-guide/configuring#specifying-globals), you can fix it either a... | You have to wait for the DOM to be ready. Since your are using jQuery, please encapsulate your code in that:
```
$(document).ready(function () {
// Your code...
});
```
You can also use this syntax:
```
$(function () {
// Your code...
});
```
*(Bonus tip: use the `switch` instruction in your code. `RoNBeta.js... |
43,429,018 | i have the following link:
<https://webcache.googleusercontent.com/search?q=cache:jAc7OJyyQboJ>:**<https://cooking.nytimes.com/learn-to-cook>**+&cd=5&hl=en&ct=clnk
I have multiple links in a dataset. Each link is of same pattern. I want to get a specific part of the link, for the above link i would be the bold part of... | 2017/04/15 | [
"https://Stackoverflow.com/questions/43429018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7872059/"
] | Instead of `var c = new Audio(src);` use `var c = document.createElement('audio'); c.src=src; c.play();` | The accepted answer doesn't look like the best way to address that issue to me. You should either change your `JSLint` options or disable that rule on that specific line.
### Add it as a global
In both `JSLint` and [`ESLint`](https://eslint.org/docs/user-guide/configuring#specifying-globals), you can fix it either a... |
50,706,987 | I've been trying for a couple of days with limited success to use TCP to make two ruby programs on the same or different machines communicate.
I'm looking for example 'client' and 'server' scripts that will work straight away, once I've chosen ports that work.
Client code I found that seems to work, shown below.
But... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50706987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336879/"
] | @adjam you haven't created a TcpServer,
[TCPSocket](https://ruby-doc.org/stdlib-1.9.3/libdoc/socket/rdoc/TCPSocket.html) is used to create TCP/IP client socket
To create TCP/IP server you have to use [TCPServer](https://ruby-doc.org/stdlib-1.9.3/libdoc/socket/rdoc/TCPServer.html)
EX:
Tcp/ip Server code:
```
require ... | Taking the documentation from <https://ruby-doc.org/stdlib-2.5.1/libdoc/socket/rdoc/Socket.html>, you seem to be looking for something like this:
```
require 'socket'
server = TCPServer.new(1540)
client = server.accept
client.puts "GETHELLO"
client.close
server.close
```
More generally, if you'd like the server acce... |
50,706,987 | I've been trying for a couple of days with limited success to use TCP to make two ruby programs on the same or different machines communicate.
I'm looking for example 'client' and 'server' scripts that will work straight away, once I've chosen ports that work.
Client code I found that seems to work, shown below.
But... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50706987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336879/"
] | Taking the documentation from <https://ruby-doc.org/stdlib-2.5.1/libdoc/socket/rdoc/Socket.html>, you seem to be looking for something like this:
```
require 'socket'
server = TCPServer.new(1540)
client = server.accept
client.puts "GETHELLO"
client.close
server.close
```
More generally, if you'd like the server acce... | `tcp_server.rb`
```rb
require "socket"
server = TCPServer.new(1234)
loop do # Keep the server alive
session = server.accept
puts "Request arrived"
session.write "Time is #{Time.now}" # Send data to client
session.close
end
```
`tcp_client.rb`
```rb
require "socket"
socket = TCPSocket.open("localhost", 1... |
50,706,987 | I've been trying for a couple of days with limited success to use TCP to make two ruby programs on the same or different machines communicate.
I'm looking for example 'client' and 'server' scripts that will work straight away, once I've chosen ports that work.
Client code I found that seems to work, shown below.
But... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50706987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336879/"
] | @adjam you haven't created a TcpServer,
[TCPSocket](https://ruby-doc.org/stdlib-1.9.3/libdoc/socket/rdoc/TCPSocket.html) is used to create TCP/IP client socket
To create TCP/IP server you have to use [TCPServer](https://ruby-doc.org/stdlib-1.9.3/libdoc/socket/rdoc/TCPServer.html)
EX:
Tcp/ip Server code:
```
require ... | `tcp_server.rb`
```rb
require "socket"
server = TCPServer.new(1234)
loop do # Keep the server alive
session = server.accept
puts "Request arrived"
session.write "Time is #{Time.now}" # Send data to client
session.close
end
```
`tcp_client.rb`
```rb
require "socket"
socket = TCPSocket.open("localhost", 1... |
6,844,863 | Relative import not working properly in python2.6.5 getting "ValueError: Attempted relative import in non-package".
I am having all those `__init__.py` in proper place. | 2011/07/27 | [
"https://Stackoverflow.com/questions/6844863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/865438/"
] | I have seen that error before when running a script that is actually *inside* a package. To the interpreter, it appears as though the package is not a package.
Try taking the script into another directory, putting your package inside your `pythonpath`, and import absolutely. Then, relative imports inside your package ... | ```
main.py
setup.py
Main Package/ ->
__init__.py
subpackage_a/ ->
__init__.py
module_a.py
subpackage_b/ ->
__init__.py
module_b.py
```
i)
```
1.You run python main.py
2.main.py does: import app.package_a.module_a
3.module_a.py does import app.package_b.module_b
... |
45,301,335 | I am using Python + IPython for Data Science. I made a folder that contains all the modules I wrote, organised in packages, something like
```
python_workfolder
|
|---a
| |---__init__.py
| |---a1.py
| |---a2.py
|
|---b
| |---__init__.py
| |---b1.py
| |---b2.py
|
|---c
| |---__init__.py
| |---c1.py
| ... | 2017/07/25 | [
"https://Stackoverflow.com/questions/45301335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2558671/"
] | Just type:
```
last root
```
This will give you details of the IP addresses of machines where users logged in as root. | Without knowing your Input\_file I am providing this solution, so could you please try following and let me know if this helps you.
```
awk '{match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/);array[substr($0,RSTART,RLENGTH)]} END{for(i in array){print i,array[i]}}' Input_file
```
If above is not helping you then kindly ... |
32,031,111 | I am trying to run a simple Python script with crontab, but I can’t get it to work. I can run a simple program in crontab when not using Python though. Here is the line I have in my Crontab file that does work:
```
* * * * * echo “cron test” >> /home/ftpuser/dev/mod_high_lows/hello.txt
```
I also can run this python... | 2015/08/16 | [
"https://Stackoverflow.com/questions/32031111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1087809/"
] | * cron runs commands in a limited environment. Only a few environment variables
are automatically set. It loads the environment specified by `/etc/environment`
and `/etc/security/pam_env.conf`, but not about the environment variables you
might have set in your `.bashrc` or `.profile`.
Set the crontab entry
```
* * ... | I'm not sure if this will help, but I've always successfully managed to get python scripts to run successfully from cron by adding this line to the end of the crontab file:
```
@reboot python /home/ftpuser/dev/mod_high_lows/testit.py &
```
The `&` is necessary at the end of the line. If this is what you need, and yo... |
32,031,111 | I am trying to run a simple Python script with crontab, but I can’t get it to work. I can run a simple program in crontab when not using Python though. Here is the line I have in my Crontab file that does work:
```
* * * * * echo “cron test” >> /home/ftpuser/dev/mod_high_lows/hello.txt
```
I also can run this python... | 2015/08/16 | [
"https://Stackoverflow.com/questions/32031111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1087809/"
] | * cron runs commands in a limited environment. Only a few environment variables
are automatically set. It loads the environment specified by `/etc/environment`
and `/etc/security/pam_env.conf`, but not about the environment variables you
might have set in your `.bashrc` or `.profile`.
Set the crontab entry
```
* * ... | One thing that always gets me: You have to leave a blank line at the end of the crontab file. Cron will not run the last line of the crontab! |
62,714,282 | In the [ThreadPoolExecutor documentation](https://docs.python.org/3/library/concurrent.futures.html) it says:
>
> Changed in version 3.5: If `max_workers` is `None` or not given, it will default to the number of processors on the machine, multiplied by 5, assuming that `ThreadPoolExecutor` is often used to overlap I/... | 2020/07/03 | [
"https://Stackoverflow.com/questions/62714282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13859123/"
] | You are writing `binascii.hexlify(self._public_key.exportKey(format='DER')).decode('ascii')` at the next line. Try writing it after the `return` keyword. Hope your error will go away | you should define a Clinet instance and then get it's \_public\_key:
```
binascii.hexlify(Client._public_key.exportKey(format='DER')).decode('ascii')
``` |
62,714,282 | In the [ThreadPoolExecutor documentation](https://docs.python.org/3/library/concurrent.futures.html) it says:
>
> Changed in version 3.5: If `max_workers` is `None` or not given, it will default to the number of processors on the machine, multiplied by 5, assuming that `ThreadPoolExecutor` is often used to overlap I/... | 2020/07/03 | [
"https://Stackoverflow.com/questions/62714282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13859123/"
] | You are writing `binascii.hexlify(self._public_key.exportKey(format='DER')).decode('ascii')` at the next line. Try writing it after the `return` keyword. Hope your error will go away | You need to get the `identity` property with the help of a function, not as a plain attribute. Modify your `identity()` function as follows:
```
def identity(self):
idn = binascii.hexlify(self._public_key.exportKey(format='DER')).decode('ascii') # <------
return idn # <------
```
And then, you can call it li... |
38,044,788 | it's login is fine, but i am not able to track the issue, here the code below
```
while True:
time.sleep(10)
browser.get("https://www.instagram.com/accounts/edit/?wo=1")
```
I am getting this error when i ran project.py
```
Superuser$ python project.py
user diabruxaneas1989 with proxy 192.126.1... | 2016/06/27 | [
"https://Stackoverflow.com/questions/38044788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6445447/"
] | You forgot to close the `href` attribute (double-quotes):
```
echo '<a href="directMessageRoom.php?directMessageRoomID='.$row3['id'].'"></a>';
right here ---^
``` | Be aware of lots of 'white-space' in your form field. Your submit button for example, you write this `<input type = "submit" ...>`. You are accidentally insert white space. It should be `<input type="submit" ...>`. |
55,549,014 | I get the syntax error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
when running the below code.
It is a little hard to find a good solution for this problem on windows which I am running as compared to UNIX which I can find working code for.
```
from subprocess import Popen, check_cal... | 2019/04/06 | [
"https://Stackoverflow.com/questions/55549014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6104634/"
] | A big problem there is that your width will be zero.
The X and Y scales are factors. As in multipliers. Anything times Zero is zero.
Hence
```
ScaleTransform(0, -1);
```
Will give you something with no width.
You presumably want the same width and hence:
```
ScaleTransform(1, -1);
```
That might still have anoth... | Just set the PathGeometry's `Transform` property:
```
var myPathGeometry = new PathGeometry();
myPathGeometry.Figures.Add(myPathFigure);
myPathGeometry.Transform = new ScaleTransform(1, -1);
```
Note that you may also need to set the ScaleTransform's `CenterY` property for a correct vertical alignment. |
55,549,014 | I get the syntax error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
when running the below code.
It is a little hard to find a good solution for this problem on windows which I am running as compared to UNIX which I can find working code for.
```
from subprocess import Popen, check_cal... | 2019/04/06 | [
"https://Stackoverflow.com/questions/55549014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6104634/"
] | Just set the PathGeometry's `Transform` property:
```
var myPathGeometry = new PathGeometry();
myPathGeometry.Figures.Add(myPathFigure);
myPathGeometry.Transform = new ScaleTransform(1, -1);
```
Note that you may also need to set the ScaleTransform's `CenterY` property for a correct vertical alignment. | Both @Andy and @Clemens gave right answers. The reason why I didn't get the expected shape is because I didn't notice that the shape is outside the screen region. However, I used Andy's solution because I need to keep the original shape. Also, he notified me about creating new bounds. The only thing I changed in his an... |
55,549,014 | I get the syntax error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
when running the below code.
It is a little hard to find a good solution for this problem on windows which I am running as compared to UNIX which I can find working code for.
```
from subprocess import Popen, check_cal... | 2019/04/06 | [
"https://Stackoverflow.com/questions/55549014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6104634/"
] | A big problem there is that your width will be zero.
The X and Y scales are factors. As in multipliers. Anything times Zero is zero.
Hence
```
ScaleTransform(0, -1);
```
Will give you something with no width.
You presumably want the same width and hence:
```
ScaleTransform(1, -1);
```
That might still have anoth... | Both @Andy and @Clemens gave right answers. The reason why I didn't get the expected shape is because I didn't notice that the shape is outside the screen region. However, I used Andy's solution because I need to keep the original shape. Also, he notified me about creating new bounds. The only thing I changed in his an... |
63,614,832 | I've faced an global issue recently and I have no idea for this behavior in python:
```
# declaring some global variables
variable = 'peter'
list_variable_1 = ['a','b']
list_variable_2 = ['c','d']
def update_global_variables():
"""without using global line"""
variable = 'PETER' # won't update in global scope
... | 2020/08/27 | [
"https://Stackoverflow.com/questions/63614832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6756530/"
] | from [exitBeforeEnter](https://www.framer.com/api/motion/animate-presence/#animatepresenceprops.exitbeforeenter) docs
>
> If set to `true`, `AnimatePresence` will only render one component at a time. The exiting component will finished its exit animation before the entering component is rendered.
>
>
>
You have t... | That's normal if you will not add an `exit` animation to each and every routes.
Main route with AnimatePresense
```
<AnimatePresence exitBeforeEnter>
<Switch location={window.location} key={window.location.pathname}>
<Route exact path='/' component={Home} />
<Route exact path='/about' component={About} />
... |
63,614,832 | I've faced an global issue recently and I have no idea for this behavior in python:
```
# declaring some global variables
variable = 'peter'
list_variable_1 = ['a','b']
list_variable_2 = ['c','d']
def update_global_variables():
"""without using global line"""
variable = 'PETER' # won't update in global scope
... | 2020/08/27 | [
"https://Stackoverflow.com/questions/63614832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6756530/"
] | from [exitBeforeEnter](https://www.framer.com/api/motion/animate-presence/#animatepresenceprops.exitbeforeenter) docs
>
> If set to `true`, `AnimatePresence` will only render one component at a time. The exiting component will finished its exit animation before the entering component is rendered.
>
>
>
You have t... | For those of you still lost, you need to wrap the <motion.div> tag AROUND the < redirect > tag with an "exit" parameter as mentioned in the other answers. Example code is provided below.
```
return (
<motion.div exit='exit' variants={PageTransition} initial='hidden' animate='show' className='login-contain... |
63,614,832 | I've faced an global issue recently and I have no idea for this behavior in python:
```
# declaring some global variables
variable = 'peter'
list_variable_1 = ['a','b']
list_variable_2 = ['c','d']
def update_global_variables():
"""without using global line"""
variable = 'PETER' # won't update in global scope
... | 2020/08/27 | [
"https://Stackoverflow.com/questions/63614832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6756530/"
] | from [exitBeforeEnter](https://www.framer.com/api/motion/animate-presence/#animatepresenceprops.exitbeforeenter) docs
>
> If set to `true`, `AnimatePresence` will only render one component at a time. The exiting component will finished its exit animation before the entering component is rendered.
>
>
>
You have t... | Does anyone have an update with react-router-dom v6 ?
I'm rewriting a small app I made some months ago, and it was working perfectly before, with `AnimatePresence` and `Switch` Router components. Exit transitions were running successfully between pages changes.
Now for some reason, exit transitions don't trigger on p... |
63,614,832 | I've faced an global issue recently and I have no idea for this behavior in python:
```
# declaring some global variables
variable = 'peter'
list_variable_1 = ['a','b']
list_variable_2 = ['c','d']
def update_global_variables():
"""without using global line"""
variable = 'PETER' # won't update in global scope
... | 2020/08/27 | [
"https://Stackoverflow.com/questions/63614832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6756530/"
] | That's normal if you will not add an `exit` animation to each and every routes.
Main route with AnimatePresense
```
<AnimatePresence exitBeforeEnter>
<Switch location={window.location} key={window.location.pathname}>
<Route exact path='/' component={Home} />
<Route exact path='/about' component={About} />
... | For those of you still lost, you need to wrap the <motion.div> tag AROUND the < redirect > tag with an "exit" parameter as mentioned in the other answers. Example code is provided below.
```
return (
<motion.div exit='exit' variants={PageTransition} initial='hidden' animate='show' className='login-contain... |
63,614,832 | I've faced an global issue recently and I have no idea for this behavior in python:
```
# declaring some global variables
variable = 'peter'
list_variable_1 = ['a','b']
list_variable_2 = ['c','d']
def update_global_variables():
"""without using global line"""
variable = 'PETER' # won't update in global scope
... | 2020/08/27 | [
"https://Stackoverflow.com/questions/63614832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6756530/"
] | That's normal if you will not add an `exit` animation to each and every routes.
Main route with AnimatePresense
```
<AnimatePresence exitBeforeEnter>
<Switch location={window.location} key={window.location.pathname}>
<Route exact path='/' component={Home} />
<Route exact path='/about' component={About} />
... | Does anyone have an update with react-router-dom v6 ?
I'm rewriting a small app I made some months ago, and it was working perfectly before, with `AnimatePresence` and `Switch` Router components. Exit transitions were running successfully between pages changes.
Now for some reason, exit transitions don't trigger on p... |
63,614,832 | I've faced an global issue recently and I have no idea for this behavior in python:
```
# declaring some global variables
variable = 'peter'
list_variable_1 = ['a','b']
list_variable_2 = ['c','d']
def update_global_variables():
"""without using global line"""
variable = 'PETER' # won't update in global scope
... | 2020/08/27 | [
"https://Stackoverflow.com/questions/63614832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6756530/"
] | For those of you still lost, you need to wrap the <motion.div> tag AROUND the < redirect > tag with an "exit" parameter as mentioned in the other answers. Example code is provided below.
```
return (
<motion.div exit='exit' variants={PageTransition} initial='hidden' animate='show' className='login-contain... | Does anyone have an update with react-router-dom v6 ?
I'm rewriting a small app I made some months ago, and it was working perfectly before, with `AnimatePresence` and `Switch` Router components. Exit transitions were running successfully between pages changes.
Now for some reason, exit transitions don't trigger on p... |
11,767,757 | This issue just started, last week I had no issues with the particular source file.
I'm using SQLAlchemy and Geoalchemy and the particular block of code that triggers Eclipse and Aptana to start pegging the cpu while simply editing the file is:
```
obsRecs = db.session.query(multi_obs)\
.join(sensor,sensor.row_id == m... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11767757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1569769/"
] | I was running into the same problem but for a different, long query. I tried disabling auto-complete, tried the `-clean` thing, no luck.
To fix, I waited for the memory leak to explode and used `jmap.exe` to dump the heap. I then ran Eclipse Memory Analyzer to see where my memory was going, the screenshot is attached ... | In the past I have had some success solving Eclipse insanity by starting with a clean workspace.
It's kind of a shot in the dark, but try the following one by one:
1. Start eclipse with the `-clean` option and the existing workspace.
2. If the above does not work, try editing the same file in a new workspace.
If yo... |
11,767,757 | This issue just started, last week I had no issues with the particular source file.
I'm using SQLAlchemy and Geoalchemy and the particular block of code that triggers Eclipse and Aptana to start pegging the cpu while simply editing the file is:
```
obsRecs = db.session.query(multi_obs)\
.join(sensor,sensor.row_id == m... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11767757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1569769/"
] | In the past I have had some success solving Eclipse insanity by starting with a clean workspace.
It's kind of a shot in the dark, but try the following one by one:
1. Start eclipse with the `-clean` option and the existing workspace.
2. If the above does not work, try editing the same file in a new workspace.
If yo... | Again I too ran into this problem. I followed all the usual advice about memory settings, disabling code completion etc.
I was running Eclipse 4.2 on Mountain Lion. I tried upgrading to 4.3 and even tried the 4.3 32 bit version. nothing was working.
I casually noticed that one Python module in particular was the cau... |
11,767,757 | This issue just started, last week I had no issues with the particular source file.
I'm using SQLAlchemy and Geoalchemy and the particular block of code that triggers Eclipse and Aptana to start pegging the cpu while simply editing the file is:
```
obsRecs = db.session.query(multi_obs)\
.join(sensor,sensor.row_id == m... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11767757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1569769/"
] | I was running into the same problem but for a different, long query. I tried disabling auto-complete, tried the `-clean` thing, no luck.
To fix, I waited for the memory leak to explode and used `jmap.exe` to dump the heap. I then ran Eclipse Memory Analyzer to see where my memory was going, the screenshot is attached ... | For me that appears like a bug in the PyDev type inference engine... (could be looping until an out of memory error occurs). Just with that subset of your code I was not able to reproduce it here (i.e.: installing sqlalchemy and geoalchemy, creating a project with that file as a source file and working with the file di... |
11,767,757 | This issue just started, last week I had no issues with the particular source file.
I'm using SQLAlchemy and Geoalchemy and the particular block of code that triggers Eclipse and Aptana to start pegging the cpu while simply editing the file is:
```
obsRecs = db.session.query(multi_obs)\
.join(sensor,sensor.row_id == m... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11767757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1569769/"
] | For me that appears like a bug in the PyDev type inference engine... (could be looping until an out of memory error occurs). Just with that subset of your code I was not able to reproduce it here (i.e.: installing sqlalchemy and geoalchemy, creating a project with that file as a source file and working with the file di... | Again I too ran into this problem. I followed all the usual advice about memory settings, disabling code completion etc.
I was running Eclipse 4.2 on Mountain Lion. I tried upgrading to 4.3 and even tried the 4.3 32 bit version. nothing was working.
I casually noticed that one Python module in particular was the cau... |
11,767,757 | This issue just started, last week I had no issues with the particular source file.
I'm using SQLAlchemy and Geoalchemy and the particular block of code that triggers Eclipse and Aptana to start pegging the cpu while simply editing the file is:
```
obsRecs = db.session.query(multi_obs)\
.join(sensor,sensor.row_id == m... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11767757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1569769/"
] | I was running into the same problem but for a different, long query. I tried disabling auto-complete, tried the `-clean` thing, no luck.
To fix, I waited for the memory leak to explode and used `jmap.exe` to dump the heap. I then ran Eclipse Memory Analyzer to see where my memory was going, the screenshot is attached ... | Again I too ran into this problem. I followed all the usual advice about memory settings, disabling code completion etc.
I was running Eclipse 4.2 on Mountain Lion. I tried upgrading to 4.3 and even tried the 4.3 32 bit version. nothing was working.
I casually noticed that one Python module in particular was the cau... |
394,500 | In the python program I'm writing, I've got a thread which iterates over a large structure in memory and writes it incrementally into a file-like object. I've got another thread which takes a file-like object and writes it to disk. Is there an easy way to connect the two, such that any data input from the first thread ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9161/"
] | You should use the [Queue](http://docs.python.org/library/queue.html) module for sharing sequential data across threads. You would have to make a file-like Queue subclass, where .read and .write mutually block each other, with a buffer in-between.
OTOH, I wonder why the first thread can't write to the real file in the... | I'm not clear what you're trying to do ehre. This sounds like a job for a regular old pipe, which is a file-like object. I'm guessing, however, that you mean you're got a stream of some other sort.
It also sounds a lot like what you want is a python [Queue](http://docs.python.org/library/queue.html), or maybe a [tempf... |
394,500 | In the python program I'm writing, I've got a thread which iterates over a large structure in memory and writes it incrementally into a file-like object. I've got another thread which takes a file-like object and writes it to disk. Is there an easy way to connect the two, such that any data input from the first thread ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9161/"
] | You should use the [Queue](http://docs.python.org/library/queue.html) module for sharing sequential data across threads. You would have to make a file-like Queue subclass, where .read and .write mutually block each other, with a buffer in-between.
OTOH, I wonder why the first thread can't write to the real file in the... | I think there is something wrong in the design if you already have a file-like object if you want your data to end up in the subprocess. You should then arrange that they get written into the subprocess in the first place, rather than having them written into something else file-like first. Whoever is writing the data ... |
394,500 | In the python program I'm writing, I've got a thread which iterates over a large structure in memory and writes it incrementally into a file-like object. I've got another thread which takes a file-like object and writes it to disk. Is there an easy way to connect the two, such that any data input from the first thread ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9161/"
] | I think there is something wrong in the design if you already have a file-like object if you want your data to end up in the subprocess. You should then arrange that they get written into the subprocess in the first place, rather than having them written into something else file-like first. Whoever is writing the data ... | I'm not clear what you're trying to do ehre. This sounds like a job for a regular old pipe, which is a file-like object. I'm guessing, however, that you mean you're got a stream of some other sort.
It also sounds a lot like what you want is a python [Queue](http://docs.python.org/library/queue.html), or maybe a [tempf... |
394,500 | In the python program I'm writing, I've got a thread which iterates over a large structure in memory and writes it incrementally into a file-like object. I've got another thread which takes a file-like object and writes it to disk. Is there an easy way to connect the two, such that any data input from the first thread ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9161/"
] | Use [`shutil`'s `copyfileobj()`](http://docs.python.org/library/shutil.html#shutil.copyfileobj) function:
```
import shutil
import subprocess
proc = subprocess.Popen([...], stdin=subprocess.PIPE)
my_input = get_filelike_object('from a place not given in the question')
shutil.copyfileobj(my_input, proc.stdin)
```
... | I'm not clear what you're trying to do ehre. This sounds like a job for a regular old pipe, which is a file-like object. I'm guessing, however, that you mean you're got a stream of some other sort.
It also sounds a lot like what you want is a python [Queue](http://docs.python.org/library/queue.html), or maybe a [tempf... |
394,500 | In the python program I'm writing, I've got a thread which iterates over a large structure in memory and writes it incrementally into a file-like object. I've got another thread which takes a file-like object and writes it to disk. Is there an easy way to connect the two, such that any data input from the first thread ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9161/"
] | Use [`shutil`'s `copyfileobj()`](http://docs.python.org/library/shutil.html#shutil.copyfileobj) function:
```
import shutil
import subprocess
proc = subprocess.Popen([...], stdin=subprocess.PIPE)
my_input = get_filelike_object('from a place not given in the question')
shutil.copyfileobj(my_input, proc.stdin)
```
... | I think there is something wrong in the design if you already have a file-like object if you want your data to end up in the subprocess. You should then arrange that they get written into the subprocess in the first place, rather than having them written into something else file-like first. Whoever is writing the data ... |
25,387,286 | When I do `pip install statsmodels` it gives me `ImportError: statsmodels requires patsy. http://patsy.readthedocs.org`, but then I run `pip install patsy` and it says its successful, but running `pip install statsmodels` still gives me same error about requiring patsy.
How can this be?
---
```
$ sudo pip install pa... | 2014/08/19 | [
"https://Stackoverflow.com/questions/25387286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3391108/"
] | What the error message doesn't tell you is that the module `six` not being there is really the problem.
Found this out by doing `import patsy` and having it fail and tell me that I needed `six`. So I did `pip install six` and now the patsy import worked, as did the `pip install statsmodels`. | For me:
```
$python3 -m pip install --upgrade patsy
$python3 -m pip install statsmodels
```
worked! |
25,387,286 | When I do `pip install statsmodels` it gives me `ImportError: statsmodels requires patsy. http://patsy.readthedocs.org`, but then I run `pip install patsy` and it says its successful, but running `pip install statsmodels` still gives me same error about requiring patsy.
How can this be?
---
```
$ sudo pip install pa... | 2014/08/19 | [
"https://Stackoverflow.com/questions/25387286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3391108/"
] | What the error message doesn't tell you is that the module `six` not being there is really the problem.
Found this out by doing `import patsy` and having it fail and tell me that I needed `six`. So I did `pip install six` and now the patsy import worked, as did the `pip install statsmodels`. | I also had an issue with this in Python 3.4. It worked using the WHL statsmodel file at this link: <https://pypi.python.org/pypi/statsmodels#downloads>
After the download I installed it using: pip3.4 install my\_directory\statsmodels-0.8.0rc1-cp34-none-win\_amd64.whl, where my\_directory is where I put the WHL file. |
25,387,286 | When I do `pip install statsmodels` it gives me `ImportError: statsmodels requires patsy. http://patsy.readthedocs.org`, but then I run `pip install patsy` and it says its successful, but running `pip install statsmodels` still gives me same error about requiring patsy.
How can this be?
---
```
$ sudo pip install pa... | 2014/08/19 | [
"https://Stackoverflow.com/questions/25387286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3391108/"
] | What the error message doesn't tell you is that the module `six` not being there is really the problem.
Found this out by doing `import patsy` and having it fail and tell me that I needed `six`. So I did `pip install six` and now the patsy import worked, as did the `pip install statsmodels`. | For anyone still experiencing issues, I highly recommend this site:
[Python libraries](http://www.lfd.uci.edu/~gohlke/pythonlibs/#statsmodels). I'm using Python 3, so I,
1. Downloaded the file named: `statsmodels‑0.8.0‑cp35‑cp35m‑win_amd64.whl`
2. Opened windows command prompt
3. Went to my Downloads directory (`cd Do... |
25,387,286 | When I do `pip install statsmodels` it gives me `ImportError: statsmodels requires patsy. http://patsy.readthedocs.org`, but then I run `pip install patsy` and it says its successful, but running `pip install statsmodels` still gives me same error about requiring patsy.
How can this be?
---
```
$ sudo pip install pa... | 2014/08/19 | [
"https://Stackoverflow.com/questions/25387286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3391108/"
] | For me:
```
$python3 -m pip install --upgrade patsy
$python3 -m pip install statsmodels
```
worked! | I also had an issue with this in Python 3.4. It worked using the WHL statsmodel file at this link: <https://pypi.python.org/pypi/statsmodels#downloads>
After the download I installed it using: pip3.4 install my\_directory\statsmodels-0.8.0rc1-cp34-none-win\_amd64.whl, where my\_directory is where I put the WHL file. |
25,387,286 | When I do `pip install statsmodels` it gives me `ImportError: statsmodels requires patsy. http://patsy.readthedocs.org`, but then I run `pip install patsy` and it says its successful, but running `pip install statsmodels` still gives me same error about requiring patsy.
How can this be?
---
```
$ sudo pip install pa... | 2014/08/19 | [
"https://Stackoverflow.com/questions/25387286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3391108/"
] | For anyone still experiencing issues, I highly recommend this site:
[Python libraries](http://www.lfd.uci.edu/~gohlke/pythonlibs/#statsmodels). I'm using Python 3, so I,
1. Downloaded the file named: `statsmodels‑0.8.0‑cp35‑cp35m‑win_amd64.whl`
2. Opened windows command prompt
3. Went to my Downloads directory (`cd Do... | I also had an issue with this in Python 3.4. It worked using the WHL statsmodel file at this link: <https://pypi.python.org/pypi/statsmodels#downloads>
After the download I installed it using: pip3.4 install my\_directory\statsmodels-0.8.0rc1-cp34-none-win\_amd64.whl, where my\_directory is where I put the WHL file. |
32,085,019 | I am very new to Google App engine and was trying to understand bolb storage and api, but cant get it working.
I followed the the below tutorial from goolge on using blobstore api
<https://cloud.google.com/appengine/docs/python/blobstore/>
Github:
<https://github.com/GoogleCloudPlatform/appengine-blobstore-python/b... | 2015/08/19 | [
"https://Stackoverflow.com/questions/32085019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4822241/"
] | You are dealing with jQuery object, methods like removeChild() and [appendChild()](https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild) belongs to dom element not to the jQuery object.
To remove all contents of an element you can use [.empty()](http://api.jquery.com/empty) and to set the text content of ... | Did you wanna do somethin like this?
```
<html>
<head>
<title>STACK OVERFLOW TESTS</title>
<style>
</style>
</head>
<body>
<span>HI, IM SOME TEXT</span>
<input type = 'button' value = 'Click me!' onClick = 'changeText()'></input> <!-- Change the text with a button for example... -->
<script... |
45,031,524 | I have a melted DataFrame I would like to pivot but cannot manage to do so using 2 columns as index.
```
import pandas as pd
df = pd.DataFrame({'A': {0: 'XYZ', 1: 'XYZ', 2: 'XYZ', 3: 'XYZ', 4: 'XYZ', 5: 'XYZ', 6: 'XYZ', 7: 'XYZ', 8: 'XYZ', 9: 'XYZ', 10: 'ABC', 11: 'ABC', 12: 'ABC', 13: 'ABC', 14: 'ABC', 15: 'ABC', 16:... | 2017/07/11 | [
"https://Stackoverflow.com/questions/45031524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4947923/"
] | Is that what you want?
```
In [23]: df.pivot_table(index=['A','B'], columns='C', values='D', aggfunc='first')
Out[23]:
C Price Trading
A B
ABC 01/01/2017 50 Yes
02/01/2017 NaN No
03/01/2017 48 Yes
04/01/2017 47 Yes
05/01/2017 46 Yes
XYZ 01/01/2017 100... | I found the following is possible:
```
df.set_index(['A', 'C', 'B']).unstack().T
Out[59]:
A ABC XYZ
C Price Trading Price Trading
B
D 01/01/2017 50 Yes 100 Yes
02/01/2017 NaN No 101 Yes
03/01/2017 48 ... |
40,712,887 | I am confused with the time queryset uses its `_result_cache` or it directly hits the database.
For example (in python shell):
```
user = User.objects.all() # User is one of my models
print(user) # show data in database (hitting the database)
print(user._result_cache) # output is None
len(user) # output... | 2016/11/21 | [
"https://Stackoverflow.com/questions/40712887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6751999/"
] | A queryset will cache its data in `self._result_cache` whenever the *complete* queryset is evaluated. This includes iterating over the queryset, calling `bool()`, `len()` or `list()`, or pickling the queryset.
The `print()` function indirectly calls `repr()` on the queryset. `repr()` will evaluate the queryset to incl... | There is an explanation for this behavior :
When you use User.objects.all(),Database is not hit.When you do not iterate through the query set, the \_result\_cache is always None.But when you invoke len() function.The iteration will be done through query set, the database will be hit and resulting output will also set ... |
46,994,144 | I am a beginner in python. I have written the following python code:
```
import subprocess
PIPE = subprocess.PIPE
process = subprocess.Popen(['git', 'status'], stdout=PIPE, stderr=PIPE, cwd='my\git-repo\path',shell=True)
stdout_str, stderr_str = process.communicate()
print (stdout_str)
print (stderr_str)
```
Upon e... | 2017/10/28 | [
"https://Stackoverflow.com/questions/46994144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8849445/"
] | You have to specify the full php binary path inside the cronjob. Assuming your php binary full path is `/usr/bin/php` then your cronjob will look like this:
```
/usr/bin/php -q /home/user/tracker.domain.com/cron/3.php
``` | You should use php before -q in your cron jobs like this
php -q /home/user/tracker.domain.com/cron/3.php |
11,860,252 | In a python script i do a gobject call. I need to know, when its finished. are there any possible ways to check this?
Are there Functions or so on to check?
My code is:
```
gobject.idle_add(main.process)
class main:
def process():
<-- needs some time to finish -->
next.call.if.finished()
```
I want t... | 2012/08/08 | [
"https://Stackoverflow.com/questions/11860252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508490/"
] | ```
for($i = 0; $i < count($key); $i++){
$query.=" AND (dealTitle rlike '[[:<:]]".$key[$i]."[[:>:]]' )";
}
```
Should use AND
EDITED:
```
for($i = 0; $i < count($key); $i++){
$query.=" AND (dealTitle like '% ".$key[$i]." %' or dealTitle like '% ".$key[$i]."' or dealTitle like '".$key[$i]."%'... | try this:
```
AND (CONCAT(' ',dealTitle,' ') LIKE '% car %' and
CONCAT(' ',dealTitle,' ') LIKE '% wash %' )
``` |
11,860,252 | In a python script i do a gobject call. I need to know, when its finished. are there any possible ways to check this?
Are there Functions or so on to check?
My code is:
```
gobject.idle_add(main.process)
class main:
def process():
<-- needs some time to finish -->
next.call.if.finished()
```
I want t... | 2012/08/08 | [
"https://Stackoverflow.com/questions/11860252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508490/"
] | If you are using mysql database, there is a full text search functionality which will be robust and scalable solution.
```
$query .= " AND MATCH(dealTitle) AGAINST('". $searchString ."')";
```
<http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html#function_match>
Look into this article to understand FULLTEXT ... | try this:
```
AND (CONCAT(' ',dealTitle,' ') LIKE '% car %' and
CONCAT(' ',dealTitle,' ') LIKE '% wash %' )
``` |
11,860,252 | In a python script i do a gobject call. I need to know, when its finished. are there any possible ways to check this?
Are there Functions or so on to check?
My code is:
```
gobject.idle_add(main.process)
class main:
def process():
<-- needs some time to finish -->
next.call.if.finished()
```
I want t... | 2012/08/08 | [
"https://Stackoverflow.com/questions/11860252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508490/"
] | ```
for($i = 0; $i < count($key); $i++){
$query.=" AND (dealTitle rlike '[[:<:]]".$key[$i]."[[:>:]]' )";
}
```
Should use AND
EDITED:
```
for($i = 0; $i < count($key); $i++){
$query.=" AND (dealTitle like '% ".$key[$i]." %' or dealTitle like '% ".$key[$i]."' or dealTitle like '".$key[$i]."%'... | Try this query :-
```
AND (dealTitle LIKE '%car wash%' )
``` |
11,860,252 | In a python script i do a gobject call. I need to know, when its finished. are there any possible ways to check this?
Are there Functions or so on to check?
My code is:
```
gobject.idle_add(main.process)
class main:
def process():
<-- needs some time to finish -->
next.call.if.finished()
```
I want t... | 2012/08/08 | [
"https://Stackoverflow.com/questions/11860252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508490/"
] | ```
for($i = 0; $i < count($key); $i++){
$query.=" AND (dealTitle rlike '[[:<:]]".$key[$i]."[[:>:]]' )";
}
```
Should use AND
EDITED:
```
for($i = 0; $i < count($key); $i++){
$query.=" AND (dealTitle like '% ".$key[$i]." %' or dealTitle like '% ".$key[$i]."' or dealTitle like '".$key[$i]."%'... | You are basically trying to achieve what a search engine does -- full-text indexing. `LIKE '%keyword%'` is partial match as you already know. Not only it hits partial word, it is very slow because the db has to read and compare each one of records on the disk.
Consider using full-text indexer. MySQL specifically suppo... |
11,860,252 | In a python script i do a gobject call. I need to know, when its finished. are there any possible ways to check this?
Are there Functions or so on to check?
My code is:
```
gobject.idle_add(main.process)
class main:
def process():
<-- needs some time to finish -->
next.call.if.finished()
```
I want t... | 2012/08/08 | [
"https://Stackoverflow.com/questions/11860252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508490/"
] | If you are using mysql database, there is a full text search functionality which will be robust and scalable solution.
```
$query .= " AND MATCH(dealTitle) AGAINST('". $searchString ."')";
```
<http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html#function_match>
Look into this article to understand FULLTEXT ... | Try this query :-
```
AND (dealTitle LIKE '%car wash%' )
``` |
11,860,252 | In a python script i do a gobject call. I need to know, when its finished. are there any possible ways to check this?
Are there Functions or so on to check?
My code is:
```
gobject.idle_add(main.process)
class main:
def process():
<-- needs some time to finish -->
next.call.if.finished()
```
I want t... | 2012/08/08 | [
"https://Stackoverflow.com/questions/11860252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508490/"
] | If you are using mysql database, there is a full text search functionality which will be robust and scalable solution.
```
$query .= " AND MATCH(dealTitle) AGAINST('". $searchString ."')";
```
<http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html#function_match>
Look into this article to understand FULLTEXT ... | You are basically trying to achieve what a search engine does -- full-text indexing. `LIKE '%keyword%'` is partial match as you already know. Not only it hits partial word, it is very slow because the db has to read and compare each one of records on the disk.
Consider using full-text indexer. MySQL specifically suppo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.