Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Phil Thompson wrote:

On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
wrote:

A bit nasty, since I see (and follow) lots of examples that say:
from PyQt4.QtCore import *

This redefines the builtin hex.


Check the Roadmap.


Appending a _ just to make an unpleasant style of programming work seems 
like a pretty silly idea.


I, along with everyone else who's tryng to learn a new python package, 
absolutely *hate* from x import * as it makes it much more difficult 
figure out where something is coming from.


I did raise this with David when this very issue tripped me and a number 
of other people up at the PyConUK tutorial last year.


If this were done sanely, you'd likely have:

from PyQt4.QtCore import hex

...somewhere, which, if it's causing problems, can easilly be changed to:

from PyQt4.QtCore import hex as qt_hex

Or, if you don't want do have a load of import statements, you can use 
the style that xlrd seems to prefer:


from PyQt4 import QtCore
...
QtCore.hex(...)

Either way, you end up knowing where stuff if coming from...

cheers,

Chris (who's still putting off using PyQt as he's dreading fighting his 
way through a load of *'s)


--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Giovanni Bajo
On mer, 2009-01-07 at 09:26 +, Chris Withers wrote:
 Phil Thompson wrote:
  On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
  wrote:
  A bit nasty, since I see (and follow) lots of examples that say:
  from PyQt4.QtCore import *
 
  This redefines the builtin hex.
  
  Check the Roadmap.
 
 Appending a _ just to make an unpleasant style of programming work seems 
 like a pretty silly idea.
 
 I, along with everyone else who's tryng to learn a new python package, 
 absolutely *hate* from x import * as it makes it much more difficult 
 figure out where something is coming from.

So don't use it.

This has been discussed thousands of times and it starts getting
annoying. There are many people (including myself and all our customers)
that simply love using star-imports with PyQt, since the leading Q* on
most symbols is already a clear enough indication of where the symbol is
coming from.

Appending the underscore to those symbols is a perfect fix IMO. I don't
see why people that don't use star-imports in the first place should
care about it at all.
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Phil Thompson wrote:

This has been discussed thousands of times and it starts getting
annoying. 
Yes, it is annoying that all the example code continues to be in a form 
that confuses users trying to learn PyQt.


*None* of the PyQt4 examples uses star imports.


Hmmm, apologies then, must have been exclusively a problem with Mark 
Summerfield's tutorial stuff.


(and in my previous mail when I said David I actually meant Mark, 
happy new year ;-) )


FWIW, I still think sticking a _ on the end of the name is silly...

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Giovanni Bajo
On mer, 2009-01-07 at 10:33 +, Chris Withers wrote:
 However, like most people, I learn by example, and when the examples 
 contain exclusively start imports, they are much less helpful than
 they could be.

I don't understand you. Are you really saying that it's harder to
understand that QListBox or QVariant is part of PyQt4 because it's not
prefixed by QtGui. or QtCore.?
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Adeodato Simó
* Giovanni Bajo [Wed, 07 Jan 2009 11:06:09 +0100]:

 Appending the underscore to those symbols is a perfect fix IMO.

I realize this is a matter of preference, but I'd suggest using qbin()
and qhex() rather than the underscore: I think it makes more sense for
stuff that can be imported into the global namespace (as opposed to
stuff as exec_() that can only be attached to an object).

If you see in the middle of a program hex_(foo), you may wonder where
that came from, whereas qhex(foo) is going to be rather obvious.

Of course, do what you think it's best. :-)

-- 
Adeodato Simó dato at net.com.org.es
Debian Developer  adeodato at debian.org
 
