Thanks!! Dejan
On Sunday, July 19, 2015 at 4:42:00 AM UTC-7, Avik Sengupta wrote: > > Sometimes PyCall cannot infer that an object is callable, since so many in > python are (beyond simple functions). In such situations, the workaround is > to use the "pycall" function in julia directly. See the invocations > below... > > *julia> **urllib2.Request("http://google.com <http://google.com>")* > > *ERROR: type: apply: expected Function, got PyObject* > > > *julia> **urllib2.urlopen("http://google.com <http://google.com>")* > > *PyObject <addinfourl at 4660350848 whose fp = <socket._fileobject object > at 0x1168f1ed0>>* > > > *julia> **req = pycall(urllib2.Request, PyAny, "http://google.com > <http://google.com>")* > > *PyObject <urllib2.Request instance at 0x115c74d40>* > > > *julia> **f=urllib2.urlopen(req)* > > *PyObject <addinfourl at 4660402584 whose fp = <socket._fileobject object > at 0x1168f76d0>>* > > > *julia> **f[:read](100)* > > *"<!doctype html><html itemscope=\"\" > itemtype=\"http://schema.org/WebPage\ <http://schema.org/WebPage%5C>" > lang=\"en-GB\"><head><meta cont"* > > On Sunday, 19 July 2015 03:15:28 UTC+1, Dejan Miljkovic wrote: >> >> What would be the right way to execute urllib2 call in julia >> >> using PyCall >> @pyimport urllib2 as urllib2 >> request = urllib2.Request(url, json_payload, "{'Content-Type': >> 'application/json'}") >> >> type: apply: expected Function, got PyObject >> while loading In[29], in expression starting on line 1 >> >> >> >> Thanks, >> >> Dejan >> >