Re: Python and Flaming Thunder

2008-05-22 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) Maybe if I have a kid someday I'll teach him Flaming Thunder! (just kidding, you prick). Err... Could we please avoid name calling, gentlemens ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Showing the method's class in expection's traceback

2008-05-22 Thread Bruno Desthuilliers
Agustin Villena a écrit : On May 22, 5:19 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Agustin Villena a écrit : And not that useful - why would one care about the function being defined in class X or Y when one have the exact file and line ? I have 3 reasons: 1) My developing

Re: Calling class method by name passed in variable

2008-05-23 Thread Bruno Desthuilliers
Sagari a écrit : Greetings, Can someone suggest an efficient way of calling method whose name is passed in a variable? method = getattr(obj, 'method_name', None) if callable(method): method(args) -- http://mail.python.org/mailman/listinfo/python-list

Re: Relationship between GUI and logic?

2008-05-23 Thread Bruno Desthuilliers
John Salerno a écrit : I know that it is good programming practice to keep GUI and logic code physically separate, by using XRC for example, but I'm wondering if it's also good practice (and even possible) to keep them separate from an implementation standpoint as well. Basically what I mean

Re: Python is slow

2008-05-23 Thread Bruno Desthuilliers
Brad a écrit : cm_gui wrote: Python is slow. It ain't C++, but it ain't a punch card either... somewhere in between. I find it suitable for lots of stuff. I use C++ when performance really matters tho... right tool for the job. Learn a good interpreted language (Pyhton) and a good compiled

Re: MVC

2008-05-23 Thread Bruno Desthuilliers
George Maggessy a écrit : Hi Gurus, I'm a Java developer and I'm trying to shift my mindset to start programming python. Welcome onboard then. So, my first exercise is to build a website. However I'm always falling back into MVC pattern. And ? Is there anything wrong with web-style MVC ?

Re: Calling class method by name passed in variable

2008-05-23 Thread Bruno Desthuilliers
Nick Craig-Wood a écrit : Bruno Desthuilliers [EMAIL PROTECTED] wrote: Can someone suggest an efficient way of calling method whose name is passed in a variable? method = getattr(obj, 'method_name', None) if callable(method): method(args) I think that that is needless LBYL... From

Re: Python is slow

2008-05-23 Thread Bruno Desthuilliers
Carl Banks a écrit : (snip technically pedantic correction) You know, even though you're technically correct, I'd like to see you abandon this little crusade. At this point it's more noisy than helpful. (snip) Mmm... You're probably right. I tend to be way too pedantic sometimes. OTHO, there

Re: Relationship between GUI and logic?

2008-05-23 Thread Bruno Desthuilliers
John Salerno a écrit : Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Ever heard of the Model/View/Controller pattern ? Yes, I have, but I probably don't understand it well enough yet. For example, I don't really know what is meant by phrases like build

Re: Relationship between GUI and logic?

2008-05-23 Thread Bruno Desthuilliers
David C. Ullrich a écrit : On Fri, 23 May 2008 09:13:50 -0400, John Salerno [EMAIL PROTECTED] wrote: Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Ever heard of the Model/View/Controller pattern ? Yes, I have, but I probably don't understand it well enough yet

Re: Hungarian Notation

2008-05-28 Thread Bruno Desthuilliers
Dan Bishop a écrit : On May 27, 12:28 am, inhahe [EMAIL PROTECTED] wrote: Does anybody know of a list for canonical prefixes to use for hungarian notation in Python? Not that I plan to name all my variables with hungarian notation, but just for when it's appropriate. pnWe vUse adjHungarian

Re: A quick question

2008-05-28 Thread Bruno Desthuilliers
James a écrit : Hey everyone, I just started using python and cant figure this out, I'm trying to make a program where someone types in a word and the program gives it back backwards. For example if the person puts in cat I want the program to give it back as tac and what it does is prints

Re: A quick question

2008-05-28 Thread Bruno Desthuilliers
D'Arcy J.M. Cain a écrit : On Wed, 28 May 2008 10:25:01 - James [EMAIL PROTECTED] wrote: Hey everyone, I just started using python and cant figure this out, I'm trying to make a program where someone types in a word and the program gives it back backwards. For example if the person puts

Re: should I put old or new style classes in my book?

2008-05-30 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Hi All, I am working on a revised edition of How To Think Like a Computer Scientist, which is going to be called Think Python. It will be published by Cambridge University Press, but there will still be a free version under the GNU FDL. You can see the latest

Re: Better performance

2008-06-02 Thread Bruno Desthuilliers
Franck Y a écrit : Hello Folks, I am facing a problem where i need to parse around 200 files, i have a bit of knowledge in PHP/Perl/Python (the magic P :-P) Which one would you suggest me since i have to generate a web interface ? And each one has his area of 'work' And where's your

Re: Why does python not have a mechanism for data hiding?

2008-06-03 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 2, 6:41 am, Carl Banks [EMAIL PROTECTED] wrote: You are not realizing that only useful(**) thing about data hiding is that some code has access to the data, other code does not. If you hide data equally from everyone it's just a useless spelling change. I think

Re: Webpy vs Django?

2008-06-03 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : i have been trying to get Django running for 2 days now and it drives me crazy. i played with webpy a bit and it is easy to get going with. but django seems like once you have it all up and running it will be easier. just that the barrier of entry is much higher.

Re: new to python, looking for streams clues

2008-06-04 Thread Bruno Desthuilliers
Thierry a écrit : Hello peoples, As I said, I'm new to python, and particularly to XML generation in python. Using the 4suite XML package, I have been able to produce XML, but only directly to STDOUT. Refering to the 4suite markupWriter refrence, the class needs a stream to output the

Re: Squeak-like environment for Python?

2008-06-05 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : Jumping Arne wrote: I've been playing with Squeak a bit and I really like the persistent storage model, I also liked HyperCard and Frontier (well, the persistent storage model at least). I wonder if there is some similar environment but based on python, I would like

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Bruno Desthuilliers
Antoon Pardon a écrit : On 2008-06-04, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes, you can live with it, and it does no

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Bruno Desthuilliers
Russ P. a écrit : (snip) (answering to Carl Bank) I thought you were saying that encapsulation or so-called data hiding is worthless. As far as I'm concerned, I view encapsulation as very desirable, and data-hidding as totally worthless when applied to Python's object model. Here's what I

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : [EMAIL PROTECTED] [EMAIL PROTECTED] writes: On 5 juin, 17:40, Gabriel Rossetti [EMAIL PROTECTED] wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. It's

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread Bruno Desthuilliers
Gabriel Rossetti a écrit : Larry Bates wrote: Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 4, 4:29 am, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes, you can live with it, and it does no

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 5, 4:53 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Russ P. a écrit : Given your very recent discovery of what 'dynamic' *really* means in Python (like, for exemple, dynamically adding / replacing attributes - including methods - on a per-class or per

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 5, 2:27 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Thu, 5 Jun 2008 11:36:28 -0700 (PDT), Russ P. [EMAIL PROTECTED] declaimed the following in comp.lang.python: would need to use a mangled name to access private data or methods. But you will be using the name

Re: Newb question: underscore

2008-06-06 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : My question is: Why would anyone decide to obfuscate something as easy to read as Python??? They didn't decide to obfuscate; they decided to follow a strongly-expected convention for the name of that function by existing users of the 'gettext' functionality, in

Re: Newb question: underscore

2008-06-06 Thread Bruno Desthuilliers
John Fabiani a écrit : Skye wrote: What is this doing? print fd, _(__doc__) I'm guessing line-splitting __doc__ into a list, but what's that leading underscore do? Thanks! I think it is standard practice to use the underscore for unicode converts. Actually, it's for i18n, not for

Re: Q re documentation Python style

2008-06-09 Thread Bruno Desthuilliers
kj a écrit : (snip) I think that sometimes even simple functions require a lot of documentation. For example, I want to document a function that takes a dictionary as argument, and this dictionary is expected to have 5 keys. (When the number of mandatory arguments gets above 4, I find that

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Mark Wooding a écrit : Russ P. [EMAIL PROTECTED] wrote: The idea of being able to discern properties of an object by its name alone is something that is not normally done in programming in general. Really? You obviously haven't noticed Prolog, Smalltalk, Haskell, ML, or Erlang then. And

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 8, 5:40 am, Mark Wooding [EMAIL PROTECTED] wrote: Russ P. [EMAIL PROTECTED] wrote: The idea of being able to discern properties of an object by its name alone is something that is not normally done in programming in general. Really? You obviously haven't noticed

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Mark Wooding a écrit : Fuzzyman [EMAIL PROTECTED] wrote: So, you are stating that no API programmer using Python *ever* has a valid or genuine reason for wanting (even if he can't have it) genuine 'hiding' of internal state or members from consumers of his (or her...) API? I don't want to

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 6, 8:25 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: I also realize, by the way, that Python allows a client of a class to define a new class member from completely outside the class definition. Obviously, that cannot be declared private. Why so ? Why

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 9, 2:10 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: But if it takes 6 month to get the mentioned developer to release something I can use, I'm screwed up. Fine. I've lost track of how many times I've said this now, but my suggestion for a priv keyword allowed for

Re: Question by someone coming from C...

2008-06-10 Thread Bruno Desthuilliers
Skye a écrit : Writing this app in Python, not sure what the best practice would be. I want a bitfield global logging level that allows me to turn specific debugging modules on and off. If I was doing this in C, I'd just use some globals like: unsigned int debug_level = 0; #define

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 10, 1:04 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: If you hope to get a general agreement here in favor of a useless keyword that don't bring anything to the language, then yes, I'm afraid you're wasting your time. Actually, what I hope to do is to take

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 10, 11:58 am, Jonathan Gardner (snip) Who cares about private declarations, or interface declarations at all? It is only a message to the developers. If you have a problem with your users doing the right thing, that is a social problem, not a technical one, and the

[OT] Re: Why does python not have a mechanism for data hiding?

2008-06-12 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : On Wed, 11 Jun 2008 10:10:14 +0200, Bruno Desthuilliers [EMAIL PROTECTED] declaimed the following in comp.lang.python: are some *very* talented and *experimented* programmers here. Pardon, but I think you mean experienced. Indeed. Tim Golden already

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Bruno Desthuilliers
Mike Orr a écrit : (snip) 'self' has a .__class__ attribute because it's an instance, but MyClass and Superclass do not because they're already classes. Not true for new-style classes: class Toto(object): pass ... Toto.__class__ type 'type' (snip) I sometimes wish classes had a

Re: My fight with classes :)

2008-06-12 Thread Bruno Desthuilliers
TheSaint a écrit : On 04:51, giovedì 12 giugno 2008 Terry Reedy wrote: First of all a big thank you, all. def makeappender(): data = ['',''] def appender(val): code that mutates data return appender I'll give it a try. I just doubting if the data will be shared outside the

Re: ClassName.attribute vs self.__class__.attribute

2008-06-13 Thread Bruno Desthuilliers
Duncan Booth a écrit : Bruno Desthuilliers [EMAIL PROTECTED] wrote: FWIW, metaclasses do have a class attribute that refers to itself !-) One metaclass (i.e. type) has a class attribute that refers to itself. Other metaclasses have a class attribute that refers to the metaclass's

Re: Comments on my first script?

2008-06-13 Thread Bruno Desthuilliers
Phillip B Oldham a écrit : I'm keen on learning python, with a heavy lean on doing things the pythonic way, so threw the following script together in a few hours as a first-attempt in programming python. I'd like the community's thoughts/comments on what I've done; improvements I can make,

Re: My fight with classes :)

