background preloader

PythonMonk - Interactive Python tutorials

PythonMonk - Interactive Python tutorials
Related:  Getting started with Python

A Note on Python Paths This time I decided to share some knowledge about Python paths which seemed a little bit confusing to me in the beginning of diving into Python. I am working with Django in different platforms like Mac OS X, Windows, and Linux, therefore the common patterns how to activate new python modules in all of those environments should be familiar to me. Python modules are either *.py files or directories containing . When defining paths to python modules, you will usually need to deal with the latter ones. A module is meant to be under python path if you can run python and import that module. For example, if you can run the following, then django is under your python path. python >>> import django Stay tuned to get deeper into python paths. Installing modules If a module is installable, usually all you need to do is to extract its setup directory, cd to it, and run python install This will copy the module into the site-packages directory of the current python installation. or

The Nature of Code Becoming a Pythonista — Platipy 0.2 documentation This chapter is will provide a very brief review of some important python concepts which will be useful and necessary. The basic concepts will be for those who are unfamiliar with Python, but a good refresher for those who don’t write in Python every day. Intermediate concepts will be great for programmers of all levels to refresh on some Python idioms. The code below will focus on Python 2.5+, since that is the version on most XO laptops. PEP8 and The Zen of Python¶ One of the most important aspects of developing in Python is the Python community. Use 4 spaces per indentation level. The Zen of Python is a list of guiding principles behind the design of Python, and a good list of guiding principles for any project written in python. Control Flow in Python¶ The if statement acts predictably in Python. >>> if <conditional>:... statement... elif <conditional>:... statement... else:... statement >>> for <item> in <sequence>:... statement >>> while <conditional>:... statement Numerics¶ Strings¶ Note

10 Things C++ Developers Learning C# Should Know After taking a lot of time with C# fundamentals, I decided to go down a different road this week and talk about some of the differences in C# that can be troublesome to people who are used to C++ development but are learning C#. My first post on this blog months ago was just a simple piece on how I divorced C++ as my first-love language (here). This is not to say that C++ is not still a valuable language, in fact as far as object-oriented languages go C++ is still king of performance. That said, C++ has a lot of quirks and idiosyncrasies due to its age and backward-compatibility with C that have caused it to take a back seat to C# and Java for business programming where time-to-market and maintainability are more important than having the absolute best performance. C# especially has made huge inroads into the business development market because it offers a lot of the power of C++ without a lot of the danger. 1. This one should be obvious, so I put it right up front. 2. 3. 4. 3: public:

objgraph 1.7.2 Draws Python object reference graphs with graphviz objgraph is a module that lets you visually explore Python object graphs. You'll need graphviz if you want to draw the pretty graphs. I recommend xdot for interactive use. pip install xdot should suffice; objgraph will automatically look for it in your PATH. Moved to GitHub.Python 3.4 support (LP#1270872).New function: is_proper_module.New shortnames argument for typestats, most_common_types, show_most_common_types, show_growth, show_refs, and show_backrefs.count and by_type accept fully-qualified type names now.Fixes issue 4. Bugfix: sdist was broken on Python 2.7 (UnicodeDecodeError in tarfile).The filename argument for show_refs and show_backrefs now allows arbitrary image formats, not just PNG. Bugfix: non-ASCII characters in object representations would break graph generation on Python 3.x, in some locales (e.g. with LC_ALL=C). Python 3 support, thanks to Stefano Rivera (fixes LP#687601).Removed weird weakref special-casing.

Using .pth files for Python development Python's site module is responsible for setting up the interpreter's environment upon startup. One of the things it does during startup is scan your site directories (typically just site-packages , but framework builds for Mac OS X have an additional undocumented default location) for .pth files. .pth files are used to add additional locations sys.path , and they are typically created by distutils setup scripts that use the (still undocumented) extra_path argument. .pth files are a great alternative to using the PYTHONPATH environment variable: You don't have to screw with your environment (which can be difficult on Mac OS X and Windows). They become especially useful when using a framework build of Python, such as the one that ships with Mac OS X 10.3, because ~/Library/Python/2.3/site-packages/ is added to your path (undocumented), so they become a vector for simply and easily "installing" packages without authentication or administrator access -- perfect for development. py2app.pth

PythonBooks - Learn Python the easy way ! Online Python Tutor - Learn programming by visualizing code execution teejeejee: Playing with C++0x -- lambdas C++0x has a workload of new features[2]... Today I'm having a look at lambdas. Lambdas are available in g++-4.5, for now only available in experimental. What are lambdas? Closures are a very powerful tool that are being retrofitted in many languages (for instance Java). Enough for theory, let's have a look at this new beast. How do they look like? [](int i) { return i + 1; }; This is the increment lambda. How to read this? Using a lambda To use it add arguments, for instance: [](int i) { return i + 1; }(0); would compute the value 1. Storing a lambda The type of a lambda is automatically deduced. auto inc = [](int i) { return i + 1; }; std::cout << inc(0) << std::endl; Notice that calling a named lambda is not different from calling a function. auto mult = [](int x, double y) -> double { return x * y; }; Capturing environment You can use lambdas to capture outter environment. void f() { int x = 5; [](int w) { return w + x; }(0); } void f() { int x = 5; [=](int w) { return w + x; }(0); } Yes, mutable.

A Working Introduction to Crypto with PyCrypto A Working Introduction to Crypto with PyCrypto filed under: cryptography, introduction, and python posted on 2011-06-17 Recently at work I have been using the PyCrypto libraries quite a bit. The documentation is pretty good, but there are a few areas that took me a bit to figure out. Some quick terminology: for those unfamiliar, I introduce the following terms: plaintext: the original messageciphertext: the message after cryptographic transformations are applied to obscure the original message.encrypt: producing ciphertext by applying cryptographic transformations to plaintext.decrypt: producing plaintext by applying cryptographic transformations to ciphertext.cipher: a particular set of cryptographic transformations providing means of both encryption and decryption.hash: a set of cryptographic transformations that take a large input and transform it to a unique (typically fixed-size) output. There are two basic types of ciphers: symmetric and public-key ciphers. What is a salt? Encryption

Python progression path - From apprentice to guru Hackasaurus Look ahead Learn all about Firefox OS » Welcome to Webmaker! That username is taken You must choose a username Invalid username. You must agree to our terms and conditions. X-Ray Goggles Remix and share web pages instantly Activate X-Ray Goggles See how Goggles work by swapping an image Copy this image URL (highlight the text below, right-click, then copy the link) The URL you just copied links to a new image! Share your remix When you're ready to share your remixed page, click the Publish button or press P on your keyboard. Help If you need help, make sure the X-Ray Goggles are activated, then press H on your keyboard. Remix any webpage! You can take X-Ray Goggles with you anywhere on the web: Make sure your web browser's bookmarks bar is enabled. Now visit any website on the internet.