[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[py8] 90

"evaluation with kwargs"
| year1 year2 |
{''py'from datetime import timedelta'}.
year1 := Python call: #{timedelta} args: #() kwargs: #(
  #(days 365)
).
year2 := Python call: #{timedelta} args: #() kwargs: #(
  #(weeks 40) #(days 84) #(hours 23)
  #(minutes 50) #(seconds 600)
).
year1 = year2 ifFalse: [
  ^self error: 'Year do not match'
].
year1 total_seconds = 31536000.0 ifFalse: [
  ^self error: 'Wrong total seconds'
].
^#Ok


"API call with kwargs"
| ip |
ip := (Array @ (Python	call: #getaddrinfo
	on: Python socket handle
	args: #('swiki.smalltalking.net' 80)
	kwargs: #(#(proto 6"SocketLibrary ipprotoTcp"))
)) first last first.
(ip occurrencesOf: $.) = 3 ifFalse: [
	self error: 'Invalid IP address'
].
^#Ok