[BangPypers] Favorite tips/techniques
BibhasD
me at bibhas.in
Tue Sep 10 12:52:26 CEST 2013
On Tuesday 10 September 2013 04:16 PM, Saju M wrote:
> echo '{"name": "Bangpypers", "location": "Bangalore"}' | python -m json.tool
>
> In this command, what is this "json.tool" ?
>
> I could not find "tool" in dir(json)
>
>>>> import json
>>>> dir(json)
> ['JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__',
> '__doc__', '__file__', '__name__', '__package__', '__path__',
> '__version__', '_default_decoder', '_default_encoder', 'decoder', 'dump',
> 'dumps', 'encoder', 'load', 'loads', 'scanner']
import json.tool
print json.tool.__doc__
Command-line tool to validate and pretty-print JSON
Usage::
$ echo '{"json":"obj"}' | python -m json.tool
{
"json": "obj"
}
$ echo '{ 1.2:3.4}' | python -m json.tool
Expecting property name enclosed in double quotes: line 1 column 3 (char
2)
>
>
> Regards
> Saju Madhavan
> +91 09535134654
>
>
> On Tue, Sep 10, 2013 at 3:39 PM, Vineet Naik <naikvin at gmail.com> wrote:
>
>> Command line json formatter
>> $ echo '{"name": "Bangpypers", "location": "Bangalore"}' | python -m
>> json.tool
>>
>>
>> On Tue, Sep 10, 2013 at 3:28 PM, Noufal Ibrahim <noufal at nibrahim.net.in
>>> wrote:
>>> "Me at Bibhas" <me at bibhas.in> writes:
>>>
>>>> Don't know if I can call it a snippet, But this command on terminal -
>>>>
>>>> $ python -m SimpleHTTPServer 8080
>>> Similar but less well known.
>>>
>>> Command line ftp client (similar to ftp(1))
>>> python -m ftplib ftp.gnu.org
>>>
>>> Command line mail client (similar to mail(1)) but needs a local MTA
>>> running
>>> python -m smtplib
>>>
>>> Command line IMAP client (similar mutt -f imap://...)
>>> python -m imaplib -d5 noufal at imap.gmail.com
>>>
>>> Command line POP client
>>> python -m poplib pop.gmail.com
>>>
>>> There are probably others too.
>>>
>>>
>>> [...]
>>>
>>>
>>> --
>>> Cordially,
>>> Noufal
>>> http://nibrahim.net.in
>>> _______________________________________________
>>> BangPypers mailing list
>>> BangPypers at python.org
>>> https://mail.python.org/mailman/listinfo/bangpypers
>>>
>>
>>
>> --
>> Vineet Naik
>> _______________________________________________
>> BangPypers mailing list
>> BangPypers at python.org
>> https://mail.python.org/mailman/listinfo/bangpypers
>>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> https://mail.python.org/mailman/listinfo/bangpypers
More information about the BangPypers
mailing list