Re: string to datetime parser?

2006-01-13 Thread beza1e1
A good solution may be to specify a language to determine the order. The default would be (something like) en-US and thus early October in the example. -- http://mail.python.org/mailman/listinfo/python-list

string to datetime parser?

2006-01-09 Thread beza1e1
Is there a library which can parse strings and output a datetime object? It should be as magical as possible and allow things like: 12:30 tomorrow 10.10.2005 02-28-00 28/03/95 1995-03-28 1996.Feb.29 (Thu) 16:45:23.7 Is there anything like that out there? My Google can't find anything useful ...

Re: Python's website does a great disservice to the language

2005-11-02 Thread beza1e1
Things, which can be done better are: - seperate content and layout (no table design, no font tags, ...) - blue links on blue background are nearly as ugly as visited-purple links on blue background - he frontpage is overloaded. Ok this is worth a discussion: poweruser vs. marketing --

Re: Tricky Areas in Python

2005-10-24 Thread beza1e1
let me try. 1) ''.join(lots_of_pieces) 2) This doesn't even work, if something is removed, the list is too short. So: [x for x in somelist if not isbad(x)] well, list comprehension is Python 2.4 and 2.3 is the standard in many OSes, so it is possibly not the most portable solution I had to look

Re: Syntax across languages

2005-10-23 Thread beza1e1
id(blub) -1210548288 This is not identity in a mathematical view. def identity(x): return x It has is uses. I had some kind of parser and had a dict like this: {case: function, ...} It had to be a dict, because i wanted to dynamically add and remove cases. In some cases nothing had to be done.

Re: Popularity of blogging tools used by python programmers

2005-10-20 Thread beza1e1
polished. btw my blog runs on Python! :D http://beza1e1.tuxen.de -- http://mail.python.org/mailman/listinfo/python-list

Re: Popularity of blogging tools used by python programmers

2005-10-20 Thread beza1e1
Uh, no good style to comment myself, sorry. I just found why i could't see your blog entry. Since i read your message through groups.google.de i just clicked on the link. Your Google Highlight plugin seems to be confused about that: Warning: Unknown modifier '/' in

Re: Python vs Ruby

2005-10-20 Thread beza1e1
Depends on your experience. If you know C,C++,Java and the whole C-syntax-bunch. I'd recommend Python just to learn to adapt a different syntax. If you want to learn for the learnings sake, i'd also recommend Haskell to try functional programming, if you do not already know it. Ruby has some

Changing an AST

2005-10-10 Thread beza1e1
Is it possible compiler.parse a statement, then change and then execute/resolve it? Background: I'm probably to lazy to write my own parser. I have such a statement as string: distance = x**2 + y**2 x and y are undefined, so it is no executable Python code, but it is parseable. Now i'd like

Re: Changing an AST

2005-10-10 Thread beza1e1
Thank you! this compile/exec in context is the thing i wanted. It is not that performant i think. But it should ease the prototyping. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2nd favorite language in Linux Journal poll

2005-10-07 Thread beza1e1
Hm, you didn't include a link and my google did not find the final results. The results are fluctuating very much. This suggests a small number of votes. Linux Journal may be a big magazine, but i don't think language opinions change that fast. The vote is all done by email this year, which is

Re: How to run python scripts with IDLE

2005-10-07 Thread beza1e1
What are you developing for? You could write another small python scripts, which calls your script. os.system(python yours.py --param Ünicöde) -- http://mail.python.org/mailman/listinfo/python-list

bug or feature?

2005-10-05 Thread beza1e1
Coming back from a bug hunt, i am not sure what to think of this python behaviour. Here is a demo program: class A: def __init__(self, lst=[]): self.lst = lst a = A() b = A() b.lst.append(hallo) print a.lst # output: [hallo] The point seems to be, that lst=[] creates a class attribute

Re: bug or feature?

2005-10-05 Thread beza1e1
Thanks for you answer! This copy trick is the most elegant solution i think. -- http://mail.python.org/mailman/listinfo/python-list

