Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Bruno Desthuilliers
Ilias Lazaridis a écrit : bruno modulix wrote: Ilias Lazaridis wrote: (snip) impressive. but things are much simpler. Could you be more prolific ? Please explain the word "prolific". Say more -- http://mail.python.org/mailman/listinfo/python-list

Re: Variables.

2005-02-15 Thread Bruno Desthuilliers
Jeff Shannon a écrit : bruno modulix wrote: administrata wrote: I wrote this, It's a bit lame though (snip code - see other answers in this thread) raw_input("\n\\t\t\t- The End -") Why on earth are you using raw_input() here ? This is a fairly common idiom, on Windows at least. Windows only, I

Re: Ruby on Rails or Perl's Maypole..is there a Python equivalent

2005-03-03 Thread Bruno Desthuilliers
Gary Nutbeam a écrit : I've noticed that the Perl camp has a very nice web/database environment called Maypole. Ruby has the Rails environment which on the surface seems similar to Maypole. I can't find anything in Python that ties a database to a web interface anywhere near as well as Ruby on Rail

Re: (Newbie) Restricting inherited methods to operate on element from same subclass

2005-03-11 Thread Bruno Desthuilliers
andy2o a écrit : Hi all, Sorry if the post's title is confusing... I'll explain: I have a class, called A say, and N>1 subclasses of A, called A1, A2, A3, ..., AN say. Instances of each subclass can sensibly be joined together with other instances of the *same subclass*. The syntax of the join me

Re: storing large amounts of data in a list/dictionary

2005-03-11 Thread Bruno Desthuilliers
flamesrock a écrit : Hi, Basically, what I'm trying to do is store large amounts of data in a list or dictionary and then convert that to a custom formatted xml file. My list looks roughly like this: (d[],r[c[d[p[],p[R,C,I) My question is, would it be faster to use a dictionary if the elements

Re: Python becoming less Lisp-like

2005-03-14 Thread Bruno Desthuilliers
news.sydney.pipenetworks.com a Ãcrit : I looked for a new language for my hobby programming. I used to use Turbo Pascal for 10 years and then C++ for 6 years. A couple of weeks ago, I narrowed my decision to C#, Ruby, and Python. At the moment, I want to go with Python, but you can definitely s

Re: Python becoming less Lisp-like

2005-03-15 Thread Bruno Desthuilliers
Valentino Volonghi aka Dialtone a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: It is actually. Ruby's syntax is mostly consistent and coherent, and there is much less special cases than in Python. I'd be glad to know which special cases are you referring to. A f

Re: Python becoming less Lisp-like

2005-03-15 Thread Bruno Desthuilliers
Martin Franklin a écrit : Tim Daneliuk wrote: In-Reply-To: <[EMAIL PROTECTED]> (snip) Of course we users will complain about removals, but we'll knuckle down and take our medicine eventually ;-) Except that in this case, removal will also complicate code in some cases. Consider this fragment of Tk

Re: readonly class attribute ?

2005-03-15 Thread Bruno Desthuilliers
Simon Percivall a écrit : Start the attribute name with "_" and don't document it. If clients mess with it, they're to blame. The problem is that client code must *define* this attribute when subclassing BaseClass - and that's (well, in most case that should be) the only place where they have to

Re: readonly class attribute ?

2005-03-15 Thread Bruno Desthuilliers
Bengt Richter a écrit : On Tue, 15 Mar 2005 20:21:19 +0100, bruno modulix <[EMAIL PROTECTED]> wrote: Hi How can I make a *class* attribute read-only ? (snip) Does this help, or did I misunderstand? >>> class Base(object): ... class __metaclass__(type): ... def __setattr__(cls, name,

Re: Variable Variable

2005-03-19 Thread Bruno Desthuilliers
Tanteauguri a écrit : Hi List, is there in python a variable variable like in PHP ($$var)? Hopefully, no. See other answers in that thread for pythonic idioms. -- http://mail.python.org/mailman/listinfo/python-list

Re: Obfuscated Python: fun with shadowing builtins

2005-03-19 Thread Bruno Desthuilliers
fraca7 a écrit : Michael Hoffman wrote: Enjoy ;) That's not the exact word that first came to my mind :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Anonymus functions revisited

