Hi,
I would like to retain the orginal dictionary data without deleting the entire data in it as shown below. - Sample
-
>>> d1 = {1:100,2:200,3:400}
-
>>> d2 = d1
-
>>> d1
-
{1: 100, 2: 200, 3: 400}
-
>>> d2
-
{1: 100, 2: 200, 3: 400}
-
>>> del d2[2]
-
>>> d2
-
{1: 100, 3: 400}
-
>>> d1
-
{1: 100, 3: 400}
-
>>>
-
But I want d1 = {1:100,2:200,3:400} to be reatined with all the values upto the end of the program.
Could you please suggest what is steps to be followed to retain the values in orginal Dict.
Thanks
PSB
2 1036
Please ignore this post.
I got the solution. It is copy method we have to use
d2 = d1.copy()
-PSB
Please ignore this post.
I got the solution. It is copy method we have to use
d2 = d1.copy()
-PSB
Now you're getting to be a Pythoneer!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Xavier |
last post by:
Greetings,
(do excuse the possibly comical subject text)
I need advice on how I can convert a text db into a dict. Here is an
example of what I need done.
some example data lines in the...
|
by: Thomas Guettler |
last post by:
Hi!
If I pickle a class which inherits from dict,
I don't get the same data again, if I unpickle
it.
def test_pickle():
home="..."
server=WorkflowServer(home)
server.save()
|
by: GrelEns |
last post by:
hello,
i would like if this behaviour can be obtained from python : trap an
attributeError from inside a subclassing dict class... (here is a silly
examples to explain my question)
class...
|
by: Alexander Kervero |
last post by:
Hi ,today i was reading diveinto python book,in chapter 5 it has a very
generic module to get file information,html,mp3s ,etc.
The code of the example is here :...
|
by: David Rasmussen |
last post by:
If I have a collection of dicts like:
john = {'id': 1, 'name': "John Cleese", 'year': 1939}
graham = {'id': 2, 'name': "Graham Chapman", 'year': 1941}
I could store all of them in a list. But...
|
by: A_Republican |
last post by:
I am interested in writing my own secure file deletion program. I want to be
able to read and write to my hard drive directly. My application will seach
my hard drive for all locations marked for...
|
by: Jay Tee |
last post by:
Hi,
I have some code that does, essentially, the following:
- gather information on tens of thousands of items (in this case, jobs
running on a
compute cluster)
- store the information as a...
|
by: Seongsu Lee |
last post by:
Hi,
I have a dictionary with million keys. Each value in the
dictionary has a list with up to thousand integers.
Follow is a simple example with 5 keys.
dict = {1: ,
2: ,
900000: ,
900001:...
|
by: rewonka |
last post by:
Hello,
I'm trying to find the fastest way to convert an sql result into a
dict or list.
What i mean, for example:
my sql result:
contact_id, field_id, field_name, value
sql_result=,
,
,
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |