Dynamically creating properties?

2011-10-27 Thread Andy Dingley
I have some XML, with a variable and somewhat unknown structure. I'd like to encapsulate this in a Python class and expose the text of the elements within as properties. How can I dynamically generate properties (or methods) and add them to my class? I can easily produce a dictionary of the

Re: SVN access with pysvn under Cygwin (Installation problems)

2008-07-31 Thread Andy Dingley
On 30 Jul, 20:30, Jason Tishler [EMAIL PROTECTED] wrote: You need to build (and install) pysvn under Cygwin.  The pre-built Windows version will not work under Cygwin. Thanks. Presumably this same problem would affect anything that uses a .pyd under Cygwin? --

SVN access with pysvn under Cygwin (Installation problems)

2008-07-30 Thread Andy Dingley
I'm building Python tools to wrap up access to our Subversion / SVN source control system. It's to run on my desktop (Cygwin under Windows XP) and then later under Redhat. Trying to install the pysvn module I'm running into problems getting it to work under Cygwin. Works fine from a Windows

Using doctest with simple text files ?

2007-06-08 Thread Andy Dingley
I have a problem involving lots of simple text files (Java properties files), for which I'm building Python tools to manage their contents. I'm also writing lots of Python modules and using doctest to embed unit tests within them. Maintenance and shhared code ownership is an issue here. What's

Re: Fortran vs Python - Newbie Question

2007-03-26 Thread Andy Dingley
On 26 Mar, 14:20, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: what are the advantages of using Python for creating number crunching apps over Fortran?? If you have to ask, you've not experienced enough Fortran to know its sheer horror. You can write programs in Python that do usefully

Re: Help Required for Choosing Programming Language

2007-02-19 Thread Andy Dingley
On 16 Feb, 21:22, [EMAIL PROTECTED] wrote: I am VB6 programmer and wants to start new programming language Why? What is causing you to do this, and what do you need to achieve by doing it? i want to go through with GUI based programming language like VB.net GUI-based is fairly unimportant as

Re: rot13 in a more Pythonic style?

2007-02-16 Thread Andy Dingley
On 14 Feb, 20:06, Beej [EMAIL PROTECTED] wrote: http://linuxgazette.net/109/pramode.html Thanks, that's a _really_ interesting link (Oh, I need to learn Scheme!) My code now looks like this, which I'm starting to feel much happier about in a functional sense. c_rot = lambda c, chars :

Re: rot13 in a more Pythonic style?

2007-02-15 Thread Andy Dingley
On 14 Feb, 21:59, Paul Rubin http://[EMAIL PROTECTED] wrote: Why don't you describe the actual problem instead of the rot13 analogy. I don't know what the actual problem is! I need to perform a complex mapping between old style structured identifiers and new style structured identifers. As the

Re: rot13 in a more Pythonic style?

