[issue37934] Docs: Clarify NotImplemented use cases

2019-09-01 Thread Kyle Stanley


Kyle Stanley  added the comment:

> Would it be viable to rephrase the existing section in a manner that explains 
> the functional purpose of NotImplemented without revolving around its use 
> case in binary special methods?

To expand further upon this, here's an initial idea for improving the first 
sentence:

A special value used to indicate that an operation is not supported between 
specific types.

The section regarding it's usage in binary special methods could potentially 
remain. I'm thinking the main issue here (if there is one) is that the 
NotImplemented constant is defined _exclusively_ from a specific use case, 
rather than its general purpose.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37934] Docs: Clarify NotImplemented use cases

2019-09-01 Thread Kyle Stanley


Kyle Stanley  added the comment:

Thanks for the feedback Vedran and Raymond.

> It is not the purpose of the docs to list use cases.  Mostly we say what 
> something does or how it is defined. As Vedran says, how people use it is 
> their own business.

The underlying issue here seems to be that I misunderstood the existing section 
to suggest to suggest binary special methods are the only use case, which is 
probably a good argument in favor of not listing additional use cases. This can 
be misinterpreted as suggesting that others are not recommended, and lead to 
further confusion.


First sentence of the NotImplemented documentation:

> Special value which should be returned by the binary special methods (e.g. 
> __eq__(), __lt__(), __add__(), __rsub__(), etc.) to indicate that the 
> operation is not implemented with respect to the other type; may be returned 
> by the in-place binary special methods (e.g. __imul__(), __iand__(), etc.) 
> for the same purpose. 

Would it be viable to rephrase the existing section in a manner that explains 
the functional purpose of NotImplemented without revolving around its use case 
in binary special methods?

> Also, please be careful expanded the docs.  They quickly become a promise.

Good point, I may not have adequately considered that mentioning a use case 
turns into a promise for that functionality. This could easily result in a 
significant long-term maintenance cost.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Problem while integrating unittest with setuptools

2019-09-01 Thread dieter
YuXuan Dong  writes:
> I met a problem while I ran `python setup.py test`: 
>
>   unittest.case.SkipTest: No module named 'winreg'
> ... no windows modules should be necessary ...

I know apparently unexplainable "no module named ..." messages as
a side effect of the use of "six".

"six" is used to facilitate the development of components usable
for both Python 2 and Python 3. Among others, it contains the
module "six.moves" which uses advance Python features to allow
the import of Python modules from different locations in the
package hierarchy and also handles name changes. This can
confuse other components using introspection (they see
modules in "six.move" which are not really available).

To find out if something like this is the cause of your problem,
please try to get a traceback. It might be necessary to
use a different test runner for this (I like much "zope.testrunner"
and my wrapper "dm.zopepatches.ztest").

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


[issue37995] Multiline ast.dump()

2019-09-01 Thread Raymond Hettinger


Change by Raymond Hettinger :


Added file: https://bugs.python.org/file48580/ast_bloop.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37995] Multiline ast.dump()

2019-09-01 Thread Raymond Hettinger


Change by Raymond Hettinger :


Removed file: https://bugs.python.org/file48579/ast_bloop.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: a,b = 2,3 and [a,b] = [2,3]

2019-09-01 Thread Chris Angelico
On Mon, Sep 2, 2019 at 12:36 PM Alan Bawden  wrote:
>
> Eko palypse  writes:
>
> > Am Montag, 2. September 2019 00:49:05 UTC+2 schrieb Hongyi Zhao:
> > > Hi,
> > >
> > > What's differences:
> > >
> > > a,b = 2,3 and [a,b] = [2,3]
> > >
> > > Regards
> >
> > In this example the result is the same but the second one
> > builds, internally, an additional list, therefore isn't as sufficient
> > as the first one.
>
> It looks to me like they generate identical code.  The first one calls the
> construction of a tuple, where the second one calls for the construction of
> a list.  It would be surprising if the compiler optimized the tuple
> away, but failed to optimize the list away!
>

Well, you can find out with the 'dis' module.

>>> def f():
... a, b = 2, 3
... a, b = [2, 3]
...
>>> dis.dis(f)
  2   0 LOAD_CONST   1 ((2, 3))
  2 UNPACK_SEQUENCE  2
  4 STORE_FAST   0 (a)
  6 STORE_FAST   1 (b)

  3   8 LOAD_CONST   2 (2)
 10 LOAD_CONST   3 (3)
 12 BUILD_LIST   2
 14 UNPACK_SEQUENCE  2
 16 STORE_FAST   0 (a)
 18 STORE_FAST   1 (b)
 20 LOAD_CONST   0 (None)
 22 RETURN_VALUE

This is with CPython 3.9. It's entirely possible that other Pythons
and/or other versions of CPython may give different results, but with
this particular interpreter, the list is not optimized away.

Tuples get optimized away in quite a number of situations. Exchanging
is done on the stack:

>>> def f():
... x, y = y, x
...
>>> dis.dis(f)
  2   0 LOAD_FAST0 (y)
  2 LOAD_FAST1 (x)
  4 ROT_TWO
  6 STORE_FAST   1 (x)
  8 STORE_FAST   0 (y)
 10 LOAD_CONST   0 (None)
 12 RETURN_VALUE

There are a lot of assumptions the interpreter can make about them,
including that they cannot nest recursively [1], and that, when
constructed from constants, they are themselves constant. Any time you
think it'll make no difference, go with a tuple.

ChrisA

[1] Technically they can, but you have to use the CPython API or
equivalent - vanilla Python code can't do it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a,b = 2,3 and [a,b] = [2,3]

2019-09-01 Thread Alan Bawden
Eko palypse  writes:

> Am Montag, 2. September 2019 00:49:05 UTC+2 schrieb Hongyi Zhao:
> > Hi,
> > 
> > What's differences:
> > 
> > a,b = 2,3 and [a,b] = [2,3]
> > 
> > Regards
> 
> In this example the result is the same but the second one
> builds, internally, an additional list, therefore isn't as sufficient
> as the first one.

It looks to me like they generate identical code.  The first one calls the
construction of a tuple, where the second one calls for the construction of
a list.  It would be surprising if the compiler optimized the tuple
away, but failed to optimize the list away!

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


[issue24416] Have date.isocalendar() return a structseq instance

2019-09-01 Thread Paul Ganssle


Paul Ganssle  added the comment:

> Dong-hee Na, if you want to make a fresh PR for this and bring it to 
> fruition, I would be happy to review and apply it.

It seems premature to say that you will accept a PR for this when there's no 
consensus for actually adding the feature, and it would be good to probably 
work out if it's even desirable before asking contributors to do more work on 
it.

It seems like it would be better to argue the point of *why* you think a 
structseq actually solves the problem here. Is a struct sequence more backwards 
compatible than a namedtuple? Less? Is it as performant? Will it make it easier 
or harder to maintain compatibility between the C and pure Python 
implementations of the datetime module?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38003] Incorrect "fixing" of isinstance tests for basestring

2019-09-01 Thread Bob Kline


Bob Kline  added the comment:

> Use str instead.

Sure. I understand the advantages of the new approach to strings. Which, by the 
way, weren't available when this project began. I don't disagree with anything 
you say in the context of writing new code. I was, however, surprised and 
dismayed to learn of the cavalier approach the upgrade tool has taken to 
silently breaking existing code which it is claiming to "fix."

Here's my favorite so far.

--- cdr.py  (original)
+++ cdr.py  (refactored)
@@ -36,15 +36,15 @@
 # ==
 from six import itervalues
 try:
-basestring
+str
 is_python3 = False
 base64encode = base64.encodestring
 base64decode = base64.decodestring
 except:
 base64encode = base64.encodebytes
 base64decode = base64.decodebytes
-basestring = (str, bytes)
-unicode = str
+str = (str, bytes)
+str = str
 is_python3 = True

