reference

How can I make two objects from different classes to reference each other?

How can I make two objects from different classes to reference each other? Question: I am working on a project and have encountered a roadblock. I’m not sure to make objects of different classes reference each other and delete the reference if one of them drops it. For example, I have a network switch and …

Total answers: 1

how to solve "Unresolved reference 'unpack'" in python3.7?

how to solve "Unresolved reference 'unpack'" in python3.7? Question: when I check the code in kaggle 3hr-tensorrt-nextvit-example, I find there is a error that I can not solve. it is called Unresolved reference ‘unpack‘.what should I do? unc_data = unpack(unpack_fmt, cast(bytes, item.LUTData)) Asked By: Hong Cheng || Source Answers: import the symbol unpack is probably …

Total answers: 1

how to create a list of new objects in python

how to create a list of new objects in python Question: I am trying to create a list of new objects in python (as in separate memory locations, not references) class example: _name = "" _words = [] def __init__(self,name): _name = name def add_words(self,new_words): for i in new_words: self._words.append(i) examples = [example("example_1"),example("example_2"),example("example_3")] examples[0].add_words(["test1","test2"]) print(examples[2]._words) …

Total answers: 2

How to modify a Series(DataFrame) of Pandas in place during iterating?

How to modify a Series(DataFrame) of Pandas in place during iterating? Question: I need to revice values in a Series(column) of Pandas according to another function. During iterating, after I get the result, I don’t want to lookup the series twice, becasue I guess that it wastes time and is not required. For example: import …

Total answers: 1

How to Reference List of Dicitionaries from One Class to Another?

How to Reference List of Dicitionaries from One Class to Another? Question: I am currently working on an inventory system and trying to implement a class that serves as a "fast fact finer" for my database, which is managed by my Database Management class. The csv file looks like this: I have the following code: …

Total answers: 1

Why doesn't list change?

Why doesn't list change? Question: In Python: b = [] a = np.arange(2) b.append(a) a = np.arange(4) b.append(a) print(b) # gives [array([0, 1]), array([0, 1, 2, 3])] Why doesn’t it give [array([0, 1, 2, 3]), array([0, 1, 2, 3])]? There are a ton of questions going the other way (to make sure the list does …

Total answers: 1

sys.getrefcount() prints one more than the expected number of references to an object?

sys.getrefcount() prints one more than the expected number of references to an object? Question: I would like to know why this code prints 4 instead of 3. Where is the fourth reference? import sys def f(a): print(sys.getrefcount(a)) a = [1, 2, 3] f(a) Asked By: ThunderPhoenix || Source Answers: We can make sense of this …

Total answers: 2

When does a pointer to a linked list change the actual list?

When does a pointer to a linked list change the actual list? Question: I have a singly-linked-list, L, and create a pointer to this list P. It seems like sometimes modifying P changes the actual list, while other times modifying P does nothing to the actual list L and only changes what P is pointing …

Total answers: 3

Python 3.6.5 "is" and "==" for integers beyond caching interval

Python 3.6.5 "is" and "==" for integers beyond caching interval Question: I want to preface this by saying that I know the difference between == and is one is for references and the other is for objects. I also know that python caches the integers in the range (-5, 256) at startup so they should …

Total answers: 2