On Thu, Aug 02, 2018 at 12:19:41PM -0700, Marc Tompkins wrote:
> What you want in that case is an assertion:
>
> try:
> assert type(uvc)==float
> except AssertionError as e:
> print(e, msg)
>
> An assertion says "The following statement is True. If it isn't, I'm going
> to throw an exce
On 02/08/18 15:29, Shall, Sydney wrote:
> uvc = 2
> msg = "Bad argument provided, the value of uvc must be a float."
>
> try:
> type(uvc) == float
> except TypeError as e:
> print(e, msg)
The try block contains an expression that will always evaluate
to True or False and thus never rai
On 02/08/18 21:12, Ali M wrote:
> I tried writing the search_word function and binded it to the button, but
> it doesn't work, please help i'm still a beginner.
>
> def search_word(self, tag):
> esperanto = self.listbox.selection_set(0)
> results = self.cur.execute("SELECT Eng
Hi, in my code i have the curselection in my enter_meaning function, and it
works well and prints the result which comes from db to the text widget.
When user searches in entrybox the list lowers down to 1 item, how can i
get the index of that item and bind it to the button so it will print the
res
try... except is meant to catch errors: places where your program would
otherwise crash. It does NOT work as a truth check.
In your example:
> try:
> type(uvc) == float
> except TypeError as e:
> print(e, msg)
>
> "type(uvc)==float" resolves to a standalone True or False, not an
exception
On 2 August 2018 at 15:29, Shall, Sydney wrote:
>
> try:
> type(uvc) == float
> except TypeError as e:
> print(e, msg)
Let's try this interactively:
>>> uvc = 2
>>> type(uvc)
>>> type(uvc) == float
False
So calling type(uvc) doesn't raise an error. It returns the type
"int". You then c
On 2 August 2018 at 13:49, Peter Otten <__pete...@web.de> wrote:
> Oscar Benjamin wrote:
>>
>> Comparing floats for equality can be flakey. Sometimes two floats that
>> should be equal will not compare equal e.g.:
>>
> 0.01 + 0.1 - 0.1 == 0.01
>> False
>
> Do you know if there's a way to constr
MAC OS X 10.13.6
Anaconda python 3.6.5
Anaconda IPython 6.4.0
I am having difficulty in using the try, except form.
I copy and paste a minimal program to illustrate my problem.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 2 15:41:15 2018
@author: sydney
"""
uvc = 2
Oscar Benjamin wrote:
> On 1 August 2018 at 21:38, Roger Lea Scherer wrote:
>>
>> I'm trying to get a list of tuples to be a float, a numerator, and a
>> denominator for all the fractions: halves, thirds, fourths etc up to
>> ninths. 1/2 returns the same float as 2/4, 3/6, 4/8. I would like to ke
On 1 August 2018 at 21:38, Roger Lea Scherer wrote:
>
> I'm trying to get a list of tuples to be a float, a numerator, and a
> denominator for all the fractions: halves, thirds, fourths etc up to
> ninths. 1/2 returns the same float as 2/4, 3/6, 4/8. I would like to keep
> only the 1/2. When I try
I'm trying to get a list of tuples to be a float, a numerator, and a
denominator for all the fractions: halves, thirds, fourths etc up to
ninths. 1/2 returns the same float as 2/4, 3/6, 4/8. I would like to keep
only the 1/2. When I try (line 18) to "pop" from the list I get a "TypeError:
integer
I am running only one line of code "import requests"
Error I am getting is below
Traceback (most recent call last):
File "/Users/saketmehrotra/Documents/Flaskask.py", line 4, in
import requests
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/__
12 matches
Mail list logo