We wrote this following the example of comparable techniques in 
http://python-future.org/compatible_idioms.html and similar guides to an 
upgrade path. Seems we're being punished for taking the trouble to make our 
code work with Python 2 and 3 during the transition period. :-(

It's hard to see how this conversion resulted in something better than what we 
already had.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread Richard Damon
On 9/1/19 4:02 PM, Spencer Du wrote:
> Hi 
>
> I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a 
> GUI file if the file exists in current directory. I want to add the file name 
> to a list when a file is imported and for each subsequent file that is 
> imported I want the file name to be imported to the same list and print the 
> list or create a new list but with the imported file named added to list 
> which has the existing file names that have already been imported. I was 
> wondering how I do this. By the way run GUI.py to test this and test1.py and 
> test2.py are the files which can be used to import GUI . 

To make the list persistent you need to create it as a module global or
as a class member of a persistent object (like your MainWindow)

-- 
Richard Damon

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


[issue38001] Unexpected behaviour of 'is' operator

2019-09-01 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Further to Karthikeyan Singaravelan comment, the behaviour you see is 
absolutely correct. The operator isn't behaving differently, it is reporting 
precisely the truth.

The ``is`` operator tests for object identity, not equality. Python makes no 
promises about object identity of literals. If you use an immutable literal in 
two places:

a = 1234
b = 1234

the interpreter is free to use the same object for both a and b, or different 
objects. The only promise made is that ``a == b``.

The Python interpreter currently caches some small integers for re-use, but 
that's not a language guarantee, and is subject to change without warning. It 
has changed in the past, and could change again in the future.

The bottom line is that you shouldn't use ``is`` except to test for object 
identity, e.g. ``if obj is None``.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread MRAB

On 2019-09-01 21:02, Spencer Du wrote:

Hi

I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a 
GUI file if the file exists in current directory. I want to add the file name to a list 
when a file is imported and for each subsequent file that is imported I want the file 
name to be imported to the same list and print the list or create a new list but with the 
imported file named added to list which has the existing file names that have already 
been imported. I was wondering how I do this. By the way run GUI.py to test this and 
test1.py and test2.py are the files which can be used to import GUI .

GUI.py

[snip]
import json



[snip]

 def loadGUI(self):
 print("Searching file", self.fileName_UI)
 try:
 module = __import__(self.fileName_UI)
 my_class = getattr(module, "SubWindow")

 sub = QMdiSubWindow()

 sub.setWidget(my_class())
 sub.setWindowTitle("New GUI:  " + self.fileName_UI)
 self.mdi.addSubWindow(sub)
 sub.show()

 print("creating new instance " + self.fileName_UI)
 client = device("Device")
 client.run()

 client.loop_start()  # start the loop
 device_message = self.fileName_UI
 time.sleep(2)
 print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI")
 client.subscribe("microscope/light_sheet_microscope/UI")
 print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI")
 client.publish("microscope/light_sheet_microscope/UI", json.dumps({"type": "device", 
"payload":{"name": self.fileName_UI, "cmd": "adding device"}}, indent=2))
 time.sleep(1)  # wait
 client.loop_stop()  # stop the loop
 print("Device added" + "\n")


This is a local name, local to the method.


 listofdevice = []
 listofdevice.append(self.fileName_UI)
 print(listofdevice)


You could store the list in a file: read the current list from the file 
and then write the modified list to the file. The file won't exist 
initially, so you can treat that as the list being empty.


You're already importing the json module, so you could read/write it as 
JSON.


Also, _don't_ use a "bare" except like here:


 except:


because catches _all_ exceptions. Instead, catch only those you're 
prepared to handle.


[snip]
--
https://mail.python.org/mailman/listinfo/python-list


Re: Need help: integrating unittest with setuptools

2019-09-01 Thread Sayth Renshaw
On Monday, 2 September 2019 04:44:29 UTC+10, YuXuan Dong  wrote:
> Hi, everybody:
> 
> I have met a problem while I ran `python setup.py test`:
> 
>   unittest.case.SkipTest: No module named 'winreg'
> 
> I ran the command in MacOS and my project is written for only UNIX-like 
> systems. I don't use any Windows-specified API. How dose `winreg` come here?
> 
> In my `setup.py`:
> 
>   test_suite="test"
> 
> In my `test/test.py`:
> 
>   import unittest
> 
>   class TestAll(unittest.TestCase):
>   def testall(self):
>   return None
> 
> It works if I ran `python -m uniittest test.py` alone but raises the above 
> exception if I ran `python setup.py test`.
> 
> I'm working on this for the whole day, searching for every keywords I can 
> think of with Google but can't find why or how. Could you help me? Thanks.
> 
> --
> YX. D.

Does this help?
https://stackoverflow.com/questions/4320761/importerror-no-module-named-winreg-python3

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


Re: How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread Sayth Renshaw
On Monday, 2 September 2019 06:02:58 UTC+10, Spencer Du  wrote:
> Hi 
> 
> I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a 
> GUI file if the file exists in current directory. I want to add the file name 
> to a list when a file is imported and for each subsequent file that is 
> imported I want the file name to be imported to the same list and print the 
> list or create a new list but with the imported file named added to list 
> which has the existing file names that have already been imported. I was 
> wondering how I do this. By the way run GUI.py to test this and test1.py and 
> test2.py are the files which can be used to import GUI . 
> 
> GUI.py 
> 
> import logging 
> from datetime import timedelta 
> import time 
> from thespian.actors import * 
> from transitions import Machine 
> import paho.mqtt.client as mqtt 
> import importlib 
> import os.path 
> import sys 
> from PyQt5.QtWidgets import * 
> from PyQt5.QtCore import * 
> from PyQt5 import QtWidgets, uic 
> from mqtt import * 
> import json 
> 
> class MainWindow(QtWidgets.QMainWindow): 
> def __init__(self,parent = None): 
> QMainWindow.__init__(self) 
> super(MainWindow, self).__init__(parent) 
> self.mdi = QMdiArea() 
> self.setCentralWidget(self.mdi) 
> 
> self.setMinimumSize(QSize(800, 600)) 
> self.setWindowTitle("PyQt button example - 
> pythonprogramminglanguage.com") 
> 
> pybutton = QPushButton('Add device', self) 
> 
> pybutton.clicked.connect(self.importbutton) 
> 
> pybutton.move(100, 400) 
> pybutton.resize(150, 32) 
> 
> self.textbox = QLineEdit(self) 
> self.textbox.move(100,350) 
> self.textbox.resize(100, 32) 
> 
> self.fileName_UI = "" 
> 
> def importbutton(self): 
> self.fileName_UI = self.textbox.text() 
> self.loadGUI() 
> 
> def getGUIFilename(self): 
> return self.fileName_UI 
> 
> def loadGUI(self): 
> print("Searching file", self.fileName_UI)   
> try: 
> module = __import__(self.fileName_UI) 
> my_class = getattr(module, "SubWindow") 
> 
> sub = QMdiSubWindow() 
> 
> sub.setWidget(my_class()) 
> sub.setWindowTitle("New GUI:  " + self.fileName_UI) 
> self.mdi.addSubWindow(sub) 
> sub.show() 
> 
> print("creating new instance " + self.fileName_UI) 
> client = device("Device") 
> client.run() 
> 
> client.loop_start()  # start the loop 
> device_message = self.fileName_UI 
> time.sleep(2) 
> print("Subscribing to topic", 
> "microscope/light_sheet_microscope/UI") 
> client.subscribe("microscope/light_sheet_microscope/UI") 
> print("Publishing message to topic", 
> "microscope/light_sheet_microscope/UI") 
> client.publish("microscope/light_sheet_microscope/UI", 
> json.dumps({"type": "device", "payload":{"name": self.fileName_UI, "cmd": 
> "adding device"}}, indent=2)) 
> time.sleep(1)  # wait 
> client.loop_stop()  # stop the loop 
> print("Device added" + "\n") 
> listofdevice = [] 
> listofdevice.append(self.fileName_UI) 
> print(listofdevice) 
> except: 
> print("creating new instance " + self.fileName_UI) 
> client = device("Device") 
> client.run() 
> 
> client.loop_start()  # start the loop 
> device_message = self.fileName_UI 
> time.sleep(2) 
> print("Subscribing to topic", 
> "microscope/light_sheet_microscope/UI") 
> client.subscribe("microscope/light_sheet_microscope/UI") 
> print("Publishing message to topic", 
> "microscope/light_sheet_microscope/UI") 
> client.publish("microscope/light_sheet_microscope/UI", 
> json.dumps({"type": "device", "payload":{"name": self.fileName_UI}}, 
> indent=2)) 
> time.sleep(2)  # wait 
> client.loop_stop()  # stop the loop 
> print(device_message + ".py " + "file doesn't exist") 
> print("Device not added") 
> if __name__ == "__main__": 
> app = QApplication(sys.argv) 
> mainWin = MainWindow() 
> mainWin.show() 
> publishedMessage = mainWin.getGUIFilename() 
> sys.exit(app.exec_()) 
> 
> MQTT.py 
> import logging 
> from datetime import timedelta 
> import time 
> from thespian.actors import * 
> from transitions import Machine 
> import paho.mqtt.client as mqtt 
> import importlib 
> import os.path 
> import sys 
> from PyQt5.QtWidgets import * 
> from PyQt5.QtCore import * 
> from PyQt5 import QtWidgets, uic 
> 
> class device(mqtt.Client): 
> def on_connect(self, mqttc, obj, flags, rc): 
> if rc == 0: 
> print("Connected to broker") 
> else: 
> 

[issue38003] Incorrect "fixing" of isinstance tests for basestring

2019-09-01 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

https://docs.python.org/3.0/whatsnew/3.0.html

> The builtin basestring abstract type was removed. Use str instead. The str 
> and bytes types don’t have functionality enough in common to warrant a shared 
> base class. The 2to3 tool (see below) replaces every occurrence of basestring 
> with str.

For a longer explanation of this and other changes you might find below link 
useful. In Python 2 str is used to represent both text and bytes. Hence to 
check the type is str in python 2 you have to check it to be basestring and 
then check it to be unicode. In python 3 all strings are unicode with str and 
bytes being two different types. Hence there is no basestring and unicode 
string since they are both unified to be str itself in Python 3.

https://portingguide.readthedocs.io/en/latest/strings.html

Hope this helps.

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: IDLE not working

2019-09-01 Thread Terry Reedy

On 9/1/2019 1:06 AM, Anoushka wrote:

Even after repairing my python IDLE, my IDLE is not working. It says sub 
process connection error. Kindly help me to resolve. I want to recover my 
previous work.

Sent from Mail for Windows 10


Select Help => IDLE Help and read the Startup Failure section.


--
Terry Jan Reedy

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


Re: "Edit With Python" option missing

2019-09-01 Thread Terry Reedy

On 8/31/2019 4:54 AM, Akash verma wrote:

"Edit With Python" option missing from message context when right clicked
with mouse .


'Edit with Python' does not make much sense since Python is not an editor.

What OS?  If Windows, do you possible mean 'Edit with IDLE'?  If so, 
that requires installing IDLE.



--
Terry Jan Reedy

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


[issue38003] Incorrect "fixing" of isinstance tests for basestring

2019-09-01 Thread Bob Kline


New submission from Bob Kline :

We are attempting to convert a large Python 2 code base. Following the guidance 
of the official documentation 
(https://docs.python.org/2/library/functions.html#basestring) we created tests 
in many, many places that look like this:

if isinstance(value, basestring):
if not isinstance(value, unicode):
value = value.decode(encoding)
else:
some other code

It seems that the 2to3 tool is unaware that replacing basestring with str in 
such cases will break the software.

Here's an example.

$ 2to3 repro.py
...
--- repro.py(original)
+++ repro.py(refactored)
@@ -1,8 +1,8 @@
 from frobnitz import transform

 def foo(value, encoding=None):
-if isinstance(value, basestring):
-if not isinstance(value, unicode):
+if isinstance(value, str):
+if not isinstance(value, str):
 value = value.decode(encoding or "utf-8")
 return value
 else:

Help me understand how this "fix" results in the correct behavior.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 350964
nosy: bkline
priority: normal
severity: normal
status: open
title: Incorrect "fixing" of isinstance tests for basestring
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: IDLE missing !

2019-09-01 Thread Piet van Oostrum
Alex  writes:

> I tried downloading the 3.7.4 version of python and and then tried to
> install tensorflow but found that TF is only available for version
> 3.5.x.
> Thus uninstalled the 3.7.4. version and tried downloading multiple 3.5.x
> version while all of them downloaded but I couldn’d find the IDLE shell
> with them.

Well, on MacOS 10.13.6 (High Sierra) tensorflow 1.14.0 does install on Python 
3.7.4, and it also runs. It does give some warnings about deprecations, however.

There is also a version 2.0RC which installs and runs without warnings.
-- 
Piet van Oostrum 
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37995] Multiline ast.dump()

2019-09-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

It would be great is the tool wasn't tightly bound to our particular AST and 
could be used for any hand-rolled AST.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37995] Multiline ast.dump()

2019-09-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

FWIW, I wrote a generic AST pretty printer for a personal compiler project (see 
attached file).  Perhaps it can be adapted to the Python AST.

## Example input ###

Program(procs=[Procedure(name='FACTORIAL', params=['N'], is_test=False, 
body=Block(blocknum=0, stmts=[Assign(name=Output(is_bool=False), 
value=Number(x=1)), Assign(name=Cell(i=0), value=Number(x=1)), 
Loop(times=Id(name='N'), fixed=False, body=Block(blocknum=1, 
stmts=[Assign(name=Output(is_bool=False), 
value=BinOp(value1=Output(is_bool=False), op='x', value2=Cell(i=0))), 
Assign(name=Cell(i=0), value=BinOp(value1=Cell(i=0), op='+', 
value2=Number(x=1)))]))]))], calls=[])

## Example output ###

Program(
   procs = [
  Procedure(
 name = 'FACTORIAL',
 params = [
'N'
 ],
 is_test = False,
 body = Block(
blocknum = 0,
stmts = [
   Assign(
  name = Output(is_bool=False),
  value = Number(x=1)
   ),
   Assign(
  name = Cell(i=0),
  value = Number(x=1)
   ),
   Loop(
  times = Id(name='N'),
  fixed = False,
  body = Block(
 blocknum = 1,
 stmts = [
Assign(
   name = Output(is_bool=False),
   value = BinOp(
  value1 = Output(is_bool=False),
  op = 'x',
  value2 = Cell(i=0)
   )
),
Assign(
   name = Cell(i=0),
   value = BinOp(
  value1 = Cell(i=0),
  op = '+',
  value2 = Number(x=1)
   )
)
 ]
  )
   )
]
 )
  )
   ],
   calls = []
)

--
Added file: https://bugs.python.org/file48579/ast_bloop.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24416] Have date.isocalendar() return a structseq instance

2019-09-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Why close this?  Having isocalendar() return a structseq instance would be a 
nice improvement.  It is what structseq was designed for.

Dong-hee Na, if you want to make a fresh PR for this and bring it to fruition, 
I would be happy to review and apply it.

I'm changing the title to structseq.  It was a distractor to mention 
collections.namedtuple() at all -- that would have been more appropriate for 
pure python code.

--
assignee: belopolsky -> rhettinger
title: Return a namedtuple from date.isocalendar() -> Have date.isocalendar() 
return a structseq instance

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38002] 'ModifiedInterpreter' object has no attribute 'interp'

