Peter Otten wrote:
...
> I recommend that you use a dataclass /instead/ of a namedtuple, not
> both. However, for a dataclass with the same fields in the same order as
> in your namedtuple the conversion is trivial:
>
> Create compatible namedtuple and dataclass types:
>
> >>> NTRow = namedtuple("N
On 18/12/2022 16:44, songbird wrote:
Peter Otten wrote:
...
While I think what you need is a database instead of the collection of
csv files the way to alter namedtuples is to create a new one:
from collections import namedtuple
Row = namedtuple("Row", "foo bar baz")
row = Row(1, 2, 3)
row._r
On 17/12/2022 20:45, Albert-Jan Roskam wrote:
On Dec 15, 2022 10:21, Peter Otten <__pete...@web.de> wrote:
>>> from collections import namedtuple
>>> Row = namedtuple("Row", "foo bar baz")
>>> row = Row(1, 2, 3)
>>> row._replace(bar=42)
Row(foo=1, bar=42, baz=3)
Peter Otten wrote:
...
> While I think what you need is a database instead of the collection of
> csv files the way to alter namedtuples is to create a new one:
>
> >>> from collections import namedtuple
> >>> Row = namedtuple("Row", "foo bar baz")
> >>> row = Row(1, 2, 3)
> >>> row._replace(bar=4
On Dec 15, 2022 10:21, Peter Otten <__pete...@web.de> wrote:
>>> from collections import namedtuple
>>> Row = namedtuple("Row", "foo bar baz")
>>> row = Row(1, 2, 3)
>>> row._replace(bar=42)
Row(foo=1, bar=42, baz=3)
Ahh, I always thought these are undocumen
Peter Otten wrote:
>
> While I think what you need is a database instead of the collection of
> csv files the way to alter namedtuples is to create a new one:
the files are coming from the web site that stores the
accounts. i already have manually created files from many
years ago with some of
I have a lot of NamedTuples in my codebase, and I now add new ones never. They
were a good option prior to Python 3.7 but dataclasses are much easier to work
with and are almost a drop-in substitute.
A combination of a default dictionary and a dataclass might meet your needs:
import collectio
On 14/12/2022 19:50, songbird wrote:
I'm relatively new to python but not new to programming in general.
The program domain is accounting and keeping track of stock trades and other
related information (dates, cash accounts, interest, dividends, transfers of
funds, etc.)
Assume that
Dictionaries and sets are your friends here.
On 12/14/2022 1:50 PM, songbird wrote:
I'm relatively new to python but not new to programming in general.
The program domain is accounting and keeping track of stock trades and other
related information (dates, cash accounts, interest, divid