Re: Alternatives to XML?

2016-08-26 Thread Roland Koebler
Hi, after reading the mails of this thread, I would recommend one of the following ways: 1. Use a computer-readable format and some small editor for humans. The file-format could then be very simple -- I would recommend JSON. Or some kind of database (e.g. SQLite). For humans, you w

Re: [Bulk] Re: Alternatives to XML?

2016-08-26 Thread Roland Koebler
Hi, > It is *my* XML, and I know that I only use the offending characters inside > attributes, and attributes are the only place where double-quote marks are > allowed. > > So this is my conversion routine - > > lines = string.split('"') # split on attributes > for pos, line in enumerate(lines)

Re: Recommendation for GUI lib?

2016-06-07 Thread Roland Koebler via Python-list
Hi, the two "big" GUI toolkits on Linux are GTK+ and Qt. Both are free, have Python bindings and a graphical GUI designer, and both have ports for Windows and Mac OS X. Qt does have a better cross-platform- support and supports more platforms, but GTK+3 also works for Linux, Mac OS X and Windows.

Re: pyflakes best practices?

2014-06-04 Thread Roland Koebler
Hi, I would recommend to use Pylint (http://www.pylint.org/) in addition to pyflakes. Pylint is much more powerful than pyflakes, and largely configurable. Regards Roland -- https://mail.python.org/mailman/listinfo/python-list

Re: Ideal way to separate GUI and logic?

2013-07-13 Thread Roland Koebler
Hi, > But how then do I separate out the logic and the GUI? I usually write a library (C library, Python module, ...) which contains the logic. Then, I write a GUI (in a separate file), which imports and uses the library. If I need another UI (e.g. GUI with an other toolkit, or a text-based or HT

ANN: template-engine pyratemp 0.3.0/0.2.3

2013-04-23 Thread Roland Koebler
Hi, since there were some questions about template-engines some time ago, I would like to announce: - I updated my comparison and benchmarks of several template-engines on http://www.simple-is-better.org/template/ - I have released a new version of my small and simple but powerful and pythoni

Re: How to set my gui?

2013-04-19 Thread Roland Koebler
Hi, > These days, GUI programming is to me just > programming and calling on certain libraries/modules. +1 > One thing you may want to consider is using your main thread for the > UI, and spinning off another thread to do your search. But do that > ONLY if you know you understand threads, and thr

Re: Encoding NaN in JSON

2013-04-18 Thread Roland Koebler
On Thu, Apr 18, 2013 at 11:46:37AM +1000, Chris Angelico wrote: > Wait... you can do that? It's internal to iterencode, at least in > Python 3.3 and 2.7 that I'm looking at here. In Python 2.6 it wasn't internal to iterencode; in Python 2.7 and 3.x you probably would have to monkey-patch iterencode

Re: Encoding NaN in JSON

2013-04-17 Thread Roland Koebler
Hi, > > yes, there is: subclass+extend the JSON-encoder, see pydoc json. > Please read the original post before answering. What you suggested does not > work since NaN is of float type. ok, right, default does not work this way. But I would still suggest to extend the JSON-encoder, since that is

Re: Encoding NaN in JSON

2013-04-17 Thread Roland Koebler
Hi, > > Easiest way is probably to transform your object before you try to write > Yeah, that's what I ended up doing. Wondered if there's a better way ... yes, there is: subclass+extend the JSON-encoder, see pydoc json. e.g.: class JsonNanEncoder(json.JSONEncoder): def default(self, obj):

Re: I hate you all

2013-04-07 Thread Roland Koebler
Hi, > Well all previous (python 2) code is meant to work for a tab size of > 8. yes, but even in Python 2, mixing spaces and tabs is considered bad style and should be avoided. And code-checkers like pylint (which I can recommend to everyone) create a warning. > You may call this "categorically w

Re: Inserting-embedding some html data at the end of a .py file

2013-03-07 Thread Roland Koebler
Hi, > but now iam receiving this error concering except: > > ni...@superhost.gr [~/www/cgi-bin]# /usr/bin/python3 metrites.py > File "metrites.py", line 88 > except MySQLdb.Error, e: > ^ > SyntaxError: invalid syntax > ni...@superhost.gr [~/www/cgi-bin]# > > which

Re: Inserting-embedding some html data at the end of a .py file

2013-03-06 Thread Roland Koebler
Hi, On Tue, Mar 05, 2013 at 09:39:19AM -0800, Νίκος Γκρ33κ wrote: > But i did, I just tried this: > > # open html template > if htmlpage.endswith('.html'): > f = open( "/home/nikos/public_html/" + htmlpage ) > > htmldata = f.read() > counter

Re: Embedding a for inside an html template for substitution

2013-03-05 Thread Roland Koebler
Hi, On Mon, Mar 04, 2013 at 09:22:38AM -0800, Ferrous Cranus wrote: > can i just put the liens you provided me inside "files.html" and thwy > will work? > > Thats pure pythjon code! There are several template-engines where you more or less include python-code into the template, e.g.: empy, mako,

Re: Can't catch CTRL-C when SimpleXMLRPCServer running ?

2013-02-22 Thread Roland Koebler
Hi, > I would like to stop the script running in response to a CTRL-C. how about "KeyboardInterrupt"? try: ... except KeyboardInterrupt: print "You pressed Ctrl+C" Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a graphical GUI builder?

2013-02-21 Thread Roland Koebler
Hi, > The situation has not substantively changed, but your description of > it is not really accurate. There was and still is a "commercial > license" which allows for completely proprietary development without > needing to allow end users to relink the application against > user-supplied version

Re: Is there a graphical GUI builder?

2013-02-21 Thread Roland Koebler
Hi, > How so? It's LGPL. You can't get much freer than that. you can -- MIT/BSD/public domain etc. provide much more freedom to the developer. (And I prefer freedom for the developer over the guarantee (freedom or restriction -- call it as you wish) that nobody may lock down a copy of the sourceco

Re: Is there a graphical GUI builder?

2013-02-20 Thread Roland Koebler
Hi Phil, > > In Qt Designer (at least in 4.x), the default is a fixed layout, where > > I have to position the widgets at precise pixel-positions and have to > > define the size in pixels. And I cannot remove the default fixed layout > > without modifying the .ui-file in a text editor! > > I'm so

Re: Is there a graphical GUI builder?

2013-02-20 Thread Roland Koebler
Hi, > > [q] In Qt, it's also possible to generate such flexible layouts. But > > it's unfortunately not the default way in Qt, and the Qt designer only > > supports it rudimentarily, and in a much less obvious way. And Qt does > > not have such a "container"-concept, where many widgets (e.g. butto

Re: working with csv module in python

2013-02-20 Thread Roland Koebler
Hi, On Wed, Feb 20, 2013 at 10:50:54AM +0100, inshu chauhan wrote: > I have 10 simple text files with 3 columns x,y,z delimited by "space". I am > trying to combine these 10 files to get a single text file. > > Eg. of data in 10 files is > 299 446 2 Do you only want to concat the files, or do you

Re: Is there a graphical GUI builder?

2013-02-20 Thread Roland Koebler
Hi, > I agree that on Linux GTK is pretty darn slick. I use it for all my > little GUIs. But on Windows, GTK, particularly under python, isn't > quite as easy to get running. installing GTK+ 2.x should be easy, since there are all-in-one-installers for windows on http://www.gtk.org (for GTK+) an

Re: Is there a graphical GUI builder?

2013-02-20 Thread Roland Koebler
Hi, > That way of building a window tends to produce programs that port > badly to other systems. hmm, I don't think so. I've build several applications in C + GTK/Glade and Python + GTK/Glade, which easily run on Linux and Windows without any GUI changes. > playing with Java applets introduced >

Re: Is there a graphical GUI builder?

2013-02-19 Thread Roland Koebler
Hi, > I'm new to Python and only a hobbyist programmer. A long time ago I used > Microsoft's Visual Basic which had a nice (graphical) facility for creating > GUIs which was part of the development environment. I'm wondering if there's > a utility for Python to build GUIs. yes, there are seve

Re: Speed-up for loops

2010-09-02 Thread Roland Koebler
Hi, > Are there any ways to speed up the for/xrange loop? You can use psyco. The following example should be about 4-times as fast as your example: import psyco psyco.full() def f(): imax = 10 a = 0 for i in xrange(imax): a += 10 print a f() regards, Ro

Re: Simple Python Sandbox

2010-08-17 Thread Roland Koebler
On Sat, Aug 14, 2010 at 08:01:00PM -0700, Stephen Hansen wrote: > > As you can see, black listing isn't the best approach here. > > But I have a two pronged strategy: the black list is only half of the > equation. One, I'm blacklisting all the meta functions out of builtins. But blacklists are *ne

Re: Simple Python Sandbox

2010-08-16 Thread Roland Koebler
On Sat, Aug 14, 2010 at 07:54:11PM -0700, Stephen Hansen wrote: > How are you implementing refusing-names-beginning-with-underscore, out > of curiosity? I compile the expressions and look into co_names, e.g.: >>> expr = "0 .__class__" >>> c=compile(expr,"","eval") >>> c.co_names ('__class__

Re: Simple Python Sandbox

2010-08-14 Thread Roland Koebler
On Sun, Aug 15, 2010 at 12:06:35AM +, Steven D'Aprano wrote: > Hmmm... is that meant just as an illustration of a general technique, or > do you actually have something against the class of 0? It's a short illustration; 0 .__class__ itself is harmless, but e.g. 0 .__class__.__base__.__subclass

Re: Simple Python Sandbox

2010-08-14 Thread Roland Koebler
Hi, > I know all this -- but its not relevant really, I think. I'm not trying > to create a safe yet relatively complete or functional Python. All those > efforts to sandbox Python fail because of the incredible dynamic nature > of the language has lots of enticing little holes in it. But I'm not

module metadata variables

2009-09-17 Thread Roland Koebler
Hi, many Python-modules contain metadata-variables, like __author__ etc. But most documentation-tools only support some of these variables, and some tools even define their own metadata-variables. So far, I found: - pydoc (-> pydoc.py): __author__ __credits__ __date__ __version__