Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File structure
#11
(Sep-21-2020, 05:07 AM)buran Wrote: don't use dict as variable name - it's built-in function
Easier said than done......

But ok, I will take it to our team's attention
Reply
#12
(Sep-22-2020, 01:57 PM)macfanpl Wrote: Easier said than done......

But ok, I will take it to our team's attention


just to illustrate

spam = dict()
print(spam, type(spam)) # spam is empty dict
eggs = dict(zip([1, 2], ['a', 'b'])) # {1: 'a', 2: 'b'}
print(eggs)

dict = 'something'
eggs = dict(zip([1, 2], ['a', 'b']))
print(eggs)
Output:
{} <class 'dict'> {1: 'a', 2: 'b'} Traceback (most recent call last): File "***", line 7, in <module> eggs = dict(zip([1, 2], ['a', 'b'])) TypeError: 'str' object is not callable
even if you don't use it, it may be used by a third-party package you do and then it will be a nightmare to debug
.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#13
Plus, dict is likely not a particularly meaningful name for a variable anyway.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Hard disk structure like a file selection dialog malonn 2 761 Aug-09-2023, 09:14 PM
Last Post: malonn
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,558 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  File system representation in a data structure Alfalfa 1 2,026 Dec-18-2019, 01:56 AM
Last Post: Alfalfa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020