Re: Empty text

2007-07-10 Thread Jan Danielsson
Thank you! goes to those who helped me find the source of the problem. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Empty text

2007-07-08 Thread Jan Danielsson
it is not the proper thing to do. Is it possible to force ElementTree to output the XHTML code I need it to? -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

[mostly OT] mod_python doc file system layout

2007-07-04 Thread Jan Danielsson
the images and style sheets.. A solution which I find to be particularly ugly. :-) Any mod_python users out there with any other solutions? -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

ElementTree -- adding one structure to another?

2007-06-27 Thread Jan Danielsson
as a subelement of fooElement. Do I need to traverse the elem tree manually, or is there a way to just 'stick it in there'? -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree -- adding one structure to another?

2007-06-27 Thread Jan Danielsson
Jan Danielsson wrote: If have an element tree representing an XML document, and I load another tree from a file, is there an easy way to stick the second tree into the first one? fooElement = ET.SubElement(...) tree = ET.parse(TEMPLDIR + '/welcome.xml') elem = tree.getroot

Re: Output XML buffer?

2007-06-26 Thread Jan Danielsson
checked the specs, and found a '?' there (but not where I expected it to be). I just checked the first mention of the header, and didn't see it marked as optional. However, I want it to be there, simply because it feels better. I'll check lxml out. -- Kind regards, Jan Danielsson -- http

p br using ElementTree?

2007-06-26 Thread Jan Danielsson
Hello all, This is probably a mind numbingly brain dead question.. But how do I generate the following: pCurrent date:br/2000-01-01/p ..using ElementTree? The p element kind of needs two text blocks, as far as I can tell? -- Kind regards, Jan Danielsson -- http://mail.python.org

Re: p br using ElementTree?

2007-06-26 Thread Jan Danielsson
' In [8]: ET.dump(p) pCurrent date:br /2000-01-01/p That did the trick. Thanks! -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Output XML buffer?

2007-06-25 Thread Jan Danielsson
regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Re: Do other Python GUI toolkits require this?

2007-04-20 Thread Jan Danielsson
of interest. So I'll just shut up and go away. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Re: Standardizing XML

2007-04-15 Thread Jan Danielsson
out of something which isn't XML, you'll probably have to be a little more specific about how this other format works. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

mod_python Cookie - unexpected dictionary value

2007-04-13 Thread Jan Danielsson
) c = str(cookies['sessId']).split('=', 1) ...then use c[1]. Is that the proper way? Seems kind of strange to store the cookies in a dictonary without being able to use the benefits of them? -- Kind regards, Jan Danielsson And now a word from our sponsor

Re: mod_python Cookie - unexpected dictionary value

2007-04-13 Thread Jan Danielsson
Jan Danielsson wrote: [---] Never mind. Cookie objects have a value attribute -- that's what I was doing wrong. -- Kind regards, Jan Danielsson And now a word from our sponsor -- Want to have instant messaging, and chat rooms, and discussion groups for your local

SimpleXMLRPCServer - revisited

2007-04-03 Thread Jan Danielsson
or tips.. Please share them. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

SimpleXMLRPCServer - client address

2007-04-01 Thread Jan Danielsson
Hello all, I writing an application based on the SimpleXMLRPCServer class. I would like to know the IP address of the client performing the RPC. Is that possible, without having to abandon the SimpleXMLRPCServer class? -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman

Modules positive surprises

2007-03-27 Thread Jan Danielsson
fell in love with: Python Cryptography Toolkit (http://www.amk.ca/python/writing/pycrypt/). It's just so ... elegant, and functional. /IMHO -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Re: Mastering Python

2007-03-16 Thread Jan Danielsson
is the best way?And how long would it take before I can develop applications using python? Depends on your learning skills, and what kind of applications we're talking about. -- Kind regards, Jan Danielsson And now a word from our sponsor -- Want to have instant

mod_python demo

2007-03-14 Thread Jan Danielsson
at for ideas). Is there any Python/web community site anywhere which allows users to upload template code for others to use? Note: I am a Python newbie, so there are probably lots of improvements to be done, if anyone cares enough). -- Kind regards, Jan Danielsson -- http://mail.python.org