2007-02-15 Thread Andy Dingley
On 15 Feb, 17:55, Dennis Lee Bieber [EMAIL PROTECTED] wrote: Sounds more like a case for a parser/lexer wherein the emitted code tokens are the new style identifiers... 8-(I'm trying not to think about that Fortunately I don't think it's _quite_ that bad. --

rot13 in a more Pythonic style?

2007-02-14 Thread Andy Dingley
I'm trying to write rot13, but to do it in a better and more Pythonic style than I'm currrently using. What would you reckon to the following pretty ugly thing? How would you improve it? In particular, I don't like the way a three-way selection is done by nesting two binary selections. Also I

Re: rot13 in a more Pythonic style?

2007-02-14 Thread Andy Dingley
On 14 Feb, 16:23, Neil Cerutti [EMAIL PROTECTED] wrote: str.translate is what I'd do. That's what I hope to do too, but it might not be possible (for the live, complex example). It looks as if I have to make a test, then process the contents of the code differently depending. There might well

Re: How can I access data from MS Access?

2007-02-06 Thread Andy Dingley
On 5 Feb, 19:40, Sells, Fred [EMAIL PROTECTED] wrote: Years ago we used to get our FORTRAN card decks back from the DP center with a piece of scrap paper saysing She No Work. top that. I used to use a cross-compiler (targetting some obscure single-chip hardware) that had just a single error

Re: How can I access data from MS Access?

2007-02-05 Thread Andy Dingley
On 3 Feb, 15:43, [EMAIL PROTECTED] wrote: How to access data from MS Access? Can you access Access from Access ? from Excel / Visual Basic / SQL Query? First of all check that the DSN is working and connects to the back end MDB. This might not be Python's problem. Secondly check whatever

Python tools to manipulate JARs ?

2007-01-31 Thread Andy Dingley
I run build processes for a Java shop using Python (and some Ant). Would anyone care to suggest favoured tools for manipulating the innards of JARs? Or do I just treat them as plain zipfiles and get stuck right in there? Mainly I'm trying to query lists of classes and their embedded versions and

Re: program deployment

2007-01-05 Thread Andy Dingley
king kikapu wrote: Are they embarassed by their code? hehehe...no, just worried about stealing their ideas... Ever heard of Open Source ? I do better by letting other people steal my ideas (and stealing theirs too) than I'd ever do by keeping things secret. --

Re: One module per class, bad idea?

2006-12-12 Thread Andy Dingley
Matias Jansson wrote: I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. Don't confuse packages and files. Java commonly splits a package across many files, Python binds a module to a single file. If you see Java

Re: dict.has_key(x) versus 'x in dict'

2006-12-06 Thread Andy Dingley
Paul Melis wrote: I've always been using the has_key() method to test if a dictionary contains a certain key. Recently I tried the same using 'in', e.g. I've found using the set type to be the quickest way to do many of these tasks. That leads me to another problem: how to cast / convert sets

Re: dict.has_key(x) versus 'x in dict'

2006-12-06 Thread Andy Dingley
Roberto Bonvallet wrote: lstBugsChanged = [ bugId for bugId in setBugsChanged ] In Python 2.4: Hmmm. Thanks. Another reason to twist the admin's arm and get them to upgrade the last 2.3.4 boxen sorted(setBugsChanged) Out of interest, whats the Pythonic way to simply cast

Re: rdf, xmp

2006-12-04 Thread Andy Dingley
Imbaud Pierre wrote: I have to add access to some XMP data to an existing python application. XMP is built on RDF, I'm just looking at the XMP Spec from the Adobe SDK. First impressions only, as I don't have time to read the whole thing in detail. This spec doesn't inspire me with

Re: rdf, xmp

2006-12-02 Thread Andy Dingley
Imbaud Pierre wrote: I have to add access to some XMP data to an existing python application. XMP is built on RDF, RDF is built on XML. RDF is _NOT_ built on top of XML. Thinking that it is causes a lot of trouble in the architecture of big RDF projects. RDF is a data model, not a

Re: Printing Barcodes from webapp?

2006-12-02 Thread Andy Dingley
Burhan wrote: Is there an easy way to generate barcodes using Python Easy way for any application or language to generate barcodes is to install a barcode font on the client machine, then just generate a suitable text string for it. This is _very_ easy, if you can get the font deployed. I

Re: Python v PHP: fair comparison?

2006-11-15 Thread Andy Dingley
walterbyrd wrote: I don't know if this is a fair comparison or not. Who cares? Anything involving PHP is a billion flies can't be wrong type of statement. I agree completely with your observation about PHP's lower cost of access. This is ostensibly a good thing, but it also means that every

Re: HTML Parsing and Indexing

2006-11-13 Thread Andy Dingley
[EMAIL PROTECTED] wrote: I am involved in one project which tends to collect news information published on selected, known web sites inthe format of HTML, RSS, etc I just can't imagine why anyone would still want to do this. With RSS, it's an easy (if not trivial) problem. With HTML

Re: Book about database application development?

2006-10-16 Thread Andy Dingley
Paul Rubin wrote: http://philip.greenspun.com/sql/ There was a time (some time in the mid 90s) when I thought that Philip Greenspun had a Clue. Then I realised just how wrong he was (he started off reasonably right, he just didn't keep up when the world moved on). The highlight of this process

Re: Where is Python in the scheme of things?

2006-10-05 Thread Andy Dingley
gord wrote: As a complete novice in the study of Python, I am asking myself where this language is superior or better suited than others. I use it, and see it primarily, as a Perl killer. It also does for Ruby and our infernal shell scripts. I've never considered using Python instead of VB.

Re: does anybody earn a living programming in python?

2006-09-26 Thread Andy Dingley
walterbyrd wrote: If so, I doubt there are many. I currently earn my living programming in Python. This is particularly amusing given that it's a Java shop and I don't even know Python! I've only been using it for a few months as a replacement for the previous shell scripts and instead of

Re: Looking for a regexp generator based on a set of known string representative of a string set

2006-09-08 Thread Andy Dingley
[EMAIL PROTECTED] wrote: I am looking for python code that takes as input a list of strings [...] and outputs the python regular expression (s1|s2|s3|s4|s5) for strings of s1 etc. Regex compilers are themselves quite good at optimising beyond this --

Re: python vs java

2006-09-06 Thread Andy Dingley
Aravind wrote: some of my friends told that python and java are similar in the idea of platform independency. Similar in goal, but quite different in approach. Python supports lots of platforms and goes to great lengths to offer facades around whatever features a platform does have, so as

Newbie - How to iterate list or scalar ?

2006-08-08 Thread Andy Dingley
I seem to be writing the following fragment an awful lot, and I'm sure it's not the best and Pythonic way to do things. Any advice on better coding style? pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be a list of the same

Re: do people really complain about significant whitespace?

2006-08-08 Thread Andy Dingley
Thomas Guettler wrote: I like python, but sometimes i don't like that python allows spaces and tabs. It would be easier if you had less choice and must use four spaces. That's the nice thing about Python. It doesn't care about indentation distance, it just wants some and consistent. I like

Re: Newbie - How to iterate list or scalar ?

2006-08-08 Thread Andy Dingley
Bruno Desthuilliers wrote: there's really no reason to assume it should be a list - any iterable could - and IMHO should - be accepted... expect of course for strings (royal PITA case, duh). 2/ test for pluginVersionsNeeded.__iter__ (an attribute of most iterables except strings...):

Re: Windows vs. Linux

2006-08-01 Thread Andy Dingley
[EMAIL PROTECTED] wrote: Python and Ubuntu rock...go fot it. That's nice. I've just burned myself a new Ubuntu f*ck-a-duck release CD intending to rebuild a flakey old Deadrat box with it. Once it's done I'd like to be running Python with some USB to Dallas one-wire hardware on it, re-plugged

Re: Windows vs. Linux

2006-07-31 Thread Andy Dingley
[EMAIL PROTECTED] wrote: Is Windows an okay enviornment in which to program under Python, or do you recommend that I run a dual-boot of Linux or maybe a VMWare install to program under Python? Python is one of the best languages I've found for platform-independence - significantly better

Re: range() is not the best way to check range?

2006-07-18 Thread Andy Dingley
[EMAIL PROTECTED] wrote: it seems that range() can be really slow: if i in range (0, 1): RTFM on range() You're completely mis-using it here, using it with an if ... in ... test. The purpose of range() in Python is as loop control, not comparisons! It's not a SQL BETWEEN statement.

Re: list comprehension

2006-06-30 Thread Andy Dingley [EMAIL PROTECTED]
Simon Forman wrote: There's more to it, but that's the basic idea. This much I knew, but _why_ and _when_ would I choose to use list comprehension (for good Python style), rather than using a simple traditional loop ? If I want to generate something that's simply ( [1] + [2] + [3]+... ) then

Re: Python in HTML

2006-06-23 Thread Andy Dingley [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: Python, like it's (evil?) cousin Perl, Isn't that evil cousin Ruby? Perl's the mad old grandmother in the attic, spewing out incomprehensible [EMAIL PROTECTED]% swearing all day. can be used as a CGI. If you don't have one already, go download Apache server to play

[newbie] Iterating a list in reverse ?

2006-06-21 Thread Andy Dingley [EMAIL PROTECTED]
Python newbie: I've got this simple task working (in about ten different ways), but I'm looking for the favoured and most Python like way. Forwards I can do this for t in listOfThings: print t Now how do I do it in reverse? In particular, how might I do it if I only wanted to iterate

Re: Iterating a list in reverse ?

2006-06-21 Thread Andy Dingley [EMAIL PROTECTED]
Fredrik Lundh wrote: for item in reversed(listOfThings): Thanks! I was staring so hard at reverse() that I'd completely missed reversed() I think I prefer this to listOfThings[::-1]: as it's a little more readable. Not that I'm reacting to past bad experience of Perl, you understand 8-) --

Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-19 Thread Andy Dingley
On Fri, 17 Mar 2006 11:22:06 +0100, Timo Stamm [EMAIL PROTECTED] wrote: Xah's posting was properly encoded and will display fine in every decent newsreader. Well mine killfiled it straight off, which I think is entirely proper rendering for one of Xah Lee's kookery lessons. --