root/trunk/infrastructure/pyd/doc/object.html

Revision 25, 38.6 kB (checked in by KirkMcDonald, 2 years ago)

Fleshed out the docs a little.

Line 
1 <html><head>
2 <meta http-equiv="content-type" content="text/html; charset=utf-8">
3 <meta content="text/javascript" http-equiv="content-script-type">
4 <title>pyd.object</title>
5 <link rel="stylesheet" type="text/css" href="candydoc/style.css">
6 <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]-->
7 <script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script>
8 <script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script>
9 <script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script>
10 </head><body>
11 <div id="tabarea"></div><div id="explorerclient"></div>
12 <div id="content"><script>explorer.initialize("pyd.object");</script>
13     <table class="content">
14         <tr><td id="docbody"><h1>pyd.object</h1><!-- Generated by Ddoc from pyd\object.d -->
15 <br><br>
16
17 <script>explorer.outline.incSymbolLevel();</script>
18 <dl>
19 <script>explorer.outline.writeEnabled = true;</script>
20 <dt><span class="decl">class
21 <span class="currsymbol">DPyObject</span>
22 <script>explorer.outline.addDecl('DPyObject');</script>
23
24 ;
25 </span></dt>
26 <script>explorer.outline.writeEnabled = false;</script>
27
28
29 <dd>Wrapper class for a Python/C API PyObject.
30 <br><br>
31 Nearly all of these member functions may throw a PythonException if the
32  underlying Python API raises a Python exception.
33
34 <br><br>
35 <b>Authors:</b><br>
36 <a href="mailto:kirklin.mcdonald@gmail.com">Kirk McDonald</a>
37 <br><br>
38 <b>Date:</b><br>
39 June 18, 2006
40 <br><br>
41 <b>See Also:</b><br>
42 <a href="http://docs.python.org/api/api.html">The Python/C API</a>
43  
44 <br><br>
45
46
47 <script>explorer.outline.incSymbolLevel();</script>
48 <dl>
49 <script>explorer.outline.writeEnabled = true;</script>
50 <dt><span class="decl">this(PyObject * <span class="funcparam">o</span>, bool <span class="funcparam">borrowed</span> = false);
51 </span></dt>
52 <script>explorer.outline.writeEnabled = false;</script>
53
54
55 <dd>Wrap around a passed PyObject*.
56 <br><br>
57 <b>Params:</b><br>
58 <table><tr>
59 <td nowrap valign="top" style="padding-right: 8px">PyObject * <span class="funcparam">o</span></td>
60
61                
62 <td>The PyObject to wrap.</td></tr>
63 <tr>
64 <td nowrap valign="top" style="padding-right: 8px">bool <span class="funcparam">borrowed</span></td>
65
66                
67 <td>Whether <span class="funcparam">o</span> is a borrowed reference. Instances
68                  of DPyObject always own their references.
69                  Therefore, Py_INCREF will be called if <span class="funcparam">borrowed</span> is
70                  <font color=blue><b>true</b></font>.</td></tr>
71 </table><br>
72
73 </dd>
74
75 <script>explorer.outline.writeEnabled = true;</script>
76 <dt><span class="decl">this();
77 </span></dt>
78 <script>explorer.outline.writeEnabled = false;</script>
79
80
81 <dd>The default constructor constructs an instance of the Py_None DPyObject.
82 <br><br>
83
84 </dd>
85
86 <script>explorer.outline.writeEnabled = true;</script>
87 <dt><span class="decl">PyObject *
88 <span class="currsymbol">ptr</span>
89 <script>explorer.outline.addDecl('ptr');</script>
90
91 ();
92 </span></dt>
93 <script>explorer.outline.writeEnabled = false;</script>
94
95
96 <dd>Returns a borrowed reference to the PyObject.
97      
98 <br><br>
99
100 </dd>
101
102 <script>explorer.outline.writeEnabled = true;</script>
103 <dt><span class="decl">bool
104 <span class="currsymbol">hasattr</span>
105 <script>explorer.outline.addDecl('hasattr');</script>
106
107 (char[] <span class="funcparam">attr_name</span>);
108 </span></dt>
109 <script>explorer.outline.writeEnabled = false;</script>
110
111
112 <dd>Same as hasattr(this, <span class="funcparam">attr_name</span>) in Python.
113 <br><br>
114
115 </dd>
116
117 <script>explorer.outline.writeEnabled = true;</script>
118 <dt><span class="decl">bool
119 <span class="currsymbol">hasattr</span>
120 <script>explorer.outline.addDecl('hasattr');</script>
121
122 (DPyObject <span class="funcparam">attr_name</span>);
123 </span></dt>
124 <script>explorer.outline.writeEnabled = false;</script>
125
126
127 <dd>Same as hasattr(this, <span class="funcparam">attr_name</span>) in Python.
128 <br><br>
129
130 </dd>
131
132 <script>explorer.outline.writeEnabled = true;</script>
133 <dt><span class="decl">DPyObject
134 <span class="currsymbol">getattr</span>
135 <script>explorer.outline.addDecl('getattr');</script>
136
137 (char[] <span class="funcparam">attr_name</span>);
138 </span></dt>
139 <script>explorer.outline.writeEnabled = false;</script>
140
141
142 <dd>Same as getattr(this, <span class="funcparam">attr_name</span>) in Python.
143 <br><br>
144
145 </dd>
146
147 <script>explorer.outline.writeEnabled = true;</script>
148 <dt><span class="decl">DPyObject
149 <span class="currsymbol">getattr</span>
150 <script>explorer.outline.addDecl('getattr');</script>
151
152 (DPyObject <span class="funcparam">attr_name</span>);
153 </span></dt>
154 <script>explorer.outline.writeEnabled = false;</script>
155
156
157 <dd>Same as getattr(this, <span class="funcparam">attr_name</span>) in Python.
158 <br><br>
159
160 </dd>
161
162 <script>explorer.outline.writeEnabled = true;</script>
163 <dt><span class="decl">void
164 <span class="currsymbol">setattr</span>
165 <script>explorer.outline.addDecl('setattr');</script>
166
167 (char[] <span class="funcparam">attr_name</span>, DPyObject <span class="funcparam">v</span>);
168 </span></dt>
169 <script>explorer.outline.writeEnabled = false;</script>
170
171
172 <dd>Same as setattr(this, <span class="funcparam">attr_name</span>, <span class="funcparam">v</span>) in Python.
173      
174 <br><br>
175
176 </dd>
177
178 <script>explorer.outline.writeEnabled = true;</script>
179 <dt><span class="decl">void
180 <span class="currsymbol">setattr</span>
181 <script>explorer.outline.addDecl('setattr');</script>
182
183 (DPyObject <span class="funcparam">attr_name</span>, DPyObject <span class="funcparam">v</span>);
184 </span></dt>
185 <script>explorer.outline.writeEnabled = false;</script>
186
187
188 <dd>Same as setattr(this, <span class="funcparam">attr_name</span>, <span class="funcparam">v</span>) in Python.
189      
190 <br><br>
191
192 </dd>
193
194 <script>explorer.outline.writeEnabled = true;</script>
195 <dt><span class="decl">void
196 <span class="currsymbol">delattr</span>
197 <script>explorer.outline.addDecl('delattr');</script>
198
199 (char[] <span class="funcparam">attr_name</span>);
200 </span></dt>
201 <script>explorer.outline.writeEnabled = false;</script>
202
203
204 <dd>Same as del this.<span class="funcparam">attr_name</span> in Python.
205      
206 <br><br>
207
208 </dd>
209
210 <script>explorer.outline.writeEnabled = true;</script>
211 <dt><span class="decl">void
212 <span class="currsymbol">delattr</span>
213 <script>explorer.outline.addDecl('delattr');</script>
214
215 (DPyObject <span class="funcparam">attr_name</span>);
216 </span></dt>
217 <script>explorer.outline.writeEnabled = false;</script>
218
219
220 <dd>Same as del this.<span class="funcparam">attr_name</span> in Python.
221      
222 <br><br>
223
224 </dd>
225
226 <script>explorer.outline.writeEnabled = true;</script>
227 <dt><span class="decl">int
228 <span class="currsymbol">opCmp</span>
229 <script>explorer.outline.addDecl('opCmp');</script>
230
231 (DPyObject <span class="funcparam">rhs</span>);
232 </span></dt>
233 <script>explorer.outline.writeEnabled = false;</script>
234
235
236 <dd>Exposes Python object comparison to D. Same as cmp(this, <span class="funcparam">rhs</span>) in Python.
237      
238 <br><br>
239
240 </dd>
241
242 <script>explorer.outline.writeEnabled = true;</script>
243 <dt><span class="decl">bool
244 <span class="currsymbol">opEquals</span>
245 <script>explorer.outline.addDecl('opEquals');</script>
246
247 (DPyObject <span class="funcparam">rhs</span>);
248 </span></dt>
249 <script>explorer.outline.writeEnabled = false;</script>
250
251
252 <dd>Exposes Python object equality check to D.
253      
254 <br><br>
255
256 </dd>
257
258 <script>explorer.outline.writeEnabled = true;</script>
259 <dt><span class="decl">DPyObject
260 <span class="currsymbol">repr</span>
261 <script>explorer.outline.addDecl('repr');</script>
262
263 ();
264 </span></dt>
265 <script>explorer.outline.writeEnabled = false;</script>
266
267
268 <dd>Same as repr(this) in Python.
269 <br><br>
270
271 </dd>
272
273 <script>explorer.outline.writeEnabled = true;</script>
274 <dt><span class="decl">DPyObject
275 <span class="currsymbol">str</span>
276 <script>explorer.outline.addDecl('str');</script>
277
278 ();
279 </span></dt>
280 <script>explorer.outline.writeEnabled = false;</script>
281
282
283 <dd>Same as str(this) in Python.
284 <br><br>
285
286 </dd>
287
288 <script>explorer.outline.writeEnabled = true;</script>
289 <dt><span class="decl">char[]
290 <span class="currsymbol">toString</span>
291 <script>explorer.outline.addDecl('toString');</script>
292
293 ();
294 </span></dt>
295 <script>explorer.outline.writeEnabled = false;</script>
296
297
298 <dd>Allows use of DPyObject in writef via %s
299 <br><br>
300
301 </dd>
302
303 <script>explorer.outline.writeEnabled = true;</script>
304 <dt><span class="decl">DPyObject
305 <span class="currsymbol">unicode</span>
306 <script>explorer.outline.addDecl('unicode');</script>
307
308 ();
309 </span></dt>
310 <script>explorer.outline.writeEnabled = false;</script>
311
312
313 <dd>Same as unicode(this) in Python.
314 <br><br>
315
316 </dd>
317
318 <script>explorer.outline.writeEnabled = true;</script>
319 <dt><span class="decl">bool
320 <span class="currsymbol">isInstance</span>
321 <script>explorer.outline.addDecl('isInstance');</script>
322
323 (DPyObject <span class="funcparam">cls</span>);
324 </span></dt>
325 <script>explorer.outline.writeEnabled = false;</script>
326
327
328 <dd>Same as isinstance(this, <span class="funcparam">cls</span>) in Python.
329 <br><br>
330
331 </dd>
332
333 <script>explorer.outline.writeEnabled = true;</script>
334 <dt><span class="decl">bool
335 <span class="currsymbol">isSubclass</span>
336 <script>explorer.outline.addDecl('isSubclass');</script>
337
338 (DPyObject <span class="funcparam">cls</span>);
339 </span></dt>
340 <script>explorer.outline.writeEnabled = false;</script>
341
342
343 <dd>Same as issubclass(this, <span class="funcparam">cls</span>) in Python. Only works if this is a class.
344 <br><br>
345
346 </dd>
347
348 <script>explorer.outline.writeEnabled = true;</script>
349 <dt><span class="decl">bool
350 <span class="currsymbol">callable</span>
351 <script>explorer.outline.addDecl('callable');</script>
352
353 ();
354 </span></dt>
355 <script>explorer.outline.writeEnabled = false;</script>
356
357
358 <dd>Same as callable(this) in Python.
359 <br><br>
360
361 </dd>
362
363 <script>explorer.outline.writeEnabled = true;</script>
364 <dt><span class="decl">DPyObject
365 <span class="currsymbol">opCall</span>
366 <script>explorer.outline.addDecl('opCall');</script>
367
368 (DPyObject <span class="funcparam">args</span> = cast(DPyObject)null);
369 </span></dt>
370 <script>explorer.outline.writeEnabled = false;</script>
371
372
373 <dd>Calls the DPyObject.
374 <br><br>
375 <b>Params:</b><br>
376 <table><tr>
377 <td nowrap valign="top" style="padding-right: 8px">DPyObject <span class="funcparam">args</span></td>
378
379                
380 <td>Should be a DPyTuple of the arguments to pass. Omit to
381              call with no arguments.</td></tr>
382 </table><br>
383 <b>Returns:</b><br>
384 Whatever the function DPyObject returns.
385      
386 <br><br>
387
388 </dd>
389
390 <script>explorer.outline.writeEnabled = true;</script>
391 <dt><span class="decl">DPyObject
392 <span class="currsymbol">opCall</span>
393 <script>explorer.outline.addDecl('opCall');</script>
394
395 (DPyObject <span class="funcparam">args</span>, DPyObject <span class="funcparam">kw</span>);
396 </span></dt>
397 <script>explorer.outline.writeEnabled = false;</script>
398
399
400 <dd>Calls the DPyObject with positional and keyword arguments.
401 <br><br>
402 <b>Params:</b><br>
403 <table><tr>
404 <td nowrap valign="top" style="padding-right: 8px">DPyObject <span class="funcparam">args</span></td>
405
406                
407 <td>Positional arguments. Should be a DPyTuple. Pass an empty
408              DPyTuple for no positional arguments.</td></tr>
409 <tr>
410 <td nowrap valign="top" style="padding-right: 8px">DPyObject <span class="funcparam">kw</span></td>
411
412                
413 <td>Keyword arguments. Should be a DPyDict.</td></tr>
414 </table><br>
415 <b>Returns:</b><br>
416 Whatever the function DPyObject returns.
417      
418 <br><br>
419
420 </dd>
421
422 <script>explorer.outline.writeEnabled = true;</script>
423 <dt><span class="decl">DPyObject
424 <span class="currsymbol">method</span>
425 <script>explorer.outline.addDecl('method');</script>
426
427 (char[] <span class="funcparam">name</span>, DPyObject <span class="funcparam">args</span> = cast(DPyObject)null);
428 </span></dt>
429 <script>explorer.outline.writeEnabled = false;</script>
430
431
432 <dd><br><br>
433 </dd>
434
435 <script>explorer.outline.writeEnabled = true;</script>
436 <dt><span class="decl">int
437 <span class="currsymbol">hash</span>
438 <script>explorer.outline.addDecl('hash');</script>
439
440 ();
441 </span></dt>
442 <script>explorer.outline.writeEnabled = false;</script>
443
444
445 <dd>Same as hash(this) in Python.
446 <br><br>
447
448 </dd>
449
450 <script>explorer.outline.writeEnabled = true;</script>
451 <dt><span class="decl">bool
452 <span class="currsymbol">toBool</span>
453 <script>explorer.outline.addDecl('toBool');</script>
454
455 ();
456 </span></dt>
457 <script>explorer.outline.writeEnabled = false;</script>
458
459
460 <dd>Same as "not not this" in Python.
461 <br><br>
462
463 </dd>
464
465 <script>explorer.outline.writeEnabled = true;</script>
466 <dt><span class="decl">bool
467 <span class="currsymbol">not</span>
468 <script>explorer.outline.addDecl('not');</script>
469
470 ();
471 </span></dt>
472 <script>explorer.outline.writeEnabled = false;</script>
473
474
475 <dd>Same as "not this" in Python.
476 <br><br>
477
478 </dd>
479
480 <script>explorer.outline.writeEnabled = true;</script>
481 <dt><span class="decl">DPyObject
482 <span class="currsymbol">type</span>
483 <script>explorer.outline.addDecl('type');</script>
484
485 ();
486 </span></dt>
487 <script>explorer.outline.writeEnabled = false;</script>
488
489
490 <dd>Gets the type of this DPyObject. Same as type(this) in Python.
491 <br><br>
492 <b>Returns:</b><br>
493 The type DPyObject of this DPyObject.
494      
495 <br><br>
496
497 </dd>
498
499 <script>explorer.outline.writeEnabled = true;</script>
500 <dt><span class="decl">int
501 <span class="currsymbol">length</span>
502 <script>explorer.outline.addDecl('length');</script>
503
504 ();
505 </span></dt>
506 <script>explorer.outline.writeEnabled = false;</script>
507
508
509 <dd>The length of this DPyObject. Same as len(this) in Python.
510      
511 <br><br>
512
513 </dd>
514
515 <script>explorer.outline.writeEnabled = true;</script>
516 <dt><span class="decl">int
517 <span class="currsymbol">size</span>
518 <script>explorer.outline.addDecl('size');</script>
519
520 ();
521 </span></dt>
522 <script>explorer.outline.writeEnabled = false;</script>
523
524
525 <dd>Same as length()
526 <br><br>
527
528 </dd>
529
530 <script>explorer.outline.writeEnabled = true;</script>
531 <dt><span class="decl">DPyObject
532 <span class="currsymbol">dir</span>
533 <script>explorer.outline.addDecl('dir');</script>
534
535 ();
536 </span></dt>
537 <script>explorer.outline.writeEnabled = false;</script>
538
539
540 <dd>Same as dir(this) in Python.
541 <br><br>
542
543 </dd>
544
545 <script>explorer.outline.writeEnabled = true;</script>
546 <dt><span class="decl">DPyObject
547 <span class="currsymbol">opIndex</span>
548 <script>explorer.outline.addDecl('opIndex');</script>
549
550 (DPyObject <span class="funcparam">key</span>);
551 </span></dt>
552 <script>explorer.outline.writeEnabled = false;</script>
553
554
555 <dd>Equivalent to o[key] in Python.
556 <br><br>
557
558 </dd>
559
560 <script>explorer.outline.writeEnabled = true;</script>
561 <dt><span class="decl">DPyObject
562 <span class="currsymbol">opIndex</span>
563 <script>explorer.outline.addDecl('opIndex');</script>
564
565 (char[] <span class="funcparam">key</span>);
566 </span></dt>
567 <script>explorer.outline.writeEnabled = false;</script>
568
569
570 <dd>Equivalent to o['key'] in Python; usually only makes sense for
571  mappings.
572      
573 <br><br>
574
575 </dd>
576
577 <script>explorer.outline.writeEnabled = true;</script>
578 <dt><span class="decl">DPyObject
579 <span class="currsymbol">opIndex</span>
580 <script>explorer.outline.addDecl('opIndex');</script>
581
582 (int <span class="funcparam">i</span>);
583 </span></dt>
584 <script>explorer.outline.writeEnabled = false;</script>
585
586
587 <dd>Equivalent to o[i] in Python; usually only makes sense for sequences.
588 <br><br>
589
590 </dd>
591
592 <script>explorer.outline.writeEnabled = true;</script>
593 <dt><span class="decl">void
594 <span class="currsymbol">opIndexAssign</span>
595 <script>explorer.outline.addDecl('opIndexAssign');</script>
596
597 (DPyObject <span class="funcparam">value</span>, DPyObject <span class="funcparam">key</span>);
598 </span></dt>
599 <script>explorer.outline.writeEnabled = false;</script>
600
601
602 <dd>Equivalent to o[key] = value in Python.
603 <br><br>
604
605 </dd>
606
607 <script>explorer.outline.writeEnabled = true;</script>
608 <dt><span class="decl">void
609 <span class="currsymbol">opIndexAssign</span>
610 <script>explorer.outline.addDecl('opIndexAssign');</script>
611
612 (DPyObject <span class="funcparam">value</span>, char[] <span class="funcparam">key</span>);
613 </span></dt>
614 <script>explorer.outline.writeEnabled = false;</script>
615
616
617 <dd>Equivalent to o['key'] = value in Python. Usually only makes sense for
618  mappings.
619      
620 <br><br>
621
622 </dd>
623
624 <script>explorer.outline.writeEnabled = true;</script>
625 <dt><span class="decl">void
626 <span class="currsymbol">opIndexAssign</span>
627 <script>explorer.outline.addDecl('opIndexAssign');</script>
628
629 (DPyObject <span class="funcparam">value</span>, int <span class="funcparam">i</span>);
630 </span></dt>
631 <script>explorer.outline.writeEnabled = false;</script>
632
633
634 <dd>Equivalent to o[i] = value in Python. Usually only makes sense for
635  sequences.
636      
637 <br><br>
638
639 </dd>
640
641 <script>explorer.outline.writeEnabled = true;</script>
642 <dt><span class="decl">void
643 <span class="currsymbol">delItem</span>
644 <script>explorer.outline.addDecl('delItem');</script>
645
646 (DPyObject <span class="funcparam">key</span>);
647 </span></dt>
648 <script>explorer.outline.writeEnabled = false;</script>
649
650
651 <dd>Equivalent to del o[key] in Python.
652 <br><br>
653
654 </dd>
655
656 <script>explorer.outline.writeEnabled = true;</script>
657 <dt><span class="decl">void
658 <span class="currsymbol">delItem</span>
659 <script>explorer.outline.addDecl('delItem');</script>
660
661 (char[] <span class="funcparam">key</span>);
662 </span></dt>
663 <script>explorer.outline.writeEnabled = false;</script>
664
665
666 <dd>Equivalent to del o['key'] in Python. Usually only makes sense for
667  mappings.
668      
669 <br><br>
670
671 </dd>
672
673 <script>explorer.outline.writeEnabled = true;</script>
674 <dt><span class="decl">void
675 <span class="currsymbol">delItem</span>
676 <script>explorer.outline.addDecl('delItem');</script>
677
678 (int <span class="funcparam">i</span>);
679 </span></dt>
680 <script>explorer.outline.writeEnabled = false;</script>
681
682
683 <dd>Equivalent to del o[i] in Python. Usually only makes sense for
684  sequences.
685      
686 <br><br>
687
688 </dd>
689
690 <script>explorer.outline.writeEnabled = true;</script>
691 <dt><span class="decl">DPyObject
692 <span class="currsymbol">opSlice</span>
693 <script>explorer.outline.addDecl('opSlice');</script>
694
695 (int <span class="funcparam">i1</span>, int <span class="funcparam">i2</span>);
696 </span></dt>
697 <script>explorer.outline.writeEnabled = false;</script>
698
699
700 <dd>Equivalent to o[i1:i2] in Python.
701 <br><br>
702
703 </dd>
704
705 <script>explorer.outline.writeEnabled = true;</script>
706 <dt><span class="decl">DPyObject
707 <span class="currsymbol">opSlice</span>
708 <script>explorer.outline.addDecl('opSlice');</script>
709
710 ();
711 </span></dt>
712 <script>explorer.outline.writeEnabled = false;</script>
713
714
715 <dd>Equivalent to o[:] in Python.
716 <br><br>
717
718 </dd>
719
720 <script>explorer.outline.writeEnabled = true;</script>
721 <dt><span class="decl">void
722 <span class="currsymbol">opSliceAssign</span>
723 <script>ex