473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

python33, dictionary, NoneType' object has no attribute 'append'

103 100+
I am not able to initialize empty dictionary in python33.
I have tried:
Expand|Select|Wrap|Line Numbers
  1. D=dict()
  2. D={}
Later i want to insert values using:
Expand|Select|Wrap|Line Numbers
  1. D.setdefault(num).append(ansdb2.Rname)
In both cases i am getting error "NoneType' object has no attribute 'append'"
Oct 4 '14 #1
1 4180
gintare
103 100+
It should be empty brackets as a second parameter to setdefault:
Expand|Select|Wrap|Line Numbers
  1. D.setdefault(num, []).append(ansdb2.Rname)
Oct 4 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Arnaud-F. FAUSSE | last post by:
Hello, I wrote code to store and fetch information from MySQL, and I have this problem: - using .fetchall(), I get tuples (correct according to specification) - using .fetchone(), I get...
4
by: python newbie | last post by:
Is there anything that would get in the way of me being able to reference an object attribute, from within a list. I have: # one class here class BackupSet: fileGroupList = # ...
1
by: Atul Kshirsagar | last post by:
Hello, I am using Python 2.3.2 with a C++ extention DLL in muti-threaded environment. 1. For each new thread I create a separate sub-interpreter. 2. Each thread executes multiple python...
4
by: Arjen | last post by:
Hi, I have a class with some attributes. For example class person with name as attribute. I have add multiple persons in an arraylist. Now I need a function to get/find a person by the name...
7
by: noro | last post by:
Is it possible to do the following: for a certain class: ---------------------------- class C: def func1(self): pass def func2(self):
5
by: tom | last post by:
Hi! My code is And it gives following error: How can sortedList variable turn into NoneType? I just don't get it...
3
by: Al Meadows | last post by:
I'm using a generic Dictionary object where it is described as: Dictionary<this, thatstuff = new Dictonary<this, that>() Where THIS is a class with several property values. This works fine...
3
by: =?Utf-8?B?THVpZ2k=?= | last post by:
Hi all, I have a dictionary (C# 2.0) with an object (an instance of a class) for the key. The class has only a "name" field. dictionary<object, ...> When I use ContainsKey property of the...
4
by: Atrisa | last post by:
I have a file with lines like this: Host: gateway.edge.messenger.live.com Referer: 13.gateway.edge.messenger.live.com/help Host: ads.lfstmedia.com Referer:...
3
by: Barry1point4 | last post by:
I've been learing python from http://www.learnpython.org/page/Functions and in the functions lesson I've got stuck on the exercise for 2 days now. As far as I can tell my code should work but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.