Live data from Hacker News

Anyprint: use any language's print statements in Python

github.com

51–60 of 76 posts

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

#51

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....

> for a language proud of getting rid of parenthesis

Er… what?

Python doesn't have braces, it has plenty of parenthesis. In fact, Python 3 added more since it upgraded several keywords to functions (not just print but also exec, and some forms of re-raising)

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

#52
post #39

Earlier quoted context omitted.

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.

Note that they say it feels more powerful, it's not like it is more powerful than the file kwarg.

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

#55
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…

> 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 the other?

I've always wondered this: would it be that bad, if you could easily guarantee that all those formats really are equivalent? (maybe by being able to check a unique identifier of the function to which the expression is going to be compiled).

In the case of this library, the semantics are simple and clear: I have a string object, and I want its contents to be poured on a predefined output device; maybe converting on-the-fly some escape characters in the string to the values of some parameters.

Provided that you don't deviate from this specified meaning, is it that bad that the language accepts any common syntax?

I understand the "being harder to recognize what it is doing", but I think that might be somewhat alleviated by the feature I said above of unambiguously resolving to a single entity in the programming language.

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

#56
post #26
post #21

Earlier quoted context omitted.

As someone most at home in lisps--there's just no accounting for taste ;)

Is there a LISP with significant white space in place of parentheses? Our two groups could be united by the disgust of the rest of the programming community.

See this: http://readable.sourceforge.net/

Works with both Scheme and Common Lisp, two most popular Lisps out there. Nobody uses it because paredit/parinfer is just too convenient, but the option is there.

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

#57
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)

If you want power you can

    fprint = lambda string: print(string, file=somefile)
and use fprint all over the place

that little chevron trick is bad imo

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

#58
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.

It gets better with chained function calls, e.g. (D-like pseudocode):

writeln(mul(add(x, 5), 30))

vs.

x.add(5).mul(30).writeln()

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

#60
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?

[deleted]
Post reply on HN