What use is of this 'cast=float ,'?

edmondo.giovannozzi at gmail.com edmondo.giovannozzi at gmail.com
Fri Oct 27 17:32:09 EDT 2017


Il giorno venerdì 27 ottobre 2017 22:35:45 UTC+2, Robert ha scritto:
> Hi,
> 
> I read below code snippet on line. I am interested in the second of the last 
> line.
> 
>      cast=float ,
> 
> 
> I've tried it in Python. Even simply with 
> 
> float
> 
> 
> it has no error, but what use is it?
> 
> 
> I do see a space before the comma ','. Is it a typo or not?
> 
> 
> Thanks,
> 
> 
> 
> self.freqslider=forms.slider(
>      parent=self.GetWin( ),
>      sizer=freqsizer,
>      value=self.freq,
>      callback= self.setfreq,
>      minimum=−samprate/2,
>      maximum=samprate/2,
>      num_steps=100,
>      style=wx.SL_HORIZONTAL,
>      cast=float ,
>      proportion=1,
> )

cast is the name of keyword argument of the function slider called "cast". It likely means that it should return a float. Quite likely inside the function "slider" there will be something like 

return cast(...)

that if you pass float will become equivalent to

return float(...)

Of course I don't know that function so take it as just a likely possibility.

By the way, it can be a method of an object named forms or a function in a module named forms.

cheers,



More information about the Python-list mailing list