request fails on wikipedia (https) - certificate verify failed (_ssl.c:748)
Hi, I would like to get information from Wikipedia articles and I am testing the connection to Wikipedia. I am running Python 3.6.2 on Windows 10. I get certificate errors for all pages with https. Any suggestions are welcome! Here my code: import requests, bs4 from bs4 import BeautifulSoup res = requests.get('https://en.wikipedia.org/wiki/Stethoscope') type(res) res.status_code == requests.codes.ok wiki = bs4.BeautifulSoup(res.text) type(wiki) len(res.text) print(res.text[:250]) Here the error message: Traceback (most recent call last): File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen chunked=chunked) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request self._validate_conn(conn) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn conn.connect() File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connection.py", line 326, in connect ssl_context=context) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 401, in wrap_socket _context=self, _session=session) File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 808, in __init__ self.do_handshake() File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 1061, in do_handshake self._sslobj.do_handshake() File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 683, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 440, in send timeout=timeout File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen _stacktrace=sys.exc_info()[2]) File "c:\Program Files (x86)\Python36-32\lib\site-packages\urllib3\util\retry.py", line 388, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /wiki/Stethoscope (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "web_1.py", line 3, in res = requests.get('https://en.wikipedia.org/wiki/Stethoscope') File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 508, in request resp = self.send(prep, **send_kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 618, in send r = adapter.send(request, **kwargs) File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 506, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /wiki/Stethoscope (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),)) -- https://mail.python.org/mailman/listinfo/python-list
Re: request fails on wikipedia (https) - certificate verify failed (_ssl.c:748)
Install pyopenssl package and try again? Original Message On 11 Dec 2017, 16:44, F Massion wrote: > Hi, > > I would like to get information from Wikipedia articles and I am testing the > connection to Wikipedia. > > I am running Python 3.6.2 on Windows 10. > > I get certificate errors for all pages with https. > Any suggestions are welcome! > > Here my code: > > import requests, bs4 > from bs4 import BeautifulSoup > res = requests.get('https://en.wikipedia.org/wiki/Stethoscope') > type(res) > res.status_code == requests.codes.ok > wiki = bs4.BeautifulSoup(res.text) > type(wiki) > len(res.text) > print(res.text[:250]) > > Here the error message: > > Traceback (most recent call last): > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 601, in > urlopen > chunked=chunked) > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 346, in > _make_request > self._validate_conn(conn) > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 850, in > _validate_conn > conn.connect() > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\urllib3\connection.py", line 326, in > connect > ssl_context=context) > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in > ssl_wrap_socket > return context.wrap_socket(sock, server_hostname=server_hostname) > File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 401, in wrap_socket > _context=self, _session=session) > File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 808, in __init__ > self.do_handshake() > File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 1061, in > do_handshake > self._sslobj.do_handshake() > File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 683, in > do_handshake > self._sslobj.do_handshake() > ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed > (_ssl.c:748) > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 440, in send > timeout=timeout > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 639, in > urlopen > _stacktrace=sys.exc_info()[2]) > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\urllib3\util\retry.py", line 388, in > increment > raise MaxRetryError(_pool, url, error or ResponseError(cause)) > urllib3.exceptions.MaxRetryError: > HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded > with url: /wiki/Stethoscope (Caused by SSLError(SSLError(1, '[SSL: > CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),)) > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "web_1.py", line 3, in > res = requests.get('https://en.wikipedia.org/wiki/Stethoscope') > File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", > line 72, in get > return request('get', url, params=params, **kwargs) > File "c:\Program Files (x86)\Python36-32\lib\site-packages\requests\api.py", > line 58, in request > return session.request(method=method, url=url, **kwargs) > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 508, in > request > resp = self.send(prep, **send_kwargs) > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\requests\sessions.py", line 618, in send > r = adapter.send(request, **kwargs) > File "c:\Program Files > (x86)\Python36-32\lib\site-packages\requests\adapters.py", line 506, in send > raise SSLError(e, request=request) > requests.exceptions.SSLError: HTTPSConnectionPool(host='en.wikipedia.org', > port=443): Max retries exceeded with url: /wiki/Stethoscope (Caused by > SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify > failed (_ssl.c:748)'),)) > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: scipy
On Sat, Dec 9, 2017 at 11:43 AM, Thomas Jollans wrote: > > On 08/12/17 23:57, Larry Martell wrote: > > Trying to install scipy on ubuntu-trusty-64 running Python 2.7.6. > > I STRONGLY recommend moving to Python 3 if you can. The scientific > python ecosystem has had good support for Python 3 for years now. Many > scientific packages, including numpy (the king of scientific > Pythonland), have decided to drop official Python 2 support fairly soon; > numpy will not release any new versions for Python 2 after 2018. It's not in my control. This is part of a django app that is deployed it many sites all over the world, and my customer wants to make as few changes as possible. > > It's failing with: > > > > $ sudo pip install scipy > > Downloading/unpacking scipy > > Downloading scipy-1.0.0.tar.gz (15.2MB): 15.2MB downloaded > > Running setup.py (path:/tmp/pip_build_root/scipy/setup.py) egg_info > > for package scipy > > /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown > > distribution option: 'python_requires' > > > > Followed by many screens full of errors. Is that just a warning or is > > that the issue? I've installed many other packages without a problem > > on this same system. What is the issue here? > > > > I'm just guessing here, but do you have the latest versions of > distutils, setuptools and pip? It's likely that scipy requires newer > versions of these than your distribution provides. You may have to > upgrade them. I resolved this by installing a newer version of pip. -- https://mail.python.org/mailman/listinfo/python-list
Re: csv.DictReader line skipping should be considered a bug?
On 2017-12-05, Steve D'Aprano wrote: > On Wed, 6 Dec 2017 04:20 am, Jason wrote: >> while iterating over two files, which are line-by-line >> corresponding. The DictReader skipped ahead many lines >> breaking the line-by-line correspondence. > > Um... this doesn't follow. If they are line-by-line > corresponding, then they should skip the same number of blank > lines and read the same number of non-blank lines. > > Even if one file has blanks and the other does not, if you > iterate the over the records themselves, they should keep their > correspondence. > > I'm afraid that if you want to convince me this is a buggy > design, you need to demonstrate a simple pair of CSV files > where the non-blank lines are corresponding (possibly with > differing numbers of blanks in between) but the CSV readers get > out of alignment somehow. Preface: I'm not arguing for this to be changed--it obviously cannot be at this point, and we know how to work around it when it matters--although the current design does make finding the erronesou records needlessly harder than it needs to be. Examine the records that DictReader returns for the following csv file and see if you think it still feels obvious and usable. A,B,C a,b,c a,b a a,b a,b,c Furthermore, see what DictWriter produces from this program: with open("wcsv.csv", 'w', newline='') as f: writer = csv.DictWriter(f, fieldnames=('A', 'B', 'C')) writer.writeheader() for rec in ( {'A': 'a', 'B': 'b', 'C': 'c'}, {'A': 'a', 'B': 'b'}, {'A': 'a'}, {}, {'A': 'a'}, {'A': 'a', 'B': 'b'}, {'A': 'a', 'B': 'b', 'C': 'c'},): writer.writerow(rec) DictReader doesn't handle the output of DictWriter in a usable and recoverable way. >> And I want to argue that the difference of behavior should be >> considered a bug. It should be considered as such because: 1. >> I need to know what's in the file to know what class to use. > > Sure. But blank lines don't tell you what class to use. > >> The file content should not break at-least-1-record-per-line. > > Blank lines DO break that requirement. A blank line is not a > record. Except it inconsistently is one for DictWriter, which if you were right should produce no output for an empty dict. > is a blank record with five empty fields. \n alone is just a > blank. The DictReader correctly returns records with blank > fields. The question to me is what should DictReader do when the hopeful constraint that the header defines the number of fields is broken in the data. In my opinion, it should do a thing that makes it the simplest to handle the situation for the programmer. This is in fact usually what happens. When there are more records than define in the header, you can choose what happens by setting extrasaction. When some records are missing--it sets them to None. Except, when all the records are missing, it silently hides the error with no ability provided to recover it. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: csv.DictReader line skipping should be considered a bug?
On 2017-12-11, Neil Cerutti wrote: > On 2017-12-05, Steve D'Aprano wrote: >> On Wed, 6 Dec 2017 04:20 am, Jason wrote: >>> while iterating over two files, which are line-by-line >>> corresponding. The DictReader skipped ahead many lines >>> breaking the line-by-line correspondence. >> >> Um... this doesn't follow. If they are line-by-line >> corresponding, then they should skip the same number of blank >> lines and read the same number of non-blank lines. >> >> Even if one file has blanks and the other does not, if you >> iterate the over the records themselves, they should keep their >> correspondence. >> >> I'm afraid that if you want to convince me this is a buggy >> design, you need to demonstrate a simple pair of CSV files >> where the non-blank lines are corresponding (possibly with >> differing numbers of blanks in between) but the CSV readers get >> out of alignment somehow. > > Preface: I'm not arguing for this to be changed--it obviously > cannot be at this point, and we know how to work around it when > it matters--although the current design does make finding the > erronesou records needlessly harder than it needs to be. > > Examine the records that DictReader returns for the following csv > file and see if you think it still feels obvious and usable. > > A,B,C > a,b,c > a,b > a > > a,b > a,b,c > > Furthermore, see what DictWriter produces from this program: > > with open("wcsv.csv", 'w', newline='') as f: > writer = csv.DictWriter(f, fieldnames=('A', 'B', 'C')) > writer.writeheader() > for rec in ( > {'A': 'a', 'B': 'b', 'C': 'c'}, > {'A': 'a', 'B': 'b'}, > {'A': 'a'}, > {}, > {'A': 'a'}, > {'A': 'a', 'B': 'b'}, > {'A': 'a', 'B': 'b', 'C': 'c'},): > writer.writerow(rec) > > DictReader doesn't handle the output of DictWriter in a usable > and recoverable way. DOH! Never mind this part of my argument. I'll take some time to eat these eggs on my face. ;) -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: Processing Game Help
On 12/11/2017 07:27 AM, Dennis Lee Bieber wrote: > On Sun, 10 Dec 2017 16:05:37 -0800 (PST), Lauren Porter > declaimed the following: > >> Hello all! I've been trying to create a game in Python Processing Seems like most of the replies missed this information. http://py.processing.org/ >> where a spaceship moves horizontally in order to miss a collision with >> an asteroid. >> > Global variables are seldom the proper solution -- especially if, as > you say, you have classes (in which case you likely should be > providing an instance of the class and modifying its contents) Except that with Processing, global variables are the only way to share things between the setup() function and the loop() function, since both are called directly by the framework. > And NO SIGN of a main program to actually call any of it. You've > defined a half dozen functions, and a few classes, but nothing to run any > of it. This is a python script that runs within the Processing framework, so it has no "main program" in the traditional sense. setup() and loop() are the entry points. Unfortunately this is confusing both to us on the mailing list and to the original poster, as I doubt very few of us use the Processing framework (unless you've worked with Arduino), and the OP is led to think that Python Processing is the same thing as generic Python (which it kind of is...). The OP probably will want to consult with the community at the Processing website (https://forum.processing.org/two/). -- https://mail.python.org/mailman/listinfo/python-list
Re: Processing Game Help
Lauren Porter wrote: > Hello all! I've been trying to create a game in Python Processing where a > spaceship moves horizontally in order to miss a collision with an > asteroid. I'm having difficulty making it so that the game quits when an > asteroid hits the spaceship, could anybody help? Here is my code. As you > can see, I tried using globals in order use variables from previous > classes, but nothing has worked. For this specific approach, no error > message popped up, but nothing happened either. Thanks so much! > > COLORS = {"black":"#00", "white":"#FF", > "red":"#FF", "green":"#00FF00", > "blue":"#D1F5FF", "yellow":"#00", > "orange":"#FFA500", "hendrixorange":"#F58025", > "purple":"#9B30FF", "gray":"#808080", "lightgray": "#CACACA", > "darkgray":"#A9A9A9"} > import random > asteroid = [] > spaceship = [] > stars = [] > justPressed = False > aX = 0 > aY = 0 > x = 0 > y = 0 > > def setup(): > global aX, aY, X, Y > size(640, 480) > for s in range(1): > X = 320 > Y = 440 > spaceship.append(Space(X, Y, COLORS["orange"])) > for a in range(4): > aX = random.randint(0, 640) > aY = 0 > asteroid.append(Asteroid(aX, aY, COLORS["orange"])) > for d in range(100): > randX = random.randint(0, 640) > randY = random.randint(0, 480) > stars.append(Star(randX, randY, COLORS["orange"])) > > > > class Space: > def __init__(self, x, y, color): > self.x = x > self.y = y > self.color = color > > def spaceship(self): > fill(COLORS["blue"]) > stroke(COLORS["white"]) > ellipse(self.x, self.y, 75, 75) #body > fill(COLORS["green"]) > fill(COLORS["gray"]) > stroke(COLORS["green"]) > ellipse(self.x, self.y + 20, 120, 35) > stroke(COLORS["orange"]) > fill(COLORS["purple"]) > ellipse(self.x, self.y + 20, 10, 10) > ellipse(self.x + 30, self.y + 20, 10, 10) > ellipse(self.x - 30, self.y + 20, 10, 10) > > def move(self, dx, dy): > self.x += dx > self.y += dy > > class Asteroid: > def __init__(self, x, y, color): > self.x = x > self.y = y > self.color = color > > def update(self): > self.velx = 0 > self.vely = random.randint(1, 5) > self.x += self.velx > self.y += self.vely > if self.y > 480: > self.y = 0 > self.x = random.randint(1,640) > > def asteroid(self): > fill(COLORS["lightgray"]) > stroke(COLORS["white"]) > ellipse(self.x, self.y, 50, 50) > fill(COLORS["gray"]) > ellipse(self.x +15, self.y + 6, 15, 15) > ellipse(self.x -12, self.y + 7, 10, 10) > ellipse(self.x + 5, self.y - 13, 11, 11) > ellipse(self.x - 12, self.y - 9, 7, 7) > ellipse(self.x + 2, self.y + 18, 7, 7) > > class Star: > def __init__(self, x, y, color): > self.x = x > self.y = y > self.color = color > > def star(self): > fill(COLORS["white"]) > ellipse(self.x, self.y, 3, 3) > > > def draw(): > global justPressed > background(COLORS["black"]) > for f in stars: > f.star() > for f in spaceship: > f.spaceship() > if f.x < 60: > f.move(3, 0) > elif f.x > 580: > f.move(-3, 0) > elif justPressed : > if key == 'd': > f.move(3, 0) > elif key == 'a': > f.move(-3, 0) > for f in asteroid: I'd swap the following lines to move the asteroid before drawing it. That way the x and y attributes keep in sync with what the user sees. > f.asteroid() > f.update() Remove this: >#collision detection 'for' loop >distance = sqrt(((aX - X)**2) + ((aY - Y)**2)) You can test for a collision and exit if an asteroid is close to a spaceship with for s in spaceship: for a in asteroid: if calculate_distance(s, a) < 62.5: print("One of your ships was hit by an asteroid") exit() There are two loops because you want to test every asteroid for every spaceship (although you only have one at the moment). I defined calculate_distance() as def calculate_distance(a, b): dx = a.x - b.x dy = a.y - b.y return sqrt(dx*dx + dy * dy) As invoked in the for loops `a` will be bound to a spaceship and `b` to an asteroid. The function uses the x and y attributes of these objects, so you do not need global variables for coordinates. > def keyTyped(): > global justPressed > justPressed = True > print("typed", key) > > def keyPressed(): > global justPressed > justPressed = True > print("pressed", key) -- https://mail.python.org/mailman/listinfo/python-list
Re: Processing Game Help
On Tue, Dec 12, 2017 at 5:46 AM, Peter Otten <__pete...@web.de> wrote: > You can test for a collision and exit if an asteroid is close to a spaceship > with > > for s in spaceship: > for a in asteroid: > if calculate_distance(s, a) < 62.5: > print("One of your ships was hit by an asteroid") > exit() > > There are two loops because you want to test every asteroid for every > spaceship (although you only have one at the moment). Then shouldn't they be "spaceships" and "asteroids" in the plural? It looks wrong to iterate over a singular asteroid. (And I'd prefer to iterate over a collection of spaceships in the plural even if I know it's a list of one, though I can understand that a list of one is a tricky case for some people.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python homework
On Tue, Dec 05, 2017 at 09:02:54PM +1200, ssghotra1997 wrote: > for i in range(num): > rolls = int(random.randint(1, 6)) > if rolls == 1: > sides['One'] += 1 [...] Using integers as the key makes the code a bit shorter... That approach is also better if you're using a function where you don't know the full range, or if the range is very large. In that case, you don't need to initialize the dictionary; you can instead test if the index exists in the dictionary already, and if not set its value to 1. Much harder to do that if you use text keys (but not impossible--you could write a function that converts numbers to their text names). This is Python 2.7, but there's very little difference from the 3.x version: -=-=-=-=-=-=-=- #!/usr/bin/python import random def roll_die(times): sides = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0} for i in range(times): roll = int(random.randint(1, 6)) sides[roll] += 1 return sides, max(sides,key=sides.get) (rolls, max_side) = roll_die(50) print rolls print "%d was rolled the most: %d times." % (max_side, rolls[max_side]) -=-=-=-=-=-=-=- Both versions have a flaw: If there is a tie, only one is printed: $ ./sides.py {1: 11, 2: 7, 3: 6, 4: 6, 5: 11, 6: 9} 1 was rolled the most: 11 times. [So was 5.] Here's a version that prints all sides that were rolled the maximum number of times: -=-=-=-=-=-=-=- #!/usr/bin/python import random def roll_die(times): sides = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0} max_rolls_sides = [] # roll the dice... for i in range(times): roll = int(random.randint(1, 6)) sides[roll] += 1 # find the first side which was rolled the maximum number index = max(sides, key=sides.get) # get the number of rolls for the side we just got max_rolls = sides[index] # now find all sides that have that number of rolls for i in range(6): current_side = i + 1 if sides[current_side] == max_rolls: max_rolls_sides.append(current_side) # return all those things in a tuple return sides, max_rolls, max_rolls_sides # roll the dice 50 times, and print the results (rolls, max_roll, max_roll_sides) = roll_die(50) print rolls print "max rolls of %d was rolled on sides: %s." % (max_roll, max_roll_sides) -=-=-=-=-=-=-=- [The lines to calculate the index and the max_rolls can be combined, but I left them explicitly separated as I felt it improved clarity.] $ ./sides.py {1: 11, 2: 11, 3: 7, 4: 6, 5: 9, 6: 6} max rolls of 11 was rolled on sides: [1, 2]. $ ./sides.py {1: 8, 2: 9, 3: 9, 4: 7, 5: 8, 6: 9} max rolls of 9 was rolled on sides: [2, 3, 6]. -- https://mail.python.org/mailman/listinfo/python-list
Re: Processing Game Help
Chris Angelico wrote: > On Tue, Dec 12, 2017 at 5:46 AM, Peter Otten <__pete...@web.de> wrote: >> You can test for a collision and exit if an asteroid is close to a >> spaceship with >> >> for s in spaceship: >> for a in asteroid: >> if calculate_distance(s, a) < 62.5: >> print("One of your ships was hit by an asteroid") >> exit() >> >> There are two loops because you want to test every asteroid for every >> spaceship (although you only have one at the moment). > > Then shouldn't they be "spaceships" and "asteroids" in the plural? Yes. (I started out with for spaceship in spacehips: for asteroid in asteroids: if distance(spaceship, asteroid) < 62.5: ... but then decided that while better in principle this slope was too slippery for me, and, after only a few minor changes, the OP would no longer recognize her script...) > It > looks wrong to iterate over a singular asteroid. (And I'd prefer to > iterate over a collection of spaceships in the plural even if I know > it's a list of one, though I can understand that a list of one is a > tricky case for some people.) Here's another line aX = random.randint(0, 640) that "hurts" almost as much as the missing plural. There are other naming problems (did you see the Spaceship class, the drawing methods?). If you write code for some time you develop a set of conventions that help you avoid certain errors, and allows others with similar experience to do sanity checks quickly. However, the script mostly works, has some nice graphics and responds to user input. That's quite an achievement. -- https://mail.python.org/mailman/listinfo/python-list
Re: Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)
Lawrence D’Oliveiro wrote: > Rick Johnson wrote: > > And it's not like we can just pick file up and shake > > it, in a crude attempt to intuit the contents. > > Yes we can! BO??? Is that you? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python homework
On Thursday, December 7, 2017 at 4:49:52 AM UTC-8, edmondo.g...@gmail.com wrote: > import numpy I teach Python to students at varying levels. As much as I love and use Numpy in my regular work, I try to avoid showing beginning Python students solutions that require third-party packages. Here are my reasons: 1. Not every programming novice needs to understand things at the bits-and-bytes level, but they should learn the inner workings of algorithms. You won't always have a ready-made algorithm to solve your problem in a library function call, so you should learn to write your own. 2. Package maintenance can be its own headache. Sure, Anaconda can help, but it's a heavyweight distribution. And not every student is working on a computer where they have the rights to install software. -- https://mail.python.org/mailman/listinfo/python-list
Re: Please tell me how to execute python file in Ubuntu by double
This thread is getting like a mini hologram of our current surreal time… If we can put aside who is right and wrong for a moment we see the more frightening spectacle that Repubs and democrats, Remainers and Brexiters and so on all over — by getting more and more shrill are not talking to each other but past each other So… On Tuesday, December 12, 2017 at 2:45:32 AM UTC+5:30, Rick Johnson wrote: > Rustom Mody wrote: > > [...] > > > Whether there was nothing wrong in what I did, the "wrong- > > right" was de facto, or de jureâ | I will leave to more wise > > persons than myself > > A file with no extension (regardless of the OS or desktop enviroment that it > was created on), is like a sealed box with no label to indicate the contents. So to Rick: Not if you use something like file (magic) My (unschooled) estimate is it gets its detection right 80% of the time And to Chris and others who think file(magic) is a replacement for file-associations. Even assuming that magic works 100% : Say I have an html file. That means its ALSO a text file. So its equally legitimate to set defaults to use… - a plain text editor (of which there are hundreds) - to open it in browser of choice (also plural nowadays) - some sort of html composer - etc Which means we are beyond the nature of the file per se to the pattern of its usage Yeah… magic… in the category of mind-reading? sooth-saying? -- https://mail.python.org/mailman/listinfo/python-list
Re: Please tell me how to execute python file in Ubuntu by double
On Tue, Dec 12, 2017 at 12:37 PM, Rustom Mody wrote: > > This thread is getting like a mini hologram of our current surreal time… > If we can put aside who is right and wrong for a moment we see the more > frightening spectacle that Repubs and democrats, Remainers and Brexiters and > so > on all over — by getting more and more shrill are not talking to each other > but > past each other > > So… > > On Tuesday, December 12, 2017 at 2:45:32 AM UTC+5:30, Rick Johnson wrote: >> Rustom Mody wrote: >> >> [...] >> >> > Whether there was nothing wrong in what I did, the "wrong- >> > right" was de facto, or de jureâ | I will leave to more wise >> > persons than myself >> >> A file with no extension (regardless of the OS or desktop enviroment that it >> was created on), is like a sealed box with no label to indicate the contents. > > So to Rick: > > Not if you use something like file (magic) > My (unschooled) estimate is it gets its detection right 80% of the time > > And to Chris and others who think file(magic) is a replacement for > file-associations. Even assuming that magic works 100% : > > Say I have an html file. > That means its ALSO a text file. > So its equally legitimate to set defaults to use… > - a plain text editor (of which there are hundreds) > - to open it in browser of choice (also plural nowadays) > - some sort of html composer > - etc > > Which means we are beyond the nature of the file per se to the pattern of its > usage > > Yeah… magic… in the category of mind-reading? sooth-saying? Which is why OS/2, back in the 1990s, had *multiple* associations for any given file. You could use file types (sadly not MIME types - this was before MIME was the one obvious standard to use) to identify *any number* of programs that are likely to be used with a file, and then one of them is the global default. For any specific file, you can change which program is its own default, and even add specific associations for that individual file. When you double-click, you get the default; if you right-click and choose "Open", you could pick from the associated programs. A good system, and one that I still haven't seen replicated in a mainstream OS. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: request fails on wikipedia (https) - certificate verify failed (_ssl.c:748)
F Massion writes: > ... > I would like to get information from Wikipedia articles and I am testing the > connection to Wikipedia. > > I am running Python 3.6.2 on Windows 10. > > I get certificate errors for all pages with https. > Any suggestions are welcome! > ... > self._sslobj.do_handshake() > File "c:\Program Files (x86)\Python36-32\lib\ssl.py", line 683, in > do_handshake > self._sslobj.do_handshake() > ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed > (_ssl.c:748) There are too possibilities: * the certificate is really invalid * Python does not know the root certificate[s] necessary for the verification. To differenciate between the possibilities, connect (on the same computer) Wikipedia via a browser. If it, too, reports certificate problems, you likely have the first possibility; otherwise, the second. Python typically looks for root certificate information at the same (platform dependent) place as the browsers. Thus, normally, there is no need to tell Python where to look for them; but, you can do it in the case that the root certificates are installed strangely. Consult the documentation. -- https://mail.python.org/mailman/listinfo/python-list