Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush things when printing with Python's print method #79

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions scalapy-native/src/main/scala/coursier/echo/Scalapy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ object Scalapy {
def main(args: Array[String]): Unit = {
py.local {
val args0 = args.toSeq.map(x => x: py.Any)
// What we really want to do is:
// Getting "applyDynamic does not support passing a vararg parameter" with
// py.Dynamic.global.print(args0: _*)
// but getting "applyDynamic does not support passing a vararg parameter"
CPythonInterpreter.callGlobal(
"print",
args0.map(Helper.scalapyValue),
Seq()
)
// Using @kiendang's suggestion instead (https://gitter.im/shadaj/scalapy?at=6324a9ef72ad51741fe3afb5)
py.Dynamic.global.applyDynamicNamed("print")(args0.map("" -> _) ++ Seq("flush" -> py.Any.from(true)): _*)

()
}
Expand Down
10 changes: 3 additions & 7 deletions scalapy/src/main/scala/coursier/echo/Scalapy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import me.shadaj.scalapy.py
object Scalapy {
def main(args: Array[String]): Unit = {
val args0 = args.toSeq.map(x => x: py.Any)
// What we really want to do is:
// Getting "applyDynamic does not support passing a vararg parameter" with
// py.Dynamic.global.print(args0: _*)
// but getting "applyDynamic does not support passing a vararg parameter"
CPythonInterpreter.callGlobal(
"print",
args0.map(Helper.scalapyValue),
Seq()
)
// Using @kiendang's suggestion instead (https://gitter.im/shadaj/scalapy?at=6324a9ef72ad51741fe3afb5)
py.Dynamic.global.applyDynamicNamed("print")(args0.map("" -> _) ++ Seq("flush" -> py.Any.from(true)): _*)
}
}