
Anyprint: use any language's print statements in Python - Sir_Cmpwn
https://github.com/kragniz/anyprint
======
simonh
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!

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

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

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

~~~
est
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)

~~~
nhumrich
> More powerful

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

~~~
wruza
I'm not going to discuss perl readability, but the fact is that I cannot
simply 0%% to beginning of the block in "readable" python. ?:$<CR> does its
job though.

------
flavio81
Let's hope they also add

    
    
        (format t "hello ~a!" name)
    

for completeness...

~~~
sbmassey
To say nothing of vitally important format expressions like

    
    
      (format t "~{~a~^, ~}" list)

~~~
stevelosh
And of course the stuff necessary for word-wrap-in-`format`:

    
    
        (format t "~{~<~%~1,40:;~A~> ~}"
          '("these" "words" "will" "be" "wrapped" "to" "40" "characters"))
    

and the other `format` insanity in:
[http://cybertiggyr.com/fmt/fmt.pdf](http://cybertiggyr.com/fmt/fmt.pdf)

~~~
flavio81
Behold the mighty power of CL format!! I wonder if the format string language,
aka "line noise", is turing complete...

------
nneonneo
Worth noting: the language's syntax must still be minimally compatible with
Python -- this isn't some sort of magic parser hack, it's just adding
functions and types with special behaviour (like having "cout" be an object
that overrides __lshift__). Now, given that many Lisp and Lisp-likes support
ridiculous parser hacks (Scheme/Racket come to mind), I bet you really could
pull off "Anyprint" in one of those languages...

------
krylon
The Testimonials section cracked me up.

~~~
rhencke
It looks like your testimonial has been added to the project, ha.

------
scardine
Makes all these valid in Python:

    
    
        printf("printf %d\n", 10);
    
        fmt.Println("hello")
    
        cout << "Hello, C++!" << endl;
    
        Print["Hello from Mathematica!"]
    
        console.log("yes");
    
        System.out.printf("java stuff\n");
    
        Ada.Text_IO.Put_Line("Ada is cool")
    
    

Really funny, including the testimonials:

> Anyprint has many glowing reviews from its many satisfied users: > > * "omg
> pls" > * "what is wrong with you" > * "That's stupid and not useful." > *
> "Please add my testimonial: "very accurate testimonials"." > * "kragniz,
> please stop writing questionable python metamodules :v"

~~~
josefx
> cout << "Hello, C++!" << endl;

For the love of god, please stop using endl. It performs a flush when "\n" is
both valid and all that you ever want.

Also what happened to the std:: prefix?

~~~
ben0x539
Are you saying you never want to flush?

If flushing after every line is good enough for printf then it's gonna be good
enough for me~

~~~
josefx
Buffering of Cs stdout is implementation defined. For Linux it is only line
buffered in an interactive terminal session and fully buffered otherwise.

> Are you saying you never want to flush?

90% of the time not. The other ten percent include asking for user input,
which causes an implicit flush since std::cin is linked to std::cout, and
debugging an ugly heisenbug.

------
laurentlb
Lovely! The idea is very similar to NoFail (
[https://github.com/laurentlb/NoFail](https://github.com/laurentlb/NoFail)), a
language I've described, but not yet implemented.

------
rhizome31
How about Ruby, Perl or the Python 2 print statements?

------
derpydev
This project is so wonderful it took down Github

------
umanwizard
Please add support for

    
    
        NSLog(@"Hello, %s and %s!", @"macOS", @"iOS");

~~~
jibberia
Warning: Format specifies type 'char _' but the argument has type 'NSString _'

~~~
umanwizard
Whoops! Should have been `%@`

------
RhysU
Is Fortan's

    
    
      WRITE(*, *)
    

doable? How to handle the * isn't jumping out at me.

------
RodgerTheGreat
Please add support for:

    
    
        `0:"Hello from K.\n"

------
krallja
Ironically, it doesn't (and can't) support Python 2 print statements.

~~~
sandwell
And by extension, QBasic's PRINT statement. 0/10.

------
bjackman
In all seriousness, it never occurred to me before that because of access to
"globals", an import statement can introduce (or alter the value of!)
unexpected names.

------
mhh__
Can I have a D style:

    
    
      "Your text here".writeln;

~~~
sdsk8
You can monkeypatch str type with:

[http://clarete.li/forbiddenfruit/?goback=.gde_50788_member_2...](http://clarete.li/forbiddenfruit/?goback=.gde_50788_member_228887816)

------
amelius
Now implement printing to a string (sprintf, etc.)

------
systems
All your testimonials are belong to us.

------
rosstex
I already sent this to my co-founder

------
Piccollo
5

------
cbanek
Now we just need a nice restrictive license to grab all the patents.

