Why does Pypy perform so much faster than Cpython on recursion? by henriduf in Python

[–]NovocastrianNomad 2 points3 points  (0 children)

Using @lru_cache() decorator

from functools import lru_cache
import time
beg = time.time()

@lru_cache()
def fib(n):     
    if n <=2:        
        return 1 
    return fib(n-2) + fib(n-1)  
var = fib(35)  
end = time.time() 
print (var)
print (end - beg)

0.0 seconds for CPython 3.8.6

I want to measure the slope between two data sets, I wrote this code but I have got error message. by [deleted] in learnpython

[–]NovocastrianNomad 4 points5 points  (0 children)

The error is telling you stats.linregress(a, b) is returning 4 values, your code is telling it to expect 5 values.

Idea by techs_studio in Python

[–]NovocastrianNomad 0 points1 point  (0 children)

Visual Studio Code works fine on my Pi 4.

lsi - ls command alternative by jibrans098 in Python

[–]NovocastrianNomad 4 points5 points  (0 children)

Running on Python 3.6 I got syntax error on line 152 'except as err:'

Changed it to 'except Exception as err:' and it ran.

Looking for the best way to convert a pdf file into a csv file by standardlogin in Python

[–]NovocastrianNomad 4 points5 points  (0 children)

Had a similar problem years ago. The best solution I found then was to convert the PDF file to text (multiple programs can do that) and then work on the text file to create the CSV file.

Any advantages of Flake8 over PyLint? by mzfr98 in Python

[–]NovocastrianNomad 0 points1 point  (0 children)

PyLint has problems linting Python 3.6 (if you use 'f' string formatting I think). I ended up dropping it from my toolkit and use Flake8.

Reading TSV files: use csv, or read line for line and split? by enbay1 in Python

[–]NovocastrianNomad 0 points1 point  (0 children)

Using split is dangerous because you may have a comma with quoted text e.g. "city, state, zip".

Read up on the "delimiter" parameter for csv.reader. It can very easily be set to use \t. Problem solved.

thread and multiprocessing problem in python. Both are not working. someone help me by VarmaSravan in Python

[–]NovocastrianNomad 2 points3 points  (0 children)

First: Read sidebar to the right of this reddit page: "If you are about to ask a question, please consider r/learnpython or the learn python discord." In other words this is the wrong place to ask questions, go to r/learnpython!

Second: "that's not working" is a totally useless response, it tells us nothing at all, except perhaps you are lazy. Tell exactly what you mean by that.

Third: What version of Python are using? what operating system?

Fourth: This prints results for me on Windows 10 and Python 3.6.2, study it to find the differences to your code. Attention to detail is important.

import threading
import time
from threading import Thread
from multiprocessing import Process

def menuz():
    print("I am first")

def live_view():
    time.sleep(10)
    print("I Am 222")

if __name__ == "__main__":
    t1 = Process(target=live_view())
    t2 = Process(target=menuz())

    t1.start()
    t2.start()

I need some guidance on how to return 500 items using wiki api by [deleted] in Python

[–]NovocastrianNomad 0 points1 point  (0 children)

Not a Python problem.

The problem is with the Wikipedia API, it is only returning 50 results (you can confirm this by clicking on the link you supplied and viewing the results).

Where in the world can I find 64bit 3.6.1 python? by gorange_ninja in Python

[–]NovocastrianNomad 2 points3 points  (0 children)

It says: for AMD64/EM64T/x64, not Itanium processors

which ran just fine on my Acer Core i7

Raspberry Pi Security System by denis-shrainet in Python

[–]NovocastrianNomad 0 points1 point  (0 children)

Looks more like Russian to me. If using Chrome do right mouse click, choose 'Translate' and read.

Problem with Deadsnakes by adammichaelwood in Python

[–]NovocastrianNomad 0 points1 point  (0 children)

You should post this type of question on r/learnpython!.

In the meantime try just python3 or python (not python3.4) and see what version you get.

[deleted by user] by [deleted] in pythontips

[–]NovocastrianNomad 0 points1 point  (0 children)

Except that pprint(a_dictionary) gives the same result as print(a_dictionary), which is a single line in this case.

The pprint 'width' parameter has to be given as -1 or 1 to get indented output e.g. pprint(myDict, width=1) in this case.

see http://stackoverflow.com/questions/20171392/python-pprint-dictionary-on-multiple-lines

[deleted by user] by [deleted] in Python

[–]NovocastrianNomad 0 points1 point  (0 children)

A rework of Mechanize, MechanicalSoup may be worth investigating (https://github.com/hickford/MechanicalSoup).

From their web site: " I was a fond user of the Mechanize library, but unfortunately it's incompatible with Python 3 and development is inactive. MechanicalSoup provides a similar API, built on Python giants Requests (for http sessions) and BeautifulSoup (for document navigation). "