2005-03-22 Thread Bruno Desthuilliers
Ron a écrit : (snip) def dfv( arg = value): return arg > >>> def dfv( arg = value): ... return arg ... Traceback (most recent call last): File "", line 1, in ? NameError: name 'value' is not defined And sorry, but -1 for using exec here. -- http://mail.python.org/mailman/listinfo

Re: Anonymus functions revisited

2005-03-22 Thread Bruno Desthuilliers
Ron a écrit : On 21 Mar 2005 22:37:42 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: Mappings like that: ((x,y),z) -> x+y-z ((x,y=0),z) -> None should be valid actions too. What is the audience thinking about that? I think that there's too much implied, and that in the long run it, if we k

Re: Anonymus functions revisited

2005-03-22 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : (snip) You are right, but for lambda in its current limited form short, named functions are a good replacement. -inf on this !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert the contents of a string into name of variable

2005-03-27 Thread Bruno Desthuilliers
Erwan VITIERE a écrit : Hello, I want to convert the contents of a string into name of variable. For example: var1="toto" ... toto=5 print toto exec "toto = 5" print toto But I would use another solution if possible. -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem in designing a global directory in python

2005-03-29 Thread Bruno Desthuilliers
Tian a écrit : I want to create a object directory called Context in my program, which is based on a dict to save and retrieve values/objects by string-type name. I have the definition like this: utils.py global sysctx class Context: def __init__(self): def set(self, na

Re: Problem in designing a global directory in python

2005-03-30 Thread Bruno Desthuilliers
Tian a écrit : I googled about how to write singleton in python, but even if I use Singleton, in which module's namespace should I keep the instance of this singleton? You found the doc but I'm afraid you did not grasp the concept. You don't have to 'keep the instance' anywhere - it's the job of t

Re: Problem in designing a global directory in python

2005-03-30 Thread Bruno Desthuilliers
'@'.join([..join(['fred','dixon']),..join(['gmail','com'])]) a écrit : noob warning: what is so wonderful about the NEW class over the old ? A whole lot of things. But the main thing to know is that old-style classes are deprecated, and will disappear in the future. -- http://mail.python.org/mailm

Re: Help understanding code

2005-04-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Reading the language tututorial would help you a lot :( === what is the difference between pc and pc()? pc = getToolByName() - returnes a refference to a method Nope. pc is a refference to a method, Nope. pc is not 'a reference to a method', it's a callable object

Re: How to debug SOAP using TCpMon and Python?

2005-04-14 Thread Bruno Desthuilliers
Jim a écrit : Hello, I am trying to debug a Python SOAP What about unit tests ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a perl module to a python module would it be worthit?

2005-04-14 Thread Bruno Desthuilliers
Mothra a écrit : (snip) I checked out the above link (thanks!!) I need to look deeper at the docs for creating a "module" Well, start with wrting the code - you'll take care of how-to-distribute-it later. Thanks all for the responses!! You're welcome. -- http://mail.python.org/mailman/listinfo/p

Re: Using python from a browser

2005-04-14 Thread Bruno Desthuilliers
Philippe C. Martin a écrit : Hi, I have a python script I wish to call from various browsers (IE; Mozilla, Firefox ..) on Windows & Linux. What do you mean ? Is that a client-side or server-side script ? I read that IE had the capability to embedd Python scripts, Where ? -- http://mail.python.o

Re: Python or PHP?

2005-04-24 Thread Bruno Desthuilliers
Mage a écrit : I can tell: - python is more *pythonic* than php Keyboard !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python or PHP?

2005-04-24 Thread Bruno Desthuilliers
Lad a trollé : Is anyone capable of providing Python advantages over PHP if there are any? Why don't you check by yourself ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Which IDE is recommended?

2005-04-27 Thread Bruno Desthuilliers
monkey a écrit : Read through python site for programming tool, really plenty of choices :-) (For c++, I just can't breath with very very limited choices) Tried Spe, it come with wxGlade built-in very nice(is Spe still actively develop?). But seem that Boa Constructor and PyDev(the plug-in for Ecli

Re: OO in Python? ^^

2005-12-11 Thread Bruno Desthuilliers
Matthias Kaeppler a écrit : > Hi, > > sorry for my ignorance, but after reading the Python tutorial on > python.org, I'm sort of, well surprised about the lack of OOP > capabilities in python. I beg your pardon ??? > Honestly, I don't even see the point at all of > how OO actually works in P

Re: OO in Python? ^^

2005-12-11 Thread Bruno Desthuilliers
Matthias Kaeppler a écrit : (snip) > I stumbled over this paragraph in "Python is not Java", can anyone > elaborate on it: > > "In Java, you have to use getters and setters because using public > fields gives you no opportunity to go back and change your mind later to > using getters and sette

Re: Newbie with some doubts.

2006-01-09 Thread Bruno Desthuilliers
Edgar A. Rodriguez a écrit : > Hi everybody, > > Im newbie to Python (I found it three weeks ago) , in fact Im newbie to > programming. I'm being reading and training with the language, but I > still wondering about what Classes are used to. A class is the definition of a type of object, and let

Re: Help with dynamic attributes.

2006-01-09 Thread Bruno Desthuilliers
Mr.Rech a écrit : (snip) > > My class's init method takes a list of lists as input argument and I'd > like to create > several attributes each one referencing one item of the passed list. > > Easy-of-use arguments > has led me to call these attributes as x0, x1, x2 and so on. This is a very wro

Re: Abuse of the object-nature of functions?

2006-07-11 Thread Bruno Desthuilliers
xceptions hierarchy in the fine manual - you'll notice some exception you perhaps don't want to catch or at least don't want to display (hint: look for the warnings hierarchy and for SysExit...) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating all ordered substrings of a string

2006-07-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi, > I want to generate all non-empty substrings of a string of length >=2. > Also, > each substring is to be paired with 'string - substring' part and vice > versa. > Thus, ['abc'] gives me [['a', 'bc'], ['bc', 'a'], ['ab', 'c'], ['c', > 'ab'], ['b', 'ac'], ['ac',

Re: import and global namespace

2006-07-11 Thread Bruno Desthuilliers
nate a écrit : > I'd like a module than I'm importing to be able to use objects in the > global namespace into which it's been imported. is there a way to do > that? It's a very bad idea. Instead of asking how to implement a bad solution, tell us about the real problem. NB : FWIW, the clean sol

Re: Object Persistence Using a File System

2006-07-12 Thread Bruno Desthuilliers
olution. I also wonder how (if...) you intend to address concurrent R/W access and transactions... A few observations and questions : - you should avoid tests on concrete types as much as possible - at least use isinstance - tuples are immutable containers. What about them ? - what about multiple

Re: import and global namespace

2006-07-12 Thread Bruno Desthuilliers
Dennis Lee Bieber wrote: > On Wed, 12 Jul 2006 02:48:44 +0200, Bruno Desthuilliers > <[EMAIL PROTECTED]> declaimed the following in > comp.lang.python: > > >>nate a écrit : >> >>>I'd like a module than I'm importing to be able to use obj

Re: Accessors in Python (getters and setters)

2006-07-12 Thread Bruno Desthuilliers
ted 'tmp' to be part of the API, then you're responsible for the bad naming. If you didn't, then you're responsible for breaking the encapsulation - FWIW, following the convention (single leading underscore) could have make it clearer to you. In both cases, you happily used a bad name in 27 KLOC - so you really had a lot of time and occasions to notice something wrong with this. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Data access from multiple code modules

2006-07-12 Thread Bruno Desthuilliers
times). Well, actually one can do MVC without OO. It's more a matter of separating concerns. Now I agree that it's not always obvious to know for sure which part should be responsible for what... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Persistant dictionary with lockable elements

2006-07-12 Thread Bruno Desthuilliers
t; Is there some way of using Shelve like this, or should I just move to a > more typical database solution? You may want to try with the ZODB. Or with SQLite. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]

Re: Data access from multiple code modules

2006-07-12 Thread Bruno Desthuilliers
s around instead of having a big global datastructure. Classes are handy when many functions needs to share state (work on a same dataset), but there's no way to have one call the other and pass it the dataset. > but it's hard to get out of that mentality. Seems you're on the right

Re: check type when assignment

2006-07-12 Thread Bruno Desthuilliers
raise >>a exception. > > > In general, not doable. The assignment operator is not overloadable. > > Only if you use assignments of the form > > a.foo = bar > > you could overwrite the __setattribute__-method (Or use a Descriptor) > to achieve what you want.

Re: Too many imports to use a business class library?

2006-07-13 Thread Bruno Desthuilliers
lopper problem - put closely related symbols in a same module - put closely related modules in a same package > a single import and you are able to use > all the classes? Python as packages: http://docs.python.org/tut/node8.html#SECTION00840 > Is there anything wr

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
d attributes ? > 90% of public APIs in almost all > languages are methods or functions. "allmost all languages" lacks computed attributes. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
on and > never changed. Stuff happens. > > Maybe you didn't know about the underscore way to mark private entities. > Maybe this doesn't work as I think it does If you think that single leading underscores have a special meaning for the compiler/interpreter, then you got

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
;_' *is* API. >> >>Right, and what if I want to change a private API to a public one. How >>does that solve my naming issues. > > > Then you have to change all references to that private attribute. Not even - cf my answer on this point. -- bruno desthuill

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
tribute style would break all client code. Having the two schemes coexisting would make for bloated APIs and too-many-ways-to-do-it. So we live with this until Py3K. And none of these considerations contradicts the point that there's no more use for javaish getters/setters in Python, nor that javaish getters/setters are not pythonic. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >> >>>Lousy Attribute Name: >>> self.tmp >>> >>>Accessors: >>> set_temporary_buffer >>> get_temporary_buffer >>> >>

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >> >>>Marc 'BlackJack' Rintsch wrote: >>> >>> >>>>In <[EMAIL PROTECTED]>, mystilleef >>>>wrote: >>>> >>>> >>&

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >>(snip) >> >>>Python doesn't have any philosophy with regards to naming identifiers. >> >>Yes it does. > > > No it doesn't. > > >>>>But they

Re: Data access from multiple code modules

2006-07-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Bruno Desthuilliers wrote: > > >>Do you mean the code effectively doing these operations is in the gui ? >>If yes, it would be better to factor it out IMHO. > > The GUI has to be able to acces the data object, otherwise how does the >

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >> (snip) >>>> >>>>>I have used that name in >>>>>dozens of places spanning over 27000 LOC. >>>> >>>>Too bad for you. >>> >>&g

Re: Data access from multiple code modules

2006-07-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Bruno Desthuilliers wrote: > > >>Separating operations on data (model/controler) from GUI code (view). >>The controler(s) have a reference on the model. The views have a >>reference on the controler(s), and call on the controller to get data

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>>>You choose a bad name for a *public* symbol. >>> >>> >>>My point exactly! It doesn't solve my problem! >> >>What do you hope ? Something that cures cancer ? Please enlighten us an

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
ia "properties". If you need to control anything - else just use a plain attribute. > That's the pythonic way to implement > accessors and mutators > > I guess people who've done medium to large scale programming in Python > already know this. Do 50

Re: How to have application-wide global objects

2006-07-13 Thread Bruno Desthuilliers
, create the 'singleton' in it's module (at the module's to level), then import the module. > Trying hard, I am not even being able to figure out how to create an > object in one module and refer the same in another one. "import" > created a new object, as I trie

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Bruno Desthuilliers
t Python > sucks. Neither those it suggest that Java or other OO languages are > better. I asked because I sincerely wanted to know the Pythonic way > handling issues like that. Mark as implementation what is obviously implementation (be it callable or not), mark as API what is obviously

Re: How to have application-wide global objects

2006-07-13 Thread Bruno Desthuilliers
st the code !-) > Pardon me if I am too novice but I could not make out the meaning of > this phrase from your reply: > > "(at the module's to level)" Pardon me if I am too bad typist to avoid a typo on such a simple word as 'top' !-) And, please, don

