Skip to content

Commit

Permalink
Flush things when printing with Python's print method (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Sep 21, 2022
1 parent c15fa8a commit deb559d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
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)): _*)
}
}

0 comments on commit deb559d

Please sign in to comment.