Re: Using dictionary to hold regex patterns?

2008-11-26 Thread Bruno Desthuilliers
André a écrit : (snip) you don't need to use pattern.items()... Here is something I use (straight cut-and-paste): def parse_single_line(self, line): '''Parses a given line to see if it match a known pattern''' for name in self.patterns: result = self.patterns[nam

Re: confused about classes and tkinter object design

2008-11-26 Thread Bruno Desthuilliers
marc wyburn a écrit : Hi, I've created my first Tkinter GUI class which consists of some buttons that trigger functions. I have also created a tkFileDialog.askdirectory control to local a root folder for log files. I have several file paths that depend on the value of tkFileDialog.askdirectory

Re: Requesting direction for installation problem

2008-11-26 Thread Bruno Desthuilliers
Frederic Rentsch a écrit : Hi, Where can one get assistance if a Windows installation service fails to install an msi installer? I used to download zip files, but they seem to have been replaced with msi files. I know this issue is off topic here. So my question simply is: where is it not off

Re: How to get the class instance of a passed method ?

2008-11-25 Thread Bruno Desthuilliers
Arnaud Delobelle a écrit : (snip) .im_self will become example.method.__self__ and in python 3. But I can't see the equivalen of .im_class? At worst, you'll still have example.method.__self__.__class__ !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: zope vs openACS

2008-11-25 Thread Bruno Desthuilliers
Stefan Scholl a écrit : [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: On Nov 19, 1:50 am, gavino <[EMAIL PROTECTED]> wrote: what is nicer about each? Yes. And No. Or maybe ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Module Structure/Import Design Problem

2008-11-25 Thread Bruno Desthuilliers
Rafe a écrit : On Nov 20, 2:06 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: (snip) Or (better IMHO) you can make types register themselves with the factory function (in which case it would have some state so it would make more sense to make it a factory object). Can you elaborate on what

Re: Instance attributes vs method arguments

2008-11-25 Thread Bruno Desthuilliers
M.-A. Lemburg a écrit : (snip) It is always good practice to provide default values for instance variables in the class definition, both to enhance readability and to allow adding documentation regarding the variables, e.g. Your opinion. As far as I'm concerned, using class variables this way i

Re: Clustering the keys of a dict according to its values

2008-11-16 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Bruno Desthuilliers: What is data is another type of sequence or iterable ?-)< The original problem statement was: I did read it, thanks. If the problem changes, then the code has to/can change. When you write code it's better to avoid over-genera

Re: Is this optparse object abuse?

2008-11-16 Thread Bruno Desthuilliers
John O'Hagan a écrit : Hello, I've recently found it convenient to do something like this: (snip) In other words, using the optparse object to hold as attributes everything needed by all the functions and methods in the module, and simply passing it holus bolus to all them and just pulling o

Re: object creation

2008-11-14 Thread Bruno Desthuilliers
BiraRai a écrit : (snip) class box: a = int() b = int() I strongly suggest you read the tutorial. -- http://mail.python.org/mailman/listinfo/python-list

Re: object creation

2008-11-14 Thread Bruno Desthuilliers
BiraRai a écrit : for record in roll: x = box() x.createSomething(record) do something Can anyone tell me why python keeps return the original object x that was created in the FOR loop. Where is the "return" statement ? I want to instantiate a new x object for each iterat

Re: object creation

2008-11-14 Thread Bruno Desthuilliers
Jerry Hill a écrit : On Fri, Nov 14, 2008 at 6:10 PM, BiraRai <[EMAIL PROTECTED]> wrote: class box: a = int() b = int() def createSomething(self,x): At a guess, x = box() does create a new instance of your box class, but since you've declared a and b to be class variables instead of inst

Re: using "private" parameters as static storage?

2008-11-14 Thread Bruno Desthuilliers
Matimus a écrit : On Nov 13, 9:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: (snip) def spam2(): if not hasattr(spam2,'count'):spam2.count=0 spam2.count += 1 return "spam2 " * spam2.count This is definitely preferred over the first. I beg to disagree. This solution stores

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Alternative version: def cluster(data): d = defaultdict(list) pairs = enumerate(data) if isinstance(data, list) else data.iteritems() What is data is another type of sequence or iterable ?-) for k, v in pairs: d[v].append(k) return d By

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Bruno Desthuilliers
Florian Brucker a écrit : Hi everybody! Given a dictionary, I want to create a clustered version of it, collecting keys that have the same value: >>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3} >>> cluster(d) {1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']} That is, generate a new dict which

Re: using "private" parameters as static storage?

2008-11-14 Thread Bruno Desthuilliers
Joe Strout a écrit : One thing I miss as I move from REALbasic to Python is the ability to have static storage within a method s/method/function/ -- i.e. storage that is persistent between calls, but not visible outside the method. I frequently use this for such things as caching, or for ke

Re: Little direction please Python MySQL

2008-11-14 Thread Bruno Desthuilliers
len a écrit : Hi all; I am looking for a little direction in moving from novice python MySQL to real world processing. I can connect to MySQL databases and have performed most of the various select, create, update, insert, etc given the examples in the various books and internet tutorials not t

Re: Finding the instance reference of an object

2008-11-04 Thread Bruno Desthuilliers
Joe Strout a écrit : On Nov 3, 2008, at 5:27 PM, Marc 'BlackJack' Rintsch wrote: Maybe this is a surprise for you, because we haven't discussed this in much detail in this group lately, but it applies to Python which does call-by-object or call-by-sharing. ;-) There's no such thing. Those a

Re: Structures

2008-11-04 Thread Bruno Desthuilliers
Paulo J. Matos a écrit : (snip) However, I wouldn't dare to say Python needs structures to be a good language, or anything similar. My question was more directed to : if there aren't structures in Python, what do Pythonists use instead? (I have seen dicts might be an alternative, Yes, and the

Re: Structures

2008-11-04 Thread Bruno Desthuilliers
Joe Strout a écrit : On Nov 3, 2008, at 4:38 PM, Paulo J. Matos wrote: However, I wouldn't dare to say Python needs structures to be a good language, or anything similar. My question was more directed to : if there aren't structures in Python, what do Pythonists use instead? Classes. or obj

Re: compare items in list to x

2008-11-02 Thread Bruno Desthuilliers
Matt Herzog a écrit : I want a program that loops over a list of numbers (y) and tells me whether each number in the list is less than, greater than or equal to another number (x). In the below code, I can't get python to see that 2 is equal to 2. x = 2 def compare(): for y in ['12',

Re: Finding the instance reference of an object

2008-10-31 Thread Bruno Desthuilliers
greg a écrit : Aaron Brady wrote: Maybe I missed this part. What does the phrase, "value of variable x" mean in Python? I didn't use the phrase "value of variable x" anywhere in my definitions, so it doesn't matter what it means, or even whether it means anything at all. > If "value of 'x'

Re: Default Argument Question

2008-10-29 Thread Bruno Desthuilliers
Chris Rebert a écrit : (snip) Note that the "accumulation" behavior of lists is considered an aberration By who ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Default Argument Question

2008-10-29 Thread Bruno Desthuilliers
Paulo J. Matos a écrit : Hi all, Going through the tutorial brought up a question. Consider the functions: def f(a, L=[]): L.append(a) return L print f(3) print f(9) print f(7) def f1(i = 0): i = i + 1 print i f1() f1() f1() f1() Since the f accumulates the values in L, I wa

Re: Deviation from object-relational mapping (pySQLFace)

2008-10-29 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : On okt. 22, 06:27, huy <[EMAIL PROTECTED]> wrote: (snip) Best use of XML for SQL generation/use I have seen is Ibatis SQLMAPS. This focuses on the right things i.e queries and mapping values to/ from objects. It would be great if python had such a tool. I have lo

Re: explanation of values, references, assignment, and method calls

2008-10-28 Thread Bruno Desthuilliers
Joe Strout a écrit : I've tried to write up this topic in a clear, step-by-step manner, with the help of diagrams and short examples from several different OOP languages. I hope it will help clear up the confusion that seems to be pervading the Python community May I suggest http://effbot.or

Re: Question about scope

2008-10-26 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : In message <[EMAIL PROTECTED]>, Steven D'Aprano wrote: Why is it a class attribute instead of an instance attribute? Singleton class. Possibly, yes (and I believe it is the case, but...). Or the OP doesnt have a good enough understanding of Python's object mod

Re: Question about scope

2008-10-24 Thread Bruno Desthuilliers
Pat a écrit : (snip) Stripping out the extra variables and definitions, this is all that there is. Whether or not this technique is *correct* programming is irrelevant. It's obviously relevant. If it was correct, it would work, and you wouldn't be asking here !-) I simply want to know wh

Re: Python Script Bug

2008-10-23 Thread Bruno Desthuilliers
Chris Rebert a écrit : (snip) 'global' declarations are only allowed (and only make sense) inside a function. Well, they _are_ actually allowed outside a function. But they indeed only make sense within !-) (snip) -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search over a list

2008-10-23 Thread Bruno Desthuilliers
Steve Holden a écrit : Pat wrote: Bruno Desthuilliers wrote: (snip) words = ['foo', 'bar', 'somestring', 'baaz'] re.search(r"^somestring$", "\n".join(words), re.MULTILINE) (snip) I suspect that any(re.match(pat, word)

Re: Question about scope

2008-10-23 Thread Bruno Desthuilliers
Pat a écrit : I have a Globals class. Not sure it's such a great idea, but anyway... What's the use case for this class ? There are perhaps better (or at least more idiomatic) solutions... In it, I have a variable defined something like this: remote_device_enabled = bool Could you show

Re: substitution __str__ method of an instance

2008-10-23 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : Christian Heimes wrote: netimen wrote: How can I substitute __str__ method of an instance? It's not possible. For performance and other reasons most __*__ methods are looked up on the type only. Is that documented somewhere? I *know* it is that way, yet I'd like t

Re: substitution __str__ method of an instance

2008-10-23 Thread Bruno Desthuilliers
netimen a écrit : I couldn't substitute __str__ method of an instance. Though I managed to substitute ordinary method of an instance: from types import MethodType class Foo(object): pass class Printer(object): def __call__(self, obj_self): return 'printed' f = Foo() f.printe

Re: Slow comparison between two lists

2008-10-23 Thread Bruno Desthuilliers
Jani Tiainen a écrit : I have rather simple 'Address' object that contains streetname, number, my own status and x,y coordinates for it. I have two lists both containing approximately 3 addresses. I've defined __eq__ method in my class like this: def __eq__(self, other): return

Re: [APSW] SELECT COUNT(*) not succesfull?

2008-10-23 Thread Bruno Desthuilliers
Gilles Ganault a écrit : On Thu, 23 Oct 2008 00:24:01 -0200, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: In case you didn't notice, B.D. already provided the answer you're after - reread his 3rd paragraph from the end. Yes, but it doesn't work with this wrapper (APSW version 3.5.9-r1): T

Re: Need some advice

2008-10-23 Thread Bruno Desthuilliers
Larry Bates a écrit : azrael wrote: On Oct 22, 9:48 am, Bruno Desthuilliers wrote: azrael a écrit : If my memory is me well http transfers data in plaintext. Because of the risk of datacapturing, is there a better soulutioon to suggest to be more secure like shttp I suppose you mean https

Re: substitution of a method by a callable object

2008-10-22 Thread Bruno Desthuilliers
netimen a écrit : (snip) OK, I have implemented Bruno Desthuilliers example. But there is another question: can I having a method determine if it is an instance of given class. So: As the name imply, a method is usually, well, an instance of type 'method' !-) class Obj(objec

Re: substitution of a method by a callable object

2008-10-22 Thread Bruno Desthuilliers
netimen a écrit : Can I substitute a method of a class by a callable object (not a function)? I can very easy insert my function in a class as a method, but an object - can't. functions implement the descriptor protocol so when looked up as class attributes, the lookup invoke their __get__ met

Re: [APSW] SELECT COUNT(*) not succesfull?

2008-10-22 Thread Bruno Desthuilliers
Gilles Ganault a écrit : Hello I'm trying to use the APSW package to access a SQLite database, but can't find how to check if a row exists. I just to read a tab-separated file, extract a key/value from each line, run "SELECT COUNT(*)" to check whether this tuple exists in the SQLite database, an

Re: Need some advice

2008-10-22 Thread Bruno Desthuilliers
azrael a écrit : There have been some discutions with my partner about which protocol to use. We agreed to use also http. But we are looking for a possibility to use something to trasfer python objects like Json objects. 'like' ??? there are a couple json implementation for Python, and for PHP

Re: Commercial Products in Python

2008-10-21 Thread Bruno Desthuilliers
Paulo J. Matos a écrit : Bruno Desthuilliers wrote: Paulo J. Matos a écrit : Hi all, I was just wondering, if you wish to commercialize an application developed in Python, what's the way to go? I guess the only way is to sell the source, right? Nope, why ? This is because (and tell me

Re: Need some advice

2008-10-21 Thread Bruno Desthuilliers
azrael a écrit : I am starting to work on a application and need some advice. I am planing to develop a desktop application which would have some usage, but also it should be able to comunicate to a web server which hosts a php web application. So I wanted to ask if someone has some expirience w

Re: Commercial Products in Python

2008-10-21 Thread Bruno Desthuilliers
Paulo J. Matos a écrit : Hi all, I was just wondering, if you wish to commercialize an application developed in Python, what's the way to go? I guess the only way is to sell the source, right? Nope, why ? This is because (and tell me if I am wrong): 1) You can't sell an executable because Py

Re: Python equivalent for C module

2008-10-21 Thread Bruno Desthuilliers
Derek Martin a écrit : On Mon, Oct 20, 2008 at 07:29:16PM +0200, Bruno Desthuilliers wrote: This should have been: fprintf(STDERR, "DEBUG: %s", msg); No, it shouldn't have. If I turn on debugging, I want the debug messages to go to stdout, so that they can be captured

Re: indentation

2008-10-21 Thread Bruno Desthuilliers
GHUM a écrit : (snip) Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four

Re: Python certification

2008-10-20 Thread Bruno Desthuilliers
Eric Wertman a écrit : Given the way that medical/legal licensing is used to stifle competition, prevent innovation, and keep people from earning a living delivering simple services that people need at prices they can afford, 'more like' would have to be done very carefully. To draw an analogy.

Re: Python equivalent for C module

2008-10-20 Thread Bruno Desthuilliers
Ville M. Vainio a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> writes: STDOUT is for *normal* program outputs. Debug informations, warnings, and all verbosity should go to STDERR. Actually, stderr is for errors, by convention. It's rather impolite to dump trivial debug inf

Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-20 Thread Bruno Desthuilliers
Eric Wertman a écrit : I (again) wonder what's the perfect way to store, OS-independent, filepaths ? I'm in agreement that perfect probably isn't applicable. If I were doing this myself, I might store the information in a tuple: base = 'some root structure ('/' or 'C') make it "C:\" path

Re: Python equivalent for C module

2008-10-20 Thread Bruno Desthuilliers
Derek Martin a écrit : I'd like to know if it's possible to code something in Python which would be equivalent to the following C: [Assume bool is typedef'd to int, and TRUE and FALSE are #defined to 1 and 0, respectively] debug.c #include bool DEBUG; void dprint(char *msg) {

Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Bruno Desthuilliers
Stef Mientki a écrit : (snip) I'm very satisfied with Python, and must say it's much more beautiful language than Delphi, seen over the full width of programming. Although both languages are Object Oriented, I think you can lowercase those two last words - it's not a religion, you know ?-)

Re: Porting VB apps to Python for Window / Linux use

2008-10-20 Thread Bruno Desthuilliers
Stef Mientki a écrit : Lawrence D'Oliveiro wrote: In message <[EMAIL PROTECTED]>, Dotan Cohen wrote: I often see mention of SMBs that either want to upgrade their Windows installations, or move to Linux, but cannot because of inhouse VB apps. Probably best to leave those legacy VB app

Re: Python certification

2008-10-20 Thread Bruno Desthuilliers
Eric Wertman a écrit : On Mon, Oct 20, 2008 at 3:52 AM, olive <[EMAIL PROTECTED]> wrote: Certification prooves you're an idiot who needs to spend money to work for another idiot who doesn't know enough about programming to know if they hire competent programmers and need an idiot paper to make t

Re: Can i use this script as a python evaluator?

2008-10-20 Thread Bruno Desthuilliers
Peter Wang a écrit : #! /bin/sh python -c "import sys;exec(sys.stdin)" Emacs has a function `shell-command-on-region', which takes region as input for the evaluator (script above), and output its result. I have tried and found it works, is there any problems for this, or any other better solut

Re: question regarding list comprehensions

2008-10-20 Thread Bruno Desthuilliers
Pat a écrit : I have written chunks of Python code that look this: new_array = [] for a in array: if not len( a ): continue new_array.append( a ) # à la lisp new_array = filter(None, array) # à la haskell new_array = [a for a in array if a] NB : all built

Re: re.search over a list

2008-10-20 Thread Bruno Desthuilliers
Pat a écrit : Bruno Desthuilliers wrote: Pat a écrit : While I can use a for loop looking for a match on a list, I was wondering if there was a one-liner way. In particular, one of my RE's looks like this '^somestring$' so I can't just do this: re.search( '^

Re: regexp in Python (from Perl)

2008-10-20 Thread Bruno Desthuilliers
Pat a écrit : Bruno Desthuilliers wrote: Pat a écrit : I have a regexp in Perl that converts the last digit of an ip address to '9'. This is a very particular case so I don't want to go off on a tangent of IP octets. ( my $s = $str ) =~ s/((\d+\.){3})\d+/${1}9/ ; While I

Re: indentation

2008-10-20 Thread Bruno Desthuilliers
Duncan Booth a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Ross Ridge a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: I can't remember having seen any other "standard" so far. I've seen various indentation styles used in examples on thi

Re: indentation

2008-10-20 Thread Bruno Desthuilliers
Ross Ridge a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: I can't remember having seen any other "standard" so far. Ross Ridge a écrit : I've seen various indentation styles used in examples on this newsgroup. Bruno Desthuilliers <[EMAIL PROTECTED

Re: default value in __init__

2008-10-20 Thread Bruno Desthuilliers
David C. Ullrich a écrit : In article <[EMAIL PROTECTED]>, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: (snip) Well... How to say.. Is there any chance these people will read anything *at all* ? No. That's exactly the point! Yeps. But I don't think we derive the

Re: indentation

2008-10-20 Thread Bruno Desthuilliers
Ross Ridge a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: I can't remember having seen any other "standard" so far. I've seen various indentation styles used in examples on this newsgroup. I meant: in a real-life project. -- http://mail.python.org/mailman/listinfo/python-list

Re: indentation

2008-10-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Sun, 19 Oct 2008 19:03:29 +0200, Bruno Desthuilliers wrote: Steven D'Aprano a écrit : (snip) You can use tabs, or spaces. If you use spaces, you can choose 4 spaces, or 8, or any number, By all means, make it 4 spaces - that's the standard. It

Re: regexp in Python (from Perl)

2008-10-20 Thread Bruno Desthuilliers
MRAB a écrit : On Oct 19, 5:47 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Pat a écrit : (snip) ip = ip[ :-1 ] ip =+ '9' or: ip = ip[:-1]+"9" (snip) >>> re.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.1")

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-20 Thread Bruno Desthuilliers
Sebastian Wiesner a écrit : At Thu, 16 Oct 2008 18:21:38 +0200 wrote Bruno Desthuilliers <[EMAIL PROTECTED]>: It doesn't look like there's any way to browse the subversion any more, though. Doh :( Is there any way to get this version then ??? svn co https://python-mode.svn

Re: indentation

2008-10-19 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : (snip) You can use tabs, or spaces. If you use spaces, you can choose 4 spaces, or 8, or any number, By all means, make it 4 spaces - that's the standard. -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search over a list

2008-10-19 Thread Bruno Desthuilliers
Pat a écrit : While I can use a for loop looking for a match on a list, I was wondering if there was a one-liner way. In particular, one of my RE's looks like this '^somestring$' so I can't just do this: re.search( '^somestring$', str( mylist ) ) I'm not smart enough (total newbie) to code u

Re: indentation

2008-10-19 Thread Bruno Desthuilliers
Gandalf a écrit : every time I switch editor all the script indentation get mixed up, and python start giving me indentation weird errors. indentation also hard to follow because it invisible unlike brackets { } is there any solution to this problems? Properly configure your eidtors to use

Re: regexp in Python (from Perl)

2008-10-19 Thread Bruno Desthuilliers
Pat a écrit : I have a regexp in Perl that converts the last digit of an ip address to '9'. This is a very particular case so I don't want to go off on a tangent of IP octets. ( my $s = $str ) =~ s/((\d+\.){3})\d+/${1}9/ ; While I can do this in Python which accomplishes the same thing: i

Re: Python certification

2008-10-17 Thread Bruno Desthuilliers
srinivasan srinivas a écrit : Hi, I m planning to do certification in Python?? Is therr any good certification available in Python like Sun certification for java?? Yes, indeed : actively contribute to some major python project (or even better to the language itself or its stdlib), and become

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-16 Thread Bruno Desthuilliers
rustom a écrit : (snip) I am interested in knowing which mode supports better the use of pdb inside emacs? Since you mention this, I think I remember having a couple issues here with python-mode.el - but that was a long time ago, and I usually don't use pdb within the emacs-python-shell (mos

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-16 Thread Bruno Desthuilliers
Carl Banks a écrit : On Oct 14, 1:05 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: - a slightly less but still annoying problem (I wouldn't call it a bug) is the handling of indentation for nested litteral dicts/lists/tuples. The python-mode.el on Subversion (python-mode&#

Re: install Django under PYTHONPATH

2008-10-16 Thread Bruno Desthuilliers
limas a écrit : please help me.. i want to install django under PYTHONPATH with out root permission. Can i do it without setup.py You don't need root permissions to edit your own PYTHONPATH. It's just an environment variable, you know ?-) -- http://mail.python.org/mailman/listinfo/python-

Re: OOP books?

2008-10-16 Thread Bruno Desthuilliers
Asun Friere a écrit : On Oct 16, 7:12 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: [snip] Not a word about Python in it, but:http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-... A must-read if you want to understand OO (MHO of course). Yes, if only to s

Re: OOP books?

2008-10-15 Thread Bruno Desthuilliers
Ken D'Ambrosio a écrit : Hi, all. Over the years, I've programmed in a fair number of languages; the ones with which I became most familiar were assembler, BASIC, Pascal, and "lately" (the last fifteen years or so) Perl. Now I'm trying my hand at Python. While I don't have any problems with

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-15 Thread Bruno Desthuilliers
Paul Rubin a écrit : [EMAIL PROTECTED] writes: If you're an Emacs user who has used both python-mode.el (the python mode code distributed with Python and XEmacs) and python.el (the python mode code distributed with GNU Emacs), I'd like to get your impressions on how they compare and where you fe

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-15 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: If you're an Emacs user who has used both python-mode.el (the python mode code distributed with Python and XEmacs) and python.el (the python mode code distributed with GNU Emacs), I'd like to get your impress

Re: File Management

2008-10-15 Thread Bruno Desthuilliers
erict1689 a écrit : I am writing this program in which I open up a file and update that information but to a new file. I already have a global variable for it A global variable ??? WHY ??? but how do I go about creating an openable file in the source code? It's in the FineManual(tm) If

Re: recommendations for a web CMS (content management system)?

2008-10-15 Thread Bruno Desthuilliers
Joe Strout a écrit : We need to set up a content management system that allows nontechnical users to manage the content of their web site. Rather than starting from scratch, I'd prefer to start with an existing CMS that we can extend as needed. So, I'd prefer something with nice clean, easy-

Re: Deviation from object-relational mapping (pySQLFace)

2008-10-15 Thread Bruno Desthuilliers
J Peyret a écrit : On Oct 12, 8:19 am, [EMAIL PROTECTED] wrote: I would like to get some opinions on this approach. Thanks. I realize I will be minority here, but... Then count me in - as long as all SQL stuff is cleanly encapsulated in it's own module and called via appropriate functions

Re: replace mothod for only one object but not for a class

2008-10-15 Thread Bruno Desthuilliers
hofer a écrit : Hi hofer a écrit : I have multiple objects all belonging to the same class (which I didn't implement and whose code I don't want to modify) Now I'd like to change one method for one object only (after it has been created) without adding any overhead to the call of the other ob

Re: replace mothod for only one object but not for a class

2008-10-15 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : hofer a écrit : Hi, I have multiple objects all belonging to the same class (which I didn't implement and whose code I don't want to modify) Now I'd like to change one method for one object only (after it has been created) without adding any overh

Re: replace mothod for only one object but not for a class

2008-10-15 Thread Bruno Desthuilliers
George Sakkis a écrit : (snip) You're right of course; that's what you get with minimal testing ;) Still it works with a small modification, binding self to b as default argument: b.foo = lambda self=b: "modified called on %s" % self Ok, now with a real use case : use a named function instead

Re: Win32api.MessageBox

2008-10-15 Thread Bruno Desthuilliers
Unkwntech a écrit : When I use win32api.MessageBox from the interactive console from an app that runs at the command line, it works and displays my alert just fine however when I use it in a service that I built I can hear the 'beep' but the alert does not show and the program seems to stall wait

Re: replace mothod for only one object but not for a class

2008-10-14 Thread Bruno Desthuilliers
Christian Heimes a écrit : Bruno Desthuilliers wrote: If the class is a new-style one [1], it just requires invoking the descriptor protocol by yourself to get a bound method, ie: Another note about new style classes: You can NOT overwrite most magic methods (__*__) on the instance. Most

Re: default value in __init__

2008-10-14 Thread Bruno Desthuilliers
David C. Ullrich a écrit : In article <[EMAIL PROTECTED]>, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: David C. Ullrich a écrit : (snip) Seems to me that people often site the "important warning" in the tutorial. Of course there's no reason anyone wou

Re: Emacs users: feedback on diffs between python-mode.el and python.el?

2008-10-14 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : If you're an Emacs user who has used both python-mode.el (the python mode code distributed with Python and XEmacs) and python.el (the python mode code distributed with GNU Emacs), I'd like to get your impressions on how they compare and where you feel the bugs lie. I'

Re: replace mothod for only one object but not for a class

2008-10-14 Thread Bruno Desthuilliers
hofer a écrit : Hi, I have multiple objects all belonging to the same class (which I didn't implement and whose code I don't want to modify) Now I'd like to change one method for one object only (after it has been created) without adding any overhead to the call of the other object's methods.

Re: replace mothod for only one object but not for a class

2008-10-14 Thread Bruno Desthuilliers
George Sakkis a écrit : On Oct 14, 1:50 pm, hofer <[EMAIL PROTECTED]> wrote: Hi, I have multiple objects all belonging to the same class (which I didn't implement and whose code I don't want to modify) Now I'd like to change one method for one object only (after it has been created) without a

Re: Deviation from object-relational mapping (pySQLFace)

2008-10-14 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) It is not convincing to look at an XML file alone. Let me give you an example. Glade is a GTK+ application for creating GTK+ GUI. It generates an XML file, that can be loaded in every programming language that has libglade binding. Similarly, there could be a da

Re: Question

2008-10-13 Thread Bruno Desthuilliers
Aditi Meher a écrit : Hello How to write code to store data into buffer using python? A text/code editor might be useful. -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion for s/the PythonDevelopment for next version/azrael

2008-10-13 Thread Bruno Desthuilliers
azrael a écrit : You know, sometimes it annoys me to write a for loop in Python. If we use a list a=[1,2,3,4], and want to loop through it, Python offers the next option for i in a: print i 1 2 3 4 I love this. So simple and smooth. But what happens if we need also the position of an object

Re: Append a new value to dict

2008-10-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : jdd: foo = {'bar': 'baz'} foo.update({'quux': 'blah'}) That creates a new dict, to throw it away. Just to make it clear for the easily confused ones (like me...): bearophile is talking about the dict passed as an argument to foo.update - not about the behaviour

Re: Deviation from object-relational mapping (pySQLFace)

2008-10-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : I have made a simple python module to handle SQL databases: https://fedorahosted.org/pySQLFace/wiki Its goal to separate relational database stuff (SQL) from algorythmic code (python). A SQLFace is a facade initialized with a configuration file (XML). It provides calla

Re: Deviation from object-relational mapping (pySQLFace)

2008-10-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : I have made a simple python module to handle SQL databases: https://fedorahosted.org/pySQLFace/wiki Its goal to separate relational database stuff (SQL) from algorythmic s/algorythmic/algorithmic !-) code (python). A SQLFace is a facade initialized with a configur

Re: python debugger tips?

2008-10-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Hi All, I'm switching to python from perl, and like the language a ton, but I find pdb and pydb to be vastly inferior debuggers to the perl version. In particular, I've grown very used to stepping into arbitrary functions interactively. For instance, in perl you can

Re: a regular expression problem

2008-10-10 Thread Bruno Desthuilliers
lookon a écrit : I want to use django to dispatch url. The url is like /test/Google/6,and my patten is r'^/test/(?P\b\W+ \b)/(?P\d+)$'. It works when the string is English(like Google), but fails when the string is in foreign language. Care to give an exemple of url that fails ? Anyway, if you

Re: default value in __init__

2008-10-10 Thread Bruno Desthuilliers
David C. Ullrich a écrit : In article <[EMAIL PROTECTED]>, kenneth <[EMAIL PROTECTED]> wrote: On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote: kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing

Re: Debugging suggestions, efficiency - handling modules

2008-10-10 Thread Bruno Desthuilliers
John [H2O] a écrit : Hello, I am writing some scripts that run a few calculations using scipy and plot the results with matplotlib (i.e. pylab). What I have found, however, is that the bulk of the time it takes to run the script is simply in loading modules. Is this loading time really that h

Re: inspect feature

2008-10-10 Thread Bruno Desthuilliers
Aaron "Castironpi" Brady a écrit : On Oct 9, 3:48 am, Bruno Desthuilliers wrote: Aaron "Castironpi" Brady a écrit : Hello, The 'inspect' module has this method: inspect.getargvalues(frame) It takes a frame and returns the parameters used to call it, includin

Re: NameError question - def(self,master) - master not in namespace within class?

2008-10-09 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : bieffe, please, learn to snip irrelevant material... On 9 Ott, 17:43, harijay <[EMAIL PROTECTED]> wrote: (snip) NameError: name 'master' is not defined" (snip) #File runner.py #!/usr/bin/python import master import child if __name__=="__main__": print

Re: default value in __init__

2008-10-09 Thread Bruno Desthuilliers
kenneth a écrit : On Oct 9, 10:14 am, Christian Heimes <[EMAIL PROTECTED]> wrote: kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing some stupid error, or this is a problem ? No, it always contains the default a

<    3   4   5   6   7   8   9   10   11   12   >