Re: Multiplatform scripts: Can I avoid os.sep?

2006-07-13 Thread Bruno Desthuilliers
utomatically converts \\ to / when > the script runs on Linux? What is the best way to deal with this > situation? os.path.join('log', 'log.txt') os.path.join('ctl', 'table.ctl') Or look for the 'path' module http://www.jorendorff.com/articles/

Re: Multiplatform scripts: Can I avoid os.sep?

2006-07-13 Thread Bruno Desthuilliers
Mike Kent wrote: (snip - about Jason Orendorff's path module) > Of course, using the '/' operator in this manner makes some people's > heads explode. +1 QOTW -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w i

Re: testing array of logicals

2006-07-13 Thread Bruno Desthuilliers
Simon Brunning a écrit : > On 13 Jul 2006 05:45:21 -0700, John Henry <[EMAIL PROTECTED]> wrote: > >> >> Simon Brunning wrote: >> > >> > min(logflags) >> > >> >> !!! > > > Be aware that not only is this an outrageous misuse of min(), +1 QOTW Ho, my, I've already proposed another one today :( --

Re: String handling and the percent operator

2006-07-14 Thread Bruno Desthuilliers
ame2)s", "what about %(name2)s for %(name1)s ?", "Now we only deal with %(name1)s", ] data = {'name1' : 'parrot', 'name2': 'dead'} for tpl in tpls: print tpl % data As you can see, the keyword flavour doesn't care about positions nor repetitions. You may also want to look at more featured templating solutions like empy, cheetah, etc... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: NB question on global/local variables in functions

