Re: "Empty" text

2007-07-10 Thread Jan Danielsson
ust by changing content type from text/html to application/xml+xhtml. (Quite a positive surprise, to me) A big "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
when 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
to make the python script load 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

Re: ElementTree -- adding one structure to another?

2007-06-26 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 + 

ElementTree -- adding one structure to another?

2007-06-26 Thread Jan Danielsson
stick elem 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: p & br using ElementTree?

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

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: Current date:2000-01-01 ..using ElementTree? The element kind of needs two text blocks, as far as I can tell? -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman

Re: Output XML buffer?

2007-06-26 Thread Jan Danielsson
XML anyway. Yeah, I 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 lx

Output XML buffer?

2007-06-25 Thread Jan Danielsson
s the case). -- Kind 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
with a "flatter" one). OTOH, I just went to an (Am.) English school my first school year, and language is not one of my fields 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
XML. If you want to make XML 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

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

mod_python & Cookie - unexpected dictionary value

2007-04-13 Thread Jan Danielsson
string containing "blah"? I can get this to work, by doing this: cookies = Cookie.get_cookies(req) 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 di

SimpleXMLRPCServer - revisited

2007-04-03 Thread Jan Danielsson
-- If anyone has any hints 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
Yesterday I found another module which I fell in love with: Python Cryptography Toolkit (http://www.amk.ca/python/writing/pycrypt/). It's just so ... elegant, and functional. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Re: Mastering Python

2007-03-16 Thread Jan Danielsson
form independent? Mostly.. > What > 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 o

mod_python demo

2007-03-14 Thread Jan Danielsson
ely look 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://

Re: Mod python - mysql lock

2007-03-05 Thread Jan Danielsson
a MySQL question. Or even a generic database design question. I would suggest you try asking in a more appropriate forum. -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

doxygen

2007-03-04 Thread Jan Danielsson
stFunction(foo=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

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

2007-02-26 Thread Jan Danielsson
ly if you want to create a set, avoiding the list > creation: > > 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

Preallocate? -- potentially brain dead question about performance

2007-02-26 Thread Jan Danielsson
cond one is more appealing, when I think in terms of risk 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

Graphs, bar charts, etc

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

Return images with matplotlib?

2007-02-04 Thread Jan Danielsson
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
ow could I make full use of an SMP 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 d

Re: Removing outdated files

2007-01-22 Thread Jan Danielsson
o extract week numbers from a date. > > .isocalendar() .thanks() -- Kind regards, Jan Danielsson -- http://mail.python.org/mailman/listinfo/python-list

Removing outdated files

2007-01-22 Thread Jan Danielsson
functions 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 m

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 > lo

UTF8 & HTMLParser

2006-11-30 Thread Jan Danielsson
ption: 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. M

pygresql - bytea

2006-04-26 Thread Jan Danielsson
have a working 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
but redirects its output to its own input, 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 Danie

Re: What are new-style classes?

2005-08-29 Thread Jan Danielsson
ply written a setText() method, but imho properties are neater - but that's just a matter 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
Java does), but what do I need to do to support it, and how does it work? -- Kind Regards, Jan Danielsson Te audire no possum. Musa sapientum fixa est in aure. -- http://mail.python.org/mailman/listinfo/python-list

Re: Escaping certain characters

2005-07-31 Thread Jan Danielsson
tried searching for it, but could only find UTF/Unicode-related information. Is it in the normal python documentation? Semi-Offtopic: The "search" facility in the Python help has stopped functioning for me (I'm using XP on this system). No matter what I search for, I get no resul

Re: Escaping certain characters

2005-07-31 Thread Jan Danielsson
Robert Kern wrote: [---] >> Hmm... On second thought, I need to escape more characters. >> >> Is there no other way to escape characters in strings? > > Which characters? I need to escape '\n', '"', '[' and ']'. I finally went with a few of these: string.replace('\n', '\\n') string.replace('"'

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

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! -- http://mail.python.org/mailman/

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? -- http://mail.pytho

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

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 a

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: http://user.it.uu.se/~jada3673/a

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 "#!/usr/

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 progr

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.

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, but on the download page I see that ther

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 won

Graphs/statistics using wxPython

2005-06-29 Thread Jan Danielsson
Hello all, 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 someone would

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 +

Re: Going crazy...

2005-06-14 Thread Jan Danielsson
Gary Herron wrote: [---] >> I just tried typing the above in Python, and it - obviously - doesn't >> work, so it must be some other syntax. >> >> > Not with tuples, lists or dictionaries. However a more recent addition > to the language is Sets, and they support set differences: > from s

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? I

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

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; // fi

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 tha

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 des

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

"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? -- http://mail.python.org/mailman

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 d

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

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!