Python Forum
Attribute of module shelve doesn't work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attribute of module shelve doesn't work
#1
import shelve
db = shelve.open('experement')
db['name'] = 'Sam'
db['age'] = 45
db.close()
Error:
Traceback (most recent call last): File "C:/Users/Владелец/Desktop/experements/shelve.py", line 1, in <module> import shelve File "C:/Users/Владелец/Desktop/experements\shelve.py", line 2, in <module> db = shelve.open('experement') AttributeError: 'module' object has no attribute 'open'
Reply
#2
Your file is named shelve.py, so python looks for open in it. Rename your file to something different
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 791 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 962 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,810 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 898 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  How do I get pygame module to work in Spyder? (Mac) FirstBornAlbratross 18 4,429 Dec-18-2022, 06:43 PM
Last Post: FirstBornAlbratross
  client.get_all_tickers() Doesn't work gerald 2 1,724 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 4,241 May-30-2022, 03:31 PM
Last Post: bowlofred
  Module 'time' has no attribute 'clock' Sophie 4 3,133 Jan-25-2022, 08:05 PM
Last Post: Sophie
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 2,030 Dec-18-2021, 02:38 AM
Last Post: knight2000
  Class Method to Calculate Age Doesn't Work gdbengo 1 1,717 Oct-30-2021, 11:20 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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