Re: Mod python - mysql lock

2007-03-05 Thread Jan Danielsson
appropriate forum. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

doxygen

2007-03-04 Thread Jan Danielsson
=None): pass --- ..is not. Is this by design? Is it possible to get doxygen to include standalone functions? -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Preallocate? -- potentially brain dead question about performance

2007-02-26 Thread Jan Danielsson
of memory fragmentation, etc. But since Python is such a high level language, I'm not sure my traditional reasoning applies. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Re: Preallocate? -- potentially brain dead question about performance

2007-02-26 Thread Jan Danielsson
: newlist = set(int(e[0]) for e in mylist) ...completely avoiding the design issue I raised altogether. Thanks! Exactly what I was hoping for! :-) -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Graphs, bar charts, etc

2007-02-06 Thread Jan Danielsson
regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Return images with matplotlib?

2007-02-04 Thread Jan Danielsson
to return the image data, like so: def barchart(req, params): some_format = matplotlib.generate_fancy_graph(params) png_buf = make_png_buffer(some_format) return png_buf Is this possible? If so -- how? -- Kind regards, Jan Danielsson And now a word from our sponsor

Re: Any python scripts to do parallel downloading?

2007-02-01 Thread Jan Danielsson
system?. I would never claim that multithreading is *easier* than singlethreaded. It's mererly a different way of thinking. OTOH, multithreaded does have a steeper learning curve. But once you get past that, there's really not a lot of difference, IMHO. YMMV. -- Kind regards, Jan Danielsson

Removing outdated files

2007-01-22 Thread Jan Danielsson
in Python to extract week numbers from a date. -- Kind regards, Jan Danielsson And now a word from our sponsor -- For a quality usenet news server, try DNEWS, easy to install, fast, efficient and reliable. For home servers or carrier class installations with millions

Re: Removing outdated files

2007-01-22 Thread Jan Danielsson
. .isocalendar() .thanks() -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

UTF8 HTMLParser

