Re: isinstance(.., file) for Python 3

2012-11-08 Thread Stefan Behnel
Duncan Booth, 08.11.2012 14:58: > Ulrich Eckhardt wrote: >> If possible, I'm looking for a solution that works for Pythons 2 and 3, >> since I'm not fully through the conversion yet and have clients that >> might use the older snake for some time before shedding their skin. >> >> Suggestions? >

Re: Python3.3 str() bug?

2012-11-09 Thread Stefan Behnel
Helmut Jarausch, 09.11.2012 10:18: > probably I'm missing something. > > Using str(Arg) works just fine if Arg is a list. > But > str([],encoding='latin-1') > > gives the error > TypeError: coercing to str: need bytes, bytearray or buffer-like object, >list found > > If this is

Re: Python3.3 str() bug?

2012-11-09 Thread Stefan Behnel
Helmut Jarausch, 09.11.2012 14:13: > On Fri, 09 Nov 2012 23:22:04 +1100, Chris Angelico wrote: >> What you really should be doing is not transforming the whole >> structure, but explicitly transforming each part inside it. I >> recommend you stop fighting the language and start thinking about your

Re: How to install libxml2-devel and libxslt-devel in Windows ?

2012-11-10 Thread Stefan Behnel
goldtech, 10.11.2012 18:12: > I have Windows XP and Python 2.7.x > > I download and install libxml2-python-2.7.7.win32-py2.7.exe, From > here: http://users.skynet.be/sbi/libxml-python/ > > This file has both libxml2 AND libxslt. > > But, I also need libxml2-devel and libxslt-devel for python 2.7

Re: A gnarly little python loop

2012-11-11 Thread Stefan Behnel
Steve Howell, 11.11.2012 04:03: > On Nov 10, 2:58 pm, Roy Smith wrote: >> I'm trying to pull down tweets with one of the many twitter APIs. The >> particular one I'm using (python-twitter), has a call: >> >> data = api.GetSearch(term="foo", page=page) >> >> The way it works, you start with page=1

Re: xml data or other?

2012-11-19 Thread Stefan Behnel
Prasad, Ramit, 19.11.2012 22:42: > Artie Ziff wrote: >> Writing XML files so to see whats happening. My plan is to >> keep xml data in memory and parse with xml.etree.ElementTree. >> >> Unfortunately, xml parsing fails due to angle brackets inside >> description tags. In particular, xml.etree.Eleme

Python on Android (was: PyPy 2.0 beta 1 released)

2012-11-22 Thread Stefan Behnel
Peter Funk, 23.11.2012 07:54: > Is it be possible to use PyPy to develop Apps for Android phones and tablets? > Or will it be possible to do so in the future? You can use CPython and kivy for that. Nik Klever gave a quick intro to Python on Android at this year's PyCon-DE: http://pyvideo.org/vid

Re: Using Xpath to parse a Yahoo Finance page

2012-12-02 Thread Stefan Behnel
MRAB, 03.12.2012 03:25: > On 2012-12-03 01:23, Jason Hsu wrote: >> I'm trying to extract the data on "total assets" from Yahoo Finance using >> Python 2.7 and lxml. >> >> Here is a special test script I set up to work on this issue: >> >> import urllib >> import lxml >> import lxml.h

Re: empty object from C

2012-12-07 Thread Stefan Behnel
Eric Frederich, 07.12.2012 16:42: > From C, I'd like to call a Python function that takes an object and sets > some attributes on it. > Lets say this is the function... > > def foo(msg): > msg.bar = 123 > msg.spam = 'eggs' > > How do I create an empty object in C? > In Python I would do s

Re: What are the minimum requirements to get a job in?

2012-12-14 Thread Stefan Behnel
suresh.pinn...@gmail.com, 14.12.2012 03:49: > My aim is to get a job into google or cisco or facebok. Why? There are lots of attractive places to work at. Choosing a less visible one means that you have a higher chance of getting hired in the first place, simply because less people aim for the sa

Re: Create xml with elementtree ET and xml escaping

2012-12-15 Thread Stefan Behnel
nenad.ci...@gmail.com, 12.12.2012 03:19: > Il giorno martedì 11 dicembre 2012 20:59:54 UTC+1, MRAB ha scritto: >> >>> Since I have also the need to sign the XML I need the ability to create xml >>> but without xml escaping (unescaped data are signed). >> >> XML with the escaping isn't valid XML. >

Re: Brython - Python in the browser

