Re: How to start gnuradio

2018-07-31 Thread Ben Finney
bengt.to...@gmail.com writes:

> My gnuradio program does not start in my Mint 17.3 installation.

Summary: I believe this is a bug in the package on Mint. (The bug may be
inherited from elsewhere, too: maybe in the Debian package, maybe in the
PyPI package. That would need more diagnosis to determine.)

> When I invoke the command "gnuradio-companion" I get the following message:
>
> -
> Cannot import gnuradio.

That looks like a bug, indeed.

Because you later reported that installing another Python package brings
correct behaviour, this strongly indicates that the gnuradio package
does not correctly declare its dependencies.

In other words: The 'gnuradio-companion' program does not work without
an additional package installed, so that is a dependency which must be
declared for the 'gnuradio' package.

> Grateful for hints on how to find out the reason and to solve the
> problem.

I think you have enough information to write a bug report to the Mint
bug tracking system for this.

-- 
 \  “The good thing about science is that it's true whether or not |
  `\  you believe in it.” —Neil deGrasse Tyson, 2011-02-04 |
_o__)  |
Ben Finney

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


Re: How to start gnuradio

2018-07-31 Thread Ross Wilson
I had a paddle through the manual at
https://www.gnuradio.org/doc/doxygen/page_python_blocks.html and apparently
some DSP operations use numpy.

Ross

On Wed, 1 Aug 2018 at 11:56  wrote:

>
>
> After some research I found out that "sudo apt-get install python-numpy"
> solved the problem.
>
> Can anyone clarify how python-numpy solves the problem?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to start gnuradio

2018-07-31 Thread bengt . tornq



After some research I found out that "sudo apt-get install python-numpy" solved 
the problem. 

Can anyone clarify how python-numpy solves the problem? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Confused on git commit tree about Lib/datetime.py

2018-07-31 Thread Jeffrey Zhang
I found a interesting issue when checking the Lib/datetime.py
implementation in python3

This patch is introduced by cf86e368ebd17e10f68306ebad314eea31daaa1e [0].
But if you
check the github page[0], or using git tag --contains, you will find v2.7.x
includes this commit too.

$ git tag --contains cf86e368ebd17e10f68306ebad314eea31daaa1e
3.2
v2.7.10
v2.7.10rc1
v2.7.11
v2.7.11rc1
...

whereas, if you check the v2.7.x code base, nothing is found

$ git log v2.7.4 -- Lib/datetime.py


I guess it maybe a git tool bug, or the commit tree is messed up. Is there
any guys could explain this
situation?

[0]
https://github.com/python/cpython/commit/cf86e368ebd17e10f68306ebad314eea31daaa1e

-- 
Regards,
Jeffrey Zhang
Blog: http://xcodest.me
-- 
https://mail.python.org/mailman/listinfo/python-list


i have add mouse motion feature to turtle

2018-07-31 Thread Coding Kids
i have add mouse motion event to turtle 
i think it's an small but excellent imporovement and made turtle could create 
more interesting project for kids
any possiblity add  this feature to offical version?is so what a exciting 
things!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Console Menu

2018-07-31 Thread Juraj Papic via Python-list
Thanks for the links

[image: cid:D5DA6341-AA78-4808-9639-F19B8AB3CBE8]

*Juraj A. Papic*

Arquitecto de Soluciones

juraj.pa...@bghtechpartner.com

Arias 1639/41. C1429DWA.
Bs. As., Argentina.

T. +54 11 5080-7400

M. +54 911 3445-6944

Skype juraj.papic

www.bghtechpartner.com



2018-07-31 15:36 GMT-03:00 Jerry Hill :

> On Tue, Jul 31, 2018 at 12:31 PM juraj.papic--- via Python-list
>  wrote:
> > I will check the links thanks for that tips, is there any page where I
> can see more examples?
>
> I like Doug Hellmann's Python Module of the Week site for in-depth
> looks at particular modules (including subprocess).  If you're using
> python 3, the subprocess module's page is here:
> https://pymotw.com/3/subprocess/.
>
> From your sample code, you may still be using python 2.  If so, the
> PyMOTW page for that version is here:
> https://pymotw.com/2/subprocess/.
>
> --
> Jerry
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unittest.TestCase.assertRaisesRegex throws DeprecationWarning

2018-07-31 Thread Peter Otten
Uri Even-Chen wrote:

> Do you know what is the problem and why I receive these deprecation
> warnings?

I poked around a bit and found

https://bugs.python.org/issue24134

Perhaps you can make sense of it (I can't).

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


Re: unittest.TestCase.assertRaisesRegex throws DeprecationWarning

2018-07-31 Thread Peter Otten
Uri Even-Chen wrote:

> Hi,
> 
> We are using unittest.TestCase.assertRaisesRegex in our Django project
> (Speedy Net / Speedy Match - https://github.com/urievenchen/speedy-net),
> and I always prefer calling Python function parameters by name. So we call
> self.assertRaisesRegex with parameters (keyword arguments)
> expected_exception, expected_regex and callable - as documented on
> 
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaisesRegex
> . You can see our code on
> https://github.com/urievenchen/speedy-net/blob/master/speedy/core/accounts/tests/test_models.py
> . When I run tests regularly (with "./manage.py test") they pass, But when
> I run tests with "python -W error::DeprecationWarning manage.py test",
> (with Python 3.5.5), I receive errors like this:
> 
> DeprecationWarning: 'callable' is an invalid keyword argument for this
> function
> 
> See the full errors here:
> https://travis-ci.org/urievenchen/speedy-net/jobs/410482655 (by the way,
> with Python 3.4.6 the tests pass).

No, the function to be tested is not run at all (it looks like callable was 
called callable_obj back then):

$ cat unittest_regex.py
import unittest

def foo(*args, **kw):
print("RUNNING FOO")

class T(unittest.TestCase):
def test_baz(self):
self.assertRaisesRegex(
expected_exception=ValueError,
expected_regex="bar",
callable=foo
)

if __name__ == "__main__":
unittest.main()
$ python3.4 unittest_regex.py
.
--
Ran 1 test in 0.000s

OK


> Do you know what is the problem and why I receive these deprecation
> warnings?

Apparently they want you to use the context manager ;)
Like

with self.assertRaisesRegex(ValueError, "bar"):
foo()

Clean, readable, robust -- but no keyword args.


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


ANN: Wing Python IDE version 6.1 released

2018-07-31 Thread Wingware

Hi,

Wingware has just released Wing 6.1 
, which adds PEP 8 reformatting, 
includes a How-To for Windows Subsystem for Linux, supports the Qt5Agg 
backend for matplotlib, allows configuring a path for code snippets, 
supports evaluating generator expressions that use data from the 
enclosing scope in the Debug Probe, improves auto-completion for pygame, 
and makes about 45 other minor improvements.For details, see 
https://wingware.com/pub/wingide/6.1.0/CHANGELOG.txt


Download Now 

About Wing

Wing is a family of cross-platform 
 Python IDEs with 
powerful integrated editing, debugging, unit testing, and project 
management features. Wing runs on Windows, Linux, and OS X, and can be 
used to develop any kind of Python code for web, desktop, embedded 
scripting, and other applications.


Wing 101  and Wing Personal 
 omit some features and 
are free to download and use without a license. Wing Pro 
 requires purchasing 
 or upgrading 
 a license, or obtaining a 30-day 
trial at startup.


Version 6 introduces many new features, including improved 
multi-selection, much easier remote development 
, debugging from the Python 
Shell, recursive debugging, PEP 484 and 526 type hinting, PEP 8 
reformatting, support for Python 3.6 and 3.7, Vagrant 
, Jupyter 
, Django 
 1.10+ and 2.0, and Windows 
Subsystem for Linux, improved mainloop support for matplotlib, easier 
Raspberry Pi  development, 
optimized debugger, OS X full screen mode, One Dark color palette, 
Russian localization (thanks to Alexandr Dragukin), expanded free 
product line, and much more. For details, see What's New in Wing Version 
6 .


Wing 6 works with Python versions 2.5 through 2.7 and 3.2 through 3.7, 
including also Anaconda, ActivePython, EPD, Stackless, and others 
derived from the CPython implementation.


For more product information, please visit wingware.com 



Upgrading

You can try Wing 6 without removing older versions. Wing 6 will read and 
convert your old preferences, settings, and projects. Projects should be 
saved to a new name since previous versions of Wing cannot read Wing 6 
projects.


See also Migrating from Older Versions 
 and Upgrading 
.


Links

Release notice: https://wingware.com/news/2018-07-30
Downloads and Free Trial: https://wingware.com/downloads
Buy: https://wingware.com/store/purchase
Upgrade: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at supp...@wingware.com.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

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


unittest.TestCase.assertRaisesRegex throws DeprecationWarning

2018-07-31 Thread Uri Even-Chen
Hi,

We are using unittest.TestCase.assertRaisesRegex in our Django project
(Speedy Net / Speedy Match - https://github.com/urievenchen/speedy-net),
and I always prefer calling Python function parameters by name. So we call
self.assertRaisesRegex with parameters (keyword arguments)
expected_exception, expected_regex and callable - as documented on
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaisesRegex
. You can see our code on
https://github.com/urievenchen/speedy-net/blob/master/speedy/core/accounts/tests/test_models.py
. When I run tests regularly (with "./manage.py test") they pass, But when
I run tests with "python -W error::DeprecationWarning manage.py test",
(with Python 3.5.5), I receive errors like this:

DeprecationWarning: 'callable' is an invalid keyword argument for this
function

See the full errors here:
https://travis-ci.org/urievenchen/speedy-net/jobs/410482655 (by the way,
with Python 3.4.6 the tests pass).

Do you know what is the problem and why I receive these deprecation
warnings?

Thanks,
Uri.


*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
 
 

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


Re: Python Console Menu

2018-07-31 Thread Jerry Hill
On Tue, Jul 31, 2018 at 12:31 PM juraj.papic--- via Python-list
 wrote:
> I will check the links thanks for that tips, is there any page where I can 
> see more examples?

I like Doug Hellmann's Python Module of the Week site for in-depth
looks at particular modules (including subprocess).  If you're using
python 3, the subprocess module's page is here:
https://pymotw.com/3/subprocess/.

>From your sample code, you may still be using python 2.  If so, the
PyMOTW page for that version is here:
https://pymotw.com/2/subprocess/.

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


Re: Python Console Menu

2018-07-31 Thread juraj.papic--- via Python-list
El martes, 31 de julio de 2018, 11:56:47 (UTC-3), Tcpip  escribió:
> Hi all,
> 
> Im new with python, im working on a Python console Menu, I found some 
> examples on Git, but  what I need to understand is how I can call a 
> subprocess.
> 
> Here is an Example ,
> 
> if choice==1:
> print "Test SSH Connection (check ssh to all hosts)"
> ## You can add your code or functions here
> #print_menu()
> elif choice==2:
> print "Menu 2 has been selected"
> ## You can add your code or functions here
> elif choice==3:
> print "Menu 3 has been selected"
> ## You can add your code or functions here
> elif choice==4:
> print "Menu 4 has been selected"
> ## You can add your code or functions here
> elif choice==5:
> print "Menu 5 has been selected"
> ## You can add your code or function here
> 
> 
> Thanks.

I will check the links thanks for that tips, is there any page where I can see 
more examples?

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


Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread Chris Angelico
On Wed, Aug 1, 2018 at 1:28 AM, MRAB  wrote:
> On 2018-07-31 08:40, Robin Becker wrote:
>>
>> A bitbucket user complains that python 3.6.6 with -Wall -b prints warnings
>> for some reportlab code; the
>> example boils down to the following
>>
>> ##
>> C:\code\hg-repos\reportlab\tmp>cat tb.py
>> if __name__=='__main__':
>>   d={'a':1}
>>   d[b'a'] = d['a']
>> ##
>>
>>
>> C:\code\hg-repos\reportlab\tmp>\python36\python -Wall -b tb.py
>> tb.py:3: BytesWarning: Comparison between bytes and string
>> d[b'a'] = d['a']
>>
>> I had always assumed that dicts didn't care about the type of keys
>> although some types might cause issue with hashability, but
>> obviously the implementation seems to be comparing b'a' with 'a' (I
>> suppose because they hash to the same chain).
>>
>> Is this code erroneous or is the warning spurious or wrong?
>>
> The warning looks wrong to be.
>
> In Python 2, u'a' and b'a' would be treated as the same key, but in Python 3
> they are distinct and can co-exist.
>
> Something for Python's bug tracker, I think!

It's a warning specifically requested by the -b option. The two keys
in question have the same hash, which means they have to be compared
directly; they will compare unequal, but because of the -b flag, the
comparison triggers a warning. If that warning is spurious, *don't use
the -b option*.

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


Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread MRAB

On 2018-07-31 08:40, Robin Becker wrote:

A bitbucket user complains that python 3.6.6 with -Wall -b prints warnings for 
some reportlab code; the
example boils down to the following

##
C:\code\hg-repos\reportlab\tmp>cat tb.py
if __name__=='__main__':
  d={'a':1}
  d[b'a'] = d['a']
##


C:\code\hg-repos\reportlab\tmp>\python36\python -Wall -b tb.py
tb.py:3: BytesWarning: Comparison between bytes and string
d[b'a'] = d['a']

I had always assumed that dicts didn't care about the type of keys although 
some types might cause issue with hashability, but
obviously the implementation seems to be comparing b'a' with 'a' (I suppose 
because they hash to the same chain).

Is this code erroneous or is the warning spurious or wrong?


The warning looks wrong to be.

In Python 2, u'a' and b'a' would be treated as the same key, but in 
Python 3 they are distinct and can co-exist.


Something for Python's bug tracker, I think!
--
https://mail.python.org/mailman/listinfo/python-list


RE: Python Console Menu

2018-07-31 Thread David Raymond
Take a look at the subprocess module for how to "spawn new processes, connect 
to their input/output/error pipes, and obtain their return codes."

https://docs.python.org/2/library/subprocess.html


-Original Message-
From: Python-list 
[mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of 
Tcpip via Python-list
Sent: Tuesday, July 31, 2018 10:56 AM
To: python-list@python.org
Subject: Python Console Menu

Hi all,

Im new with python, im working on a Python console Menu, I found some examples 
on Git, but  what I need to understand is how I can call a subprocess.

Here is an Example ,

if choice==1:
print "Test SSH Connection (check ssh to all hosts)"
## You can add your code or functions here
#print_menu()
elif choice==2:
print "Menu 2 has been selected"
## You can add your code or functions here
elif choice==3:
print "Menu 3 has been selected"
## You can add your code or functions here
elif choice==4:
print "Menu 4 has been selected"
## You can add your code or functions here
elif choice==5:
print "Menu 5 has been selected"
## You can add your code or function here


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


Python Console Menu

2018-07-31 Thread Tcpip via Python-list
Hi all,

Im new with python, im working on a Python console Menu, I found some examples 
on Git, but  what I need to understand is how I can call a subprocess.

Here is an Example ,

if choice==1:
print "Test SSH Connection (check ssh to all hosts)"
## You can add your code or functions here
#print_menu()
elif choice==2:
print "Menu 2 has been selected"
## You can add your code or functions here
elif choice==3:
print "Menu 3 has been selected"
## You can add your code or functions here
elif choice==4:
print "Menu 4 has been selected"
## You can add your code or functions here
elif choice==5:
print "Menu 5 has been selected"
## You can add your code or function here


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


Re: Using Python on a fork-less POSIX-like OS

2018-07-31 Thread Stephan Houben
Op 2018-07-29, Terry Reedy schreef :

> multiprocessing module uses 'spawn' rather than 'fork' on Windows and it 
> has an option to use 'spawn' even on *nix.  I presume the latter refers 
> to posix_spawn.  You might want to check the multiprocessing code to see 
> what *it* is doing 'under the covers'.

Actually, the only place posix_spawn is currently used in Python is in
some experimental and currently-disabled code in the posix module.

`spawn' in multiprocessing only refers to a fork/exec combination 
(on Posix, at least), as opposed to `fork' which only does a fork.

Note that posix_spawn cannot provide full subprocess functionality
(obviously preexec_fn, but also not start_new_session).
So it's a hard sell to add a posix_spawn special case there, since 
a generic fork/exec would need to be maintained anyway.

(The same reason is also why most shells such as bash, zsh, don't bother
with posix_spawn.)

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


Re: Python bug in ArcGIS - Urban Network analysis tool

2018-07-31 Thread Станимира Николова
понеделник, 30 юли 2018 г., 15:19:43 UTC+3, Andrew MacIntyre написа:
> On 30/07/2018 4:02 PM, Станимира Николова wrote:
> 
> > I run Urban network analysis but It shows similar mistake several 
> > times. The UNA tool is free plugin that i downloaded, it's not from the 
> > default intalled in ArcGIS packed. It ask for integer data.
> > I checked the type of the attributes, it's all integer. PLus it's all 
> > in geo data based file.
> >
> > Unfortunately I don't understand Python, I'm one of those who use 
> > ArcGIS as sample customer.
> >
> > This is the mistake:
> >
> > Start Time: Fri Jul 27 14:48:32 2018
> > Running script Centrality...
> > [started] Copying input buildings
> > [finished]
> > [1 started] Computing adjacency list
> > [1 failed]
> > Not successful
> > Completed script Centrality...
> > Succeeded at Fri Jul 27 14:48:36 2018 (Elapsed Time: 4,56 seconds)
> >
> > Any suggestions? How it's calling these adjaency list? What could be 
> > wrong? I even don't know how to get debugger, so it could give me more 
> > information.
> 
> If it's a third party plugin, contact the author or source.  This 
> mailing list sees very little traffic about ArcGIS usage as it is a 
> highly specialised commercial product.
> 
> > I add in a project the .py file for the adjacency list.
> > 
> > That's the main from the debuger:
> > 
> > pydev debugger: process 8904 is connecting
> > 
> > Connected to pydev debugger (build 182.3684.100)
> > Traceback (most recent call last):
> >File "C:\Program Files\JetBrains\PyCharm 
> > 2018.2\helpers\pydev\pydevd.py", line 1664, in 
> >  main()
> >File "C:\Program Files\JetBrains\PyCharm 
> > 2018.2\helpers\pydev\pydevd.py", line 1658, in main
> >  globals = debugger.run(setup['file'], None, None, is_module)
> >File "C:\Program Files\JetBrains\PyCharm 
> > 2018.2\helpers\pydev\pydevd.py", line 1068, in run
> >  pydev_imports.execfile(file, globals, locals)  # execute the script
> >File "C:\Program Files\JetBrains\PyCharm 
> > 2018.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
> >  exec(compile(contents+"\n", file, 'exec'), glob, loc)
> >File "D:/INSTALL/Urban Network Analysis Toolbox 
> > 1.01/src/Centrality/Adjacency_List_Computation.py", line 14, in 
> >  from arcpy import AddField_management
> > ModuleNotFoundError: No module named 'arcpy'
> > 
> > May I found the following lines from the code?
> 
> Is it documented that the file you've attempted to run via PyCharm 
> actually supports being run from outside ArcGIS?  Most plugins don't 
> seem to be...  This failure is because PyCharm isn't starting the script 
> with the necessary environment (including the arcpy ArcGIS Python 
> module) accessible.
> 
> The fact that it starts running from within ArcGIS and produces some 
> status messages before bailing out with the failure message strongly 
> suggests to me that the plugin is working properly but the input given 
> is not sufficient to produce the expected output.  In the absence of 
> sufficient documentation for you to figure out the required input, my 
> advice above stands: contact the author or the download source.
> 
> If you or your organisation has a current ArcGIS maintenance agreement, 
> you might also be able to access the community forums that ESRI run to 
> ask for more info about this plugin.
> 
> -- 
> -
> Andrew I MacIntyre "These thoughts are mine alone..."
> E-mail: andy...@bullseye.apana.org.au  (pref) | Snail: PO Box 370
>  andy...@pcug.org.au (alt) |Belconnen ACT 2616
> Web:http://www.andymac.org/   |Australia

Hi Andrew,
Thanks for your reply.

I managed to resolve the problem.

It seems that just the plugin doesn't found the python paths of it's 
environments and libraries. As I understood the adj. list is "calling" for 
functions in the other python files of the plugin (plus functions from ArcGIS).

What I've done (me and one IT specialist, actually):
 - Found the pythonpath of the module arcpy in the folder of default installed 
ArcGIS
 - Copied the pythonpath file, for the connection with module arcpy, in the 
folder with scripts of the plugin (UNA tool)
 - opened Python 3.7 and called for arcpy of the plugin. There we saw the paths 
of all enviroments that might use the plugin. The path to the arcpy appeared.

After that I got few mistakes of the input data, because I had to make unique 
ID of all the data points in the folder.

And tadamm … it works. 

Thanks for all the suggestions.
Mira.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread Peter Otten
Robin Becker wrote:

> On 31/07/2018 09:16, Paul Moore wrote:
>> On 31 July 2018 at 08:40, Robin Becker  wrote:
>>> A bitbucket user complains that python 3.6.6 with -Wall -b prints
>>> warnings for some reportlab code; the
>>> example boils down to the following
>>>
>>> ##
>>> C:\code\hg-repos\reportlab\tmp>cat tb.py
>>> if __name__=='__main__':
>>>  d={'a':1}
>>>  d[b'a'] = d['a']
>>> ##
>>>
>>..
>> v.1500 64 bit (AMD64)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
> b'a' == 'a'
>> True
> b'a' == u'a'
>> True
>
>> 
>> which is basically the sort of thing that -b should warn about.
>> Specifically the quoted code would end up with a dictionary with 2
>> entries on Python 3, but 1 entry on Python 2.
>> 
>> Paul
>> 
> yes but I didn't do the compare so this warning seems entirely spurious
> and wrong. 

I disagree. Going from {"a": 1} in Python 2 to {"a": 1, b"a": 2} in Python3 
can certainly be a source of nasty bugs.

Also the interpreter cannot magically separate the comparisons directly 
"done by you" from those you triggered by running other people's code.

> It's not an error to put 1 and 1.0 and 'a' into a dict. 

With these keys you end up with a single entry in both py2 and py3.

> Should
> I get a warning if the hashes of two different types happen to clash so
> that an int needs to be checked against a string?

Not the hash, a collision is basically meaningless unless it causes a 
performance regressen. However, ensuring that all keys have the same type 
may sometimes be useful.



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


Re: How to decide (and know) which Python GTK version to use?

2018-07-31 Thread Chris Green
Michael Torrie  wrote:
> On 07/30/2018 11:04 AM, Akkana Peck wrote:
> > Yes, this is the future, since it lets you use both GTK3 and Python3.
> 
> Unfortunately the automatically-generated bindings, while fast and
> complete, are not quite as pythonic as the old PyGTK bindings were.  The
> abstraction layer pygobject provides leaks some of the underlying C-isms
> through.  I can't remember exactly which bits feel the most foreign as
> it's been a while since I used it.  But who am I kidding?  PyQt (my
> preferred toolkit) or PySide aren't terribly Pythonic either; lots of
> C++ and Qt abstractions leaking through various Qt types when native
> Python types would be preferable (like lists and dictionaries).

Yes, this has been some of my problem when starting to use these
packages.  I'm a retired Software Engineer and I spent much of my
career (like the last 40 years or more) writing C/C++, so seeing C-like
code isn't 'difficult', but it can be confusing.  Some of the bits of
'example' code are actually C/C++ rather than Python which had me very
confused for a while!

Also there's the oddity of Gtk.Window and Gtk.Window.new (also due to
the C/C++ ancestry?).

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread Paul Moore
On 31 July 2018 at 09:32, Robin Becker  wrote:
> On 31/07/2018 09:16, Paul Moore wrote:
>>
>> On 31 July 2018 at 08:40, Robin Becker  wrote:
>>>
>>> A bitbucket user complains that python 3.6.6 with -Wall -b prints
>>> warnings
>>> for some reportlab code; the
>>> example boils down to the following
>>>
>>> ##
>>> C:\code\hg-repos\reportlab\tmp>cat tb.py
>>> if __name__=='__main__':
>>>  d={'a':1}
>>>  d[b'a'] = d['a']
>>> ##
>>>
>> ..
>> v.1500 64 bit (AMD64)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>
> b'a' == 'a'
>>
>> True
>
> b'a' == u'a'
>>
>> True
>
>
>>
>> which is basically the sort of thing that -b should warn about.
>> Specifically the quoted code would end up with a dictionary with 2
>> entries on Python 3, but 1 entry on Python 2.
>>
>> Paul
>>
> yes but I didn't do the compare so this warning seems entirely spurious and
> wrong. It's not an error to put 1 and 1.0 and 'a' into a dict. Should I get
> a warning if the hashes of two different types happen to clash so that an
> int needs to be checked against a string?

No, but it does seem reasonable (to me, at least) that you'd get a
warning if the behaviour of

a[1] = 12
a[1.0] = 99

were to change so that the dict had two separate entries. That's
exactly what happened here - Python 3 behaves differently than Python
2, and the -b flag is to enable warnings about such cases.

If you feel the warning is spurious then you can simply not use -b. Or
suppress the warning, I guess. But it seems to me that it's an opt-in
warning of something that could cause problems, so I don't really see
why it's such a big problem.

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


Re: How to decide (and know) which Python GTK version to use?

2018-07-31 Thread Chris Green
Liste guru  wrote:
> Il 30/07/2018 19:31, Chris Green ha scritto:
> 
> > OK, thanks, where is its home and full API documentation etc.?
> > -- Chris Green·-- https://mail.python.org/mailman/listinfo/python-list
> 
> On the first page of the official docs, 
> http://pygobject.readthedocs.io/en/latest/, there are the links to the 
> Python Gtk3 Tutorial, to the Python GI API Reference and all you need to 
> start to work with Pygobject and Gtk3.
> 
Excellent, thank you, it did take me a few seconds to find the links
but they are there!  It would have been more obvious if they had been
repeated in the side bar (but maybe I'm just being obtuse!).

> Just a side note: Gtk3 uses the gobject-introspection (and, for Python, 
> PyGobect) to 'connect' the library to Python (or with Lua or Vala) but 
> the same introspection system is used also for different library, 
> graphical (GStreamer or Goocanvas) or not (Gio).
> 
Ah, that's why it's "import gi", thank you some more.  :-)

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread Robin Becker

On 31/07/2018 09:16, Paul Moore wrote:

On 31 July 2018 at 08:40, Robin Becker  wrote:

A bitbucket user complains that python 3.6.6 with -Wall -b prints warnings
for some reportlab code; the
example boils down to the following

##
C:\code\hg-repos\reportlab\tmp>cat tb.py
if __name__=='__main__':
 d={'a':1}
 d[b'a'] = d['a']
##


..
v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

b'a' == 'a'

True

b'a' == u'a'

True




which is basically the sort of thing that -b should warn about.
Specifically the quoted code would end up with a dictionary with 2
entries on Python 3, but 1 entry on Python 2.

Paul

yes but I didn't do the compare so this warning seems entirely spurious and wrong. It's not an error to put 1 and 1.0 and 'a' into 
a dict. Should I get a warning if the hashes of two different types happen to clash so that an int needs to be checked against a 
string?

--
Robin Becker

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


Re: Are dicts supposed to raise comparison errors

2018-07-31 Thread Paul Moore
On 31 July 2018 at 08:40, Robin Becker  wrote:
> A bitbucket user complains that python 3.6.6 with -Wall -b prints warnings
> for some reportlab code; the
> example boils down to the following
>
> ##
> C:\code\hg-repos\reportlab\tmp>cat tb.py
> if __name__=='__main__':
> d={'a':1}
> d[b'a'] = d['a']
> ##
>
>
> C:\code\hg-repos\reportlab\tmp>\python36\python -Wall -b tb.py
> tb.py:3: BytesWarning: Comparison between bytes and string
>   d[b'a'] = d['a']
>
> I had always assumed that dicts didn't care about the type of keys although
> some types might cause issue with hashability, but obviously the
> implementation seems to be comparing b'a' with 'a' (I suppose because they
> hash to the same chain).
>
> Is this code erroneous or is the warning spurious or wrong?

The warning seems right to me. Behaviour differs between Python 2 and Python 3:

>py -Wall -b
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> b'a' == 'a'
__main__:1: BytesWarning: Comparison between bytes and string
False
>>> ^Z

>py -2
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC
v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> b'a' == 'a'
True
>>> b'a' == u'a'
True
>>>

which is basically the sort of thing that -b should warn about.
Specifically the quoted code would end up with a dictionary with 2
entries on Python 3, but 1 entry on Python 2.

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


Are dicts supposed to raise comparison errors

2018-07-31 Thread Robin Becker

A bitbucket user complains that python 3.6.6 with -Wall -b prints warnings for 
some reportlab code; the
example boils down to the following

##
C:\code\hg-repos\reportlab\tmp>cat tb.py
if __name__=='__main__':
d={'a':1}
d[b'a'] = d['a']
##


C:\code\hg-repos\reportlab\tmp>\python36\python -Wall -b tb.py
tb.py:3: BytesWarning: Comparison between bytes and string
  d[b'a'] = d['a']

I had always assumed that dicts didn't care about the type of keys although some types might cause issue with hashability, but 
obviously the implementation seems to be comparing b'a' with 'a' (I suppose because they hash to the same chain).


Is this code erroneous or is the warning spurious or wrong?
--
Robin Becker

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