2006-07-17 Thread Bruno Desthuilliers
ct): def __init__(self): self._c1=123.0 self._c2=134.0 def fun(self, temp): return temp + self._c1 - self._c2 def fun1(self, temp): return temp - self._c1 foo = Foo() foo.fun(42) foo.fun1(42) -- bruno desthuilliers python -c "print '@'.join([

Re: Accessors in Python (getters and setters)

2006-07-17 Thread Bruno Desthuilliers
o focus on design. Let me reiterate, I'm not obsessing over language > semantics, I just need practical, not religious, solutions for my > problem domain. Using properties instead of explicit getters/setters is pragmatism, not religion. Using the default get/set mechanism when th

Re: Accessors in Python (getters and setters)

2006-07-17 Thread Bruno Desthuilliers
f objects. Behaviour is how a given object reacts to a given message. *Nothing* in this implies the notions of attributes or methods. Attributes and methods are implementation details of the concepts of state and behaviour, and - while this is a common implementation of OO concepts - the choice to use non-callable attributes as representing the state and callable ones as representing behaviour is totally implementation-dependant. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessors in Python (getters and setters)

2006-07-17 Thread Bruno Desthuilliers
Bruno Desthuilliers wrote: > mystilleef wrote: (snip) >>Here are the lessons I've learned (the hard way). >> >>1) Make all attributes of a class private or protected. > > > Unless they are obviously part of the implementation s/implementation/interface/

