Re: A replacement for lambda

2005-07-30 Thread Stefan Rank
on 30.07.2005 10:20 Paolino said the following: > why (x**2 with(x))<(x**3 with(x)) is not taken in consideration? > > If 'with' must be there (and substitue 'lambda:') then at least the > syntax is clear.IMO Ruby syntax is also clear. > I am sorry if this has already been proposed (I am sure i

RE: Pythoncom scripting Windows Media Player & visible

2005-08-02 Thread Stefan Schukat
Hello, you have to put the ocx in a container window (e.g. a dialog or the IE). Without this the media player just acts like a normal COM object. Example for the dialog you can find in [Pythonroot]\Lib\site-packages\pythonwin\pywin\Demos\ocx Bye Stefan

Re: Advanced concurrancy

2005-08-03 Thread Stefan Rank
iting now. So do you plan on including a kind of scheduler-aware blocking communication (like the `channels` of the `tasklets` in stackless)? (as you have a postman already - not a bad idea i think if you compare with multi-agent-systems theory (see jade) - it could be responsible for alerti

Re: Advanced concurrancy

2005-08-04 Thread Stefan Rank
on 04.08.2005 11:15 Matt Hammond said the following: > Hi Stefan, > >>It seems as though all components basically have to do busy waiting now. > > You are right - components are, for the most part, busy-waiting. Which > is not a good thing! > >>So do you plan on

regexps with unicode-aware characterclasses?

2005-08-30 Thread Stefan Rank
Hi all, in a python re pattern, how do I match all unicode uppercase characters (in a unicode string/in a utf-8 string)? I know that there is string.uppercase/.lowercase which are 'locale-aware', but I don't think there is a "all locales" locale. I know that there is a re.U switch that makes \

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-09-01 Thread Stefan Rank
> [snipped alot from others about indexing, slicing problems, > and the inadequacy of -1 as Not Found indicator] on 31.08.2005 16:16 Ron Adam said the following: > The problem with negative index's are that positive index's are zero > based, but negative index's are 1 based. Which leads to a no

Re: Problems with python and threads under Freebsd

2005-02-07 Thread Stefan Schwarzer
ange. If the libmap.conf change doesn't help, you could try to rebuild the base system and kernel and after that the Python port. Also, reading the UPDATING files for the base system and the ports tree may give you a hint. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with `is not None`?

2005-02-09 Thread Stefan Behnel
lled with None. If I want to check for None, I always do it with "is". It's a constant after all... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: probably weird or stupid newbie dictionary question

2005-02-09 Thread Stefan Behnel
red the value 'myvalue' at a location that the hashed key refers to (don't care how that is done) 3) mydict hashes the key 'mykey' and retrieves an integer. It looks at the location that that int refers to and finds the value 'somevalue' that was previously stored there. It returns that value. A bit clearer now? Stefan -- http://mail.python.org/mailman/listinfo/python-list

frozenset() without arguments should return a singleton

2005-02-11 Thread Stefan Behnel
.>>> id(frozenset()),id(frozenset()) (1077581296, 1077581296) .>>> id(frozenset()) 1077581440 .>>> id(frozenset(())) 1077582256 frozenset() called without arguments (or on empty sequences) should always return a singleton object. It is immutable, so I can see no reason why i

frozenset() without arguments should return a singleton

2005-02-11 Thread Stefan Behnel
.>>> id(frozenset()),id(frozenset()) (1077581296, 1077581296) .>>> id(frozenset()) 1077581440 .>>> id(frozenset(())) 1077582256 frozenset() called without arguments (or on empty sequences) should always return a singleton object. It is immutable, so I can't see a reason wh

[PATCH] Re: frozenset() without arguments should return a singleton

2005-02-12 Thread Stefan Behnel
therefore not necessarily worth doing. Up to the maintainers. I don't have any experience in writing extension modules for the standard library and 'running the test suite'. Implementing the check is trivial, though. Could anyone please 'run the test suite' ? I tested i

Re: [PATCH] Re: frozenset() without arguments should return a singleton

2005-02-12 Thread Stefan Behnel
Raymond Hettinger wrote: >Stefan Behnel wrote: I stumbled over the fact that 'frozenset()' doesn't return a constant but creates a new object everytime. Since it is immutable, I wrote to c.l.py that this behaviour is different from what tuple() & Co do. It is not quite co

Re: [PATCH] Re: frozenset() without arguments should return a singleton

2005-02-13 Thread Stefan Behnel
is not very high. Admittedly, the set types are too recent in Python to claim 'major common use cases' that demand optimization. But I generally believe that many programmers will silently expect frozenset() to be (and become) more efficient than set() - in whatever regard: processing, memory, etc. - and use it when they think appropriate. We'll see. Stefan -- http://mail.python.org/mailman/listinfo/python-list

changing __call__ on demand

2005-02-13 Thread Stefan Behnel
ll__(self): self.the_right_method() and then set the_right_method accordingly, but I find that somewhat sub-optimal. Is there a way to change __call__ after class creation? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: changing __call__ on demand

2005-02-13 Thread Stefan Behnel
answer. I didn't know they were class-level methods. Too bad. Guess I'll stick with indirection then. Stefan -- http://mail.python.org/mailman/listinfo/python-list

[PATCH] allow partial replace in string.Template

2005-02-14 Thread Stefan Behnel
to do this. Use type(self)? That doesn't necessarily mean the constructor of that type takes the same arguments... Any comments? Stefan --- Lib/string.py~ 2004-11-01 04:52:43.0 +0100 +++ Lib/string.py 2005-02-14 10:41:41.0 +0100 @@ -145,6 +145,12 @@ r

Re: [PATCH] allow partial replace in string.Template

2005-02-14 Thread Stefan Behnel
ng able to partially evaluate the Template is something that is absolutely missing in the implementation. I consider that a bug that should be fixed for 2.5 at latest. Stefan -- http://mail.python.org/mailman/listinfo/python-list

RE: keeping a COM server alive

2005-02-17 Thread Stefan Schukat
exports COM objects and is started by the operating system or a Python script which you start by hand, registers the class factories and then does not shut down. Stefan > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > [EMAIL PROTE

Re: seeking tree-browser widget for use with Tkinter

2005-03-06 Thread Stefan Eischet
of Parnassus at http://www.vex.net/parnassus/ which I promise to keep # updated. If you can't find it there I can mail it to you. Stefan On 06.03.2005, at 21:02, Sean McIlroy wrote: I'm looking for a widget, to be used with Tkinter, that displays a tree whose leaves are strings. I thought

reversed heapification?

2005-03-07 Thread Stefan Behnel
to replace the "key" option, I do not see an obvious way to have heapq work in a reverse way without making assumptions on the data. Any ideas? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: reversed heapification?

2005-03-07 Thread Stefan Behnel
Kent Johnson schrieb: heapq.nlargest() heapq.nsmallest() ? Python 2.4 only Thanks! Those are *very* well hidden in the documentation. Maybe I already read that page too often... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: reversed heapification?

2005-03-07 Thread Stefan Behnel
me sort bucket). What I'd like to do is heapify and then create an iterator for the result. But since heapify doesn't support "reverse" ... Any other ideas? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: reversed heapification?

2005-03-07 Thread Stefan Behnel
d: def __le__(self, other): return other.s <= self.s I actually looked at the C-implementation of heapq in 2.4 and saw that it even provides distinct implementations for min-heaps and max-heaps. It would be so convinient if both of them became part of the module... Stefan -- http://mail.python.org/mailman/listinfo/python-list

distutils: binary distribution?

2005-03-08 Thread Stefan Waizmann
Hello, I would like the distutils are creating a binary distribution only - means create the distribution file with *.pyc files WITHOUT the *.py files. Any ideas? Or are the distutils the wrong tool for that? "setup.py bdist" creates binary dist, but includes the sourcecode chee

Re: shuffle the lines of a large file

2005-03-10 Thread Stefan Behnel
00))' 1000 loops, best of 3: 308 usec per loop There. Factor 10. That's what I call optimization... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: pyasm 0.2 - dynamic x86 assembler for python

2005-03-10 Thread Stefan Behnel
and build an assembly function that takes the same arguments to make the assembly function directly callable. Maybe the decorator line has to look like this: @pyasm(globals()) or something like that, I can't tell. I don't think it would be much work to implement this. Stefan -- http://mail.python.org/mailman/listinfo/python-list

RE: COM connection point

2005-03-18 Thread Stefan Schukat
Just use obj = win32com.client.Dispatch(obj) Stefan > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Oy Politics > Sent: Wednesday, March 16, 2005 11:51 PM > To: python-list@python.org > Subject: COM connection point

Re: RELEASED Python 2.4 (final)

2004-11-30 Thread Stefan Behnel
erything should work fine. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax for extracting multiple items from a dictionary

2004-11-30 Thread Stefan Behnel
e keys named in cols out of row? In other words, to get this: {"city" : "Hoboken", "state" : "Alaska"} Untested: dict( (key,value) for (key,value) in row.iteritems() if key in cols ) Works in Py2.4 Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.3.5 ?

2004-12-08 Thread Stefan Behnel
Stefan mails! the way you read it doesn't reflect why top-posting is bad: It's me wrote: Not to mention that there are packages out there that doesn't work (yet) with 2.4. Pynum is one such package. -- It's me "Larry Bates" <[EMAIL PROTECTED]> wrote in message

Re: Compiling PIL for Python 2.4

2004-12-13 Thread Stefan Behnel
this topic. In short, submitting a cross-post reads as: you haven't actually thought about your problem but want to bug as many people as possible with it. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: lies about OOP

2004-12-13 Thread Stefan Seefeld
ine-grained, i.e. glyphs can represent individual characters or elements of vector graphics such as paths. That's unlike any conventional 'toolkit' such as Qt, where a 'widget' is quite coarse-grained, and the display of such 'widgets' is typically not that of a structured graphic, but procedural. Regards, Stefan -- http://mail.python.org/mailman/listinfo/python-list

".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

2004-12-16 Thread Stefan Behnel
the beginning of a line. Thank you Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as the default prompt as it messes up the display on mail/news readers that provide "syntax highlighting" for quotes. I wish everyone would write examples that way! On the other hand - three levels of quoting are really rare, maybe it would be easier to change that in the mail readers... ... or in Py3k ? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: looking for wget-like module for getching software

2004-12-16 Thread Stefan Behnel
d. Should work for many source repositories. You can use urllib2 for both querying and download. Stefan -- http://mail.python.org/mailman/listinfo/python-list

exec src in {}, {} strangeness

2005-03-20 Thread Stefan Seefeld
"", line 1, in ? File "", line 2, in ? File "", line 3, in Bar NameError: name 'Foo' is not defined However, when I use the current global and local scope, i.e. simply 'exec f', everything works fine. What am I missing ? Thanks, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: exec src in {}, {} strangeness

2005-03-21 Thread Stefan Seefeld
ject, which is a bit confusing. (Under what circumstances does 'locals()' return not the same object as 'globals()' ?) The problem appears to be that exec f in a, b where a and b are distinct dictionaries, does not look up symbols in 'a' when in local scope. I filed a bug

Re: exec src in {}, {} strangeness

2005-03-21 Thread Stefan Seefeld
Peter Hansen wrote: Stefan Seefeld wrote: Indeed, using 'globals()' and 'locals()' works. However, both report the same underlaying object, which is a bit confusing. (Under what circumstances does 'locals()' return not the same object as 'globals()' ?) W

Re: exec src in {}, {} strangeness

2005-03-21 Thread Stefan Seefeld
Bernhard Herzog wrote: Stefan Seefeld <[EMAIL PROTECTED]> writes: Is there anything wrong with 'exec source in a, b' where a and b are distinc originally empty dictionaries ? Again, my test code was class Foo: pass class Bar: foo = Foo and it appears as if 'Foo'

Heap class for heapq module

2005-03-23 Thread Stefan Behnel
list to get the patch ready for integration. I know, it currently misses documentation and tests, but I'm ready to add them once the patch is actually considered for integration. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: The Running Time of += on Char Strings ?

2005-03-24 Thread Stefan Behnel
f Python and to not rely on the specific performance of a specific implementation. Just use the tool that is made for your task. The information for choosing the right tool can already be found in the documentation. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Which is easier? Translating from C++ or from Java...

2005-03-28 Thread Stefan Seefeld
is much less a matter of ease of parsing but instead how closely programming idioms match between the two languages that are involved. And that obviously also depends on the specific code that needs to be rewritten and the style it is written in (i.e. for example OO vs. templates, etc.). Regard

Re: Stylistic question about inheritance

2005-03-31 Thread Stefan Seefeld
lf, I still prefer to use inheritance even if Python doesn't force me to do it. It's simply a matter of mapping the conceptual model to the actual design/implementation, if ever possible. Regards, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with import "from omniORB import CORBA, PortableServer"

2005-04-11 Thread Stefan Seefeld
look fine. Make sure to either have a binary package for omniORBpy that was compiled for the version of python you are actually using, or alternatively compile it yourself. HTH, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing Module when calling 'Import' _omnipy

2005-04-11 Thread Stefan Seefeld
the library path, not the python path. Thus you will have to add the library path to the PYTHONPATH variable. For details see http://omniorb.sourceforge.net/omnipy2/omniORBpy/omniORBpy001.html#toc2 or the omniORB specific mailing list. HTH, Stefan -- http://mail.python.org/mailman

Re: Missing Module when calling 'Import' _omnipy

2005-04-12 Thread Stefan Seefeld
nd at http://omniorb.sourceforge.net/, and finally ask any unanswered question on the omniORB ML. Sorry, it has been a long while since I last used omniORB. Regards, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: domain specific UI languages

2005-04-13 Thread Stefan Seefeld
xamples of such languages include XUL (mozilla), Javascript, and similar. HTH, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: are DLLs needed to run glade interfaces in python with Windows?

2005-04-13 Thread stefan . eletzhofer
.. IMHO that's actually the _only_ sane way on windows to deploy DLLs. The other option you have is to put them in %SYSTEM32% or whatever environment variable it was on that platform. But once you start to drop DLLs _outside_ your App's install directory, you _can't_ simply move the ins

Re: Python 2.4 killing commercial Windows Python development ?

2005-04-18 Thread Stefan Behnel
spits out a readily baken RPM, ready to be nailed into the system. Sadly, this doesn't exist for Debian and it doesn't work for all Python packages (Twisted, that is). Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: XML-RPC -- send file

2005-04-19 Thread Stefan Behnel
else from the function or make XML-RPC return nothing (don't know if that works). xmlrpclib.Fault: The obvious error. :) Stefan -- http://mail.python.org/mailman/listinfo/python-list

RE: how to pass an array to a VB array via COM

2005-04-27 Thread Stefan Schukat
dim array (1x3) with elements which are also 1-dim arrays. Since the automatic calculation always tries to find the highest dimensionality the Rhino program will get a 2-Dim array which it does not support. In VB you can define the dimension of such a array in Python we must guess. I'm just working on a PySafeArray implementation for PythonCom which should give you also the opportunity to define the dimension via Python. Until then you have no luck. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread Stefan Behnel
mply pass down a list of element names that you append() at the beginning of the function and pop() at the end, i.e. a stack. That list will then always give you the current path from the root node. Alternatively, if you want to use lxml.etree instead of ElementTree, you can use it's iterwal

Re: parsing nested unbounded XML fields with ElementTree

2013-11-26 Thread Stefan Behnel
Larry Martell, 26.11.2013 13:23: > On Tue, Nov 26, 2013 at 2:38 AM, Stefan Behnel wrote: >> larry.martell...@gmail.com, 25.11.2013 23:22: >>> I have an XML file that has an element called "Node". These can be nested >>> to any depth and the depth of the

Re: Optimizing list processing

2013-12-12 Thread Stefan Behnel
Terry Reedy, 12.12.2013 03:26: > from itertools import count > table = sorted(t for t in zip(iterable, count)) This is a useless use of a generator expression. sorted(zip(...)) is enough (and likely to be substantially faster also). Stefan -- https://mail.python.org/mailman/listinfo/

Re: Blog "about python 3"

2014-01-05 Thread Stefan Behnel
their share. Maybe a couple of major projects should start dropping their Py2 support, just to make their own life easier and to help others in taking their decision, too. (And that's me saying that, who maintains two major projects that still have legacy support for Py2.4 ...) Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Porting c extension - PyBuffer_New() deprecated in python3. What's the replacement?

2014-01-11 Thread Stefan Behnel
may take a moment to learn, especially if you are used to doing everything in excessive manual detail in C code, but once you are through that, you should get things done much more quickly than when trying to do them by hand. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: 'Straße' ('Strasse') and Python 2

2014-01-12 Thread Stefan Behnel
ion. > >>> s = "Straße" > >>> assert len(s) == 6 > Traceback (most recent call last): > File "", line 1, in > AssertionError > >>> assert s[5] == "e" > Traceback (most recent call last): > File "", line 1, in > AssertionError The point I think he was trying to make is that Linux is better than Windows, because the latter fails to fail on these assertions for some reason. Stefan :o) -- https://mail.python.org/mailman/listinfo/python-list

Re: Writing SOME class methods in C

2015-11-29 Thread Stefan Behnel
n code. I strongly recommend not to resort to writing real C code here (using the C-API of CPython). It will be slower and will contain more bugs. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Bash-like pipes in Python

2016-03-18 Thread Stefan Otte
satsatsastatbadstssdhhhnbb", set, (sorted, {"reverse": True})) ['t', 's', 'n', 'h', 'd', 'b', 'a'] Cheers, Stefan [0] https://github.com/sotte/pelpe [1] http://elixir-lang.org/getting-started/enumerables-and-

Re: Bash-like pipes in Python

2016-03-19 Thread Stefan Otte
mul) ) `pipe` also allows you to us named arguments which would be difficult if you use operator overloading: pipe("sentaoisrntuwyo", (sorted, {"reverse": True})) Beste Grüße, Stefan On Wed, Mar 16, 2016 at 4:39 PM, Steven D'Aprano wrote: > On Thu, 17 Mar 2016 02:22

