[{"data":1,"prerenderedAt":325},["ShallowReactive",2],{"project-8158976":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":35,"aspects":36,"strip":42,"post_text":45,"what":46,"said":66,"maker_in_thread":171,"shape":178,"grid":182,"attempts":284,"same_week":289,"maker_shows":44,"maker_hidden":317,"reader_version":318,"card":319},"8158976","Pythonpy","the swiss army knife of the command line","title","Show HN: Pythonpy – the swiss army knife of the command line","https:\u002F\u002Fgithub.com\u002FRussell91\u002Fpythonpy","github.com","Russell91",1407649651,2014,220,42,83,2272,4,"notable","dev_tools","command line utility","cli",[24,25,26,27,28],"python","command line","pipes","stdin","unix shell","debated",-0.018,{"positive":32,"neutral":33,"mixed":34,"critical":32},6,8,0,20,{"idea":37,"performance":39,"execution":40},{"positive":18,"critical":38},3,{"positive":34,"critical":34},{"positive":41,"critical":38},2,[43,34,38,34,43,34,34,34,34,34,34,34,43,44,38,34,43,43,34,38,38,44,34,34,34,34,44,44,34,44,34,34,34,43,44,38,34,38,38,34],5,1,null,{"problem":47,"audience":45,"pricing":45,"motivation":45,"time_to_build":45,"stack":58,"openness":63,"stage":64,"team_size":65},{"value":48,"source":49,"evidence":50},"Doing line-by-line transforms and aggregations on command-line pipe input using Python","inferred",[51,54],{"id":52,"by":11,"text":53},"8161005","Yea, fortunately pythonpy supports lazy iteration over sys.stdin when you really need it. Just like in python, the syntax won't be as nice as using a list. But it works: ``` py…",{"id":55,"by":56,"text":57},"8159706","S4M","I like it! Now I can count the number of files I have in a directory: ``` ls |py -l 'sum(1 for x in l)' ``` And also I can count the number of files whose names matche a certain…",[59],{"value":60,"source":49,"evidence":61},"Python",[62],{"id":52,"by":11,"text":53},"open_source","launched","unknown",{"praise":67,"objections":81,"requests":113,"questions":125,"alternatives":130},[68],{"value":69,"source":70,"evidence":71},"Useful for quick Python one-liners on pipes","commenter",[72,76,77],{"id":73,"by":74,"text":75},"8159038","d0m","Looks so useful, can't believe I never thought of hacking something to do that. Will experiment with it!",{"id":55,"by":56,"text":57},{"id":78,"by":79,"text":80},"8160148","Lambdanaut","I usually use Python(or another lang's interpreter) as my calculator, so this will save me a few keystrokes in the future. I think I'll still use short scripts rather than the…",[82,92,103],{"value":83,"source":70,"evidence":84},"Does not work on Windows due to Unix-only calls",[85,89],{"id":86,"by":87,"text":88},"8161506","cohomologo","I attempted to install on Windows - it doesn't work due to the lack of os.geteuid(), which is called in the setup.py file to check for root. With a little bit of finagling I…",{"id":90,"by":11,"text":91},"8161870","Yea, sorry about that. I had an initiative to make a windows version, wpy, a little after launch, but couldn't really get any windows developers interested in making it happen.…",{"value":93,"source":70,"evidence":94},"Shell tools like wc, awk and grep already do this",[95,99],{"id":96,"by":97,"text":98},"8159798","mitchty","You'll probably want to learn the regular unix way as well. Tools like this are nice, but you're already 99% there as it is for most things. ``` ls | wc -l ls | grep -c .py ```…",{"id":100,"by":101,"text":102},"8161927","mgr86","Honest question. Why would I want to use this? I am already quite happy with awk,sed,grep, etc.",{"value":104,"source":70,"evidence":105},"Example using shell mv was risky",[106,110],{"id":107,"by":108,"text":109},"8159160","Qantourisc","ls | py -x '\"mv %s %s.txt\" % (x,x)' | sh has me worried, I can't find the escape code directly. Also you might wish to offer the following api ls | py -X '[\"mv\",\"%s\",\"%s.txt\"]…",{"id":111,"by":11,"text":112},"8160922","Hmm, I just added this example yesterday, and it seems to be highly contested, so I'll exchange it for something less controversial. That being said, if you're concerned about…",[114,118],{"value":115,"source":70,"evidence":116},"Document Windows incompatibility",[117],{"id":86,"by":87,"text":88},{"value":119,"source":70,"evidence":120},"Support multi-statement one-liners",[121],{"id":122,"by":123,"text":124},"8162865","Grue3","Would've been more useful with a language that doesn't limit one-liners (e.g. you can't have \"for x in [1,2,3]: dothing1(x); dothing2(x)\").",[126],{"value":127,"source":70,"evidence":128},"Why use this over awk, sed and grep",[129],{"id":100,"by":101,"text":102},[131,138,145,152,164],{"value":132,"source":70,"evidence":133},"PyP from Sony Imageworks",[134],{"id":135,"by":136,"text":137},"8159115","ctrijueque","Nice. Similar to PyP from Sony Imageworks: http:\u002F\u002Fopensource.imageworks.com\u002F?p=pyp The Pyed Piper Tutorial: http:\u002F\u002Fwww.youtube.com\u002Fwatch?v=eWtVWF0JSJA",{"value":139,"source":70,"evidence":140},"piep",[141],{"id":142,"by":143,"text":144},"8160919","gfxmonk","I wrote a similar tool a while back: http:\u002F\u002Fgfxmonk.net\u002Fdist\u002Fdoc\u002Fpiep\u002F Mostly out of frustration for PyP not being lazy (on large inputs it reads the entire file up-front, or at…",{"value":146,"source":70,"evidence":147},"e (pypi)",[148],{"id":149,"by":150,"text":151},"8159207","kseistrup","A simpler version of py is e ⌘ https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fe\u002F1.4.5",{"value":153,"source":70,"evidence":154},"Standard unix tools wc, awk, grep",[155,159,163],{"id":156,"by":157,"text":158},"8159774","foob","For reference, you can do this using the wc core utility. The -l option makes it count the number of lines so 'wc -l' will do the same thing as your sum expression.",{"id":160,"by":161,"text":162},"8159777","alco","'wc -l' counts the number of lines. It also supports '-c' and '-b'. To work with input split into columns, use awk. By default, it assumes the columns are separated with spaces.…",{"id":96,"by":97,"text":98},{"value":165,"source":70,"evidence":166},"pru for Ruby",[167],{"id":168,"by":169,"text":170},"8161859","__debug__","Check out https:\u002F\u002Fgithub.com\u002Fgrosser\u002Fpru",{"comments":18,"answered":34,"key":172},[173,174,175],{"id":52,"text":53},{"id":111,"text":112},{"id":176,"text":177},"8160930","Yea, IMO the best way to do this with pythonpy is: ``` py -l 'len(l)' ``` That being said, I still use wc -l every time. In fact, I always prefer regular unix commands (e.g.…",{"commenters":179,"max_depth":18,"maker_replies":18,"first_comment_mins":180,"lifespan_hours":181},32,46,30,[183,185,189,191,193,196,200,203,206,209,213,216,219,222,224,226,227,228,229,232,234,235,238,240,243,245,248,249,250,252,253,256,259,262,264,266,268,272,274,276,280,283],[135,34,43,184,136,34],"project\u002Fpositive\u002Fidea",[186,34,34,187,188,34],"8160590","other\u002Fneutral\u002Fnone","vram22",[142,34,38,190,143,34],"project\u002Fneutral\u002Fperformance",[52,34,34,192,11,44],"project\u002Fneutral\u002Fexecution",[194,34,43,195,143,34],"8161405","project\u002Fpositive\u002Fexecution",[197,44,34,198,199,34],"8159282","other\u002Fneutral\u002Fpricing","k_os",[201,44,34,198,202,34],"8159421","thejosh",[204,44,34,198,205,34],"8160061","canistr",[207,44,34,198,208,34],"8161439","whit537",[210,44,34,211,212,34],"8159569","other\u002Fneutral\u002Fidea","easytiger",[214,44,34,187,215,34],"8159589","afarrell",[217,44,34,187,218,34],"8160104","ams6110",[220,41,43,184,221,34],"8159199","zokier",[107,38,44,223,108,34],"project\u002Fcritical\u002Fexecution",[225,38,38,192,221,34],"8159396",[111,38,34,192,11,44],[73,18,43,184,74,34],[55,43,43,195,56,34],[230,43,34,187,231,34],"8159771","chmielewski",[156,43,38,233,157,34],"project\u002Fneutral\u002Fidea",[160,43,38,233,161,34],[236,43,38,192,237,34],"8159779","Denvercoder9",[96,43,44,239,97,34],"project\u002Fcritical\u002Fidea",[241,43,34,242,56,34],"8160109","commenter\u002Fneutral\u002Fnone",[244,43,34,242,97,34],"8160340",[246,43,34,247,188,34],"8160614","commenter\u002Fneutral\u002Fexecution",[176,43,34,192,11,44],[149,32,44,239,150,34],[86,251,44,223,87,34],7,[90,251,34,192,11,44],[254,33,44,239,255,34],"8159348","arno_v",[257,33,34,242,258,34],"8159430","n0body",[260,33,34,242,261,34],"8159626","Demiurge",[263,33,34,242,258,34],"8160199",[78,265,43,184,79,34],9,[122,267,44,223,123,34],10,[269,270,38,233,271,34],"8160280",11,"leichtgewicht",[273,270,34,187,169,34],"8161857",[100,275,38,233,101,34],12,[277,278,38,233,279,34],"8159295",13,"fsiefken",[281,278,34,242,282,34],"8159584","judofyr",[168,278,34,187,169,34],[285,288],{"id":286,"t":287,"points":41,"comments":34},"7990941",1404531402,{"id":4,"t":12,"points":14,"comments":15},[290,295,299,303,308,312],{"id":291,"name":292,"points":293,"category":294},"8173934","Remember Win",455,"productivity",{"id":296,"name":297,"points":298,"category":294},"8173170","92five app",135,{"id":300,"name":301,"points":302,"category":294},"8173179","Opp.io",133,{"id":304,"name":305,"points":306,"category":307},"8175019","Startuplister",101,"web_saas",{"id":309,"name":310,"points":311,"category":294},"8152649","HN-beautify",91,{"id":313,"name":314,"points":315,"category":316},"8161604","Cloud9trader",88,"finance_crypto",false,"v2",{"id":320,"name":5,"line":6,"ai":317,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":321,"top":18,"kw":322,"maker":11,"domain":10,"tier":19,"attempts":41,"strip":323,"url":9,"mix":324,"praise":69,"objection":83,"sub":21},8158976,-0.02,[24,25,26,27,28],"5030500000005130550331000011010005130330",[32,33,34,32],1794036521168]