Regular Toronto Python User's Group (PyGTA) Meeting July 15th: Code Aesthetics

2008-07-11 Thread Mike C. Fletcher
We'll be holding our regular Toronto Python User's Group (PyGTA) this upcoming Tuesday the 15th 7pm at Linux Caffe, on the corner of Grace and Harbord Street. At the moment we don't have a confirmed speaker, so I was thinking we might try the following (inspired by one of Greg Wilson's recent

2008 Pizzigati Prize

2008-07-11 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Last year, I was humbly honored to be awarded the 2007 Antonio Pizzigati Prize for Software in the Public Interest. This year, I am honored to serve on the awards committee for the 2008 prize. From the PDF flyer: The Tides Foundation is

Re: Simple question, how do you tell how many items in a list?

2008-07-11 Thread Vlastimil Brom
2008/7/11, Alex Bryan [EMAIL PROTECTED]: I am just wondering how you get an integer value for how many items there are in a list, preferably w/o a for loop. -- http://mail.python.org/mailman/listinfo/python-list Use len len([1,2,3]) 3 vbr --

Re: Python 3.0 and removal of the 'string' module

2008-07-11 Thread Ben Finney
Terry Reedy [EMAIL PROTECTED] writes: Ben Finney wrote: Can anyone see a reason to believe the above wiki page's statement about the 'string' module being removed? More to the point, can anyone see a reason why that statement should remain on that page? Removing string and moving the

Re: Elisp Lesson on file processing (make downloadable copy of a website)

2008-07-11 Thread [EMAIL PROTECTED]
Xah Lee wrote: « ... emacs program and tutorial that does archiving a website for offline reading. (See http://xahlee.org/emacs/make_download_copy.html ) » Sashi wrote: «Why not use wget or curl?» The Emacs lisp program makes a archive of parts of website you own, so that readers of your website

Re: Bypassing WebFilter security

2008-07-11 Thread Daniel Fetchinson
I am working in an organization, which is using a very strict webcontent filter management suite. Due to this i am unable to download any exe file, or surf web (even the necessary downloads from sourceforgenet are blocked). I was wondering, if python could be of any help. Say i have a python

Re: problem with exec and locals()

2008-07-11 Thread Uwe Schmitt
On 1 Jul., 15:15, Mel [EMAIL PROTECTED] wrote: rocksportrockerwrote: Hi, the following code does not work until I ommit the a=0 statement.    def test():        exec a=3 in locals()        print a        a=0     test() print raises:      UnboundLocalError: local variable

Re: ActiveState Code: the new Python Cookbook site

2008-07-11 Thread Thin Myrna
Trent Mick wrote: Stef Mientki wrote: one small remark, If I want to browse 200 recipes, at 10 per page ... please make something like 100 available per page, are internet is fast enough nowadays. Touche. Done: http://code.activestate.com/recipes/?paginate_by=100 The old

Re: error with configure (svn 64857)

2008-07-11 Thread Martin v. Löwis
Thank you Martin. How can I remove -lgcc_s and use the Intel equivalent ? I'm not so sure that there is anything wrong in configure. configure doesn't pass -lgcc_s to icc; instead, icc is making this up on its own. So I would guess you need to get libgcc_s onto you system in a way that the

Re: Python 3.0 and removal of the 'string' module

2008-07-11 Thread Martin v. Löwis
This is rather disappointing. Is that entire page suspect? All documentation about Python 3 is suspect until Python 3 gets actually released (nobody can say for sure how the release will look like in all details). Wiki pages, traditionally, are always suspect for incorrect or outdated

Re: Bypassing WebFilter security

2008-07-11 Thread pranav
On Jul 11, 11:42 am, Daniel Fetchinson [EMAIL PROTECTED] wrote: I am working in an organization, which is using a very strict webcontent filter management suite. Due to this i am unable to download any exe file, or surf web (even the necessary downloads from sourceforgenet are blocked). I

Re: socket-module: different behaviour on windows / unix when a timeout is set

2008-07-11 Thread Gabriel Genellina
En Wed, 09 Jul 2008 15:02:56 -0300, Mirko Vogt [EMAIL PROTECTED] escribi�: it seems that the socket-module behaves differently on unix / windows when a timeout is set. [...] Now I will change the code slightly - to be precise I set a timeout on the socket: # test.py import socket

numeric emulation and the rich comparison operators

2008-07-11 Thread Ethan Furman
Greetings, List! Still working on my Measure class, and my next question is... (drum roll please ;) What are the advantages of using __[eq|ne|lt|gt|le|ge]__ vs __cmp__? Thanks in advance! -- Ethan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 and removal of the 'string' module

2008-07-11 Thread Ben Finney
Martin v. Löwis [EMAIL PROTECTED] writes: This is rather disappointing. Is that entire page suspect? All documentation about Python 3 is suspect until Python 3 gets actually released (nobody can say for sure how the release will look like in all details). Is there a better information

Re: problem with exec and locals()

2008-07-11 Thread Peter Otten
Uwe Schmitt wrote: Apparently, exec in locals() knows nothing about slots (because locals() is the only dictionary in the universe where slots would be involved ? -- perhaps not, but close). Mel. Thanks for your answer. I wonder if this is a bug, or did I miss something in the docs ???

Re: installing any python module

2008-07-11 Thread Gabriel Genellina
En Thu, 10 Jul 2008 14:02:29 -0300, Bhagwat Kolde [EMAIL PROTECTED] escribi�: What is the correct process of installing any external python module? Once we downloaded any python module, Q1) Where this module should be placed in python installation file structure? If it is a single Python

