Re: Is it possible to inheret a metaclass.

2020-04-11 Thread Pieter van Oostrum
Pieter van Oostrum  writes:

> Your Pardon is not a class, it is a function. Class A is created by
> type(cls, *args), so 'type' is the metaclass of A, and therefore also of
> B.
> Creation of B does not call Pardon.

With a class it *does* work:

In [74]: class Pardon(type):
 ... def __init__(cls, *args):
 ... print("Calling Pardon with", cls)

In [75]: class A(metaclass=Pardon): pass
Calling Pardon with 

In [76]: class B(A): pass
Calling Pardon with 

-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: For Loop Invariants

2020-04-11 Thread Rhodri James

On 10/04/2020 21:44, Elliott Dehnbostel wrote:

Hello Everyone,

I've also posted this to the python-ideas mailing list, but I thought to
post here as well for a more general audience.

If I've done this incorrectly, please let me know so that I can
improve/revise. I'm new to the Python community and quite enjoy the more
functional features of Python 3, but have I have a peeve about it. I'd like
to propose and discuss the following enhancement to Python 3:

*Consider the following trivial for-loop:*

chars = "abcaaabkjzhbjacvb"
seek = {'a','b','c'}
count = 0for a in chars:
  if a in seek:
   count += 1

Gross. Twice nested for a simple count.


a) I don't personally think that's gross (apart from the missing 
newline, which is just an email artefact I assume).


b) If it's simple like this and you care enough, refactor it as a 
comprehension:


  count = sum(1 for a in chars if a in seek)

It it's not so simple, neither the comprehension nor your proposal are 
going to be as readable as the twice nesting.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Is it possible to inheret a metaclass.

2020-04-11 Thread Peter Otten
Antoon Pardon wrote:

> 
> 
> Op 9/04/20 om 18:37 schreef Peter Otten:
>> Antoon Pardon wrote:
>> 
>>> I am experimenting with subclasses that all need the same metaclass as
>>> the base class. Is there a way to make the metaclass be inherited, so
>>> that you don't have to repeat the "metaclass = MetaClass" with every
>>> subclass.
>> 
>> ?
>> 
>> This is not only possible, this is the default:
>> 
>>   >>> class Pardon(type): pass
>> ...
> class A(metaclass=Pardon): pass
>> ...
> class B(A): pass
>> ...
> type(B)
>> 
> 
> Can you explain what is wrong with the code below:
> 
> This produces only: Calling Pardon with A.
> 
> 
> def Pardon(cls, *args):
>  print("Calling Pardon with", cls)
>  return type(cls, *args)
> 
> class A(metaclass=Pardon): pass
> 
> class B(A): pass

As has been pointed out, the problem is the factory function you are using 
instead of a class. One way to look at it:

class Foo: 
pass

def make_foo(): 
return Foo()

foo = make_foo()
assert isinstance(foo, make_foo)

Would you expect the assertion to succeed? Would you expect that foo 
remembers that it has been created by make_foo()? 
No? Then replace the instance with the class, the class with the metaclass.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: For Loop Invariants

2020-04-11 Thread Terry Reedy

On 4/10/2020 4:44 PM, Elliott Dehnbostel wrote:


chars = "abcaaabkjzhbjacvb"
seek = {'a','b','c'}
count = 0for a in chars:
  if a in seek:
   count += 1


Why did you repeatly omit the \n after 0?  Please paste code that ran


Gross. Twice nested for a simple count.


Twice indented does not particularly bother me.

> [snip]

*We could do this:*

chars = "abcaaabkjzhbjacvb"
seek = {'a','b','c'}
count = sum([1 for a in chars if a in seek])

However, this changes important semantics by creating an entire new
list before summing.


Unnecessary.  Use a generator comprehension (expression).

sum(1 for a in chars if a in seek)


chars = "abcaaabkjzhbjacvb"
seek = {'a','b','c'}
count = 0  # fixed
for a in chars if a in seek: count += 1


Rejected and rejected again, any mixing of keyword clauses like this 
except in comprehensions.  The sum expression is shorter and only 1 line.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


help me subcorrect

2020-04-11 Thread khuchee



Sent from Mail for Windows 10

