Skip to main content

Home/ Python Programming/ Group items tagged c

Rss Feed Group items tagged

reckoner reckoner

12. Writing a C extension to NumPy - 0 views

  • There are two applications that require using the NumPy array type in C extension modules: Access to numerical libraries: Extension modules can be used to make numerical libraries written in C (or languages linkable to C, such as Fortran) accessible to Python programs. The NumPy array type has the advantage of using the same data layout as arrays in C and Fortran. Mixed-language numerical code: In most numerical applications, only a small part of the total code is CPU time intensive. Only this part should thus be written in C, the rest can be written in Python. NumPy arrays are important for the interface between these two parts, because they provide equally simple access to their contents from Python and from C. This document is a tutorial for using NumPy arrays in C extensions.
reckoner reckoner

Charming Python: Functional programming in Python, Part 1 - 0 views

  • Document options Document options requiring JavaScript are not displayed Rate this pageHelp us improve this contentLevel: IntroductoryDavid Mertz (mertz@gnosis.cx), Applied Metaphysician, Gnosis Software, Inc. 01 Mar 2001Although users usually think of Python as a procedural and object-oriented language, it actually contains everything you need for a completely functional approach to programming. This article discusses general concepts of functional programming, and illustrates ways of implementing functional techniques in Python. We'd better start with the hardest question: "What is functional programming (FP), anyway?" One answer would be to say that FP is what you do when you program in languages like Lisp, Scheme, Haskell, ML, OCAML, Clean, Mercury, or Erlang (or a few others). That is a safe answer, but not one that clarifies very much. Unfortunately, it is hard to get a consistent opinion on just what FP is, even from functional programmers themselves. A story about elephants and blind men seems apropos here. It is also safe to contrast FP with "imperative programming" (what you do in languages like C, Pascal, C++, Java, Perl, Awk, TCL, and most others, at least for the most part).
reckoner reckoner

IpythonOnConsole - IPython - 0 views

  • IPython on resizeable Win32 Console If you are on win32, you might want to use Console, an open source replacement for that inflexible old win32 terminal. Here's how. Install IPython using the .exe installer. Download stable version of Console (1.5 at this time). Create a shortcut to console.exe, right-click -> properties. Set target to e.g. C:\opt\Console\console.exe -c "/k python c:\python25\scripts\ipython.py -p sh" you can also create a tab dedicated to Ipython (and have other dedicated to other shells or command-line app). go to edit->settings->tabs : click on the add button and fill the following fields : * title : ipython ico : C:\Python24\py.ico shell : cmd.exe /k "ipython" start-up dir : whatever is good for you. note that python.exe need to be in the path Using IPython with Version 2 of Console use the -r option for creating the shortcut, e.g. C:\opt\Console2\console.exe -r "/k python c:\python25\scripts\ipython.py -p sh" Some advantages of Console2 over normal console (for IPython use) Distinctive taskbar icon Can reside in system tray There are many other benefits, so it's well worth setting up Example config for Console-2.00b120-Beta (you need to edit the xml file): http://vvtools.googlecode.com/svn/trunk/config/console.xml If you have problems with ctrl+C killing Console2 immediately, launch ipython from a normal Console2 session manually.
reckoner reckoner

stdout in pyscripter - PyScripter | Google Groups - 0 views

  • PyScripter and most Python IDEs redirect sys.stdout.  Also GUI apps like PyScripter have no standard output.  What you need to do is PyObject *f = PySys_GetObject("stdout") and then use PyFile_WriteString for writing to the sys.stdout. This is what Python itself is doing and I think this is the best way
  •  
    PyScripter and most Python IDEs redirect sys.stdout. Also GUI apps like PyScripter have no standard output. What you need to do is PyObject *f = PySys_GetObject("stdout") and then use PyFile_WriteString for writing to the sys.stdout. This is what Python itself is doing and I think this is the best way for printing from C extensions anyway.
reckoner reckoner

"n choose m" module - 0 views

  • """ a class for generating permutations from an array # choose 2 letters from 'abcd' c = Chooser(['a', 'b', 'c', 'd'], 2) while c.hasMoreElements(): print c.next() """ import time, copy class NoMoreChoices(StandardError): pass class Chooser:
