Python Feature Request: Add the "using" keyword which works like"with" in Visual Basic
Terry Reedy
tjreedy at udel.edu
Sat Apr 14 18:48:06 EDT 2007
<samjnaa at gmail.com> wrote in message
news:1176547372.584539.89170 at q75g2000hsh.googlegroups.com...
| self.setFixedSize(200, 120)
| self.quit = QtGui.QPushButton("Quit", self)
| self.quit.setGeometry(62, 40, 75, 30)
| self.quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
| self.connect(self.quit, QtCore.SIGNAL("clicked()"), QtGui.qApp,
| QtCore.SLOT("quit()"))
|
| to be rewritten as:
|
| using self:
| __setFixedSize(200,120)
| __quit = QtGui.QPushButton("Quit", self)
| __using quit:
| ____setGeometry(62, 40, 75, 30)
| ____setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
| __connect(self.quit, QtCore.SIGNAL("clicked()"), QtGui.qApp,
| QtCore.SLOT("quit()"))
If you want to save typing, you are free to use 's' instead of 'self' as
the parameter name. No need to make a fairly major language change.
I do things like 'import math as m' to save repetition.
tjr
More information about the Python-list
mailing list