Python Forum
Parenthesis in User-Defined Functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parenthesis in User-Defined Functions
#3
data = generate_data(100, np.random.uniform)
Here the function np.random.uniform is given as a parameter to the function
and inside the function the according argument name generator_type can be used to call the function by adding ()
data = generate_data(100, np.random.uniform())
Here you are CALLING the function np.random.uniform once and that call returns a random value
and that value is passed as a parameter to the function and then assigned to e and then to the ϵ_values list.
So your 2nd code snippet runs but all values are the same.
Reply


Messages In This Thread
RE: Parenthesis in User-Defined Functions - by ThomasL - Aug-07-2019, 12:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  User-defined function to reset variables? Mark17 3 1,662 May-25-2022, 07:22 PM
Last Post: Gribouillis
  Multiple user defined plots with secondary axes using for loop maltp 1 1,466 Apr-30-2022, 10:19 AM
Last Post: maltp
  Definitions in User-Created Functions and For Loops new_coder_231013 6 2,114 Dec-29-2021, 05:51 AM
Last Post: ndc85430
  Why built in functions are defined as class? quazirfan 5 2,838 Oct-23-2021, 01:20 PM
Last Post: Gribouillis
  Why does Python not use parenthesis to contain loops? davidorlow 3 3,495 Jun-09-2021, 06:33 AM
Last Post: Gribouillis
  Running scripts and location of saved interpreted user-defined classes and functions leodavinci1990 3 2,544 Aug-25-2020, 03:43 AM
Last Post: micseydel
  User functions don't work: Baldev10 7 3,188 Aug-18-2020, 08:34 PM
Last Post: deanhystad
  python library not defined in user defined function johnEmScott 2 3,885 May-30-2020, 04:14 AM
Last Post: DT2000
  Problem with user defined main menu function stefzeer 3 2,414 Mar-27-2020, 06:12 AM
Last Post: buran
  User defined functions inside other user defined functions WildP 1 1,955 Jan-29-2020, 04:57 PM
Last Post: Clunk_Head

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020