Got it, what I need was json.dumps. Sorry I posted too early.
Thanks.
On Tue, Aug 18, 2009 at 11:50 AM, Kent Johnson wrote:
> On Mon, Aug 17, 2009 at 11:02 PM, Vincent
> Gulinao wrote:
>> I see you could pipe your output to 'python -mjson.tool', but how do I
>> achie
I see you could pipe your output to 'python -mjson.tool', but how do I
achieve the same within my script?
TIA.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I see, I think "property" is what I'm looking for.
But how would you design it yourself (you said it's a little ugly, I love to
hear better ideas)? My only concern is to avoid unnecessary DB accesses (or
any other expensive processes).
Thanks.
On 8/16/07, Tiger12506 <[EMAIL PROTECTED]> wrote:
>
gailer <[EMAIL PROTECTED]> wrote:
>
> Vincent Gulinao wrote:
> >
> > Sorry, I just started experimenting on Python classes...
> >
> > Is there any way a reference to a class attribute
> > ([class].[attribute]) be treated like a method ([class].[method]())?
Sorry, I just started experimenting on Python classes...
Is there any way a reference to a class attribute ([class].[attribute]) be
treated like a method ([class].[method]())?
I have a class with DB component. Some of its attributes are derived from DB
and I find it impractical to derive all at o
Anyone knows a neat way of displaying
output in columnar/tabular form?
Say you have a list with both
dictionary and string members; you want to print the data, dictionary
being one element per line, and the string on the next "column"
aligned on the first element of the dictionary
I have a list of lists of constant width (2 rows). I need to:
1. delete sub-lists with None element
2. sort it by any sub-list index
say: [ ['c','d'], ['g',None], ['a','b',], ['e','f']
if sorted using 2nd index: [ ['a','b'], ['c','d'], ['e','f'] ] (same result for 1st index for this example)
TIA
is there any simple syntax for joining strings such that if any (or
all) of the params is white space or None, it won't be included in the
resulting string?
e.g. str1, str2, str3 = "foo", "bar", None, if delimiter is " " would
result to "foo bar"; str1, str2 = None, None would result to None.
TIA
I was fascinated when I learned that I can do this in Python:
(str1, str2, str3, rest) = str.split(" ", 3)
Later that I realize that str could contain values of less than 4
strings, in which case it would complain something like -- ValueError:
unpack list of wrong size.
Now I don't want to