2019-09-01 Thread Raymond Hettinger


New submission from Raymond Hettinger :

Here's a new traceback I haven't seen before.  I only see these at the end of a 
session, so I don't know which steps triggered it.

$ python3.8 -m idlelib.idle tmp_pretty_fact_ast.py
Exception in Tkinter callback
Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/__init__.py",
 line 1883, in __call__
return self.func(*args)
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/idlelib/runscript.py",
 line 173, in _run_module_event
interp.runcode(code)
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/idlelib/pyshell.py",
 line 756, in runcode
self.interp.restart_subprocess()
AttributeError: 'ModifiedInterpreter' object has no attribute 'interp'

--
assignee: terry.reedy
components: IDLE
messages: 350961
nosy: rhettinger, terry.reedy
priority: normal
severity: normal
status: open
title: 'ModifiedInterpreter' object has no attribute 'interp'
versions: Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread Spencer Du
Hi 

I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a 
GUI file if the file exists in current directory. I want to add the file name 
to a list when a file is imported and for each subsequent file that is imported 
I want the file name to be imported to the same list and print the list or 
create a new list but with the imported file named added to list which has the 
existing file names that have already been imported. I was wondering how I do 
this. By the way run GUI.py to test this and test1.py and test2.py are the 
files which can be used to import GUI . 

GUI.py 

import logging 
from datetime import timedelta 
import time 
from thespian.actors import * 
from transitions import Machine 
import paho.mqtt.client as mqtt 
import importlib 
import os.path 
import sys 
from PyQt5.QtWidgets import * 
from PyQt5.QtCore import * 
from PyQt5 import QtWidgets, uic 
from mqtt import * 
import json 

class MainWindow(QtWidgets.QMainWindow): 
def __init__(self,parent = None): 
QMainWindow.__init__(self) 
super(MainWindow, self).__init__(parent) 
self.mdi = QMdiArea() 
self.setCentralWidget(self.mdi) 

