[Python-Dev] Hello!
My name is Matt Eaton (Agnostic Dev) and I am just joining the mailing list so I wanted to reach out and say hello! ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Hello!
On 03/20/2018 04:15 AM, Agnostic Dev wrote: My name is Matt Eaton (Agnostic Dev) and I am just joining the mailing list so I wanted to reach out and say hello! Hello back! Welcome to the list! Just as a reminder, this list is for discussions of the development OF Python, or how to make Python itself better. If you want to discuss development WITH Python, then you'll want the general Python List instead. -- ~Ethan~ ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] ttk.Treeview.insert() does not allow to insert item with iid=0
On Fri, Mar 16, 2018 at 10:54 AM, Игорь Яковченко wrote: > I investigated problem and found that in ttk.py, Treeview.insert(... > iid=None, ...) in method's body has a check: > if iid: > res = self.tk.call(self._w, "insert", parent, index, > "-id", iid, *opts) > else: > res = self.tk.call(self._w, "insert", parent, index, *opts) > It means that if iid is "True" then use it else autogenerate it. > Maybe there should be "if iid is not None", not "if iid"? Or there are > some reasons to do check this way? > isn't it considered pythonic to both: use None as a default for "not specified" AND use: if something is None to check if the parameter has been specified? however, this is a bit of an odd case: ids are strings, but it allows you to pass in a non-string and stringified version will be used. so None should be the only special case -- not "anything false" (but if the empty string is the root, then it's another special case -- again, good to check for none rather than anything Falsey) so it probably should do something like: if iid is not None: res = self.tk.call(self._w, "insert", parent, index, "-id", str(iid), *opts) else: res = self.tk.call(self._w, "insert", parent, index, *opts) note both the check for None and the str() call. I'm assuming the str() call happens under the hood at the boundary already, but better to make it explicit in teh Python. Alternatively: this has been around a LONG time, so the maybe the answer is "don't do that" -- i.e. don't use anything falsey as an iid. But it would still be good to make the docs more clear about that. -CHB --- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [email protected] ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Symmetry arguments for API expansion
It seems .as_integer_ratio() has been resolved. what about the original .is_integer() request? (Or did I miss that somehow?) Anyway, it seems like __index__() should play a role here somehow... isn't that how you ask an object for the integer version of itself? Could float et al. add an __index__ method that would return a ValueError if the value was not an integer? Of course, as pointed out earlier in this thread, an "exact" integer is probably not what you want with a float anyway -CHB On Tue, Mar 13, 2018 at 10:29 PM, Tim Peters wrote: > [Tim] > >> An obvious way to extend it is for Fraction() to look for a special > >> method too, say "_as_integer_ratio()". > > [Greg Ewing] > > Why not __as_integer_ratio__? > > Because. at this point, that would be beating a dead horse ;-) > ___ > Python-Dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ > chris.barker%40noaa.gov > -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [email protected] ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Symmetry arguments for API expansion
No, the whole point of __index__ is that it refuses *all* floats -- otherwise people will do approximate computations that for their simple test inputs give whole numbers, use them as sequence indices, and then find their code broken only when the computation incurs some floating point approximation. OTOH, is_integer() specifically asks whether a given real value is a whole number so you can cast it to int() without rounding, etc. On Tue, Mar 20, 2018 at 5:32 PM, Chris Barker wrote: > It seems .as_integer_ratio() has been resolved. > > what about the original .is_integer() request? (Or did I miss that > somehow?) > > Anyway, it seems like __index__() should play a role here somehow... isn't > that how you ask an object for the integer version of itself? > > Could float et al. add an __index__ method that would return a ValueError > if the value was not an integer? > > Of course, as pointed out earlier in this thread, an "exact" integer is > probably not what you want with a float anyway > > -CHB > > > On Tue, Mar 13, 2018 at 10:29 PM, Tim Peters wrote: > >> [Tim] >> >> An obvious way to extend it is for Fraction() to look for a special >> >> method too, say "_as_integer_ratio()". >> >> [Greg Ewing] >> > Why not __as_integer_ratio__? >> >> Because. at this point, that would be beating a dead horse ;-) >> ___ >> Python-Dev mailing list >> [email protected] >> https://mail.python.org/mailman/listinfo/python-dev >> Unsubscribe: https://mail.python.org/mailman/options/python-dev/chris. >> barker%40noaa.gov >> > > > > -- > > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R(206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > [email protected] > > ___ > Python-Dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ > guido%40python.org > > -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Hello!
Thank you, Ethan. It sounds like I landed in the right place. Thank you for the heads up. On Tue, Mar 20, 2018 at 11:20 AM, Ethan Furman wrote: > On 03/20/2018 04:15 AM, Agnostic Dev wrote: > > My name is Matt Eaton (Agnostic Dev) and I am just joining the mailing >> list so I wanted to reach out and say hello! >> > > Hello back! Welcome to the list! > > Just as a reminder, this list is for discussions of the development OF > Python, or how to make Python itself better. If you want to discuss > development WITH Python, then you'll want the general Python List instead. > > -- > ~Ethan~ > ___ > Python-Dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/agnosticd > ev%40gmail.com > ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Symmetry arguments for API expansion
On Wed, Mar 21, 2018 at 12:32:11AM +, Chris Barker wrote: > Could float et al. add an __index__ method that would return a ValueError > if the value was not an integer? That would allow us to write things like: "abcdefgh"[5.0] which is one of the things __index__ was invented to prevent. > Of course, as pointed out earlier in this thread, an "exact" integer is > probably not what you want with a float anyway Not always. For example, I might want a function factorial(x) which returns x! when x is an exact integer value, and gamma(x+1) when it is not. That is what the HP-48 series of calculators do. (This is just an illustration.) Another example is that pow() functions sometimes swap to an exact algorithm if the power is an int. There's no particular reason why x**n and x**n.0 ought to be different, but they are: py> 123**10 792594609605189126649 py> 123**10.0 7.925946096051892e+20 On the other hand, some might argue that by passing 10.0 as the power, I am specifically requesting a float implementation and result. I don't wish to argue in favour of either position, but just to point out that it is sometimes reasonable to want to know whether a float represents an exact integer value or not. -- Steve ___ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
