Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
tusharsadhwani
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
9 ms
·
31.
▲
Why YOU should write a Blog – A Mini Rant
(sadh.life)
4 points
by
tusharsadhwani
5y ago
|
0 comments
32.
▲
by
tusharsadhwani
5y ago
notice the raw_input(), it's written in python 2.
33.
▲
by
tusharsadhwani
5y ago
that would be s/in//g :)
34.
▲
by
tusharsadhwani
5y ago
Yup, I'll fix this, thanks for pointing it out.
35.
▲
by
tusharsadhwani
5y ago
That's great to hear :D hopefully you'll try out Python sometime.
36.
▲
by
tusharsadhwani
5y ago
Type annotations link is fixed, thank you! Just `__add__` doesn't work for me. I get: TypeError: unsupported operand type(s) for +: 'int' and 'Number' Here's the code: class Number: def _
37.
▲
by
tusharsadhwani
5y ago
In my case I meant it as things that only extend from object. Kinda like how prime numbers only have two factors including themselves.
38.
▲
by
tusharsadhwani
5y ago
you're right, thanks!
39.
▲
by
tusharsadhwani
5y ago
Oh, I didn't know that about locals! Yeah, calling float and complex "supertypes" probably wasn't the best idea, but I couldn't think of a better explanation that wouldn't take too long to explain. I'll po
40.
▲
by
tusharsadhwani
5y ago
that is indeed interesting. Mind if I add this in the article?
41.
▲
by
tusharsadhwani
5y ago
I think linters are really effective to figure out such issues in professional code. For students for example, I'll have to agree. Maybe having a flag or environment variable that teachers can set up for it would be a nice idea. You sh
42.
▲
by
tusharsadhwani
5y ago
I was concerned if my writing style will click with people, this is good to know :)
43.
▲
by
tusharsadhwani
5y ago
I can personally recommend Fluent Python (its 2nd edition is about to come out in a couple months) for learning these intermediate/advanced concepts, and Python Cookbook for code examples using many of these features. I don't know
44.
▲
by
tusharsadhwani
5y ago
whether mutating data is better than creating a new copy for everything is a really long debate about immutability and functional programming, with good points on either sides, but that's really beyond the point here. In my opinion, yo
45.
▲
by
tusharsadhwani
5y ago
Thank you! Things like `list.append` modifying in-place might feel like a flaw to some, but I think Python is really consistent when it comes to its behaviour. If you ask a person who comes from an object-oriented world, they'll say it
46.
▲
Understanding Python through its builtins
(sadh.life)
544 points
by
tusharsadhwani
5y ago
|
173 comments
47.
▲
by
tusharsadhwani
5y ago
Shameless plug; might wanna look into zxpy :)
48.
▲
by
tusharsadhwani
5y ago
Tried it, most people end up putting vim in background with Ctrl+Z instead of closing it.
49.
▲
by
tusharsadhwani
5y ago
You might want to check out https://github.com/asottile/all-repos :)
50.
▲
by
tusharsadhwani
5y ago
Funnily this problem seems trivial when you have good test coverage for your code. Especially trivial compared to the insane amount of help you could get in writing boilerplate and simple logic from a magical tool like this, if it delivers
51.
▲
by
tusharsadhwani
5y ago
FWIW, VS Code has a "zen mode" view which hides everything other than the editor window, which kinda makes it comfortable for people coming from vim, sublime and the like. Try it out sometime.
52.
▲
by
tusharsadhwani
5y ago
The biggest reason of all would be that 3.5 is already end of life :)
53.
▲
by
tusharsadhwani
5y ago
This is all true. So true infact that I wrote a huge article documenting this for people who are new to it: https://tshr.me/mypy I'm planning to migrate this to my own blog soon.
54.
▲
by
tusharsadhwani
5y ago
Nothing as such, idk why you're implying that alternatives can't exist...
55.
▲
by
tusharsadhwani
5y ago
Thanks!
56.
▲
by
tusharsadhwani
5y ago
The approach is very different. Xonsh is a shell first, and it adds python capabilities on top (with an arguably complicated syntax). Meanwhile, zxpy is just a python script, that can seamlessly run bash commands inside it.
57.
▲
by
tusharsadhwani
5y ago
the await's were a big no-no for me, that's mostly it. having to unnecessarily write await 20 times for 20 shell commands isn't that clean imo.
58.
▲
Show HN: zxpy, a cleaner version of Google's zx
(github.com)
30 points
by
tusharsadhwani
5y ago
|
12 comments
59.
▲
by
tusharsadhwani
5y ago
Yeah, I saw this yesterday and didn't like it so I made my own cleaner version: https://github.com/tusharsadhwani/zxpy
60.
▲
by
tusharsadhwani
5y ago
Honestly, i saw the syntax and thought I can do better, so I made it: https://github.com/tusharsadhwani/zxpy
More ›