Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
newb selfie
#1
I'm trying to get a grasp on Python classes and want to clarify something.

If I use a variable name like "count" inside a class and also have a "count" variable outside the class then I *must* use self.count inside the class or python will use the global instead?

So when writing any class all "local" variables really have to be written as self.var or they could clash with variables in the main program?
Reply


Messages In This Thread
newb selfie - by PatM - Feb-18-2019, 08:18 PM
RE: newb selfie - by micseydel - Feb-18-2019, 08:29 PM
RE: newb selfie - by Larz60+ - Feb-18-2019, 08:34 PM
RE: newb selfie - by PatM - Feb-18-2019, 08:51 PM
RE: newb selfie - by ichabod801 - Feb-18-2019, 10:07 PM
RE: newb selfie - by snippsat - Feb-19-2019, 12:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python newb need help Fictile 1 347 Apr-02-2024, 03:28 AM
Last Post: buran
  NameError issue with daughter's newb code MrGonk 2 1,540 Sep-16-2021, 01:29 PM
Last Post: BashBedlam
  Simple newb string question Involute 2 2,324 Sep-08-2019, 12:50 AM
Last Post: Involute
  please help this newb install pygame iofhua 7 6,174 May-15-2019, 01:09 PM
Last Post: buran
  Newb question: Debugging + Linting Python in Visual Studio Code Drone4four 1 2,511 Apr-15-2019, 06:19 AM
Last Post: perfringo
  Newb question about %02d %04d bennylava 30 20,187 Mar-05-2019, 11:23 PM
Last Post: snippsat
  Pthyon 3 question (newb) bennylava 11 6,152 Feb-28-2019, 06:04 PM
Last Post: buran
  Complete NEWB and openpyxl project Netopia 44 18,074 Jan-18-2019, 08:15 PM
Last Post: Netopia
  Newb Question - Threading in Crons vvarrior 2 2,888 Jul-20-2018, 08:12 PM
Last Post: vvarrior
  Matt's newb question 1 MattSS102 1 2,786 Aug-28-2017, 03:27 AM
Last Post: BerlingSwe

Forum Jump:

User Panel Messages

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