Enter topic ==> 



Knowledge

Knowledge Base
   Movies
     p
       Python

p=2025
  • k_code=xm2>
    p=2025
  • k_code=xm2>Buy



    Year: 2000
    Classification: Science Fiction
    Directed: Richard Clabaugh
    Actors/Actresses: Robert Englund Casper Van Dien Wil Wheaton Frayne Rosanoff Casper Van Diem
    Discuss: Python Messageboard
    More about Python

  • Python

    Gnibo created an article from about 88097 text blocks

    I have the students learn Python in our undergraduate and graduateSemantic Web courses. Why? Because basically there's nothing elsewith the flexibility and as many web libraries, said Prof. JamesA. Hendler (www.python.org/)

    I just upgraded from python 2.4.2 to 2.5 (r25:51908, Jan 4 2007, 17:18:25) and my program using the xmpp module stopped working. Investigating, it appears that ssl() is no longer part of the socket module, but I can't find any documenation to that effect. Here is what I see (opensuse 10.1) (wiki.python.org....hon_2.5%3F)

    Interesting. any idea what that might be? I grepped all the config* stuff for ssl and there doesn't seem to be any mention of it. Any suggestions on where I start to find out how to build python with ssl support on linux? (wiki.python.org....hon_2.5%3F)

    Python 2.2.4 is another maintenance release in the Python 2.2.x line. This release will extend Python 2.2.3 with various bugfixes, with an emphasis on bugs that can cause core dumps ("General Protection Faults" and the like on some systems) and memory leaks (wiki.python.org....thon_2.2.4)

    [Python -Dev] Should hex() yield 'L' suffix for long numbers? [Python -Dev] Should hex() yield 'L' suffix for long numbers? Guido van Rossum guido at python .or (mail.python.org....65918.html)

    OT: Tab characters considered harmful (Was: Emacs has eaten my python tabs!) OT: Tab characters considered harmful (Was: Emacs has eaten my python tabs!) Robin Munn rmunn at pobox.co (mail.python.org....83758.html)

    [Python -Dev] 'With' context documentation draft (was Re: Terminology for PEP 343 [Python -Dev] 'With' context documentation draft (was Re: Terminology for PEP 343 Nick Coghlan ncoghlan at gmail.co (mail.python.org....54658.html)

    [Python -Dev] Why are contexts also managers? (was r45544 -peps/trunk/pep-0343.txt) [Python -Dev] Why are contexts also managers? (was r45544 -peps/trunk/pep-0343.txt) A.M. Kuchling amk at amk.c (mail.python.org....63859.html)

    Because if you don't tell it that class is noncopyable, Boost.Python tries to register a converter for handling wrapped functions which handle function returning values of class type. Naturally, this has to be able to copy construct the returned C++ class object into storage that can be managed by a Python object. Since this is an abstract class, that fails. (wiki.python.org....thon/class)

    Boost.Python allows you to specify how Python objects will hold the C++ objects they wrap. You can specify that they be held by shared_ptr T (or any other smart pointer), in which case the library will generate converters to/from Python for shared_ptr T . The to_python converters will simply build a new Python object around the shared_ptr . You can specify that your C++ object is held by shared_ptr U . That allows you to hold a U object for dispatching, yet still pass shared_ptrs around in your C++ code. (wiki.python.org....thon/class)

    If you have virtual functions you want to override in Python , you actually have to hold the T object with a derived class U which overrides the virtual functions to dispatch back to Python . In this case, class U naturally has to have access to the Python objec (wiki.python.org....thon/class)

    There are several problems with the above arrangement , but the most important one is that if you keep the shared_ptr U alive longer than its corresponding Python object, calls to the Python -overridable virtual functions will crash, because they'll try to call through an invalid pointer (wiki.python.org....thon/class)

    #include string namespace { // Avoid cluttering the global namespace. // A couple of simple C++ functions that we want to expose to Python . std::string greet() { return "hello, world"; } int square(int number) { return number * number; } (wiki.python.org....pleExample)

    BOOST_PYTHON _MODULE(nested_ext) { using namespace boost::python ; // Establish X as the current scope. scope x_class( class_ X ("X", init int ()) .def(str(self)) ); // Y will now be defined in the current scope class_ Y ("Y", init int ()) .def(str(self)) } (wiki.python.org....ingClasses)

    Pretty cool! You can't do that with an ordinary Python extension type! Of course, you may now have a slightly empty feeling in the pit of your little python ic stomach. Perhaps you wanted to see the following wordy invitation (wiki.python.org....ingClasses)

    After all, invite calls hello::greet() , and you reimplemented that in your Python subclass, wordy . In the next section we'll make greet virtual, and we'll see how to make C++ code see our overrides from Python . (wiki.python.org....ingClasses)

    It is important to note that boost::python will not allow you to make dynamic type casts (through polymorphism) if the function/method is considered "unsafe". That means that an appropriate method-wrapper will not be created for functions that execute potentially exception-generating code where exceptions do not have python mappings. Let's have a look at an example: (wiki.python.org....ingClasses)

    And derive from that in the classic way, implementing the function x() in such a way that it uses unprotected boost::python ::extract instances without catching potential exceptions: (wiki.python.org....ingClasses)

    class BaseWrap public Base, public wrapper Base { public: virtual void x() { this- get_override("x")(); } }; class_ BaseWrap, boost::noncopyable ("Base") .def("x", boost::python ::pure_virtual( Base::x)) class_ Derive, bases Base ("Derive"); (wiki.python.org....ingClasses)

    This is a publically accessible list which is used to disseminate version control check-in messages made by the Python maintainers, to interested Python developers. This list is an adjunct to the publicly available Subversion tree currently residing on svn.python .org (mail.python.org....n-checkins)

    Using the Python /C API, you have to deal with passing pointers back and forth between Python and C, and worry about pointers hanging out in one place when the object they point to has been thrown away. Boost::Python takes care of much of this for you. In addition, Boost::Python lets you write operations on Python objects in C++ in OOP style. (wiki.python.org....ingStarted)

    In addition, Boost::Python makes it easy to EXPORT your C++ classes into Python , without even changing them. Boost::Python is designed with the idea in mind that users never touch a P (wiki.python.org....ingStarted)

    If you do use Boost::Python , though, you can still use stuff from the Python /C API in your C++ code. You don't even need to import the Python .h header file. Just use the functions. For example, to clear an error in Python that you caught in C++, you could do this in the middle of an otherwise purely Boost::Python program: (wiki.python.org....ingStarted)

    In C++, the Python /C API represents Python objects by PyObject pointers. In Boost::Python , these are wrapped by instances of the boost::python ::object class. (wiki.python.org....ingStarted)

    boring = Boost.Python .class( . 'boring' . , bases_tuple # in this case, just () . , { . '_module_' module_name . , '_doc_' doc_string # optional . } . (wiki.python.org....derTheHood)

    function object is added to the class dictionary which default-constructs a boring in a value_holder (because you didn't specify some smart pointer or derived wrapper class as a holder) held by the Python boring object. register_class_from_python is used to register a from-pytho (wiki.python.org....derTheHood)

    . boost::shared_ptrs are special among smart pointers because their Deleter argument can be made to manage the whole Python object, not just the C++ object it contains, no matter how the C++ object is held. (wiki.python.org....derTheHood)

    The registry is simple: it's just a map from typeid registration (see boost/python /converter/registrations.hpp). lvalue_chain and rvalue_chain are simple endogenous linked lists. (wiki.python.org....derTheHood)

    Python Package Index (aka "PyPI") seems to be the current preferred location to list packages, and is integrated with the distutils in recent versions of Python . You can upload distribution files to PyPI so that the code will be available for downloading. (wiki.python.org....on_modules)

    Vaults of Parnassus a link store for Python modules. You must host files elsewhere, but this is one of the oldest and largest lists of available Python code (wiki.python.org....on_modules)

    Python Cookbook , hosted by ActiveState , for small useful bits. Code submitted there is reviewed, and takes a while to appear on the site, if submitted by e-mail. Code submitted directly through a web form appears immediately. (wiki.python.org....on_modules)

    python _command provides modules to facilitate the creation of a Python command. This is primarily used to create contexts for which scripts are tobe ran within (pypi.python.org....ommand/1.1)

    Provides loaders for, well, loading Python code. The loader interfacesfrom PEP302 were chosen for working with pkgutil.get_loader. Theimplementation of this may have been mangled a bit with file_loader andsingle_loader, but it was the best seemingly standard interface forsuch a task (pypi.python.org....ommand/1.1)

    Provides the 'execution' class to create the execution context,and an ExtendedConsole class that provides some basic backslashcommands to the Python interpreter (pypi.python.org....ommand/1.1)

    The notable use-case is the pb_python command that takes standard PostgreSQLoptions and runs a Python command with an already established connection setas a builtin. Scripts written to be executed by the command only need toreference that object for database access (pypi.python.org....ommand/1.1)

    If you want to expose a static function that returns a pointer to an already exposed C++ type, you have to specify a return policy. This is because python needs to know what to do with that pointer and how to track it after it is returned. The return policy specified what to do with the pointer, such as whether or not to free the memory after exiting. Like so: (wiki.python.org....thon/HowTo)

    This has told python that a pointer returned from foo:f() must be managed as a new object and is to be deleted when out of scope or at exit. There are more return policies. Return policies are all subtypes of ResultConverterGenerator , check it out in the docs. (wiki.python.org....thon/HowTo)

    Perhaps you'd like the resulting Python object to contain a raw pointer to the argument? In that case, the caveat is that if the lifetime of the C++ object ends before that of the Python object, that pointer will dangle and using the Python object may cause a crash. (wiki.python.org....thon/HowTo)

    There is a poorly documented make_constructor() function for this purpose. (The best available documentation seems to be in libs/python /test/injected.cpp of the boost source tree.) (wiki.python.org....thon/HowTo)

    void* extract_swig_wrapped_pointer(PyObject* obj) { char thisStr[] = "this"; //first we need to get the this attribute from the Python Object if (!PyObject_HasAttrString(obj, thisStr)) return NULL; PyObject* thisAttr = PyObject_GetAttrString(obj, thisStr); if (thisAttr == NULL) return NULL; //This Python Object is a SWIG Wrapper and contains our pointer return (((PySwigObject*)thisAttr)- ptr); } (wiki.python.org....thon/HowTo)

    The method defined upper does not work if part of your object is written in Python . The PyObject* associated to the object may still be delete by Python . If you want to ensure the lifetime of the object, you have to increase manually the reference couting in the C++ Wrapper and use the above method. With this, you'll be sure the PyObject* is not destroyed while the C++ still exists. (wiki.python.org....thon/HowTo)

    The problem is, if the dynamic type of my_obj is not MyClass but a class derived from MyClass, you won't have, in Python , the interface of the derived class. If you want to create the object with the interface of the real dynamic type you have to use the ResultConverter created by Boos (wiki.python.org....thon/HowTo)

    . If you do, then you have to take extra care about the lifetime of the Python object and the underlying C++ object for there are no lifetime guards possible (the original object being a C++ one, you have no automatic way to tie the lifetime of this object with the lifetime of the Python wrapper). (wiki.python.org....thon/HowTo)

    Boost will create a new MyClass wrapper and you won't have access to the Python methods. To access the Python object you have to explicitly send the Python wrapper boost gave you at the object creatio (wiki.python.org....thon/HowTo)

    bool my_fct(MyClass* my_obj) { MyClassWrap *wrap_obj = dynamic_cast MyClassWrap* (my_obj); object final_obj; if( wrap_obj != NULL // Means we have a Python -defined object { final_obj = object(handle (borrowed(wrap_obj- self))); } else { final_obj = my_obj; } return extract bool python _function(final_obj) ); } (wiki.python.org....thon/HowTo)

    Aimed at beginner programmers or people that has no programming experience. For you to watch this class, you must have python installed from python .org . Lecture 2 will show you how to install and run python . This lecture assumes that you already have python . (wiki.python.org....nd_Tkinter)

    The python course series is designed to be short, fun, and concise. They are 10 minutes each with fun examples and easy instruction. If you want to learn programming this is the way to go. (wiki.python.org....nd_Tkinter)

    In this lecture I will convince you that python will eventually take over the world :). Actually we will discuss how the class will be conducted and how much fun we are going to have. This will be the last lecture I write. (wiki.python.org....nd_Tkinter)

    I will show you where you download python . If you found this page, chances are that you already know how. I will also talk about different resources to help you program python (wiki.python.org....nd_Tkinter)

    Why operators.hpp imports certain functions (such as 'str') into the global namespace, instead of the namespace boost::python . That looks like an error. (wiki.python.org....python/FAQ)

    Example: In C++ I create a CWheel and I set its member m_diameter to 1233. In python I have a function that receives a CWheel and displays the diameter (Let's suppose that Python knows the CWheel from Boost.Python ) (wiki.python.org....python/FAQ)

    Now you can pass wheel_obj back to python , and all reference counts are nicely managed. You don't need to "map" anything between C++ and Python ; the library takes care of that for you. (wiki.python.org....python/FAQ)

    It's only on broken compilers which don't support KoenigLookup , and it's intentional. The negative impact should be limited due to the fact that these functions only operate on objects of type boost::python ::self_ns::self_t. Do you anticipate a real problem with this (wiki.python.org....python/FAQ)

    Incidentally, if you are on Windows and want to see what's really happening with the crash, #include "$BOOST_ROOT/libs/python /test/module_tail.cpp" at the end of your source file (wiki.python.org....python/FAQ)

    The modules described in this chapter provide a wide range of servicesrelated to the Python interpreter and its interaction with itsenvironment. Here's an overview (docs.python.org....ython.html)

    Since Python handles memory allocation and garbage collection automatically, the concept "pointer" is not meaningful within Python . However, many C++ API exposes either raw pointers or shared pointers, and to wrap such APIs one would need to deal with pointers. (wiki.python.org....rtPointers)

    lwickjr That's fine for people who are "power-users" *AND* have convenient web access at the time the bug is discovered. What about people who do *NOT* know how to use SourceForge or do *NOT* have Internet access when they're using Python ? (wiki.python.org....ntation%3F)

    Builds a Python object around a pointer to the C++ result object (which must have a class_ wrapper somewhere), and applies some lifetime management to keep the "self" object alive as long as the Python result is alive. NULL pointer returning as None. (wiki.python.org....CallPolicy)

    A new Python object is created which contains an unowned U* pointer to the referent of the wrapped function's return value, and no attempt is made to ensure that the lifetime of the referent is at least as long as that of the corresponding Python object. (wiki.python.org....CallPolicy)

    BoostPython/ResultConverterGenerator which can be used to wrap C++ functions returning a pointer to an object allocated with a new-expression and expecting the caller to take responsibility for deleting that C++ object from heap. boost.python will do it as part of Python object destruction. (wiki.python.org....CallPolicy)

    I would like to be able to distribue a Python script to be run on computers that may not trust me (I.E. for use as a Folding@Home kind of distributed application. (wiki.python.org....Sandbox%29)

    However, I would like my Python script to run in a secured sandbox that would not allow that script (by malice or accident) to damage that person's computer. (wiki.python.org....Sandbox%29)

    Update These instructions have now been incorporated into the Python sources, as part of file PCBuild/readme.txt . Read that version for more up to date details. Some particular changes (wiki.python.org...._C_Toolkit)

    You need the Visual C++ Toolkit Compiler 2003, as this is the version compatible with the Visual Studio version used to build Python . This is an optimising compiler, unlike the compiler supplied with the .NET SDK. (wiki.python.org...._C_Toolkit)

    It is possible to build from a normal command shell, but you need to modify LIB, PATH and INCLUDE to include the corresponding %SDK%/LIB , %SDK%/BIN and %SDK%/Include paths. This will allow core Python to build, but you may still have trouble with extensions such as TCL, which seem to require additional SDK environment variables (wiki.python.org...._C_Toolkit)

    The scope is a class that has an associated global Python object which controls the Python namespace in which new extension classes and wrapped functions will be defined as attributes. Details can be found at boost.python /scope . (wiki.python.org....hon/module)

    boring = Boost.Python .class( . 'boring' . , bases_tuple # in this case, just () . , { . '_module_' module_name . , '_doc_' doc_string # optional . } (wiki.python.org....veState%29)

    function object is added to the class dictionary which default-constructs a boring in a value_holder (because you didn't specify some smart pointer or derived wrapper class as a holder) held by the Python boring object. register_class_from_python is used to register a from-python (wiki.python.org....veState%29)

    . boost::shared_ptrs are special among smart pointers because their Deleter argument can be made to manage the whole Python object, not just the C++ object it contains, no matter how the C++ object is held. (wiki.python.org....veState%29)

    The registry is simple: it's just a map from typeid registration (see boost/python /converter/registrations.hpp). lvalue_chain and rvalue_chain are simple endogenous linked lists. (wiki.python.org....veState%29)

    If you're reading this document, you probably have a good idea of whatmodules, extensions, and so forth are. Nevertheless, just to be surethat everyone is operating from a common starting point, we offer thefollowing glossary of common Python terms (docs.python.org....terms.html)

    a module written in the low-level language of the Python implementation: C/C++ for Python , Java for Jython. Typically contained in a single dynamically loadable pre-compiled file, e.g. a shared object .so file for Python extensions on Unix , a DLL (given the .pyd extension) for Python extensions on Windows, or a Java class file for Jython extensions. (Note that currently, the Distutils only handles C/C++ extensions for Python . (docs.python.org....terms.html)

    It complicates your upgrade process, as versions of Python , Apache, and mod_python must be coordinated. The appropriate versions are not always available for some combinations. (wiki.python.org....mod_python)

    mod_python is a module for Apache, which is tested less than other well known Apache modules such as mod_proxy. Because of this reason the server administrator (which might not be you) might not want to install this module for security reasons. (wiki.python.org....mod_python)

    Join us on IRC for an effort at closing some Python bugs and patches. Get quick feedback on your patches and bugfixes, or learn how to submit and examine patches. (wiki.python.org....thonBugDay)

    The goal of the bug day is to process bug reports in the Python bug tracker , trying to fix and close issues. Bugs should be processed in the fashion described by PEP 0003 , "Guidelines for Handling Bug Reports" (wiki.python.org....thonBugDay)

    Consider providing a patch that fixes the problem, or at least a simple test case that demonstrates the bug. Does the bug appear to be gone in the Python 2.6 trunk, but not the 2.5 maintenance branch? Report that, too (wiki.python.org....thonBugDay)



    Home | About | Add URL

    Copyright (c) 2000-2009 Gnibo.com, All rights reserved