• Welcome to Religious Forums, a friendly forum to discuss all religions in a friendly surrounding.

    Your voice is missing! You will need to register to get access to the following site features:
    • Reply to discussions and create your own threads.
    • Our modern chat room. No add-ons or extensions required, just login and start chatting!
    • Access to private conversations with other members.

    We hope to see you as a part of our community soon!

Python Language author retires

Brickjectivity

wind and rain touch not this brain
Staff member
Premium Member
PEP 13 -- Python Language Governance
As of December of 2018, due to Guido announcing retirement, the core developers of Cpython voted on their new language governance structure.

Its a voting structure, and nobody will be replacing the tyrant-for-life.

Feel free to prognosticate the future of this programming language.
 

beenherebeforeagain

Rogue Animist
Premium Member
PEP 13 -- Python Language Governance
As of December of 2018, due to Guido announcing retirement, the core developers of Cpython voted on their new language governance structure.

Its a voting structure, and nobody will be replacing the tyrant-for-life.

Feel free to prognosticate the future of this programming language.
I so thought this was going to be about Monty Python...:(:eek::oops::rolleyes:
 

icehorse

......unaffiliated...... anti-dogmatist
Premium Member
Thanks for the info.

I'd be surprised if much changes, Python has found a few good niches, and it seems well settled in at this point.

In case anyone cares, purveyors of Python are called "Pythonistas". ;)
 

Brickjectivity

wind and rain touch not this brain
Staff member
Premium Member
I don't use python. I'm more of a C fan myself.
How does it compare, and what are the niches that @icehorse mentioned?
Parsing, extends the command line, runs as an interpreter glues utilities together, has a good C API for patching to C object code, and plus its named after the Monty Python show. Its main competitor is probably Perl, and it supports Perl regular expressions. Perl is intended to let you do the same thing multiple ways while Python is being engineered in the hope that every task will have one obvious method. Perl is older, but Python now comes standard in almost all the same systems.
 

icehorse

......unaffiliated...... anti-dogmatist
Premium Member
To add to what @Brickjectivity said, Python has also become popular with the so-called "data scientists" and the machine learning crowd. It's seen as one of the easier to learn and more forgiving of the popular languages. so researchers who aren't full time programmers often choose Python.
 

Tumah

Veteran Member
Speaking about Python, @Brickjectivity , can you explain to me why I'm getting list index out of range?

fib_list=[]
highest_value =10
n = 0
while fib_list[-1] < highest_value:
fib_list.append(Fibonacci(n)) #Fibonacci() defined earlier
n += 1​

I'm trying to populate a list with the Fibonacci sequence up until the last value of the sequence hits highest_value. I don't have more than a few weeks of Python under my belt though.
 

Jedster

Well-Known Member
Speaking about Python, @Brickjectivity , can you explain to me why I'm getting list index out of range?

fib_list=[]
highest_value =10
n = 0
while fib_list[-1] < highest_value:
fib_list.append(Fibonacci(n)) #Fibonacci() defined earlier
n += 1​

I'm trying to populate a list with the Fibonacci sequence up until the last value of the sequence hits highest_value. I don't have more than a few weeks of Python under my belt though.

(not a Python programmer, but it seems similar to C)
If the condition fib_list[-1] < highest_value is never true then n will become infinite, hence index too large.
It maybe a simple syntax error, which I can't spot, since I haven't ever used Python)
Could be to do with how fib_list=[] is instantiated.
What does Fibonacci(n)) #Fibonacci() do? Could it be that said function is never returns a value< 10?
 
Last edited:

Tumah

Veteran Member
Shouldn't it be while fib_list[n] < highest_value?



(not sure, but it seems similar to C to me)
I'm trying to iterate from the last number in the list. So every time I append another number to fib_list, I'm hoping it will be evaluated against highest_value.
 

Brickjectivity

wind and rain touch not this brain
Staff member
Premium Member
Speaking about Python, @Brickjectivity , can you explain to me why I'm getting list index out of range?

fib_list=[]
highest_value =10
n = 0
while fib_list[-1] < highest_value:
fib_list.append(Fibonacci(n)) #Fibonacci() defined earlier
n += 1
I'm trying to populate a list with the Fibonacci sequence up until the last value of the sequence hits highest_value. I don't have more than a few weeks of Python under my belt though.
I think the problem there is that on the first go in that loop your list is empty, so fib[-1] will not refer to anything on the first pass.

