Definition of 'apply' of MDI GUI 
Author Message
 Definition of 'apply' of MDI GUI

Dear people,

   I don't understand EXACTLY how apply works in MDI GUIS? What's the purpose of it?

def __init__(self, parent, doc, *args):
        apply(QWidget.__init__,(self, parent) + args)
        self.doc = doc
        self.connect(self.doc, PYSIGNAL("sigDocModified"),
                     self.slotDocModified)
        self.connect(self.doc, PYSIGNAL("sigDocTitleChanged"),
                     self.setCaption)
        # Set initial values
        self.slotDocModified(self.doc.modified())

I don't quite understand, what's the purpose of apply.

Anson



Sun, 13 Nov 2005 20:21:28 GMT  
 Definition of 'apply' of MDI GUI
anson schreef op woensdag 28 mei om 14:27:58 +0000:

Quote:
> Dear people,

>    I don't understand EXACTLY how apply works in MDI GUIS? What's the purpose of it?

>         apply(QWidget.__init__,(self, parent) + args)

The purpose of apply was, before python 2.3, to be able to call
functions or methods with lists 'applied' as arguments. For
example:

  1 >>> def foo(*args): return args
  1 ...
  2 >>> l = ['a', 1, {"yeah!": True}]
  3 >>> foo(l)
(['a', 1, {'yeah!': True}],)

But that is not what we want.
We want something that equals:
foo(['a', 1, {"yeah!": True}])

  4 >>> apply(foo, l)
('a', 1, {'yeah!': True})

That's more like it.

As of Python 2.3, you can do:

  5 >>> foo(*l)
('a', 1, {'yeah!': True})

apply is redundant now.

The statement above equals:
Qwidget.__init__(self, parent, *args)
...so that all elements of args are passed seperately, and not as one tuple.

See also:

http://www.python.org/dev/doc/devel/lib/built-in-funcs.html#l2h-4

Hope this helps!

yours,
Gerrit.

--
196. If a man put out the eye of another man, his eye shall be put out.
        -- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
        http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
        http://www.sp.nl/



Sun, 13 Nov 2005 20:47:44 GMT  
 Definition of 'apply' of MDI GUI

Quote:

> The purpose of apply was, before Python 2.3, to be able to call
> functions or methods with lists 'applied' as arguments.

The new asterisk "apply" notation has been around since 2.0.

--

 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Your theory is not right; it is not even wrong.
\__/  Wolfgang Pauli



Mon, 14 Nov 2005 03:21:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. better 'apply' function

2. Feature request: 'apply' command

3. two definitions of 'cyclic'?

4. Technical: Definition of ``alyasing''

5. Definition of 'pickle'

6. A definition for 'foreach'

7. 'manpage'-like CL-Definitions availiable ?

8. 'multiple definitions' with MacOS X

9. TIP #194: Procedures as Values via '''apply'''

10. GUI editor in 'Clean'?

11. fpl's and gui's

12. VI's GUI events disturb another VI's work

 

 
Powered by phpBB® Forum Software