Alex Amato
Alex Amato

Reputation: 1591

Good way to generate GUIDs on app engine?

I was wondering if anyone knows of a good way to generate GUIDs on python google app engine. I feel like there is a simple way that people are using, what would you suggest.

Upvotes: 8

Views: 3218

Answers (5)

andruso
andruso

Reputation: 1995

import uuid

print(uuid.uuid4().hex)

Upvotes: 1

Aaron D
Aaron D

Reputation: 5886

Code example using the uuid module:

from uuid import uuid4

print(uuid4())

# Output: 7d720c5a-b3e9-455e-961c-0e37b330b098

Upvotes: 5

Bob Aman
Bob Aman

Reputation: 33249

The uuid module should be available.

Why do you need uuids? Usually they're necessary to make really unique primary keys, but GAE's datastore essentially ought to be taking care of that for you.

Upvotes: 5

Marc Hughes
Marc Hughes

Reputation: 5858

Any chance they are guid's for things you're storing in the datastore?

If so, I believe object.key is a GUID

Upvotes: 0

Grant Limberg
Grant Limberg

Reputation: 21393

Assuming the module is available in Google App Engine, check out Python's uuid module.

Upvotes: 0

Related Questions