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: Please help for Python programming

2005-03-23 Thread bruno modulix
ou a working example. If you don't read answers, don't post questions :-/ -- 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: Anonymus functions revisited

2005-03-23 Thread bruno modulix
(): ... global G ... G = 42 ... >>> G Traceback (most recent call last): File "", line 1, in ? NameError: name 'G' is not defined >>> yuck() >>> G 42 >>> Anyone doing such a thing in my team would be shoot down at once !-) -- bruno

Re: Anonymus functions revisited

2005-03-23 Thread bruno modulix
ot; else: print "After makeVars: Not NameError" Interesting. I'll keep a copy of this one in my cookbook for further exploration. But I think I would use such a thing in production code. >>> b = 25 >>> makeVars(b=88) >>> b 88 -- bruno desthuilliers python

Re: Anonymus functions revisited

2005-03-23 Thread bruno modulix
Ron wrote: On Tue, 22 Mar 2005 21:45:42 +0100, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: 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 actio

Re: Anonymus functions revisited : tuple actions

2005-03-23 Thread bruno modulix
subsequent posting in lambda fashion: 2. [(lambda x,y,z=0:x*y-z)(*v) for v in (1,2,3), (4,5), (6,7,8)] Argh! Stupid me ! I never thought of using the star operator for this :( Thanks Kay. (snip) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split

Re: Anonymus functions revisited

2005-03-24 Thread bruno modulix
George Sakkis wrote: "bruno modulix" <[EMAIL PROTECTED]> wrote: in message news:[EMAIL PROTECTED] (snip) Note that you don't have anything like list unpacking, now tuple unpacking is pretty common in Python (swap, multiple return values, formatted strings and outputs, ...).

Re: Please help for Python programming

2005-03-24 Thread bruno modulix
a pretty common idiom in Python -, try to answer Q1 and Q2, and you should be able to work it out by yourself. -- 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: Suggestions for a Java programmer

2005-03-24 Thread bruno modulix
xpedite that process if possible. What are your suggestions? These two books should help you to get a grasp of Pythonic idioms: http://www.mindview.net/Books/TIPython http://diveintopython.org/ -- 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: An Abridged Python Tutorial

2005-03-25 Thread bruno modulix
Michael Spencer wrote: An Abridged Python Tutorial (snip fine piece of art) -- 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: 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: Best editor?

2005-04-06 Thread bruno modulix
y human :( Thus, I recommend using either to impress your friends. Err... most of my friend not being coders, they don't even have a clue about what are emacs and vim, so they're not really impressed. The other are coders and use either vim or emacs or both, so they're not really

Re: boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-06 Thread bruno modulix
Sunnan wrote: Aahz wrote: (snip) print "foo is", foo Is the space added automatically? (Like awk does, if you add a comma.) Yes. But you can also format it how you like: print "foo is %s and that's a good news, my friends" % foo -- bruno desthuilliers python -c &qu

Re: logging as root using python script

2005-04-07 Thread Luis Bruno
sudo(8) to not prompt for any password, BTW. Cheers! -- Luis Bruno -- http://mail.python.org/mailman/listinfo/python-list

Re: logging as root using python script

2005-04-07 Thread Luis Bruno
Martin Franklin wrote: > another alternative would be setuid I also thought about making the script setuid root, but I'm under the impression that Linux (at least) won't honor the suid bit on a script. That's from memory though. Cheers! -- http://mail.python.org/mailman/listinfo/python-list

Re: Help understanding code

2005-04-11 Thread Bruno Desthuilliers
turn "hello, I'm %s" % self.name f= fakeFun('foo') f() >> hello, I'm foo HTH Bruno -- http://mail.python.org/mailman/listinfo/python-list

Re: [perl-python] Python documentation moronicities (continued)

2005-04-13 Thread bruno modulix
hy don't we pay him $100 to re-write the PERL docs? +1 ! -- 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: A beginer question about SOAP and Python: : {}

2005-04-14 Thread bruno modulix
Did you look at the SOAPpy api for the description of Types.structType ? -- 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: Converting a perl module to a python module would it be worth it?

2005-04-14 Thread bruno modulix
epresentative of a good Python coding style !-) -- 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: 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: Using python from a browser

2005-04-15 Thread bruno modulix
27;ll have a look one day. -- 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: Is Python appropriate for web applications?

2005-04-15 Thread bruno modulix
uot;+" operators for arrays and the array_merge() function (don't forget that PHP uses the same construct for arrays and mappings - doh). Then imagine yourself programming PHP, and ask yourself if you'll really develop faster with such a braindead quick&dirty hack for language.

Re: Python - interpreted vs compiled

2005-04-15 Thread bruno modulix
the code each time it's runned. The main difference here between Python and Java is that the Python runtime takes care of those details for you instead of requiring you to either manually recompile everything each time you make a change or use a complex build system (that you'll have to

Re: Zope3 and Plone

2005-04-18 Thread bruno modulix
Mir Nazim wrote: Hi, I wanted to know what will happen to plone once Zope3 will be official version. (snip) what should be done. Ask on the Plone mailing list ?-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')])

Re: Persistent python object and the Web

2005-04-22 Thread bruno modulix
e user pushes a button. I'm using python2.3, mod_python and Apache. You may want to have a look at ZODB - the Zope object database. It has been developped for Zope, but can be used without. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.s

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: Simple, elegant, pythonic solution for switch statement

2005-04-26 Thread bruno modulix
python_only wrote: Check it out! Readable switch construction without lambdas or dictionaries: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410692 Not sure I'll have a need for it, but, yes, nice job !-) -- bruno desthuilliers python -c "print '@'.join(['

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: Which IDE is recommended?

2005-04-28 Thread bruno modulix
Dave Cook wrote: (snip) Once upon a time emacs was considered bloated, That was when "640ko ought to be enough" ?-) but it's tiny compared to eclipse. Yeps. And a *lot* faster. And in not that much bigger than Vim in fact... -- bruno desthuilliers python -c "print '@'

Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Bruno Cauet
inator.com/item?id=8730156 http://redd.it/2ovlwm http://redd.it/2ovls4 Feel free to publish it anywhere else, to get as many answers as possible. Bruno 2014-12-10 18:24 GMT+01:00 Nathaniel Smith : > On 10 Dec 2014 17:16, "Ian Cordasco" wrote: > > > > On Wed, Dec 1

Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Bruno Cauet
ublish the results around the end of the year. Last year results: https://wiki.python.org/moin/2.x-vs-3.x-survey Thank you Bruno -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Bruno Cauet
014 at 3:59 AM, Bruno Cauet wrote: >> Here's the url: http://goo.gl/forms/tDTcm8UzB3 >> I'll publish the results around the end of the year. > On "Which versions do you use?", 3.5 is not included. My primary > Python 3 build on here is a 3.5 built from trun