Re: XML Patch

2014-10-26 Thread Stefan Behnel
ools, but something which is XML aware. > > I can see several projects on Pypi that can generate some form of xml > diff, but I can't seem to see anything that can also do the patching > side of things. Is there a use case for this? Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: XML Patch

2014-10-27 Thread Stefan Behnel
Hi, please keep this on-list. Nicholas Cole schrieb am 26.10.2014 um 22:43: > On Sun, Oct 26, 2014 at 6:30 PM, Stefan Behnel wrote: >> Nicholas Cole schrieb am 26.10.2014 um 18:00: >>> I'm looking for a python library that can parse XML Documents and >>> create

Re: (-1)**1000

2014-10-29 Thread Stefan Behnel
for unlikely cases may provide a net-loss for the "normal" code. So there are several reasons why an "obvious" optimisation may be a bad idea. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with HTML5 documents

2014-11-20 Thread Stefan Behnel
t; table = etree.SubElement(body, 'table') > > etc etc > > with open('mynewfile.html', 'wb') as f: > doc.write(f, pretty_print=True, method='html') > > (you can leave out the method= option to get xhtml). There's also the E-factory for creating (sub-)trees and a nicely objectish way: http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory and the just released lxml 3.4.1 has an "htmlfile" context manager that allows you to generate HTML incrementally: http://lxml.de/api.html#incremental-xml-generation Obviously, you can combine both, so you can create a subtree in memory and write it into an incrementally built HTML stream. Pretty versatile. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Most gratuitous comments

