About 50 results
Open links in new tab
  1. "Initializing" variables in python? - Stack Overflow

    Jun 16, 2015 · Even though initializing variables in python is not necessary, my professor still wants us to do it for practice. I wrote my program and it worked fine, but after I tried to initialize some of the

  2. Initialize a string variable in Python: "" or None?

    Initialize a string variable in Python: "" or None? Asked 16 years, 5 months ago Modified 6 years, 7 months ago Viewed 435k times

  3. python - Automatically initialize instance variables? - Stack Overflow

    For Python 3.7+ you can use a Data Class, which is a very pythonic and maintainable way to do what you want. It allows you to define fields for your class, which are your automatically initialized instance …

  4. python - How do I 'declare' an empty bytes variable? - Stack Overflow

    Jan 21, 2022 · 47 How do I initialize ('declare') an empty bytes variable in Python 3? I am trying to receive chunks of bytes, and later change that to a utf-8 string. However, I'm not sure how to initialize …

  5. correct way to define class variables in Python - Stack Overflow

    I noticed that in Python, people initialize their class attributes in two different ways. The first way is like this: class MyClass: __element1 = 123 __element2 = "this is Africa" ...

  6. Is it possible only to declare a variable without assigning any value ...

    Mar 20, 2009 · Is it possible to declare a variable in Python, like so?: var so that it initialized to None? It seems like Python allows this, but as soon as you access it, it crashes. Is this possible? If not, ...

  7. python - What's the pythonic way of conditional variable initialization ...

    Dec 6, 2011 · Due to the scoping rules of Python, all variables once initialized within a scope are available thereafter. Since conditionals do not introduce new scope, constructs in other languages …

  8. How to properly initialize a variable in python - Stack Overflow

    Aug 11, 2021 · How to properly initialize a variable in python Asked 4 years, 5 months ago Modified 4 years, 5 months ago Viewed 1k times

  9. python: is there anyway to initialize a variable only one time?

    Dec 9, 2015 · 16 Python does not have a static variable declaration; however, there are several fairly standard programming patterns in python to do something similar. The easiest way is to just use a …

  10. python - Recommended way to initialize variable in if block - Stack ...

    Jan 19, 2012 · In Python there's no great advantage to initializing before a conditional as in your first example. You just need to be sure that the variable is initialized before it's returned.