Any way to "subclass" typing.Annotated?

2025-01-28 Thread Ian Pilcher via Python-list
(Note: I have mail delivery disabled for this list and read it through GMane. Please copy me on any responses, so that I can respond with proper threading.) From the things that I probably shouldn't spend my free time on department ... As background, I'm working on a project that is going to i

[SOLVED] Struggling to understand Callable type hinting

2025-01-18 Thread Ian Pilcher via Python-list
(Note: I have mail delivery disabled for this list and read it through GMane, so I am unable to respond with correct threading if I'm not cc'ed directly.) On 1/18/25 8:52 AM, Ian Pilcher wrote: (And even that wouldn't really be correct, if it worked, because it doesn't e

Re: Struggling to understand Callable type hinting

2025-01-18 Thread Ian Pilcher via Python-list
(Note: I have mail delivery disabled for this list and read it through GMane, so I am unable to respond with correct threading if I'm not cc'ed directly.) On 1/17/25 7:26 PM, dn via Python-list wrote: On 18/01/25 12:33, Ian Pilcher via Python-list wrote: I am making my first atte

Struggling to understand Callable type hinting

2025-01-17 Thread Ian Pilcher via Python-list
I am making my first attempt to use type hinting in a new project, and I'm quickly hitting areas that I'm having trouble understanding. One of them is how to write type hints for a method decorator. Here is an example that illustrates my confusion. (Sorry for the length.) import collections.a

Re: Checking if email is valid

2023-11-01 Thread Ian Hobson via Python-list
ng regex sounds like a bad idea to me and the other options I found required paying for third party services. Could someone push me in the right direction please? I just want to find out if a string is a valid email address. Thank you. Simon. -- Ian Hobson Tel (+66) 626 544 695 -- https://

Re: Getty fully qualified class name from class object

2023-08-23 Thread Ian Pilcher via Python-list
On 8/22/23 11:13, Greg Ewing via Python-list wrote: Classes have a __module__ attribute: >>> logging.Handler.__module__ 'logging' Not sure why I didn't think to look for such a thing. Looks like it's as simple as f'{cls.__module__}.{cls.__qualname__}'. Thanks! -- ==

Getty fully qualified class name from class object

2023-08-22 Thread Ian Pilcher via Python-list
How can I programmatically get the fully qualified name of a class from its class object? (I'm referring to the name that is shown when str() or repr() is called on the class object.) Neither the __name__ or __qualname__ class attributes include the module. For example: >>> import logging

Which more Pythonic - self.__class__ or type(self)?

2023-03-02 Thread Ian Pilcher
Seems like an FAQ, and I've found a few things on StackOverflow that discuss the technical differences in edge cases, but I haven't found anything that talks about which form is considered to be more Pythonic in those situations where there's no functional difference. Is there any consensus? --

Re: Tool that can document private inner class?

2023-02-08 Thread Ian Pilcher
On 2/8/23 08:25, Weatherby,Gerard wrote: No. I interpreted your query as “is there something that can read docstrings of dunder methods?” Have you tried the Sphinx specific support forums? https://www.sphinx-doc.org/en/master/support.html Yes. I've posted to both the -user and -dev group

Re: Tool that can document private inner class?

2023-02-07 Thread Ian Pilcher
On 2/7/23 14:53, Weatherby,Gerard wrote: Yes. Inspect module import inspect class Mine: def __init__(self): self.__value = 7 def __getvalue(self): /"""Gets seven""" /return self.__value mine = Mine() data = inspect.getdoc(mine) for m in inspect.getmembers(mine): if '__getvalue' in m[0]:

Tool that can document private inner class?

2023-02-07 Thread Ian Pilcher
I've been banging my head on Sphinx for a couple of days now, trying to get it to include the docstrings of a private (name starts with two underscores) inner class. All I've managed to do is convince myself that it really can't do it. See https://github.com/sphinx-doc/sphinx/issues/11181. Is t

Re: set.add() doesn't replace equal element

2022-12-31 Thread Ian Pilcher
On 12/30/22 17:00, Paul Bryan wrote: It seems to me like you have to ideas of what "equal" means. You want to update a "non-equal/equal" value in the set (because of a different time stamp). If you truly considered them equal, the time stamp would be irrelevant and updating the value in the set

Re: set.add() doesn't replace equal element

2022-12-30 Thread Ian Pilcher
On 12/30/22 15:47, Paul Bryan wrote: What kind of elements are being added to the set? Can you show reproducible sample code? The objects in question are DHCP leases. I consider them "equal" if the lease address (or IPv6 prefix) is equal, even if the timestamps have changed. That code is not

set.add() doesn't replace equal element

2022-12-30 Thread Ian Pilcher
I just discovered this behavior, which is problematic for my particular use. Is there a different set API (or operator) that can be used to add an element to a set, and replace any equal element? If not, am I correct that I should call set.discard() before calling set.add() to achieve the behavi

Re: Calling pselect/ppoll/epoll_pwait

2022-12-13 Thread Ian Pilcher
On 12/2/22 14:00, Ian Pilcher wrote: Does Python provide any way to call the "p" variants of the I/O multiplexing functions? Just to close this out ... As others suggested, there's no easy way to call the "p" variants of the I/O multiplexing functions, but thi

Calling pselect/ppoll/epoll_pwait

2022-12-02 Thread Ian Pilcher
Does Python provide any way to call the "p" variants of the I/O multiplexing functions? Looking at the documentation of the select[1] and selectors[2] modules, it appears that they expose only the "non-p" variants. [1] https://docs.python.org/3/library/select.html [2] https://docs.python.org/3/l

Re: Dealing with non-callable classmethod objects

2022-11-12 Thread Ian Pilcher
On 11/12/22 14:57, Cameron Simpson wrote: You shouldn't need a throwaway class, just use the name "classmethod" directly - it's the type!     if not callable(factory):     if type(factory) is classmethod:     # replace fctory with a function calling factory.__func__    

Re: Dealing with non-callable classmethod objects

2022-11-12 Thread Ian Pilcher
On 11/11/22 16:47, Cameron Simpson wrote: On 11Nov2022 15:29, Ian Pilcher wrote: * Can I improve the 'if callable(factory):' test above?  This treats  all non-callable objects as classmethods, which is obviously not  correct.  Ideally, I would check specifically for a classmethod,

Re: Superclass static method name from subclass

2022-11-11 Thread Ian Pilcher
On 11/11/22 11:02, Thomas Passin wrote: You can define a classmethod in SubClass that seems to do the job: class SuperClass(object):   @staticmethod   def spam():  # "spam" and "eggs" are a Python tradition   print('spam from SuperClass') class SubClass(SuperClass):     @cla

Re: Superclass static method name from subclass

2022-11-11 Thread Ian Pilcher
On 11/11/22 11:29, Dieter Maurer wrote: Ian Pilcher wrote at 2022-11-11 10:21 -0600: class SuperClass(object): @staticmethod def foo(): pass class SubClass(SuperClass): bar = SuperClass.foo ^^ Is there a way to do this without

Dealing with non-callable classmethod objects

2022-11-11 Thread Ian Pilcher
I am trying to figure out a way to gracefully deal with uncallable classmethod objects. The class hierarchy below illustrates the issue. (Unfortunately, I haven't been able to come up with a shorter example.) import datetime class DUID(object): _subclasses = {} def __init_subclass__

Superclass static method name from subclass

2022-11-11 Thread Ian Pilcher
Is it possible to access the name of a superclass static method, when defining a subclass attribute, without specifically naming the super- class? Contrived example: class SuperClass(object): @staticmethod def foo(): pass class SubClass(SuperClass): bar = SuperCl

Re: Comparing sequences with range objects

2022-04-09 Thread Ian Hobson
n 0 # They are equal and key data for both is present 2) Sort the data using the comparator function. 3) Run through the data with a trailing enumeration loop, merging matching records together. 4) If there are no records copied out with missing key data, then you are done, so exit. 5) Choose

Re: neoPython : Fastest Python Implementation: Coming Soon

2021-05-05 Thread Ian Clark
I wish you best of luck, on top of everything else it looks like the neopython namespace has already been eaten up by some crypto project On Wed, May 5, 2021 at 11:18 AM Benjamin Schollnick < bscholln...@schollnick.net> wrote: > > Why? The currently extant Python implementations contribute to cli

_pydoc.css

2020-10-25 Thread Ian Gay
The default colors of pydoc are truly horrendous! Has anyone written a _pydoc.css file to produce something reasonable? (running 3.6 on OpenSuse 15.1) Ian -- *** To reply by e-mail, make w single in address ** -- https://mail.python.org/mailman/listinfo/python-list

Re: What kind of magic do I need to get python to talk to Excel xlsm file?

2020-09-03 Thread Ian Hill
If you don't need to do any specific data analysis using pandas, try openpyxl. It will read xlsm files and it quite straight forward to use. https://openpyxl.readthedocs.io/en/stable/ pip install openpyxl. Ian -- https://mail.python.org/mailman/listinfo/python-list

Re: Silly question, where is read() documented?

2020-08-29 Thread Ian Hobson
27;s not a built-in function and it's not documented with (for example) the file type object sys.stdin. So where is it documented? :-) -- Ian Hobson -- This email has been checked for viruses by AVG. https://www.avg.com -- https://mail.python.org/mailman/listinfo/python-list

Re: LittleRookie

2020-08-19 Thread Ian Hill
You can access Dr.Chuck's Python for Everybody course here https://www.py4e.com/ or you need to be on the audit track on Coursera. R. ushills -- https://mail.python.org/mailman/listinfo/python-list

Re: Any socket library to communicate with kernel via netlink?

2019-11-20 Thread Ian Pilcher
always found library called netlinkg but it actually does something like modify network address or check network card... Any idea is welcome https://pypi.org/project/pyroute2/ -- Ian Pilcher

Distutils - bdist_rpm - specify python interpretter location

2019-10-30 Thread Ian Pilcher
--record=INSTALLED_FILES Is there a way to tell Distutils to use 'python2'? Thanks! -- ==== Ian Pilcher arequip...@gmail.com --

Re: What's the purpose the hook method showing in a class definition?

2019-10-20 Thread Ian Hobson
odifies the call, to look for a magic method, and starts again at B. When the magic method is found in Object, you get the "not found" error. If you implement the magic method in A or B it will be run instead. Regards Ian -- This email has been checked for viruses by AVG.

Re: Get __name__ in C extension module

2019-10-07 Thread Ian Pilcher
bject actually is a logger. Doing that validation (by using an "O!" unit in the PyArg_ParseTuple format string) requires access to the logging.Logger type object, and I was unable to find a way to access that object by name. -- =====

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
ts wrong and you get memory leaks of worse crash python. Well, I like driving cars with manual transmissions, so ... -- ==== Ian Pilcher arequip...@gmail.com "I grew up before

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
do I access that later in one of my extension functions? The only thing I can think of would be to save it in a static variable, but static variables seem to be a no-no in extensions. -- ==== Ian Pilcher

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
On 10/5/19 12:55 PM, Ian Pilcher wrote: This is straightforward, except that I cannot figure out how to retrieve the __name__. Making progress. I can get a __name__ value with: PyDict_GetItemString(PyEval_GetGlobals(), "__name__") I say "a __name__ value" because t

Get __name__ in C extension module

2019-10-05 Thread Ian Pilcher
On 10/4/19 4:30 PM, Ian Pilcher wrote: Ideally, I would pass my existing Logging.logger object into my C function and use PyObject_CallMethod to call the appropriate method on it (info, debug, etc.). As I've researched this further, I've realized that this isn't the correc

Using a logging.Logger in a C extension

2019-10-04 Thread Ian Pilcher
, etc.). PyArg_ParseTuple should be able to handle this with an "O!" format unit, but I can't figure out how to retrieve the type object for logging.Logger. Any hints, links, etc. appreciated. Thanks! -- ====

Irritating bytearray behavior

2019-09-16 Thread Ian Pilcher
ts of ip.packed into the bytearray without changing its size? TIA -- ==== Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented

Re: ``if var'' and ``if var is not None''

2019-09-01 Thread Ian Kelly
On Sun, Sep 1, 2019, 8:58 AM Terry Reedy wrote: > On 9/1/2019 2:12 AM, Hongyi Zhao wrote: > > > The following two forms are always equivalent: > > ``if var'' and ``if var is not None'' > > Aside from the fact that this is false, why would you post such a thing? > Trolling? Did you hit [Send]

Re: itertools cycle() docs question

2019-08-21 Thread Ian Kelly
On Wed, Aug 21, 2019 at 12:36 PM Calvin Spealman wrote: > > The point is to demonstrate the effect, not the specific implementation. But still yes, that's pretty much exactly what it does. The main difference between the "roughly equivalent to" code and the actual implementation is that the forme

Re: Enumerate - int object not subscriptable

2019-08-20 Thread Ian Kelly
Or use the "pairwise" recipe from the itertools docs: from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return zip(a, b) for num1, num2 in pairwise(a): print(num1, num2) On Tue, Aug 20, 2019 at 7:42 AM

Re: Remote/Pair-Programming in-the-cloud

2019-08-04 Thread Ian Kelly
On Sat, Aug 3, 2019, 9:25 AM Bryon Tjanaka wrote: > Depending on how often you need to run the code, you could use a google doc > and copy the code over when you need to run. Of course, if you need linters > and other tools to run frequently this would not work. > I've conducted a number of remo

Re: if bytes != str:

2019-08-04 Thread Ian Kelly
On Sun, Aug 4, 2019, 9:02 AM Hongyi Zhao wrote: > Hi, > > I read and learn the the following code now: > > https://github.com/shadowsocksr-backup/shadowsocksr-libev/blob/master/src/ > ssrlink.py > > > In this s

Re: super or not super?

2019-07-16 Thread Ian Kelly
On Tue, Jul 16, 2019 at 1:21 AM Chris Angelico wrote: > > On Tue, Jul 16, 2019 at 3:32 PM Ian Kelly wrote: > > > > Just using super() is not enough. You need to take steps if you want to > > ensure that you class plays nicely with MI. For example, consider the > &g

Re: super or not super?

2019-07-15 Thread Ian Kelly
On Sun, Jul 14, 2019 at 7:14 PM Chris Angelico wrote: > > On Mon, Jul 15, 2019 at 10:51 AM Paulo da Silva > wrote: > > > > Às 15:30 de 12/07/19, Thomas Jollans escreveu: > > > On 12/07/2019 16.12, Paulo da Silva wrote: > > >> Hi all! > > >> > > >> Is there any difference between using the base cl

Re: How Do You Replace Variables With Their Values?

2019-07-14 Thread Ian Kelly
On Thu, Jul 11, 2019 at 11:10 PM Chris Angelico wrote: > > On Fri, Jul 12, 2019 at 2:30 PM Aldwin Pollefeyt > wrote: > > > > Wow, I'm so sorry I answered on the question : "How do you replace a > > variable with its value". For what i understood with the example values, > > CrazyVideoGamez wants

Re: Seeking help regarding Python code

2019-07-11 Thread Ian Hobson
code will come after you understand exactly what to achieve, and how a computer could do it. Regards Ian (Another one). -- https://mail.python.org/mailman/listinfo/python-list

Re: Conway's game of Life, just because.

2019-05-07 Thread Ian Kelly
On Tue, May 7, 2019 at 1:00 PM MRAB wrote: > > On 2019-05-07 19:29, Eli the Bearded wrote: > > In comp.lang.python, Paul Rubin wrote: > > > > Thanks for posting this. I'm learning python and am very familiar with > > this "game". > > > >> #!/usr/bin/python3 > >> from itertools import chain > >>

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Ian Kelly
On Tue, Apr 2, 2019 at 1:43 AM Alexey Muranov wrote: > > > On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov > gmail.com> > > wrote: > > > > > > I only see a superficial analogy with `super()`, but perhaps it is > > > because you did not give much details of you suggestion. > > > > No, it's because t

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-04-02 Thread Ian Kelly
On Mon, Apr 1, 2019 at 3:52 PM Alexey Muranov wrote: > > I only see a superficial analogy with `super()`, but perhaps it is > because you did not give much details of you suggestion. No, it's because the analogy was not meant to be anything more than superficial. Both are constructs of syntactic

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-31 Thread Ian Kelly
On Sun, Mar 31, 2019 at 1:09 PM Alexey Muranov wrote: > > On dim., Mar 31, 2019 at 6:00 PM, python-list-requ...@python.org wrote: > > On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov > > > > wrote: > > > >> > >> On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org > >> wrote: > >> > > >

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-30 Thread Ian Kelly
On Sat, Mar 30, 2019, 5:32 AM Alexey Muranov wrote: > > On ven., Mar 29, 2019 at 4:51 PM, python-list-requ...@python.org wrote: > > > > There could perhaps be a special case for lambda expressions such > > that, > > when they are directly assigned to a variable, Python would use the > > variable

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Ian Kelly
On Thu, Mar 28, 2019 at 2:30 PM Alexey Muranov wrote: > > On jeu., mars 28, 2019 at 8:57 PM, Terry Reedy wrote: > > Throwing the name away is foolish. Testing functions is another > > situation in which function names are needed for proper report. > > My idea however was to have it as an exact s

Re: Syntax for one-line "nonymous" functions in "declaration style"

2019-03-28 Thread Ian Kelly
On Wed, Mar 27, 2019 at 3:13 AM Paul Moore wrote: > > On Wed, 27 Mar 2019 at 08:25, Alexey Muranov wrote: > > > > Whey you need a simple function in Python, there is a choice between a > > normal function declaration and an assignment of a anonymous function > > (defined by a lambda-expression) t

Re: array of characters?

2019-03-22 Thread Ian Kelly
I don't know the answer, and PEP 393 doesn't talk about the array('u') deprecation directly. But it seems to me that with Py_UNICODE going away this array type code would have to be completely reimplemented, and also at that point array('u') is just equivalent to array('L') with some extra conversi

Re: Potential Security Bug

2019-03-20 Thread Ian Kelly
On Wed, Mar 20, 2019 at 5:14 AM Laish, Amit (GE Digital) wrote: > > Hello, > I’m Amit Laish, a security researcher from GE Digital. > During one of our assessments we discovered something that we consider a bug with security implications which can cause a denial of service by disk exhausting, and

Re: Determining latest stable version for download

2019-03-20 Thread Ian Kelly
1) https://www.python.org/downloads/ has release information. Based on that you would currently want 3.7.2. Make sure you actually download 3.7.2 and not 3.7.2rc1. 2) The tarfiles are not distro-specific. For Linux there are really only two options: Python-3.7.2.tar.xz and Python-3.7.2.tgz. The onl

Re: Why can't access the property setter using the super?

2019-03-19 Thread Ian Kelly
Here's the thing: the result of calling super() is not an instance of the base class. It's just a proxy object with a __getattribute__ implementation that looks up class attributes in the base class, and knows how to pass self to methods to simulate calling base class methods on an instance. This w

Re: Generator question

2019-03-13 Thread Ian Kelly
You're basically running into this: https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result To see why, let's try disassembling your function. I'm using Python 3.5 here, but it shouldn't make much of a difference. py> import

Re: comp.lang.python

2019-02-12 Thread Ian Hobson
://www.gangboard.com/big-data-training/data-science-training Wow! I know Nagels algorithm backed off, but over 20 years! Impressive! Ian -- https://mail.python.org/mailman/listinfo/python-list

Re: The slash "/" as used in the documentation

2019-02-11 Thread Ian Kelly
On Mon, Feb 11, 2019 at 1:56 PM boB Stepp wrote: > > On Mon, Feb 11, 2019 at 2:34 PM Chris Angelico wrote: > > > Calling on the D'Aprano Collection of Ancient Pythons for confirmation > > here, but I strongly suspect that positional arguments with defaults > > go back all the way to 1.x. > > Has

Re: The slash "/" as used in the documentation

2019-02-11 Thread Ian Kelly
On Mon, Feb 11, 2019 at 1:35 PM Chris Angelico wrote: > > On Tue, Feb 12, 2019 at 7:26 AM Avi Gross wrote: > > If you want to talk about recent or planned changes, fine. But make that > > clear. I was talking about how in the past positional arguments did not have > > defaults available at the de

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Mon, Feb 11, 2019 at 12:19 AM Terry Reedy wrote: > The pass-by-position limitation is not in CPython, it is the behavior of > C functions, which is the behavior of function calls in probably every > assembly and machine language. Allowing the flexibility of Python > function calls take extra c

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Sun, Feb 10, 2019 at 2:18 PM Avi Gross wrote: > I am not sure how python implements some of the functionality it does as > compared to other languages with similar features. But I note that there are > rules, presumably some for efficiency, such as requiring all keyword > arguments to be placed

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Sun, Feb 10, 2019 at 9:34 AM Chris Angelico wrote: > > On Mon, Feb 11, 2019 at 2:49 AM Ian Kelly wrote: > > > > On Sat, Feb 9, 2019 at 1:19 PM Terry Reedy wrote: > > > > > > This is the result of Python being a project of mostly unpaid volunteers. > &

Re: The slash "/" as used in the documentation

2019-02-10 Thread Ian Kelly
On Sat, Feb 9, 2019 at 1:19 PM Terry Reedy wrote: > > This is the result of Python being a project of mostly unpaid volunteers. > > See my response in this thread explaining how '/' appears in help output > and IDLE calltips. '/' only appears for CPython C-coded functions that > have been modifie

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ian Clark
This is my whack at it, I can't wait to hear about it being the wrong big o notation! numbers=[] while len(numbers) < 10: try: chip = int(input('please enter an integer: ')) except ValueError: print('that is not a number, try again') else: numbers.append(chip)

Re: How to replace space in a string with \n

2019-01-31 Thread Ian Clark
text = "The best day of my life!" output = '' for i in text: if i == ' ': output +='\n' else: output += i print(output) throwing my hat in the ring, not only is it .replace free it is entirely method free On Thu, Jan 31, 2019 at 3:41 AM ^Bart wrote: > [Solved by myself and I'm happy!!!

Re: what considerations for changing height of replacement radiator?

2019-01-30 Thread Ian Clark
looking for a Space heater? sorry, not the Java mailing list On Wed, Jan 30, 2019 at 3:11 PM jkn wrote: > Hi all > I'm looking at changing a radiator in a bedroom shortly and wondering > about > my options re. sizing. > > The current radiator is 900mm W x 600mm H, and is single panel, no > c

Re: Python stopped installing packages

2019-01-29 Thread Ian Clark
according to https://pypi.org/project/discord.py/ Discord.py only supports 3.4 and 3.5 On Tue, Jan 29, 2019 at 4:52 PM Hamish Allen <101929...@gmail.com> wrote: > Hi, > > Recently I’ve been trying to code a Discord bot in Python 3.6.2, then I > realised that some features of discord.py were only

Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
which version of Python? I get Syntax error on 3.7.1 On Tue, Jan 29, 2019 at 12:37 PM Adrian Ordona wrote: > The code actually works just the way i copy and pasted > > Sent from my iPhone > > On Jan 29, 2019, at 12:34, Ian Clark wrote: > > just the pure number of letter

Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
just the pure number of letters next to parenthesis would cause the Parser to error out On Tue, Jan 29, 2019 at 12:32 PM Schachner, Joseph < joseph.schach...@teledyne.com> wrote: > Yes, that works. Assuming it was correctly formatted when you ran it. > The formatting could not possibly be run in

Re: Problem in Installing version 3.7.2(64 bit)

2019-01-29 Thread Ian Clark
back in my day we had to show our professors errors on punchcard! and we liked it On Sun, Jan 27, 2019 at 11:51 AM Terry Reedy wrote: > On 1/26/2019 6:24 AM, Vrinda Bansal wrote: > > Dear Sir/Madam, > > > > After Installation of the version 3.7.2(64 bit) in Windows 8 when I run > the > > program

Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
threw this together, let me know what you think num_list=[] name_list = ['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth'] name_it = name_list.pop(0) while len(num_list) < 3: try: num_list.append( int( input(f"Insert the {name_it} number: "))) except Valu

Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
Like this? num_max = 0 num_index = 0 name_list = ['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth'] name_it = name_list.pop(0) while num_index <3: try: num_list = int( input(f"Insert the {name_it} number: ")) except ValueError: print('Not a number, try

Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-23 Thread Ian Kelly
On Wed, Jan 23, 2019 at 1:36 PM Stefan Behnel wrote: > > Cameron Simpson schrieb am 23.01.19 um 00:21: > > from __future__ import absolute_imports, print_function > > > > gets you a long way. > > ... and: division. All right, but apart from absolute imports, the print function, and true division

Re: Pythonic Y2K

2019-01-17 Thread Ian Kelly
On Wed, Jan 16, 2019 at 9:57 PM Avi Gross wrote: > > The forthcoming UNIX 2038 problem will, paradoxically happen on January 19. I wonder what they will do long before then. Will they just add a byte or four or 256 and then make a date measurable in picoseconds? Or will they start using a number f

Re: sampling from frequency distribution / histogram without replacement

2019-01-15 Thread Ian Hobson
rators are actually any good. Regards Ian On 14/01/2019 20:11, duncan smith wrote: Hello, Just checking to see if anyone has attacked this problem before for cases where the population size is unfeasibly large. i.e. The number of categories is manageable, but the sum of the frequencies, N,

Re: the python name

2019-01-04 Thread Ian Kelly
On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber wrote: > > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross" > declaimed the following: > > > >language, Formula Translator? (I recall using the What For version). > > WATFOR => WATerloo FORtran And then there was WATFIV, which stands for WA

Re: Type hinting of Python is just a toy ?

2019-01-04 Thread Ian Kelly
On Fri, Jan 4, 2019 at 10:44 AM iamybj--- via Python-list wrote: > > { id: 1, name:’abc’, age:99, address:{province:’CA’, city:’SA’}} Those are nested dicts, not tuples, which leaves your argument really unclear. A dict is essentially a hash map. Java and C# (it's unclear what language you're co

Re: Type hinting of Python is just a toy ?

2019-01-04 Thread Ian Kelly
On Fri, Jan 4, 2019 at 1:20 AM Chris Angelico wrote: > > Pep484 is too complex. Typle should not a seperate type, in fact it should > > be just a class. Like this in other programming language > > Python: Tuple(id: int, name: string, age: int) > > Other: class someClass { > > public int i

Re: Question about slight deviations when using integer division with large integers.

2018-12-30 Thread Ian Kelly
On Sun, Dec 30, 2018 at 10:18 PM Christian Seberino wrote: > > What is simplest way to make both those > prints give same values? Any slicker way > than an if statement? Stack Overflow has a few suggestions: https://stackoverflow.com/questions/19919387/in-python-what-is-a-good-way-to-round-towar

Re: Question about slight deviations when using integer division with large integers.

2018-12-30 Thread Ian Kelly
On Sun, Dec 30, 2018 at 10:27 PM Cameron Simpson wrote: > > On 30Dec2018 21:14, Christian Seberino wrote: > >What is simplest way to make both those > >prints give same values? Any slicker way > >than an if statement? > > If your post had an attachment, be aware that the python-list list drops >

Re: Ask for help about class variable scope (Re: Why doesn't a dictionary work in classes?)

2018-12-27 Thread Ian Kelly
On Wed, Dec 26, 2018 at 11:21 PM Chris Angelico wrote: > > On Thu, Dec 27, 2018 at 1:56 PM wrote: > > > > I saw the code below at stackoverflow. I have a little idea about the scope > > of a class, and list comprehension and generator expressions, but still > > can't figure out why Z4 works and

Re: Why do data descriptors (e.g. properties) take priority over instance attributes?

2018-12-18 Thread Ian Kelly
On Mon, Dec 17, 2018, 12:09 PM Paul Baker When Python looks up an attribute on an object (i.e. when it executes > `o.a`), it uses an interesting priority order [1]. It looks for: > > 1. A class attribute that is a data-descriptor (most commonly a property) > 2. An instance attribute > 3. Any ot

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Ian Kelly
On Sat, Dec 8, 2018 at 7:57 PM wrote: > > Grant Edwards於 2018年12月9日星期日 UTC+8上午12時52分04秒寫道: > > Just to be clear: you do _not_ want to use eval on the string. > > > > If you're not the one who created the string, it might wipe your hard > > drive or empty your bank account. If you _are_ the one wh

Re: Program to keep track of success percentage

2018-12-08 Thread Ian Kelly
On Sat, Dec 8, 2018 at 1:22 PM Alister via Python-list wrote: > > On Sat, 08 Dec 2018 10:02:41 -0800, Musatov wrote: > > > I am thinking about a program where the only user input is win/loss. The > > program let's you know if you have won more than 31% of the time or not. > > Any suggestions about

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Ian Kelly
On Fri, Dec 7, 2018 at 11:56 PM Henrik Bengtsson wrote: > > A comment from the sideline: one could imagine extending the Python syntax > with a (optional) 0d prefix that allows for explicit specification of > decimal values. They would "complete" the family: > > * 0b: binary number > * 0o: octal n

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Ian Kelly
On Fri, Dec 7, 2018 at 7:47 PM wrote: > > MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: > > Before Python 3, a leading 0 in an integer literal would indicate an > > octal (base 8) number. > > So, the reason is historical. > > > The old form is now invalid in order to reduce the chance of bugs. > > I e

Re: Question on difference between LambdaType and FunctionType

2018-11-26 Thread Ian Kelly
On Sun, Nov 25, 2018 at 2:00 PM Chris Angelico wrote: > > On Mon, Nov 26, 2018 at 7:55 AM Iwo Herka wrote: > > > > > class Foo: > > >def setup(self): ... > > >__init__ = lambda self: self.setup() > > > > Sorry, didn't address this. This is fine too, since I'm assuming that > > only method

Re: Odd truth result with in and ==

2018-11-21 Thread Ian Kelly
On Wed, Nov 21, 2018 at 2:53 PM Serhiy Storchaka wrote: > > 21.11.18 22:17, Cameron Simpson пише: > > Can someone show me a real world, or failing that - sane looking, > > chained comparison using "in"? > > s[0] == s[-1] in '\'"' > > Tests that string s starts and ends with a single or double

Re: on the prng behind random.random()

2018-11-19 Thread Ian Kelly
On Mon, Nov 19, 2018 at 2:12 PM Robert Girault wrote: > > Chris Angelico writes: > > > On Tue, Nov 20, 2018 at 7:31 AM Robert Girault wrote: > >> Nice. So Python's random.random() does indeed use mt19937. Since it's > >> been broken for years, why isn't it replaced by something newer like > >>

Re: Generators, generator expressions, and loops

2018-11-16 Thread Ian Kelly
On Fri, Nov 16, 2018 at 7:57 AM Steve Keller wrote: > > I have looked at generators, generator expressions, and iterators and > I try to get more familiar with these. > > 1. How would I loop over all (with no upper bound) integers or all > powers of two, for example? > > In C it would be > >fo

Re: Iterators of iterators

2018-11-16 Thread Ian Kelly
On Fri, Nov 16, 2018 at 8:01 AM Steve Keller wrote: > > I wonder why iterators do have an __iter__() method? I thought > iterable objects would have an __iter__() method (but no __next__()) > to create an iterator for it, and that would have the __next__() > method but no __iter__(). > > $ py

installing modules problem

2018-11-08 Thread Ian K.
Hello, My name is Ian Kilty and I have been having trouble with pip. I have pip installed, and I have tried to install modules they say they are installed in cmd, but when I go into python and import the module, it can't find it. I hope there is a simple solution to this problem, please l

Re: Asyncio tasks getting cancelled

2018-11-06 Thread Ian Kelly
On Tue, Nov 6, 2018 at 3:39 PM Ian Kelly wrote: > > n Mon, Nov 5, 2018 at 8:43 PM wrote: > > What I meant was, the error message is specific to futures in the > > 'PENDING' state. Which should be set to 'RUNNING' before any actions > > occur. So

Re: Asyncio tasks getting cancelled

2018-11-06 Thread Ian Kelly
n Mon, Nov 5, 2018 at 8:43 PM wrote: > > On Mon, Nov 05, 2018 at 07:15:04PM -0700, Ian Kelly wrote: > > > For context: > > > https://github.com/ldo/dbussy/issues/13 > > > https://gist.github.com/tu500/3232fe03bd1d85b1529c558f920b8e43 > > > > >

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Ian Kelly
On Mon, Nov 5, 2018 at 6:20 PM wrote: > Again sorry for the confusion, but I don't think this is an issue with > restarting loops, as this isn't happening in my application. Sure, I wasn't talking about restarting loops so much as strategies for making sure that everything has completed in the fi

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Ian Kelly
On Mon, Nov 5, 2018 at 8:41 AM wrote: > > > But anyway, I highly recommend you to use the "await other_coroutine()" > > > syntax I talked about earlier. It may even fix the issue (90% chance). > > > > This should indeed fix the issue, but this is definitely not what one is > > looking for if one r

Re: Asyncio tasks getting cancelled

2018-11-04 Thread Ian Kelly
On Sun, Nov 4, 2018 at 3:58 PM Léo El Amri via Python-list wrote: > > On 04/11/2018 20:25, i...@koeln.ccc.de wrote: > > I'm having trouble with asyncio. Apparently tasks (asyncio.create_task) > > are not kept referenced by asyncio itself, causing the task to be > > cancelled when the creating func

  1   2   3   4   5   6   7   8   9   10   >