2008-06-13 Thread Bruno Desthuilliers
TheSaint a écrit : On 17:47, giovedì 12 giugno 2008 Bruno Desthuilliers wrote: For multiple functions, use classes. Well... Closures are poor men's objects, or so they say (or is that the other way round ?-). Well, I'd like to know what could be the reason to design a single-call class

Re: Best way to make a number of tests against an object('s attributes) with absence of switch statement?

2008-06-16 Thread Bruno Desthuilliers
Phillip B Oldham a écrit : What would be the optimal/pythonic way to subject an object to a number of tests (based on the object's attributes) and redirect program flow? Say I had the following: pets[0] = {'name': 'fluffy', 'species': 'cat', 'size': 'small'} pets[1] = {'name': 'bruno',

Re: Hard to understand 'eval'

2008-06-16 Thread Bruno Desthuilliers
TheSaint a écrit : On 04:08, domenica 15 giugno 2008 [EMAIL PROTECTED] wrote: what's wrong with getattr(cp, nn) ? The learning curve to get into these programming ways. Does gettattr run the snippet passed in? Nope, it just does what the name implies. Considering that nn is a name of

Re: Hard to understand 'eval'

2008-06-16 Thread Bruno Desthuilliers
TheSaint a écrit : On 01:15, lunedì 16 giugno 2008 Calvin Spealman wrote: such as getattr(obj, methname)(a, b, c). Does this make sense? This is big enlightenment :) Thank you! :) I found problem with eval() when it comes to pass quoted strings. I circumvent that by encapsulating the

Re: NoneType Error

2008-06-16 Thread Bruno Desthuilliers
Gabriel Genellina a écrit : En Sun, 15 Jun 2008 05:35:18 -0300, Maryam Saeedi [EMAIL PROTECTED] escribió: (snip) It appears that you want to catch all exceptions, just use Exception for that: try: ... except Exception: ... Hem... That's definitively *not* an a good advice here IMHO.

Re: Context manager for files vs garbage collection

2008-06-16 Thread Bruno Desthuilliers
Floris Bruynooghe a écrit : Hi I was wondering when it was worthwil to use context managers for file. Consider this example: def foo(): t = False for line in file('/tmp/foo'): if line.startswith('bar'): t = True break return t What would the

Re: Name lookup inside class definition

2008-06-18 Thread Bruno Desthuilliers
WaterWalk a écrit : Hello. Consider the following two examples: class Test1(object): att1 = 1 def func(self): print Test1.att1// ok or print type(self).att1 class Test2(object): att1 = 1 att2 = Test2.att1 // NameError: Name Test2 is not defined It

Re: Function argument conformity check

2008-06-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Hi. I am looking for a way to check if some given set of (*args, **kwds) conforms to the argument specification of a given function, without calling that function. import inspect help(inspect.getargspec) -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for lots of words in lots of files

2008-06-19 Thread Bruno Desthuilliers
brad a écrit : Just wondering if anyone has ever solved this efficiently... not looking for specific solutions tho... just ideas. I have one thousand words and one thousand files. I need to read the files to see if some of the words are in the files. I can stop reading a file once I find 10

Re: An idiom for code generation with exec

2008-06-20 Thread Bruno Desthuilliers
eliben a écrit : Hello, In a Python program I'm writing I need to dynamically generate functions[*] (snip) [*] I know that each time a code generation question comes up people suggest that there's a better way to achieve this, without using exec, eval, etc. Just to make things clear: you

Re: An idiom for code generation with exec

2008-06-20 Thread Bruno Desthuilliers
eliben a écrit : On Jun 20, 9:17 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: eliben a écrit : Hello, In a Python program I'm writing I need to dynamically generate functions[*] (snip) [*] I know that each time a code generation question comes up people suggest that there's

