Live data from Hacker News

Anyprint: use any language's print statements in Python

github.com

41–50 of 76 posts

Re: Anyprint: use any language's print statements in Python

#42
post #23

Earlier quoted context omitted.

Perhaps you'd enjoy Nim which supports both. echo "hello world" echo("hello world") and as a bonus, also the following: "hello world".echo

I'm a primarily Python dev, have been for a long time. Lately I've been working in Javascript/typescript and there is no worse antifeature than having 3 different ways of doing the same thing. You try to figure out how to do something, you see 3 different solutions and you ask yourself, what's the difference? What's more correct? Will I need one over the other? Are they compatible? Is one way better supported than th…

> [T]here is no worse antifeature than having 3 different ways of doing the same thing.

Ironically, this is touted as a strength of Powershell. Speaking of which, this code supports none of Powershell's Write-Host variants.

Re: Anyprint: use any language's print statements in Python

#43
post #6

Why stop at print statements? After all if you find yourself successfully using the print statement from some other language, you might accidentally also use its if, for loop, file handling and class declaration constructs among many others. Who's looking out for those people? This is just the beginning!

Coming from Powershell, nobody told me JavaScript copies arrays by reference instead of by value. Why would anyone want to pass a reference?

Re: Anyprint: use any language's print statements in Python

#45
post #23

Earlier quoted context omitted.

Perhaps you'd enjoy Nim which supports both. echo "hello world" echo("hello world") and as a bonus, also the following: "hello world".echo

I'm a primarily Python dev, have been for a long time. Lately I've been working in Javascript/typescript and there is no worse antifeature than having 3 different ways of doing the same thing. You try to figure out how to do something, you see 3 different solutions and you ask yourself, what's the difference? What's more correct? Will I need one over the other? Are they compatible? Is one way better supported than th…

Python 3 now has 3 similar-but-different way to format strings. Python is definitely heading down a bad path.

Re: Anyprint: use any language's print statements in Python

#46
post #39

Ironically, what I miss most from Python is Python2's print, which for a language proud of getting rid of parenthesis, that is very contradictory....

print chevron in python2 is super awesome print 'hello' f = open(file, 'w') print>>f, 'world' It just feels more "powerful" than Py3k's print(somestring, file=someopenfile)

> More powerful

But less obvious and readable, which is anti pythonic. If you want "power" over readability, there is ruby/perl.

Re: Anyprint: use any language's print statements in Python

#47
post #6

Why stop at print statements? After all if you find yourself successfully using the print statement from some other language, you might accidentally also use its if, for loop, file handling and class declaration constructs among many others. Who's looking out for those people? This is just the beginning!

Coming from Powershell, nobody told me JavaScript copies arrays by reference instead of by value. Why would anyone want to pass a reference?

In Object Oriented Programming it can be useful if you want to pass the reference as the argument instead of the value.

Re: Anyprint: use any language's print statements in Python

#48
post #31
post #23

Earlier quoted context omitted.

Perhaps you'd enjoy Nim which supports both. echo "hello world" echo("hello world") and as a bonus, also the following: "hello world".echo

>"hello world".echo Okay I have to admit I love this one.

UFCS.

Also found in D.

And, frustratingly, did not get past the C++ committee.

Re: Anyprint: use any language's print statements in Python

#49
post #48
post #31

Earlier quoted context omitted.

>"hello world".echo Okay I have to admit I love this one.

UFCS. Also found in D. And, frustratingly, did not get past the C++ committee.

Name resolution is already so insanely complicated in C++ it's hard for me to lament this too much.

Re: Anyprint: use any language's print statements in Python

#50
post #39

Ironically, what I miss most from Python is Python2's print, which for a language proud of getting rid of parenthesis, that is very contradictory....

print chevron in python2 is super awesome print 'hello' f = open(file, 'w') print>>f, 'world' It just feels more "powerful" than Py3k's print(somestring, file=someopenfile)

> print chevron in python2 is super awesome

Print chevron is super awful, it's unreadable, hard to remember and difficult to search for.

The print function was a welcome improvement: it's not a statement (so can be used in a lambda, no need to fall back to sys.stdout.write), it doesn't use weird-ass syntax to redirect or suppress the final newline and it's more extensible (e.g. "end" or "flush" kwargs would have been… challenging to add to the keyword version)

Post reply on HN