Skip to content

Tag: python-3.x

Create a list of dictionaries from nested list

I do have a dynamic text that will change. I want to store those values in a meaningful way. I have created a nested list to store them but I need to convert those to individual dictionaries and store it into a list. How do I do this? So far good. Devices variable is a nested list. I need to

Custom list class slicing functionality

I want to implement my own type of list called Stack. I also want to add slicing functionality with the __getitem__ method like so: Now if I create a Stack instance and append some elements to it I get the Stack type: but if I slice my Stack, it becomes a list again: how can I make st_sliced to stay

Define the variable of a function call indirectly

I have two files file1.py and file2.py. I execute a function from file2.py which executes a function from file1.py. The transfer function from file1.py is used in several other files in the tree. Could I, from outside the tree, set the token variable for the transfer function in my file1.py? Which would be ap…