Re: function v. method

2006-07-18 Thread Bruno Desthuilliers
why not use some more dot-magic to implement > privates? What for ? What makes you think we need language-inforced access restriction ? (snip) > BTW, I am aware of Python's name mangling feature. Name mangling is mainly here to protect from accidental overridding. The convention for

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
ings, integer 0, float 0.0 and None are all false. This is part of the language specs. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
ions*. An expression is boolean if it's result can be coerced to a boolean value, ie fed to the bool type's constructor. So your example is wrong wrt/ if statements - it should read: empty_list = [] bool(empty_list) is False => True -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
if all you are doing is removing > all the items in the list, this is definitely better: > > lst = [] Not if there are other names bound to the same list. You are only rebinding this name, which does *not* empty the list object. The correct solution here is del lst[:] which will remove all cont

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
e/readable/ Python is much more readable than Java because it's *less* verbose than Java. > BTW, lst = [] was not what > I was interested in :-) Nor is it the correct functional equivalent of your code snippet. > I was asking whether it was better style to > use len() or not

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
ustomization.html > If Python had been designed with these types in > mind, I'm not sure "empty list is false" would have been part of the > language, let alone recommend practice. FWIW, this magic method already existed in 1.5.2 : http://www.python.org/doc/1.5.2p2/ref/customization.html -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
it's obvious the expression is a Boolean. The fact that the expression is used in the context of a if statement is clearly enough to denote a boolean expression. Explicitly testing against a boolean is uselessly redundant - and doesn't change anything, since it's always a bool

