Is there a nice way to switch between 2 different packages providing the same APIs?

2018-07-05 Thread Mark Summerfield via Python-list
For GUI programming I often use Python bindings for Qt. There are two competing bindings, PySide and PyQt. Ideally I like to have applications that can use either. This way, if I get a problem I can try with the other bindings: if I still get the problem, then it is probably me; but if I don't

Re: sqlite in 2.7 on redhat 6

2017-06-15 Thread Mark Summerfield via Python-list
On Thursday, June 15, 2017 at 1:47:00 PM UTC+1, larry@gmail.com wrote: > I am trying to use sqlite > > $ python2.7 > Python 2.7.10 (default, Feb 22 2016, 12:13:36) > [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>>

Re: sqlite3 is non-transactional??

2017-06-15 Thread Mark Summerfield via Python-list
On Thursday, June 15, 2017 at 9:50:18 AM UTC+1, Michele Simionato wrote: > Thanks. I suspected the culprit was executescript, but I did not see it > documented in > https://docs.python.org/3/library/sqlite3.html#connection-objects. Although the standard library's sqlite3 module is useful, person

Re: How to install Python package from source on Windows

2017-05-16 Thread Mark Summerfield via Python-list
I think the problem that Deborah has encountered is a more general one on Windows: many pip-installable packages assume that a C compiler is available. Now an "obvious" solution is for pip to recognise that a C compiler is needed and give an appropriate error message. But while that may reduce con

Re: Why am I getting a 'sqlite3.OperationalError'?

2017-05-11 Thread Mark Summerfield via Python-list
The ? is indeed for variable substitution, but AFAIK only for field values, not for table names, which is why your first example doesn't work and your second and third examples do work. -- https://mail.python.org/mailman/listinfo/python-list

Re: Rosetta: Sequence of non-squares

2017-05-02 Thread Mark Summerfield via Python-list
On Monday, May 1, 2017 at 9:47:10 PM UTC+1, jlad...@itu.edu wrote: > On Monday, May 1, 2017 at 11:27:01 AM UTC-7, Robert L. wrote: > [no Python] > > Do you ever plan to ask any questions about Python? Or are you just using a > few lines of code as a fig leaf for the race baiting that you post in

Re: Error installing python on Windows

2017-03-19 Thread Mark Summerfield
Windows users (quite reasonably IMO) expect installs to "just work". If Python needs extra bits it should ask the user if it can go get them and if they say Yes it should do just that. (And this should actually work -- unlike maybe, the Python 3.5 Windows installer.) And as for searching Google

Is there a lint tool that can spot unused classes/methods/attributes/functions/etc?

2017-02-02 Thread Mark Summerfield
Suppose I have a project with an application .py file and various module .py files all in the same directory, and after lots of refactoring and other changes the modules contain lots of unused stuff. Is there a lint tool that will spot the unused things so that I can get rid of them? I've tried

Re: The Case Against Python 3

2016-11-25 Thread Mark Summerfield
On Thursday, November 24, 2016 at 7:35:03 PM UTC, bream...@gmail.com wrote: > It's all here https://learnpythonthehardway.org/book/nopython3.html although > I strongly suggest that people have large piles of sedatives to hand before > reading the article. Does me a favour though, i've been looki

Re: [FAQ] "Best" GUI toolkit for python

2016-10-20 Thread Mark Summerfield
opment) > > https://www.amazon.com/Programming-Python-Prentice-Software-Development/dp/0132354187/ref=sr_1_1?ie=UTF8&qid=1476901015&sr=8-1&keywords=rapid+qt+python > > Inside the book the apps are been developed in PyQt > > Regards, > Dim > > On 10/19/2016 03:49 PM,

Re: Python GUI application embedding a web browser - Options?

2016-10-19 Thread Mark Summerfield
On Wednesday, October 19, 2016 at 11:08:15 AM UTC+1, Paul Moore wrote: > I'm looking to write a GUI application in Python (to run on Windows, using > Python 3.5). The application is just a relatively thin wrapper around a > browser - it's presenting an existing web application, just in its own w

Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Mark Summerfield
On Tuesday, October 18, 2016 at 9:09:46 PM UTC+1, Demosthenes Koptsis wrote: > My favorite GUIs are PyQt and wxPython. > > I prefer PyQt than PySide because PySide seem to me like an abandoned > project. [snip] It does seem that PySide 1 isn't making any visible progress. However, PySide 2 for

