Re: Any python HTML generator libs?

2006-03-09 Thread Stephen D Evans
Jarek Zgoda wrote: > I use HTMLTemplate + ElementTree combo to generate static HTML documents > from data in XML files. Other way might be using "object oriented XSL", > as ll-xist is often advertized. HTMLTemplate + ElementTree works for me too. Additionally I use CSS (Cascading Style Sheets) to

Re: implementation of "complex" type

2006-03-09 Thread Steven D'Aprano
On Thu, 09 Mar 2006 09:20:17 -0800, Russ wrote: > "Why don't you show us your complex class?" > > Because I don't have a complex class. I merely used the complex class > as an example to test the referencing behavior. Please read more > carefully next time. Or why don't you explain yourself more

Re: A better RE?

2006-03-09 Thread Schüle Daniel
Magnus Lycka wrote: > I want an re that matches strings like "21MAR06 31APR06 1236", > where the last part is day numbers (1-7), i.e it can contain > the numbers 1-7, in order, only one of each, and at least one > digit. I want it as three groups. I was thinking of > > r"(\d\d[A-Z]\d\d) (\d\d[A-Z]

Re: creating an executable?

2006-03-09 Thread [EMAIL PROTECTED]
>Can I make an executable with just the standard distribution, or do I >need a separate module? Check out py2exe: http://www.py2exe.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: implementation of "complex" type

2006-03-09 Thread Russ
Thanks for the links, especially for the pure Python implementation. That provides a good model for similar classes. I am just wondering why your implementation of complex numbers does not have "assignment operators" such as "__iadd", etc. By the way, I suppose my original post (where I wrote, "

Re: Any python HTML generator libs?

2006-03-09 Thread Michael
> HTMLTemplate + ElementTree works for me too. Additionally I use CSS > (Cascading Style Sheets) to add style (e.g. fonts, colors and spacing). The > CSS also allows for different styles for display/print (e.g. not printing > menus). If you want to see artistic CSS google for "css Zen Garden" . >

ANN: Config module v0.3.6 released.

2006-03-09 Thread Vinay Sajip
A new version of the Python config module has been released. What Does It Do? The config module allows you to implement a hierarchical configuration scheme with support for mappings and sequences, cross-references between one part of the configuration and another, the ability to f

Re: advice on this little script

2006-03-09 Thread Terry Reedy
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ben Cartwright wrote: >> BartlebyScrivener wrote: >>> What about a console beep? How do you add that? >>> >>> rpd >> >> Just use ASCII code 007 (BEL/BEEP): >> >> >>> import sys >> >>> sys.stdout.write('\007') >> >> O

Re: linux clipboard?

2006-03-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, david.humpherys wrote: > how can i copy text to the linux clipboard? > > I've seen a number of posts explain how to do it with tk > is this the only way? > > (i'm not using tk as my gui tool kit.) So what are you using instead? Ciao, Marc 'BlackJack' Rintsch

Help with a reverse dictionary lookup

2006-03-09 Thread rh0dium
Hi all, I have a dict which looks like this.. dict={'130nm': {'umc': ['1p6m_1.2-3.3_fsg_ms']}, '180nm': {'chartered': ['2p6m_1.8-3.3_sal_ms'], 'tsmc': ['1p6m_1.8-3.3_sal_log', '1p6m_1.8-3.3_sal_ms']}, '250nm': {'umc': ['2p6m_1.8-3.3_sal_ms'], 'tsmc': ['1p6m_2.2-3.5_sal_log', '1p6m_1.8-3.3_sal_ms'

About printing in IDLE?

2006-03-09 Thread Dr. Pastor
Installed Python 2.4.2 on Windows XP. Activated IDLE. Loaded the following to the Edit window: --- print "hello world" for i in range(10): print i, print "Done" --- It prints as: 0 1 2 3 4 5 6 7 8 9 Done Should not Done be printed on a new line alone? Thanks for any guidance. -- http://

Re: About IDLE?

2006-03-09 Thread Dr. Pastor
Any reply? Dr. Pastor wrote: > Installed Python 2.4.2 on Windows XP. > Activated IDLE. > Loaded the following into the Edit window: > --- > # dates are easily constructed and formatted (Tutorial 10.8) > > from datetime import date > now = date.today() > now > > now.strftime("%m-%d-%y. %d %b %Y i

Re: why no block comments in Python?

2006-03-09 Thread Terry Hancock
On 9 Mar 2006 07:21:00 -0800 "msoulier" <[EMAIL PROTECTED]> wrote: > > (and if you don't, you can quickly comment out regions > > by putting them inside a triple-quoted string.) > > Although that will use up memory, as opposed to a comment. Not really. Unless it is the first string in the block (

Re: Python Evangelism

2006-03-09 Thread Terry Hancock
On Thu, 09 Mar 2006 20:21:59 +0100 Magnus Lycka <[EMAIL PROTECTED]> wrote: > It's not too late to rename the cheese shop though. > (We don't need even more stink...) I love cheese, so no problem on that score. But the problem is, if you actually know where "Python" comes from, you are likely to su

Re: About printing in IDLE?

2006-03-09 Thread Dustan
Dr. Pastor wrote: > Installed Python 2.4.2 on Windows XP. > Activated IDLE. > Loaded the following to the Edit window: > --- > print "hello world" > for i in range(10): > print i, > > print "Done" > --- > It prints as: 0 1 2 3 4 5 6 7 8 9 Done > Should not Done be printed on a new line al

Re: Hashtables in pyhton ...

2006-03-09 Thread Xavier Morel
Konrad Mühler wrote: > Hi, > > are there predefinded chances to use hashtables in python? How can I use > Hashtable in python? Or do I have to implement this on my own? > > Thanks A Java Hashtable/Hashmap is equivalent to a Python dictionary, which is a builtin objects (and not a second-class c

Re: Python Evangelism

2006-03-09 Thread Andrew Gwozdziewycz
> I agree that names are very important -- Java would never have caught > on the way that it did if Sun had left the name as "Oak". I think > you're wrong about the name "Python", though. Snakes are cool and > have street cred. That's why there are cars with names like "Cobra" > and "Viper". > >

Re: First script, please comment and advise

2006-03-09 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: >> nested and hided inside a class. > > Hidden, sorry :-) > > >> Can a "sub-function" be called directly from outside the defining function? No, and each call to scramble_text defines a new function "scramble". Further, there is no way to unit test "scramble". --Scott D

Re: Python Evangelism

2006-03-09 Thread UrsusMaximus
Python is a friendly name, like Mickey Mouse. If you saw a real mouse (or worse, a rat), you wouldn't likely fall in love with it; but Mickey is about as good a marketing icon as any in history. Python also has staying power. Snakes may be scary and even dangerous, but they get respect; think abou

RE: About printing in IDLE?

2006-03-09 Thread Kelly Vincent
>Installed Python 2.4.2 on Windows XP. >Activated IDLE. >Loaded the following to the Edit window: >--- >print "hello world" >for i in range(10): > print i, > >print "Done" >--- >It prints as: 0 1 2 3 4 5 6 7 8 9 Done >Should not Done be printed on a new line alone? >Thanks for any guidance

Best way to have a for-loop index?

2006-03-09 Thread andrewfelch
I write a lot of code that looks like this: for myElement, elementIndex in zip( elementList, range(len(elementList))): print "myElement ", myElement, " at index: ",elementIndex My question is, is there a better, cleaner, or easier way to get at the element in a list AND the index of a loop t

Re: About IDLE?

2006-03-09 Thread Nick Smallbone
Dr. Pastor wrote: > Any reply? > ahem. three replies, when i counted: http://groups.google.com/group/comp.lang.python/browse_frm/thread/ab0c8455251e616c/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to have a for-loop index?

2006-03-09 Thread Michael Spencer
[EMAIL PROTECTED] wrote: > I write a lot of code that looks like this: > > for myElement, elementIndex in zip( elementList, > range(len(elementList))): > print "myElement ", myElement, " at index: ",elementIndex > > > My question is, is there a better, cleaner, or easier way to get at the >

Re: Best way to have a for-loop index?

2006-03-09 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > I write a lot of code that looks like this: > > for myElement, elementIndex in zip( elementList, > range(len(elementList))): > print "myElement ", myElement, " at index: ",elementIndex > > > My question is, is there a better, cleaner, or easier way to get at the >

Re: Python Evangelism

2006-03-09 Thread John Pote
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] This thread was great entertainment at the end of today reading down the screen with a beer going down on the side. Here's my penny's worth: Over this side of the pond the good old British Post Office changed its name

Re: Help with a reverse dictionary lookup

2006-03-09 Thread John McMonagle
On Thu, 2006-03-09 at 15:51 -0800, rh0dium wrote: > Hi all, > > I have a dict which looks like this.. > > dict={'130nm': {'umc': ['1p6m_1.2-3.3_fsg_ms']}, > '180nm': {'chartered': ['2p6m_1.8-3.3_sal_ms'], 'tsmc': > ['1p6m_1.8-3.3_sal_log', '1p6m_1.8-3.3_sal_ms']}, > '250nm': {'umc': ['2p6m_1.8-3.

output formatting for classes

2006-03-09 Thread Russ
I'd like to get output formatting for my own classes that mimics the built-in output formatting. For example, >>> x = 4.54 >>> print "%4.2f" % x 4.54 In other words, if I substitute a class instance for "x" above, I'd like to make the format string apply to an element or elements of the instance.

Re: Help with a reverse dictionary lookup

2006-03-09 Thread Lonnie Princehouse
Here's the illegible gibberish version of your function. Once you understand completely the following line of code, you will be well on your way to Python nirvana: getNodes = lambda Foundry=None,Process=None: [node for node,foundries in dict.iteritems() if ((Foundry is None) and ((Process is None

Re: output formatting for classes

2006-03-09 Thread Schüle Daniel
Russ wrote: > I'd like to get output formatting for my own classes that mimics the > built-in output formatting. For example, > > x = 4.54 print "%4.2f" % x > > 4.54 > > In other words, if I substitute a class instance for "x" above, I'd > like to make the format string apply to an elem

Re: Help with a reverse dictionary lookup

2006-03-09 Thread rh0dium
Thanks!! I got all of this. The problem that I was trying to figure out was this. Basically there are multiple combinatories here - I was hoping someone could point me to a general approach. Writing the actual funtion is not necessary - as you pointed out I can certainly do that. Here is my pr

Re: Best way to have a for-loop index?

2006-03-09 Thread Roy Smith
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > I write a lot of code that looks like this: > > for myElement, elementIndex in zip( elementList, > range(len(elementList))): > print "myElement ", myElement, " at index: ",elementIndex > > > My question is, is there a better, clean

Re: question about slicing with a step length

2006-03-09 Thread Terry Reedy
"André" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Terry Reedy wrote: >> It appears that s[i:j:-1] is s[(j+1):(i+1)] .reverse()'ed. For >> 'numbers', >> this is 10, 9, 8, 7, 6, 5, 4, 3, 2]. Then take every other item. Why >> the >> +1? Don't know and not my intuitive expe

ANN: pyregex 0.5 - command line tools for Python's regular expression

2006-03-09 Thread [EMAIL PROTECTED]
pyregex is a command line tools for constructing and testing Python's regular expression. Features includes text highlighting, detail break down of match groups, substitution and a syntax quick reference. It is released in the public domain. Screenshot and download from http://tungwaiyip.info/soft

Re: Help with a reverse dictionary lookup

2006-03-09 Thread rh0dium
Hey thanks - OK how would you arrange the data structure? I think that is my problem - I can arrange in any order - I just want something which makes sense - this "seemed" logical but can you point me in a better method.. Basically I am parsing a directory structure: TECHROOT/ 130nm/ ts

Re: About printing in IDLE?

2006-03-09 Thread Dr. Pastor
Many thanks to you all. -- http://mail.python.org/mailman/listinfo/python-list

Re: creating an executable?

2006-03-09 Thread John Salerno
[EMAIL PROTECTED] wrote: >> Can I make an executable with just the standard distribution, or do I >> need a separate module? > > Check out py2exe: http://www.py2exe.org/ > Thanks. Been meaning to look into that one anyway, now I get a chance. :) -- http://mail.python.org/mailman/listinfo/python

Re: About IDLE?

2006-03-09 Thread Dr. Pastor
Thank you! I can see only your reply. But indeed google prints three. The mind boggles. Nick Smallbone wrote: > Dr. Pastor wrote: > >>Any reply? >> > > > ahem. three replies, when i counted: > http://groups.google.com/group/comp.lang.python/browse_frm/thread/ab0c8455251e616c/ > -- http://ma

Re: Help with a reverse dictionary lookup

2006-03-09 Thread Lonnie Princehouse
The parsing is good; the structure can be transformed after the parsing is done. The basic problem with the "reverse lookup" search is that you need to iterate over lots of things. If you're only doing one search, that's not too horrible But if you're going to perform multiple searches, you can

BECOME A DOT.COM MILLIONAIRE WITH ONLY $5.99Cents or $1K.

2006-03-09 Thread ISRAEL FAGBEMI
BECOME A DOT.COM MILLIONAIREInvest $1,000. Get back up to $3,000 a day ,$100,000 monthly. for 1 year. Silent Partners. Do no work.www.vosar.net416-903-5685775-333-1125[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Why property works only for objects?

2006-03-09 Thread Michal Kwiatkowski
Hi, Code below shows that property() works only if you use it within a class. class A(object): pass a = A() a.y = 7 def method_get(self): return self.y a.x = property(method_get) print a.x # => A.x = property(method_get) print a.x # =>

Re: Password entering system

2006-03-09 Thread Paul Rubin
"Tuvas" <[EMAIL PROTECTED]> writes: > I want to write a GUI program (Preferably in Tkinter) that will allow > for the entering of passwords, stared out like a normal program does. > Is that possible? Thanks! http://blogs.translucentcode.org/oisin/2003/09/04/tkinter_password_entry/ -- http://mail.

Re: About IDLE?

2006-03-09 Thread Terry Reedy
"Dr. Pastor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Installed Python 2.4.2 on Windows XP. > Activated IDLE. > Loaded the following into the Edit window: > Why I do not get any output? > Thanks for any guidance. When you run code from an edit window, IDLE saves the file to

Re: Password entering system

2006-03-09 Thread Tuvas
Thanks, that's exactly what I wanted! -- http://mail.python.org/mailman/listinfo/python-list

Re: Why property works only for objects?

2006-03-09 Thread Steven Bethard
Michal Kwiatkowski wrote: > Code below shows that property() works only if you use it within a class. Yes, descriptors are only applied at the class level (that is, only class objects call the __get__ methods). > Is there any method of making descriptors on per-object basis? I'm still not convi

Re: About printing in IDLE?

2006-03-09 Thread Terry Reedy
"Dr. Pastor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Installed Python 2.4.2 on Windows XP. > Activated IDLE. > Loaded the following to the Edit window: > --- > print "hello world" > for i in range(10): > print i, > > print "Done" > --- > It prints as: 0 1 2 3 4 5 6 7

urlerror, urllib2: "no address" ... why or debug tips?

2006-03-09 Thread joemynz
Help please with a URLError. Invoking a url that works in Firefox and IE results in a "urlerror 7, no address ..." in python. I need to debug why. Traceback is below. There's a redirect when the url is invoked (it's part of a chain) - you can see it using liveheaders in firefox. What is the best w

Re: Password entering system

2006-03-09 Thread John McMonagle
On Thu, 2006-03-09 at 19:42 -0800, Tuvas wrote: > Thanks, that's exactly what I wanted! > > -- > http://mail.python.org/mailman/listinfo/python-list > You may also want to check out Pmw (Python Megawidgets) Pmw has a nifty Prompt Dialog. See http://pmw.sourceforge.net/doc/PromptDialog.html

Re: Help with a reverse dictionary lookup

2006-03-09 Thread Lonnie Princehouse
I made a logic error in that. Must be tired :-( Alas, there is no undo on usenet. -- http://mail.python.org/mailman/listinfo/python-list

Re: embedding Python: how to avoid memory leaks?

2006-03-09 Thread Andrew Trevorrow
Torsten Bronger <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Andrew Trevorrow) writes: > > > [...] > > > > I couldn't get the PyRun_*File* calls to work on Windows, presumably > > because of the FILE* problem mentioned in the docs. > > Which compiler do you use? MSVC++ (version 6 from memory

Re: Why property works only for objects?

2006-03-09 Thread Michal Kwiatkowski
Steven Bethard napisał(a): >> Is there any method of making descriptors on per-object basis? > > I'm still not convinced that you actually want to, but you can write > your own descriptor to dispatch to the instance object (instead of the > type): Ok, this works for attributes I know a name of at

counting number of (overlapping) occurances

2006-03-09 Thread John
I have two strings S1 and S2. I want to know how many times S2 occurs inside S1. For instance if S1 = "" and S2 = "AA" then the count is 3. Is there an easy way to do this in python? I was trying to use the "count" function but it does not do overlapping counts it seems. Thanks, --j -- ht

Re: embedding Python: how to avoid memory leaks?

2006-03-09 Thread Torsten Bronger
Hallöchen! [EMAIL PROTECTED] (Andrew Trevorrow) writes: > Torsten Bronger <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] (Andrew Trevorrow) writes: >> >>> [...] >>> >>> I couldn't get the PyRun_*File* calls to work on Windows, >>> presumably because of the FILE* problem mentioned in the docs.

Re: embedding Python: how to avoid memory leaks?

2006-03-09 Thread Andrew Trevorrow
[EMAIL PROTECTED] wrote: > I could reproduce a memory leak with the code > > #include > int main() > { > while(1){ > Py_Initialize(); > PyRun_SimpleString("execfile('foo.py')"); > Py_Finalize(); > } > } > > However, I could not reproduce a memory leak with the code > > #include

Re: counting number of (overlapping) occurances

2006-03-09 Thread Paul Rubin
"John" <[EMAIL PROTECTED]> writes: > if S1 = "" > and S2 = "AA" > > then the count is 3. Is there an easy way to do this in python? > I was trying to use the "count" function but it does not do > overlapping counts it seems. len([1 for i in xrange(len(s1)) if s1[i:].startswith(s2)]) -- http:

Re: Help with a reverse dictionary lookup

2006-03-09 Thread Scott David Daniels
rh0dium wrote: > Basically there are multiple combinatories here - I was hoping someone > could point me to a general approach. Writing the actual funtion is > not necessary - as you pointed out I can certainly do that. Here is my > problem - I did exactly as you and said OK I can > > if Foundry

How to pop random item from a list?

2006-03-09 Thread flamesrock
Hi, It's been a while since I've played with python. My question is... whats the best way to pop a random item from a list?? -Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: counting number of (overlapping) occurances

2006-03-09 Thread John
Thanks a lot, This works but is a bit slow, I guess I'll have to live with it. Any chance this could be sped up in python? Thanks once again, --j -- http://mail.python.org/mailman/listinfo/python-list

can't send large messages over SSL socket

2006-03-09 Thread Bryan
i'm having some trouble this code which i hope someone can help me with. the following client side code works correctly if the length of the message being sent in the POST request is 16384 (1024 * 16) chars or less. if the length of message is greater than 16384 an OpenSSL.SSL.SysCallError: (

Re: How to pop random item from a list?

2006-03-09 Thread marduk
On Thu, 2006-03-09 at 21:59 -0800, flamesrock wrote: > Hi, > > It's been a while since I've played with python. > > My question is... whats the best way to pop a random item from a list?? import random # ... item = mylist.pop(random.randint(0,len(mylist))) -- http://mail.python.org/mailman/l

Re: counting number of (overlapping) occurances

2006-03-09 Thread Paul Rubin
"John" <[EMAIL PROTECTED]> writes: > This works but is a bit slow, I guess I'll have to live with it. > Any chance this could be sped up in python? Whoops, I meant to say: len([1 for i in xrange(len(s1)) if s1.startswith(s2,i)]) That avoids creating a lot of small strings. If s1 is large you

Re: counting number of (overlapping) occurances

2006-03-09 Thread Ben Cartwright
John wrote: > This works but is a bit slow, I guess I'll have to live with it. > Any chance this could be sped up in python? Sure, to a point. Instead of: def countoverlap(s1, s2): return len([1 for i in xrange(len(s1)) if s1[i:].startswith(s2)]) Try this version, which takes smaller sl

Re: counting number of (overlapping) occurances

2006-03-09 Thread Alex Martelli
John <[EMAIL PROTECTED]> wrote: > Thanks a lot, > > This works but is a bit slow, I guess I'll have to live with it. > Any chance this could be sped up in python? Sure (untested code): def count_with_overlaps(needle, haystack): count = 0 pos = 0 while True: where = haystack.

Re: How to pop random item from a list?

2006-03-09 Thread Ben Cartwright
flamesrock wrote: > whats the best way to pop a random item from a list?? import random def popchoice(seq): # raises IndexError if seq is empty return seq.pop(random.randrange(len(seq))) --Ben -- http://mail.python.org/mailman/listinfo/python-list

Licensing question

2006-03-09 Thread Christian Ehrlicher
Hi, I've got a question about your python license. For the (lgpl'd) kdewin32 - layer (some unix functions for kdelibs4/win32) I need a mmap implementation. Can I use your code within kdewin32-lib? I don't think that the resulting code will contain a lot of similarities with your code (apart from t

Re: counting number of (overlapping) occurances

2006-03-09 Thread Alex Martelli
Alex Martelli <[EMAIL PROTECTED]> wrote: > John <[EMAIL PROTECTED]> wrote: > > > Thanks a lot, > > > > This works but is a bit slow, I guess I'll have to live with it. > > Any chance this could be sped up in python? > > Sure (untested code): > > def count_with_overlaps(needle, haystack): >

Re: Why property works only for objects?

2006-03-09 Thread Alex Martelli
Michal Kwiatkowski <[EMAIL PROTECTED]> wrote: ... > The problem is I have an instance of a given class (say BaseClass) and I > want it to implement some attribute accesses as method calls. I'm not a > creator of this object, so changing definition of BaseClass or > subclassing it is not an optio

Re: Why property works only for objects?

2006-03-09 Thread Alex Martelli
Michal Kwiatkowski <[EMAIL PROTECTED]> wrote: > So another question arise. Is it possible to make function a method (so > it will receive calling object as first argument)? Sure, impor types then call types.MethodType: f = types.MethodType(f, obj, someclass) (f.__get__ is also fine for Python-c

creating variable in root namespace from module

2006-03-09 Thread MakaMaka
Hi, I have a scope related question that I haven't been able to find an answer to anywhere. Is there a way to have a function in an imported module add variables to the scope of the calling script? Basically, can I have the following: #root.py import some_module.py some_module.afunction() # <==

Re: embedding Python: how to avoid memory leaks?

2006-03-09 Thread Martin v. Löwis
Andrew Trevorrow wrote: > Surely that's a bug that should be fixed. There should be some way > to tell Python "release all the memory you've ever allocated and > start again with a clean slate". This bug cannot be fixed in any foreseeable future. > I've been told that the next version of Python

Re: Hashtables in pyhton ...

2006-03-09 Thread Konrad Mühler
Max M wrote: > >>> a_hash_is_a_dict = {'key':'value'} > >>> a_hash_is_a_dict['key2'] = 'value 2' > >>> a_hash_is_a_dict['key'] > 'value' Thank you very much. This is I was looking for :-) -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3