- I love you, Shirley, I'm not ashamed to say.
- If you love me, then you'll want me to be happy. Even if I'm not with you.
- I don't love you that much.
-- Denny Crane and Shirley Schmidt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Phil Thompson
On Wed, 07 Jan 2009 10:33:00 +, Chris Withers ch...@simplistix.co.uk
wrote:
 Giovanni Bajo wrote:
 On mer, 2009-01-07 at 09:26 +, Chris Withers wrote:
 Phil Thompson wrote:
 On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
 wrote:
 A bit nasty, since I see (and follow) lots of examples that say:
 from PyQt4.QtCore import *

 This redefines the builtin hex.
 Check the Roadmap.
 Appending a _ just to make an unpleasant style of programming work
seems

 like a pretty silly idea.

 I, along with everyone else who's tryng to learn a new python package, 
 absolutely *hate* from x import * as it makes it much more difficult 
 figure out where something is coming from.
 
 So don't use it.
 
 You rather miss my point.
 
 I don't ever use star imports anyway.
 
 However, like most people, I learn by example, and when the examples 
 contain exclusively start imports, they are much less helpful than they 
 could be.
 
 It's a shame PEP8 doesn't make a pronouncement on this. PEP 328 is 
 pretty clear though...
 
 This has been discussed thousands of times and it starts getting
 annoying. 
 
 Yes, it is annoying that all the example code continues to be in a form 
 that confuses users trying to learn PyQt.

*None* of the PyQt4 examples uses star imports.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Giovanni Bajo wrote:

On mer, 2009-01-07 at 09:26 +, Chris Withers wrote:

Phil Thompson wrote:

On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
wrote:

A bit nasty, since I see (and follow) lots of examples that say:
from PyQt4.QtCore import *

This redefines the builtin hex.

Check the Roadmap.
Appending a _ just to make an unpleasant style of programming work seems 
like a pretty silly idea.


I, along with everyone else who's tryng to learn a new python package, 
absolutely *hate* from x import * as it makes it much more difficult 
figure out where something is coming from.


So don't use it.


You rather miss my point.

I don't ever use star imports anyway.

However, like most people, I learn by example, and when the examples 
contain exclusively start imports, they are much less helpful than they 
could be.


It's a shame PEP8 doesn't make a pronouncement on this. PEP 328 is 
pretty clear though...



This has been discussed thousands of times and it starts getting
annoying. 


Yes, it is annoying that all the example code continues to be in a form 
that confuses users trying to learn PyQt.



There are many people (including myself and all our customers)
that simply love using star-imports with PyQt, since the leading Q* on
most symbols is already a clear enough indication of where the symbol is
coming from.


What you and/or your customers do in the privacy of your own homes and 
offices is none of my concern ;-)



Appending the underscore to those symbols is a perfect fix IMO. I don't
see why people that don't use star-imports in the first place should
care about it at all.


Because it looks butt ugly for no reason.

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Neal Becker wrote:
If the pyqt examples did not use *, and if you could import a useful enough 
subset without doing that, I'd agree.  If the suggestion is to explicitly 
qualify everything, I don't think that's reasonable.


Yes, python, well know for believing that implicit is better than 
explicit ;-)


Chris . o O ( import this )

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Mark Summerfield
On 2009-01-07, Chris Withers wrote:
 Phil Thompson wrote:
  This has been discussed thousands of times and it starts getting
  annoying.
 
  Yes, it is annoying that all the example code continues to be in a form
  that confuses users trying to learn PyQt.
 
  *None* of the PyQt4 examples uses star imports.

 Hmmm, apologies then, must have been exclusively a problem with Mark
 Summerfield's tutorial stuff.

I have now switched to a new style for imports, for example:

from PyQt4.QtCore import (PYQT_VERSION_STR, QFile, QFileInfo, QSettings,
QString, QT_VERSION_STR, QTimer, QVariant, Qt, SIGNAL)
from PyQt4.QtGui import (QAction, QActionGroup, QApplication,
QDockWidget, QFileDialog, QFrame, QIcon, QImage, QImageReader,
QImageWriter, QInputDialog, QKeySequence, QLabel, QListWidget,
QMainWindow, QMessageBox, QPainter, QPixmap, QPrintDialog,
QPrinter, QSpinBox)