Re: An idiom for code generation with exec

2008-06-23 Thread Bruno Desthuilliers
eliben a écrit : d = {} execcode in globals(), d return d['foo'] My way: return function(compile(code, 'string', 'exec'), globals()) With some help from the guys at IRC I came to realize your way doesn't do the same. It creates a function that, when called, creates 'foo' on

Re: An idiom for code generation with exec

2008-06-23 Thread Bruno Desthuilliers
Maric Michaud a écrit : Le Monday 23 June 2008 09:22:29 Bruno Desthuilliers, vous avez écrit : With some help from the guys at IRC I came to realize your way doesn't do the same. It creates a function that, when called, creates 'foo' on globals(). This is not exactly what I need. I possibly

Re: Passing arguments to subclasses

2008-06-23 Thread Bruno Desthuilliers
John Dann a écrit : May I ask a simple newbie question, which I presume is true, but for which I can't readily find confirmation: Let's say I have a parent class with an __init__ method explicitly defined: class ParentClass(object): def __init__(self, keyword1, keyword2):

Re: newb question on strings

2008-06-25 Thread Bruno Desthuilliers
Dan Bishop a écrit : On Jun 24, 4:04 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Are you trying to escape for a regular expression? Just do re.escape(). print re.escape('Happy') Happy print re.escape(Frank's Diner) Frank\'s\ Diner If you're escaping for URLs, there's urllib2.quote(),

Re: IDE on the level of Eclipse or DEVc++?

2008-06-25 Thread Bruno Desthuilliers
cirfu a écrit : is there an IDE for python of the same quality as Eclipse or DEVC++? I am currently using the editor that coems iwth python and it is all fine but for bigger projects it would be nice to have some way to easier browse the projectfiles for example. If you're into clickodroms,

Re: IDE on the level of Eclipse or DEVc++?

2008-06-25 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : On Jun 25, 12:38 pm, Jorge Godoy [EMAIL PROTECTED] wrote: Ben Finney wrote: Bruno Desthuilliers [EMAIL PROTECTED] writes: If you're into clickodroms, you may want to have a look at Eric too. As far as i'm concerned, I still wait for something that would be worth

Re: recursion in Class-methods?

2008-06-26 Thread Bruno Desthuilliers
klant a écrit : do i need to call Graph.find_path? g = Graph({'A': ['B', 'C'], 'B': ['C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F'], 'F': ['C']}) g __main__.Graph instance at 0x01D74378 g.find_all_paths('A', 'C')

Re: list previous or following list elements

2008-06-27 Thread Bruno Desthuilliers
antar2 a écrit : Hello Suppose I have a textfile (text1.txt) with following four words: Apple balcony cartridge damned paper bold typewriter and I want to have a python script that prints the words following the word starting with the letter b (which would be cartridge) or differently put, a

Re: recursion in Class-methods?

2008-06-27 Thread Bruno Desthuilliers
defn noob a écrit : class Graph(object): where does anyone write like that? Almost everywhere nowadays. I've seen only examples like i have written. Most of the doc has still not been updated since the introduction of newstyle classes years ago. You'll find more here:

Re: list previous or following list elements

2008-06-27 Thread Bruno Desthuilliers
Terry Reedy a écrit : (snip) I believe wordlist = open('words.txt','r').read().split('\n') should give you the list in Python. Or simply: wordlist = open('words.txt').readlines() In any case, wordlist = ['Apple','balcony', 'cartridge', 'damned', 'paper', 'bold', 'typewriter'] for i, word

Re: Adding functions to an existing instance

2008-06-27 Thread Bruno Desthuilliers
Allen a écrit : [EMAIL PROTECTED] wrote: On 26 juin, 17:18, Allen [EMAIL PROTECTED] wrote: I need a way to add a method to an existing instance, but be as close as possible to normal instance methods. def set_method(obj, func, name=None): if not name: name = func.__name__

Re: what is meaning of @ in pyhon program.

2008-06-27 Thread Bruno Desthuilliers
Mike Driscoll a écrit : On Jun 27, 9:48 am, Evan [EMAIL PROTECTED] wrote: HI, When I check example of cmd2 module (a enhancement of cmd module), I can not understand all, for example: the character @, + def options(option_list):

Re: what is meaning of @ in pyhon program.

2008-06-27 Thread Bruno Desthuilliers
Damon Getsman a écrit : Okay, maybe I just didn't understand the websites that were given as examples as to 'decoration'. I first came across the unusual '@' when I was browsing through some extreme beginner's information on os.x method descriptions. I asked some other people about it and they

Re: Using just the Mako part of Pylons?

2008-06-30 Thread Bruno Desthuilliers
John Salerno a écrit : I just installed Pylons onto my hosting server so I could try out templating with Mako, but it seems a little more complicated than that. Err... Actually, it's certainly a little less complicated than that. First point: Mako is totally independant from Pylons. Second

Re: list extension ?

2008-06-30 Thread Bruno Desthuilliers
Stef Mientki a écrit : hello, I basically need a list with a few extra attributes, so I derived a new object from a list, and it works perfect. But I wonder why the newly derived list component is much more flexible ? # so here is the new list object class tGrid_List ( list ) : pep08: class

Re: Why is recursion so slow?

2008-06-30 Thread Bruno Desthuilliers
Dan Upton a écrit : On Sun, Jun 29, 2008 at 1:27 AM, Terry Reedy [EMAIL PROTECTED] wrote: slix wrote: Recursion is awesome for writing some functions, like searching trees etc but wow how can it be THAT much slower for computing fibonacci- numbers? The comparison below has nothing to do with

Re: How do web templates separate content and logic?

2008-06-30 Thread Bruno Desthuilliers
John Salerno a écrit : [EMAIL PROTECTED] wrote: For which definitions of content and logic ??? The point of mvc is to keep domain logic separated from presentation logic, not to remove logic from presentation (which just couldn't work). Templating systems are for presentation logic. Whether

Re: Functions associated with a class.

2008-07-01 Thread Bruno Desthuilliers
Kurda Yon a écrit : Hi, I start to learn the object oriented programing in Python. As far as I understood, every class has a set of corresponding methods and variables. Every object has a set of attributes. Some of these attributes are methods (which are thmeselves objects too), some are

Re: Scope and program structure problems

2008-07-01 Thread Bruno Desthuilliers
John Dann a écrit : Trying to learn Python here, but getting tangled up with variable scope across functions, modules etc and associated problems. Can anyone advise please? Learning project is a GUI-based (wxPython) Python program that needs to access external data across a serial port. The

Re: Scope and program structure problems

2008-07-01 Thread Bruno Desthuilliers
John Dann a écrit : Many thanks for the repsonse - much appreciated. And sorry - yes I was probably compounding two separate issues here - the GUI one and the variable scope one. Maybe the wxPython list would be the best place to ask more about the GUI side of things. Then actually I can

Re: Attribute reference design

2008-07-02 Thread Bruno Desthuilliers
chamalulu a écrit : On Jul 2, 1:17 am, Gary Herron [EMAIL PROTECTED] wrote: No need. Also, you can define a class attribute (C++ might call it a static attribute) and access it transparently through an instance. class C: aClassAttribute = 123 def __init__(self, ...): ... c = C() ...

Re: How to make a function associated with a class?

2008-07-02 Thread Bruno Desthuilliers
Kurda Yon a écrit : On Jul 1, 5:01 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On 1 juil, 22:43, Kurda Yon [EMAIL PROTECTED] wrote: Hi, I have a class called vector. And I would like to define a function dot which would return a dot product of any two vectors. I want to call this

Re: Mako vs. Cheetah?

2008-07-02 Thread Bruno Desthuilliers
Maric Michaud a écrit : Le Saturday 28 June 2008 06:30:50 Tim Roberts, vous avez écrit : Others really like the TAL scheme in Zope. For my taste, TAL just requires too much non-essential syntax; it interferes with the reading of the page. So, the folks who like TAL can go ahead and be

Re: Problem with a for loop and a list

2008-07-02 Thread Bruno Desthuilliers
Alexnb a écrit : I am not sure what is going on here. Here is the code that is being run: def getWords(self): self.n=0 for entry in self.listBuffer: self.wordList[self.n] = entry.get() self.n=self.n+1 print self.wordList def get_words(self):

Re: How do web templates separate content and logic?

2008-07-02 Thread Bruno Desthuilliers
TheDarkTrumpet a écrit : Another thing I'd like to add on this subject. I agree with others here that having logic in the view isn't really a bad thing. I used to think it did, but now I don't think it does as much. I feel that when you're separating out the view, you're giving really

Re: Trouble using pinckle

2008-07-02 Thread Bruno Desthuilliers
Pierre-Alain Dorange a écrit : Cédric Lucantis [EMAIL PROTECTED] wrote: Here self is only a local variable and its meaning is only a convention. So assigning it to a new value won't change the object itself (and is not a good idea as it may be confusing for the reader). Thanks, i was

Re: Times where one would use new style classes vs classic classes

2008-07-03 Thread Bruno Desthuilliers
Quek a écrit : Hi all, I'm really new to Python and I've been reading up some texts on older versions of Python (2.2 to be specific). The text briefly mentioned new style and classic classes. I'd really like to know in the current context of Python 2.5, besides in the cases of

Re: Generating list of possible configurations

2008-07-03 Thread Bruno Desthuilliers
Terry Reedy a écrit : Mensanator wrote: (snip) Lookup Cartesian Product. (snip) for a in [True,False]: for b in [True,False]: for c in [1,2,3,4]: print 'combined settings:',a,'\t',b,'\t',c This has been added to itertools at least for 2.6/3.0 Great ! --

Re: Trouble using pinckle

2008-07-03 Thread Bruno Desthuilliers
Pierre-Alain Dorange a écrit : Bruno Desthuilliers [EMAIL PROTECTED] wrote: I try the staticmethod, it works fine. Very helpful. But i don't like it very much, it seems 'complicated' (python was supposed to be simple). Try doing the same thing in C++ !-) OK ;-) I just ask myself what

Re: site-packages, unzipepd there but import fails

2008-07-03 Thread Bruno Desthuilliers
defn noob a écrit : i unzipped what ? and put the folder which folder in site-packages. which one ? (remember that if you have more than one Python installation on your machine, you'll have more than one site-packages too). when i run setup.py install nothing happens. Well...

Re: Write a file - beginner's question

2008-07-03 Thread Bruno Desthuilliers
Ben Keshet a écrit : I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but might have gotten the syntax wrong. The syntax is:

Re: Newbie, list has no attribute iteritems

2008-07-04 Thread Bruno Desthuilliers
rabad a écrit : Hi, I've created a custom filter based on HTMLParser, with the following source: (snip) But when I use it, it gives me the following error message: ERROR Processor exception: AttributeError: 'list' object has no attribute 'iteritems' (snip) File

Re: Static Class Initialization Question.

2008-07-04 Thread Bruno Desthuilliers
Thomas Troeger a écrit : Hello, I have a class that looks like this: class A(object): def __init__(self, a=0, b=1): self.a, self.b=a, b def __str__(self): return %s(%d,%d) % (type(a).__name__, self.a, self.b) Given the output example you give, I assume there's a

Re: re.search much slower then grep on some regular expressions

2008-07-04 Thread Bruno Desthuilliers
Henning_Thornblad a écrit : What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row= for a in range(156000): row+=a print re.search('[^ =]*/',row) While doing a simple grep: grep

Re: re.search much slower then grep on some regular expressions

2008-07-04 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : Henning_Thornblad a écrit : What can be the cause of the large difference between re.search and grep? This script takes about 5 min to run on my computer: #!/usr/bin/env python import re row= for a in range(156000): row+=a print re.search('[^ =]*/',row

Re: Validation in plone

2008-07-07 Thread Bruno Desthuilliers
Sallu a écrit : Hi all and one, How to do server side validation in plone? Wrong place for Plone related questions. Try the Plone mailing list. -- http://mail.python.org/mailman/listinfo/python-list

Re: yo...

2008-07-07 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) However welcome to Python and this Google Group. OT This is *not* a google group. This is the usenet newsgroup comp.lang.python, made accessible TTW by google. /OT -- http://mail.python.org/mailman/listinfo/python-list

Re: Emacs/Python Essentials?

2008-07-08 Thread Bruno Desthuilliers
Ben Finney a écrit : xkenneth [EMAIL PROTECTED] writes: What does everyone consider essential for emacs python dev? GNU Emacs 22. The 'whitespace-mode' and 'python-mode' are good improvements in that version of Emacs. I've heard good things also about: 'ropemacs'

Re: Regular Expressions Quick Question

2008-07-09 Thread Bruno Desthuilliers
Rajanikanth Jammalamadaka a écrit : (top-post corrected - Please, Rajanikanth, learn to trimquote properly, and by all means avoid top-posting) On Wed, Jul 9, 2008 at 12:13 AM, Lamonte Harris [EMAIL PROTECTED] wrote: Alright, basically I have a list of words in a file and I load each word

Re: a simple 'for' question

2008-07-09 Thread Bruno Desthuilliers
Tim Cook a écrit : On Wed, 2008-07-09 at 00:00 -0400, Ben Keshet wrote: oops, my mistake, actually it didn't work... when I tried: for x in folders: print x # print the current folder filename='Folder/%s/myfile.txt' %x f=open(filename,'r') it says: IOError: [Errno 2] No such

Re: Impossible to change methods with special names of instances of new-style classes?

2008-07-10 Thread Bruno Desthuilliers
samwyse a écrit : On Jul 8, 4:56 pm, Joseph Barillari [EMAIL PROTECTED] wrote: My question is: did something about the way the special method names are implemented change for new-style classes? Just off the top of my head, I'd guess that it's due to classes already having a default __call__

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Bruno Desthuilliers
Phillip B Oldham a écrit : Thanks all - lots to go through there! :D I'd heard previously that Trac was a nice example, or rather its core was, but I'd also heard that there were lots of problems with it and that they were redeveloping it from scratch? Trac's plugin system is interesting,

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Bruno Desthuilliers
Phillip B Oldham a écrit : On Jul 9, 9:26 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: This is somewhat subjective... Some would say that Python's object model is fundamentally broken and crappy (not MHO, needless to say) that Python + solid OO principles is antinomic !-) Really? Would you

Re: python scalability

2008-07-10 Thread Bruno Desthuilliers
Tim Mitchell a écrit : Hi All, I work on a desktop application that has been developed using python and GTK (see www.leapfrog3d.com). We have around 150k lines of python code (and 200k+ lines of C). We also have a new project manager with a C# background who has deep concerns about the

Re: Smal question

2008-07-10 Thread Bruno Desthuilliers
Hans Müller a écrit : Hello group, I have some scripts sharing some common functions. So what I'd like to have is a modern include. Of course python does not have (with good reasons) no include statement. But I'm too lazy to create a module which has to be installed into the interpreter for

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: Does altering a private member decouple the property's value?

2007-06-22 Thread Bruno Desthuilliers
Ethan Kennerly a écrit : Thanks for the help! Using the class name (object) syntax fixed my problem. (snip) I am having to unteach myself some of the defensive programming techniques in C++, such as using name mangling to ensure privacy, when privacy is not the most important criterion.

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