Python Forum
Block of code, scope of variables and surprising exception
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Block of code, scope of variables and surprising exception
#6
Why are you declaring the class inside your function? It's unnecessary (for a start, that means that class will be redefined every time that function is called) and perhaps more importantly here, interrupts the readability of your function - seeing all the details takes your focus away from what the function is actually for.
Reply


Messages In This Thread
RE: Block of code, scope of variables and surprising exception - by ndc85430 - Apr-02-2020, 05:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,960 Nov-07-2023, 09:49 AM
Last Post: buran
  Library scope mike_zah 2 885 Feb-23-2023, 12:20 AM
Last Post: mike_zah
  python multiple try except block in my code -- can we shorten code mg24 10 6,406 Nov-10-2022, 12:48 PM
Last Post: DeaD_EyE
  Scope of variable confusion Mark17 10 2,979 Feb-24-2022, 06:03 PM
Last Post: deanhystad
  "If Len(Word) == 0" Code Block in Pig Latin Program new_coder_231013 3 2,140 Jan-02-2022, 06:03 PM
Last Post: deanhystad
  Variable scope issue melvin13 2 1,613 Nov-29-2021, 08:26 PM
Last Post: melvin13
  Try,Except,Else to check that user has entered either y or n (Code block pasted) RandomNameGenerator 3 2,371 Jun-29-2021, 08:21 PM
Last Post: RandomNameGenerator
  Variable scope - "global x" didn't work... ptrivino 5 3,118 Dec-28-2020, 04:52 PM
Last Post: ptrivino
  Python Closures and Scope muzikman 2 1,886 Dec-14-2020, 11:21 PM
Last Post: muzikman
  code with exception arguments doen't work MaartenRo 1 1,989 Aug-09-2020, 06:06 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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