This avoids importing confusing junk while still allowing you to write
nice things like:

action = QAction(Action)

The disadvantage is that you keep having to extend the lists of imports
as you develop and maintain your code.

I don't want to change this for the book's examples because I want them
to exactly match the text---although actually, the only change is to the
imports, the use of the classes is unchanged. However I've done a
separate set of Python 2.6 versions of the examples and these use the new
import style.

 FWIW, I still think sticking a _ on the end of the name is silly...

Yes, but it has precedents in PyQt already, e.g. QApplication.exec_().


 (and in my previous mail when I said David I actually meant Mark,
 happy new year ;-) )

Understandable since David is a much more regular poster than I am:-)

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
Programming in Python 3 - ISBN 0137129297

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Sundance
Adeodato Simó wrote:

If you see in the middle of a program hex_(foo), you may wonder where
that came from, whereas qhex(foo) is going to be rather obvious.

Greetings all,

Might I humbly second this motion? I do understand the usual 
reservations about star-imports (being the kind of guy that often gets 
to debug other people's work...), but I also do appreciate the relative 
ease of getting away with it in PyQt's case, thanks to the prevalence of 
the Q prefix in its class names and its relative absence of module-level 
functions.

With this in mind, using the same prefix for the three problematic 
functions makes good sense to me. Are there reservations about this 
approach that I may not be aware of?

Ta,

-- S.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Jim Bublitz
On Wednesday 07 January 2009 05:27:06 am Sundance wrote:
 Adeodato Simó wrote:
 If you see in the middle of a program hex_(foo), you may wonder
  where that came from, whereas qhex(foo) is going to be rather
  obvious.

 Greetings all,

 Might I humbly second this motion? I do understand the usual
 reservations about star-imports (being the kind of guy that often
 gets to debug other people's work...), but I also do appreciate the
 relative ease of getting away with it in PyQt's case, thanks to the
 prevalence of the Q prefix in its class names and its relative
 absence of module-level functions.

 With this in mind, using the same prefix for the three problematic
 functions makes good sense to me. Are there reservations about this
 approach that I may not be aware of?

One problem I'd see is that 'qhex' doesn't sort alphabetically the same 
as 'hex' or 'hex_' does. Also, other bindings - like PyKDE - have the 
same problem. In the case of PyKDE, it's in a lot more than three 
places. That makes it a lot harder for people to find it in the docs, 
especially if they're coming from or reconciling with Qt or KDE docs 
and method names. 

The 'q*' convention doesn't make a lot of sense for other bindings 
packages, and the underscore seems less likely to clash with other 
people's naming schemes, although in the case of PyQt a clash seems to 
have a fairly low probability either way. 

As to the ugliness factor, I somewhat agree, but then we're talking 
about a language that uses things like __init__  or __main__ all over 
the place. 

As to '*' imports - having done a lot of C/C++ where you have to declare 
every variable, declaring objects in an import statement isn't that 
difficult. And IIRC, PyKDE4 inherits name clashes between modules from 
KDE itself in a couple of places.

Jim

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] PyQt4.Qtcore defines 'hex'

2009-01-06 Thread Neal Becker
A bit nasty, since I see (and follow) lots of examples that say:
from PyQt4.QtCore import *

This redefines the builtin hex.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-06 Thread Phil Thompson
On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
wrote:
 A bit nasty, since I see (and follow) lots of examples that say:
 from PyQt4.QtCore import *
 
 This redefines the builtin hex.

Check the Roadmap.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-06 Thread David Boddie
On Tue Jan 6 22:05:41 GMT 2009, Phil Thompson wrote:

 On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbecker2 at gmail.com

  This redefines the builtin hex.

 Check the Roadmap.

http://www.riverbankcomputing.com/software/pyqt/roadmap

...for those not following the site updates so closely. :-)

David
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt