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

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

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

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: 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): >

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

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

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

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

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: 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: 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.

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

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

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

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: Password entering system

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

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

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 # =>

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

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

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: 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 printing in IDLE?

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

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

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

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

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

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

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

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

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://

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'

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

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

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: 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" . >

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: 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: 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: 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: 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: Any python HTML generator libs?

2006-03-09 Thread Bruno Desthuilliers
Sullivan WxPyQtKinter a écrit : > Hi, everyone. Simply put, what I need most now is a python lib to > generate simple HTML. > > I am now using XML to store my lab report records. I found python > really convinient to manipulate XML, so I want to make a small on-line > CGI program to help my colle

Re: Silly import question (__file__ attribute)

2006-03-09 Thread Fredrik Lundh
"mh" wrote: > So on most modules I import, I can access the .__file__ attribute to > find the implementation. ie: > >>> import time > >>> time.__file__ > '/data1/virtualpython/lib/python2.3/lib-dynload/timemodule.so' > >>> import socket > >>> socket.__file__ > '/data1/virtualpython/lib/python2.3/

Re: Silly import question (__file__ attribute)

2006-03-09 Thread Jack Diederich
On Thu, Mar 09, 2006 at 02:04:45PM -0800, mh wrote: > So on most modules I import, I can access the .__file__ attribute to > find the implementation. ie: > >>> import time > >>> time.__file__ > '/data1/virtualpython/lib/python2.3/lib-dynload/timemodule.so' > >>> import socket > >>> socket.__file__

Re: New python.org website

2006-03-09 Thread Peter Mayne
Kay Schluehr wrote: > > This evening we talked at the Hofbraeuhaus at Munich about Michelangelo > whose sixtine chapel images where once overpainted because his figures > appeared naked "as god created them". That's why Michelangelo didn't design the new Python web site: because Google wouldn't

Re: Inline assignments

2006-03-09 Thread Steven D'Aprano
On Thu, 09 Mar 2006 15:45:13 +, Duncan Booth wrote: > Like it or not, Python uses exceptions for normal loop flow control. That's > a fact of life, live with it: every normal termination of a for loop is an > exception. Real exceptions don't get masked: for loops terminate with > StopIterat

creating an executable?

2006-03-09 Thread John Salerno
Well, now that I can time my laundry, I need to make it runnable. I tried looking for info on the freeze module in the help file, but it didn't seem to come up with much. According to the Python wiki, freeze is for making executables for Unix. Can I make an executable with just the standard dis

Silly import question (__file__ attribute)

2006-03-09 Thread mh
So on most modules I import, I can access the .__file__ attribute to find the implementation. ie: >>> import time >>> time.__file__ '/data1/virtualpython/lib/python2.3/lib-dynload/timemodule.so' >>> import socket >>> socket.__file__ '/data1/virtualpython/lib/python2.3/socket.pyc' This doesn't wor

Re: Simple questions on use of objects (probably faq)

2006-03-09 Thread Steven D'Aprano
On Thu, 09 Mar 2006 13:44:25 +0100, bruno at modulix wrote: > Steven D'Aprano wrote: > (snip) > >> I say "think you want" because I don't know what problem you are trying to >> solve with this messy, self-referential, piece of code. > > This messy piece of code is mine, thanks !-) You're welcom

Re: Simple questions on use of objects (probably faq)

2006-03-09 Thread Steven D'Aprano
On Thu, 09 Mar 2006 13:23:22 +0100, Brian Elmegaard wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > >> Can you explain more carefully what you are trying to do? If you want the >> square of the maximum value, just do this: > > I want to get the value of another attribute of the instance w

Re: Any python HTML generator libs?

2006-03-09 Thread Gerard Flanagan
Sullivan WxPyQtKinter wrote: > Hi, everyone. Simply put, what I need most now is a python lib to > generate simple HTML. > > I am now using XML to store my lab report records. I found python > really convinient to manipulate XML, so I want to make a small on-line > CGI program to help my colleag

Re: Any python HTML generator libs?

2006-03-09 Thread Sullivan WxPyQtKinter
That lib can help. But still, I have to code a lot using that lib. Maybe my program is quite strange, far from common. Thank you, after all~! -- http://mail.python.org/mailman/listinfo/python-list

Re: Hashtables in pyhton ...

2006-03-09 Thread Ravi Teja
Hashtables (dictonaries) and ArrayLists(lists) are integral parts of modern languages (for example: Python, Ruby, OCaml, D). They are builtin data types unlike say, Java or C++, where they are added to the library as an afterthought. -- http://mail.python.org/mailman/listinfo/python-list

Re: Any python HTML generator libs?

2006-03-09 Thread Sullivan WxPyQtKinter
Sorry I am completely a green-hand in HTML. What is HTMLTemplate and ElementTree? Would you please post some source code as an example? Of course I would Google them to find out more. Thank you so much. -- http://mail.python.org/mailman/listinfo/python-list

Re: Any python HTML generator libs?

2006-03-09 Thread Steve Holden
Sullivan WxPyQtKinter wrote: > Hi, everyone. Simply put, what I need most now is a python lib to > generate simple HTML. > > I am now using XML to store my lab report records. I found python > really convinient to manipulate XML, so I want to make a small on-line > CGI program to help my colleagu

Re: Any python HTML generator libs?

2006-03-09 Thread Jarek Zgoda
Sullivan WxPyQtKinter napisał(a): > Hi, everyone. Simply put, what I need most now is a python lib to > generate simple HTML. > > I am now using XML to store my lab report records. I found python > really convinient to manipulate XML, so I want to make a small on-line > CGI program to help my co

Re: Any python HTML generator libs?

2006-03-09 Thread Michael
> Will XSTL be useful? Is my problem somewho related with XML-SIG? > Looking forward to your precious suggestion. > XSLT is powerful but a royal pain in the arse. Just writing some Python to generate your HTML would probably be a lot easier for you. -- Michael McGlothlin, tech monkey Tub Monk

Re: First script, please comment and advise

2006-03-09 Thread bearophileHUGS
> nested and hided inside a class. Hidden, sorry :-) >Can a "sub-function" be called directly from outside the defining function? I don't think you can access a nested function in a clean&nice way (and you can nest classes too, etc). With a little of Python magic maybe there is a way to do it..

Re: Python Evangelism

2006-03-09 Thread Steve Holden
Felipe Almeida Lessa wrote: > Em Qui, 2006-03-09 às 09:51 +, Steve Holden escreveu: > >>I've been thinking (and blogging) about python evangelism since PyCon, >>as a result of which I created a squidoo lens: >> >> http://www.squidoo.com/pythonlogy >> >>Imagine my surprise at discovering tha

Re: convert hex to decimal

2006-03-09 Thread Peter Maas
[EMAIL PROTECTED] schrieb: > popS = string.join(pop.readlines()) Why not popS = pop.read()? > The output from the second popen is: > > SNMPv2-SMI::enterprises.9.9.168.1.2.1.1.13.51858 = Hex-STRING: 00 00 00 > 26 > > > I need to get the Hex-STRING into the following format: 0.0038

Any python HTML generator libs?

2006-03-09 Thread Sullivan WxPyQtKinter
Hi, everyone. Simply put, what I need most now is a python lib to generate simple HTML. I am now using XML to store my lab report records. I found python really convinient to manipulate XML, so I want to make a small on-line CGI program to help my colleagues to build their lab report records into

Re: First script, please comment and advise

2006-03-09 Thread bearophileHUGS
This is different too, but maybe a little better than my last version: from random import shuffle from itertools import groupby def scramble_text(text): """Return the words in input text string scrambled, except for the first and last letter.""" def scramble(word): if len(word

Re: Python Evangelism

2006-03-09 Thread Tim Churches
Douglas Alan wrote: > Ruby didn't start catching on until Ruby on Rails came out. If Python > has a naming problem, it's with the name of Django, rather than > Python. Firstly, Django doesn't have "Python" in the name, so it > doesn't popularize the language behind it, even should Django become >

Re: timeit.py examples in docs generate error

2006-03-09 Thread 3c273
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Window's command processor doesn't recognise single quote marks as > meaning anything special, so your command is passing 4 separate arguments > to timeit.py instead of the 1 argument that a unix shell would be passing. >

Re: A better RE?

2006-03-09 Thread Fredrik Lundh
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: Python Evangelism

2006-03-09 Thread Tim Churches
Robert Boyd wrote: > And re Cheeseshop, yes, it's a poor name when you consider that the > point of the skit was that the cheeseshop _had no cheese_, whose only > purpose was to "deliberately waste your time." Not a great name for a > package library, especially for those in the know of Python humo

Re: First script, please comment and advise

2006-03-09 Thread Pedro Graca
[EMAIL PROTECTED] wrote: > My version is similar to Just one: > > from random import shuffle > > def scramble_text(text): > """Return the words in input text string scrambled > except for the first and last letter.""" > def scramble_word(word): Nice. You can have functions inside funct

Re: First script, please comment and advise

2006-03-09 Thread Pedro Graca
[EMAIL PROTECTED] wrote: > Just: >> [previous post, hand inserted] >>> def scramble_text(text): >>> def scramble_word(word): >> >> Btw. I find the use of a nested function here completely bogus: you >> don't need the surrounding scope. > > I don't agree, nested functions are useful to better st

Re: First script, please comment and advise

2006-03-09 Thread Pedro Graca
Just wrote: > In article <[EMAIL PROTECTED]>, > Pedro Graca <[EMAIL PROTECTED]> wrote: > [snip: very un-pythonic code] > > def curious(text): > """ Return the words in input text scrambled except for the > first and last letter. """ > new_text = "" > word = "" >

pythoncom.PumpMessages - how to quit

2006-03-09 Thread abcd
When I call: pythoncom.PumpMessages() ...it blocks at that line. According to the docs, it says it will run until it receives a WM_QUITso I try to create a separate thread and do import win32api win32api.PostQuitMessage() ...but the code is still blocking at PumpMessages. Any ideas? othe

pythoncom.PumpMessages - how to quit

2006-03-09 Thread abcd
When I call: pythoncom.PumpMessages() ...it blocks at that line. According to the docs, it says it will run until it receives a WM_QUITso I try to create a separate thread and do import win32api win32api.PostQuitMessage() ...but the code is still blocking at PumpMessages. Any ideas? othe

  1   2   3   >