1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klemol [59]
3 years ago
9

You are utilizing the pickle.load function to load objects into a program from a file. However, your program raises an exception

as soon as the end of the file is reached. What must you do?
Social Studies
1 answer:
lesantik [10]3 years ago
6 0

Answer:

When the program raises an exception as soon as the end of the is reached, this exception makes the input process difficult. We have no specific or clear way to encounter the end of the file before the exception is raised.

So to resolve this Python's try except statement can be used. This statement catches the exception and enables the program to recover. We can construct an input file loop. This loop will keep loading objects until the end of the file is detected. Below is an example to load objects from the file into a new list.

lst=list()

fileObj = open("item.dat","rb")

while True:

try:

      item= pickle.load(fileObj)

      lst.append(item)

      except EOFError:

               fileObj.close()

               break

print(lst)

The file name is item.dat and new list is named as lst. When the end of the file is encountered EOFError is raised and except clause with EOFError closes the input file and breaks out of the loop.

You might be interested in
Which behavior therapy technique is correctly matched to its description?
kakasveta [241]
Idk Bit I do knoe that the dept will and can call you down
3 0
3 years ago
what does john green mean when he says But the emergence of the Civil Rights Movement shows us that the picture of consensus in
Shalnov [3]

Answer:

He meant that at that time the consensus on the rights and duties of society was selective and that it did not cover all American citizens.

Explanation:

John Green is reporting that the need and the emergence of the civil rights movement shows that the American concept and consensus on citizenship, rights, duties, civil liberties and respect were at odds with what America preaches. These factors were offered to the population selectively, leaving part of the population deprived of all of them and suffering for not being able to use any political force to help them, because they were considered by the powerful to be inferior and unworthy.

3 0
3 years ago
A researcher states that "anxiety decreases performance irrespective of the participants' motivation levels." this means that th
WINSTONCH [101]
<span>This means that there is "a main effect of  anxiety".
</span>
Anxiety refers to a general term for a few issue that reason dread, fear, nervousness and stressing. 
These disorders influence how we feel and carry on and can cause physical side effects. Mild anxiety is unclear and disrupting, while extreme can genuinely influence everyday living.
7 0
3 years ago
If Claire does not make any payments, how much will she owe after ten years?
DIA [1.3K]
Ten times more than before
4 0
3 years ago
Read 2 more answers
What are the dangers of optimism or, conversely, of skepticism? How do you see these two theories operating in Candide?
zhenek [66]

Answer:

The danger of optimism is to see things in a way they are not. It is dangerous because t can't fool someone into thinking things are working out when they are not.

Skepticism can lead to apathy. When a person does not believe in what other people say they cannot relate to one and other. A extreme skeptical postition would lead no a very difficult way of leaving.

Candice at first sustained a very optimistic position, and after all the tragedes he started being skeptcical to the optmisitc position. This allowed her to questioned what he believed before.

Explanation:

Candide is an example of an optimistic person. A lot of terrible things happened to him and to his loved ones, and despite that, he still believed things are good. Loosing his friends and being beat up among other things. He wanted to believe in Pantagon's theory of optimism and he did, until he couldn't any more.

After some time in the plot, reason comes to him and he thinks of optimism as a mania of seening good when things are actually pretty bad.

Candice is a innocent and naive person, his optimism made him like this. An extreme optimistic position can lead to a naive postition in life.

8 0
3 years ago
Other questions:
  • In the Competency Based Leadership Model, Bennis suggests four actions or behaviors successful leaders employ. They are creating
    6·1 answer
  • Three locations where new Greek colonies began:
    9·1 answer
  • Who authorized the atomic bomb to be dropped on Japan?
    14·2 answers
  • In its early years, psychology focused on the study of ________, but from the 1920s into the 1960s, american psychologists empha
    15·1 answer
  • Which of the following ancient Roman structures was built as a place of worship?
    14·1 answer
  • Why is a democracy considered the most inefficient form of government?
    6·1 answer
  • Select all that apply. at hazeroth, god's anger was kindled against _____ and _____ because they murmured against moses. the pri
    14·1 answer
  • Your roommate argues that businesses should focus on the pursuit of profits. Your roommate is prescribing to which view of corpo
    6·1 answer
  • give me the most interesting best facts about ancient Greece dice for a BRAINLY (MAKE SURE YOU MAKE IT EXCITING AND INTERESTING
    5·1 answer
  • 2. Define Secularism.​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!