2014-11-20 Thread Stefan Behnel
e in mind. Whether that purpose is still what the modules are used for or whether they are even still in use at all, is unclear from the above. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with HTML5 documents

2014-11-20 Thread Stefan Behnel
Ian Kelly schrieb am 20.11.2014 um 20:44: > On Thu, Nov 20, 2014 at 12:02 PM, Stefan Behnel wrote: >> There's also the E-factory for creating (sub-)trees and a nicely objectish >> way: >> >> http://lxml.de/lxmlhtml.html#creating-html-with-the-e-factory > > T

Re: Embedded python 'scripting engine' inside Python app

2014-11-23 Thread Stefan Behnel
a bunch of functions you can call" or "here's an object, go and call some methods on it" kind of APIs, there isn't all that much of a difference either. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: jitpy - Library to embed PyPy into CPython

2014-12-07 Thread Stefan Behnel
ose tools at this level is great, so if PyPy becomes yet another way to speed up the critical 5% of a CPython application, that's a good thing. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: xml SAX Parsing in python

2014-12-17 Thread Stefan Behnel
try to do it but i always get None as answerI am using > Window 7 professional and python 2.7 The formatting of your code example was heavily screwed up, please send a plain text email next time. My general advice is to use ElementTree instead of SAX. It's way easier to use (even for simple tasks). Use iterparse() to get event driven incremental parsing. https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.iterparse http://effbot.org/zone/element-iterparse.htm Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: lxml objectify - attribute elements to list.

