Search found 3 matches

by REMsleep100
Fri Feb 11, 2022 9:34 pm
Forum: General Discussion
Topic: Accessing Variables from Generator
Replies: 3
Views: 2362

Re: Accessing Variables from Generator

Code: Select all

 def func():
  func.variable = "John"

func()

print(func.variable)


There. Accessing a variable from a function

But how do you do that with a generator?
by REMsleep100
Wed Feb 09, 2022 10:41 pm
Forum: General Discussion
Topic: Accessing Variables from Generator
Replies: 3
Views: 2362

Re: Accessing Variables from Generator

I am attempting to get every set of random Boolean values for each number in the list

1. It should be done with lazy evaluation
2. It should reference itself in the generator
by REMsleep100
Wed Feb 02, 2022 6:01 pm
Forum: General Discussion
Topic: Accessing Variables from Generator
Replies: 3
Views: 2362

Accessing Variables from Generator

I have a generator to make an infinite list of numbers

Code: Select all

 t = 0
u = []
def h ():
 while True:
  t = t + 1
  u.append(t)
  yield u
h ()


But how do I use it?

Code: Select all

 z = any(u)


Thanks, Oliver

Go to advanced search