Re: [FAQ] "Best" GUI toolkit for python

2016-10-18 Thread Mark Summerfield
On Tuesday, October 18, 2016 at 9:04:48 AM UTC+1, pozz wrote: > Il 18/10/2016 09:42, Mark Summerfield ha scritto: [snip] > Why don't you use a GUI design tool? Better... how can you design a GUI > without seeing it? For me it's very difficult to "code the GUI".

Re: [FAQ] "Best" GUI toolkit for python

2016-10-18 Thread Mark Summerfield
PySide/PyQt On Windows I use Python 3.4 + PySide 1.2.4 (Qt 4.8). I have found this very reliable and use it for both my personal projects and for my commercial products. I don't use a GUI design tool but you could use Qt Designer to visually draw your GUI since PySide can read the .ui files it out

Re: PyQT - Signals and Slots?

2016-10-10 Thread Mark Summerfield
The ZeroSpinBox is a tiny example designed to show how the signal/slot mechanism works. It is just a QSpinBox with the addition of remembering how many times (all the) ZeroSpinBox(es) have had a 0 value. Nowadays the connections would be made with a new improved syntax: self.connect(self, SIGNAL

Re: Solid Approach For Creating A Desktop Application

2016-10-10 Thread Mark Summerfield
On Monday, October 10, 2016 at 5:53:37 AM UTC+1, Mahan Marwat wrote: > I want to know what will be your approach creating a solid/reliable > application in Python? > i.e > 1. Which GUI framework will you use i.e PyQT or what? (will you make it work > removing the window default border) > 2. What

Re: What is the correct form for saying "licensed under the same terms as Python itself"?

2016-09-14 Thread Mark Summerfield
Thanks v. much: I'll use the Apache 2.0 license. -- https://mail.python.org/mailman/listinfo/python-list

What is the correct form for saying "licensed under the same terms as Python itself"?

2016-09-14 Thread Mark Summerfield
Hi, I'm developing a small Python software library that I want to publish as free software under the same terms as Python itself. I notice that a few of Python's own files begin like this: # Copyright 2007 XXX. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. Is this form

Is it possible to process dist files before they are build via a setuptools hook?

2016-09-09 Thread Mark Summerfield
Hi, I use setuptools (in my case with cx_Freeze) to package some of my Python applications. As part of this process a build\exe.win-amd64-3.4 dir is created with all the necessary files, and then a separate dist\ dir is created with the distributable package (e.g., a .msi file). I'd like to r

Re: Getting back into PyQt and not loving it.

2016-06-27 Thread Mark Summerfield
On Monday, June 27, 2016 at 3:12:34 AM UTC+1, MRAB wrote: [snip] > > Not sure that wxPython is really any different in that respect, and Tkinter > > doesn't feel Pythonic to me, either -- considering how it's Tk at heart. > > So what's the alternative? There really is no good Python-based GUI t

Re: PyQt5: is the wrapper incomplete?

2016-06-16 Thread Mark Summerfield
On Thursday, June 16, 2016 at 8:22:33 AM UTC+1, Mark Summerfield wrote: > On Thursday, June 16, 2016 at 3:54:53 AM UTC+1, jlad...@itu.edu wrote: > > I am developing a data acquisition system for a custom device that > > communicates over USB. On the host computer side, I am usi

Re: PyQt5: is the wrapper incomplete?

2016-06-16 Thread Mark Summerfield
On Thursday, June 16, 2016 at 3:54:53 AM UTC+1, jlad...@itu.edu wrote: > I am developing a data acquisition system for a custom device that > communicates over USB. On the host computer side, I am using PyQt5.4. My > Linux box has both Qt4 and Qt5 installed on it. I assume that PyQt5.4 > comp

Re: what is wrong with this property setter

2016-06-09 Thread Mark Summerfield
On Thursday, June 9, 2016 at 8:28:47 AM UTC+1, Nagy László Zsolt wrote: > class Test: > def __init__(self): > self._parent = None > > @property > def parent(self): > return self._parent > > @parent.setter > def set_parent(self, new_parent): > self._pare

Re: Trying to pass sys.argv as (int argc, char **argv) using ctypes

2016-06-06 Thread Mark Summerfield
Thanks, that works! And also thanks for the excellent explanations of each part. -- https://mail.python.org/mailman/listinfo/python-list

Trying to pass sys.argv as (int argc, char **argv) using ctypes

2016-06-06 Thread Mark Summerfield
Hi, I have a setup roughly like this: import ctypes import sys Lib = ctypes.cdll.LoadLibrary("libthing") c_char_pp = ctypes.POINTER(ctypes.c_char_p) LibOpen = Lib.Open LibOpen.argtypes = (ctypes.c_int, # argc c_char_pp) # argv LibOpen.restype = ctypes.c_int

Re: Spreading a class over multiple files

2016-06-05 Thread Mark Summerfield
You're quite right! For some reason I have a blind-spot about mixins, but they are the perfect solution. Thanks:-) -- https://mail.python.org/mailman/listinfo/python-list

Spreading a class over multiple files

2016-06-05 Thread Mark Summerfield
Sometimes I want to spread a class over multiple files. My primary use case is when I create a "Model" class to reflect an entire SQL database. I want a model instance to provide a single point of access to the database, but the database has many tables each requiring its own methods since they

Spread a class over multiple files

2016-06-04 Thread Mark Summerfield
Sometimes I want to spread a class over multiple files. My primary use case is when I create a "Model" class to reflect an entire SQL database. I want a model instance to provide a single point of access to the database, but the database has many tables each requiring its own methods since they

Re: setup failed

2016-02-08 Thread Mark Summerfield
On Monday, February 8, 2016 at 10:50:19 AM UTC, Mark Summerfield wrote: > If you need 32-bit Python on Windows my advice is to install 3.4. If you need > 32-bit and 64-bit Python on Windows, then I think it will only work with 3.4 > (or older), but not with 3.5's new installer. >

Re: setup failed

2016-02-08 Thread Mark Summerfield
If you need 32-bit Python on Windows my advice is to install 3.4. If you need 32-bit and 64-bit Python on Windows, then I think it will only work with 3.4 (or older), but not with 3.5's new installer. I have tried installing 3.5.0 and 3.5.1 on several machines both 32- and 64-bit Windows. The 3

Re: [RELEASED] Python 3.5.0a4 is now available

2015-04-20 Thread Mark Summerfield
be run as > part of a larger application's installer for apps using or extending > Python. I can't see any mention of this in https://docs.python.org/dev/whatsnew/3.5.html Best wishes, -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu Python and PyQt/PySide - training and consul

Is anyone doing Python 3 bindings for the IUP GUI library?

2015-01-14 Thread Mark Summerfield
Just wondering if anyone is doing Python 3 bindings for the IUP GUI library? The library is pure C and GUI only (so not a giant framework), and uses native controls. It comes with Lua bindings and I believe there are third-party Ruby bindings. http://webserver2.tecgraf.puc-rio.br/iup/ -- https:/

Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-18 Thread Mark Summerfield
On Thursday, December 11, 2014 4:53:04 AM UTC, iMath wrote: > I think the user interface shouldn't be freezed when using > concurrent.futures.ThreadPoolExecutor here,as it executes asynchronously , > but it doesn't meet my expectations,anyone can explain why ? any other > solutions here to not l

Re: bug or feature in enum34 py2.7 backport?

2014-11-26 Thread Mark Summerfield
6 PM UTC, Chris Angelico wrote: > On Thu, Nov 27, 2014 at 1:05 AM, wrote: > > On Wed, Nov 26, 2014, at 06:29, Mark Summerfield wrote: > >> TypeError: type() argument 1 must be string, not unicode > > > > If this is a bug, maybe it is one in type() itself - I get the same

Re: GUI toolkit(s) status

2014-11-26 Thread Mark Summerfield
I've done a fair bit of Python GUI programming, so here's my 2c. Tkinter is small, fast, and v. frustrating to use (but maybe the latter is just me). It looks good on Windows (from 8.5), ugly on Linux, and OK on Mac (but you have to do a fair bit of if MAC do this else do that. The next three w

bug or feature in enum34 py2.7 backport?

2014-11-26 Thread Mark Summerfield
Hi, Here are two programs both executed with Python 2.7 with the enum34 backport and their output. Is this a bug or intended behavior? (It may well be intended to help ensure that the class name is ASCII for Python 2; but maybe it would be nicer to check a unicode to see if it is ASCII and if s

Re: Correct type for a simple "bag of attributes" namespace object (was: 3 Suggestions to Make Python Easier For Children)

2014-08-02 Thread Mark Summerfield
On Saturday, 2 August 2014 20:58:59 UTC+1, Ben Finney wrote: > Steven D'Aprano writes: > > > If you need instances which carry state, then object is the wrong > > class. Fair enough. > Right. The 'types' module provides a SimpleNamespace class for the > common "bag of attributes" use case:: >

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Mark Summerfield
On Saturday, 2 August 2014 08:46:04 UTC+1, Mark Lawrence wrote: > On 02/08/2014 07:45, Mark Summerfield wrote: > [snip] > > > Suggestion #1: Make IDLE start in the user's home directory. > > Entirely agree. Please raise an enhancement request on the bug tracker &g

Re: 3 Suggestions to Make Python Easier For Children

2014-08-02 Thread Mark Summerfield
On Saturday, 2 August 2014 08:14:08 UTC+1, Marko Rauhamaa wrote: > Mark Summerfield: > > > Suggestion #1: Make IDLE start in the user's home directory. > > > Suggestion #2: Make all the turtle examples begin "from turtle import > > *" so no

3 Suggestions to Make Python Easier For Children

2014-08-01 Thread Mark Summerfield
Last week I spent a couple of days teaching two children (10 and 13 -- too big an age gap!) how to do some turtle graphics with Python. Neither had programmed Python before -- one is a Minecraft ace and the other had done Scratch. Suggestion #1: Make IDLE start in the user's home directory. Sug

Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Mark Summerfield
On Monday, 17 March 2014 08:44:23 UTC, Mark Summerfield wrote: > Hi, > > > > What is the correct idiom for getting the path to a top-level module in 3.3 > and 3.4 when the module might be frozen? > > > > At the moment I'm using this: > >

Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Mark Summerfield
Hi, What is the correct idiom for getting the path to a top-level module in 3.3 and 3.4 when the module might be frozen? At the moment I'm using this: if getattr(sys, "frozen", False): path = os.path.dirname(sys.executable) else: path = os.path.dirname(__file__) Thanks!

Re: SQLite + FTS (full text search)

2014-01-23 Thread Mark Summerfield
On Thursday, 23 January 2014 14:09:19 UTC, Antoine Pitrou wrote: > Hi, > > > > Mark Summerfield qtrac.plus.com> writes: > > > > > > My guess is that on Debian, the packagers install a full SQLite 3 and the > > Python package uses that. But on &

SQLite + FTS (full text search)

2014-01-23 Thread Mark Summerfield
Hi, On my Debian stable 64-bit system, SQLite3 has FTS (full text search) enabled (although at version 3 rather than the recommended version 4): Python 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2] on linux2 Type "copyright", "credits" or "license()" for more information. >>> import sqlite3

Re: how to get raw bytes for ctypes functions that return c_wchar_p

2013-11-19 Thread Mark Summerfield
On Tuesday, November 19, 2013 5:22:36 PM UTC, Thomas Heller wrote: > Am 19.11.2013 17:58, schrieb Mark Summerfield: > > > Hi, > > > > > > I am using ctypes to access a function in a DLL using Python 3.3 > > > 32-bit on Windows 7 64-bit: > >

how to get raw bytes for ctypes functions that return c_wchar_p

2013-11-19 Thread Mark Summerfield
Hi, I am using ctypes to access a function in a DLL using Python 3.3 32-bit on Windows 7 64-bit: dplGetPageText = dpl.DPLGetPageText dplGetPageText.argtypes = (ctypes.c_int, ctypes.c_int) dplGetPageText.restype = ctypes.c_wchar_p Python returns this as a str with the raw bytes already decoded.

New book: Python in Practice

2013-08-22 Thread Mark Summerfield
Hi, My new Python 3-based book, "Python in Practice", is due out next week. The book is aimed at people who can already program in Python and want to take their coding further. The book's web page (http://www.qtrac.eu/pipbook.html) has the table of contents and a link to a free PDF of Chapter 1

concurrent.futures inconsistency?

2012-08-24 Thread Mark Summerfield
Hi, It seems that in concurrent.futures, ProcessPoolExecutor() can be used with no args and default to max_workers=multiprocessing.cpu_count(); but for ThreadPoolExecutor() the max_workers arg is required. Is this intentional? (I'm using Python 3.2.) -- http://mail.python.org/mailman/listinfo/pyt

ttk.Spinbox missing?

2012-06-06 Thread Mark Summerfield
Hi, I have Python 3.2 with Tcl/Tk 8.5, but there doesn't seem to be a ttk.Spinbox widget even though that widget is part of Tcl/Tk 8.5: http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_spinbox.htm Why is that? -- http://mail.python.org/mailman/listinfo/python-list

Re: Use a locally built Tk for Python?

2012-06-04 Thread Mark Summerfield
Thanks for your thoughtful replies. I don't use altinstall because using --prefix is sufficient to get a locally built Python. Both your suggestions require root (or sudo) and changing the system itself. Whereas I was hoping to just build a local Python and install my own Tcl/Tk in its lib and si

How to Test GUI Apps for many Python X GUI toolkits

2012-06-03 Thread Mark Summerfield
Hi, There are many options for writing desktop GUI applications with Python and I'd like to explore some of them. However, to do this I need to be able to test various Python 3.x X GUI toolkit y.z combinations. With PyQt4 this is easy. (Example given at the end.) I'd like to be able to do the sa

Use a locally built Tk for Python?

2012-06-01 Thread Mark Summerfield
Hi, I have multiple Pythons locally installed so that I can test against different versions. (On a 64-bit Debian stable system.) All of them use the system's Tcl/Tk installation. However, I want to make some of them use a locally build Tcl/Tk that has a small customization. There doesn't seem to

Re: [python-committers] [RELEASED] Python 3.2 rc 3

2011-02-14 Thread Mark Summerfield
les" in What's New in alphabetical order? -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy Programming in Python 3" - ISBN 0321680561 http://www.qtrac.eu/py3book.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator question

2011-01-27 Thread Mark Summerfield
On Jan 27, 2:42 am, "Thomas L. Shinnick" wrote: > At 08:17 PM 1/26/2011, Chris wrote: > > >I have a class (A, for instance) that possesses a boolean (A.b, for > >instance) that is liable to change over an instance's lifetime. > > >Many of the methods of this class (A.foo, for instance) should not

Re: Which is the best book to learn python

2011-01-25 Thread Mark Summerfield
On Jan 24, 5:09 pm, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice If you want to learn Python 3 and have some prior programming experience (in any modern procedural or object oriented language), you m

Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1

2011-01-17 Thread Mark Summerfield
On Mon, 17 Jan 2011 09:23:39 -0500 "R. David Murray" wrote: > On Mon, 17 Jan 2011 08:33:42 +, Mark Summerfield > wrote: > > from ..Graphics import Xpm > > SVG = 1 > > > > I can do the relative import with Python 3.0 and 3.1 but not with > > 3.2

Re: [python-committers] [RELEASED] Python 3.2 rc 1

2011-01-17 Thread Mark Summerfield
2011, 08:32:59) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from Graphics.Vector import * Traceback (most recent call last): File "", line 1, in File "Graphics/Vector/Sv

Re: [python-committers] [RELEASED] Python 3.2 rc 1

2011-01-16 Thread Mark Summerfield
ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='a' encoding='UTF-8'> which looks pretty good:-) However, I hit a problem with relative imports not working (compared with 3.1). I have to go now but will try to produce a small example if I can.

Re: [Python-Dev] [RELEASED] Python 3.2 alpha 3

2010-11-16 Thread Mark Summerfield
might add: "The xml.etree.ElementTree now raises an xml.etree.ElementTree.ParseError when a parse fails; previously it raised a xml.parsers.expat.ExpatError." It would also be nice to mention this in the ElementTree module's documentation for the

Re: Moving from Python 2 to Python 3: 4 page "cheat sheet" issue#3

2009-12-04 Thread Mark Summerfield
On 3 Dec, 01:17, Antoine Pitrou wrote: > Le Tue, 01 Dec 2009 06:03:36 -0800, Mark Summerfield a écrit : > > > I've produced a 4 page document that provides a very concise summary of > > Python 2<->3 differences plus the most commonly used new Python 3 > > featu

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 2 Dec, 21:28, David H Wild wrote: > In article > <9d290ad6-e0b8-4bfa-92c8-8209c7e93...@a21g2000yqc.googlegroups.com>, >    Mark Summerfield wrote: > > > > There is a typographical fault on page 4 of this pdf file. The letter > > > "P" is mis

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 3 Dec, 01:17, Antoine Pitrou wrote: > Le Tue, 01 Dec 2009 06:03:36 -0800, Mark Summerfield a écrit : > > > I've produced a 4 page document that provides a very concise summary of > > Python 2<->3 differences plus the most commonly used new Python 3 > > featu

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 2 Dec, 20:59, MRAB wrote: > Mark Summerfield wrote: > > On 2 Dec, 19:28, David H Wild wrote: > >> In article > >> <351fcb4c-4e88-41b0-a0aa-b3d63832d...@e23g2000yqd.googlegroups.com>, > >>    Mark Summerfield wrote: > > >>> I only j

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 2 Dec, 22:49, "John Posner" wrote: > On Wed, 02 Dec 2009 13:34:11 -0500, Carsten Haese   > > wrote: > > > With string interpolation, you don't need to do that, either. > '%*d' % (8,456) > > '     456' > > Thanks, Carsten and Mark D. -- I'd forgotten about the use of "*" in   > minimum-fie

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 2 Dec, 19:28, David H Wild wrote: > In article > <351fcb4c-4e88-41b0-a0aa-b3d63832d...@e23g2000yqd.googlegroups.com>, >    Mark Summerfield wrote: > > > I only just found out that I was supposed to give a different URL: > >http://www.informit.com/promotio

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 4:22 pm, Mark Summerfield wrote: > On Dec 2, 11:31 am, "Martin P. Hellwig" > wrote: > > > MarkSummerfieldwrote: > > > > It is available as a free PDF download (no registration or anything) > > > from InformIT's website. Here

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 11:31 am, "Martin P. Hellwig" wrote: > MarkSummerfieldwrote: > > > It is available as a free PDF download (no registration or anything) > > from InformIT's website. Here's the direct link: > >http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/... > > > Very handy! Am I

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 11:20 am, Wolodja Wentland wrote: > On Wed, Dec 02, 2009 at 00:10 -0800, Mark Summerfield wrote: > > On 1 Dec, 18:30, Lie Ryan wrote: > > > Also, I'm not sure what this change is referring to: > > > Python 2                 Python 3 > > >

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 8:53 am, Mark Dickinson wrote: > On Dec 2, 8:01 am, MarkSummerfield wrote: > > > On 1 Dec, 17:50, Mark Dickinson wrote: > > > My only quibble is with the statement on the first page that > > > the 'String % operator is deprecated'.  I'm not sure that's > > > true, for all values of 'dep

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 1, 2:03 pm, Mark Summerfield wrote: > I've produced a 4 page document that provides a very concise summary > of Python 2<->3 differences plus the most commonly used new Python 3 > features. It is aimed at existing Python 2 programmers who want to > start writing Pyt

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 23:52, John Bokma wrote: > Mark Summerfield writes: > > It is available as a free PDF download (no registration or anything) > > from InformIT's website. Here's the direct link: > >http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/...

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 21:55, Terry Reedy wrote: > Mark Summerfield wrote: > > I've produced a 4 page document that provides a very concise summary > > of Python 2<->3 differences plus the most commonly used new Python 3 > > features. It is aimed at existing Python 2 programme

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 18:30, Lie Ryan wrote: > On 12/2/2009 1:03 AM, Mark Summerfield wrote: > > > > > I've produced a 4 page document that provides a very concise summary > > of Python 2<->3 differences plus the most commonly used new Python 3 > > features. It is a

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 17:50, Mark Dickinson wrote: > On Dec 1, 2:03 pm, Mark Summerfield wrote: > > > I've produced a 4 page document that provides a very concise summary > > of Python 2<->3 differences plus the most commonly used new Python 3 > > features. > > Very

Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-01 Thread Mark Summerfield
I've produced a 4 page document that provides a very concise summary of Python 2<->3 differences plus the most commonly used new Python 3 features. It is aimed at existing Python 2 programmers who want to start writing Python 3 programs and want to use Python 3 idioms rather than those from Python

Book: Programming Python 3 (Second Edition) now available

2009-11-20 Thread Mark Summerfield
Hi, I'm delighted to announce that a new edition of my Python 3 book is now available in the U.S. "Programming in Python 3 (Second Edition): A Complete Introduction to the Python Language" ISBN 0321680561 http://www.qtrac.eu/py3book.html The book has been fully revised and updated and now covers

New Book: Programming in Python 3 (Second Edition)

2009-10-01 Thread Mark Summerfield
Hi, A new edition of my Python 3 book will be available in the U.S. next month, and elsewhere in December or January: "Programming in Python 3 (Second Edition): A Complete Introduction to the Python Language" ISBN 0321680561 http://www.qtrac.eu/py3book.html The book is aimed at a wide audience,

Why aren't OrderedDicts comparable with < etc?

2009-07-15 Thread Mark Summerfield
Hi, I'm just wondering why <, <=, >=, and > are not supported by collections.OrderedDict: >>> d1 = collections.OrderedDict((("a",1),("z",2),("k",3))) >>> d2 = d1.copy() >>> d2["z"] = 4 >>> d1 == d2 False >>> d1 < d2 Traceback (most recent call last): File "", line

Re: Public attributes with really private data

2009-05-08 Thread Mark Summerfield
On 8 May, 13:56, Peter Otten <__pete...@web.de> wrote: > Mark Summerfield wrote: > > On 8 May, 08:19, Peter Otten <__pete...@web.de> wrote: > >> MarkSummerfieldwrote: > >> > I had a quick search & didn't find anything _nice_ that produced >

Re: Public attributes with really private data

2009-05-08 Thread Mark Summerfield
values are shared between all instances of the same class: > > >>> class A: > > ...     x = Attribute("x", 42, lambda *a: True) > ...>>> a = A() > >>> b = A() > >>> a.x, b.x > (42, 42) > >>> a.x = "yadda" > >>> a.x, b.x > > ('yadda', 'yadda') > > Peter Yes. I did think of trying to create the closures dynamically the first time the getter or setter was called---but that _is_ getting ugly, so I'll give it up:-) Thanks! -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Programming in Python 3" - ISBN 0137129297 -- http://mail.python.org/mailman/listinfo/python-list

Re: Public attributes with really private data

2009-05-08 Thread Mark Summerfield
[snip] > By the way, your Attribute descriptor stores the value for all instances of > A in the same variable... > > Peter You're right. -- http://mail.python.org/mailman/listinfo/python-list

Re: Public attributes with really private data

2009-05-08 Thread Mark Summerfield
it.) > I am not opposed to adding a little well-considered protection to some > attributes where mistakes are prone to happen and/or dangerous, but it > is futile to try to stop access entirely.  There's just too many back > doors. Sure, but I like the fact that there is no "

Re: Public attributes with really private data

2009-05-08 Thread Mark Summerfield
= Attribute("a", 5, lambda *a: True) b = Attribute("b", 5, lambda *a: True) >>> a = A() >>> b = B() >>> a.a,a.b,b.a,b.b (5, 5, 5, 5) >>> a.a=1;a.b=2;b.a=3;b.b=4 >>> a.a,a.b,b.a,b.b (1, 2, 3, 4) -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy "Programming in Python 3" - ISBN 0137129297 -- http://mail.python.org/mailman/listinfo/python-list

Public attributes with really private data

2009-05-07 Thread Mark Summerfield
ner=None): if instance is None: return self return self.__getter(instance) def __set__(self, instance, value): if self.__setter is None: raise AttributeError("'{0}' is read-only".format( self.__name__))