-- 
https://mail.python.org/mailman/listinfo/python-list


plead add persian languges

2020-04-11 Thread m. bahrami



Sent from Mail for Windows 10

-- 
https://mail.python.org/mailman/listinfo/python-list


problem in installing

2020-04-11 Thread shina sameeran
i tried to install python 3.8.2 in my HP windows 8 laptop(core i3). after
installation when i tried to open the programme it shows  window says
modify, repair or uninstall.  it does not work after modify and repair.
please help.


yours sincerely

shina  m j
chennai
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem in installing

2020-04-11 Thread Souvik Dutta
You are running the installer instead of the program itself. Try searching
idle from the start menu and run it in that way.

Souvik flutter dev

On Sat, Apr 11, 2020, 8:36 PM shina sameeran 
wrote:

> i tried to install python 3.8.2 in my HP windows 8 laptop(core i3). after
> installation when i tried to open the programme it shows  window says
> modify, repair or uninstall.  it does not work after modify and repair.
> please help.
>
>
> yours sincerely
>
> shina  m j
> chennai
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: py2c - an open source Python to C/C++ is looking for developers

2020-04-11 Thread jared . h . lam
On Monday, July 30, 2012 at 6:27:04 AM UTC-7, [email protected] wrote:
> I created py2c ( http://code.google.com/p/py2c )- an open source Python to 
> C/C++ translator!
> py2c is looking for developers!
> To join create a posting in the py2c-discuss Google Group or email me!
> Thanks
> PS:I hope this is the appropiate group for this message.

Here is my code from python
import cv2
import numpy as np

img = cv2.imread('c1.pgm',0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,
param1=50,param2=30,minRadius=10,maxRadius=60)

circles = np.uint16(np.around(circles))
for i in circles[0,:]:
# draw the outer circle
cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)

cv2.imshow('detected circles',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
Thanks a bunch
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: For Loop Invariants

2020-04-11 Thread Peter J. Holzer
On 2020-04-10 15:44:05 -0500, Elliott Dehnbostel wrote:
> *Consider the following trivial for-loop:*
> 
> chars = "abcaaabkjzhbjacvb"
> seek = {'a','b','c'}
> count = 0
> for a in chars:
>  if a in seek:
>   count += 1
> 
> Gross. Twice nested for a simple count.
> 
[...]
> I propose the following enhancement:
> 
> chars = "abcaaabkjzhbjacvb"
> seek = {'a','b','c'}
> count = 0
> for a in chars if a in seek: count += 1

I don't see much of an enhancement here. You save writing one colon and
one newline here. The code itself is exactly the same. If the original
was gross (I don't agree), then this is just as gross.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | [email protected] |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Getting ReadTimeoutError for tensorflow while deploying python app to Azure Web App

2020-04-11 Thread kargawal . abhishek
remote: [20:44:36+] Collecting tensorflow==2.1.0

remote: [20:44:36+] Downloading 
tensorflow-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl (421.8 MB)

remote: ...

remote: ...

remote: 
.

remote: WARNING: Retrying (Retry(total=4, connect=None, read=None, 
redirect=None, status=None)) after connection broken by ' 
("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read 
timeout=15)")': /simple/tensorflow-estimator/

remote: [20:51:54+] Collecting tensorflow-estimator==2.1.0

remote: ..

remote: WARNING: Retrying (Retry(total=4, connect=None, read=None, 
redirect=None, status=None)) after connection broken by 
'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', 
port=443): Read timed out. (read timeout=15)")': 
/packages/18/90/b77c328a1304437ab1310b463e533fa7689f4bfc41549593056d812fab8e/tensorflow_estimator-2.1.0-py2.py3-none-any.whl

remote: [20:52:09+] Downloading 
tensorflow_estimator-2.1.0-py2.py3-none-any.whl (448 kB)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help me subcorrect

2020-04-11 Thread Souvik Dutta
Did you send a screenshot? If so then understand that this mailing list
does not support photos so you cannot send that. Try giving us a verbal
description. And if you write anything other that the sub then sorry that
is my Gmail's fault.

Souvik flutter dev

On Sat, Apr 11, 2020, 8:32 PM khuchee  wrote:

>
>
> Sent from Mail for Windows 10
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list