self.setMinimumSize(QSize(800, 600)) 
self.setWindowTitle("PyQt button example - 
pythonprogramminglanguage.com") 

pybutton = QPushButton('Add device', self) 

pybutton.clicked.connect(self.importbutton) 

pybutton.move(100, 400) 
pybutton.resize(150, 32) 

self.textbox = QLineEdit(self) 
self.textbox.move(100,350) 
self.textbox.resize(100, 32) 

self.fileName_UI = "" 

def importbutton(self): 
self.fileName_UI = self.textbox.text() 
self.loadGUI() 

def getGUIFilename(self): 
return self.fileName_UI 

def loadGUI(self): 
print("Searching file", self.fileName_UI)   
try: 
module = __import__(self.fileName_UI) 
my_class = getattr(module, "SubWindow") 

sub = QMdiSubWindow() 

sub.setWidget(my_class()) 
sub.setWindowTitle("New GUI:  " + self.fileName_UI) 
self.mdi.addSubWindow(sub) 
sub.show() 

print("creating new instance " + self.fileName_UI) 
client = device("Device") 
client.run() 

client.loop_start()  # start the loop 
device_message = self.fileName_UI 
time.sleep(2) 
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI") 
client.subscribe("microscope/light_sheet_microscope/UI") 
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI") 
client.publish("microscope/light_sheet_microscope/UI", 
json.dumps({"type": "device", "payload":{"name": self.fileName_UI, "cmd": 
"adding device"}}, indent=2)) 
time.sleep(1)  # wait 
client.loop_stop()  # stop the loop 
print("Device added" + "\n") 
listofdevice = [] 
listofdevice.append(self.fileName_UI) 
print(listofdevice) 
except: 
print("creating new instance " + self.fileName_UI) 
client = device("Device") 
client.run() 

client.loop_start()  # start the loop 
device_message = self.fileName_UI 
time.sleep(2) 
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI") 
client.subscribe("microscope/light_sheet_microscope/UI") 
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI") 
client.publish("microscope/light_sheet_microscope/UI", 
json.dumps({"type": "device", "payload":{"name": self.fileName_UI}}, indent=2)) 
time.sleep(2)  # wait 
client.loop_stop()  # stop the loop 
print(device_message + ".py " + "file doesn't exist") 
print("Device not added") 
if __name__ == "__main__": 
app = QApplication(sys.argv) 
mainWin = MainWindow() 
mainWin.show() 
publishedMessage = mainWin.getGUIFilename() 
sys.exit(app.exec_()) 

MQTT.py 
import logging 
from datetime import timedelta 
import time 
from thespian.actors import * 
from transitions import Machine 
import paho.mqtt.client as mqtt 
import importlib 
import os.path 
import sys 
from PyQt5.QtWidgets import * 
from PyQt5.QtCore import * 
from PyQt5 import QtWidgets, uic 

class device(mqtt.Client): 
def on_connect(self, mqttc, obj, flags, rc): 
if rc == 0: 
print("Connected to broker") 
else: 
print("Connection failed") 

# mqttc.subscribe("microscope/light_sheet_microscope/UI") 

def on_message(self, mqttc, userdata, message): 
msg = str(message.payload.decode("utf-8")) 
print("message recieved= " + msg) 
# print("File which you want to import(with .py extension)") 
print("message topic=", 

How to create list for stuff inside mqtt and GUI?.

2019-09-01 Thread Spencer Du via Python-list
Hi 

I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a 
GUI file if the file exists in current directory. I want to add the file name 
to a list when a file is imported and for each subsequent file that is imported 
I want the file name to be imported to the same list and print the list or 
create a new list but with the imported file named added to list which has the 
existing file names that have already been imported. I was wondering how I do 
this. By the way run GUI.py to test this.

GUI.py

import logging
from datetime import timedelta
import time
from thespian.actors import *
from transitions import Machine
import paho.mqtt.client as mqtt
import importlib
import os.path
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtWidgets, uic
from mqtt import *
import json

class MainWindow(QtWidgets.QMainWindow):
def __init__(self,parent = None):
QMainWindow.__init__(self)
super(MainWindow, self).__init__(parent)
self.mdi = QMdiArea()
self.setCentralWidget(self.mdi)

self.setMinimumSize(QSize(800, 600))
self.setWindowTitle("PyQt button example - 
pythonprogramminglanguage.com")

pybutton = QPushButton('Add device', self)

pybutton.clicked.connect(self.importbutton)

pybutton.move(100, 400)
pybutton.resize(150, 32)

self.textbox = QLineEdit(self)
self.textbox.move(100,350)
self.textbox.resize(100, 32)

self.fileName_UI = ""

def importbutton(self):
self.fileName_UI = self.textbox.text()
self.loadGUI()

def getGUIFilename(self):
return self.fileName_UI

def loadGUI(self):
print("Searching file", self.fileName_UI)   
try:
module = __import__(self.fileName_UI)
my_class = getattr(module, "SubWindow")

sub = QMdiSubWindow()

sub.setWidget(my_class())
sub.setWindowTitle("New GUI:  " + self.fileName_UI)
self.mdi.addSubWindow(sub)
sub.show()

print("creating new instance " + self.fileName_UI)
client = device("Device")
client.run()

client.loop_start()  # start the loop
device_message = self.fileName_UI
time.sleep(2)
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI")
client.subscribe("microscope/light_sheet_microscope/UI")
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI")
client.publish("microscope/light_sheet_microscope/UI", 
json.dumps({"type": "device", "payload":{"name": self.fileName_UI, "cmd": 
"adding device"}}, indent=2))
time.sleep(1)  # wait
client.loop_stop()  # stop the loop
print("Device added" + "\n")
listofdevice = []
listofdevice.append(self.fileName_UI)
print(listofdevice) 
except:
print("creating new instance " + self.fileName_UI)
client = device("Device")
client.run()

client.loop_start()  # start the loop
device_message = self.fileName_UI
time.sleep(2)
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI")
client.subscribe("microscope/light_sheet_microscope/UI")
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI")
client.publish("microscope/light_sheet_microscope/UI", 
json.dumps({"type": "device", "payload":{"name": self.fileName_UI}}, indent=2))
time.sleep(2)  # wait
client.loop_stop()  # stop the loop
print(device_message + ".py " + "file doesn't exist")
print("Device not added")
if __name__ == "__main__":
app = QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
publishedMessage = mainWin.getGUIFilename()
sys.exit(app.exec_())

MQTT.py
import logging
from datetime import timedelta
import time
from thespian.actors import *
from transitions import Machine
import paho.mqtt.client as mqtt
import importlib
import os.path
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtWidgets, uic

class device(mqtt.Client):
def on_connect(self, mqttc, obj, flags, rc):
if rc == 0:
print("Connected to broker")
else:
print("Connection failed")

# mqttc.subscribe("microscope/light_sheet_microscope/UI")

def on_message(self, mqttc, userdata, message):
msg = str(message.payload.decode("utf-8"))
print("message recieved= " + msg)
# print("File which you want to import(with .py extension)")
print("message topic=", message.topic)
print("message qos=", message.qos)
print("message retain flag=", message.retain)

def run(self):
self.connect("broker.hivemq.com", 1883, 60)


Re: Issue About Install pyinstaller

2019-09-01 Thread MRAB

On 2019-09-01 17:15, Mehmet Furkan ÇOLAK wrote:

Have a good day sir,
I use python so much, I try to install pyinstaller in order to covert .py files 
to .exe files
I did “cmd > pip install pyinstaller > enter”

from C:\Users\Furkan ÇOLAK\AppData\Local\Programs\Python\Python37-32
but there isnt Script folder.

İn cmd I see this kind of ERROR
'pip' is not recognized as an internal or external command,
operable program or batch file.

So in order to install pyinstaller what should I do?
Best regards



Try running the pip module with the Python launcher instead:

py -m pip install pyinstaller
--
https://mail.python.org/mailman/listinfo/python-list


Re: 'python' is not recognized as an internal or external command

2019-09-01 Thread MRAB

On 2019-08-31 10:13, G Kishore wrote:

Hi Team,

I was installing python in my new windows 10 machine and cpuld able to access 
python from command window when the location is where I have installed python.

The same I have tried to enter the command from Desktop location but "'python' is 
not recognized as an internal or external command,"  error is thrown. Done the path 
variable in the environmental variables as the location where python is installed.


Try using the Python launcher instead. It's called "py".
--
https://mail.python.org/mailman/listinfo/python-list


Re: Using exec with embedded python interpreter 3.7

2019-09-01 Thread MRAB

On 2019-08-31 13:16, Eko palypse wrote:

I've already sent this through mail yesterday but it doesn't appear here, maybe 
because of the help word in the content. Please execute in case it appears a 
second time.


Hello,
I'm creating a notepad++ plugin which hosts an embedded python interpreter by 
using cffi to build the dll.
So far so good. One obstacle I've found is that I'm not able to use 
exec(help(object)) in order to get the wanted info from the object.

The error I get is:

Traceback (most recent call last):
   File "", line 131, in run_code
   File "", line 1, in 
   File "D:\...\Python\Python37_64\Lib\_sitebuiltins.py", line 103, in __call__
 return pydoc.help(*args, **kwds)
   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1895, in __call__
 self.help(request)
   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1954, in help
 else: doc(request, 'Help on %s:', output=self._output)
   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1674, in doc
 pager(render_doc(thing, title, forceload))
   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1451, in pager
 pager(text)
   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1576, in plainpager
 sys.stdout.write(plain(_escape_stdout(text)))
   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1528, in _escape_stdout
 return text.encode(encoding, 'backslashreplace').decode(encoding)
TypeError: encode() argument 1 must be str, not method

If I encase the object with quotes then I do get the info that no documentation
is found for that object.

1. It doesn't feel right to encase the object with quotes. I don't have to do 
this using the standard python interpreter shell. What did I miss?

2. If it is needed to use the encased way, why don't it show the help info?
The object class contains the module, class and functions doc strings, what did 
I miss here?

I don't understand the "exec(help(object))" bit. help(object) print the 
help and returns None, so why exec(None)?

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


Re: IDLE missing !

2019-09-01 Thread MRAB

On 2019-09-01 11:53, Alex wrote:

I tried downloading the 3.7.4 version of python and and then tried to install 
tensorflow but found that TF is only available for version 3.5.x.
Thus uninstalled the 3.7.4. version and tried downloading multiple 3.5.x 
version while all of them downloaded but I couldn’d find the IDLE shell with 
them.
They do get installed into the system but the IDLE is not installed.
what should I do about it ?

It should be in a subfolder of Python's folder, for example: 
C:\Python35\Lib\idlelib\idle.bat

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


Re: Python 3.7.4 on win 7

2019-09-01 Thread MRAB

On 2019-08-30 13:25, Mohammad Arif Samana wrote:

Dear sir,
I am installing the above version of python on my pc with win7 as my
operating system. But I am constantly receiving error messages. What could
be the problem and remedy for that. Kindly update me as I am facing
problems for my studies. Also brief me about Anaconda3. Its not installing
on window 7, is there any bugs.


What do the error messages say?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Using exec with embedded python interpreter 3.7

2019-09-01 Thread Peter Otten
Eko palypse wrote:

> I've already sent this through mail yesterday but it doesn't appear here,
> maybe because of the help word in the content. Please execute in case it
> appears a second time.
> 
> 
> Hello,
> I'm creating a notepad++ plugin which hosts an embedded python interpreter
> by using cffi to build the dll. So far so good. One obstacle I've found is
> that I'm not able to use exec(help(object)) in order to get the wanted
> info from the object.
> 
> The error I get is:
> 
> Traceback (most recent call last):
>   File "", line 131, in run_code
>   File "", line 1, in 
>   File "D:\...\Python\Python37_64\Lib\_sitebuiltins.py", line 103, in
>   __call__
> return pydoc.help(*args, **kwds)
>   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1895, in __call__
> self.help(request)
>   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1954, in help
> else: doc(request, 'Help on %s:', output=self._output)
>   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1674, in doc
> pager(render_doc(thing, title, forceload))
>   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1451, in pager
> pager(text)
>   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1576, in plainpager
> sys.stdout.write(plain(_escape_stdout(text)))
>   File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1528, in
>   _escape_stdout
> return text.encode(encoding, 'backslashreplace').decode(encoding)
> TypeError: encode() argument 1 must be str, not method

The traceback suggests that sys.stdout was replaced with a custom object 
that has a method stdout.encoding() rather than the expected stdout.encoding  
attribute of type str.

> If I encase the object with quotes then I do get the info that no
> documentation is found for that object.
> 
> 1. It doesn't feel right to encase the object with quotes. I don't have to
> do this using the standard python interpreter shell. What did I miss?
> 
> 2. If it is needed to use the encased way, why don't it show the help
> info? The object class contains the module, class and functions doc
> strings, what did I miss here?
> 
> Thank you
> Eren


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


Issue About Install pyinstaller

2019-09-01 Thread Mehmet Furkan ÇOLAK
Have a good day sir, 
I use python so much, I try to install pyinstaller in order to covert .py files 
to .exe files
I did “cmd > pip install pyinstaller > enter”

from C:\Users\Furkan ÇOLAK\AppData\Local\Programs\Python\Python37-32
but there isnt Script folder.

İn cmd I see this kind of ERROR
'pip' is not recognized as an internal or external command,
operable program or batch file.

So in order to install pyinstaller what should I do?
Best regards


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


Need help: integrating unittest with setuptools

2019-09-01 Thread YuXuan Dong
Hi, everybody:

I have met a problem while I ran `python setup.py test`:

unittest.case.SkipTest: No module named 'winreg'

I ran the command in MacOS and my project is written for only UNIX-like 
systems. I don't use any Windows-specified API. How dose `winreg` come here?

In my `setup.py`:

test_suite="test"

In my `test/test.py`:

import unittest

class TestAll(unittest.TestCase):
def testall(self):
return None

It works if I ran `python -m uniittest test.py` alone but raises the above 
exception if I ran `python setup.py test`.

I'm working on this for the whole day, searching for every keywords I can think 
of with Google but can't find why or how. Could you help me? Thanks.

--
YX. D.

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


Re: "Edit With Python" option missing

2019-09-01 Thread DL Neil via Python-list

Hi Aakash,

On 31/08/19 8:54 PM, Akash verma wrote:

"Edit With Python" option missing from message context when right clicked
with mouse .


There are two stages to working with a Python program: editing the 
source-code, and executing the program.


For the first, most use a text editor/IDE, eg Sublime Text, PyCharm. 
Although Python comes with "Idle" as a built-in editor, plus the REPL. 
Accordingly, you will want to set the (right-click) context menu for the 
.py file-type/extension to open your chosen editor (if it's not already).


In the second case, it depends very much upon which operating 
system/editor combination you are using. Most of the better editors have 
a 'magic button' to do the job. In case you are using MS-Windows (I 
don't!) please review https://docs.python.org/3.3/using/windows.html


In the case of executing a program without editing the code, most of us 
utilise 'the command line', eg


python3 source.py


--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


IDLE not working

2019-09-01 Thread Anoushka
Even after repairing my python IDLE, my IDLE is not working. It says sub 
process connection error. Kindly help me to resolve. I want to recover my 
previous work.

Sent from Mail for Windows 10

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


Re: pandas loc on str lower for column comparison

2019-09-01 Thread Sayth Renshaw



I've created a share doc same structure anon data from my google drive.

https://drive.google.com/file/d/0B28JfFTPNr_lckxQRnFTRF9UTEFYRUVqRWxCNVd1VEZhcVNr/view?usp=sharing

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


PYTHON DIDNT DETECTED

2019-09-01 Thread АРТЁМ БОЗАДЖИ via Python-list

Traceback (most recent call last):
File "", line 1, in 
NameError: name 'python' is not defined and more 
C:\Users\VeNoMD>python -v
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # 
import '_warnings' # 
import '_weakref' # 
# installing zipimport hook
import 'zipimport' # 
# installed zipimport hook
import '_frozen_importlib_external' # 
import '_io' # 
import 'marshal' # 
import 'nt' # 
import _thread # previously loaded ('_thread')
import '_thread' # 
import _weakref # previously loaded ('_weakref')
import '_weakref' # 
import 'winreg' # 
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\__pycache__\__init__.cpython-37.pyc
 matches 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\__init__.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\encodings\\__pycache__\\__init__.cpython-37.pyc'
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\codecs.cpython-37.pyc
 matches C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\codecs.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\__pycache__\\codecs.cpython-37.pyc'
import '_codecs' # 
import 'codecs' # <_frozen_importlib_external.SourceFileLoader object at 
0x031B8E90>
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\__pycache__\aliases.cpython-37.pyc
 matches 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\aliases.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\encodings\\__pycache__\\aliases.cpython-37.pyc'
import 'encodings.aliases' # <_frozen_importlib_external.SourceFileLoader 
object at 0x031D00D0>
import 'encodings' # <_frozen_importlib_external.SourceFileLoader object at 
0x031B8770>
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\__pycache__\utf_8.cpython-37.pyc
 matches 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\utf_8.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\encodings\\__pycache__\\utf_8.cpython-37.pyc'
import 'encodings.utf_8' # <_frozen_importlib_external.SourceFileLoader object 
at 0x031DAF70>
import '_signal' # 
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\__pycache__\latin_1.cpython-37.pyc
 matches 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\encodings\latin_1.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\encodings\\__pycache__\\latin_1.cpython-37.pyc'
import 'encodings.latin_1' # <_frozen_importlib_external.SourceFileLoader 
object at 0x031DF1D0>
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\io.cpython-37.pyc
 matches C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\io.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\__pycache__\\io.cpython-37.pyc'
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\abc.cpython-37.pyc
 matches C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\abc.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\__pycache__\\abc.cpython-37.pyc'
import '_abc' # 
import 'abc' # <_frozen_importlib_external.SourceFileLoader object at 
0x031DF430>
import 'io' # <_frozen_importlib_external.SourceFileLoader object at 0x031DF290>
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\site.cpython-37.pyc
 matches C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\site.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\__pycache__\\site.cpython-37.pyc'
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\os.cpython-37.pyc
 matches C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\os.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\__pycache__\\os.cpython-37.pyc'
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\stat.cpython-37.pyc
 matches C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\stat.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\__pycache__\\stat.cpython-37.pyc'
import '_stat' # 
import 'stat' # <_frozen_importlib_external.SourceFileLoader object at 
0x032F1E50>
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\ntpath.cpython-37.pyc
 matches C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\ntpath.py
# code object from 
'C:\\Users\\VeNoMD\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\__pycache__\\ntpath.cpython-37.pyc'
# 
C:\Users\VeNoMD\AppData\Local\Programs\Python\Python37-32\lib\__pycache__\genericpath.cpython-37.pyc
 matches 

IDLE missing !

2019-09-01 Thread Alex
I tried downloading the 3.7.4 version of python and and then tried to install 
tensorflow but found that TF is only available for version 3.5.x.
Thus uninstalled the 3.7.4. version and tried downloading multiple 3.5.x 
version while all of them downloaded but I couldn’d find the IDLE shell with 
them.
They do get installed into the system but the IDLE is not installed.
what should I do about it ?

Regrards,
Alex

Sent from Mail for Windows 10

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


ssl certificate issue while installing Django on y windows 64 bit os

2019-09-01 Thread mohd zak



Sent from Mail for Windows 10

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


Re: open, close

2019-09-01 Thread Max Zettlmeißl via Python-list
On Sat, Aug 31, 2019 at 3:43 PM Piet van Oostrum  wrote:
>
> There is a difference here with the construct that the OP mentioned:
>
>   lines = open("foo.txt").readlines()
>
> In that case the file COULD be closed, but there is no guarantee. It depends 
> on garbage collection.
> In your case the file will not be closed as long as there is still a 
> reference to it (as in f). When f disappears and all copies of it as well, 
> the file COULD be closed similarly.
>

Yes, that is correct. I thought about mentioning the garbage
collection and the extra binding for f, but eventually it does not
change the conclusion.
The garbage collection is just too unpredictable to rely upon in any
scenario where you would deal with many open descriptors in a short
period of time e.g. when opening and processing files in a loop.
It is not easy to generalise from such simple examples. After all, if
all the program does is process one file and shut down afterwards,
this would not be an aspect to worry about.
-- 
https://mail.python.org/mailman/listinfo/python-list


problem occurring in operating python , after typing only 5-6 programs only is causing problem it has stoped working

2019-09-01 Thread best web site



Sent from Mail for Windows 10

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


it is not working

2019-09-01 Thread ABID NAZIR


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


python-list@python.org

2019-09-01 Thread YuXuan Dong



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


Async subprocess context manager

2019-09-01 Thread Peter Sutton
Hi all,

First time posting! I need an async context manager that ensures a
Process has finished before it `__exit__()`s, either by graceful or
forceful termination, and regardless of cancellation. I've put my code
at the bottom.

I'm relatively new to asyncio, so I'm looking for feedback on any
aspect of the code. Not only correctness, but things like if I'm
handling cancellation correctly or is the a more idiomatic way to go
back this?

Thanks,


Peter.


```
from __future__ import annotations
import asyncio
import time
from contextlib import asynccontextmanager
from typing import AsyncIterator, Optional


@asynccontextmanager
async def terminating(proc: asyncio.subprocess.Process, timeout: float) \
-> AsyncIterator[asyncio.subprocess.Process]:
try:
yield proc
finally:
try:
proc.terminate()
except ProcessLookupError:
pass
else:
start = time.time()
while True:
remaining = timeout - (time.time() - start)
try:
await asyncio.wait_for(proc.wait(), remaining)
except asyncio.CancelledError:
is_done = False
is_cancelled = True
except asyncio.TimeoutError:
is_done = False
is_cancelled = False
break
else:
print('Terminated')
is_done = True
is_cancelled = False
break
if not is_done:
try:
proc.kill()
except ProcessLookupError:
pass
else:
while True:
try:
proc.wait()
except asyncio.CancelledError:
is_cancelled = True
else:
print('Killed')
break
if is_cancelled:
raise asyncio.CancelledError()


async def test(sleep: float) -> None:
proc = await asyncio.create_subprocess_shell('sleep 10')
async with terminating(proc, 1):
await asyncio.sleep(sleep)


async def main():
await test(1)

task = asyncio.create_task(test(1))
task.cancel()
try:
await task
except asyncio.CancelledError:
pass


asyncio.run(main())
```
-- 
https://mail.python.org/mailman/listinfo/python-list


Using exec with embedded python interpreter 3.7

2019-09-01 Thread Eko palypse
I've already sent this through mail yesterday but it doesn't appear here, maybe 
because of the help word in the content. Please execute in case it appears a 
second time.


Hello,
I'm creating a notepad++ plugin which hosts an embedded python interpreter by 
using cffi to build the dll.
So far so good. One obstacle I've found is that I'm not able to use 
exec(help(object)) in order to get the wanted info from the object.

The error I get is:

Traceback (most recent call last):
  File "", line 131, in run_code
  File "", line 1, in 
  File "D:\...\Python\Python37_64\Lib\_sitebuiltins.py", line 103, in __call__
return pydoc.help(*args, **kwds)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1895, in __call__
self.help(request)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1954, in help
else: doc(request, 'Help on %s:', output=self._output)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1674, in doc
pager(render_doc(thing, title, forceload))
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1451, in pager
pager(text)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1576, in plainpager
sys.stdout.write(plain(_escape_stdout(text)))
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1528, in _escape_stdout
return text.encode(encoding, 'backslashreplace').decode(encoding)
TypeError: encode() argument 1 must be str, not method

If I encase the object with quotes then I do get the info that no documentation
is found for that object.

1. It doesn't feel right to encase the object with quotes. I don't have to do 
this using the standard python interpreter shell. What did I miss?

2. If it is needed to use the encased way, why don't it show the help info?
The object class contains the module, class and functions doc strings, what did 
I miss here?

Thank you
Eren
-- 
https://mail.python.org/mailman/listinfo/python-list


'python' is not recognized as an internal or external command

2019-09-01 Thread G Kishore
Hi Team,

I was installing python in my new windows 10 machine and cpuld able to access 
python from command window when the location is where I have installed python.

The same I have tried to enter the command from Desktop location but "'python' 
is not recognized as an internal or external command,"  error is thrown. Done 
the path variable in the environmental variables as the location where python 
is installed.

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


Problem while integrating unittest with setuptools

2019-09-01 Thread YuXuan Dong
Hi, everybody:

I met a problem while I ran `python setup.py test`: 

unittest.case.SkipTest: No module named 'winreg'

I ran the command in MacOS and my project is written for only UNIX-like 
systems. I don't use any Windows-specified API. How dose `winreg` come here?

In my `setup.py`:

test_suite="test"

In my `test/test.py`:

import unittest

class TestAll(unittest.TestCase):
def testall(self):
return None

I'm working on this for the whole day, searched for every keywords I can think 
of with Google but can't find why or how. Could you help me? Thanks.

--
YX. D.

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


"Edit With Python" option missing

2019-09-01 Thread Akash verma
"Edit With Python" option missing from message context when right clicked
with mouse .

I am facing many problems with it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3.7.4 on win 7

2019-09-01 Thread Mohammad Arif Samana
Dear sir,
I am installing the above version of python on my pc with win7 as my
operating system. But I am constantly receiving error messages. What could
be the problem and remedy for that. Kindly update me as I am facing
problems for my studies. Also brief me about Anaconda3. Its not installing
on window 7, is there any bugs.

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


Using exec with embedded python interpreter 3.7

2019-09-01 Thread Eko palypse
Hello,
I'm creating a notepad++ plugin which hosts an embedded python interpreter
by using cffi to build the dll.
So far so good. One obstacle I've found is that I'm not able to use
exec(help(object)) in order to get the wanted info from the object.

The error I get is:

Traceback (most recent call last):
  File "", line 131, in run_code
  File "", line 1, in 
  File "D:\...\Python\Python37_64\Lib\_sitebuiltins.py", line 103, in
__call__
return pydoc.help(*args, **kwds)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1895, in __call__
self.help(request)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1954, in help
else: doc(request, 'Help on %s:', output=self._output)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1674, in doc
pager(render_doc(thing, title, forceload))
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1451, in pager
pager(text)
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1576, in plainpager
sys.stdout.write(plain(_escape_stdout(text)))
  File "D:\...\Python\Python37_64\Lib\pydoc.py", line 1528, in
_escape_stdout
return text.encode(encoding, 'backslashreplace').decode(encoding)
TypeError: encode() argument 1 must be str, not method

If I encase the object with quotes then I do get the info that no
documentation
is found for that object.

1. It doesn't feel right to encase the object with quotes. I don't have to
do this using the standard python interpreter shell. What did I miss?

2. If it is needed to use the encased way, why don't it show the help info?
The object class contains the module, class and functions doc strings, what
did I miss here?

Thank you
Eren
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: open, close

2019-09-01 Thread Barry



> On 1 Sep 2019, at 17:57, MRAB  wrote:
> 
> On 2019-09-01 16:46, Barry wrote:
>>> On 31 Aug 2019, at 15:41, Manfred Lotz  wrote:
>>> When you say COULD this sounds like it is a matter of luck. My thinking
>>> was that USUALLY the file will be closed after the statement because
>>> then the file handle goes out of scope.
>> It all depends on the way any python implementation does its garbage 
>> collection. The file is closed as a side effect of deleting the file object 
>> to reclaiming the memory of the file object.
>> At the start of python 3 people where suprised when files and other 
>> resources where not released at the same time that python 2 released them.
> Is that true?

Yes. I recalling having to fix some code, but that was over 10 years ago.
I have been using python 3 since the alphas of 3.0.

> 
> I thought that it was because other implementations of Python, such as Jython 
> and IronPython, don't use reference counting, so files and other resources 
> aren't necessarily released as soon as an object loses its last reference, 
> and, moreover, it's not required to do so by the language definition.

You can also see delayed rsource freeing with cpython. I think it was
an fd leak and lsof showed the files where not closing. Adding with fixed it.
But it was so long ago...

> 
> Adding the 'with' statement added determinism.

Barry

> 
> See PEP 343 -- The "with" Statement
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Re: open, close

2019-09-01 Thread Chris Angelico
On Mon, Sep 2, 2019 at 3:02 AM MRAB  wrote:
>
> On 2019-09-01 16:46, Barry wrote:
> >
> >
> >> On 31 Aug 2019, at 15:41, Manfred Lotz  wrote:
> >>
> >> When you say COULD this sounds like it is a matter of luck. My thinking
> >> was that USUALLY the file will be closed after the statement because
> >> then the file handle goes out of scope.
> >
> > It all depends on the way any python implementation does its garbage 
> > collection. The file is closed as a side effect of deleting the file object 
> > to reclaiming the memory of the file object.
> >
> > At the start of python 3 people where suprised when files and other 
> > resources where not released at the same time that python 2 released them.
> >
> Is that true?
>
> I thought that it was because other implementations of Python, such as
> Jython and IronPython, don't use reference counting, so files and other
> resources aren't necessarily released as soon as an object loses its
> last reference, and, moreover, it's not required to do so by the
> language definition.
>

Yeah. Given that the PEP introducing the 'with' statement dates back
well before Python 3, I very much doubt it has anything to do with the
3.0 changes.

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


Re: open, close

2019-09-01 Thread MRAB

On 2019-09-01 16:46, Barry wrote:




On 31 Aug 2019, at 15:41, Manfred Lotz  wrote:

When you say COULD this sounds like it is a matter of luck. My thinking
was that USUALLY the file will be closed after the statement because
then the file handle goes out of scope.


It all depends on the way any python implementation does its garbage 
collection. The file is closed as a side effect of deleting the file object to 
reclaiming the memory of the file object.

At the start of python 3 people where suprised when files and other resources 
where not released at the same time that python 2 released them.


Is that true?

I thought that it was because other implementations of Python, such as 
Jython and IronPython, don't use reference counting, so files and other 
resources aren't necessarily released as soon as an object loses its 
last reference, and, moreover, it's not required to do so by the 
language definition.


Adding the 'with' statement added determinism.

See PEP 343 -- The "with" Statement
--
https://mail.python.org/mailman/listinfo/python-list


[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Dong-hee Na


Dong-hee Na  added the comment:

@taleinat @p-ganssle

I am okay with closing this issue without any change.
My initial purpose for this issue was also whether or not to close a long left 
issue.

I am +1 to closing this issue without any change.
Please leave a vote for this issue.
If @taleinat and @p-ganssle agree with closing this issue.
I am going to close this issue!

Thanks always!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: open, close

2019-09-01 Thread Manfred Lotz
On Sun, 1 Sep 2019 16:46:44 +0100
Barry  wrote:

> > On 31 Aug 2019, at 15:41, Manfred Lotz  wrote:
> > 
> > When you say COULD this sounds like it is a matter of luck. My
> > thinking was that USUALLY the file will be closed after the
> > statement because then the file handle goes out of scope.  
> 
> It all depends on the way any python implementation does its garbage
> collection. The file is closed as a side effect of deleting the file
> object to reclaiming the memory of the file object.
> 
> At the start of python 3 people where suprised when files and other
> resources where not released at the same time that python 2 released
> them.
> 

Thanks for this. Very interesting.



-- 
Manfred

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


[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Tal Einat


Tal Einat  added the comment:

Paul, I'm also on the fence regarding the advantage of this.  It's not clear 
that the minor possible benefits outweigh the additional complexity and slight 
backwards-incompatibility (pickling).

Thinking about this further, yes, we'd probably avoid making this change.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Dong-hee Na


Dong-hee Na  added the comment:

@pganssle @serhiy.storchaka

Sounds reasonable on the view of maintaining pure Python and C APIs at the time
Thank you for the explanation.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: open, close

2019-09-01 Thread Barry



> On 31 Aug 2019, at 15:41, Manfred Lotz  wrote:
> 
> When you say COULD this sounds like it is a matter of luck. My thinking
> was that USUALLY the file will be closed after the statement because
> then the file handle goes out of scope.

It all depends on the way any python implementation does its garbage 
collection. The file is closed as a side effect of deleting the file object to 
reclaiming the memory of the file object.

At the start of python 3 people where suprised when files and other resources 
where not released at the same time that python 2 released them.

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


[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Paul Ganssle


Paul Ganssle  added the comment:

> But I'm wondering how the `fromisocalendar` API relates to this patch.
> Rather, wouldn't this patch contribute to improving the usability of the 
> `fromisocalendar` API?

The `fromisocalendar` API relates to this patch only insofar as it is the 
inverse function of `isocalendar` and in some sense it allows specifying the 
parameters by keyword rather by position. I was merely bringing up that we 
didn't choose that API because we thought people would or should want or need 
to specify the individual components by keyword but because we didn't have an 
easy way to maintain the same API in the pure Python and C APIs at the time. By 
contrast, returning a plain tuple from `isocalendar()` is the easier *and* more 
performant thing to do, and given that any benefits seem marginal I'm against 
the switch.

I think that the usability of `fromisoformat` with the output of `isocalendar` 
will be largely unchanged if we were to switch to returning a namedtuple.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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] prematurely?
>

I suspect it was posted as a question despite not being phrased as such.

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


[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

You can use datetime.date.fromisocalendar(*b).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-09-01 Thread Terry Reedy

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] prematurely?



--
Terry Jan Reedy

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


[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Dong-hee Na


Dong-hee Na  added the comment:

@p-ganssle @taleinat

I agree that there are penalties of this patch what you said.
But I'm wondering how the `fromisocalendar` API relates to this patch.
Rather, wouldn't this patch contribute to improving the usability of the 
`fromisocalendar` API?
I would appreciate it if you would generously understand that my background 
knowledge of this module is less than yours.

AS-IS:

>>> year, week, weekday = a.isocalendar()
>>> datetime.date.fromisocalendar(year, week, weekday)
datetime.date(2019, 9, 1)

TO-BE:
>>> b = a.isocalendar()
>>> datetime.date.fromisocalendar(b.year, b.week, b.weekday)
datetime.date(2019, 9, 1)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38001] Unexpected behaviour of 'is' operator

2019-09-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38001] Unexpected behaviour of 'is' operator

2019-09-01 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This will emit a SyntaxWarning in Python 3.8 to use == instead of using is for 
literals. This is not a bug but an implementation detail over caching a range 
of integers at 
https://github.com/python/cpython/blob/1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70/Objects/longobject.c#L19

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38001] Unexpected behaviour of 'is' operator

2019-09-01 Thread Digin Antony


New submission from Digin Antony :

The 'is' operator behave differently on two sets of values 
please find the attachment below

tested environment 
windows 7
python 3.7.3


Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> a=256
>>> b=256
>>> a is b
True
>>> a=257
>>> b=257
>>> a is b
False

--
components: Interpreter Core
files: bug.png
messages: 350952
nosy: Digin Antony
priority: normal
severity: normal
status: open
title: Unexpected behaviour of  'is'  operator
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48578/bug.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Paul Ganssle


Paul Ganssle  added the comment:

Sorry for the late response after a patch, but I'm actually -1 on this patch. I 
don't think it buys us very much in terms of the API considering it only has 3 
parameters, and it adds some complexity to the code (in addition to the 
performance issue). Honestly, I think the main reason we didn't go with 
positional-only parameters in `fromisocalendar` was that the "/" syntax didn't 
exist yet.

--
nosy: +p-ganssle

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36889] Merge StreamWriter and StreamReader into just asyncio.Stream

2019-09-01 Thread Thrlwiti


Change by Thrlwiti :


--
nosy:  -THRlWiTi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36889] Merge StreamWriter and StreamReader into just asyncio.Stream

2019-09-01 Thread Thrlwiti


Change by Thrlwiti :


--
nosy: +THRlWiTi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38000] importlib can not handle module file names with periods

2019-09-01 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38000] importlib can not handle module file names with periods

2019-09-01 Thread Andrey


New submission from Andrey :

```
import os, sys

def import_module(dir_path, module_name, ref_module_name = None):
  module_file_path = os.path.join(dir_path, module_name).replace('\\', '/')
  if sys.version_info[0] > 3 or sys.version_info[0] == 3 and 
sys.version_info[1] >= 4:
import importlib
import_spec = 
importlib.util.spec_from_file_location(os.path.splitext(module_name)[0] if 
ref_module_name is None else ref_module_name, os.path.join(dir_path, 
module_name).replace('\\', '/'))
import_module = importlib.util.module_from_spec(import_spec)
import_spec.loader.exec_module(import_module)
#globals()[module_name if ref_module_name is None else ref_module_name] = 
import_module # still does not accept modules with periods without this
  else:
# back compatability
import imp
module_file, module_file_name, module_desc = 
imp.find_module(os.path.splitext(module_name)[0], 
[os.path.dirname(module_file_path)])
globals()[module_name if ref_module_name is None else ref_module_name] = 
imp.load_module(module_file_path, module_file, module_file_name, module_desc)
```

I am trying to import my modules targeted by file path:

```
import_module(MYTOOLS_ROOT, 'cmdoplib.std.py', 'cmdoplib')
import_module(MYTOOLS_ROOT, 'cmdoplib.yaml.py', 'cmdoplib_yaml')
```

And got error:

```
Traceback (most recent call last):
  File "c:\python\x64\37\lib\site-packages\xonsh\proc.py", line 1411, in run
r = self.f(self.args, sp_stdin, sp_stdout, sp_stderr, spec, spec.stack)
  File "c:\python\x64\37\lib\site-packages\xonsh\proc.py", line 1204, in 
proxy_two
return f(args, stdin)
  File "c:\python\x64\37\lib\site-packages\xonsh\aliases.py", line 575, in 
source_alias
builtins.execx(src, "exec", ctx, filename=fpath)
  File "c:\python\x64\37\lib\site-packages\xonsh\built_ins.py", line 1497, in 
__call__
return self.obj.__call__(*args, **kwargs)
  File "c:\python\x64\37\lib\site-packages\xonsh\execer.py", line 190, in exec
return exec(code, glbs, locs)
  File 
"w:/Work/MyProjects/__scm_solutions/all-in-one/_common/tools/cmdoplib.yaml.xsh",
 line 11, in 
g_yaml_env = cmdoplib_yaml.YamlEnv()
NameError: name 'cmdoplib_yaml' is not defined
```

If try to uncomment this:

```
globals()[module_name if ref_module_name is None else ref_module_name] = 
import_module
```

All works fine.
Seems the latest version of the python still can not handle modules with the 
periods in a file name without constructions from the old and well known `imp` 
module.

It seems for me as a bug or at least as an incomplete (re)implementation.

--
components: Interpreter Core
messages: 350950
nosy: andry
priority: normal
severity: normal
status: open
title: importlib can not handle module file names with periods
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37998] re.sub(r'\\', r'\\\\', s) reporting MemoryError