Re: ANN: New Book: Programming in Python 3

2008-12-20 Thread Mark Summerfield
On 20 Dec, 00:32, "Colin J. Williams" wrote: > Thomas Heller wrote: > > Mark Summerfield schrieb: > >> Just a follow-up to say that the book has now been published in the > >> U.S. > >> It is now in stock at InformIT, and should reach other stores, e

Re: ANN: New Book: Programming in Python 3

2008-12-19 Thread Mark Summerfield
On 19 Dec, 19:52, excord80 wrote: > On Dec 4, 2:42 pm, Alan G Isaac wrote: > > > Mark Summerfield wrote: > > > "Programming in Python 3: > > > A Complete Introduction to the Python Language" > > > ISBN 0137129297 > > >http://www.qtrac.eu/

Re: ANN: New Book: Programming in Python 3

2008-12-19 Thread Mark Summerfield
shows a validation technique that combines class decorators with descriptors.) On 4 Dec, 15:02, Mark Summerfield wrote: > Now that Python 3 final has been released I thought it would be a good time > to mention that there's a new book to go with it: > > "Programming in

Re: ANN: New Book: Programming in Python 3

2008-12-04 Thread Mark Summerfield
On 2008-12-04, Dotan Cohen wrote: > 2008/12/4 Mark Summerfield <[EMAIL PROTECTED]>: > > Now that Python 3 final has been released I thought it would be a good > > time to mention that there's a new book to go with it: > > > > "Programming in Python 3