Re: ActiveState Code: the new Python Cookbook site

2008-07-11 Thread Peter Otten
Thin Myrna wrote: The old cookbook offered choices by category. Did you drop that feature? Looks like categories have become tags: http://code.activestate.com/recipes/tags/ Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-11 Thread Bill Davy
Tim Golden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Bill Davy wrote: I'm not sure OL2003 can read news. I think perhaps some later OL can (added tot he View menu, perhaps?). So I use OL Express to read news. The OL with which I wish to communicate is: Application name

importing .dll in a python file

2008-07-11 Thread moijes12
Hi I need to use a .dll from a python script.I have installed pywin.But in the program ,which is like: import dllName I get : Import Error : DLL not found Please suggest a solution! -- http://mail.python.org/mailman/listinfo/python-list

Trying to learn

2008-07-11 Thread luster123
Hey, Can someone please teach me the basics of Python and Pygame? -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems Returning an HTTP 200 Ok Message

2008-07-11 Thread Gabriel Genellina
En Thu, 10 Jul 2008 18:10:46 -0300, Guy Davidson [EMAIL PROTECTED] escribi�: On Jul 10, 12:38 pm, samwyse [EMAIL PROTECTED] wrote: On Jul 10, 1:50 pm, Guy Davidson [EMAIL PROTECTED] wrote: My code (attached below) us supposed to read an HTTP Post message coming from a power meter, parse

Re: Trying to learn

2008-07-11 Thread Ben Finney
luster123 [EMAIL PROTECTED] writes: Can someone please teach me the basics of Python and Pygame? Yes, you can do it. URL:http://docs.python.org/tut/tut.html URL:http://www.python.org/doc/ URL:http://clusty.com/search?query=pygame+tutorial -- \ “Too many pieces of music finish too long

ANN: P4D 1.1

2008-07-11 Thread Kay Schluehr
P4D = E4X style embedded DSL for Python but without E and X. For more information see: http://pypi.python.org/pypi/P4D/1.1-py2.5 -- http://mail.python.org/mailman/listinfo/python-list

Re: importing .dll in a python file

2008-07-11 Thread Tim Golden
moijes12 wrote: I need to use a .dll from a python script.I have installed pywin.But in the program ,which is like: import dllName I get : Import Error : DLL not found Please suggest a solution! Well, the short answer is: use the ctypes module. The longer answer is: read around the

Re: numeric emulation and the rich comparison operators

2008-07-11 Thread Gabriel Genellina
En Thu, 10 Jul 2008 17:37:42 -0300, Ethan Furman [EMAIL PROTECTED] escribi�: Greetings, List! Still working on my Measure class, and my next question is... (drum roll please ;) What are the advantages of using __[eq|ne|lt|gt|le|ge]__ vs __cmp__? If your objects obey the trichotomy law

Re: Basic Question about Python WebServer File handling

2008-07-11 Thread Gabriel Genellina
En Thu, 10 Jul 2008 22:20:21 -0300, Alok Kumar [EMAIL PROTECTED] escribi�: I need to have a python webserver which can handle Get request from the clients and upload the *files* from 4 different directories. Can someone please point me what to exactly look for. Look at SimpleHTTPServer.py

Django admin multi layour

2008-07-11 Thread Christian Kortenhorst (Forum)
Hey All Just been messing around with django and found that can not seam to get admin to work how, it does not support multilayer input I want it I know there is some way of writing your own view, but wondering would it be possible to write a multilayer setup or what is the wok around or what

Re: problem with exec and locals()

2008-07-11 Thread Gabriel Genellina
En Fri, 11 Jul 2008 03:51:39 -0300, Uwe Schmitt [EMAIL PROTECTED] escribi�: On 1 Jul., 15:15, Mel [EMAIL PROTECTED] wrote: rocksportrockerwrote: the following code does not work until I ommit the a=0 statement.    def test():        exec a=3 in locals()        print a        a=0    

Re: Trying to learn

2008-07-11 Thread Gabriel Genellina
En Fri, 11 Jul 2008 05:49:23 -0300, Ben Finney [EMAIL PROTECTED] escribi�: luster123 [EMAIL PROTECTED] writes: Can someone please teach me the basics of Python and Pygame? Yes, you can do it. URL:http://docs.python.org/tut/tut.html URL:http://www.python.org/doc/

Question about: GUI Builder for Tkinter and call to C/C++ code

2008-07-11 Thread pauladospublicidad
First I'll introduce myself. I normally programm in C/C++ and Java. Sometimes I have to mix them (normally using C/C++ in java, because in java is easier to make portable graphic user interfaces). However to use C/C++ code in java is really complex and difficult. Not too much time ago, I

Re: recommended gcc versions for python2.5 compilation on Solaris sparc/x86, AIX, Linux

2008-07-11 Thread Jeroen Ruigrok van der Werven
-On [20080711 06:18], YIN Ming ([EMAIL PROTECTED]) wrote: 2. use new version of gcc (rather than odd version) See http://www.in-nomine.org/2008/04/11/python-26a2-execution-times-with-various-compilers/ that I wrote a while ago. Basically for Python GCC 3.4.6 outperformed the newer GCCs. So

Re: Question about: GUI Builder for Tkinter and call to C/C++ code

2008-07-11 Thread Diez B. Roggisch
pauladospublicidad schrieb: First I'll introduce myself. I normally programm in C/C++ and Java. Sometimes I have to mix them (normally using C/C++ in java, because in java is easier to make portable graphic user interfaces). However to use C/C++ code in java is really complex and difficult. Not

Moving to functional programming

2008-07-11 Thread James Fassett
Hi all, Had a simple problem that turned into an interesting solution and I thought I would share it here. I had a list of tuples that I needed to get the first value from and generate a list. tuple_list = ( ('John', 'Doe'), ('Mark', 'Mason'), ('Jeff', 'Stevens'), ('Bat', 'Man')

RE: recommended gcc versions for python2.5 compilation on Solarissparc/x86, AIX, Linux

2008-07-11 Thread YIN Ming
for python2.5 compilation on Solarissparc/x86, AIX, Linux -On [20080711 06:18], YIN Ming ([EMAIL PROTECTED]) wrote: 2. use new version of gcc (rather than odd version) See http://www.in-nomine.org/2008/04/11/python-26a2-execution-times-with-various-compilers/ that I wrote a while ago. Basically

Re: Moving to functional programming

2008-07-11 Thread bearophileHUGS
James Fassett: # the first Pythonic attempt using comprehensions result_list = [x[0] for x in tuple_list] # the final functional way [result_list, _] = zip(*tuple_list) I really like how Python allows me to do what I feel is the most natural solution (for a seasoned procedural programmer)

Re: error with configure (svn 64857)

2008-07-11 Thread Mathieu Prevot
2008/7/11 Martin v. Löwis [EMAIL PROTECTED]: Thank you Martin. How can I remove -lgcc_s and use the Intel equivalent ? I'm not so sure that there is anything wrong in configure. configure doesn't pass -lgcc_s to icc; instead, icc is making this up on its own. So I would guess you need to get

Re: error with configure (svn 64857)

2008-07-11 Thread Mathieu Prevot
2008/7/11 WDC [EMAIL PROTECTED]: On Jul 10, 6:57 pm, Mathieu Prevot [EMAIL PROTECTED] wrote: 2008/7/10 Martin v. Löwis [EMAIL PROTECTED]: I have the following error when I run configure: checking size of wchar_t... configure: error: cannot compute sizeof (wchar_t) what can I do ?

Re: importing .dll in a python file

2008-07-11 Thread moijes12
On Jul 11, 2:09 pm, Tim Golden [EMAIL PROTECTED] wrote: moijes12 wrote: I need to use a .dll from a python script.I have installed pywin.But in the program ,which is like: import dllName I get : Import Error : DLL not found Please suggest a solution! Well, the short answer is:

How to serialize and deserialize the objects into memory?

2008-07-11 Thread hardemr
Hello Everyone, I want to serialize and deserialize the objects into Memory not into file. How can i do that? Best Regards, -- http://mail.python.org/mailman/listinfo/python-list

Re: How to serialize and deserialize the objects into memory?

2008-07-11 Thread Diez B. Roggisch
hardemr schrieb: Hello Everyone, I want to serialize and deserialize the objects into Memory not into file. How can i do that? Use pickle module StringIO/cStringIO as file-to-memory-object. Diez -- http://mail.python.org/mailman/listinfo/python-list

MySQLdb will only import for root

2008-07-11 Thread martinnorth
Hi, I am running Python and MySQL on Ubuntu and have installed MySQLdb. If I try to import MySQLdb I get the following error: ActivePython 2.5.2.2 (ActiveState Software Inc.) based on Python 2.5.2 (r252:60911, Mar 27 2008, 16:42:08) [GCC 3.3.1 (SuSE Linux)] on linux2 Type help, copyright,

Re: MySQLdb will only import for root

2008-07-11 Thread Diez B. Roggisch
martinnorth schrieb: Hi, I am running Python and MySQL on Ubuntu and have installed MySQLdb. If I try to import MySQLdb I get the following error: ActivePython 2.5.2.2 (ActiveState Software Inc.) based on Python 2.5.2 (r252:60911, Mar 27 2008, 16:42:08) [GCC 3.3.1 (SuSE Linux)] on linux2

Re: MySQLdb will only import for root

2008-07-11 Thread Jeff
Is it possible the module was installed with priviledges set too strict? Perhaps the interpreter cannot see the module when it is run from a normal user account. -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL: Transparent PNGs and im.paste: ValueError: bad transparency mask

2008-07-11 Thread Ken Starks
Durand wrote: I posted this too soon. Converting the images to png with image magick's convert did the trick...However, I'm still not sure why I need to convert the images in the first place. Are there different types of PNGs?

Re: socket-module: different behaviour on windows / unix when a timeout is set

2008-07-11 Thread Mirko Vogt
Gabriel Genellina wrote: En Wed, 09 Jul 2008 15:02:56 -0300, Mirko Vogt [EMAIL PROTECTED] escribi�: it seems that the socket-module behaves differently on unix / windows when a timeout is set. [...] Now I will change the code slightly - to be precise I set a timeout on the socket: #

strip() using strings instead of chars

2008-07-11 Thread Christoph Zwerschke
In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url[7:] Similarly for stripping suffixes: if filename.endswith('.html'): filename = filename[:-5] My problem with this is that

Re: MySQLdb will only import for root

2008-07-11 Thread Peter Otten
martinnorth wrote: Hi, I am running Python and MySQL on Ubuntu and have installed MySQLdb. If I try to import MySQLdb I get the following error: ActivePython 2.5.2.2 (ActiveState Software Inc.) based on Python 2.5.2 (r252:60911, Mar 27 2008, 16:42:08) [GCC 3.3.1 (SuSE Linux)] on linux2

Re: MySQLdb will only import for root

2008-07-11 Thread Diez B. Roggisch
Jeff schrieb: Is it possible the module was installed with priviledges set too strict? Perhaps the interpreter cannot see the module when it is run from a normal user account. Possible - certainly. Yet unrealistic, because usually root access is *required* to system-wide install a package -

Perfect hashing for Py

2008-07-11 Thread bearophileHUGS
Following links from this thread: http://groups.google.com/group/comp.lang.python/browse_thread/thread/179e1a45485ab36a# I have found this perfect hash (minimal too) implementation: http://burtleburtle.net/bob/hash/perfect.html I have already translated part of it to D, and it seems to work well

Re: Python 3.0 and removal of the 'string' module

2008-07-11 Thread Benjamin
On Jul 11, 3:06 am, Ben Finney [EMAIL PROTECTED] wrote: Martin v. Löwis [EMAIL PROTECTED] writes: This is rather disappointing. Is that entire page suspect? All documentation about Python 3 is suspect until Python 3 gets actually released (nobody can say for sure how the release will

Re: strip() using strings instead of chars

2008-07-11 Thread Bruno Desthuilliers
Christoph Zwerschke a écrit : In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url[7:] DRY/SPOT violation. Should be written as : prefix = 'http://' if url.startswith(prefix):

Re: using Python's AST generator for other languages

2008-07-11 Thread Benjamin
On Jul 11, 12:27 am, eliben [EMAIL PROTECTED] wrote: snip 2) What is the meaning of the comment in astgen.py ? Are the Python maintainers unhappy with the design of the AST ?3 Node, I think, is talking about a node in the parse tree. (AST is generated from another parse tree.) See PEP

Re: How to serialize and deserialize the objects into memory?

2008-07-11 Thread Gerhard Häring
hardemr wrote: Hello Everyone, I want to serialize and deserialize the objects into Memory not into file. How can i do that? You want to serialize the objects, but only keep them in memory? That hardly makes any sense. Serialization is need if you want to store your objects in a file or if

Re: python scalability

2008-07-11 Thread Gerhard Häring
Tim Mitchell wrote: Thanks for all the replies - they have all been helpful. On reflection I think our problems are probably design and people related. I strongly agree. Scalability is becoming a buzzword lately, which is meaningless unless qualified what exactly is meant. It's overused

Re: How to serialize and deserialize the objects into memory?

2008-07-11 Thread Inyeol . Lee
On Jul 11, 12:58 pm, hardemr [EMAIL PROTECTED] wrote: Hello Everyone, I want to serialize and deserialize the objects into Memory not into file. How can i do that? pickle.dumps and pickle.loads. --Inyeol -- http://mail.python.org/mailman/listinfo/python-list

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-11 Thread Tim Golden
Bill Davy wrote: and since then have been busy with work, and my other job, and the garden. Aha! So you're English, are you? Looks like you're in the West Country. Weather map suggests you're not short of rain over there :) Now I am back looking at this (and using WInUSB to talk to a Maxim

read file into list of lists

2008-07-11 Thread antar2
Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I make the print statement list[0] [0], that the word pear

Re: ANN: P4D 1.1

2008-07-11 Thread Fuzzyman
On Jul 11, 10:09 am, Kay Schluehr [EMAIL PROTECTED] wrote: P4D = E4X style embedded DSL for Python but without E and X. For more information see: http://pypi.python.org/pypi/P4D/1.1-py2.5 That looks a lot like YAML. Any reason to use it over YAML? Michael Foord

Re: read file into list of lists

2008-07-11 Thread Laurent Rahuel
Hello, A way to do it === from __future__ import with_statement res = [] with open(sentences.txt,r) as f: sentences = [elem for elem in f.read().split('\n') if elem] for sentence in sentences: res.append(sentence.split())

Re: read file into list of lists

2008-07-11 Thread bockman
On 11 Lug, 15:15, antar2 [EMAIL PROTECTED] wrote: Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I

Re: MySQLdb will only import for root

2008-07-11 Thread Jeffrey Froman
Diez B. Roggisch wrote: Is it possible the module was installed with priviledges set too strict?  Perhaps the interpreter cannot see the module when it is run from a normal user account. Possible - certainly. Yet unrealistic, because usually root access is required to system-wide install a

Pickle and wx.TextCtrl

2008-07-11 Thread DWebre
Trying to read a pickled filed and list contents. The attached program works using pprint, but I want to write to my frame. WriteText only produces half of the records. What is happening? (See attached file: ReadDB_b.py) D. J. Webre, Jr. PE PLS Director of Engineering Technical Support

Re: read file into list of lists

2008-07-11 Thread Paddy
On Jul 11, 2:15 pm, antar2 [EMAIL PROTECTED] wrote: Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-11 Thread Bill Davy
Tim Golden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Bill Davy wrote: and since then have been busy with work, and my other job, and the garden. Aha! So you're English, are you? Looks like you're in the West Country. Weather map suggests you're not short of rain over there

Re: read file into list of lists

2008-07-11 Thread Gerard flanagan
antar2 wrote: Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I make the print statement list[0] [0],

Re: Python 3.0 and removal of the 'string' module

2008-07-11 Thread John Roth
On Jul 11, 6:26 am, Benjamin [EMAIL PROTECTED] wrote: On Jul 11, 3:06 am, Ben Finney [EMAIL PROTECTED] wrote: Martin v. Löwis [EMAIL PROTECTED] writes: This is rather disappointing. Is that entire page suspect? All documentation about Python 3 is suspect until Python 3 gets

Re: Unit Testing Techniques

2008-07-11 Thread Matthew Fitzgibbons
I'm by no means a testing expert, but I'll take a crack at it. Casey McGinty wrote: I'm familiar with the unittest module in Python, however I'm hoping someone can point me to some examples of more advanced usages of the framework. For example: 1. Using the framework to test a package with

Re: strip() using strings instead of chars

2008-07-11 Thread Christoph Zwerschke
Bruno Desthuilliers schrieb: DRY/SPOT violation. Should be written as : prefix = 'http://' if url.startswith(prefix): url = url[len(prefix):] That was exactly my point. This formulation is a bit better, but it still violates DRY, because you need to type prefix two times. It is

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-11 Thread Tim Golden
Bill Davy wrote: Traceback (most recent call last): File H:/Personal/OutlookIF1/t2.py, line 18, in module outlook = win32com.client.gencache.EnsureDispatch (Outlook.Application) File C:\Python25\Lib\site-packages\win32com\client\gencache.py, line 536, in EnsureDispatch mod =

Re: strip() using strings instead of chars

2008-07-11 Thread Marc 'BlackJack' Rintsch
On Fri, 11 Jul 2008 16:45:20 +0200, Christoph Zwerschke wrote: Bruno Desthuilliers schrieb: DRY/SPOT violation. Should be written as : prefix = 'http://' if url.startswith(prefix): url = url[len(prefix):] That was exactly my point. This formulation is a bit better, but it still

Re: read file into list of lists

2008-07-11 Thread Jeffrey Froman
Laurent Rahuel wrote that antar2 wrote: following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I make the print statement list[0] [0], that the word pear appears pear noun singular books nouns plural table noun singular File objects are

decorator to prevent adding attributes to class?

2008-07-11 Thread Neal Becker
After spending the morning debugging where I had misspelled the name of an attribute (thus adding a new attr instead of updating an existing one), I would like a way to decorate a class so that attributes cannot be (easily) added. I guess class decorators are not available yet (pep 3129), but

Editra

2008-07-11 Thread Henry Read
Editra is a multi-platform text editor with an implementation that focuses on creating an easy to use interface and features that aid in code development. Currently it supports syntax highlighting and variety of other useful features for over 60 programming languages. Editra is freely available

Re: Editra

2008-07-11 Thread Henry Read
It has been already in wxpython-doc-demos package. On Fri, Jul 11, 2008 at 11:38 PM, Henry Read [EMAIL PROTECTED] wrote: Editra is a multi-platform text editor with an implementation that focuses on creating an easy to use interface and features that aid in code development. Currently it

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Michele Simionato
On Jul 11, 5:29 pm, Neal Becker [EMAIL PROTECTED] wrote: After spending the morning debugging where I had misspelled the name of an attribute (thus adding a new attr instead of updating an existing one), I would like a way to decorate a class so that attributes cannot be (easily) added. I

Re: Weird lambda rebinding/reassignment without me doing it

2008-07-11 Thread David C. Ullrich
In article [EMAIL PROTECTED], Terry Reedy [EMAIL PROTECTED] wrote: David C. Ullrich wrote: In article [EMAIL PROTECTED], ssecorp [EMAIL PROTECTED] wrote: I am never redefining the or reassigning the list when using validate but since it spits the modified list back out that

Re: Weird lambda rebinding/reassignment without me doing it

2008-07-11 Thread David C. Ullrich
In article [EMAIL PROTECTED], ssecorp [EMAIL PROTECTED] wrote: def mod(x,y): return x.append(y) mod([1,2],3) k=[1,2,3] k [1, 2, 3] l = mod(k,4) l k [1, 2, 3, 4] l k==l False mod(k,5) k [1, 2, 3, 4, 5] mod(l,4) Traceback (most recent call last): File

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Robert Bossy
Michele Simionato wrote: This article could give you same idea (it is doing the opposite, warning you if an attribute is overridden): http://stacktrace.it/articoli/2008/06/i-pericoli-della-programmazione-con-i-mixin1/ There is also a recipe that does exactly what you want by means of a

Using the Random Module.

2008-07-11 Thread WDC
I am currently learning, and loving, Python and have a question about random(). Right now, what I have to do to get a whole number and not a decimal using random.random() is this: random.random() 0.84765728501856734 _ * 10**17 84765728501856734.0 Is there a better way to do that besides doing

Using SWIG to build C++ extension

2008-07-11 Thread mk
Hello, I'm having terrible problems building C++ extension to Python 2.4 using SWIG. I'd appreciate if somebody knowledgeable at the subject took a look at it. swig-1.3.29, g++ (GCC) 4.1.1 20070105 (Red Hat 4.1.1-52). I used following commands to build C++ extension: # swig -c++ -python

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Michele Simionato
On Jul 11, 6:38 pm, Robert Bossy I don't get it. Why use a metaclass? Wouldn't the following be the same, but easier to grasp: class Frozen(object):     def __setattr__(self, name, value):        if not hasattr(self, name):           raise AttributeError, cannot add attributes to %s % self

Re: Moving to functional programming

2008-07-11 Thread craig75
On Jul 11, 3:36 am, [EMAIL PROTECTED] wrote: James Fassett: # the first Pythonic attempt using comprehensions result_list = [x[0] for x in tuple_list] # the final functional way [result_list, _] = zip(*tuple_list) I really like how Python allows me to do what I feel is the most

Re: Using SWIG to build C++ extension

2008-07-11 Thread mk
And what's infuriating is that the .o files do contain the necessary symbol: # grep _Z13edit_distanceRSsS_ * Binary file edit_distance.o matches Binary file _edit_distance.so matches Binary file edit_distance_wrap.o matches -- http://mail.python.org/mailman/listinfo/python-list

spam

2008-07-11 Thread rickman
spam -- http://mail.python.org/mailman/listinfo/python-list

Re: strip() using strings instead of chars

2008-07-11 Thread Duncan Booth
Christoph Zwerschke [EMAIL PROTECTED] wrote: In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url[7:] If I came across this code I'd want to know why they weren't using

Re: Python with Ecmascript

2008-07-11 Thread Alan Isaac
NJSModule? http://en.wikipedia.org/wiki/NJS Daniel Fetchinson wrote: This seems to be very good indeed. Just downloaded njs but the only njsmodule version I could find was for python 2.1. Does anyone have a recent copy? 1. You might ask here:

Re: ActiveState Code: the new Python Cookbook site

2008-07-11 Thread Trent Mick
Peter Otten wrote: Thin Myrna wrote: The old cookbook offered choices by category. Did you drop that feature? Looks like categories have become tags: http://code.activestate.com/recipes/tags/ Yes, that is correct. I should document the tag names to category mapping that I've used (mostly

Re: Using the Random Module.

2008-07-11 Thread Michiel Overtoom
You wrote... Is there a better way to do that besides doing this: random.randint(0, 9) 09657398671238769 Maybe this? random.randint(0, 9e16) -- The ability of the OSS process to collect and harness the collective IQ of thousands of individuals across

Re: Moving to functional programming

2008-07-11 Thread sturlamolden
On Jul 11, 12:00 pm, James Fassett [EMAIL PROTECTED] wrote: tuple_list = (     ('John', 'Doe'),     ('Mark', 'Mason'),     ('Jeff', 'Stevens'),     ('Bat', 'Man')   ) # what I'd do in C or other procedural languages result_list = [] for item in tuple_list:    

Re: Using the Random Module.

2008-07-11 Thread WDC
On Jul 11, 2:15 pm, Michiel Overtoom [EMAIL PROTECTED] wrote: You wrote... Is there a better way to do that besides doing this: random.randint(0, 9) 09657398671238769 Maybe this?         random.randint(0, 9e16) -- The ability of the OSS process to

Re: Python with Ecmascript

2008-07-11 Thread Daniel Fetchinson
NJSModule? http://en.wikipedia.org/wiki/NJS This seems to be very good indeed. Just downloaded njs but the only njsmodule version I could find was for python 2.1. Does anyone have a recent copy? 1. You might ask here: http://lists.njs-javascript.org/cgi-bin/mailman/listinfo/users 2. Did

Converting from local - UTC

2008-07-11 Thread Keith Hughitt
Hi, I am having a little trouble figuring out how to convert a python datetime to UTC. I have a UTC date (e.g. 2008-07-11 00:00:00). I would like to create a UTC date so that when I send it to MySQL (which treats all dates at local dates by default), it will already have incorporated the proper

imaplib -- can't read body

2008-07-11 Thread Sells, Fred
I'm trying to read mail using the imaplib module. I can get the subject and date, but not the body, have not found any example on how to do that and I don't know much about imap. Here's what I have, working as noted... If anyone can show me what I'm missing in order to get the body of a mail

Re: Python 3.0 and removal of the 'string' module

2008-07-11 Thread Terry Reedy
Ben Finney wrote: Martin v. Löwis [EMAIL PROTECTED] writes: This is rather disappointing. Is that entire page suspect? All documentation about Python 3 is suspect until Python 3 gets actually released (nobody can say for sure how the release will look like in all details). Is there a

Re: Simple question, how do you tell how many items in a list?

2008-07-11 Thread Terry Reedy
Alex Bryan wrote: I am just wondering how you get an integer value for how many items there are in a list, preferably w/o a for loop. Read the library reference sections on built-in functions and classes. -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving to functional programming

2008-07-11 Thread Terry Reedy
[EMAIL PROTECTED] wrote: James Fassett: # the first Pythonic attempt using comprehensions result_list = [x[0] for x in tuple_list] This has the virtue of working for tuples of any length and doing the minimal work required. # the final functional way [result_list, _] = zip(*tuple_list)

Filechooser issues

2008-07-11 Thread Mr SZ
Hi, I am using a gtk.filechooser dialog to open and save files.How do I add a filter so that only images are filtered ?I did something like this:     def get_save_filename(self):         filename = None     chooser = gtk.FileChooserDialog(Save File..., self.window,   

Re: Filechooser issues

2008-07-11 Thread Jerry Hill
On Fri, Jul 11, 2008 at 3:09 PM, Mr SZ [EMAIL PROTECTED] wrote: ff = gtk.FileFilter.add_pixbuf_formats() The documentation doesn't say anything about an argument to be passed: http://www.pygtk.org/docs/pygtk/class-gtkfilefilter.html#method-gtkfilefilter--add-pixbuf-formats I don't know

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Neal Becker
Robert Bossy wrote: class Foo(Freezeable): def __init__(self): self.bar = 42 self.freeze() # ok, we set all variables, no more from here x = Foo() print x.bar x.bar = -42 print x.bar x.baz = OMG! A typo! Pretty nice, but unfortunately the subclass has to remember to call freeze in

Re: Simple question, how do you tell how many items in a list?

2008-07-11 Thread WDC
On Jul 11, 2:53 pm, Terry Reedy [EMAIL PROTECTED] wrote: Alex Bryan wrote: I am just wondering how you get an integer value for how many items there are in a list, preferably w/o a for loop. Read the library reference sections on built-in functions and classes. Quite simple. If I

  1   2   >