2019-09-01 Thread Guruprasad Venkataramaiah


Guruprasad Venkataramaiah  added the 
comment:

With more debug, observed the input string ('s') is getting assigned to a big 
string of '' resulting in Memory error

--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37998] re.sub(r'\\', r'\\\\', s) reporting MemoryError

2019-09-01 Thread Guruprasad Venkataramaiah


Guruprasad Venkataramaiah  added the 
comment:

With more debug, observed the input string ('s') is getting assigned to a big 
string of '' resulting in Memory error

--
resolution:  -> not a bug

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37999] No longer use implicit convertion to int with loss

2019-09-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +15304
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15636

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37999] No longer use implicit convertion to int with loss

2019-09-01 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Use only the __index__() method for implicit conversion to iteger, and not 
__int__().

This converts deprecation warnings added in issue36048 into TypeError.

--
components: Interpreter Core
messages: 350947
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: No longer use implicit convertion to int with loss
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37993] os.path.realpath on Windows resolves mapped network drives

2019-09-01 Thread Eryk Sun


Eryk Sun  added the comment:

>> Unix Python resolves the executable path with repeated _Py_wreadlink 
>> calls. Windows Python should do something similar to ensure the 
>> consistency of sys.executable with realpath(sys.executable).
>
> I don't think this necessarily follows. There's nowhere in the 
> documentation that says that sys.executable is even a valid path, 
> let alone the final path.