Re: wanting

2006-07-18 Thread Bruno Desthuilliers
arsl89 wrote: > hy gys i m wanting python programming language. > plz snd me the backup of python > Welcome to my bozo-list. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]&

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Carl Banks wrote: > Bruno Desthuilliers wrote: > >>Carl Banks wrote: >> >>>Patrick Maupin wrote: >>> >>> >>>>PTY wrote: >>>> >>>> >>>> >>>>>It looks like there are two crowds, terse and

Re: Recursive function returning a list

2006-07-18 Thread Bruno Desthuilliers
ild Or how to *not* address the real problem... Boris, using a generator may be a pretty good idea, but *not* as a way to solve a problem that happens to be a FAQ !-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) f

Re: wanting

2006-07-18 Thread Bruno Desthuilliers
Steve Holden wrote: > Bruno Desthuilliers wrote: > >> arsl89 wrote: >> >>> hy gys i m wanting python programming language. >>> plz snd me the backup of python >>> >> >> Welcome to my bozo-list. >> > Note how the OP even abbre

Re: Accessors in Python (getters and setters)

2006-07-18 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >> >>>Gerhard Fiedler wrote: >>> >>> >>>>On 2006-07-15 06:55:14, mystilleef wrote: >>>> >>>> >>>> >>>>>In very well

Re: Accessors in Python (getters and setters)

2006-07-18 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >>Please don't top-post >> >>>On State and Behavior: >>> >>>To understand objects in terms of state and behavior you need to >>>absolve yourself from impl

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Carl Banks wrote: > Bruno Desthuilliers wrote: > >>Carl Banks wrote: >> >>>Iterables, lists, arrays, and whatever else have overlapping uses, but >>>bool(obj) behaves differently for different types, >> >>bool(obj) will mainly look for __len__(),

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Volker Grabsch a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> schrieb: > >>PTY wrote: >> >>>I was asking whether it was better style to >>>use len() or not. >> >>FWIW, it's also more generic (you could have an object supporting &g

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Volker Grabsch a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> schrieb: > >>Carl Banks wrote: >> >>>Bruno Desthuilliers wrote: >>> >>>I'm well aware of Python's semantics, and it's irrelvant to my >>>argument. > &g

Re: Recursive function returning a list