2015-02-08 Thread Stefan Behnel
p in root.Track.attrib['VenueName']] > --- > AttributeErrorTraceback (most recent call last) > in () > > 1 names = [p.text for p in root.Track.attrib['VenueName']] > > AttributeError: 'str' object has no attribute 'text' As you can see from the output above, "attrib" is a mapping from strings (attribute names) to strings (attribute values). So just use name = root.Track.attrib['VenueName'] or, even simpler: name = root.Track.get('VenueName') Stefan -- https://mail.python.org/mailman/listinfo/python-list

Cython - was: Future of Pypy?

2015-02-23 Thread Stefan Behnel
line, you can use a set comprehension or yield a value back from a generator. So, it's not "half way between Python and C", it actually covers both, almost entirely. (Oh, and also C++, if you feel like it.) Stefan -- https://mail.python.org/mailman/listinfo/python-list

RE: AttributeError: '' object has no attribute 'SeriesCollection'

2014-02-13 Thread Stefan Schukat
Hello, the "chartObj" is not a Chart object it is a shape see >> from win32com.client import Dispatch >>> Excel = Dispatch("Excel.Application") >>> WB = Excel.Workbooks.Add() >>> Shape = WB.Sheets[0].Shapes.AddChart() >>> Shap

Re: insert html into ElementTree without parsing it