Results of the python 2.x and 3.x use survey, 2014 edition

2015-01-29 Thread Bruno Cauet
3, but dependencies keep them with 2.7 (I weep for the few ones still on 2.5). I also posted the results on HN (https://news.ycombinator.com/item?id=8967645) and reddit (http://www.reddit.com/r/Python/comments/2u3oh0/results_of_the_python_2x_and_3x_use_survey_2014/). Have a nice day, and a year

urllib.parser.quote() and RFC 2396: unreserved characters get encoded

2015-02-11 Thread Bruno Cauet
that URIs generated by python does not match the URIs generated by other tools and make me unable to identify elements as identical because of their URI. Thanks, Bruno -- https://mail.python.org/mailman/listinfo/python-list

ctypes problem: segfault with pointer usage

2015-03-27 Thread Bruno Cauet
ent/response types. What am I doing wrong? Any pointer (ahah) on how to solve my problem? The c code can be compiled that way: $ gcc $(pkg-config --cflags gio-2.0) segfault.c -o segfault $(pkg-config --libs gio-2.0) Thanks Bruno import ctypes import ctypes.util class GioURI(object): "

Re: ctypes problem: segfault with pointer usage

2015-03-27 Thread Bruno Cauet
Found the problem: I just have to add libgio.g_object_unref.argtypes = [ctypes.c_void_p] It now works flawlessly! Sorry for the noise. 2015-03-27 13:03 GMT+01:00 Bruno Cauet : > Hi, > I have a segfault problem with ctypes. Script attached. > I simply need to call `libgio.g_file_new_for_

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
Sanjay wrote: > Hi Bruno, > > Thanks a lot for the reply. In order to post here, I wrote a very > simple program now, and it seems working! I can diagnose the original > problem now. Fine. > There might be some other problem. This, we can't tell, since you didn't po

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

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