2012-12-21 Thread Stefan Behnel
Pierre Quentel, 20.12.2012 10:42: > Le jeudi 20 décembre 2012 01:54:44 UTC+1, Ian a écrit : >> On Wed, Dec 19, 2012 at 5:07 PM, Terry Reedy wrote: To create an element, for instance an HTML anchor : doc <= A('Python',href="http://www.python.org";) >>> >>> To me, that is a awful choice and

Re: Brython - Python in the browser

2012-12-21 Thread Stefan Behnel
Duncan Booth, 21.12.2012 14:14: > Pierre Quentel wrote: >>> If that's your intention, then instead of coming up with something >>> totally new, unpythonic and ugly, why not take the normal Python >>> route and implement a subset of the ElementTree API? >> >> Because the tree implementation in Eleme

Re: Brython - Python in the browser

2012-12-21 Thread Stefan Behnel
Pierre Quentel, 21.12.2012 17:16: > So when you see a line like > > doc <= DIV('hello') > > it should be obvious that you are not *comparing* doc and DIV('hello'), > because if it was the case, the line would do nothing Yep, that's one of the main concerns - it looks like useless code, which is

Re: proposal: Ellipsis in argument list

2013-01-12 Thread Stefan Behnel
Szabolcs Blága, 12.01.2013 14:30: > I have an idea that the Ellipsis object could be used in function calls. > The "..." syntax should automagically turn into an Ellipsis positional > argument. > > def f(*args): > ext_args = [] > for i, a in enumerate(args): > if a is Ellipsis: > ext

Re: Vote tallying...

2013-01-18 Thread Stefan Behnel
Andrew Robinson, 18.01.2013 00:59: > I have a problem which may fit in a mysql database Everything fits in a MySQL database - not a reason to use it, though. Py2.5 and later ship with sqlite3 and if you go for an external database, why use MySQL if you can have PostgreSQL for the same price? > b

Re: Vote tallying...

2013-01-18 Thread Stefan Behnel
Chris Angelico, 19.01.2013 03:00: > On Sat, Jan 19, 2013 at 12:25 PM, Kushal Kumaran wrote: >> Chris Angelico writes: >> >>> On Sat, Jan 19, 2013 at 7:24 AM, Ben Finney wrote: * MySQL's development has suffered under Sun, and become virtually moribund under Oracle. They operate as a clo

Re: Is PyArg_ParseTuple necessary to parse arguments?

2013-01-22 Thread Stefan Behnel
rahulgar...@gmail.com, 22.01.2013 18:20: > Or can I just loop through the argument tuple manually by using something > like PyTuple_GET_ITEM(args,i), then putting manual code to convert the > objects to appropriate C type? > The use case is that I am interfacing Python with another interpreter an

Re: XML/XHTML/HTML differences, bugs... and howto

2013-01-23 Thread Stefan Behnel
Andrew Robinson, 23.01.2013 16:22: > Good day :), > > I've been exploring XML parsers in python; particularly: > xml.etree.cElementTree; and I'm trying to figure out how to do it > incrementally, for very large XML files -- although I don't think the > problems are restricted to incremental parsin

Re: Further evidence that Python may be the best language forever

2013-01-28 Thread Stefan Behnel
Michael Torrie, 29.01.2013 02:15: > On 01/28/2013 03:46 PM, Malcolm McCrimmon wrote: >> My company recently hosted a programming competition for schools >> across the country. One team made it to the finals using the Python >> client, one of the four default clients provided (I wrote it). Most >>

Re: Cheat Engine In Python

2013-02-01 Thread Stefan Behnel
wheelman...@gmail.com, 01.02.2013 05:16: > Are there any softwares like cheat engine and written in python What's a "cheat engine"? And, assuming it exists, why can't you just use it? What's your use case that explains the advantage of having it (re-?)written in Python? > I mean just the code no

Re: String interning in Python 3 - missing or moved?

2012-01-24 Thread Stefan Behnel
Chris Angelico, 24.01.2012 05:47: > Lua and Pike both quite happily solved hash collision attacks in their > interning of strings by randomizing the hash used, because there's no > way to rely on it. Presumably (based on the intern() docs) Python can > do the same, if you explicitly intern your str

Re: Libxml2 Python Manual

2012-01-24 Thread Stefan Behnel
Mauricio Martinez Garcia, 25.01.2012 02:46: > For libxml2, are there any manual. For this library?, i searched on > google and just find the following URL xmlsoft.org > Wich can not find any API manual. I will apreciate your support if have one > for the library in python. Any reason you're not

Re: How do I call super() in c extention ?

2012-01-26 Thread Stefan Behnel
umedoblock, 27.01.2012 03:03: > I'd like to call super() in c extension. > I'd like to rewrite class Baa as c extension. Have you considered using Cython for this? It will allow you to do exactly that with only minor changes to your Python code (if any). And it's quite likely that the C code that

Re: PyPI - how do you pronounce it?

2012-01-28 Thread Stefan Behnel
Chris Angelico, 28.01.2012 08:48: > Hopefully this will be a step up from Rick's threads in usefulness, > but I'm aware it's not of particularly great value! > > How do you pronounce PyPI? Is it: > * Pie-Pie? I consider this taken by PyPy, and I tend to run into the trap of pronouncing both the s

Re: xhtml encoding question

2012-02-01 Thread Stefan Behnel
Tim Arnold, 31.01.2012 19:09: > I have to follow a specification for producing xhtml files. > The original files are in cp1252 encoding and I must reencode them to utf-8. > Also, I have to replace certain characters with html entities. > > I think I've got this right, but I'd like to hear if there

Re: Iterate from 2nd element of a huge list

2012-02-01 Thread Stefan Behnel
Paul Rubin, 01.02.2012 10:25: > Paulo da Silva writes: >> process1(mylist[0]) >> for el in mylist[1:]: >> process2(el) >> >> This way mylist is almost duplicated, isn't it? > > I think it's cleanest to use itertools.islice to get the big sublist > (not tested): > >from itertools import i

Re: xhtml encoding question

2012-02-01 Thread Stefan Behnel
Tim Arnold, 01.02.2012 19:15: > On 2/1/2012 3:26 AM, Stefan Behnel wrote: >> Tim Arnold, 31.01.2012 19:09: >>> I have to follow a specification for producing xhtml files. >>> The original files are in cp1252 encoding and I must reencode them to >>> utf-8.

Re: Fabric Engine + Python benchmarks

2012-02-10 Thread Stefan Behnel
Fabric Paul, 10.02.2012 17:04: > Fabric is a high-performance multi-threading engine that > integrates with dynamic languages. Hmm, first of all, fabric is a tool for automating admin/deployment/whatever tasks: http://pypi.python.org/pypi/Fabric/1.3.4 http://docs.fabfile.org/en/1.3.4/index.html

Re: Python usage numbers

2012-02-11 Thread Stefan Behnel
Eric Snow, 11.02.2012 22:02: > - categories (web, scripts, "big data", computation, etc.) No numbers, but from my stance, the four largest areas where Python is used appear to be (in increasing line length order): a) web applications b) scripting and tooling c) high-performance computation d) tes

Re: XSLT to Python script conversion?

2012-02-13 Thread Stefan Behnel
Matej Cepl, 13.02.2012 12:20: > I am getting more and more discouraged from using XSLT for a transformation > from one XML scheme to another one. Could you explain what it is that discourages you about it? That would allow us to come up with better alternatives for your specific problem. > Does

Re: Complexity question on Python 3 lists

2012-02-15 Thread Stefan Behnel
Ian Kelly, 15.02.2012 19:43: > On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: >> Do lists in Python 3 behave like ArrayList in Java (if the capacity >> is full, then the array grows by more than 1 element) ? > > I believe the behavior in CPython is that if the array is full, the > capacity

Re: Generating class definitions at runtime in memory from XSD or JSON

2012-02-17 Thread Stefan Behnel
Stodge, 17.02.2012 02:15: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? The question is: why do you want to do that? There may be other ways to do what you *actually* want to do, but we don't know what that is. Stefan -- http://mail.pyt

Re: XSLT to Python script conversion?

2012-02-17 Thread Stefan Behnel
Ross Ridge, 17.02.2012 21:37: > Matej Cepl wrote: >> No, the strangness is not that bad (well, it is bad ... almost anything >> feels bad comparing to Python, to be honest, but not the reason I would >> give up; after all I spent couple of years with Javascript). > > The XSLT language is one of

Re: generate Windows exe on Linux

2012-02-22 Thread Stefan Behnel
Gelonida N, 22.02.2012 23:25: > On 02/22/2012 07:05 PM, Alec Taylor wrote: >> http://www.pyinstaller.org/ >> >> or >> >> http://cx-freeze.sourceforge.net/ >> >> You can also run py2exe in WINE >> > > You want to say, that I could install python 2.6 > some packages like win32api > PyQt and tand py2

Re: sum() requires number, not simply __add__

2012-02-23 Thread Stefan Behnel
Chris Rebert, 23.02.2012 22:32: > On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: >> I feel like the design of sum() is inconsistent with other language >> features of python. Often python doesn't require a specific type, only >> that the type implement certain methods. >> >> Given a class th

Re: Python packaging usabilty (distutils) - automatic downloading required packages

2012-02-25 Thread Stefan Behnel
XLiIV, 25.02.2012 15:47: > There is many packaging solutions for python. > I was confused about that but it's nothing. I had to pick one of them. > I picked distutils because it's part of standard python since 3.3, am > i right? Distutils has been part of Python's stdlib for ages. > My goal is t

Re: Fwd: Question about PyXML and python's stdlib xml

2012-02-29 Thread Stefan Behnel
Roman Rakus, 29.02.2012 15:33: > I'm forwarding this message to python-list, since I didn't get answer on > xml-sig ML I didn't see a message from you on that list. > I have concerns about PyXML and stdlib xml included directly in python. > Currently (in Fedora) python is trying to import PyXML,

Re: Porting Python to an embedded system

2012-03-04 Thread Stefan Behnel
Justin Drake, 04.03.2012 11:58: > I am working with an ARM Cortex M3 on which I need to port Python > (without operating system). What would be my best approach? I just > need the core Python and basic I/O. The "without operating system" bit should prove problematic. Can't you just install Linux o

Re: Porting the 2-3 heap data-structure library from C to Python

2012-03-07 Thread Stefan Behnel
Alec Taylor, 07.03.2012 15:25: > I am planning to port the 2-3 heap data-structure as described by > Professor Tadao Takaoka in Theory of 2-3 Heaps published in 1999 and > available in PDF: > http://www.cosc.canterbury.ac.nz/tad.takaoka/2-3heaps.pdf > > The source-code used has been made available

Re: Porting the 2-3 heap data-structure library from C to Python

2012-03-07 Thread Stefan Behnel
Hrvoje Niksic, 07.03.2012 16:48: > Alec Taylor writes: > >> The source-code used has been made available: >> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h >> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c >> >> I plan on wrapping it in a class. > > You should get acquainted

Re: cython + scons + c++

2012-03-08 Thread Stefan Behnel
Neal Becker, 08.03.2012 15:23: > Is there a version of cython.py, pyext.py that will work with c++? > > I asked this question some time ago, but never got an answer. > > I tried the following code, but it doesn't work correctly. If the commented > lines are uncommented, the gcc command is total

Re: Porting the 2-3 heap data-structure library from C to Python

2012-03-10 Thread Stefan Behnel
Hrvoje Niksic, 11.03.2012 02:03: > Stefan Behnel writes: >>> which is the standard way of extending Python with high-performance >>> (and/or system-specific) C code. >> >> Well, it's *one* way. Certainly not the easiest way, neither the most >> portab

Re: html5lib not thread safe. Is the Python SAX library thread-safe?

2012-03-12 Thread Stefan Behnel
John Nagle, 11.03.2012 21:30: >"html5lib" is apparently not thread safe. > (see "http://code.google.com/p/html5lib/issues/detail?id=189";) > Looking at the code, I've only found about three problems. > They're all the usual "cached in a global without locking" bug. > A few locks would fix that.

Re: Raise X or Raise X()?

2012-03-12 Thread Stefan Behnel
Irmen de Jong, 11.03.2012 21:37: > On 11-3-2012 20:04, bvdp wrote: >> Which is preferred in a raise: X or X()? I've seen both. In my specific case >> I'm dumping out of a deep loop: >> >> try: >> for ... >> for ... >> for ... >> if match: >>raise StopInteration() >>

Re: Raise X or Raise X()?

2012-03-12 Thread Stefan Behnel
Steven D'Aprano, 12.03.2012 16:08: > On Mon, 12 Mar 2012 14:52:49 +0100, Stefan Behnel wrote: >>> "raise X" is a special case of the 3-args raise. Effectively it just >>> raises an instance of X which is constructed with an empty argument >>> list. Ther

Re: Instantiate a python class object in C

2012-03-14 Thread Stefan Behnel
Dids, 14.03.2012 14:46: > Apologies if this was asked before, I couldn't find anything. > > I have a class defined in a python file: > for example: > > class demo: > [ class definition goes here] > > I'm writing a C extension. > In the first function, I take an instance of the "demo" class

Re: Fast file data retrieval?

2012-03-21 Thread Stefan Behnel
Jorgen Grahn, 13.03.2012 21:44: > On Mon, 2012-03-12, MRAB wrote: >> Probably the best solution is to put it into a database. Have a look at >> the sqlite3 module. > > Some people like to use databases for everything, others never use > them. I'm in the latter crowd, so to me this sounds as overki

Re: Compiling Python (modules) on 64bit Windows - which compiler suite?

2012-03-22 Thread Stefan Behnel
Thomas Bach, 21.03.2012 20:03: > Ralph Heinkel writes: >> when processing our mass spectrometry data we are running against the >> 2GB memory limit on our 32 bit machines. So we are planning to move to >> 64bit. Downloading and installing the 64bit version of Python for >> Windows is trivial, but h

Re: Is there any difference between print 3 and print '3' in Python ?

2012-03-26 Thread Stefan Behnel
redstone-c...@163.com, 26.03.2012 16:28: > 在 2012年3月26日星期一UTC+8下午8时11分03秒,Dave Angel写道: >> On 03/26/2012 07:45 AM, redstone-c...@163.com wrote: >>> I know the print statement produces the same result when both of these two >>> instructions are executed ,I just want to know Is there any difference

Re: Tools for refactoring/obfuscation

2012-03-27 Thread Stefan Behnel
Javier, 07.03.2012 04:29: > I am looking for an automated tool for refactoring/obfuscation. Sadly, there really is one thing that these two have in common: they modify code while retaining its exact functionality. Apart from that, they are diametric opposites. Refactoring aims at making the code "

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Stefan Behnel
Peter Daum, 28.03.2012 10:56: > is there any way to convert a string to bytes without > interpreting the data in any way? Something like: > > s='abcde' > b=bytes(s, "unchanged") If you can tell us what you actually want to achieve, i.e. why you want to do this, we may be able to tell you how to d

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Stefan Behnel
Peter Daum, 28.03.2012 11:43: > What I am looking for is a general way to just copy the raw data > from a "string" object to a "byte" object without any attempt to > "decode" or "encode" anything ... That's why I asked about your use case - where does the data come from and why is it contained in

Re: How to resolve circular reference in python C extension?

2012-04-09 Thread Stefan Behnel
罗勇刚(Yonggang Luo) , 09.04.2012 04:28: > static PyObject * > Repository_get_index(Repository *self, void *closure) > { > int err; > git_index *index; > Index *py_index; > > assert(self->repo); > > if (self->index == NULL) { > err = git_repository_index(&index, self->rep

Re: Get stack trace from C

2012-04-16 Thread Stefan Behnel
Eric Frederich, 16.04.2012 20:14: > I embed Python in a 3rd party application. > I need to use their conventions for errors. > > Looking here... > http://docs.python.org/extending/embedding.html#pure-embedding > the example uses PyErr_Print() but that goes to stdout or stderr or > somethin

Re: Python interface of Stanford Parser

2012-04-20 Thread Stefan Behnel
ac27037, 20.04.2012 15:19: > Does anybody know how to use the Stanford Parser for Python Interface? I have > tried many times, and don't know how to install and use. In fact, I have > failed at that many times. Here is the interface: > > http://projects.csail.mit.edu/spatial/Stanford_Parser It

Re: Upgrading from 2.7 to 3.x

2012-04-25 Thread Stefan Behnel
deuteros, 26.04.2012 05:08: > I'm fairly new to Python I have version 2.7 installed on my computer. However > my professor wants us all to use the latest version of Python. Did he/she explicitly tell you to install Python 3? 2.7 is the latest version of Python 2.x, some people may mix that up. O

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 26.04.2012 21:28: > "All you have to do is assign to print". Sounds great! Can some kind soul > hit me with a clue stick? Were do I look in the API? Here's the (Py3) Cython code for it: print = my_print_function Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 26.04.2012 19:57: > I want to extend an embedded interpreter so that calls to print() are > automagically sent to a C++ gui (windows exe) via a callback function in > the DLL. > > Then I'll be able to do this: > > test.py > import printoverload > > printoverload.set_stdout(

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 27.04.2012 10:36: > On 27/04/2012 5:15 PM, Stefan Behnel wrote: >> Peter Faulks, 26.04.2012 19:57: >>> I want to extend an embedded interpreter so that calls to print() are >>> automagically sent to a C++ gui (windows exe) via a callback function in >&g

Re: (3.2) Overload print() using the C API?

2012-04-28 Thread Stefan Behnel
Peter Faulks, 27.04.2012 22:31: > On 27/04/2012 6:55 PM, Stefan Behnel wrote: >> Peter Faulks, 27.04.2012 10:36: >>> On 27/04/2012 5:15 PM, Stefan Behnel wrote: >>>> Peter Faulks, 26.04.2012 19:57: >>>>> I want to extend an embedded interpreter so that

Re: "

2012-05-04 Thread Stefan Behnel
Ian Kelly, 04.05.2012 01:02: > BeautifulSoup is supposed to parse like a browser would Not at all, that would be html5lib. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python Lazy?

2012-05-05 Thread Stefan Behnel
Dan Stromberg, 06.05.2012 07:40: > you probably won't be able to write a sort routine, and > use it as a "first 100 lowest values" routine for free. But you could > construct something that does almost the same thing lazily using a > generator - not for free. OTOH, if you really wanted to do this

Re: sorting 1172026 entries

2012-05-06 Thread Stefan Behnel
J. Mwebaze, 06.05.2012 18:29: > sorry see, corrected code > > for filename in txtfiles: >temp=[] >f=open(filename) >for line in f.readlines(): > line = line.strip() > line=line.split() > temp.append((parser.parse(line[0]), float(line[1]))) >temp=sorted(temp) >wit

Re: Retrieving result from embedded execution

2012-05-10 Thread Stefan Behnel
F L, 08.05.2012 21:07: > We are trying to implement our own interactive interpreter in our > applicationusing an embedded Python interpreter. I was wondering what > would be the best way to retreive as text the result of executing > Python code. The text must be exactly the same as it would be in

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
David Shi, 13.05.2012 15:25: > Can anyone tell me how to call and exectute C code in Python? Take a look at Cython, a Python-like language that supports native calls to and from C/C++ code. It translates your code into very efficient C code, so the wrapping code tends to be very fast (often faster

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:23: > On 13/05/2012 16:39, Chris Angelico wrote: >> On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: >>> Can anyone tell me how to call and exectute C code in Python? >> >> Browse the documentation about Extending and Embedding Python, there's >> an extensive API. >

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:27: > On 13/05/2012 16:58, Stefan Behnel wrote: >> David Shi, 13.05.2012 15:25: >>> Can anyone tell me how to call and exectute C code in Python? >> >> Take a look at Cython, a Python-like language that supports native calls to >>

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:44: > On 13/05/2012 18:38, Stefan Behnel wrote: >> Mark Lawrence, 13.05.2012 19:23: >>> On 13/05/2012 16:39, Chris Angelico wrote: >>>> On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: >>>>> Can anyone tell

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 20:25: > My response to Chris Angelico was simple and > you've gone off at a complete tangent whilst writing "War and Peace". Or is > it a simple matter that my newsreader is better than your newsreader? Ah, sorry. I didn't know we were discussing at *that* level. Stefan

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Devin Jeanpierre, 14.05.2012 01:19: > Now if only my editor would bold those "cdef"s... :) Cython syntax support in editors is definitely not ubiquitous, but it's getting more and more widespread, so you may be lucky at some point (or find a way to add it yourself). Pygments also does a pretty goo

Re: Need to get Tags and Values from Dom

2012-05-13 Thread Stefan Behnel
TommyVee, 14.05.2012 02:50: > I have a very simple XML document that I need to "walk", and I'm using > xml.dom.minidom. No attributes, just lots of nested tags and associated > values. All I'm looking to do is iterate through each of the highest > sibling nodes, check what the tag is, and process

Re: Need to get Tags and Values from Dom

2012-05-14 Thread Stefan Behnel
TommyVee, 15.05.2012 01:51: > Confused? That's an understatement. Part of the problem is that it's been > a long time since I learned DOM and now I'm trying to cram to get this > program done. Thus my recommendation to use ElementTree. Why go the complicated route when you can just get your code

Re: ucs2 and ucs4 python

2012-05-16 Thread Stefan Behnel
zayatzz, 16.05.2012 10:22: > On May 15, 7:42 pm, Miki Tebeka wrote: >>> Can someone point me towards a resource or two which will tell me how >>> to do this - im not very good with whole linux/servers stuff. Im using >>> ubuntu linux - if that makes any difference. >> >> Did not test, but this is t

Re: python and xml

2012-05-16 Thread Stefan Behnel
Nibin V M, 16.05.2012 16:16: > I am trying to use cPanel XML-API and every API call return data in XML > format. I would like to know how to manipulate the data here. > > For eg: How can I read the CPU load data from the below output > > > > 0.000.000.00 Here's some untested code to print the

Re: python and xml

2012-05-16 Thread Stefan Behnel
Hi, please don't top-post (I fixed the citation order below). Nibin V M, 16.05.2012 16:30: > On Wed, May 16, 2012 at 7:53 PM, Stefan Behnel wrote: >> Nibin V M, 16.05.2012 16:16: >>> I am trying to use cPanel XML-API and every API call return data in XML >>> for

Re: Where is the latest step by step guide to use Jython to compile Python into Java?

2012-06-04 Thread Stefan Behnel
David Shi, 04.06.2012 16:36: > Where is the latest step by step guide to use Jython to compile Python into > Java? I don't think there is such a thing, simply because Jython does not compile Python into Java. > I found that it was very confusing by reading not updated text. It usually helps to

Re: Where is the latest step by step guide to use Jython to compile Python into Java?

2012-06-04 Thread Stefan Behnel
Narayanaswamy, Mohan, 04.06.2012 16:56: > Python is dynanmic programming (but strongly typed), java is > static-typed language. Currently it is not possible to convert python > into java, since python types are dynamically identified, not identified > during compilation. That's not entirely true.

Re: Where is the latest step by step guide to use Jython to compilePython into Java?

2012-06-04 Thread Stefan Behnel
David Shi, 04.06.2012 17:35: > Compiling your Python code with jythonc > I do not know whether I downloaded a wrong version of Jythonc? Or, got > mismatched software or instructions. Jythonc used to work in Jython 2.2 but is no longer supported in Jyton 2.5. Stefan -- http://mail.python.org/

Re: validating XML

2012-06-13 Thread Stefan Behnel
andrea crotti, 13.06.2012 12:06: > Hello Python friends, I have to validate some xml files against some xsd > schema files, but I can't use any cool library as libxml unfortunately. Any reason for that? Because the canonical answer to your question would be lxml, which uses libxml2. Stefan -- h

Re: Academic citation of Python

2012-06-17 Thread Stefan Behnel
Dennis Lee Bieber, 17.06.2012 02:46: > On Sat, 16 Jun 2012 20:25:29 -0400, Terry Reedy > declaimed the following in gmane.comp.python.general: > >> Thank you for the correction. I was going by an old book (1996) he >> co-wrote that just had 'Rossum' on the spine. I guess that must have >> been d

Re: Nimp: Nested Imports (a la Java)

2011-06-16 Thread Stefan Behnel
Tomer Filiba, 16.06.2011 10:48: Nimp (Nested Imports) is a little meta-importer hook for Python 2.3-2.7 and 3.0-3.2 that enables the use of *nested packages* (`com.ibm.foo.bar`), as is commonplace in Java and various other languages. It works by collecting all packages that begin with a common

Re: NEED HELP-process words in a text file

2011-06-19 Thread Stefan Behnel
Cathy James, 19.06.2011 01:21: def fileProcess(filename): """Call the program with an argument, it should treat the argument as a filename, splitting it up into words, and computes the length of each word. print a table showing the word count for each of the word lengths that

Re: keeping local state in an C extension module

2011-06-30 Thread Stefan Behnel
Daniel Franke, 30.06.2011 12:07: For a project I implemented a extension module in C. Given the excellent documentation everything was straightforward and works fine so far. Don't miss out taking a look at Cython, just in case it's going to be a non-trivial project. Up until now I kept loc

Re: keeping local state in an C extension module

2011-06-30 Thread Stefan Behnel
Daniel Franke, 30.06.2011 13:37: 2011/6/30 Stefan Behnel: There's a PEP for Py3 that enables this through a general framework. In general, to achieve this, you may want to allocate the module content (including types etc.) on the heap rather than statically. http://www.python.org/dev/pep

Re: How do twisted and multiprocessing.Process create zombies?

2011-07-05 Thread Stefan Behnel
bitcycle, 05.07.2011 23:52: In python, using twisted loopingcall, multiprocessing.Process, and multiprocessing.Queue; is it possible to create a zombie process. And, if so, then how? I think it's best to consult your local Voodoo master on the matter of zombie creation processes. That bein

Re: CI and BDD with Python

2011-07-08 Thread Stefan Behnel
mark curphey, 09.07.2011 01:41: And for CI having been using Hudson for a while, any real advantages in a Python / Django world for adopting something native like Trac and one of the CI plugins like Bitten? I warmly recommend Jenkins (i.e. Hudson) for anything CI. It gives you tons of plugin

Re: Morelia for BDD in Python

2011-07-09 Thread Stefan Behnel
Phlip, 10.07.2011 07:10: On Jul 9, 8:38 pm, Ben Finney wrote: Phlip writes: On Jul 9, 7:39 pm, mark curphey wrote: Thanks. FWIW I played with a bunch (Freshen, Morelia, Lettuce) Morelia is "undermaintained" because it's finished. It attaches to any pre-existing TestCase-style test

Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-11 Thread Stefan Behnel
Ivan Kljaic, 11.07.2011 00:50: Ok Guys. I know that most of us have been expiriencing the need for a nice Gui builder tool for RAD and most of us have been googling for it a lot of times. But seriously. Why is the not even one single RAD tool for Python. Just a quick suggestion regarding the wa

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Stefan Behnel
Terry Reedy, 15.07.2011 05:00: On 7/14/2011 9:51 PM, Ben Finney wrote: Steven D'Aprano writes: Inside wrote: As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? At one time (before 2.2), they were functions and not classes. They are still f

Re: Python ++ Operator?

2011-07-15 Thread Stefan Behnel
Chris Angelico, 15.07.2011 10:06: 2011/7/15 Björn Lindqvist: Pre and post-increments are almost always confusing unless they are used as the counter-variable inside for-loops. I agree that they're often confusing (i+j) but there are several places where they're handy. array[count++]=value

Re: a little parsing challenge ☺

2011-07-18 Thread Stefan Behnel
Rouslan Korneychuk, 18.07.2011 09:09: I don't know why, but I just had to try it (even though I don't usually use Perl and had to look up a lot of stuff). I came up with this: /(?| (\()(?&matched)([\}\]”›»】〉》」』]|$) | (\{)(?&matched)([\)\]”›»】〉》」』]|$) | (\[)(?&matched)([\)\}”›»】〉》」』]|$) | (“)(?&m

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-19 Thread Stefan Behnel
Terry Reedy, 19.07.2011 18:31: Chapter 5 is mostly about the behavior of built-in class instances. For some classes, like range, instances only come from class calls and the behavior of instances is intimately tied to the constructor arguments. Having the constructor described in C.5 might be use

Re: I am fed up with Python GUI toolkits...

2011-07-20 Thread Stefan Behnel
Steven D'Aprano, 20.07.2011 06:28: Python has a GIL. Except for Jython, IronPython and PyPy. PyPy has a GIL, too. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: I am fed up with Python GUI toolkits...

2011-07-20 Thread Stefan Behnel
sturlamolden, 20.07.2011 04:12: Or should modern deskop apps be written with something completely different, such as HTML5? Depends. For many "desktop" apps, this is actually quite workable, with the additional advantage of having an Internet-/Intranet-ready implementation available in case y

Re: Question about timeit

2011-07-21 Thread Stefan Behnel
Frank Millman, 22.07.2011 08:06: I mentioned in a recent post that I noticed an inconsistency in timeit, and then reported that I must have made a mistake. I have now identified my problem, but I don't understand it. C:\Python32\Lib>timeit.py "int(float('165.0'))" 10 loops, best of 3: 3.52

Re: Question about timeit

2011-07-22 Thread Stefan Behnel
Thomas Rachel, 22.07.2011 10:08: Am 22.07.2011 08:59 schrieb Frank Millman: My guess is that it is something to do with the console, but I don't know what. If I get time over the weekend I will try to get to the bottom of it. I would guess that in the first case, python (resp. timeit.py) gets

Re: python.org is down?

2011-07-24 Thread Stefan Behnel
Laszlo Nagy, 24.07.2011 09:43: Can it be a problem on my side? I have tried from several different computers. I cannot even ping it. What's even worse is that PyPI is extremely slow in responding, even up to connection failures. I can live with www.python.org being down for a bit, but PyPI is

Re: seeking an example on C extension works in python 3.1.x or above

2011-07-27 Thread Stefan Behnel
Terry Reedy, 27.07.2011 04:58: On 7/26/2011 8:06 PM, llwaeva...@gmail.com wrote: I have been searching the example on C extension that works in python 3.1.x All the stdlib modules written in C. These are extension modules that come with Python. There are perhaps a hundred more on PyPI. Or hu

Re: can I use element tree for handling special characters in xml text?

2011-07-27 Thread Stefan Behnel
hackingKK, 27.07.2011 13:16: I have been waiting a lot to ask this question and I did ask some days back but probably could not put it the proper way. I assume you missed the answer you got? I want to know how I can safely include special characters like & or > in xml text? For example I sto

<    1   2   3   4   5   6   7   8   9   10   >