Re: What tools are used to write and generate Python Library documentation.

2005-09-27 Thread beza1e1
Do you think of pydoc? Just make comments in your code this way: def add10(x): this function adds ten to the given variable Then save this into add.py and now (in the same directory): pydoc add Voila, your documentation. -- http://mail.python.org/mailman/listinfo/python-list

Re: Best practices for dynamically loading plugins at startup

2005-09-26 Thread beza1e1
I wrote this one: -- def load_plugin(self, plugin, paths): import imp # check if we haven't loaded it already try: return sys.modules[plugin] except KeyError: pass # ok, the load it fp,

Re: Parsing an HTML a tag

2005-09-24 Thread beza1e1
I do not really know, what you want to do. Getting he urls from the a tags of a html file? I think the easiest method would be a regular expression. import urllib, sre html = urllib.urlopen(http://www.google.com;).read() sre.findall('href=([^]+)', html) ['/imghp?hl=detab=wiie=UTF-8',

Re: Parsing an HTML a tag

2005-09-24 Thread beza1e1
I think for a quick hack, this is as good as a parser. A simple parser would miss some cases as well. RE are nearly not extendable though, so your critic is valid. The point is, what George wants to do. A mixture would be possible as well: Getting all a ... by a RE and then extracting the url

Re: Writing a parser the right way?

2005-09-22 Thread beza1e1
Thanks for the hints. I just found NLTK and MontyLingua. And yes, it is just adventure game language. This means every tense except present tense is discarded as not changing world. Furthermore the parser will make a lot of assumptions, which are perhaps 90% right, not perfect: if word[-2:] ==

Writing a parser the right way?

2005-09-21 Thread beza1e1
I'm writing a parser for english language. This is a simple function to identify, what kind of sentence we have. Do you think, this class wrapping is right to represent the result of the function? Further parsing then checks isinstance(text, Declarative). --- class Sentence(str):

Re: Writing a parser the right way?

2005-09-21 Thread beza1e1
Well, a declarative sentence is essentially subject-predicate-object, while a question is predicate-subject-object. This is important in further processing. So perhaps i should code this order into the classes? I need to think a little bit more about this. Thanks for your feed for thought! :) --

Re: Organising a python project

2005-09-21 Thread beza1e1
I don't know about a typical python way, but i'd like to know as well ;) Personally i have a project for my project foo, which has foo/__init__.py# with all the other modules doc/# documentation is always a good idea script/ # everything executable, which later goes into 'bin'

Re: functional or object-oriented?

2005-09-20 Thread beza1e1
This nails it down, yes. :) I probably was too deep into OOP thinking-mode to work pythonic. So i am now rediscovering the python way. Have you read Paul Grahams On Lisp (or was it one of his essays)? He is strongly in favor of functional programming. Mainly because Lisp favors it. He does say

Re: functional or object-oriented?

2005-09-20 Thread beza1e1
I really should take a look at this CLOS, i think ... thanks for the background information. Do you think FP Python is appropriate or just syntactic sugar of a very sophisticated kind? Now i switching back to OO a bit, but the difference between data.value and date['value'] is not really in

functional or object-oriented?

2005-09-19 Thread beza1e1
I see myself shifting more and more over to the functional kind of coding. Could be related to the Haskell, we had to learn in CS. Now i was wondering, how other people use Python? With functional i mean my files mostly consist of functions and only rarely i use class. The library modules seem to

Re: Announce: open 0.2 - a unix application launcherr

2005-09-19 Thread beza1e1
I recently found 'gnome-open', which does this. It chooses the Gnome default for the filetype. Like you clicked on it in nautilus. OS X also has this 'open' command and i like it. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Roguelike programmers needed

2005-09-19 Thread beza1e1
I was hacking on something similar. It could be called a collaborative story-telling adventure game or something. My idea was to parse natural language text not commands. The game manages locations and objects. This is for story-telling roleplay. No stats, levels or monsters (at least no self