2014-03-01 Thread Stefan Behnel
tion? I am open to using > something else (e.g. lxml) if necessary. lxml has a tool to discard potentially unsafe content from HTML files: http://lxml.de/lxmlhtml.html#cleaning-up-html Stefan -- https://mail.python.org/mailman/listinfo/python-list

why indentation should be part of the syntax

2014-03-02 Thread Stefan Behnel
looked: https://www.imperialviolet.org/2014/02/22/applebug.html Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get bytes from bytearray without copying

2014-03-04 Thread Stefan Behnel
Juraj Ivančić, 04.03.2014 16:23: > Just for reference, it is doable in pure Python, with ctypes help For some questionable meaning of "pure". Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: python decimal library dmath.py v0.3 released

2014-03-04 Thread Stefan Krah
l#arbitrary-precision-libraries Stefan Krah -- https://mail.python.org/mailman/listinfo/python-list

Re: How to create an instance of a python class from C++

2014-03-12 Thread Stefan Behnel
int(an.description()) return 0 Clearly substantially simpler than the posted C code (and certainly safer, faster and more correct) - although that doesn't really help me much with understanding what the intention of this code is, looks rather weird... Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: python obfuscate

2014-04-12 Thread Stefan Behnel
uldn't be very telling if you don't have the original source code. Stefan PS: disclaimer: I never needed to obfuscate Python code with Cython, and this use case is definitely not a design goal of the compiler. No warranties, see the license. -- https://mail.python.org/mailman/listinfo/python-list

