jayqi / spongebob

SPoNgeBOb-CAse cONveRSioN ToOLs
https://jayqi.github.io/spongebob/
27 stars 3 forks source link

spongebobcase.spongebobsay() prints two copies #29

Open jameslamb opened 4 years ago

jameslamb commented 4 years ago

I installed spongebobcase 0.4.0 from PyPi today and ran this

import spongebobcase
print(spongebobcase.spongebobsay("this is working"))

And got two spongebobs!

image

jameslamb commented 4 years ago

oh I see, I think you must be both printing AND returning. When I assign to a variable I only get one printed

image

jayqi commented 4 years ago

There is a print_ argument that controls whether it prints internally in the function. Happy to take feedback about if that seems intuitive.

https://jayqi.github.io/spongebob/py-pkg/api-reference/spongebobsay/#spongebobcase.spongebobsay.spongebobsay

It's the same way the R function works

https://jayqi.github.io/spongebob/r-pkg/reference/spongebobsay.html

R has the concept of returning invisibly but unfortunately Python does not.

jameslamb commented 4 years ago

ooooo I didn't realize! Ok my fault for not RTFM.

My expectation from using {cowsay} in the past was that I could just run this function and it would print one thing, without me needing to do any assignment.

I think that argument does what I want, but seeing it I would have expected it's default value to be False. I expect that the interactive case is a lot more common than the "return a value" case.

Anyone, that did answer my question so you can close this, thanks!

jayqi commented 4 years ago

Yeah, I mean, it's kind of tricky. I meant for the print_ argument to be there for the interactive case, and I personally do _ = spongebobsay("whatever") to suppress the returned string. In R, it both prints and returns the string the same way, but the string is just returned invisibly.