Hey,
It is much more clean to write *session.var* than *session['var']* when I 
can, as well as *if session.var* instead of *if hasattr(session, 'var')*, 
and I would like to use this style of coding generally in python, if it can 
remain pythonic.

I've been looking into using classes to store values, just like for example 
session does in web2py. I found on stack overflow that it might not be 
pythonic, it is not recommended by some experienced programmers. After 
trying many ways to do this, none of the ways I tried created classes with 
instances. In other words, if I would make two instances of my class they 
would share attribute values. Setting *myobject2.var* would also set 
*myobject.var* to the same value.

Now in web2py these objects (session, request.vars) are used as predefined 
instances -- they are not normally used for making your own instances. This 
way they could be their own type of class (I didn't look into it). Perhaps 
this keeps things pythonic, or did you web2py developers find a pythonic 
and sustainable way to create your own dict objects?

Ps. Even though I could think of ways to deal with the issue of shared 
attributes, I wouldn't really like to write a new class, as there are many 
cases which need to be handled.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to