Q:

When do undeclared objects get ids?

Theory question
Every Python shell has objects that can be used without being declared or created, such as True, False, "", [], {}, and any combination of integers and floating point numbers.
This means that at any point, you can get their ids.
id(1)
id(42)
id('')

etc.
Of course, if you try to get the id of an undeclared object, you get:
id(myobject1)

Traceback (most recent call last):
  File "<pyshell#29>", line 1, in <module>
    id(myobject1)
NameError: name 'myobject1' is not defined

Since myobject1 points to nothing, it's not defined, and has no id.
Yet, there are an infinite number of objects which could be used without declaration, because the number system is infinite. Thus it would be impossible for all of the undeclared objects to have id's prior to being used in some capacity in the program.
When do these objects get assigned ids?

A:

You are misunderstanding the concept of assignment.
On an assignment, you bind a object to a name. All names which are assigned to can be used in any way that is wanted, unassigned names don't exist and thus cannot point to anything (including "nowhere").
With id(spam) you ask for the object which spampoints to and then ask for its ID.
A non-existing name spam has no object assigned to it whose ID could be queried.
OTOH, every object has an ID.

