Skip to main content

All Questions

Tagged with
0 votes
1 answer
126 views

_pickle.PicklingError: Can't pickle <class '__main___.{CONST} '>: attribute lookupfaileddir_namesmain_on __main__ failed

firstly dir_names works well when pickling dir_names = collections.namedtuple('dir_names', ['mark', 'category']) pickle.dump(dir_names, open('tmp.bin', 'wb')) I want make dir_name a const DIR_NAMES = ...
king Carrey's user avatar
0 votes
1 answer
129 views

Print named tuple value in a list

A function is returning me the below list of named tuples: [popenfile(path='/home/giampaolo/monit.py', fd=3, position=0, mode='r', flags=32768), popenfile(path='/var/log/monit.log', fd=4, position=...
Saga Harby's user avatar
1 vote
1 answer
131 views

Difference between a class(namedtuple) and a namedtuple

What is the difference between class(namedtuple) and only namedtuple, they look different but in both cases sensor seems to be the same thing, and what kind of functionality can be added inside class ...
Tung's user avatar
  • 33
1 vote
1 answer
803 views

Python namedtuple: AttributeError: 'tuple' object has no attribute 'end_pos'

I have a class that starts as follows: from collections import namedtuple class Parser: Rule = namedtuple('Rule', ['lhs', 'rhs', 'dot_pos', 'start_pos', 'end_pos']) # __init__ ... Since ...
TiMauzi's user avatar
  • 236
0 votes
2 answers
164 views

Getting error when trying to create namedtuple object using _make function

Hi all I recently started learning Python collections module. When I was trying to implement namedtuple collections for practice I got an error. I tried searching for in the official Python ...
Vishal Lade's user avatar
0 votes
1 answer
54 views

Storing value for a point using named tuple?

I am trying to design a spreadsheet app. I have been able to come up with a class for my Index which is typically the point consisting of row, col. I want to be able to assign a value to the point. ...
SDRJ's user avatar
  • 540
0 votes
2 answers
234 views

Are pickle-able tuple-factories (with names) possible?

There are several questions about pickling namedtuples already, however none of the ones I found [1] [2] [3] [4] deals with the case of pickling a namedtuple that is bound on an object instance. ...
Hyperplane's user avatar
  • 1,644
1 vote
1 answer
572 views

Name a nested typing.NamedTuple in the same outer class in Python

I have a problem in Python I can work around, but I'd really like to understand why it doesn't work the way I think it should. I have a class A which has nested typing.NamedTuples B and C. So far so ...
GoDontKnow's user avatar
0 votes
2 answers
54 views

Search substring in list of dictionaries of namedtuples keyed with an event type

I have created a list of dictionaries of named tuples, keyed with an event type. [{'EVENT_DELETE': DeleteRequestDetails(rid=53421, user='user1', type='EVENT_DELETE', reviewed=1, approved=1, completed=...
gosaultech's user avatar
0 votes
1 answer
61 views

Unable to compare types of identical but redeclared namedtuples in Python

While working on a difference engine to identify differences in very large data structures, I noticed that a type comparison between identical-but-redeclared namedtuples misbehaves. Redeclaring the ...
Drakes's user avatar
  • 23.5k
1 vote
0 answers
140 views

Creating tuples of images and distributing the tuples into training and testing sets

I've a simple program that creates a bunch of images. The problem is, they need to be ordered into tuples of three images so that the images in each tuple are kept together when they are distributed ...
Brian Droncheff's user avatar
1 vote
1 answer
445 views

How to get key and values using NamedTuple

Python 3.9.6 I have been trying to figure out on how I am able to print the key and value when I have given variable that I want to specific get from a NamedTuple. I have created my own NamedTuple ...
PythonNewbie's user avatar
  • 1,111
0 votes
1 answer
137 views

Nested data structures in Python

I am trying to create a data structure that will be used for geospatial decomposition - basically take a top 10x10 grid and be able to decompose each grid within it. I am using namedtuples for the ...
Bryon's user avatar
  • 1,007
-1 votes
1 answer
61 views

Trouble casting string to NamedTuple

I am trying to parse a string rep of a NamedTuple for connection parameters generated remotely by the psutil library (process.connections()) The string looks like this: pconn(fd=-1, family=<...
Bill 's user avatar
  • 666
2 votes
2 answers
631 views

Can you use namedtuples/dataclass/attrs to create a flexible sized class or do you have to use traditional classes?

If there is a json data set that looks like this. [ {'a':1,'b':'fire','c':'cambodia','type':'charizard'}, {'a':2,'d':'waterparks','type':'squirtle'}, {'a':3,'f':'thunder','type':'pikachu'} ] And it ...
polka's user avatar
  • 1,489

15 30 50 per page
1
2 3 4 5
7