Codetags (also Pylint/Pychecker + Variable declarations)
* Codetag PEP: ** I would like to comment on the codetags PEP, which I give a 0+. I think the end "<>" is bad; I would be in favor of a block system or something that looks more like regular Python (e.g. "# :FIXME(line_count=10, date='2005-08-09', ...) "). ** As to the comments that say "Trac does the same functionality" or "Eclipse/Eric/Emacs... has the same functionality" I think codetags are orthogonal to that. Also, some of us still use the old vi to edit a system script in an emergency, and relying on bloated silliness like Eclipse for documenting code seems, well, against all that is good and true. * Pylint: ** I also agree that a lint system is the place to enforce or otherwise use things like codetags. A useful implementation would go a long way to creating a standard organically. * Variable declarations--a synthesis of codetags and lint: ** Perhaps a codetag system is the place to put variable declarations, type checking, and the like. The lint system could grab these and evaluate the code with them without messing with the compiler or quick and dirty code styles. (Inferring properties of code from static listings is for geniuses--not for me--so forgive any unrealistic examples below). As an added benefit, there wouldn't be any non-explicit checking to impede performance (but if you want, you can always add assert's to your heart's content when it really matters, which is rarely). ** Example str_var = '' # :DECLARE(type='string') flt_var = 0 # :DECLARE(type='float') line_index = 0 # :DECLARE(type='int', min=0, max=10) for line_index in range(-10, 10) # "maximum exceeded" warning mispelled_flt_var = 1ine_index / 2.5 # "undeclared variable" warning str_var = var + 1 # "type mismatch" warning Thanks for everyone's patience in reading this--I hope it helps further the Pythonic cause of graceful programming. -- http://mail.python.org/mailman/listinfo/python-list
Web application design question (long)
Hi Pythonist(a/o)s I am interested if anyone can shed any light on a web application problem, both in the specific details (see below) but also in the theory of how to do ad hoc data processing and exploration through a web interface (a tall order, I think). It is apropos of my job, if you hadn't guessed, but the problem (and the solution) might be of more general interest. I am going to describe the problem as well as I can below. Any comments are appreciated, including clarification on the description. Goal: a web app that (1) takes as input a piece of text such as a novel and stores it in a class instance, (2) derives transition probabilities for each word, each two-word string, etc, stores those in a class instance, (3) creates simulated texts by using these transition probabilities, stores simulations in class instances, (4) presents instances of all of the three classes nicely, including histograms or other graphics, tabular counts of words, etc, (5) organizes each instance created in a table-of-contents type layout. Notes on the goal: (1) Each of these phases in the data processing is worth storing and viewing later--hence TOC. (2) The sequence of operations might branch: we might input the text, but then calculate three different transition rate objects, then calculate inumerable simulated texts from each of these. Additionally, we might implement different phases such that you can jump from (2) to (7) without anything between. (3) The design should be flexible enough that if there is a new phase invented, it should be reasonable to add it later without major code surgery, preferably by doing an insert into a database. (4) It would be nice to have a way to deal with the versions of the data objects ("phases" above); e.g. someone inputs texts, I upgrade the software, then there input data is no longer processable--need to do something An "upgrade" method in the object?.. (5) We need to have authentication, so users can only interact with their datasets. (6) The phases can almost be thought of "types" or OO classes, and I will model them as classes. If you were doing this from a command line, the phases would be either intermediate files or processes in a pipeline. (7) It is worth thinking about enforcing sequences of transformations, transformations that take several instances to create a new single instance of something else, and transactioning. (8) We need to keep track and display (somehow) derivations of data, so that if you want to grab all the simulated texts derived from a given transition rate instance you can do that, or if you want to get the upstream processes you can do that too. Notes on ideas for the architecture, etc: (1) My language of choice is Python, including PSP (the mod_python answer to PHP) for interface work, database postgresql, development platform gentoo linux. (2) I am thinking of storing each of the above phases (e.g. word transition stats object) as a Python object, but in a database in order to link it with its owner and the preceding data that generated it (e.g. a stochastic projection would need to be associated with the original rates entered). (3) I imagine an interface that kind of looks like google mail (or any number of other mail programs): the left sidebar contains a list of the various classes; click on a class name, and in the main portion you get a list of instances of those classes (where your email messages would be in gmail) and a list of operations across the top, like delete (where save, archive, etc would be). If you click on an instance in the main list, it would display nicely, including graphs etc; it would also have a list of operations along the top to transform it into other classes. Above all this would be a global command bar, with commands like "logout" etc. Select list of all instances of class 1: | global bar| |*class 1* | operations: on list of instances of class 1| ||-- | class 2| instance 1, class 1 | ||-- | class 3| instance 2, class 1 | ||-- || instance 3, class 1 | Select one instance of class 1: | global bar| | *class 1* | operations: on *instance1* of class 1 | | |--- | class 2 | instance 1, class 1, bunch of stuff | | | would be text,
Re: Web application design question (long)
I must not express myself very clearly. I don't need any help with the disassociated text algorithm. What I need is a framework for data processing web apps, and the disassociated text seems a good example. -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning a value from code string
>From above: I hope the contents of the database are trusted, because if the code is coming from an untrusted source, well, U R pwn3d. Seems like you are jumping through a lot of hoops for very little benefit. What am I missing? Why does anyone care about "why" people do things when they ask a specific technical question on a newsgroup? Maybe op is risking his server (who cares) or maybe he is just trying to explore an idea (again, who cares). It almost seems like bad etiquette, really. It also seems somehow different than asking questions that elicit technical context. Sorry to rant about etiquette. I just have a problem similar to the original poster's, and it pissed me off when I wrote to the newsgroup asking "how do I do x,y,z?" and somebody writes back saying "you really shouldn't want to do x,y,z..." when they really haven't a clue. This exchange has been a lot better than that, probably because of my poor explanation in my question. -- http://mail.python.org/mailman/listinfo/python-list
Cheetah template driven object output? Pythonically?
This may be trivial or stupid or both, but does anyone have a recipe for gracefully using Cheetah to generate a text representation of an object, but embedded in the object (so that it can be pickled, unpickled, and told to display itself)? Here is what I am thinking: import Cheetah.Template as T class Foo: def __init__(self, mystate, cheetah_template='./mytemplate.tmpl'): self.mystate = mystate self._template = T.compile() def set_state(self, newstate): self.mystate = newstate def as_html(self): print self._template(searchlist=) I guess that would work pretty well, though it is untested completely. Has anyone done anything fairly generic and similar? Pitfalls? -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning a value from code string
All the well reasoned responses about asking possibly out of context why questions Well, I won't be so impatient the next time someone misconstrues what I thought was a simple question and lectures me about SQL injection or whatever. Additionally, if I think something might be considered a little nuts, I will add a line to the effect of "This is crazy, I just want to figure out how to do it, you don't need to lecture me about SQL injection". I hadn't considered the viewpoint of those on the newsgroup who faithfully answer questions day in and day out, who are basically volunteering as tutors to the community, and who see the conversations in a very different light than I do. Thanks to them for their time, and I appreciate their (as usual) excellently written responses. -- http://mail.python.org/mailman/listinfo/python-list