I'm still learning python, so have to ask about how this would be
done.  Something like the following?

try:
  self.id
except NameError:
  # run this code if it is a new item
else:
  # run this code if this is a previously saved item

More generally, what do you think of this statement:  "If there are
any cases where you don't absolutely know if a variable is defined,
you have a broken design."
That's at 
http://stackoverflow.com/questions/1592565/determine-if-variable-is-defined-in-python/1592578#1592578
I've worked on many scripts where it wasn't possible to know if a
variable is defined, so I'm surprised to see someone vehemently argue
that this should never happen.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to