The reason is cross-platform parity for users who aren't language lawyers -- as 
long as it's not expensive and doesn't compromise reliability or safety. 

That said, resolving the real executable path is more of a practical concern in 
Unix. In Windows it's not generally useful since the loader does not resolve 
the real path of an executable. 

Unix Python also calls _Py_wrealpath on the script path, which I think is more 
relevant in Windows than the sys.executable case because it's at a higher level 
that we control. This allows running a script symlink at the command line (e.g. 
linked in a common bin directory in PATH) even if the script depends on modules 
in the real directory.

>> I think we want relpath(realpath('C:/Temp/foo'), realpath('S:/')) to 
>> succeed as r"..\foo". I don't think we want it to fail as a cross-
>> drive relative path.
>
> Cross-drive relative paths are fine though - they are just absolute 
> paths :)

relpath() fails if the target and start directories aren't on the same drive. 
Code that's creating a symlink in Windows has to handle this case by using an 
absolute symlink instead of a relative symlink, if that's what you mean. That's 
probably for the better. So I change my mind. Forcing scripts to create 
absolute symlinks is not an issue, even if it's unnecessary because the target 
and start directory can be resolved to the same drive. The mount point should 
take precedence. But that's an argument against using the final path. Mapped 
drives and subst drives will be resolved in the final path. Reverse mapping to 
the original drive, if possible, would be extra work.