ANN: New Book: Programming in Python 3

2008-12-04 Thread Mark Summerfield
eful (although small and basic) programs after reading chapter 1, and then go on to create larger and more sophisticated programs as they work through the chapters. -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu -- http://mail.python.org/mailman/listinfo/python-list

Re: Books to begin learning Python

2008-08-08 Thread Mark Summerfield
On 7 Aug, 21:10, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Aug 7, 1:12 pm, Beliavsky <[EMAIL PROTECTED]> wrote: > > > > > On Aug 6, 4:08 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > > > On Aug 6, 2:56 pm, Edward Cormier <[EMAIL PROTECTED]> wrote: > > > > > Which computer books are the best

Re: sorteddict PEP proposal [started off as orderedict]

2007-10-12 Thread Mark Summerfield
On 12 Oct, 09:17, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > Mark Summerfield <[EMAIL PROTECTED]> writes: > > Below is a PEP proposal for a sorteddict. ... > > Is this proposal dead? I'd been meaning to post some thoughts which I > still haven't gotte

Re: sorteddict [was a PEP proposal, but isn't anymore!]

2007-09-27 Thread Mark Summerfield
On 26 Sep, 18:59, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Mark Summerfield] > > > Below is a PEP proposal for a sorteddict. It arises out of a > > discussion on this list that began a few weeks ago with the subject of > > "An ordered dictionary for t

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-27 Thread Mark Summerfield
On 27 Sep, 08:32, Duncan Booth <[EMAIL PROTECTED]> wrote: > Paul Hankin <[EMAIL PROTECTED]> wrote: > >> A key which is in dict must be either in __keycache or in __addkeys, but > >> never in both. > > > Yes, I'm sorry: you're right. > > > But there's a different bug: if you delete a key that's not

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-26 Thread Mark Summerfield
On 26 Sep, 16:20, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Sep 26, 3:24 pm, Mark Summerfield <[EMAIL PROTECTED]> > wrote: > > > On 26 Sep, 14:59, Paul Hankin <[EMAIL PROTECTED]> wrote: > > > > On Sep 26, 2:46 pm, Duncan Booth <[EMAIL PROTECTED]

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-26 Thread Mark Summerfield
On 26 Sep, 14:59, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Sep 26, 2:46 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > > Paul Hankin <[EMAIL PROTECTED]> wrote: > > > More flexibly, keep a set of inserted keys that haven't yet been > > > included in the sorted list, and a set of deleted keys tha

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-26 Thread Mark Summerfield
On 26 Sep, 13:22, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2007-09-26, Mark Summerfield <[EMAIL PROTECTED]> wrote: > > > > > On 26 Sep, 11:27, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > >> Mark Summerfield <[EMAIL PROTECTED]> writes: >

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-26 Thread Mark Summerfield
On 26 Sep, 11:27, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Mark Summerfield <[EMAIL PROTECTED]> writes: > > On 26 Sep, 09:51, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > >> Duncan Booth <[EMAIL PROTECTED]> writes: > >> > I that's the p

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-26 Thread Mark Summerfield
On 26 Sep, 09:51, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Duncan Booth <[EMAIL PROTECTED]> writes: > > I that's the point though: you can't write one implementation that has good > > performance for all patterns of use > > An implementation of sorted dict using a balanced tree as the > underlyin

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-26 Thread Mark Summerfield
On 25 Sep, 22:33, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Sep 25, 9:55 pm, Mark Summerfield <[EMAIL PROTECTED]> > wrote: > > > ... > > class sorteddict(dict): > > > ... > > if self.__keys is None: > >

Re: sorteddict PEP proposal [started off as orderedict]

2007-09-25 Thread Mark Summerfield
On 25 Sep, 20:28, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Sep 25, 7:58 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > > > > > > Paul Hankin wrote: > > > ... > > > class sorteddict(dict): > > > "A sorted dictionary" > > > def __init__(self, arg=None, cmp=None, key=None, reverse=False):

  1   2   >