You could put a test in for that condition that would test to make sure the list has at least one item.
fib_list=[]
highest_value =10
n = 0
while True
___ if len(fib_list) > 0 and fib_list[-1] < highest_value:
_______ fib_list.append(Fibonacci(n)) #Fibonacci() defined earlier
________n += 1
___ elif len(fib_list) = 0:
_______ fib_list.append(n)
___ if n >= highest_value:
_______ break


I recently read a function that someone wrote to handle this kind of problem. Its in the Python documentation..for the functools module in the part about the lru_cache. They have a recursive function.

def fib(n):
___ if n < 2:
_______ return n
___ return fib(n-1) + fib(n-2)

Its short and works!
 
Last edited:

Jedster

Well-Known Member
I'm trying to iterate from the last number in the list. So every time I append another number to fib_list, I'm hoping it will be evaluated against highest_value.

I updated my reply to contain the following possibilities:

If the condition fib_list[-1] < highest_value is never true then n will become infinite, hence index too large.
It maybe a simple syntax error, which I can't spot, since I haven't ever used Python.
Could be to do with how fib_list=[] is instantiated; does it have data already in the list?
What does Fibonacci(n)) #Fibonacci() do? Could it be that said function is never returns a value< 10?
 

Brickjectivity

wind and rain touch not this brain
Staff member
Premium Member
def fib(n):
___ if n < 2:
_______ return n
___ return fib(n-1) + fib(n-2)

Its short and works!
As-is its slow though and doesn't finish when n gets much bigger than 30. It takes several seconds to get a response when I put 30 in, so using a simple loop is better. I guess because of this I will avoid using recursion for anything that needs too many levels.

If, however, you use the @functools.lru_cache decorator (like in the module example) the function runs fast. It works with numbers over 30. I don't remember what the recursion limit is, but it would probably work right up to the maximum depth. It looks like maximum recursion is around 900 see maximum recursion

I have run this function with the lru_cache decorator with n=81, and it runs fine that way. fib(81) = 37889062373143906 Its 37 of whatever comes after trillion. Its a lot of rabbits.
 
Last edited:

Tumah

Veteran Member
I think the problem there is that on the first go in that loop your list is empty, so fib[-1] will not refer to anything on the first pass.

You could put a test in for that condition that would test to make sure the list has at least one item.
fib_list=[]
highest_value =10
n = 0
while True
___ if len(fib_list) > 0 and fib_list[-1] < highest_value:
_______ fib_list.append(Fibonacci(n)) #Fibonacci() defined earlier
________n += 1
___ elif len(fib_list) = 0:
_______ fib_list.append(n)
___ if n >= highest_value:
_______ break


I recently read a function that someone wrote to handle this kind of problem. Its in the Python documentation..for the functools module in the part about the lru_cache. They have a recursive function.

def fib(n):
___ if n < 2:
_______ return n
___ return fib(n-1) + fib(n-2)

Its short and works!
Sorry for the delayed response. I actually read your response yesterday, but it was getting close to the Sabbath and I had to run into the shower and afterwards it was too late to respond.
I fixed the problem by adding a 0 to the list, based on your suggestion. So I guess yesterday I learned that nothing !< 10. Just goes to show.
I ended up having to change it altogether, because the way I had it before, I was appending the number right over my target. So now I'm using:
while True:
if fib_list[-1] < highest_value:
fib_list.append(Fibonacci(n))
n+=1
else:
continue​

I'm actually using a recipe I found that's not too different although yours is a little shorter:
def Fibonacci(n):
if n<0:
print("Incorrect input")
elif n==0:
return 0
elif n==1:
return 1
else:
return Fibonacci(n-1)+Fibonacci(n-2)​

Math makes me dizzy, so I don't really care what it does, as long as it works!
 

Tumah

Veteran Member
I updated my reply to contain the following possibilities:

If the condition fib_list[-1] < highest_value is never true then n will become infinite, hence index too large.
It maybe a simple syntax error, which I can't spot, since I haven't ever used Python.
Could be to do with how fib_list=[] is instantiated; does it have data already in the list?
What does Fibonacci(n)) #Fibonacci() do? Could it be that said function is never returns a value< 10?
Yeah, the list wasn't populated and nothing is apparently not recognized as a value less than 10. Once I added in a zero, it worked. Although now I'm going to have to remove the zero afterwards.
 
Top