For example, say we start with "\\??\\S:\\". The object manager reparses the 
r"\??\S:" SymbolicLink as r"\??\C:\Temp\Subst". Next it reparses r"\??\C:" to a 
device object, with a resolved path such as 
r"\Device\HarddiskVolume2\Temp\Subst". The Device object type has a parse 
routine that's implemented by the I/O manager. This sends an IRP_MJ_CREATE 
request to the mounted file-system device (NTFS in this case) with the 
remaining path to be parsed, e.g. r"\Temp\Subst". Note that at this stage, 
information about the original drive "S:" is long gone.

If the file system in turn finds a reparse point, such as a file-system symlink 
or mount point, then it stops there and returns STATUS_REPARSE with the 
contents of the reparse buffer. The I/O Manager itself handles symlink and 
mount-point reparsing, for which it implements behavior that's as close as 
possible to Unix symlinks and mount points. After setting up the new path to 
open, the I/O manager's parse routine returns STATUS_REPARSE to the object 
manager. Up to 63 reparse attempts are allowed, including within the object 
namespace itself. The limit of 63 reparse attempts is a simple way to handle 
reparse loops.

Assuming no file-system reparse points, we have as the final path 
r"\Device\HarddiskVolume2\Temp\Subst". To map this back to a DOS path, 
GetFinalPathNameByHandleW queries the mount-point manager for the canonical DOS 
device name for r"\Device\HarddiskVolume2". The mount-point manager knows about 
"C:" in this case, but it doesn't have a registry of subst drives. 
GetFinalPathNameByHandleW also doesn't enumerate DOS devices and map a path 
back to a matching subst drive. It supports only the canonical path. 