2006-07-18 Thread Bruno Desthuilliers
Boris Borcic a écrit : > Hello Bruno, > > Bruno Desthuilliers wrote: > >> Boris Borcic wrote: >> >>>> Do you have any ideas? >>> >>> >>> you could use a recursive generator, like >>> >>> def genAllChildren(sel

Re: Object Persistence Using a File System

2006-07-18 Thread Bruno Desthuilliers
Nick Vatamaniuc a écrit : (please don't top-post - corrected) > > Bruno Desthuilliers wrote: > (snip) >>A few observations and questions : >>- you should avoid tests on concrete types as much as possible - at >>least use isinstance > > Good point about

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Carl Banks a écrit : > Bruno Desthuilliers wrote: > >>There are less risk of a typo with "if a:" than with "if len(a) > 0". > > > So, it's more important to protect against typos than subtle bugs? > People making smart points are really ann

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
> have been, planned in future releases of Python. > > Would love to listen to others. I've never had a use case for this kind of feature in the past seven years. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.spli

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
Kay Schluehr wrote: > Bruno Desthuilliers wrote: > >>Sanjay wrote: >> >>>Hi Alex, >>> >>>Thanks for the input. >>> >>>Being new to Python, and after having selected Python in comparison to >>>ruby (Turbogears vs Rails) ,

Re: Number combinations

2006-07-19 Thread Bruno Desthuilliers
n ["%s%s%s%s" % (a, b, c, d) \ for a in r \ for b in r \ for c in r \ for d in r] But there's certainly better solutions... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
es is > when you want to separate your GUI code from the rest of your logic. What the ... is GUI code doing in a domain object ??? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Partial classes

2006-07-19 Thread Bruno Desthuilliers
edge of the technologies involved, > is that assign_mapper does some magic only on Person class, and things > work. But after inheritence, it is not working. Anyway, there are other ways to reuse implementation, like composition/delegation. You may want to have a look at __getattr

Re: using names before they're defined

2006-07-19 Thread Bruno Desthuilliers
ressor, then combuster, then turbine but I don't know if it makes any sens wrt/ your app !-) Now there can of course be a lot of other solutions... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive function returning a list

2006-07-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Bruno Desthuilliers wrote: > >>Boris Borcic a écrit : >> >>>Hello Bruno, >>> >>>Bruno Desthuilliers wrote: >>> >>> >>>>Boris Borcic wrote: >>>> >>>> >>>>&g

Re: Recursive function returning a list

2006-07-19 Thread Bruno Desthuilliers
Steve Holden wrote: > Bruno Desthuilliers wrote: > >> Boris Borcic a écrit : >> >>> Hello Bruno, >>> >>> Bruno Desthuilliers wrote: > > [...] > >>>> Or how to *not* address the real problem... >>>> >>>&

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: (snip) >>>>> >>>>>Of course using setters for the sake of just using them is pointless. >>>> >>>>Indeed. >>>> >>>> >>>>

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >> (snip) >>>>>For example, a third party randomly changing >>>>>is_active, (which Python lets you do freely and easily) >>>> >>>>Unless you make it a

Re: using names before they're defined

2006-07-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : >>Even if you need to do something during attachment of components it is >>more Pythonic to use properties. So you will write a method in your >>class name something like _set_up(self,upstream_obj) an _get_up(self). >> And then at the end of your class put up=property(_

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Bruno Desthuilliers
Tobias Brox a écrit : > [Jason] > >>Nothing like being forced to write getters and setters in C++/Java >>before you feel like shooting your source code. Please don't bring >>this code-rage into Python. > > > "Code generation" springs into my mind. IMO, if the code needs to be > generated, the

Re: Warning when new attributes are added to classes at run time

2006-07-20 Thread Bruno Desthuilliers
_dict__[name] = value Make it: object.__setattr__(self, name, value) Your approach will lead to strange results if you mix it with properties or other descriptors... > class C1(C): > > standard_attributes = ['a1', 'a2'] DRY viol

Re: Partial classes

2006-07-20 Thread Bruno Desthuilliers
> > I can't believe I always used version control systems for that use case if > it's that easily solved with partial classes. Collaborative work is only one of the needs solved by VCS. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1

Re: function v. method

2006-07-20 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > >>danielx wrote: (snip) >>>which gets me thinking again about >>>the stuff I self-censored. Since the dot syntax does something special >>>and unexpected in my case, >> >>"unexpected" ? Di

Re: Coding style

2006-07-20 Thread Bruno Desthuilliers
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Bruno Desthuilliers > wrote: > > >>Lawrence D'Oliveiro wrote: >> >>>In message <[EMAIL PROTECTED]>, Bob Greschke >>>wrote: >>> >>> >>> >>

Re: Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > >>mystilleef wrote: >> >>>Bruno Desthuilliers wrote: >>> >>> >>>>mystilleef wrote: >> >>(snip) >> >>>>>>>Of course using setters for the sake of just us

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