Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
61fed9cc
Kaydet (Commit)
61fed9cc
authored
Ara 03, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge from 3.2
üst
b6032f55
cc809a28
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
48 deletions
+17
-48
extending.rst
Doc/faq/extending.rst
+16
-12
general.rst
Doc/faq/general.rst
+1
-36
No files found.
Doc/faq/extending.rst
Dosyayı görüntüle @
61fed9cc
...
...
@@ -99,12 +99,7 @@ many other useful protocols.
How do I use Py_BuildValue() to create a tuple of arbitrary length?
-------------------------------------------------------------------
You can't. Use ``t = PyTuple_New(n)`` instead, and fill it with objects using
``PyTuple_SetItem(t, i, o)`` -- note that this "eats" a reference count of
``o``, so you have to :c:func:`Py_INCREF` it. Lists have similar functions
``PyList_New(n)`` and ``PyList_SetItem(l, i, o)``. Note that you *must* set all
the tuple items to some value before you pass the tuple to Python code --
``PyTuple_New(n)`` initializes them to NULL, which isn't a valid Python value.
You can't. Use :c:func:`PyTuple_Pack` instead.
How do I call an object's method from C?
...
...
@@ -147,21 +142,30 @@ this object to :data:`sys.stdout` and :data:`sys.stderr`. Call print_error, or
just allow the standard traceback mechanism to work. Then, the output will go
wherever your ``write()`` method sends it.
The easiest way to do this is to use the
StringIO class in the standard library.
The easiest way to do this is to use the
:class:`io.StringIO` class::
Sample code and use for catching stdout:
>>> import io, sys
>>> sys.stdout = io.StringIO()
>>> print('foo')
>>> print('hello world!')
>>> sys.stderr.write(sys.stdout.getvalue())
foo
hello world!
A custom object to do the same would look like this::
>>> class StdoutCatcher:
>>> import io, sys
>>> class StdoutCatcher(io.TextIOBase):
... def __init__(self):
... self.data =
''
... self.data =
[]
... def write(self, stuff):
... self.data
= self.data + stuff
... self.data
.append(stuff)
...
>>> import sys
>>> sys.stdout = StdoutCatcher()
>>> print('foo')
>>> print('hello world!')
>>> sys.stderr.write(
sys.stdout.data
)
>>> sys.stderr.write(
''.join(sys.stdout.data)
)
foo
hello world!
...
...
Doc/faq/general.rst
Dosyayı görüntüle @
61fed9cc
...
...
@@ -19,7 +19,7 @@ It has interfaces to many system calls and libraries, as well as to various
window systems, and is extensible in C or C++. It is also usable as an
extension language for applications that need a programmable interface.
Finally, Python is portable: it runs on many Unix variants, on the Mac, and on
PCs under MS-DOS, Windows, Windows NT, and OS/2
.
Windows 2000 and later
.
To find out more, start with :ref:`tutorial-index`. The `Beginner's Guide to
Python <http://wiki.python.org/moin/BeginnersGuide>`_ links to other
...
...
@@ -469,38 +469,3 @@ http://www.python.org/editors/ for a full list of Python editing environments.
If you want to discuss Python's use in education, you may be interested in
joining `the edu-sig mailing list
<http://python.org/community/sigs/current/edu-sig>`_.
Upgrading Python
================
What is this bsddb185 module my application keeps complaining about?
--------------------------------------------------------------------
.. XXX remove this question?
Starting with Python2.3, the distribution includes the `PyBSDDB package
<http://pybsddb.sf.net/>` as a replacement for the old bsddb module. It
includes functions which provide backward compatibility at the API level, but
requires a newer version of the underlying `Berkeley DB
<http://www.sleepycat.com>`_ library. Files created with the older bsddb module
can't be opened directly using the new module.
Using your old version of Python and a pair of scripts which are part of Python
2.3 (db2pickle.py and pickle2db.py, in the Tools/scripts directory) you can
convert your old database files to the new format. Using your old Python
version, run the db2pickle.py script to convert it to a pickle, e.g.::
python2.2 <pathto>/db2pickley.py database.db database.pck
Rename your database file::
mv database.db olddatabase.db
Now convert the pickle file to a new format database::
python <pathto>/pickle2db.py database.db database.pck
The precise commands you use will vary depending on the particulars of your
installation. For full details about operation of these two scripts check the
doc string at the start of each one.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment