Re: [Tutor] Python C extension - which method?

2018-05-05 Thread Stefan Behnel
Hi, Brad M schrieb am 04.05.2018 um 11:30: > I want to create a C-based memory scanner for Python, and so far this is > how I do it: > > Python: > > from ctypes import cdll > mydll = cdll.LoadLibrary('hello.dll') > print(mydll.say_something()) > > and hello.dll: > > #include > __declspec(dlle

Re: [Tutor] XML Programs

2018-04-17 Thread Stefan Behnel
Glen schrieb am 16.04.2018 um 13:10: > I'm writing a save-game editor for a game I play (just a project to learn). > But I am struggling on how to structure the code, how to store the xml data > in data structure etc, > > Can anyone recommend some source I can review that reads and writes data > f

Re: [Tutor] XML Programs

2018-04-17 Thread Stefan Behnel
leam hall schrieb am 16.04.2018 um 14:54: > On Mon, Apr 16, 2018 at 7:10 AM, Glen wrote: >> I'm writing a save-game editor for a game I play (just a project to learn). >> But I am struggling on how to structure the code, how to store the xml data >> in data structure etc, >> >> Can anyone recommend

Re: [Tutor] XML parsing

2018-03-30 Thread Stefan Behnel
Neil Cerutti schrieb am 30.03.2018 um 15:50: > On 2018-03-30, Stefan Behnel wrote: >> I admit that I'm being a bit strict here, there are certainly >> cases where parsing the namespace from a tag is a sensible >> thing to do. I'm really just saying that most of the

Re: [Tutor] XML parsing

2018-03-30 Thread Stefan Behnel
Asif Iqbal schrieb am 30.03.2018 um 03:40: > On Thu, Mar 29, 2018 at 3:41 PM, Peter Otten wrote: >> Asif Iqbal wrote: >>> On Thu, Mar 29, 2018 at 3:56 AM, Peter Otten wrote: Asif Iqbal wrote: > Here is a sample xml file > > http://tail-f.com/ns/rest";> > http://networks.com/n

Re: [Tutor] Recommended Python Compiler

2017-07-31 Thread Stefan Behnel
Ben Finney schrieb am 31.07.2017 um 04:24: > You might be looking for a different compiler, maybe one which compiles > not to Python byte code but instead to CPU machine code. There isn't > such a thing; The Python wiki lists several compilers for Python, although with varying levels of language c

Re: [Tutor] Python Optical Character Recognition

2015-09-30 Thread Stefan Behnel
Sebastian Cheung via Tutor schrieb am 30.09.2015 um 10:55: > How to read a jpg or png file into python and extract text thanks. I > would imagine getting small symbols like ; or , to be difficult? That depends entirely on the OCR engine. And you won't normally get in touch with that very deeply.

Re: [Tutor] Problem using lxml

2015-08-23 Thread Stefan Behnel
Anthony Papillion schrieb am 23.08.2015 um 01:16: > from lxml import html > import requests > > page = requests.get("http://joplin.craigslist.org/search/w4m";) > tree = html.fromstring(page.text) While requests has its merits, this can be simplified to tree = html.parse("http://joplin.craigs

Re: [Tutor] Generate Prime Numbers

2015-05-29 Thread Stefan Behnel
Mirage Web Studio schrieb am 29.05.2015 um 17:28: > Below is a sample code i created. > Can i better it any way? Absolutely. Prime number generation is a very well researched and fun to implement topic. Thus many people have done it before. See this for algorithmic improvements: https://pypi.pyt

Re: [Tutor] pip install lxml fails

2015-04-09 Thread Stefan Behnel
Alex Kleider schrieb am 09.04.2015 um 21:49: > On 2015-04-09 09:11, Stefan Behnel wrote: >> All you need to do is install the "-dev" package that goes with your Python >> installation, e.g. "python3-dev" should match Python 3.4 in current Ubuntu >> releases

Re: [Tutor] pip install lxml fails

2015-04-09 Thread Stefan Behnel
Alex Kleider schrieb am 09.04.2015 um 17:29: > On 2015-04-09 07:08, Brandon McCaig wrote: >> I'm a python newbie, but it looks to me like your compiler cannot >> find your header files, and in particular pyconfig.h. >> >> I tried searching my system and found a file with that name at >> these locat

Re: [Tutor] Code critique

2014-10-24 Thread Stefan Behnel
Bo Morris schrieb am 24.10.2014 um 14:03: > May I please get a little instructional criticism. The code below works. It > logs into 9 different Linux computers, runs a couple commands, and then > transfers a file back to the server. I want to become a better Python > coder; therefore, I was hoping

Re: [Tutor] Standard Library Performance (3.4.1)

2014-10-24 Thread Stefan Behnel
Alan Gauld schrieb am 24.10.2014 um 13:03: > Not all library modules are C based however so it doesn't > always apply. But they are usually optimised and thoroughly > debugged so it is still worth using them rather than building > your own. It's worth stressing this point a bit more. Lots of peopl

Re: [Tutor] Better way to check *nix remote file age?

2014-06-27 Thread Stefan Behnel
Raúl Cumplido, 27.06.2014 12:10: > I would recommend you to migrate your Python version for a newer one where > you can use fabric, paramiko or other ssh tools. It would be easier. +1 Even compiling it yourself shouldn't be too difficult on Linux. > I would recommend also instead of doing an "l

Re: [Tutor] Android

2014-06-04 Thread Stefan Behnel
Mario Py, 04.06.2014 07:47: > I'm writing one small simple program that will use Tkinter. > Once finished, will I be able to run it on android tablet? Have a look at kivy, it supports different systems, including various mobile devices. http://kivy.org/ Stefan _

Re: [Tutor] xml parsing from xml

2014-05-10 Thread Stefan Behnel
Stefan Behnel, 10.05.2014 10:57: > Danny Yoo, 07.05.2014 22:39: >> If you don't want to deal with a event-driven approach that SAX >> emphasizes, you may still be able to do this problem with an XML-Pull >> parser. You mention that your input is hundreds of megabytes

Re: [Tutor] xml parsing from xml

2014-05-10 Thread Stefan Behnel
Danny Yoo, 07.05.2014 22:39: > If you don't want to deal with a event-driven approach that SAX > emphasizes, you may still be able to do this problem with an XML-Pull > parser. You mention that your input is hundreds of megabytes long, in > which case you probably really do need to be careful abou

Re: [Tutor] preferred httprequest library

2014-05-09 Thread Stefan Behnel
Martin A. Brown, 09.05.2014 00:54: > : I¹m new to python but not so much to programming. I need to > : construct a set or programs to test a forms poster that has been > : enhanced (it is in php). I mostly need http get and post. This > : is a hands on set of tests and does not have to be

Re: [Tutor] xml parsing from xml

2014-05-07 Thread Stefan Behnel
Neil D. Cerutti, 07.05.2014 20:04: > On 5/7/2014 1:39 PM, Alan Gauld wrote: >> On 07/05/14 17:56, Stefan Behnel wrote: >>> Alan Gauld, 07.05.2014 18:11: >>>> and ElementTree (aka etree). The documenation gives examples of both. >>>> sax is easie

Re: [Tutor] xml parsing from xml

2014-05-07 Thread Stefan Behnel
Alan Gauld, 07.05.2014 18:11: > Python comes with several XML parsers. The simplest to use are probably sax > and ElementTree (aka etree). The documenation gives examples of both. sax > is easiest and fastest for simple XML in big files while etree is probably > better for more complex XML structur

Re: [Tutor] array('c')

2014-05-01 Thread Stefan Behnel
Ian D, 01.05.2014 16:38: > I have this part of code and am unsure as to the effect of the array('c') > part. The argument that you pass into the constructor is a type identifier. https://docs.python.org/2/library/array.html#array.array The different types are defined at the top of that page. I

Re: [Tutor] cdata/aml question..

2014-04-13 Thread Stefan Behnel
Peter Otten, 13.04.2014 10:56: > from xml.etree import ElementTree as ET > #root = ET.parse(filename).getroot() > root = ET.fromstring(data) > for department in root.findall(".//department"): > name = department.find("name").text > desc = department.find("desc").text name = departmen

Re: [Tutor] c++ on python

2014-03-13 Thread Stefan Behnel
Russel Winder, 13.03.2014 17:29: > On Thu, 2014-03-13 at 16:57 +0100, Stefan Behnel wrote: > […] >> The thing is: if you have to write your own wrapper anyway (trivial or >> not), then why not write it in Cython right away and avoid the intermediate >> plain C level? >

Re: [Tutor] c++ on python

2014-03-13 Thread Stefan Behnel
James Chapman, 13.03.2014 17:35: > Perhaps I should look into Cython as I'm currently working on a > project that utilises a C API. > > I've been finding that getting the data types to be exactly what the C > API is expecting to be the hardest part. > > With the original question in mind, here's

Re: [Tutor] c++ on python

2014-03-13 Thread Stefan Behnel
Alan Gauld, 12.03.2014 23:05: > On 12/03/14 16:49, Stefan Behnel wrote: >> Alan Gauld, 12.03.2014 10:11: >>> If it were a library then you would have to call >>> the individual C++ functions directly using >>> something like ctypes, which is usually more >&

Re: [Tutor] c++ on python

2014-03-12 Thread Stefan Behnel
Alan Gauld, 12.03.2014 10:11: > If it were a library then you would have to call > the individual C++ functions directly using > something like ctypes, which is usually more > complex. ctypes won't talk to C++, but Cython can do it quite easily. Stefan __

Re: [Tutor] XML parsing when elements contain foreign characters

2014-01-09 Thread Stefan Behnel
Garry Bettle, 09.01.2014 09:50: > I'm trying to parse some XML and I'm struggling to reference elements that > contain foreign characters. I skipped over Steven's response and he apparently invested quite a bit of time in writing it up so nicely, so I can happily agree and just add one little comm

Re: [Tutor] trying to parse an xml file

2013-12-15 Thread Stefan Behnel
Steven D'Aprano, 14.12.2013 23:22: > On Sat, Dec 14, 2013 at 09:29:00AM -0500, bruce wrote: >> Looking at a file -->> >> http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml >> >> The file is generated via online/web url, and appears to be XML. >> >> However, when I u

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread Stefan Behnel
bruce, 14.12.2013 15:29: > Looking at a file -->> > http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml That file looks ok to me. > The file is generated via online/web url, and appears to be XML. > > However, when I use elementtree: > document = ElementTree.pa

Re: [Tutor] Pretty printing XML using LXML on Python3

2013-11-30 Thread Stefan Behnel
SM, 29.11.2013 22:21: > On Thu, Nov 28, 2013 at 2:45 PM, eryksun wrote: >> On Thu, Nov 28, 2013 at 2:12 PM, SM wrote: >>> Run with Python3: >>> >>> $ python3 testx.py >>> b'\n \n some text\n\n' >> >> print() first gets the object as a string. tostring() returns bytes, >> and bytes.__str__ returns

Re: [Tutor] Load Entire File into memory

2013-11-04 Thread Stefan Behnel
Amal Thomas, 04.11.2013 14:55: > I have checked the execution time manually as well as I found it through my > code. During execution of my code, at start, I stored my initial time(start > time) to a variable and at the end calculated time taken to run the code = > end time - start time. There was

Re: [Tutor] A mergesort

2013-08-31 Thread Stefan Behnel
D.V.N.Sarma డి.వి.ఎన్.శర్మ, 31.08.2013 18:30: > I have been searching for mergesort implimentations in python and came > across this. In case this isn't just for education and you actually want to use it, the built-in sorting algorithm in Python (used by list.sort() and sorted()) is a very fast me

Re: [Tutor] list all links with certain extension in an html file python

2012-09-28 Thread Stefan Behnel
Santosh Kumar, 16.09.2012 09:20: > I want to extract (no I don't want to download) all links that end in > a certain extension. > > Suppose there is a webpage, and in the head of that webpage there are > 4 different CSS files linked to external server. Let the head look > like this: > > http:

Re: [Tutor] measuring the start up time of an event-driven program

2012-07-24 Thread Stefan Behnel
Albert-Jan Roskam, 24.07.2012 11:18: > I would like to test how long it takes for two versions of the same > program to start up and be ready to receive commands. The program is > SPSS version-very-old vs. SPSS version-latest. > > Normally I'd just fire the program up in a subprocess and measure t

Re: [Tutor] The Best Way to go About with Self Modifying Code/Code Generation?

2012-07-08 Thread Stefan Behnel
Steven D'Aprano, 08.07.2012 15:48: >> Hey all, I have a question on using self-modifying code/code generation >> in Python; namely how to do it. > > I know others have already said not to do this, and to be honest I was > going to say that same thing, but I have changed my mind. Buggrit, this is

Re: [Tutor] The Best Way to go About with Self Modifying Code/Code Generation?

2012-07-07 Thread Stefan Behnel
Aaron Tp, 07.07.2012 23:19: > I have a question on using self-modifying code/code generation > in Python; namely how to do it. Don't. Seriously, the answer you should ask yourself is: why do you think the genetic algorithm (or whatever you are trying to do exactly) would come up with any reasonab

Re: [Tutor] Python XML for newbie

2012-07-02 Thread Stefan Behnel
Peter Otten, 02.07.2012 09:57: > Sean Carolan wrote: >>> Thank you, this is helpful. Minidom is confusing, even the >>> documentation confirms this: >>> "The name of the functions are perhaps misleading" Yes, I personally think that (Mini)DOM should be locked away from beginners as far as pos

Re: [Tutor] The dreaded UnicodeDecodeError... why, why, why does it still want ascii?

2012-06-06 Thread Stefan Behnel
Marc Tompkins, 06.06.2012 10:21: > On Tue, Jun 5, 2012 at 11:22 PM, Stefan Behnel wrote: > >> You can do this: >> >>connection = urllib2.urlopen(url) >>tree = etree.parse(connection, my_html_parser) >> >> Alternatively, use fromstring() to p

Re: [Tutor] The dreaded UnicodeDecodeError... why, why, why does it still want ascii?

2012-06-05 Thread Stefan Behnel
Marc Tompkins, 06.06.2012 03:10: > I'm trying to parse a webpage using lxml; every time I try, I'm > rewarded with "UnicodeDecodeError: 'ascii' codec can't decode byte > 0x?? in position?: ordinal not in range(128)" (the byte value and > the position occasionally change; the error never does.)

Re: [Tutor] breeds of Python .....

2012-04-01 Thread Stefan Behnel
Brett Ritter, 01.04.2012 07:19: > On Sat, Mar 31, 2012 at 5:37 PM, Barry Drake wrote: >> concentrate on Python3 or stay with Python2 and get into bad habits when it >> comes to change eventually? Apart from the print and input functions, I >> haven't so far got a lot to re-learn. > > My recommend

Re: [Tutor] Python with HTML

2012-01-29 Thread Stefan Behnel
t4 techno, 28.01.2012 11:02: > I want to make a web page which has to include some python script and html > tags as well, am not getting how to do that . > I searched some articles but cant understand them . > is there anything like linking an external html file into python script ? > > Can u plea

Re: [Tutor] Why do you have to close files?

2012-01-26 Thread Stefan Behnel
Alan Gauld, 27.01.2012 02:16: > with open(myfile) as aFile: > # use aFile I should add that this is the shortest, safest (as in "hard to get wrong") and most readable way to open and close a file. It's worth getting used to. Stefan ___ Tutor maill

Re: [Tutor] Text Proccessing/Command Line Redirection/XML Parsing etc in Python.

2011-11-28 Thread Stefan Behnel
Pritesh Ugrankar, 28.11.2011 07:56: First of all, my apologies for writing this very long post. Welcome to the list. :) I have been through some related questions about this in Stack Overflow as well as googled it and found that Perl and Python are the two languages that offer most what I ne

Re: [Tutor] Cython vs Python-C API

2011-11-15 Thread Stefan Behnel
Dario Lopez-Kästen, 15.11.2011 09:33: On Tue, Nov 15, 2011 at 9:09 AM, Stefan Behnel wrote: cubic spline interpolation No, I didn't. Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Cython vs Python-C API

2011-11-15 Thread Stefan Behnel
Jaidev Deshpande, 14.11.2011 21:30: I need to perform cubic spline interpolation over a range of points, and I have written the code for the same in C and in Python. The interpolation is part of a bigger project. I want to front end for the project to be Python. Ideally I want Python only to dea

Re: [Tutor] 6 random numbers

2011-10-16 Thread Stefan Behnel
ADRIAN KELLY, 16.10.2011 21:43: anyone know how i would go about printing 6 random numbers print(75, 45, 6, 35, 36472, 632) Numbers were generated by typing randomly on my keyboard. Sorry-for-taking-it-all-too-literally-ly, Stefan ___ Tutor ma

Re: [Tutor] how obsolete is 2.2?

2011-09-07 Thread Stefan Behnel
Hi, please don't repost your question before waiting at least a little for an answer. c smith, 08.09.2011 05:26: I found a book at the local library that covers python but it's 2.2. That's way old then. It won't teach you anything about the really interesting and helpful things in Python,

Re: [Tutor] gzip

2011-08-08 Thread Stefan Behnel
questions anon, 08.08.2011 01:57: Thank you, I didn't realise that was all I needed. Moving on to the next problem: I would like to loop through a number of directories and decompress each *.gz file and leave them in the same folder but the code I have written only seems to focus on the last fold

Re: [Tutor] Mainloop conflict

2011-07-30 Thread Stefan Behnel
Christopher King, 31.07.2011 04:30: I think I'll go with threading. I've become more familiar with it. That's ok. When used carefully, threads can be pretty helpful to gain concurrency in I/O tasks. But just in case you ever feel like using them for anything else, this is worth a read: ht

Re: [Tutor] Mainloop conflict

2011-07-29 Thread Stefan Behnel
Christopher King, 29.07.2011 17:08: On Thursday, July 28, 2011, Dave Angel wrote: On 07/28/2011 08:32 PM, Christopher King wrote: Dear Tutor Dudes, I have a socket Gui program. The only problem is that socket.recv waits for a response, which totally screws Tkinter I think. I tried makin

Re: [Tutor] Mainloop conflict

2011-07-28 Thread Stefan Behnel
Christopher King, 29.07.2011 02:32: I have a socket Gui program. The only problem is that socket.recv waits for a response, which totally screws Tkinter I think. I tried making the timeout extremely small (it was alright if I didn't receive anything, I was excepting that a lot) but I think t

Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request

2011-07-22 Thread Stefan Behnel
Garry Bettle, 22.07.2011 20:18: I'm trying some calls to an wsdl API I've subscribed to. You might find this interesting: http://effbot.org/zone/element-soap.htm But I'm struggling to know what they want when sending an unsignedByte in a request. That's just a number, plain old-fashioned

Re: [Tutor] Question regarding xml.dom.minidom: How do you send an unsignedByte in an wsdl request

2011-07-22 Thread Stefan Behnel
Emile van Sebille, 22.07.2011 20:59: You'll likely get more traction on this at http://mail.python.org/mailman/listinfo/xml-sig Unlikely. Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pytho

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Stefan Behnel
Richard D. Moores, 15.07.2011 23:21: On Sun, Jul 10, 2011 at 05:05, Peter Otten wrote: >>> help(print) shows print(...) print(value, ..., sep=' ', end='\n', file=sys.stdout) Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-l

Re: [Tutor] Cython question

2011-07-02 Thread Stefan Behnel
Alan Gauld, 02.07.2011 15:28: "Albert-Jan Roskam" wrote I used cProfile to find the bottlenecks, the two Python functions getValueChar and getValueNum. These two Python functions simply call two equivalent C functions in a .dll (using ctypes). The code is currently declared as Windows-only and

Re: [Tutor] Cython question

2011-07-02 Thread Stefan Behnel
Albert-Jan Roskam, 02.07.2011 11:49: Some time ago I finished a sav reader for Spss .sav data files (also with the help of some of you!): http://code.activestate.com/recipes/577650-python-reader-for-spss-sav-files/ It works fine, but it is not fast with big files. I am thinking of implementing t

Re: [Tutor] Python Extensions in C

2011-05-26 Thread Stefan Behnel
James Reynolds, 26.05.2011 21:34: On Thu, May 26, 2011 at 3:07 PM, Stefan Behnel wrote: Stefan Behnel, 26.05.2011 18:10: James Reynolds, 26.05.2011 17:22: As an intellectual exercise, I wanted to try my hand at writing some extensions in C. This is fine for en exercise, and I hope you

Re: [Tutor] Python Extensions in C

2011-05-26 Thread Stefan Behnel
Stefan Behnel, 26.05.2011 18:10: James Reynolds, 26.05.2011 17:22: As an intellectual exercise, I wanted to try my hand at writing some extensions in C. This is fine for en exercise, and I hope you had fun doing this. However, for real code, I suggest you use Cython instead. Your module

Re: [Tutor] Python Extensions in C

2011-05-26 Thread Stefan Behnel
Rachel-Mikel ArceJaeger, 26.05.2011 17:46: A couple small things that will help improve memory management Rather than avg = sumall / count; return avg; Just return sumall/count instead. Then you don't have to waste a register or assignment operation. Division is expensive. Avoid it when you can

Re: [Tutor] Python Extensions in C

2011-05-26 Thread Stefan Behnel
James Reynolds, 26.05.2011 17:22: As an intellectual exercise, I wanted to try my hand at writing some extensions in C. This is fine for en exercise, and I hope you had fun doing this. However, for real code, I suggest you use Cython instead. Your module would have been substantially simpler

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-25 Thread Stefan Behnel
Sithembewena Lloyd Dube, 25.05.2011 14:40: Thanks for all your suggestions. I read up on gzip and urllib and also learned in the process that I could use urllib2 as its the latest form of that library. Herewith my solution: I don't know how elegant it is, but it works just fine. def get_contest

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Stefan Behnel
Sithembewena Lloyd Dube, 24.05.2011 11:59: I am trying to parse an XML feed and display the text of each child node without any success. My code in the python shell is as follows: >>> import urllib >>> from xml.etree import ElementTree as ET >>> content = urllib.urlopen(' http://xml.matchbook.c

Re: [Tutor] Problem with printing Python output to HTML Correctly

2011-05-10 Thread Stefan Behnel
Spyros Charonis, 10.05.2011 19:14: On Tue, May 10, 2011 at 5:11 PM, Spyros Charonis wrote: I know I posted the exact same topic a few hours ago and I do apologize for this, but my script had a careless error, and my real issue is somewhat different. I would have preferred an update to the init

Re: [Tutor] Jokes on Python Language

2011-04-21 Thread Stefan Behnel
Ratna Banjara, 21.04.2011 13:49: Does anybody knows jokes related to Python Language? If the answer is yes, please do share it... http://www.python.org/doc/humor/ Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

Re: [Tutor] how to optimize this code?

2011-03-27 Thread Stefan Behnel
Albert-Jan Roskam, 27.03.2011 21:57: I made a program that reads spss data files. I ran cProfile to see if I can optimize things (see #1 below). First thing to note here: sort the output by "time", which refers to the "tottime" column. That will make it more obvious where most time is really

Re: [Tutor] Efficiency of while versus (x)range

2011-03-17 Thread Stefan Behnel
Shane O'Connor, 17.03.2011 01:32: In particular, I'm using Python 2.4.3 on a web server which needs to run as fast as possible using as little memory as possible (no surprises there!). Note that a web application involves many things outside of your own code that seriously impact the performan

Re: [Tutor] BLAS Implementation on Python

2011-03-08 Thread Stefan Behnel
Alan Gauld, 08.03.2011 09:51: "Knacktus" wrote He doesn't have to write it, as it is very obvious, that no Python code on earth (even written by Guido himself ;-)) stands a chance compared to Fortran or C. Look at this: There is one big proviso. The C or Fortran needs to be well written in th

Re: [Tutor] BLAS Implementation on Python

2011-03-07 Thread Stefan Behnel
Knacktus, 07.03.2011 14:28: Am 07.03.2011 01:50, schrieb Mahesh Narayanamurthi: Hello, I am thinking of implementing a BLAS package in pure python. I am wondering if this is a good idea. My design goals are: [2] Targetted to run on Python3 Good idea. NumPy and SciPy will be (are already?)

Re: [Tutor] BLAS Implementation on Python

2011-03-07 Thread Stefan Behnel
Mahesh Narayanamurthi, 07.03.2011 01:50: I am thinking of implementing a BLAS package in pure python. I am wondering if this is a good idea. My design goals are: [1] Efficient manipulation of Matrices and Vectors using pure python objects and python code. [2] Targetted to run on Python

Re: [Tutor] c++ data types in python script

2011-03-06 Thread Stefan Behnel
Arthur Mc Coy, 06.03.2011 09:56: I've used SWIG module to embed python inside c++ app. Given that this deals with an advanced topic (C-level extensions), I find comp.lang.python (python-list), where you also posted this, a more appropriate place for discussion than the Python tutor mailing li

Re: [Tutor] Accessing a DLL from python

2011-03-01 Thread Stefan Behnel
Hanlie Pretorius, 01.03.2011 13:33: Can anyone perhaps suggest the easiest way of translating the C code into Python, bearing in mind that I'm rather a beginner? A beginner of what? Python? Programming in general? The C code you posted doesn't look too complex, so you could try to translate i

Re: [Tutor] Converting .pyd to .so

2011-02-28 Thread Stefan Behnel
j ram, 28.02.2011 18:49: Wine is a good suggestion, but it takes up 3.53 MB. Is there a lighter alternative? So far, you didn't state whether the DLL actually uses Windows calls, but I would imagine it does, and if so, you can't use it on anything but Windows without emulating those calls, thus

Re: [Tutor] Converting .pyd to .so

2011-02-27 Thread Stefan Behnel
fall colors, 28.02.2011 03:25: > Stefan Behnel wrote: Well, there's Wine, a free implementation of Windows for Unix systems. You can either try to load the DLL using Wine and ctypes (I suspect that's the hard way), or just run the Windows Python distribution through Wine and loa

Re: [Tutor] Converting .pyd to .so

2011-02-27 Thread Stefan Behnel
fall colors, 27.02.2011 20:27: I was wondering if it would be possible to convert a .pyd file that works on Windows into a .so file that works on Linux? I gather that it might not be possible to convert the .pyd file if the underlying DLL file was built with Windows API calls (Swig was used to w

Re: [Tutor] Creating xml documents

2011-02-16 Thread Stefan Behnel
allan oware, 16.02.2011 09:20: Alright, Am stuck with xml.dom.minidom Interesting. Why would that be the case? , but is there correct usage for *Node.prettyxml() *resulting in less junky newlines and spaces ? i.e *from* 28.4258363792 -6.13557141177

Re: [Tutor] Creating xml documents

2011-02-15 Thread Stefan Behnel
Karim, 15.02.2011 17:24: On 02/15/2011 02:48 PM, Stefan Behnel wrote: allan oware, 15.02.2011 14:31: Which python modules can one use to create nicely formatted xml documents ? Depends on your exact needs, but xml.etree.ElementTree is usually a good thing to use anyway. If you care about

Re: [Tutor] Creating xml documents

2011-02-15 Thread Stefan Behnel
allan oware, 15.02.2011 14:31: Which python modules can one use to create nicely formatted xml documents ? Depends on your exact needs, but xml.etree.ElementTree is usually a good thing to use anyway. If you care about formatting (a.k.a. pretty printing), look here: http://effbot.org/zone/e

Re: [Tutor] JES Jython

2011-02-07 Thread Stefan Behnel
Eun Koo, 07.02.2011 20:45: Hi I have a problem in JES getting a solution to a function. Is there a way you guys can help? If you can provide enough information for us to understand what your problem is, we may be able to help you. It's a matter of politeness to help us help you. The more wor

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Stefan Behnel
Alex Hall, 28.01.2011 14:25: On 1/28/11, Stefan Behnel wrote: Alex Hall, 28.01.2011 14:09: On 1/28/11, Stefan Behnel wrote: Alex Hall, 27.01.2011 23:23: self.id=root.find("id").text self.name=root.find("name).text There's a findtext() method on Elements for this

Re: [Tutor] small ElementTree problem

2011-01-28 Thread Stefan Behnel
Alex Hall, 28.01.2011 14:09: On 1/28/11, Stefan Behnel wrote: Alex Hall, 27.01.2011 23:23: self.id=root.find("id").text self.name=root.find("name).text There's a findtext() method on Elements for this purpose. I thought that was used to search for the text of an el

Re: [Tutor] small ElementTree problem

2011-01-27 Thread Stefan Behnel
Hi, since you said that you have it working already, here are just a few comments on your code. Alex Hall, 27.01.2011 23:23: all=root.findall("list/result") for i in all: self.mylist.append(Obj().parse(i)) It's uncommon to use "i" for anything but integer loop variables. And 'all' is not

Re: [Tutor] get xml for parsing?

2011-01-26 Thread Stefan Behnel
Alex Hall, 27.01.2011 05:01: How would I go about getting the xml from a website through the site's api? The url does not end in .xml since the xml is generated based on the parameters in the url. For example: https://api.website.com/user/me/count/10?api_key=MY_KEY would return ten results (the c

Re: [Tutor] module to parse XMLish text?

2011-01-14 Thread Stefan Behnel
Wayne Werner, 15.01.2011 03:25: On Fri, Jan 14, 2011 at 4:42 PM, Terry Carroll wrote: On Fri, 14 Jan 2011, Karim wrote: from xml.etree.ElementTree import ElementTree I don't think straight XML parsing will work on this, as it's not valid XML; it just looks XML-like enough to cause confusion.

Re: [Tutor] Refcount in C extensions

2011-01-14 Thread Stefan Behnel
Izz ad-Din Ruhulessin, 14.01.2011 19:49: Thanks for your quick reply and clearing the issue up for me. Using your answer, I rewrote the function to this: double Py_GetAttr_DoubleFromFloat(PyObject *obj, const char *attr) { PyObject *get_attr, *py_float; int has_attr; //Check if the given

Re: [Tutor] Refcount in C extensions

2011-01-14 Thread Stefan Behnel
Izz ad-Din Ruhulessin, 14.01.2011 17:52: I am writing a Python C extension and I have some trouble understanding how reference counting works exactly. Though I think I understand the practice on simple operations (see my question at stackoverflow: http://stackoverflow.com/questions/4657764/py-inc

Re: [Tutor] module to parse XMLish text?

2011-01-14 Thread Stefan Behnel
Terry Carroll, 14.01.2011 03:55: Does anyone know of a module that can parse out text with XML-like tags as in the example below? I emphasize the "-like" in "XML-like". I don't think I can parse this as XML (can I?). Sample text between the dashed lines:: - Blah,

Re: [Tutor] Equality of numbers and Strings

2011-01-10 Thread Stefan Behnel
Karim, 10.01.2011 17:07: I am not a beginner in Python language but I discovered a hidden property of immutable elements as Numbers and Strings. s ='xyz' >>> t = str('xyz') >>> id(s) == id(t) True Thus if I create 2 different instances of string if the string is identical (numerically). I ge

Re: [Tutor] Equality of numbers and Strings

2011-01-10 Thread Stefan Behnel
Emile van Sebille, 10.01.2011 18:42: On 1/10/2011 9:23 AM bob gailer said... On 1/10/2011 11:51 AM, Emile van Sebille wrote: well, not predictably unless you understand the specifics of the implementation you're running under. >>> from string import letters >>> longstring = letters*100 >>> o

Re: [Tutor] scraping and saving in file SOLVED

2010-12-29 Thread Stefan Behnel
Peter Otten, 29.12.2010 13:45: File "/usr/lib/pymodules/python2.6/BeautifulSoup.py", line 430, in encode return self.decode().encode(encoding) Wow, that's evil. Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscrip

Re: [Tutor] Python 2.7.1 interpreter passing function pointer as function argument and Shedskin 0.7

2010-12-28 Thread Stefan Behnel
Frank Chang, 28.12.2010 22:35: Good afternoon. I want to thank everyone who helped me fix the global name 'levinshtein_automata' is not defined error. When I run the Shedskin 0.7 Python to C+++ compiler on the same python program, I receive the error message * Error * automata_test.py

Re: [Tutor] Choice of Python

2010-12-28 Thread Stefan Behnel
Abdulhakim Haliru, 28.12.2010 13:38: I come from a Cakephp, zend framework angle cutting through ASP.net,VB and C# at an intermediate level. [...] Is python really worth the pain or should I just skip it ? Given that you already invested your time into learning all of the above (which basicall

Re: [Tutor] Python C API - Defining New Classes with Multiple Inheritance

2010-12-25 Thread Stefan Behnel
Logan McGrath, 24.12.2010 03:14: Hi, I've just started using the Python C API for version 2.7.1, and I've got a question! How do you define a new type which inherits from multiple types? You can do this for Python classes, but not for C implemented types (which are single inheritance by desig

Re: [Tutor] xml.etree.ElementTree.parse() against a XMLShema file

2010-12-22 Thread Stefan Behnel
Karim, 22.12.2010 22:09: Using lxml (except for the different import) will be fully compliant with the ET code. Do I have to adapt it? There are certain differences. http://codespeak.net/lxml/compatibility.html This page hasn't been changed for ages, but it should still be mostly accurate.

Re: [Tutor] xml.etree.ElementTree.parse() against a XMLShema file

2010-12-22 Thread Stefan Behnel
Karim, 22.12.2010 19:28: On 12/22/2010 07:07 PM, Karim wrote: Is somebody has an example of the way to parse an xml file against a "grammary" file.xsd. I found this: http://www.velocityreviews.com/forums/t695106-re-xml-parsing-with-python.html Stefan is it still true the limitation of etree

Re: [Tutor] Trying to parse a HUGE(1gb) xml file in python

2010-12-22 Thread Stefan Behnel
Walter Prins, 21.12.2010 22:13: On 21 December 2010 17:57, Alan Gauld wrote: "Stefan Behnel" wrote But I don't understand how uncompressing a file before parsing it can be faster than parsing the original uncompressed file? I didn't say "uncompressing a file *bef

Re: [Tutor] Trying to parse a HUGE(1gb) xml file in python

2010-12-21 Thread Stefan Behnel
David Hutto, 21.12.2010 16:11: On Tue, Dec 21, 2010 at 10:03 AM, Stefan Behnel wrote: I meant uncompressing the data *while* parsing it. Just like you have to decode it for parsing, it's just an additional step to decompress it before decoding. Depending on the performance relation betwee

Re: [Tutor] Trying to parse a HUGE(1gb) xml file in python

2010-12-21 Thread Stefan Behnel
Alan Gauld, 21.12.2010 15:11: "Stefan Behnel" wrote And I thought a 1G file was extreme... Do these people stop to think that with XML as much as 80% of their "data" is just description (ie the tags). As I already said, it compresses well. In run-length compressed XML

Re: [Tutor] Trying to parse a HUGE(1gb) xml file in python

2010-12-21 Thread Stefan Behnel
David Hutto, 21.12.2010 13:09: On Tue, Dec 21, 2010 at 6:59 AM, Stefan Behnel wrote: David Hutto, 21.12.2010 12:45: If file a.xml has simple tagged xml like, and file b.config has tags that represent the a.xml(i.e.=) as greater tags, does this pattern optimize the process by limiting the

Re: [Tutor] Trying to parse a HUGE(1gb) xml file in python

2010-12-21 Thread Stefan Behnel
David Hutto, 21.12.2010 12:45: If file a.xml has simple tagged xml like, and file b.config has tags that represent the a.xml(i.e. =) as greater tags, does this pattern optimize the process by limiting the size of the tags to be parsed in the xml, then converting those simpler tags that are found

Re: [Tutor] Trying to parse a HUGE(1gb) xml file in python

2010-12-21 Thread Stefan Behnel
David Hutto, 21.12.2010 12:02: On Tue, Dec 21, 2010 at 5:45 AM, Alan Gauld wrote: 8 bytes to describe an int which could be represented in a single byte in binary (or even in CSV). Well, "CSV" indicates that there's at least one separator character involved, so make that an asymptotic 2 bytes

  1   2   3   >