Jáchym Barvínek added the comment:
I am experiencing the same issue when trying to build the ArchLinux python
package. Not sure how to reproduce, but I can provide specific details of my
system if requested.
--
nosy: +Jáchym Barvínek
___
Python
New submission from Jáchym Barvínek:
The class collections.Counter should semantically contain only numbers, so it
makes sense to define dot product od Counters, something like this:
def __matmul__(self, other):
return sum(self[x] * other[x] for x in self.keys() | other.keys())
I find this
Jáchym Barvínek added the comment:
Sorry, It should be 0.0 ** 0 == 0 ** 0.0 == 0.0 ** 0.0 == 1.0 of course.
--
___
Python tracker
<http://bugs.python.org/issue28
New submission from Jáchym Barvínek:
0 ** 0 is mathematically undefined and equivalent to 0/0. 0/0 correctly raises
ZeroDivisionError, but 0 ** 0 == 1. Also 0.0 ** 0 == 0 ** 0.0 == 0.0 ** 0.0 ==
0.0. Similarly for math.pow.
--
components: Interpreter Core
messages: 279410
nosy: Jáchym
Jáchym Barvínek added the comment:
Java offers an identity function:
https://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html
2016-08-25 14:10 GMT+02:00 Steven D'Aprano :
>
> Steven D'Aprano added the comment:
>
> Just in case anyone else thinks this is
New submission from Jáchym Barvínek:
An identity function is sometimes useful in functional-style programming as a
dummy or default value.
For example, we can sometimes see a pattern like this (e.g. in
itertools.groupby):
def f(params, key=None):
if key is None:
key = lambda x: x
Jáchym Barvínek added the comment:
I did not know about cwd for Popen. It seems like the better way to go.
Thank you.
2015-11-14 19:58 GMT+01:00 desbma :
>
> desbma added the comment:
>
> I'm not a Python core developer, but a few thoughts:
> * this is not thread safe
New submission from Jáchym Barvínek:
I use this context manager in my code:
@contextmanager
def in_directory(path):
pwd = str(Path().absolute())
if not path.is_dir():
path = path.parent
os.chdir(str(path))
yield path.absolute()
os.chdir(pwd)
I thought it would be