Currently I came across the code that returned 9 values (return statement
spanned 5 lines due to pep8 limitation of 79 characters per line)
The function returns various values that are used by the template to render
HTML
To give you an idea - consider following two code snippets :
(This is just
Write code which is readable and then put in effort to speed things
up, if need be.
The Code 1 is definitely confusing. Why don't you create a class
and fill up the member variables. Much more readable.
There is a dis module which allows you to dump assembly code. You can
check how many
On Fri, May 23 2014, Rohit Chormale wrote:
How is it if you use DataContainer class set attributes of that class.
Something like,
class Data(object):
def __init__(self, **kwargs):
object.__setattr__(self, 'attribs', kwargs)
def __getattr__(self, item):
if item in
On Fri, May 23 2014, Mandar Vaze / मंदार वझे wrote:
Currently I came across the code that returned 9 values (return statement
spanned 5 lines due to pep8 limitation of 79 characters per line)
The function returns various values that are used by the template to render
HTML
To give you an
You can use namedtuple.
from collections import namedtuple
Person = namedtuple('Person', ['foo', 'bar', 'baz'])
p = Person(foo='foo', bar='bar', baz='baz')
print p.foo
'foo'
On Fri, May 23, 2014 at 1:23 PM, Noufal Ibrahim KV
nou...@nibrahim.net.inwrote:
On Fri, May 23 2014, Rohit Chormale
On Fri, May 23 2014, kracekumar ramaraju wrote:
You can use namedtuple.
from collections import namedtuple
Person = namedtuple('Person', ['foo', 'bar', 'baz'])
p = Person(foo='foo', bar='bar', baz='baz')
[...]
Much better although with namedtuple, the attributes are fixed aren't
they? I
Yes. Attributes are fixed. The advantage over dictionary is ease of access
like p.foo rather than p['foo'] or p.get('foo').
On Fri, May 23, 2014 at 1:34 PM, Noufal Ibrahim KV
nou...@nibrahim.net.inwrote:
On Fri, May 23 2014, kracekumar ramaraju wrote:
You can use namedtuple.
from
R u sure @ 'ease of access' or is it 'ease of writing'?
On Fri, May 23, 2014 at 1:43 PM, kracekumar ramaraju
kracethekingma...@gmail.com wrote:
Yes. Attributes are fixed. The advantage over dictionary is ease of access
like p.foo rather than p['foo'] or p.get('foo').
On Fri, May 23, 2014
Rohit
Probably ease of writing may be right here.
On Fri, May 23, 2014 at 1:46 PM, Rohit Chormale rohitchorm...@gmail.comwrote:
R u sure @ 'ease of access' or is it 'ease of writing'?
On Fri, May 23, 2014 at 1:43 PM, kracekumar ramaraju
kracethekingma...@gmail.com wrote:
Yes.
On Fri, May 23 2014, kracekumar ramaraju wrote:
Rohit
Probably ease of writing may be right here.
It's also more future proof. An attribute can be replaced by a property
which implements access controls and other things without breaking API
contracts. It's harder to do that while
Mandar Vaze / मंदार वझे mandarv...@gmail.com writes:
Code 1:
...
return dict(fname=fname, lname=lname, saluation=salutation,
gender=gender, addr1=addr1, addr2=addr2,
city=city, state=state, country=country)
First of all, both functions are returning a single value, a
On Fri, May 23, 2014 at 5:26 PM, Navin Kabra na...@smriti.com wrote:
Mandar Vaze / मंदार वझे mandarv...@gmail.com writes:
Code 1:
...
return dict(fname=fname, lname=lname, saluation=salutation,
gender=gender, addr1=addr1, addr2=addr2,
city=city, state=state,
12 matches
Mail list logo