Recommended exception for objects that can't be pickled

2014-04-21 Thread Stefan Schwarzer
raise PicklingError( /usr/lib64/python3.3/pickle.py:raise PicklingError( /usr/lib64/python3.3/pickle.py:raise PicklingError( /usr/lib64/python3.3/idlelib/rpc.py:except pickle.PicklingError: Which exception would you raise for an object that can't be pickled and why? [1] http://ftputil.sschwarzer.net/trac/ticket/75 [2] https://docs.python.org/3.4/library/pickle.html Best regards, Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
tly for this. Something like this should work: from xml.etree.ElementTree import XMLParser parser = XMLParser() parser.feed(b'') parser.feed(real_input_data) parser.feed(b'') root = parser.close() for subtree in root: ... Stefan -- http

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
ree.html#pull-api-for-non-blocking-parsing It's also supported by recent versions of lxml, which additionally has easy to use support for the sending side with its xmlfile() tool. http://lxml.de/parsing.html#incremental-event-parsing http://lxml.de/api.html#incremental-xml-generation Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
le. Well, there's json.loads(), which is more commonly used for this task. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: parsing multiple root element XML into text

2014-05-09 Thread Stefan Behnel
Burak Arslan, 09.05.2014 18:52: > On 05/09/14 16:55, Stefan Behnel wrote: >> ElementTree has gained a nice API in >> Py3.4 that supports this in a much saner way than SAX, using iterators. >> Basically, you just dump in some data that you received and get back an >> iter

Re: NumPy, SciPy, & Python 3X Installation/compatibility issues

2014-05-10 Thread Stefan Behnel
installer that comes with pretty much all of your scientific processing tools in one package: http://docs.continuum.io/anaconda/ There's a Py3.3 version. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Using threads for audio computing?

2014-05-11 Thread Stefan Behnel
this. > But AFAIK the python GIL (and in smaller or older computers that have only > one core) does not permit true paralell execution of two threads. Not for code that runs in the *interpreter", but it certainly allows I/O and low-level NumPy array processing to happen in parallel, as they do not need the interpreter. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Bug in Decimal??

2014-05-17 Thread Stefan Krah
1007') Otherwise 'partial' has an error that is too large when you pass it to the ln() function. Since decimal mostly follows IEEE 754 with arbitrary precision extensions, it cannot behave differently. Stefan Krah -- https://mail.python.org/mailman/listinfo/python-list

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
u want to implement a SourceLoader: https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader I recommend implementing this in Python code instead of C code, though. Much easier. Cython can help with the integration between both. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 15:00: > On 05/17/2014 01:58 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 02:27: >>> I'm using Python in an embedded situation. In particular I have to load >>> python scripts through a memory interface so regular python module &g

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Hi, please avoid top-posting. Roland Plüss, 17.05.2014 15:49: > On 05/17/2014 03:26 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 15:00: >>> On 05/17/2014 01:58 PM, Stefan Behnel wrote: >>>> Roland Plüss, 17.05.2014 02:27: >>>>> I'm usin

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 17:28: > On 05/17/2014 04:01 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 15:49: >>> On 05/17/2014 03:26 PM, Stefan Behnel wrote: >>>> Roland Plüss, 17.05.2014 15:00: >>>>> On 05/17/2014 01:58 PM, Stefan Behnel

Re: Loading modules from files through C++

2014-05-17 Thread Stefan Behnel
Roland Plüss, 17.05.2014 18:28: > On 05/17/2014 05:49 PM, Stefan Behnel wrote: >> Roland Plüss, 17.05.2014 17:28: >>> On 05/17/2014 04:01 PM, Stefan Behnel wrote: >>>> Roland Plüss, 17.05.2014 15:49: >>>>> On 05/17/2014 03:26 PM, Stefan Behnel

Re: Loading modules from files through C++

2014-05-20 Thread Stefan Behnel
uiltins__", PyEval_GetBuiltins() ); > PyRun_StringFlags( fileContent, Py_file_input, moduleDict, moduleDict, > NULL ); > > Hopefully this works also in Py3 should I switch some time later. But I > guess it should seeing how simple the import now became. The general principle should still w

Re: How keep Python 3 moving forward

2014-05-24 Thread Stefan Behnel
e.com/articles/fog69.html There might still be something that doesn't exist yet, and if you start working on that, going with Py3 is certainly the right way. For everything that's there already, however, reusing working, tested code is way better. And making it work in Py3. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: How keep Python 3 moving forward

2014-05-25 Thread Stefan Behnel
see why you would consider fabric a dependency that keeps you from switching to Py3. In many cases, you can just keep running it in Py2 as you did before. Taking a closer look at the "big list" that caniusepython3 spits out will usually make it shrink to a manageable size. Meaning, the blind size of that list is not an excuse for anything. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Make Python Compilable, convert to Python source to Go

2014-05-25 Thread Stefan Behnel
bookaa bookaa, 25.05.2014 10:17: > I think the significance of Python to Go, is it give us opportunity to > make Python project run fast. You shouldn't make that your only goal, because you'll have a really hard time achieving it (to put it mildly). Stefan -- https://mail.py

Re: Make Python Compilable, convert to Python source to Go

2014-05-26 Thread Stefan Behnel
) slow when compared to something (specific) else. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: how avoid delay while returning from C-python api?

2014-05-28 Thread Stefan Behnel
# external declarations: cdef extern from "someheader.h": void write_this_c(int offset, int size) # your module function: def write_object(int offset, int size): """write some stuff""" print("before call") write_this_c(offset, size) print("after call") That's it. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 is killing Python

2014-05-28 Thread Stefan Behnel
.x to 1.7.x to prevent users from falling into that evil trap. That will also make it clear again which Python is expected to prevail in the long run. Stefan :o) -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 is killing Python

2014-05-31 Thread Stefan Behnel
rtainly a reason for many people to prefer Py3 over Py2. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: PyArg_ParseTuple() when the type could be anything?

2013-08-03 Thread Stefan Behnel
... else: raise ValueError("unknown command") Two comments: 1) you can obviously do the same in C, by writing a bit more code. It would likely be a lot slower, though, and you'd have to take care of error handling etc. 2) you might want to rethink your design as this is a rather unpythonic API. Although it depends on who (or what) you are expecting to use it. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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