reckoner reckoner

XGraph plot dot showing multiple edges - networkx-discuss | Google Groups - 0 views

  • For example edge labels can be added using matplotlib "text" objects like this: import networkx as nx import pylab as plot K=nx.XGraph(name="Konigsberg", multiedges=True, selfloops=False) K.add_edges_from([("A","B","Honey Bridge"),     ("A","B","Blacksmith's Bridge"),     ("A","C","Green Bridge"),     ("A","C","Connecting Bridge"),     ("A","D","Merchant's Bridge"),     ("C","D","High Bridge"),     ("B","D","Wooden Bridge")]) pos=nx.spring_layout(K) nx.draw_nx(K,pos) xa,ya=pos['A'] xb,yb=pos['B'] plot.text((xa+xb)/2,(ya+yb)/2,"Blacksmith's Bridge") plot.show() With a little work you can get the label rotated and exactly how you want it positioned.  You can also set the node positions directly in the "pos" dictionary above.
reckoner reckoner

Py++ introduction - 0 views

  • What is Py++? Definition: Py++ is an object-oriented framework for creating a code generator for Boost.Python library. Py++ uses few different programming paradigms to help you to expose C++ declarations to Python. This code generator will not stand on your way. It will guide you through the whole process. It will raise warnings in the case you are doing something wrong with a link to the explanation. And the most important it will save your time - you will not have to update code generator script every time source code is changed.
Michael Surran

Google Code University - Programming Languages - 0 views

  •  
    Various technology lectures about Python, C++, Java, etc. Note to my 8th grade students - these videos are most likely above your learning curve, but if you love programming and want to get into the "meat" of Python, feel free to check them out.
reckoner reckoner

PerryGeo ยป A quick Cython introduction - 0 views

  • I love python for its beautiful code and practicality. But itโ€™s not going to win a pure speed race with most languages. Most people think of speed and ease-of-use as polar opposites - probably because they remember the pain of writing C. Cython tries to eliminate that duality and lets you have python syntax with C data types and functions - the best of both worlds. Keeping in mind that Iโ€™m by no means an expert at this, here are my notes based on my first real experiment with Cython:
reckoner reckoner

SWIG problems with gcc and Cygwin? - 0 views

  • try $ gcc -I/usr/include/python2.4 -L/lib/python2.4/config --shared example.c example_wrap.c -lpython2.4 -o _example.dll
reckoner reckoner

How can I work on VIM for python code such as cscope for C code? - 0 views

  • Change to the top level directory that contains your python source files, and do find -name '*.py' > cscope.files cscope -b
  • How can I work on VIM for python code such as cscope for C code?
reckoner reckoner

ASPN : Python Cookbook : Permutation and Combination Enumerator - 0 views

  • def comb(items, n=None): if n is None: n = len(items) for i in range(len(items)): v = items[i:i+1] if n == 1: yield v else: rest = items[i+1:] for c in comb(rest, n-1): yield v + c
  • def perm(items, n=None): if n is None: n = len(items) for i in range(len(items)): v = items[i:i+1] if n == 1: yield v else: rest = items[:i] + items[i+1:] for p in perm(rest, n-1): yield v + p
  • Permutation and Combination Enumerator
reckoner reckoner

PyChecker: a python source code checking tool - 0 views

  • PyChecker is a tool for finding bugs in python source code. It finds problems that are typically caught by a compiler for less dynamic languages, like C and C++. It is similar to lint. Because of the dynamic nature of python, some warnings may be incorrect; however, spurious warnings should be fairly infrequent.
reckoner reckoner

taglist.vim - Source code browser (supports C/C++, java, perl, python, tcl, sql, php, e... - 0 views

  • The "Tag List" plugin is a source code browser plugin for Vim and provides an overview of the structure of source code files and allows you to efficiently browse through source code files for different programming languages.  You can visit the taglist plugin home page for more information
jdr santos

Riverbank | Software | PyQt | What is PyQt? - 2 views

  •  
    "PyQt brings together the Qt C++ cross-platform application framework and the cross-platform interpreted language Python. "
1 - 20 of 31 Next ›
Showing 20 items per page