![]() |
Visual Studio Code - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Visual Studio Code (/thread-39997.html) |
Visual Studio Code - NewPi - May-16-2023 Hey, I use Visual Studio Code and the Python extension. When I hover over "random.choices(...)" it shows, that choices is a variable. I don't understand. Isn't it a function? Thank you! RE: Visual Studio Code - snippsat - May-16-2023 (May-16-2023, 09:52 PM)NewPi Wrote: I use Visual Studio Code and the Python extension.It's a method if look at source code. Why it show a variable,is that in source there is this line choices = _inst.choices So _inst.choices is the method,if hover over will return.(method) def sample( population: Any, k: Any, *, counts: Any | None = None ) -> (list | Any) Chooses k unique random elements from a population sequence. .....You can get to this code bye press Ctrl and click when hover over choices.![]() RE: Visual Studio Code - NewPi - May-16-2023 Hey, thank you. But what does choices = _inst.choicesmean? RE: Visual Studio Code - snippsat - May-16-2023 It's just name change to something easier to understand. In Source. randrange = _inst.randrange sample = _inst.sample shuffle = _inst.shuffle choices = _inst.choices ...It's similars as this,i want egg as simpler name. def _inst_egg(): return 'Some eggs' egg = _inst_egg() print(egg)
|