Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

saving to global variable  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i have



i would have thought that you could print out myCode as it is a global variable

how cani do this?

 
Bartender
Posts: 20353
111
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it has to be like this:



Otherwise, the "myCode" in your myFunc is created as a function-local variable and it obscures the global myCode. And gets discarded when the function goes out of scope (returns).
 
warren brandt
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beautiful!!! thanks Tim!!!
 
warren brandt
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i still dont understand

as in a previous program i wrote

i had

highestModuleName = ""

declared at the top of the program and im able to print it out...after the section runs alocating a name to it, anywhere else in my program

i dont get it...

 
Tim Holloway
Bartender
Posts: 20353
111
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never got formal training in Python, so I just play it by ear. And I think the rules may vary depending on what version of Python you use.

Best bet is to get a good Python book and study it. Someday I may even get around to doing so myself.

After that I can learn to use Ruby properly...
 
warren brandt
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK Tim will wait
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!