Reverse mapping a UNC path to a mapped drive would be even more difficult. We 
would have to doubly resolve, for example, from "M:" -> r"\Device\\;M:\server\share\path\to\directory" -> 
r"\Device\Mup\;\;M:\server\share\path\to\directory". Once we confirm that "M:" targets the 
MUP device, we can compare r"\server\share\path\to\directory" to check whether 
the final path contains this path. If so it can replace it with "M:". That's a 
lot of work to get a non-canonical path, and that's the simplest case. For 
example, we could have a subst drive for a mapped drive, and the shortest path 
would be the subst drive.

To avoid resolving drives altogether, realpath() would have to manually walk 
the path instead of relying on GetFinalPathNameByHandleW.

> If we can easily tell the difference between directory junctions and 
> mapped drives, given that they are both identical types of reparse 
> points

Mapped drives and subst drives are not file-system reparse points. They're 
"DOS" devices, which are implemented as SymbolicLink objects in the "\\??\\" 
device-alias directory. A SymbolicLink object can be read via 
NtQuerySymbolicLinkObject, or via WINAPI QueryDosDeviceW if the SymbolicLink is 
in "\\??\\".

--


[issue37994] Fix silencing all errors if an attribute lookup fails

2019-09-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37994] Fix silencing all errors if an attribute lookup fails

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 353053d9ad08fea0e205e6c008b8a4350c0188e6 by Serhiy Storchaka in 
branch '3.8':
[3.8] bpo-37994: Fix silencing all errors if an attribute lookup fails. 
(GH-15630) (GH-15635)
https://github.com/python/cpython/commit/353053d9ad08fea0e205e6c008b8a4350c0188e6


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37998] re.sub(r'\\', r'\\\\', s) reporting MemoryError

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What is s?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37998] re.sub(r'\\', r'\\\\', s) reporting MemoryError

2019-09-01 Thread Guruprasad Venkataramaiah


New submission from Guruprasad Venkataramaiah 
:

On Python 3.5:
s = re.sub(r'\\', r'', s)
  File "/pyuniti/venvs/guruv/lib/python3.5/re.py", line 182, in sub
return _compile(pattern, flags).sub(repl, string, count)
MemoryError

On Python 3.7
s = re.sub(r'\\', r'', s)  
  File "C:\Python\Python37-32\lib\re.py", line 192, in sub
return _compile(pattern, flags).sub(repl, string, count)
MemoryError

--
components: Regular Expressions
messages: 350943
nosy: Guruprasad Venkataramaiah, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.sub(r'\\', r'', s) reporting MemoryError
type: resource usage
versions: Python 3.5, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15999] Using new 'bool' format character

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70 by Serhiy Storchaka in 
branch 'master':
bpo-15999: Clean up of handling boolean arguments. (GH-15610)
https://github.com/python/cpython/commit/1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15999] Using new 'bool' format character

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 5eca7f3f3836cc734dfe8dc5ec669f3b4e9333fe by Serhiy Storchaka in 
branch 'master':
bpo-15999: Always pass bool instead of int to socket.setblocking(). (GH-15621)
https://github.com/python/cpython/commit/5eca7f3f3836cc734dfe8dc5ec669f3b4e9333fe


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15999] Using new 'bool' format character

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset eb8974616bc58f44b2a3c3e4ca2326894ae42c8f by Serhiy Storchaka in 
branch 'master':
bpo-15999: Always pass bool instead of int to the expat parser. (GH-15622)
https://github.com/python/cpython/commit/eb8974616bc58f44b2a3c3e4ca2326894ae42c8f


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37994] Fix silencing all errors if an attribute lookup fails

2019-09-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +15303
pull_request: https://github.com/python/cpython/pull/15635

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37994] Fix silencing all errors if an attribute lookup fails

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 41c57b335330ff48af098d47e379e0f9ba09d233 by Serhiy Storchaka in 
branch 'master':
bpo-37994: Fix silencing all errors if an attribute lookup fails. (GH-15630)
https://github.com/python/cpython/commit/41c57b335330ff48af098d47e379e0f9ba09d233


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36543] Remove old-deprecated ElementTree features (part 2)

2019-09-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36543] Remove old-deprecated ElementTree features (part 2)

2019-09-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset f02ea6225bc3b71bd5fe66224d199a6e3e23b14d by Serhiy Storchaka in 
branch 'master':
bpo-36543: Remove old-deprecated ElementTree features. (GH-12707)
https://github.com/python/cpython/commit/f02ea6225bc3b71bd5fe66224d199a6e3e23b14d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35771] IDLE: Fix tooltip Hovertiptest failure

2019-09-01 Thread Tal Einat


Change by Tal Einat :


--
pull_requests: +15302
pull_request: https://github.com/python/cpython/pull/15634

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-09-01 Thread Piet van Oostrum
Hongyi Zhao  writes:

> Hi,
>
> The following two forms are always equivalent:
>
> ``if var'' and ``if var is not None'' 
>
> Regards


In [1]: var = 0

In [2]: if var:
   ...: print('True')
   ...: else:
   ...: print('False')
False

In [3]: if var is not None:
   ...: print('True')
   ...: else:
   ...: print('False')
True

-- 
Piet van Oostrum 
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2019-09-01 Thread Frank Millman

On 2019-09-01 8:12 AM, Hongyi Zhao wrote:

Hi,

The following two forms are always equivalent:

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

Regards



Not so. Here is an example -

>>> var = []
>>> bool(var)
False
>>> bool(var is not None)
True
>>>

Frank Millman

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


[issue24416] Return a namedtuple from date.isocalendar()

2019-09-01 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests: +15301
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/15633

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2019-09-01 Thread Chris Angelico
On Sun, Sep 1, 2019 at 4:16 PM Hongyi Zhao  wrote:
>
> Hi,
>
> The following two forms are always equivalent:
>
> ``if var'' and ``if var is not None''
>

Ahh... False. I'll go False. I'll be honest, I might have heard
that one before, though. Sort of cheating.

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


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

2019-09-01 Thread Hongyi Zhao
Hi,

The following two forms are always equivalent:

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

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