Richard Neumann added the comment:
I just stumbled across this issue trying to resolve this:
https://bugs.python.org/issue42765?
While this fails:
from typing import NamedTuple
class Spamm(NamedTuple):
foo: int
bar: str
def __getitem__(self, index_or_key):
"&quo
Richard Neumann added the comment:
Okay, I found the solution. Not using super() works:
from typing import NamedTuple
class Spamm(NamedTuple):
foo: int
bar: str
def __getitem__(self, index_or_key):
if isinstance(index_or_key, str):
try
Richard Neumann added the comment:
Thank you all for your input.
I had a look at aforementioned discussion and learned something new.
So I tried to implement the dict data model by implementing keys() and
__getitem__() accordingly:
from typing import NamedTuple
class Spamm(NamedTuple
Richard Neumann added the comment:
I could have sworn, that this worked before, but it was obviously me being
tired at the end of the work day.
Thanks for pointing this out and sorry for the noise.
--
___
Python tracker
<https://bugs.python.
New submission from Richard Neumann :
When sublassing the built-in list, the invocation of super().__new__ will
unexpectedly expand the passed arguments:
class MyTuple(tuple):
def __new__(cls, *items):
print(cls, items)
return super().__new__(cls, items)
class MyList
New submission from Richard Neumann :
I have use cases in which I use named tuples to represent data sets, e.g:
class BasicStats(NamedTuple):
"""Basic statistics response packet."""
type: Type
session_id: BigEndianSignedInt32
motd: str
Richard Neumann added the comment:
Awesome, I didn't know that.
I tried it without the parens and it gave me a SyntaxError.
This can be closed then as it's obviously already implemented.
Let's get to refactoring.
--
___
Python
New submission from Richard Neumann :
I often write factory (deserialization) methods for ORM models for web
application backends that produce a number of records (ORM model instances) of
itself and related database tables:
@classmethod
def from_json(cls, json):
"&qu
New submission from Richard Neumann :
Currently only plain strings can be used as docstrings, such as:
class Foo:
"""Spamm eggs."""
For dynamic class generation, it would be useful to allow format strings as
docstrings as well:
doc = 'egg
Richard Neumann added the comment:
See also: https://en.wikipedia.org/wiki/Capital_%E1%BA%9E
--
___
Python tracker
<https://bugs.python.org/issue37113>
___
___
New submission from Richard Neumann :
Currently, calling the method .upper() on a string containing 'ß' will replace
this character by 'SS'. It should, however, be replaced by 'ẞ'.
--
components: Unicode
messages: 344065
nosy: Richard Neumann, ezio.melo
Richard Neumann added the comment:
I updated my pull request.
Since "_windll_getnode()" is only returning a (random?) node for a UUID, I
circumevented the value checking by introducing a new keyword-only argument
"strict" defaulting to "True&qu
Richard Neumann added the comment:
@xtreak Indeed. It fails on _windll_getnode().
==
ERROR: test_windll_getnode (test.test_uuid.TestInternalsWithoutExtModule
Richard Neumann added the comment:
Typos:
"For explicitely checking the version" → "For explicitely *setting* the
version".
"on not 1<= verision 1<=5" → "on not 1 <= version <= 5".
--
___
Richard Neumann added the comment:
@xtreak RFC 4122, section 4.1.3. specifies only versions 1 to 5.
For explicitely checking the version, there is already a test in UUID.__init__,
raising a ValueError on not 1<= verision 1<=5.
I moved it to the bottom of __init__, i.e. after setting th
Richard Neumann added the comment:
I'm not sure whether the property method should be changed.
I think it'd be more appropriate to raise a value error upon __init__ in this
case as it is done with other checks.
--
nosy: +conqp
___
Pyth
New submission from Richard Neumann :
The tempfile.TemporaryDirectory is incorrectly documented at
https://docs.python.org/3.6/library/tempfile.html#tempfile.TemporaryDirectory.
It is described as a function, though actually being a class (unlinke
tempfile.NamedTemporaryFile).
The respective
New submission from Richard Neumann :
In the documentation of the built-in exceptions hierarchy, there is a "|"
missing connecting ImportError and LookupError.
https://docs.python.org/3/library/exceptions.html#exception-hierarchy
>From LookupError.__mro__ we can tell, that i
Richard Neumann added the comment:
Maybe there is no need to sacrifice performance, if a new, optional keyword
argument would be introduced to dict.items():
def items(self, named=False):
if named:
else:
Currently I need to define a namedtuple
New submission from Richard Neumann :
Currently, iterating over dict_items will yield plain tuples, where the first
item will be the key and the second item will be the respective value.
This has some disadvantages when e.g. sorting dict items by value and key:
def sort_by_value_len
Richard Neumann added the comment:
Thank you for the hint.
I never before contributed code to the python foundation and thus am not
familiar with the process.
I will look into it when I find the time.
--
___
Python tracker
<http://bugs.python.
Richard Neumann added the comment:
Please excuse my ambiguous phrasing.
What I meant was I created the patch _from_ the Python 3.5.1 module _for_
Python 3.6.
--
___
Python tracker
<http://bugs.python.org/issue25
Richard Neumann added the comment:
I took the liberty to create a patch for Python v3.5.1.
--
keywords: +patch
nosy: +Richard Neumann
Added file: http://bugs.python.org/file42828/subprocess.patch
___
Python tracker
<http://bugs.python.org/issue25
Changes by Richard Neumann :
Added file: http://bugs.python.org/file42827/logger.patch
___
Python tracker
<http://bugs.python.org/issue26999>
___
___
Python-bugs-list m
Changes by Richard Neumann :
Removed file: http://bugs.python.org/file42825/logger.patch
___
Python tracker
<http://bugs.python.org/issue26999>
___
___
Python-bugs-list m
Richard Neumann added the comment:
Added proposed patch
--
keywords: +patch
Added file: http://bugs.python.org/file42825/logger.patch
___
Python tracker
<http://bugs.python.org/issue26
Richard Neumann added the comment:
PS: @vinay.sajip
You do realize that I want this argument to be optional and to retain '.' as
default setting in order to keep the current behaviour?!
--
___
Python tracker
<http://bugs.python.o
Richard Neumann added the comment:
I am using loggers and sub-loggers (getChild()) in classes, which contain
sub-classes, wich contain sub-sub-classes and so on for complex data processing.
Hence I was using the logging library with sub-loggers to see in which of the
(sub-)classes things
Changes by Richard Neumann :
--
title: Add child seperator keyword to logging.basicConfig and use it in
Logger.getChild() -> Add child separator keyword to logging.basicConfig and use
it in Logger.getChild()
___
Python tracker
&l
New submission from Richard Neumann:
Currently Python's logging library has the Child-Separator hard-coded in
Logger.getChild() as '.'.
It would be useful to have the ability to preset this via an optional
basicConfig() argument like 'child_sep=' and preset it to &
Richard Neumann added the comment:
A useless use case is attached.
Basically it boils down to having the ability to evaluate the CompletedProcess
directly by if/else rather than comparing its returncode attribute to zero each
time or handling the exception raised by check_returncode().
I use
New submission from Richard Neumann:
The class subprocess.CompletedProcess is currently lacking a __bool__() method.
It might be a practical feature to have the possibility to evaluate a
CompletedProcess instance in an if/else block without the necessity to handle
the exception raised by
32 matches
Mail list logo