[BangPypers] Favorite tips/techniques

s|s supr.e.etsethi at gmail.com
Wed Sep 11 14:07:30 CEST 2013


There are times when the project requires a large blob of data which needs
to be loaded with the python code. A general practice is to use pickle and
json object which is opened using file functions etc.

I tend to convert this kind of data (depending on size) into python file
using pprint and store it as code included using python standard coding
convention. Saves hassle of packaging and caring about path convention. Of
course it is not correct convention for all situations.


On Wed, Sep 11, 2013 at 4:55 PM, Anand Chitipothu <anandology at gmail.com>wrote:

> Another script I use often is repr.
>
> https://github.com/anandology/hacks/blob/master/repr
>
> It reads each line from stdin and prints it as python repr. Useful to see
> hidden/non-alphanumeric characters.
>
> $ echo -e "a\bc"
> c
> $ echo -e "a\bc" | repr
> a\x08c\n
>
> This is similar to od, but od prints fixed number of characters in each
> line and sometimes you want to see the lines without breaking.
>
> Couple of hours back, I noticed an issue with a row in a mysql dump, and
> here is how I used it to inspect at that row.
>
> $ head -28130 my-table.txt | tail -1 | repr
> 2006-05-25 00:19:12\t\t1900-01-01 00:00:00\t0000\tMetal1\t
>
> Anand
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>



-- 
Supreet Sethi
Ph UK: +447859172473
Ph IN: +919811143517
Ph Skype: d_j_i_n_n
Profile: http://www.google.com/profiles/supreet.sethi
Twt: http://twitter.com/djinn


More information about the BangPypers mailing list