2006-11-30 Thread Jan Danielsson
: self.currentName = text However, I would like to convert the text (which is utf8) to latin-1. How do I do that? I've been trying to figure it out for some time now, and I'm just getting frustrated. :-( -- Kind Regards, Jan Danielsson Te audire non possum. Musa sapientum fixa est

Re: UTF8 HTMLParser

2006-11-30 Thread Jan Danielsson
Jan Danielsson wrote: Hello all, I'm writing a python script which fetches a HTML-page (using wget), and then parses the retrieved page using a custom htmllib HTMLParser. The page I fetch is encoded in utf8, and my text-handler currently looks like this: def handle_data(self

pygresql - bytea

2006-04-26 Thread Jan Danielsson
example? A simple insertion, and a simple select is all I'm looking for. -- Kind Regards, Jan Danielsson Te audire non possum. Musa sapientum fixa est in aure. -- http://mail.python.org/mailman/listinfo/python-list

Redirecting stdin/stdout to self

2006-01-23 Thread Jan Danielsson
, and reads it line by line. I would normally have done it like this: $ tcpdump -nelttt pflog0 | mypythonscript.py ...however, the Perl script solution looks interresting.. Is it possible to do something like that in Python? -- Kind Regards, Jan Danielsson Te audire non possum. Musa sapientum fixa

Re: What are new-style classes?

2005-08-29 Thread Jan Danielsson
of opinion. -- Kind Regards, Jan Danielsson Te audire no possum. Musa sapientum fixa est in aure. -- http://mail.python.org/mailman/listinfo/python-list

Documentation

2005-08-10 Thread Jan Danielsson
(self): This method does blah, blah, blah... I'm going to assume that Python has some official tool which can be used to automatically create documentation for a .py-file (like Java does), but what do I need to do to support it, and how does it work? -- Kind Regards, Jan

Re: Escaping certain characters

2005-07-31 Thread Jan Danielsson
Jan Danielsson wrote: In [3]: s.encode('string_escape') Out[3]: 'Hello\\nWorld!' In [4]: Out[3].decode('string_escape') Out[4]: 'Hello\nWorld!' Not *quite* what you asked for, but it ought to be close enough. That'll do just fine. Many thanks! Hmm... On second thought, I need to escape more

Re: Escaping certain characters

2005-07-31 Thread Jan Danielsson
functioning for me (I'm using XP on this system). No matter what I search for, I get no results. A week ago, I got a lot of hits for almost anything I searched for. Anyone seen this behavior, and knows what to do about it? -- Kind Regards, Jan Danielsson Te audire no possum. Musa sapientum fixa est in aure

Escaping certain characters

2005-07-30 Thread Jan Danielsson
Hello, I'd like to encode the string that outputs: Hello World! to 'Hello\x0aWorld!', and the string that outputs: Hello\World! to 'Hello\\World!'. Obviously, I want to be able to reverse the process. I'm going to assume this has already been solved in Python.. But how? --

Re: Escaping certain characters

2005-07-30 Thread Jan Danielsson
Robert Kern wrote: [---] In [3]: s.encode('string_escape') Out[3]: 'Hello\\nWorld!' In [4]: Out[3].decode('string_escape') Out[4]: 'Hello\nWorld!' Not *quite* what you asked for, but it ought to be close enough. That'll do just fine. Many thanks! --

First app, thanks people

2005-07-25 Thread Jan Danielsson
Hello all, I have written my first Python application (apart from small test programs). It's a (distibuted) white board application. I'm going to assume that there already are a thousand of them, written in Python, but just in case someone would find it useful:

Re: First app, thanks people

2005-07-25 Thread Jan Danielsson
Dark Cowherd wrote: [---] In case you are interested in bug report. Always! class LineTool method OnLeftUp needs self.done = True or else if you are in Line mode and you just click with out moving the mouse you get an error. Many thanks; I can't believe I hadn't stumbled across

Re: First app, thanks people

2005-07-25 Thread Jan Danielsson
Will McGugan wrote: [---] You should use the keycode constants. http://www.wxwidgets.org/manuals/2.6.1/wx_keycodes.html#keycodes [---] Excellent! Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Lists pointers

2005-07-23 Thread Jan Danielsson
Hello all, I have written a simple whiteboard application. In my application, I want to be able to set draw attributes. This part works. I have a dictionary object which contains stuff like: self.attr['Pen.Color'] = ... self.attr['Pen.Thickness'] = ... Now, the problem is that I want to be

Data available on socket?

2005-07-22 Thread Jan Danielsson
Hello all, How do I find out if a blocking socket has data available [for reading] on it? I assume I could do something like this: tmp = self.read(1, socket.MSG_PEEK) if len(tmp) 0: # Data available But is there a better way? A call which specifically checks if data is available? --

Stupid question: Making scripts python-scripts

2005-07-21 Thread Jan Danielsson
Hello all, How do I make a python script actually a _python_ in unix:ish environments? I know about adding: #!/bin/sh ..as the first row in a shell script, but when I installed python on a NetBSD system, I didn't get a python executable; only a python2.4 executable. Adding

Question about Python

2005-07-01 Thread Jan Danielsson
Hello all, I recently started using Python, and I must say I like it. Both the language and libraries available for it. Background: I have written an application which I use to keep track of my personal economy. I wrote it in Java because I wanted to learn the language for a course in

Re: Graphs/statistics using wxPython

2005-06-29 Thread Jan Danielsson
Robert Kern wrote: I wanted to plot some statistics, so I wrote a simple wxPython class to do it. Then I realized that I would like to draw bar graphs, so I added that too. Since I'm a complete Python newbie, I haven't done much of it the Python way, I suspect. So, I'm wondering if

Re: Graphs/statistics using wxPython

2005-06-29 Thread Jan Danielsson
Robert Kern wrote: [---] It's okay. Just about every Pythonista in the sciences has, at one time or another, started a plotting library. It's a rite of passage. Welcome to the club. :-) Question: I need to install SciPy in order to use matplotlib, No you don't. Ah.. I misread. I

FAQ: __str__ vs __repr__

2005-06-15 Thread Jan Danielsson
Sorry, but I Just Don't Get It. I did search the 'net, I did read the FAQ, but I'm too dumb to understand. As far as I can gather, __str__ is just a representation of the object. For instance: class ServerConnection: def __str__(self): buf = Server: + self.name + \n buf +=

Going crazy...

2005-06-13 Thread Jan Danielsson
Hello all, I'm 100% sure that I saw an example which looked something like this recently: a=(1, 2, 3, 4, 5, 6) b=(2, 3, 6) a - b (1, 4, 5) The only new language I have been involved in lately is Python. Is my memory failing me, or have I seen such an Python-example somewhere? If so:

A question about time

2005-06-09 Thread Jan Danielsson
Hello all, I have a list of servers which an application connects to. If the connection fails, the application should mark the server as temporarily unavailable, and should try to use the server again after x units of time. In C, I would do this: server.invalidUntil = time(NULL) + 5*60; //

Re: A question about time

2005-06-09 Thread Jan Danielsson
Grant Edwards wrote: In C, I would do this: server.invalidUntil = time(NULL) + 5*60; // five minute delay In Python, I would do this: server.invalidUntil = time.time() + 5*60 # five minute delay Ah. Well. Um. I feel like an idiot. I found datetime by accident, and thought it involves

Creating file of size x

2005-06-06 Thread Jan Danielsson
Hello all, Is there any way to create a file with a specified size? -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating file of size x

2005-06-06 Thread Jan Danielsson
Erik Max Francis wrote: Is there any way to create a file with a specified size? What do you want to put in the file? Once you've answered that question, the solution should present itself. Check blocks from an FEC-encoder (Freenet, more specifically). The problem is that the design

Re: Creating file of size x

2005-06-06 Thread Jan Danielsson
Grant Edwards wrote: Is there any way to create a file with a specified size? What do you want to put in the file? Once you've answered that question, the solution should present itself. Check blocks from an FEC-encoder (Freenet, more specifically). The problem is that the design I'm

Opposite of splitting?

2005-06-05 Thread Jan Danielsson
Hello all, I have a list of integers: q = [ 1, 2, 4, 7, 9 ] which I would like to convert to a string: 1,2,4,7,9 This is *very* easy to do with a simple while loop.. But I suspect that there is a more elegant way to do it in Python. Is there? If so: How? --

Newbie question: Allocation vs references

2005-06-02 Thread Jan Danielsson
Hello all, Behold: -- a = [ 'Foo', 'Bar' ] b = [ 'Boo', 'Far' ] q = [ a, b ] print q[0][0] print q[1][1] a[0] = 'Snoo' b[1] = 'Gnuu' print q[0][0] print q[1][1] -- This will output: Foo Far Snoo Gnuu I assume it does so because q stores _references_ to a and b. How would

Question about mutexes

2005-06-01 Thread Jan Danielsson
In OS/2 C, I would do this: main() { ... DosCreateMutexSem(NULL, hmtx, 0UL, FALSE); ... } thread() { ... DosRequestMutexSem(hmtx); Locked! DosReleaseMutexSem(hmtx); ... } How would I go about doing that in Python? I figured this part out: lockobj = mutex() lockobj.lock(foo, bar) Locked!

Re: Question about mutexes

2005-06-01 Thread Jan Danielsson
Reinhold Birkenfeld wrote: [---] How would I go about doing that in Python? I think you will want to create a threading.Lock object. It would seem so. Thanks for the tip! -- http://mail.python.org/mailman/listinfo/python-list