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 |
|---|---|---|---|---|---|
3,400,144 | All,
I am familiar with the ability to fake GPS information to the emulator through the use of the `geo fix long lat altitude` command when connected through the emulator.
What I'd like to do is have a simulation running on potentially a different computer produce lat, long, altitudes that should be sent over to the ... | 2010/08/03 | [
"https://Stackoverflow.com/questions/3400144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155392/"
] | We have confirmed this bug. This is due to the end\_time having to be aligned with day delimiters in PST in order for the Insights table to return any data. To address this issue, we introduced two custom functions you can use to query the insights table:
1. end\_time\_date() : accept DATE in string form(e.g. '2010-08... | The response you're seeing is an empty response which doesn't necessarily mean there's no metric data available. A few ideas what might cause this:
* Are you using a user access token? If yes, does the user own the page? Is the 'read\_insights' extended permission granted for the user / access token? How about 'offlin... |
3,400,144 | All,
I am familiar with the ability to fake GPS information to the emulator through the use of the `geo fix long lat altitude` command when connected through the emulator.
What I'd like to do is have a simulation running on potentially a different computer produce lat, long, altitudes that should be sent over to the ... | 2010/08/03 | [
"https://Stackoverflow.com/questions/3400144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155392/"
] | The response you're seeing is an empty response which doesn't necessarily mean there's no metric data available. A few ideas what might cause this:
* Are you using a user access token? If yes, does the user own the page? Is the 'read\_insights' extended permission granted for the user / access token? How about 'offlin... | If, like me, you came here after getting this from another FQL statement, then your problem is not including the access\_token parameter, e.g.
<https://api.facebook.com/method/fql.query?query=SELECT+name+FROM+user+WHERE+uid+%3D+me()&access_token=>...
(You can use fb.getAccessToken()) |
3,400,144 | All,
I am familiar with the ability to fake GPS information to the emulator through the use of the `geo fix long lat altitude` command when connected through the emulator.
What I'd like to do is have a simulation running on potentially a different computer produce lat, long, altitudes that should be sent over to the ... | 2010/08/03 | [
"https://Stackoverflow.com/questions/3400144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155392/"
] | We have confirmed this bug. This is due to the end\_time having to be aligned with day delimiters in PST in order for the Insights table to return any data. To address this issue, we introduced two custom functions you can use to query the insights table:
1. end\_time\_date() : accept DATE in string form(e.g. '2010-08... | I'm not sure the date is correct. do you really want the date as an integer?
Usually SQL takes dates in db-format, so to format it you'd use:
```
Date.new(2010,9,14).to_s(:db)
(Time.now - 5.days).to_s(:db)
# or even better:
5.days.ago.to_s(:db)
``` |
3,400,144 | All,
I am familiar with the ability to fake GPS information to the emulator through the use of the `geo fix long lat altitude` command when connected through the emulator.
What I'd like to do is have a simulation running on potentially a different computer produce lat, long, altitudes that should be sent over to the ... | 2010/08/03 | [
"https://Stackoverflow.com/questions/3400144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155392/"
] | We have confirmed this bug. This is due to the end\_time having to be aligned with day delimiters in PST in order for the Insights table to return any data. To address this issue, we introduced two custom functions you can use to query the insights table:
1. end\_time\_date() : accept DATE in string form(e.g. '2010-08... | If, like me, you came here after getting this from another FQL statement, then your problem is not including the access\_token parameter, e.g.
<https://api.facebook.com/method/fql.query?query=SELECT+name+FROM+user+WHERE+uid+%3D+me()&access_token=>...
(You can use fb.getAccessToken()) |
44,364,458 | Currently I'm using Eclipse with Nokia/Red plugin which allows me to write robot framework test suites. Support is Python 3.6 and Selenium for it.
My project is called "Automation" and Test suites are in `.robot` files.
Test suites have test cases which are called "Keywords".
**Test Cases**
Create New Vehicle
```
C... | 2017/06/05 | [
"https://Stackoverflow.com/questions/44364458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8113230/"
] | If you need to "step into" a python defined keyword you need to use python debugger together with RED.
This can be done with any python debugger,if you like to have everything in one application, PyDev can be used with RED.
Follow below help document, if you will face any problems leave a comment here.
[RED Debug ... | If you are wanting to know which statement in the python-based keyword failed, you simply need to have it throw an appropriate error. Robot won't do this for you, however. From a reporting standpoint, a python based keyword is a black box. You will have to explicitly add logging messages, and return useful errors.
Fo... |
54,752,681 | I am working on a thesis regarding Jacobsthal sequences (A001045) and how they can be considered as being composed of some number of distinct sub-sequences. I have made a comment on A077947 indicating this and have included a python program. Unfortunately the program as written leaves a lot to be desired and so of cour... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54752681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1204443/"
] | Here's an alternative way to do it without a second for loop:
```
sequences = [ 1, 1, 2, 5, 9, 18 ]
multipliers = [ 36, 72, 144, 288, 576, 1152 ]
for x in range(100):
print(*sequences)
sequences = [ s + m*64**x for s,m in zip(sequences,multipliers) ]
```
[EDIT] Looking at the values I noticed th... | This will behave identically to your code, and is arguably prettier. You'll probably see ways to make the magic constants less arbitrary.
```
factors = [ 1, 1, 2, 5, 9, 18 ]
cofactors = [ 36*(2**n) for n in range(6) ]
for x in range(10):
print(*factors)
for i in range(6):
factors[i] = factors[i] + cof... |
54,752,681 | I am working on a thesis regarding Jacobsthal sequences (A001045) and how they can be considered as being composed of some number of distinct sub-sequences. I have made a comment on A077947 indicating this and have included a python program. Unfortunately the program as written leaves a lot to be desired and so of cour... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54752681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1204443/"
] | Here's an alternative way to do it without a second for loop:
```
sequences = [ 1, 1, 2, 5, 9, 18 ]
multipliers = [ 36, 72, 144, 288, 576, 1152 ]
for x in range(100):
print(*sequences)
sequences = [ s + m*64**x for s,m in zip(sequences,multipliers) ]
```
[EDIT] Looking at the values I noticed th... | Here is an alternative version using generators:
```
def Jacobsthal():
roots = [1, 1, 2, 5, 9, 18]
x = 0
while True:
yield roots
for i in range(6):
roots[i] += 36 * 2**i * 64**x
x += 1
```
And here is a safe way to use it:
```
j = Jacobsthal()
for _ in range(10):
... |
54,752,681 | I am working on a thesis regarding Jacobsthal sequences (A001045) and how they can be considered as being composed of some number of distinct sub-sequences. I have made a comment on A077947 indicating this and have included a python program. Unfortunately the program as written leaves a lot to be desired and so of cour... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54752681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1204443/"
] | Here's an alternative way to do it without a second for loop:
```
sequences = [ 1, 1, 2, 5, 9, 18 ]
multipliers = [ 36, 72, 144, 288, 576, 1152 ]
for x in range(100):
print(*sequences)
sequences = [ s + m*64**x for s,m in zip(sequences,multipliers) ]
```
[EDIT] Looking at the values I noticed th... | As you can see from the OEIS annotation, you only need 3 initial values and 1 recursion of 3 previous sequence elements, a(n-1), a(n-2) and a(n-3). You can then easily obtain the series.
```
# a(n-1)+a(n-2)+2*a(n-3)
# start values: 1, 1, 2
a1, a2, a3 = 1,1,2 #initial vales
m3, m2, m1 = 1,1,2 #multipliers for a(n-1):m... |
12,884,512 | I am in my first steps in learning python so excuse my questions please. I want to run the code below (taken from: <http://docs.python.org/library/ssl.html>) :
```
import socket, ssl, pprint
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# require a certificate from the server
ssl_sock = ssl.wrap_socket(s,
... | 2012/10/14 | [
"https://Stackoverflow.com/questions/12884512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476749/"
] | Your code is referring to a certificate *file* on drive 'F:' (using the `ca_certs` parameter), which is not found during execution -- is there one?
See the relevant [documentation](http://docs.python.org/library/ssl.html#ssl.wrap_socket):
>
> The ca\_certs file contains a set of concatenated “certification
> author... | Does the certificate referenced exist on your filesystem? I think that error is in response to invalid cert from this code:
ssl\_sock = ssl.wrap\_socket(s,ca\_certs="F:/cert",cert\_reqs=ssl.CERT\_REQUIRED) |
12,884,512 | I am in my first steps in learning python so excuse my questions please. I want to run the code below (taken from: <http://docs.python.org/library/ssl.html>) :
```
import socket, ssl, pprint
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# require a certificate from the server
ssl_sock = ssl.wrap_socket(s,
... | 2012/10/14 | [
"https://Stackoverflow.com/questions/12884512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476749/"
] | This is one area where the Python standard library is known to be difficult to use. Instead you may want to use the requests library. Documentation on sending certificates is available at: <http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification> | Does the certificate referenced exist on your filesystem? I think that error is in response to invalid cert from this code:
ssl\_sock = ssl.wrap\_socket(s,ca\_certs="F:/cert",cert\_reqs=ssl.CERT\_REQUIRED) |
68,900,182 | If I have a string which is the same as a python data type and I would like to check if another variable is that type how would I do it? Example below.
```
dtype = 'str'
x = 'hello'
bool = type(x) == dtype
```
The above obviously returns False but I'd like to check that type('hello') is a string. | 2021/08/23 | [
"https://Stackoverflow.com/questions/68900182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16737078/"
] | You can use `eval`:
```
bool = type(x) is eval(dtype)
```
but beware, `eval` will execute any python code, so if you're taking `dtype` as user input, they can execute their own code in this line. | If your code *actually* looks like the example you showed and `dtype` isn't coming from user input, then also keep in mind that `str` (as a value in Python) is a valid object which represents the string type. Consider
```
dtype = str
x = 'hello'
print(isinstance(x, dtype))
```
`str` is a value like any other and can... |
68,900,182 | If I have a string which is the same as a python data type and I would like to check if another variable is that type how would I do it? Example below.
```
dtype = 'str'
x = 'hello'
bool = type(x) == dtype
```
The above obviously returns False but I'd like to check that type('hello') is a string. | 2021/08/23 | [
"https://Stackoverflow.com/questions/68900182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16737078/"
] | You can use `eval`:
```
bool = type(x) is eval(dtype)
```
but beware, `eval` will execute any python code, so if you're taking `dtype` as user input, they can execute their own code in this line. | I think the best way to do this verification is to use **isinstance**, like:
```
isinstance(x, str) # returns True
```
From the docs:
>
>
isinstance(object, classinfo)
```
Return True if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. If obje... |
68,900,182 | If I have a string which is the same as a python data type and I would like to check if another variable is that type how would I do it? Example below.
```
dtype = 'str'
x = 'hello'
bool = type(x) == dtype
```
The above obviously returns False but I'd like to check that type('hello') is a string. | 2021/08/23 | [
"https://Stackoverflow.com/questions/68900182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16737078/"
] | Don't write :
-------------
```
bool = type(x) == dtype
```
*because `dtype` is a variabe It is in the form of a string , not logical !!*
*you should be entered a statement to check is str or no*
Also, the string in Python is an object so to call it write :
`str` not write `dtype = 'str'`,exemple :
```
type(x) ==... | If your code *actually* looks like the example you showed and `dtype` isn't coming from user input, then also keep in mind that `str` (as a value in Python) is a valid object which represents the string type. Consider
```
dtype = str
x = 'hello'
print(isinstance(x, dtype))
```
`str` is a value like any other and can... |
68,900,182 | If I have a string which is the same as a python data type and I would like to check if another variable is that type how would I do it? Example below.
```
dtype = 'str'
x = 'hello'
bool = type(x) == dtype
```
The above obviously returns False but I'd like to check that type('hello') is a string. | 2021/08/23 | [
"https://Stackoverflow.com/questions/68900182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16737078/"
] | Don't write :
-------------
```
bool = type(x) == dtype
```
*because `dtype` is a variabe It is in the form of a string , not logical !!*
*you should be entered a statement to check is str or no*
Also, the string in Python is an object so to call it write :
`str` not write `dtype = 'str'`,exemple :
```
type(x) ==... | I think the best way to do this verification is to use **isinstance**, like:
```
isinstance(x, str) # returns True
```
From the docs:
>
>
isinstance(object, classinfo)
```
Return True if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. If obje... |
24,944,863 | I would like to use the Decimal() data type in python and convert it to an integer and exponent so I can send that data to a microcontroller/plc with full precision and decimal control. <https://docs.python.org/2/library/decimal.html>
I have got it to work, but it is hackish; does anyone know a better way? If not what... | 2014/07/24 | [
"https://Stackoverflow.com/questions/24944863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3862210/"
] | ```
from functools import reduce # Only in Python 3, omit this in Python 2.x
from decimal import *
d = Decimal('3.14159')
t = d.as_tuple()
theInteger = reduce(lambda rst, x: rst * 10 + x, t.digits)
theExponent = t.exponent
``` | ```
from decimal import *
d=Decimal('3.14159')
t=d.as_tuple()
digits=t.digits
theInteger=0
for x in range(len(digits)):
theInteger=theInteger+digits[x]*10**(len(digits)-x)
``` |
24,944,863 | I would like to use the Decimal() data type in python and convert it to an integer and exponent so I can send that data to a microcontroller/plc with full precision and decimal control. <https://docs.python.org/2/library/decimal.html>
I have got it to work, but it is hackish; does anyone know a better way? If not what... | 2014/07/24 | [
"https://Stackoverflow.com/questions/24944863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3862210/"
] | You could do this :
[ This is 3 times faster than the other methods ]
```
d=Decimal('3.14159')
list_d = str(d).split('.')
# Converting the decimal to string and splitting it at the decimal point
# If decimal point exists => Negative exponent
# i.e 3.14159 => "3", "14159"
# exponent = -len("14159") = -5
# inte... | ```
from functools import reduce # Only in Python 3, omit this in Python 2.x
from decimal import *
d = Decimal('3.14159')
t = d.as_tuple()
theInteger = reduce(lambda rst, x: rst * 10 + x, t.digits)
theExponent = t.exponent
``` |
24,944,863 | I would like to use the Decimal() data type in python and convert it to an integer and exponent so I can send that data to a microcontroller/plc with full precision and decimal control. <https://docs.python.org/2/library/decimal.html>
I have got it to work, but it is hackish; does anyone know a better way? If not what... | 2014/07/24 | [
"https://Stackoverflow.com/questions/24944863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3862210/"
] | ```
from functools import reduce # Only in Python 3, omit this in Python 2.x
from decimal import *
d = Decimal('3.14159')
t = d.as_tuple()
theInteger = reduce(lambda rst, x: rst * 10 + x, t.digits)
theExponent = t.exponent
``` | Get the exponent directly from the tuple as you were:
```
exponent = d.as_tuple()[2]
```
Then multiply by the proper power of 10:
```
i = int(d * Decimal('10')**-exponent)
```
Putting it all together:
```
from decimal import Decimal
_ten = Decimal('10')
def int_exponent(d):
exponent = d.as_tuple()[2]
i... |
24,944,863 | I would like to use the Decimal() data type in python and convert it to an integer and exponent so I can send that data to a microcontroller/plc with full precision and decimal control. <https://docs.python.org/2/library/decimal.html>
I have got it to work, but it is hackish; does anyone know a better way? If not what... | 2014/07/24 | [
"https://Stackoverflow.com/questions/24944863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3862210/"
] | You could do this :
[ This is 3 times faster than the other methods ]
```
d=Decimal('3.14159')
list_d = str(d).split('.')
# Converting the decimal to string and splitting it at the decimal point
# If decimal point exists => Negative exponent
# i.e 3.14159 => "3", "14159"
# exponent = -len("14159") = -5
# inte... | ```
from decimal import *
d=Decimal('3.14159')
t=d.as_tuple()
digits=t.digits
theInteger=0
for x in range(len(digits)):
theInteger=theInteger+digits[x]*10**(len(digits)-x)
``` |
24,944,863 | I would like to use the Decimal() data type in python and convert it to an integer and exponent so I can send that data to a microcontroller/plc with full precision and decimal control. <https://docs.python.org/2/library/decimal.html>
I have got it to work, but it is hackish; does anyone know a better way? If not what... | 2014/07/24 | [
"https://Stackoverflow.com/questions/24944863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3862210/"
] | Get the exponent directly from the tuple as you were:
```
exponent = d.as_tuple()[2]
```
Then multiply by the proper power of 10:
```
i = int(d * Decimal('10')**-exponent)
```
Putting it all together:
```
from decimal import Decimal
_ten = Decimal('10')
def int_exponent(d):
exponent = d.as_tuple()[2]
i... | ```
from decimal import *
d=Decimal('3.14159')
t=d.as_tuple()
digits=t.digits
theInteger=0
for x in range(len(digits)):
theInteger=theInteger+digits[x]*10**(len(digits)-x)
``` |
24,944,863 | I would like to use the Decimal() data type in python and convert it to an integer and exponent so I can send that data to a microcontroller/plc with full precision and decimal control. <https://docs.python.org/2/library/decimal.html>
I have got it to work, but it is hackish; does anyone know a better way? If not what... | 2014/07/24 | [
"https://Stackoverflow.com/questions/24944863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3862210/"
] | You could do this :
[ This is 3 times faster than the other methods ]
```
d=Decimal('3.14159')
list_d = str(d).split('.')
# Converting the decimal to string and splitting it at the decimal point
# If decimal point exists => Negative exponent
# i.e 3.14159 => "3", "14159"
# exponent = -len("14159") = -5
# inte... | Get the exponent directly from the tuple as you were:
```
exponent = d.as_tuple()[2]
```
Then multiply by the proper power of 10:
```
i = int(d * Decimal('10')**-exponent)
```
Putting it all together:
```
from decimal import Decimal
_ten = Decimal('10')
def int_exponent(d):
exponent = d.as_tuple()[2]
i... |
3,950,330 | Is there a way to change python2.x source code to python 3.x manually. I guess using lib2to3 this can be done but I don't know exactly how to do this ? | 2010/10/16 | [
"https://Stackoverflow.com/questions/3950330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/441459/"
] | Thanks. Here is the answer I was looking for:
```
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
"""assume `files` to a be a list of all filenames you want to convert"""
r = RefactoringTool(get_fixers_from_package('lib2to3.fixes'))
r.refactor(files, write=True)
``` | Yes, porting is what you are looking here.
Porting is a non-trivial task that requires making various decisions about your code. For instance, whether or not you want to maintaing backward compatibility. There is no single, universal solution to porting. The way you port depends on your specific requirements.
The bes... |
6,156,358 | The example from [this post](https://stackoverflow.com/questions/6144274/string-replace-utility-conversion-from-python-to-f) has an example
```
open System.IO
let lines =
File.ReadAllLines("tclscript.do")
|> Seq.map (fun line ->
let newLine = line.Replace("{", "{{").Replace("}", "}}")
newLine )
File... | 2011/05/27 | [
"https://Stackoverflow.com/questions/6156358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | Building on Jaime's answer, since `ReadAllLines()` returns an array, just use `Array.map` instead of `Seq.map`
```
open System.IO
let lines =
File.ReadAllLines("tclscript.do")
|> Array.map (fun line ->
let newLine = line.Replace("{", "{{").Replace("}", "}}")
newLine )
File.WriteAllLines("tclscript.t... | You can use
```
File.WriteAllLines("tclscript.txt", Seq.toArray lines)
```
or alternatively just attach
```
|> Seq.toArray
```
after the Seq.map call.
(Also note that in .NET 4, there is an overload of WriteAllLines that does take a Seq) |
6,156,358 | The example from [this post](https://stackoverflow.com/questions/6144274/string-replace-utility-conversion-from-python-to-f) has an example
```
open System.IO
let lines =
File.ReadAllLines("tclscript.do")
|> Seq.map (fun line ->
let newLine = line.Replace("{", "{{").Replace("}", "}}")
newLine )
File... | 2011/05/27 | [
"https://Stackoverflow.com/questions/6156358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | You can use
```
File.WriteAllLines("tclscript.txt", Seq.toArray lines)
```
or alternatively just attach
```
|> Seq.toArray
```
after the Seq.map call.
(Also note that in .NET 4, there is an overload of WriteAllLines that does take a Seq) | Personally, I prefer sequence expressions over higher-order functions, unless you're piping the output through a series of functions. It's usually cleaner and more readable.
```
let lines = [| for line in File.ReadAllLines("tclscript.do") -> line.Replace("{", "{{").Replace("}", "}}") |]
File.WriteAllLines("tclscript.t... |
6,156,358 | The example from [this post](https://stackoverflow.com/questions/6144274/string-replace-utility-conversion-from-python-to-f) has an example
```
open System.IO
let lines =
File.ReadAllLines("tclscript.do")
|> Seq.map (fun line ->
let newLine = line.Replace("{", "{{").Replace("}", "}}")
newLine )
File... | 2011/05/27 | [
"https://Stackoverflow.com/questions/6156358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260127/"
] | Building on Jaime's answer, since `ReadAllLines()` returns an array, just use `Array.map` instead of `Seq.map`
```
open System.IO
let lines =
File.ReadAllLines("tclscript.do")
|> Array.map (fun line ->
let newLine = line.Replace("{", "{{").Replace("}", "}}")
newLine )
File.WriteAllLines("tclscript.t... | Personally, I prefer sequence expressions over higher-order functions, unless you're piping the output through a series of functions. It's usually cleaner and more readable.
```
let lines = [| for line in File.ReadAllLines("tclscript.do") -> line.Replace("{", "{{").Replace("}", "}}") |]
File.WriteAllLines("tclscript.t... |
34,464,872 | I have download some mesh exporter script to learn how to write an export script in python for blender(2.6.3).
The script follows the standard register/unregister in order to register or unregister the script.
```
### REGISTER ###
def menu_func(self, context):
self.layout.operator(Export_objc.bl_idname, text="Ob... | 2015/12/25 | [
"https://Stackoverflow.com/questions/34464872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1097185/"
] | Well I have found a workable way...
If you press 'F8' it will reload all plugins and remove the "dead" menu items.
That solves the multiple additions of the same addon.
So now if I want to change the addon and test it I do something like this:
1. Run script with unregister
2. Press F8
3. Run script with register
Th... | I am not 100% certain of the cause but it relates to running an addon script that adds a menu item within blender's text editor. Even blender's template scripts do the same thing.
I think the best solution is to use it like a real addon - that is save it to disk and enable/disable it in the addon preferences. You can ... |
48,967,621 | I will admit I'm stuck on a school project right now.
I have defined functions that will generate random numbers for me, as well as a random operator (+, -, or \*).
I have also defined a function that will display a problem using these random numbers.
I have created a program that will generate and display a random... | 2018/02/24 | [
"https://Stackoverflow.com/questions/48967621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7856878/"
] | Just move your code that is generating the random values into your for loop:
```
for _ in range(10): #loops the program 10 times
randNum = getOp(max)
operand1 = getOp(max)
operand2 = getOp(max)
operator = getOperator()
answer = doIt(operand1, operand2, operator)
displayProblem... | You generate the problem and then show it 10 times in the loop:
```
generateProblem()
for _ in range(10):
showProblem()
```
of course you will get the same problem shown 10 times. To fix this, generate the problem *inside* the loop:
```
for _ in range(10):
generateProblem()
showProblem()
``` |
48,967,621 | I will admit I'm stuck on a school project right now.
I have defined functions that will generate random numbers for me, as well as a random operator (+, -, or \*).
I have also defined a function that will display a problem using these random numbers.
I have created a program that will generate and display a random... | 2018/02/24 | [
"https://Stackoverflow.com/questions/48967621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7856878/"
] | You generate the problem and then show it 10 times in the loop:
```
generateProblem()
for _ in range(10):
showProblem()
```
of course you will get the same problem shown 10 times. To fix this, generate the problem *inside* the loop:
```
for _ in range(10):
generateProblem()
showProblem()
``` | Crrected Your Code
```
import random
max = 10
def getOp(max): #generates a random number between 1 and 10
randNum = random.randint(0,max)
return randNum
def getOperator(): #gets a random operator
opValue = random.randint(1,3)
if opValue == 1:
operator1 = '+'
elif opValue == 2:
o... |
48,967,621 | I will admit I'm stuck on a school project right now.
I have defined functions that will generate random numbers for me, as well as a random operator (+, -, or \*).
I have also defined a function that will display a problem using these random numbers.
I have created a program that will generate and display a random... | 2018/02/24 | [
"https://Stackoverflow.com/questions/48967621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7856878/"
] | Just move your code that is generating the random values into your for loop:
```
for _ in range(10): #loops the program 10 times
randNum = getOp(max)
operand1 = getOp(max)
operand2 = getOp(max)
operator = getOperator()
answer = doIt(operand1, operand2, operator)
displayProblem... | Crrected Your Code
```
import random
max = 10
def getOp(max): #generates a random number between 1 and 10
randNum = random.randint(0,max)
return randNum
def getOperator(): #gets a random operator
opValue = random.randint(1,3)
if opValue == 1:
operator1 = '+'
elif opValue == 2:
o... |
17,370,820 | I have come across some python code with slice notation that I am having trouble figuring out.
It looks like slice notation but uses a comma and a list:
```
list[:, [1, 2, 3]]
```
Is this syntax valid? If so what does it do?
**edit** looks like it is a 2D numpy array | 2013/06/28 | [
"https://Stackoverflow.com/questions/17370820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2502012/"
] | Assuming that the object is really a `numpy` array, this is known as [advanced indexing](http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#advanced-indexing), and picks out the specified columns:
```
>>> import numpy as np
>>> a = np.arange(12).reshape(3,4)
>>> a
array([[ 0, 1, 2, 3],
[ 4, 5, ... | It generates a complex value and passes it to [`__*item__()`](http://docs.python.org/2/reference/datamodel.html#object.__getitem__):
```
>>> class Foo(object):
... def __getitem__(self, val):
... print val
...
>>> Foo()[:, [1, 2, 3]]
(slice(None, None, None), [1, 2, 3])
```
What it actually *performs* depends... |
61,996,756 | When I install npm on my project ionic with Angular. There is a failed install of node-sass/ node-gyp
error show like this :
>
> $ npm install
>
>
>
> >
> > [email protected] install C:\Users\d\Documents\project\app\node\_modules\node-sass
> > node scripts/install.js
> >
> >
> >
>
>
> Downloading binary from... | 2020/05/25 | [
"https://Stackoverflow.com/questions/61996756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3766841/"
] | Short answer: **Avoid global variables!**
In your `delete` function you set the value of the global variable `temp_node`.
Then you call the function `count`. In `count` you also use the global variable `temp_node`. You change it until it has the value NULL.
Then back in the `delete` function, you do:
```
temp_node... | You are probably making an extra loop in your delete function. You should check if you are deleting an node which isn't part of your linked list. |
1,664,587 | first time poster.
I'm turning to my first question on stack overflow because I've found little resources in trying to find an answer. I'm looking to execute Selenium python tests from a C# application. I don't want to have to compile the C# Selenium tests each time; I want to take advantage of IronPython scripting fo... | 2009/11/03 | [
"https://Stackoverflow.com/questions/1664587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/201308/"
] | Looking at the [source code](http://ironpython.codeplex.com/SourceControl/ListDownloadableCommits.aspx) to the IronPython Console (ipy.exe), it looks like it eventually boils down to calling `ScriptSource.ExecuteProgram()`. You can get a `ScriptSource` from any of the various `ScriptEngine.CreateScriptSourceFrom*` meth... | Try the following:
```
unittest.main(module=__name__)
``` |
73,675,635 | I have 7 python dictionaries each named after the format `songn`, for example `song1`, `song2`, etc. Each dictionary includes the following information about a song: `name`, `duration`, `artist`. I created a list of songs, called `playlist full` of the form `[song1, song2, song3...,song7]`.
Here is my code:
```py
son... | 2022/09/10 | [
"https://Stackoverflow.com/questions/73675635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6267463/"
] | You could use [eval()](https://www.w3schools.com/python/ref_func_eval.asp) like:
```py
eval(playlist_full[2]).get("name")
```
which would do exactly what you want, evaluate the string as python code.
It's not great practice though. It would be better/safer to store the songs themselves in a dictionary or list that ... | You can use [`locals()`](https://docs.python.org/3/library/functions.html#locals) built-in function to do that:
```py
for i in range(1, 8):
song_i = "song"+str(i)
playlist_full.append(locals()[f'song{i}'])
``` |
73,675,635 | I have 7 python dictionaries each named after the format `songn`, for example `song1`, `song2`, etc. Each dictionary includes the following information about a song: `name`, `duration`, `artist`. I created a list of songs, called `playlist full` of the form `[song1, song2, song3...,song7]`.
Here is my code:
```py
son... | 2022/09/10 | [
"https://Stackoverflow.com/questions/73675635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6267463/"
] | You could use [eval()](https://www.w3schools.com/python/ref_func_eval.asp) like:
```py
eval(playlist_full[2]).get("name")
```
which would do exactly what you want, evaluate the string as python code.
It's not great practice though. It would be better/safer to store the songs themselves in a dictionary or list that ... | ```
varnames=locals()
playlist_full = []
for i in range(1, 8):
song_i = "song"+str(i)
playlist_full.append(varnames[song_i])
print(playlist_full[2].get("name"))
``` |
73,675,635 | I have 7 python dictionaries each named after the format `songn`, for example `song1`, `song2`, etc. Each dictionary includes the following information about a song: `name`, `duration`, `artist`. I created a list of songs, called `playlist full` of the form `[song1, song2, song3...,song7]`.
Here is my code:
```py
son... | 2022/09/10 | [
"https://Stackoverflow.com/questions/73675635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6267463/"
] | You could use [eval()](https://www.w3schools.com/python/ref_func_eval.asp) like:
```py
eval(playlist_full[2]).get("name")
```
which would do exactly what you want, evaluate the string as python code.
It's not great practice though. It would be better/safer to store the songs themselves in a dictionary or list that ... | It's completely redundant to keep your data as both individual variables and members of a list. If a list is what you need, create it that way in the first place.
```
playlist_full = [{"name": "Wake Me Up", "duration": 3.5, "artist": "Wham"},
{"name": "I Want Your...", "duration": 4.3, "artist": "Wham"},
{"nam... |
73,675,635 | I have 7 python dictionaries each named after the format `songn`, for example `song1`, `song2`, etc. Each dictionary includes the following information about a song: `name`, `duration`, `artist`. I created a list of songs, called `playlist full` of the form `[song1, song2, song3...,song7]`.
Here is my code:
```py
son... | 2022/09/10 | [
"https://Stackoverflow.com/questions/73675635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6267463/"
] | ```
varnames=locals()
playlist_full = []
for i in range(1, 8):
song_i = "song"+str(i)
playlist_full.append(varnames[song_i])
print(playlist_full[2].get("name"))
``` | You can use [`locals()`](https://docs.python.org/3/library/functions.html#locals) built-in function to do that:
```py
for i in range(1, 8):
song_i = "song"+str(i)
playlist_full.append(locals()[f'song{i}'])
``` |
73,675,635 | I have 7 python dictionaries each named after the format `songn`, for example `song1`, `song2`, etc. Each dictionary includes the following information about a song: `name`, `duration`, `artist`. I created a list of songs, called `playlist full` of the form `[song1, song2, song3...,song7]`.
Here is my code:
```py
son... | 2022/09/10 | [
"https://Stackoverflow.com/questions/73675635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6267463/"
] | It's completely redundant to keep your data as both individual variables and members of a list. If a list is what you need, create it that way in the first place.
```
playlist_full = [{"name": "Wake Me Up", "duration": 3.5, "artist": "Wham"},
{"name": "I Want Your...", "duration": 4.3, "artist": "Wham"},
{"nam... | You can use [`locals()`](https://docs.python.org/3/library/functions.html#locals) built-in function to do that:
```py
for i in range(1, 8):
song_i = "song"+str(i)
playlist_full.append(locals()[f'song{i}'])
``` |
67,180,248 | How can I get the text of a button clicked and return it to python? The button is selected using a mouse-click generated by the user in the Selenium WebDriver browser.
I'm trying to do as follows:
```
x=driver.execute_script("$(document).click(function(event){var text= $(event.target).text(); return text})")
```
bu... | 2021/04/20 | [
"https://Stackoverflow.com/questions/67180248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12296610/"
] | Once you click on the button,
You can extract the text of the button only if it's still available in the dom visible, else you can't. | ```
# Identify element
element = driver.find_element_by_id("id")
# Click element
element.click()
# Get text
print("Text is: " + element.text)
# Or
print("Text is: " + element.get_attribute("innerHTML")
``` |
50,639,390 | I am trying to write a music program in Python that takes some music written by the user in a text file and turns it into a midi. I'm not particularly experienced with python at this stage so I'm not sure what the reason behind this issue is. I am trying to write the source file parser for the program and part of this ... | 2018/06/01 | [
"https://Stackoverflow.com/questions/50639390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6283375/"
] | `row` contains a newline, so it's not empty. But `row.split()` doesn't find any non-whitespace characters, so it returns an empty list.
Use
```
if len(row.strip()):
```
to ignore the newline (and any other leading/trailing spaces).
Or more simply:
```
if row.strip():
```
since an empty string is falsy. | Try creating a [list comprehension](https://www.python-course.eu/python3_list_comprehension.php):
```
with open('d.txt', "r") as infile:
print([i.strip().split() for i in infile if i.strip()])
```
Output:
```
[['This', 'is'], ['A', 'test']]
``` |
50,639,390 | I am trying to write a music program in Python that takes some music written by the user in a text file and turns it into a midi. I'm not particularly experienced with python at this stage so I'm not sure what the reason behind this issue is. I am trying to write the source file parser for the program and part of this ... | 2018/06/01 | [
"https://Stackoverflow.com/questions/50639390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6283375/"
] | `row` contains a newline, so it's not empty. But `row.split()` doesn't find any non-whitespace characters, so it returns an empty list.
Use
```
if len(row.strip()):
```
to ignore the newline (and any other leading/trailing spaces).
Or more simply:
```
if row.strip():
```
since an empty string is falsy. | testdoc.txt has lot of empty lines; but in output they are out;
```
src = 'testdoc.txt'
with open(src, 'r') as f:
for r in f:
if len(r) > 1:
print(r.strip())
```
and now you can obviously put this all in list or in list line by line instead of print whatever fits your further logic |
14,633,021 | I have an AppHarbor app that I'm using as an external service which will get requested by my other servers which use Google App Engine (python). The appharbor app is basically getting pinged a lot to process some data that I send it.
Because I'll be constantly pinging the service, and time is important, is it possibl... | 2013/01/31 | [
"https://Stackoverflow.com/questions/14633021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361897/"
] | I doubt that DNS lookups will be your bottleneck, but anyway as far as I can see DNS lookups are cached by the system (for at least the TTL). | Sign up for the AppEngine Sockets Trusted Tester ([here](https://docs.google.com/a/postmaster.io/spreadsheet/viewform?formkey=dF9QR3pnQ2pNa0dqalViSTZoenVkcHc6MQ#gid=0)) and use the normal python:
```
socket.gethostbyname(...)
``` |
14,633,021 | I have an AppHarbor app that I'm using as an external service which will get requested by my other servers which use Google App Engine (python). The appharbor app is basically getting pinged a lot to process some data that I send it.
Because I'll be constantly pinging the service, and time is important, is it possibl... | 2013/01/31 | [
"https://Stackoverflow.com/questions/14633021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361897/"
] | You can theoretically send requests directly to an IP address, but you would have to also [pass the host header](http://drewish.com/content/2010/03/using_curl_and_the_host_header_to_bypass_a_load_balancer) so that the AppHarbor routing layer can figure out what application gets the request.
As Shay mentions, you shoul... | Sign up for the AppEngine Sockets Trusted Tester ([here](https://docs.google.com/a/postmaster.io/spreadsheet/viewform?formkey=dF9QR3pnQ2pNa0dqalViSTZoenVkcHc6MQ#gid=0)) and use the normal python:
```
socket.gethostbyname(...)
``` |
14,633,021 | I have an AppHarbor app that I'm using as an external service which will get requested by my other servers which use Google App Engine (python). The appharbor app is basically getting pinged a lot to process some data that I send it.
Because I'll be constantly pinging the service, and time is important, is it possibl... | 2013/01/31 | [
"https://Stackoverflow.com/questions/14633021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361897/"
] | I doubt that DNS lookups will be your bottleneck, but anyway as far as I can see DNS lookups are cached by the system (for at least the TTL). | You can theoretically send requests directly to an IP address, but you would have to also [pass the host header](http://drewish.com/content/2010/03/using_curl_and_the_host_header_to_bypass_a_load_balancer) so that the AppHarbor routing layer can figure out what application gets the request.
As Shay mentions, you shoul... |
28,690,325 | I have such problem I have this piece of code on python2.7. It works approximately 60 seconds for object with slightly more than 70000 items in the object. How it works? It gets an object with paths to another objects and convert them to the ASCII strings. I think the problem why it is so slow is loops.
```
def create... | 2015/02/24 | [
"https://Stackoverflow.com/questions/28690325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4473386/"
] | ID of an element must be unique, when you use id selector it will return only the first element with the id, so all the click handlers are added to the first button.
Use classes and event delegation
```
$(document).ready(function () {
$("#image-btn").click(function () {
var $imageElement = $("<div class='... | use $(this) instead of $imageElement
```
$(document).ready(function(){
$("#image-btn").click(function(){
var $imageElement = $("<div class='image_element' id='image-element'><div class='image_holder' align='center'><input type='image' src='{{URL::asset('images/close-icon.png')}}' name='closeStory' class='... |
28,690,325 | I have such problem I have this piece of code on python2.7. It works approximately 60 seconds for object with slightly more than 70000 items in the object. How it works? It gets an object with paths to another objects and convert them to the ASCII strings. I think the problem why it is so slow is loops.
```
def create... | 2015/02/24 | [
"https://Stackoverflow.com/questions/28690325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4473386/"
] | ID of an element must be unique, when you use id selector it will return only the first element with the id, so all the click handlers are added to the first button.
Use classes and event delegation
```
$(document).ready(function () {
$("#image-btn").click(function () {
var $imageElement = $("<div class='... | You need remove the parent/child near at button you press.
For example:
```
$("#close-img-btn").click(function(){
$(this).parent('content-div').remove();
});
``` |
28,690,325 | I have such problem I have this piece of code on python2.7. It works approximately 60 seconds for object with slightly more than 70000 items in the object. How it works? It gets an object with paths to another objects and convert them to the ASCII strings. I think the problem why it is so slow is loops.
```
def create... | 2015/02/24 | [
"https://Stackoverflow.com/questions/28690325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4473386/"
] | You need remove the parent/child near at button you press.
For example:
```
$("#close-img-btn").click(function(){
$(this).parent('content-div').remove();
});
``` | use $(this) instead of $imageElement
```
$(document).ready(function(){
$("#image-btn").click(function(){
var $imageElement = $("<div class='image_element' id='image-element'><div class='image_holder' align='center'><input type='image' src='{{URL::asset('images/close-icon.png')}}' name='closeStory' class='... |
17,438,852 | I want to pass in a string to my python script which contains escape sequences such as: `\x00` or `\t`, and spaces.
However when I pass in my string as:
```
some string\x00 more \tstring
```
python treats my string as a raw string and when I print that string from inside the script, it prints the string literally... | 2013/07/03 | [
"https://Stackoverflow.com/questions/17438852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2059819/"
] | The string you receive in `sys.argv[1]` is exactly what you typed on the command line. Its backslash sequences are left intact, not interpreted.
To interpret them, follow [this answer](https://stackoverflow.com/questions/4020539/process-escape-sequences-in-a-string-in-python): basically use `.decode('string_escape')`. | I don't know that you can parse entire strings without writing a custom parser but optparse supports [sending inputs in different formats](http://docs.python.org/2/library/optparse.html#standard-option-types) (hexidecimal, binary, etc).
```
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-... |
17,438,852 | I want to pass in a string to my python script which contains escape sequences such as: `\x00` or `\t`, and spaces.
However when I pass in my string as:
```
some string\x00 more \tstring
```
python treats my string as a raw string and when I print that string from inside the script, it prints the string literally... | 2013/07/03 | [
"https://Stackoverflow.com/questions/17438852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2059819/"
] | The string you receive in `sys.argv[1]` is exactly what you typed on the command line. Its backslash sequences are left intact, not interpreted.
To interpret them, follow [this answer](https://stackoverflow.com/questions/4020539/process-escape-sequences-in-a-string-in-python): basically use `.decode('string_escape')`. | myscript.py contains:
```
import sys
print(sys.argv[1].decode('string-escape'))
```
result
abcd abcd |
17,438,852 | I want to pass in a string to my python script which contains escape sequences such as: `\x00` or `\t`, and spaces.
However when I pass in my string as:
```
some string\x00 more \tstring
```
python treats my string as a raw string and when I print that string from inside the script, it prints the string literally... | 2013/07/03 | [
"https://Stackoverflow.com/questions/17438852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2059819/"
] | myscript.py contains:
```
import sys
print(sys.argv[1].decode('string-escape'))
```
result
abcd abcd | I don't know that you can parse entire strings without writing a custom parser but optparse supports [sending inputs in different formats](http://docs.python.org/2/library/optparse.html#standard-option-types) (hexidecimal, binary, etc).
```
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-... |
61,512,822 | Running in Jupyter-notebook
Python version 3.6
Pyspark version 2.4.5
Hadoop version 2.7.3
I essentially have the same issue described [Unable to write spark dataframe to a parquet file format to C drive in PySpark](https://stackoverflow.com/questions/59220832/unable-to-write-spark-dataframe-to-a-parquet-file-format... | 2020/04/29 | [
"https://Stackoverflow.com/questions/61512822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13436683/"
] | You have to use `$sum` to sum the size of each array like this
```js
{
"$group": {
"_id": {
"vehicleid": "$vehicleid",
"date": "$date"
},
"count": { "$sum": { "$size": "$points" } }
}
}
``` | **You can follow this code**
```
$group : {
_id : {
"vehicleid":"$vehicleid",
"date":"$date"
count: { $sum: 1 }
}
}
``` |
61,512,822 | Running in Jupyter-notebook
Python version 3.6
Pyspark version 2.4.5
Hadoop version 2.7.3
I essentially have the same issue described [Unable to write spark dataframe to a parquet file format to C drive in PySpark](https://stackoverflow.com/questions/59220832/unable-to-write-spark-dataframe-to-a-parquet-file-format... | 2020/04/29 | [
"https://Stackoverflow.com/questions/61512822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13436683/"
] | You have to use `$sum` to sum the size of each array like this
```js
{
"$group": {
"_id": {
"vehicleid": "$vehicleid",
"date": "$date"
},
"count": { "$sum": { "$size": "$points" } }
}
}
``` | You can use any of the following aggregation pipelines. You will get the size of the `points` array field. Each pipeline uses different approach, and the output details differ, but the size info will be same.
The code runs with PyMongo:
```
pipeline = [
{
"$unwind": "$points"
},
{
"$gro... |
61,512,822 | Running in Jupyter-notebook
Python version 3.6
Pyspark version 2.4.5
Hadoop version 2.7.3
I essentially have the same issue described [Unable to write spark dataframe to a parquet file format to C drive in PySpark](https://stackoverflow.com/questions/59220832/unable-to-write-spark-dataframe-to-a-parquet-file-format... | 2020/04/29 | [
"https://Stackoverflow.com/questions/61512822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13436683/"
] | You can use any of the following aggregation pipelines. You will get the size of the `points` array field. Each pipeline uses different approach, and the output details differ, but the size info will be same.
The code runs with PyMongo:
```
pipeline = [
{
"$unwind": "$points"
},
{
"$gro... | **You can follow this code**
```
$group : {
_id : {
"vehicleid":"$vehicleid",
"date":"$date"
count: { $sum: 1 }
}
}
``` |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | #Convert date into the proper format so that date time operation can be easily performed
```
df_Time_Table["Date"] = pd.to_datetime(df_Time_Table["Date"])
# Cal Year
df_Time_Table['Year'] = df_Time_Table['Date'].dt.strftime('%Y')
``` | When you write
```
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
df['Date'] = df['Date'].dt.strftime('%m/%d')
```
It can fixed |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | Your problem here is that the dtype of 'Date' remained as str/object. You can use the `parse_dates` parameter when using `read_csv`
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', parse_dates= [col],encoding='utf-8-sig', usecols= ['Date', 'ids'],)
df['Month'] = df['Date'].dt.month... | #Convert date into the proper format so that date time operation can be easily performed
```
df_Time_Table["Date"] = pd.to_datetime(df_Time_Table["Date"])
# Cal Year
df_Time_Table['Year'] = df_Time_Table['Date'].dt.strftime('%Y')
``` |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | Your problem here is that the dtype of 'Date' remained as str/object. You can use the `parse_dates` parameter when using `read_csv`
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', parse_dates= [col],encoding='utf-8-sig', usecols= ['Date', 'ids'],)
df['Month'] = df['Date'].dt.month... | `train_data=pd.read_csv("train.csv",parse_dates=["date"])` |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | `train_data=pd.read_csv("train.csv",parse_dates=["date"])` | When you write
```
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
df['Date'] = df['Date'].dt.strftime('%m/%d')
```
It can fixed |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | Your problem here is that the dtype of 'Date' remained as str/object. You can use the `parse_dates` parameter when using `read_csv`
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', parse_dates= [col],encoding='utf-8-sig', usecols= ['Date', 'ids'],)
df['Month'] = df['Date'].dt.month... | When you write
```
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
df['Date'] = df['Date'].dt.strftime('%m/%d')
```
It can fixed |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | First you need to define the format of date column.
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d %H:%M:%S')
```
For your case base format can be set to;
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d')
```
After that you can set/change your desired output as follows;
```
df['Date'] = df['... | #Convert date into the proper format so that date time operation can be easily performed
```
df_Time_Table["Date"] = pd.to_datetime(df_Time_Table["Date"])
# Cal Year
df_Time_Table['Year'] = df_Time_Table['Date'].dt.strftime('%Y')
``` |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | Your problem here is that `to_datetime` silently failed so the dtype remained as `str/object`, if you set param `errors='coerce'` then if the conversion fails for any particular string then those rows are set to `NaT`.
```
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
```
So you need to find out what is w... | First you need to define the format of date column.
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d %H:%M:%S')
```
For your case base format can be set to;
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d')
```
After that you can set/change your desired output as follows;
```
df['Date'] = df['... |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | Your problem here is that `to_datetime` silently failed so the dtype remained as `str/object`, if you set param `errors='coerce'` then if the conversion fails for any particular string then those rows are set to `NaT`.
```
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
```
So you need to find out what is w... | When you write
```
df['Date'] = pd.to_datetime(df['Date'], errors='coerce')
df['Date'] = df['Date'].dt.strftime('%m/%d')
```
It can fixed |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | First you need to define the format of date column.
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d %H:%M:%S')
```
For your case base format can be set to;
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d')
```
After that you can set/change your desired output as follows;
```
df['Date'] = df['... | `train_data=pd.read_csv("train.csv",parse_dates=["date"])` |
33,365,055 | Hi I am using pandas to convert a column to month.
When I read my data they are objects:
```
Date object
dtype: object
```
So I am first making them to date time and then try to make them as months:
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', encoding='utf-8-sig', us... | 2015/10/27 | [
"https://Stackoverflow.com/questions/33365055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738736/"
] | First you need to define the format of date column.
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d %H:%M:%S')
```
For your case base format can be set to;
```
df['Date'] = pd.to_datetime(df.Date, format='%Y-%m-%d')
```
After that you can set/change your desired output as follows;
```
df['Date'] = df['... | Your problem here is that the dtype of 'Date' remained as str/object. You can use the `parse_dates` parameter when using `read_csv`
```
import pandas as pd
file = '/pathtocsv.csv'
df = pd.read_csv(file, sep = ',', parse_dates= [col],encoding='utf-8-sig', usecols= ['Date', 'ids'],)
df['Month'] = df['Date'].dt.month... |
61,036,609 | As illustrated below, I am looking for an easy way to combine two or more heat-maps into one, i.e., a heat-map with multiple colormaps.
The idea is to break each cell into multiple sub-cells. I couldn't find any python library with such a visualization function already implemented. Anybody knows something (at least) c... | 2020/04/05 | [
"https://Stackoverflow.com/questions/61036609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3625770/"
] | The heatmaps can be drawn column by column. White gridlines can mark the cell borders.
```py
import numpy as np
from matplotlib import pyplot as plt
a = np.random.random((5, 6))
b = np.random.random((5, 6))
vmina = a.min()
vminb = b.min()
vmaxa = a.max()
vmaxb = b.max()
fig, (ax1, ax2, ax3) = plt.subplots(ncols=3, f... | You can restructure your arrays to have empty columns between you actual data then create a masked array to plot heatmaps with transparency. Here's one method (maybe not the best) to add empty columns:
```
arr1 = np.arange(20).reshape(4, 5)
arr2 = np.arange(20, 0, -1).reshape(4, 5)
filler = np.nan * np.zeros((4, 5))
... |
14,459,258 | Games from Valve use following [data format](http://media.steampowered.com/apps/440/scripts/items/items_game.9aee6b38c52d8814124b8fbfc8d13e7b1faa944f.txt)
```
"name1"
{
"name2" "value2"
"name3"
{
"name4" "value4"
}
}
```
Does this format have a name or is it just self made?
Can I parse it ... | 2013/01/22 | [
"https://Stackoverflow.com/questions/14459258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1670759/"
] | I'm not sure that it has a name, but it seems very straightforward: a node consists of a key and either a value or a set of values that are themselves either plain strings or sets of key-value pairs. It would be trivial to parse recursively, and maps cleanly to a structure of nested python dictionaries. | Looks like their own format, called Valve Data Format. Documentation [here](https://developer.valvesoftware.com/wiki/KeyValues), I don't know if there is a parser available in python, but here is a question about [parsing it in php](https://stackoverflow.com/questions/9301511/parsing-valve-data-format-files-in-php) |
14,459,258 | Games from Valve use following [data format](http://media.steampowered.com/apps/440/scripts/items/items_game.9aee6b38c52d8814124b8fbfc8d13e7b1faa944f.txt)
```
"name1"
{
"name2" "value2"
"name3"
{
"name4" "value4"
}
}
```
Does this format have a name or is it just self made?
Can I parse it ... | 2013/01/22 | [
"https://Stackoverflow.com/questions/14459258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1670759/"
] | I'm not sure that it has a name, but it seems very straightforward: a node consists of a key and either a value or a set of values that are themselves either plain strings or sets of key-value pairs. It would be trivial to parse recursively, and maps cleanly to a structure of nested python dictionaries. | Looks a lot like JSON without comma and colon seperators. You could parse it manually since it has the same logic to it.
Seems to consist of name-value pairs, so after a name, finding a '{' or another string in "" would mean a value.
A composite structure of custom classes would make it easy to handle. As Matti John ... |
50,917,003 | I'm trying to create a simple program to convert a binary number, for example `111100010` to decimal `482`. I've done the same in Python, and it works, but I can't find what I'm doing wrong in C++.
When I execute the C++ program, I get `-320505788`. What have I done wrong?
This is the Python code:
```python
def digi... | 2018/06/18 | [
"https://Stackoverflow.com/questions/50917003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5533085/"
] | The problem is that you converted this fragment of Python code
```
else:
digit = int(bit_number / exp % 10)
digit = digit * (2 ** i)
number += digit
```
into this:
```
else{
if((e % 10) == 0){
digit = 0;
}
else{
digit = bin_number / (e % 10);
}
digit = digit * pow(2, i);
... | One problem is that the 111100010 in main is not a [binary literal](https://en.cppreference.com/w/cpp/language/integer_literal) for 482 base 10 but is actually the decimal value of 111100010. If you are going to use a binary literal there is no need for any of your code, just write it out since an integer is an integer... |
49,677,110 | I am trying to decorate a function which is already decorated by `@click` and called from the command line.
Normal decoration to capitalise the input could look like this:
**standard\_decoration.py**
```
def capitalise_input(f):
def wrapper(*args):
args = (args[0].upper(),)
f(*args)
return wr... | 2018/04/05 | [
"https://Stackoverflow.com/questions/49677110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4288043/"
] | It appears that click passes keywords arguments. This should work. I think it needs to be the first decorator, i.e. it is called after all of the click methods are done.
```
def capitalise_input(f):
def wrapper(**kwargs):
kwargs['name'] = kwargs['name'].upper()
f(**kwargs)
return wrapper
@clic... | About click command groups - we need to take into account what the documentation says - <https://click.palletsprojects.com/en/7.x/commands/#decorating-commands>
So in the end a simple decorator like this:
```
def sample_decorator(f):
def run(*args, **kwargs):
return f(*args, param="yea", **kwargs)
ret... |
49,677,110 | I am trying to decorate a function which is already decorated by `@click` and called from the command line.
Normal decoration to capitalise the input could look like this:
**standard\_decoration.py**
```
def capitalise_input(f):
def wrapper(*args):
args = (args[0].upper(),)
f(*args)
return wr... | 2018/04/05 | [
"https://Stackoverflow.com/questions/49677110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4288043/"
] | Harvey's answer won't work with command groups. Effectively this would replace the 'hello' command with 'wrapper' which is not what we want. Instead try something like:
```
from functools import wraps
def test_decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
kwargs['name'] = kwargs['name'].upper(... | About click command groups - we need to take into account what the documentation says - <https://click.palletsprojects.com/en/7.x/commands/#decorating-commands>
So in the end a simple decorator like this:
```
def sample_decorator(f):
def run(*args, **kwargs):
return f(*args, param="yea", **kwargs)
ret... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | I'm using Macbook Pro M1 2020 model and faced the same issue. The issue was only with my cffi and pip versions maybe. Because these 4 steps helped me -
1. Uninstalling old cffi `pip uninstall cffi`
2. Upgrading pip `python -m pip install --upgrade pip`
3. Reinstalling cffi `pip install cffi`
4. Intalling cryptography ... | A little late to the party, but the solutions above didn't work for me. Paul got me on the right track, but my problem was that pyenv used the mac libffi for its build and cffi used the homebrew version. I read this somewhere, can't claim this unique insight.
My solution was to ensure that my python (3.8.13) was built... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | [This answer here worked like a charm! @paveldroo](https://stackoverflow.com/a/66422219/8524011)
As an extension to the answer above, I went ahead and saved the alias in step 3 as `alias ibrew='arch -x86_64 /usr/local/bin/brew'` at `~/.zshrc`
This means when I install anything with `brew` command, it gets installed f... | I have uninstalled older version of `cffi` and `cryptography`,
```
pip uninstall cffi
pip uninstall cryptography
```
and updated the `requirements.txt` file from exact versions to updated versions
```
# requirements.txt
cffi>=1.15.1
cryptography>=38.0.1
```
(version number can be different).
This resolved my is... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | I'm using Macbook Pro M1 2020 model and faced the same issue. The issue was only with my cffi and pip versions maybe. Because these 4 steps helped me -
1. Uninstalling old cffi `pip uninstall cffi`
2. Upgrading pip `python -m pip install --upgrade pip`
3. Reinstalling cffi `pip install cffi`
4. Intalling cryptography ... | I have uninstalled older version of `cffi` and `cryptography`,
```
pip uninstall cffi
pip uninstall cryptography
```
and updated the `requirements.txt` file from exact versions to updated versions
```
# requirements.txt
cffi>=1.15.1
cryptography>=38.0.1
```
(version number can be different).
This resolved my is... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | This issue is due to a mismatch between the libffi header version and the version of libffi the dynamic linker finds. In general it appears users encountering this problem have homebrew libffi installed and have a Python built against that in some fashion.
When this happens `cffi` (a `cryptography` dependency) compile... | I have uninstalled older version of `cffi` and `cryptography`,
```
pip uninstall cffi
pip uninstall cryptography
```
and updated the `requirements.txt` file from exact versions to updated versions
```
# requirements.txt
cffi>=1.15.1
cryptography>=38.0.1
```
(version number can be different).
This resolved my is... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | I'm using Macbook Pro M1 2020 model and faced the same issue. The issue was only with my cffi and pip versions maybe. Because these 4 steps helped me -
1. Uninstalling old cffi `pip uninstall cffi`
2. Upgrading pip `python -m pip install --upgrade pip`
3. Reinstalling cffi `pip install cffi`
4. Intalling cryptography ... | I wasn't able to previously install cffi, until I discovered an unrelated issue. I was at this for about two days, until I found this command:
```sh
python3 -m ensurepip --upgrade
```
Magically, everything started working for me. It came from an issue between Python and Pip coming from different sources.
Answer sto... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | I'm using Macbook Pro M1 2020 model and faced the same issue. The issue was only with my cffi and pip versions maybe. Because these 4 steps helped me -
1. Uninstalling old cffi `pip uninstall cffi`
2. Upgrading pip `python -m pip install --upgrade pip`
3. Reinstalling cffi `pip install cffi`
4. Intalling cryptography ... | [This answer here worked like a charm! @paveldroo](https://stackoverflow.com/a/66422219/8524011)
As an extension to the answer above, I went ahead and saved the alias in step 3 as `alias ibrew='arch -x86_64 /usr/local/bin/brew'` at `~/.zshrc`
This means when I install anything with `brew` command, it gets installed f... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | This issue is due to a mismatch between the libffi header version and the version of libffi the dynamic linker finds. In general it appears users encountering this problem have homebrew libffi installed and have a Python built against that in some fashion.
When this happens `cffi` (a `cryptography` dependency) compile... | A little late to the party, but the solutions above didn't work for me. Paul got me on the right track, but my problem was that pyenv used the mac libffi for its build and cffi used the homebrew version. I read this somewhere, can't claim this unique insight.
My solution was to ensure that my python (3.8.13) was built... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | A little late to the party, but the solutions above didn't work for me. Paul got me on the right track, but my problem was that pyenv used the mac libffi for its build and cffi used the homebrew version. I read this somewhere, can't claim this unique insight.
My solution was to ensure that my python (3.8.13) was built... | I have uninstalled older version of `cffi` and `cryptography`,
```
pip uninstall cffi
pip uninstall cryptography
```
and updated the `requirements.txt` file from exact versions to updated versions
```
# requirements.txt
cffi>=1.15.1
cryptography>=38.0.1
```
(version number can be different).
This resolved my is... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | This issue is due to a mismatch between the libffi header version and the version of libffi the dynamic linker finds. In general it appears users encountering this problem have homebrew libffi installed and have a Python built against that in some fashion.
When this happens `cffi` (a `cryptography` dependency) compile... | I wasn't able to previously install cffi, until I discovered an unrelated issue. I was at this for about two days, until I found this command:
```sh
python3 -m ensurepip --upgrade
```
Magically, everything started working for me. It came from an issue between Python and Pip coming from different sources.
Answer sto... |
66,035,003 | Help! I'm trying to install cryptography on my m1. I know I can run terminal in rosetta mode, but I'm wondering if there is a way not to do that.
Output:
```
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendo... | 2021/02/03 | [
"https://Stackoverflow.com/questions/66035003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4366541/"
] | This issue is due to a mismatch between the libffi header version and the version of libffi the dynamic linker finds. In general it appears users encountering this problem have homebrew libffi installed and have a Python built against that in some fashion.
When this happens `cffi` (a `cryptography` dependency) compile... | Probably, you'll have a problem with more packages and each has it's own solution for Apple Silicon, it's exhausting.
I came to final solution: using x86\_x64 Homebrew which installs x86 packages, including Python. Thus, all your requirements are installing as on the x86\_x64 macs and there are no more problems with t... |
10,442,913 | I am working on HTML tables using python.
I want to know that how can i fetch different column values using lxml?
HTML table :
```
<table border="1">
<tr>
<td>Header_1</td>
<td>Header_2</td>
<td>Header_3</td>
<td>Header_4</td>
</tr>
<tr>
<td>row 1_cell 1</td>
<td>row 1_cell 2</td>
<td>row 1_cell 3</td>
<td>row 1_ce... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10442913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/778942/"
] | I do not know how do you make the choice of Header1+Header2, or Header1+Header3,... As the tables must be reasonably small, I suggest to collect all the data, and only then to extract the wanted subsets of the table. The following code show the possible solution:
```
import lxml.etree as ET
def parseTable(table_fragm... | Look into LXML as an html/xml parser that you could use. Then simply make a recursive function. |
18,732,803 | So I'm trying to build an insult generator that will take lists, randomize the inputs, and show the randomized code at the push of a button.
Right now, the code looks like...
```
import Tkinter
import random
section1 = ["list of stuff"]
section2 = ["list of stuff"]
section3 = ["list of stuff"]
class myapp(Tkinter.T... | 2013/09/11 | [
"https://Stackoverflow.com/questions/18732803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2658570/"
] | ```
def OnButtonClick(self):
myText = self.generator() # CALL IT!
self.labelVariable.set(myText+"(You clicked the button !)")
self.entry.focus_set()
self.entry.selection_range(0,Tkinter.END)
```
AND
```
def generator(self):....
``` | change with OnButtonClick function's second line and replace myText with generator() |
18,732,803 | So I'm trying to build an insult generator that will take lists, randomize the inputs, and show the randomized code at the push of a button.
Right now, the code looks like...
```
import Tkinter
import random
section1 = ["list of stuff"]
section2 = ["list of stuff"]
section3 = ["list of stuff"]
class myapp(Tkinter.T... | 2013/09/11 | [
"https://Stackoverflow.com/questions/18732803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2658570/"
] | If im dissectiong your code properly, you need to set def generator(): outside of the class you've defined; aka, make it a local function, not a method of myapp. secondly, you are trying to use the myText variable inside your onButtonClick method, but as your error states, it is not defined. in order to use the data yo... | ```
def OnButtonClick(self):
myText = self.generator() # CALL IT!
self.labelVariable.set(myText+"(You clicked the button !)")
self.entry.focus_set()
self.entry.selection_range(0,Tkinter.END)
```
AND
```
def generator(self):....
``` |
18,732,803 | So I'm trying to build an insult generator that will take lists, randomize the inputs, and show the randomized code at the push of a button.
Right now, the code looks like...
```
import Tkinter
import random
section1 = ["list of stuff"]
section2 = ["list of stuff"]
section3 = ["list of stuff"]
class myapp(Tkinter.T... | 2013/09/11 | [
"https://Stackoverflow.com/questions/18732803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2658570/"
] | If im dissectiong your code properly, you need to set def generator(): outside of the class you've defined; aka, make it a local function, not a method of myapp. secondly, you are trying to use the myText variable inside your onButtonClick method, but as your error states, it is not defined. in order to use the data yo... | change with OnButtonClick function's second line and replace myText with generator() |
62,403,240 | I was doing some question in C and I was asked to provide the output of this question :
```
#include <stdio.h>
int main()
{
float a =0.7;
if(a<0.7)
{
printf("Yes");
}
else{
printf("No");
}
}
```
By just looking at the problem I thought the answer would be *NO* but after runni... | 2020/06/16 | [
"https://Stackoverflow.com/questions/62403240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9715289/"
] | ```
float a = 0.7;
if(a<0.7)
```
The first line above takes the `double` `0.7` and crams it into a `float`, which almost certainly has less precision (so you may lose information).
The second line upgrades the `float a` to a `double` (because you're comparing it with a `double 0.7`, and that's one of the things C do... | In `a<0.7` the constant `0.7` is a `double` then `a` which is a `float` is promoted
to `double` before the comparison.
Nothing guarantees that these two constants (as `float` and as `double`) are the same.
As `float` the fractional part of `0.7` is `00111111001100110011001100110011`; as `double` the fractional part... |
70,915,615 | I am trying to use a parent class as a blueprint for new classes.
E.g. the `FileValidator` contains all generic attributesand methods for a generic file. Then I want to create for example a `ImageValidator` inheriting everything from the FileValidator but with additional, more specific attribtues, methods. etc. In thi... | 2022/01/30 | [
"https://Stackoverflow.com/questions/70915615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11971785/"
] | Consider below approach
```
with example as (
select '670000000000100000000000000000000000000000000000000000000000000' as s
)
select s, (select sum(cast(num as int64)) from unnest(split(s,'')) num) result
from example
```
with output
[](ht... | Yet another [fun] option
```
create temp function sum_digits(expression string)
returns int64
language js as """
return eval(expression);
""";
with example as (
select '670000000000100000000000000000000000000000000000000000000000000' as s
)
select s, sum_digits(regexp_replace(replace(s, '0', ''), r'(\d)', r'+\1'))... |
8,219,630 | As a developer that has worked on more than one python project at once, I love the idea of Virtualenv. But, I'm currently trying to get Komodo IDE to play nice with VirtualEnv on a Windows box. I've downloaded virtualenvwrapper-win and got it working (btw, you are using Virtualenv on windows you should check it out):
... | 2011/11/21 | [
"https://Stackoverflow.com/questions/8219630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265681/"
] | I finally ended up posting the same question on the ActiveState forum. The reply was that it doesn't officially support VirtualEnv, yet. But, that you can make get it to work by adjusting the paths, etc. Here is the link to the question/reply.
<http://community.activestate.com/node/7499> | You can do this by adding the virtualenv's Python library to the project. Right-click on Project > Properties > Languages > Python > Additional Python Import Directories.
Now if someone could tell me how to add a folder like that in Mac when the virtualenv is under a hidden folder (without turning hidden folders on in... |
8,219,630 | As a developer that has worked on more than one python project at once, I love the idea of Virtualenv. But, I'm currently trying to get Komodo IDE to play nice with VirtualEnv on a Windows box. I've downloaded virtualenvwrapper-win and got it working (btw, you are using Virtualenv on windows you should check it out):
... | 2011/11/21 | [
"https://Stackoverflow.com/questions/8219630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265681/"
] | I finally ended up posting the same question on the ActiveState forum. The reply was that it doesn't officially support VirtualEnv, yet. But, that you can make get it to work by adjusting the paths, etc. Here is the link to the question/reply.
<http://community.activestate.com/node/7499> | Use the context menu to setup [virtualenv](https://stackoverflow.com/questions/8219630/virtualenv-and-komodo-ide-on-windows). Right-click on Project > Properties > Languages > Python > Additional Python Import Directories.
Use an alias in .profile to add support for [rvm](http://community.activestate.com/forum/does-ko... |
8,219,630 | As a developer that has worked on more than one python project at once, I love the idea of Virtualenv. But, I'm currently trying to get Komodo IDE to play nice with VirtualEnv on a Windows box. I've downloaded virtualenvwrapper-win and got it working (btw, you are using Virtualenv on windows you should check it out):
... | 2011/11/21 | [
"https://Stackoverflow.com/questions/8219630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/265681/"
] | You can do this by adding the virtualenv's Python library to the project. Right-click on Project > Properties > Languages > Python > Additional Python Import Directories.
Now if someone could tell me how to add a folder like that in Mac when the virtualenv is under a hidden folder (without turning hidden folders on in... | Use the context menu to setup [virtualenv](https://stackoverflow.com/questions/8219630/virtualenv-and-komodo-ide-on-windows). Right-click on Project > Properties > Languages > Python > Additional Python Import Directories.
Use an alias in .profile to add support for [rvm](http://community.activestate.com/forum/does-ko... |
41,846,466 | I am currently experimenting with Behavioral Driven Development. I am using behave\_django with selenium. I get the following output
```
Creating test database for alias 'default'...
Feature: Open website and print title # features/first_selenium.feature:1
Scenario: Open website # features/first_sel... | 2017/01/25 | [
"https://Stackoverflow.com/questions/41846466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7402682/"
] | I know it is a late answer but maybe somebody is going to profit from it:
you need to declare the context.browser (in a before\_all/before\_scenario/before\_feature hook definition or just test method definition) before you use it, e.g.:
```
context.browser = webdriver.Chrome()
```
Please note that the hooks must be... | In my case the browser wasn't installed. That can be a case too. Also ensure path to geckodriver is exposed if you are working with Firefox. |
18,005,365 | I need to start a python script with bash using nohup passing an arg that aids in defining a constant in a script I import. There are lots of questions about passing args but I haven't found a successful way using nohup.
a simplified version of my bash script:
```
#!/bin/bash
BUCKET=$1
echo $BUCKET
script='/home/p... | 2013/08/01 | [
"https://Stackoverflow.com/questions/18005365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1901847/"
] | In general, the argument vector for any program starts with the program itself, and then all of its arguments and options. Depending on the language, the program may be `sys.argv[0]`, `argv[0]`, `$0`, or something else, but it's basically always argument #0.
Each program whose job is to run another program—like `nohup... | ```
nohup python3 -u ./train.py --dataset dataset_directory/ --model model_output_directory > output.log &
```
Here Im executing train.py file with python3, Then -u is used to ignore buffering and show the logs on the go without storing, specifying my **dataset\_directory** with argument style and **model\_output\_di... |
18,968,607 | I'm trying to select timestamps columns from Cassandra 2.0 using cqlengine or cql(python), and i'm getting wrong results.
This is what i get from cqlsh ( or thrift ):
"2013-09-23 00:00:00-0700"
This is what i get from cqlengine and cql itself:
"\x00\x00\x01AG\x0b\xd5\xe0"
If you wanna reproduce the error, try this:
... | 2013/09/23 | [
"https://Stackoverflow.com/questions/18968607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2808750/"
] | Unfortunately, cqlengine is not currently compatible with cassandra 2.0
There were some new types introduced with Cassandra 2.0, and we haven't had a chance to make cqlengine compatible with them. I'm also aware of a problem with blob columns.
This particular issue is caused by the cql driver returning the timestamp... | The `timestamp` datatype stores values as the number of milliseconds since the epoch, in a long. It seems that however you are printing it is interpreting it as a string. This works for me using cql-dbapi2 after creating and inserting as in the question:
```
>>> import cql
>>> con = cql.connect('localhost', keyspace='... |
29,320,466 | I have tried to use [emcee](http://dan.iel.fm/emcee/current/user/advanced/) library to implement Monte Carlo Markov Chain inside a class and also make multiprocessing module works but after running such a test code:
```
import numpy as np
import emcee
import scipy.optimize as op
# Choose the "true" parameters.
m_true... | 2015/03/28 | [
"https://Stackoverflow.com/questions/29320466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2811074/"
] | There are a number of SO questions that discuss what's going on:
1. <https://stackoverflow.com/a/21345273/2379433>
2. <https://stackoverflow.com/a/28887474/2379433>
3. <https://stackoverflow.com/a/21345308/2379433>
4. <https://stackoverflow.com/a/29129084/2379433>
…including this one, which seems to be your response…... | For the record, you can now create a `pathos.multiprocessing` pool, and pass it to emcee using the `pool` argument. However, be aware that the overhead of multiprocessing can actually slow things down, unless your likelihood is particularly time-consuming to compute. |
70,747,394 | I am trying to check if a user input as a string exists in a list called categoriesList which appends categories from a text file named categories.txt. If the user inputs a category that then exists in categoriesList my code should be able to print out "Category exists", otherwise "Category doesn't exist".
Here is the... | 2022/01/17 | [
"https://Stackoverflow.com/questions/70747394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17928821/"
] | Your `STATICFILES_FINDERS` setting tells Django that it should look for static files in the following places:
* `FileSystemFinder` tells it to look in whichever locations are listed in STATICFILES\_DIRS;
* `AppDirectoriesFinder` tells it to look in the `static` folder of each registered app in INSTALLED\_APPS.
In nor... | Try changing:
`STATICFILES_DIRS = [os.path.join(PROJECT_DIR, 'static'),]`
to
`STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]` |
15,128,404 | I am making a GUI in wxpython.
I want to place images next to radio buttons.
How should i do that in wxpython? | 2013/02/28 | [
"https://Stackoverflow.com/questions/15128404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2118322/"
] | I suggest using wx.ToggleButton with bitmap labels if you are using 2.9, or one of the bitmap toggle button classes in wx.lib.buttons if you are still on 2.8. You can then implement the "radio button" functionality yourself by untoggling all other buttons in the group when one of them is toggled. Using the bitmap itsel... | I'm not sure what you mean. Are you wanting images instead of the actual radio button itself? That is not supported. If you want an image in addition to the radio button, then just use a group of horizontal box sizers or one of the grid sizers. Add the image and then the radio button. And you're done! |
15,128,404 | I am making a GUI in wxpython.
I want to place images next to radio buttons.
How should i do that in wxpython? | 2013/02/28 | [
"https://Stackoverflow.com/questions/15128404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2118322/"
] | I suggest using wx.ToggleButton with bitmap labels if you are using 2.9, or one of the bitmap toggle button classes in wx.lib.buttons if you are still on 2.8. You can then implement the "radio button" functionality yourself by untoggling all other buttons in the group when one of them is toggled. Using the bitmap itsel... | I am satisfied with the following:
* image icon is left to the radio button,
* click on the image activates radion button.
It seems that usability does not suffer.
```
def make_radio_with_icon(parent_window, bitmap, label):
sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
sizer.Add(bitmap)
r = wx.RadioButton(parent_w... |
60,976,753 | well i have this DF in python
```
folio id_incidente nombre app apm \
0 1 1 SIN DATOS SIN DATOS SIN DATOS
1 131 100085 JUAN DOMINGO GONZALEZ DELGADO
2 132 100085 FRANCISCO JAVIER VELA... | 2020/04/01 | [
"https://Stackoverflow.com/questions/60976753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11579387/"
] | Use [`Object.values`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values) with [`Array.prototype.some`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some):
```js
const obj = {
id: '123abc',
carrier_name: 'a',
group_id: 'a',
... | You could check with `every` and `Boolean` as callback, **if you have only strings**.
```js
const check = object => Object.values(object).every(Boolean);
console.log(check({ foo: 'bar' })); // true
console.log(check({ foo: '' })); // false
console.log(check({ foo: '', bar: 'baz' })); // false... |
60,976,753 | well i have this DF in python
```
folio id_incidente nombre app apm \
0 1 1 SIN DATOS SIN DATOS SIN DATOS
1 131 100085 JUAN DOMINGO GONZALEZ DELGADO
2 132 100085 FRANCISCO JAVIER VELA... | 2020/04/01 | [
"https://Stackoverflow.com/questions/60976753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11579387/"
] | Use [`Object.values`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values) with [`Array.prototype.some`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some):
```js
const obj = {
id: '123abc',
carrier_name: 'a',
group_id: 'a',
... | Simple loop and check
```js
const obj = {
id: '123abc',
carrier_name: 'a',
group_id: 'a',
member_id: '',
plan_name: '',
}
const checkIfEmpty = obj => {
for (const property in obj) {
if (obj[property].length === 0) {
return true
}
}
return false
}
console.log(checkIfEmpty(... |
60,976,753 | well i have this DF in python
```
folio id_incidente nombre app apm \
0 1 1 SIN DATOS SIN DATOS SIN DATOS
1 131 100085 JUAN DOMINGO GONZALEZ DELGADO
2 132 100085 FRANCISCO JAVIER VELA... | 2020/04/01 | [
"https://Stackoverflow.com/questions/60976753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11579387/"
] | Simple loop and check
```js
const obj = {
id: '123abc',
carrier_name: 'a',
group_id: 'a',
member_id: '',
plan_name: '',
}
const checkIfEmpty = obj => {
for (const property in obj) {
if (obj[property].length === 0) {
return true
}
}
return false
}
console.log(checkIfEmpty(... | You could check with `every` and `Boolean` as callback, **if you have only strings**.
```js
const check = object => Object.values(object).every(Boolean);
console.log(check({ foo: 'bar' })); // true
console.log(check({ foo: '' })); // false
console.log(check({ foo: '', bar: 'baz' })); // false... |
25,449,779 | I use Google Cloud SDK under Window 7 64bit.
Google Cloud SDK and python install success. and run gcloud.
The error occurs as shown below.
```
C:\Program Files\Google\Cloud SDK>gcloud
Traceback (most recent call last):
File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin\..\./lib\googlecloudsdk\gcloud\gclou... | 2014/08/22 | [
"https://Stackoverflow.com/questions/25449779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/485569/"
] | I had the same problem. And this helped me solve this problem
Manually removed directory: C:\Program Files\Google\Cloud SDK
Then rerun: GoogleCloudSDKInstaller.exe
And make sure that you have connection to needed DL servers (I was first behind company firewall and installer didn't download all files - and no complai... | ```
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt updat... |
18,805,720 | All I know how to do is type "python foo.py" in dos; the program runs but then exits python back to dos. Is there a way to run foo.py from within python? Or to stay in python after running? I want to do this to help debug, so that I may look at variables used in foo.py
(Thanks from a newbie) | 2013/09/14 | [
"https://Stackoverflow.com/questions/18805720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779936/"
] | You can enter the python interpreter by just typing Python. Then if you run:
```
execfile('foo.py')
```
This will run the program and keep the interpreter open. More details [here](http://docs.python.org/2/library/functions.html#execfile). | To stay in Python afterwards you could just type 'python' on the command prompt, then run your code from inside python. That way you'll be able to manipulate the objects (lists, dictionaries, etc) as you wish. |
18,805,720 | All I know how to do is type "python foo.py" in dos; the program runs but then exits python back to dos. Is there a way to run foo.py from within python? Or to stay in python after running? I want to do this to help debug, so that I may look at variables used in foo.py
(Thanks from a newbie) | 2013/09/14 | [
"https://Stackoverflow.com/questions/18805720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2779936/"
] | You can enter the python interpreter by just typing Python. Then if you run:
```
execfile('foo.py')
```
This will run the program and keep the interpreter open. More details [here](http://docs.python.org/2/library/functions.html#execfile). | add the module `q` , and use its `q.d()` method (I did it with `easy_install q`)
<https://pypi.python.org/pypi/q>
```
import q
....
#a bunch of code in foo.py
...
q.d()
```
that will give you a console at any point in your program where you put it that you can interact with your script
consider the following foo.py... |
27,621,018 | how to perform
```
echo xyz | ssh [host]
```
(send xyz to host)
with python?
I have tried pexpect
```
pexpect.spawn('echo xyz | ssh [host]')
```
but it's performing
```
echo 'xyz | ssh [host]'
```
maybe other package will be better? | 2014/12/23 | [
"https://Stackoverflow.com/questions/27621018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3419895/"
] | <http://pexpect.sourceforge.net/pexpect.html#spawn>
Gives an example of running a command with a pipe :
```
shell_cmd = 'ls -l | grep LOG > log_list.txt'
child = pexpect.spawn('/bin/bash', ['-c', shell_cmd])
child.expect(pexpect.EOF)
```
Previous incorrect attempt deleted to make sure no-one is confused by it. | You don't need `pexpect` to simulate a simple shell pipeline. The simplest way to emulate the pipeline is the `os.system` function:
```
os.system("echo xyz | ssh [host]")
```
A more Pythonic approach is to use [the `subprocess` module](https://docs.python.org/2/library/subprocess.html):
```
p = subprocess.Popen(["s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.