Re: html tags and python
Hansan wrote: Hi. Yeah I also like just to be able to write in numbers. That is how it works right now. But then I will have to make some code, that validates if the day number is higher than allowed. Like if it is January, the days arnt allowed to be higher than 31. Will one be so kind and explain how I write that code: Just use the datetime module: Python 2.4.1a0 (#2, Mar 1 2005, 15:45:39) [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import date >>> date(2004, 2, 29) datetime.date(2004, 2, 29) >>> date(2005, 2, 29) Traceback (most recent call last): File "", line 1, in ? ValueError: day is out of range for month >>> /patrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Grouping code by indentation - feature or ******?
Giovanni Bajo wrote: Terry Reedy wrote: 3) Sometimes the structure of the algorithm is not the structure of the code as written, people who prefer that the indentation reflects the structure of the algorithm instead of the structure of the code, are forced to indent wrongly. Do you have any simple examples in mind? Yes. When I use PyQt (or similar toolkit), I would like to indent my widget creation code so that one indentiation level means one level down into the widget tree hierarchy: v = VBox(self) # sons of v indented here w = HBox(self) # sons of w here QLabel("hello", w) QLabel("world", w) QButton("ok", v) In fact, I am used to do this very thing in C++, and it helps readability a lot. But in Python it's really easy to use a declarative construct instead, maybe something as simple as a nested list of classes and constructor arguments, and use some simple machinery to build the object graph. This way you avoid having the code and indentation saying different things, like in your example above, where it seems that w is not in fact a child of v. I don't know anything about PyQt though, so if I'm wrong about that I apologise - but the point still stands, since it's confusing to read it. /patrik -- http://mail.python.org/mailman/listinfo/python-list