Re: Can you please give me some advice?

2007-09-30 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) > I know nothing of Ruby, but just the fact that in Ruby the Hello World > program is > > puts 'Hello, World!' > > whereas the Python Hello World program is > > print 'Hello, World!' > > suggests to me that Python is more intuitive because the word "print" > h

Re: xml modifications

2007-10-01 Thread Bruno Desthuilliers
dcleaner a écrit : > hi there...i'm a begginer level user and i've stumbbled upon a problem a > bit beyond my knowledge. i hope that somebody will be able to help me with > my problem... > > the problem is: i'm transforming an Access database to XML Strange idea IMHO, but anyway... > with some

Re: Select as dictionary...

2007-10-01 Thread Bruno Desthuilliers
Besturk.Net Admin a écrit : > Hi.. > I am using python with postgresql. > And i have a query : > > aia.execute("SELECT id, w from list") > links=aia.fetchall() > print links > > and result > [(1, 5), (2,5)...] (2 million result) > > I want to see this result directly as a dictionary: > > {1

Re: How popular is Django ?

2007-10-01 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : > [EMAIL PROTECTED] wrote: > >> Hi! >> >> I was surprised when I did a google-groups search for python, >> ( >> http://groups.google.com/groups/search?q=python&qt_s=Search+Groups >> ) >> it shows these groups: >> comp.lang.python with about 11000 users, >> and second,

Re: Select as dictionary...

2007-10-01 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit : > On Mon, Oct 01, 2007 at 03:50:59PM +0200, Bruno Desthuilliers wrote regarding > Re: Select as dictionary...: >> IIRC, postgres' db-api connector (well, at least one of them - I don't >> know which one you're using) has a DictCursor.

Re: Combine two dictionary...

2007-10-01 Thread Bruno Desthuilliers
Abandoned a écrit : > > I'm sorry my bed english. Time to go to bad, then !-) (sorry, couldn't resist) -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about quoting style.

2007-10-01 Thread Bruno Desthuilliers
Steven W. Orr a écrit : > Python has a number of "quoting" 'options' to help """with > times when""" one way may be more convenient than another. > > In the world of shell scripting, I use a technique that I call minimal > quoting. It works like this: > > foo=bar# No quotes needed >

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-01 Thread Bruno Desthuilliers
Ken Tilton a écrit : > > > Matthias Benkard wrote: > >>> So this has nothing to >>> do with freedom in /any/ sense of the word, it has to do with a >>> political agenda opposed to the idea of private property. >> >> Freedom is inherently political, you know. You're condemning the FSF >> for bei

Re: slice last 4 items from a list

2007-10-01 Thread Bruno Desthuilliers
brad a écrit : > Is this the correct way to slice the last 4 items from a list? > > x = [1,2,3,4,5,6,7,8,9] > print x[-4:] > > It works, but is it Pythonic? Is there a more obvious (for a pythonic definition of 'obvious') way to do it ? If no, then it's pythonic... Now FWIW, I usually use 'esr

Re: Question about quoting style.

2007-10-02 Thread Bruno Desthuilliers
Gabriel Genellina a écrit : > En Mon, 01 Oct 2007 19:10:11 -0300, James Stroud <[EMAIL PROTECTED]> > escribi�: > >> Bruno Desthuilliers wrote: >>> First point is that Python has no "variable interpolation". >> >> If you squint, it kind of

Re: Question about quoting style.

2007-10-02 Thread Bruno Desthuilliers
J. Cliff Dyer a écrit : (snip) > You missed another dimension of python string types. I didn't "missed" - I choosed to skip the subject since it was not about quoting style. Not to say I necessarily made the best choice... -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on overriding implicit lookups

2007-10-02 Thread Bruno Desthuilliers
David Ells a écrit : > In Python we have a wonderful facility for customizing attribute > access by defining __getattr__ or __getattribute__ in our classes. > Unfortunately (or perhaps fortunately, for reasons I don't know), this > facility only works for explicit attribute access, i.e. accessing >

Re: Can you please give me some advice?

2007-10-02 Thread Bruno Desthuilliers
Thorsten Kampe a écrit : > * Bruno Desthuilliers (Sat, 29 Sep 2007 19:17:43 +0200) > >>[EMAIL PROTECTED] a écrit : >>(snip) >> >>>I know nothing of Ruby, but just the fact that in Ruby the Hello World >>>program is >>> >>>puts 

Re: List Question

2007-10-02 Thread Bruno Desthuilliers
brad a écrit : > How is this expressed in Python? > > If x is in y more than three times: > print x > > y is a Python list. if y.count(x) > 3: print x -- http://mail.python.org/mailman/listinfo/python-list

Re: global variables

2007-10-02 Thread Bruno Desthuilliers
Colin J. Williams a écrit : > TheFlyingDutchman wrote: >> Does anyone know how the variables label and scale are recognized >> without a global statement or parameter, in the function resize() in >> this code: >> >> >> >> #!/usr/bin/env python >> >> from Tkinter import * >> >> def resize(ev=None):

Re: Django for database driven web application is OK?

2007-10-03 Thread Bruno Desthuilliers
cuongvt a écrit : > Hello > I'm new to both Django and Python. I'm mainly developing on PHP. > I tend to move to Django. But I want to confirm as below: > I heard that Django is mainly used for something like content management, > CMS or something > like that and Rails is mainly for web applica

Re: module confusion

2007-10-03 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, Robert > Kern wrote: > >> Lawrence D'Oliveiro wrote: >> >>> In message <[EMAIL PROTECTED]>, Robert >>> Kern wrote: >>> Not all of the modules in a package are imported by importing the top-level package. >>> You can't import

Re: A total bullshit (was : A Must Read!!!)

2007-10-03 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I have found an excellent resource on Object Oriented Programming. > > (url snipped to protect the innocents) Let's see: "An object has methods, properties and events." Hem... "oriented programming probably existed before the concept of a class came into being b

Re: migrating to packages

2007-10-04 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : > [EMAIL PROTECTED] writes: > >> I will expose my case quicly. >> The MYCLASES.py file contains the A class, so i can use >> from MYCLASES import A >> a = () >> >> Using the "package mode" (wich looks fine BTW), having the simple >> MYCLASES/ >> __init__.py >> A.p

Re: module confusion

2007-10-04 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, Carsten > Haese wrote: > >> On Thu, 2007-10-04 at 11:11 +1300, Lawrence D'Oliveiro wrote: >> >>> In Python, all names _are_ variables. They are not "bound" to objects. >>> The value of os.path is a pointer. >> No. "os.path" refers to

Re: migrating to packages

2007-10-04 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > >> it's quite common to use the __init__.py of the package (as >> explained by Ben) as a facade to the internal organization of the >> package, so you can change this internal organizat

Re: Python "implements " equivalent?

2007-10-04 Thread Bruno Desthuilliers
Wojciech Gryc a écrit : > Hi, > > I recently started using Python and am extremely happy with how > productive it's made me, even as a new user. I'm hoping to continue > using the language for my research, and have come across a bit of a > stumbling block. > > I'm a seasoned Java programmer So y

Re: Python "implements " equivalent?

2007-10-04 Thread Bruno Desthuilliers
Grant Edwards a écrit : > On 2007-10-04, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > >>Yes, and it's even simpler : just pass your object. If it effectively >>implements the desired interface, everything will work fine !-) > > [...] > >

Re: HELP me Am very new one To python

2007-10-04 Thread Bruno Desthuilliers
Damodhar a écrit : > hi, > > Am working in PHP MYSQL. I am very very interest to learn Python but i > don't Know Little Bit, > am using windows Xp, Ialready download from > http://www.python.org/ftp/python/2.5.1/python-2.5.1.ia64.msi > > and install into C:\Python25 > > whats the next step . i U

Re: unit testing

2007-10-04 Thread Bruno Desthuilliers
Paul Rubin a écrit : > brad <[EMAIL PROTECTED]> writes: > >>Does anyone else feel that unittesting is too much work? Not in >>general, just the official unittest module for small to medium sized >>projects? > > > Yeah, unittest is sort of a Java-ism. You might try the newer doctest > module ins

[OT, definitively] Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-04 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit : > On Thu, Oct 04, 2007 at 04:49:50PM +0200, Wildemar Wildenburger wrote > regarding Re: The Modernization of Emacs: terminology buffer and > keybinding: > >> Steve Holden wrote: >>> Lawrence D'Oliveiro wrote: In message <[EMAIL PROTECTED]>, Steve Holden w

Re: module confusion

2007-10-05 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, Steven D'Aprano wrote: > >> What does type(os.path) return when you try it? > > It returns the type of the value contained in that variable, of course: Certainly not. You're confusing Python with C. In Python, 'variables' are *not*

Re: Mysql class works like php

2007-10-05 Thread Bruno Desthuilliers
Andrey a écrit : > Hi > > just a quick question about using MySQL module... are there any api / class > available to give a higher level in working with Mysql in python? > such as > db.fetch_array(), > db.fetch_rows(), > db.query(), > for eachrow in db.fetch_array(): > You really find t

Re: Is there a nicer way to do this?

2007-10-05 Thread Bruno Desthuilliers
Stefan Arentz a écrit : > Is there a better way to do the following? > > attributes = ['foo', 'bar'] > > attributeNames = {} > n = 1 > for attribute in attributes: >attributeNames["AttributeName.%d" % n] = attribute >n = n + 1 > > It works, but I am wondering if there is a more pythonic

Re: migrating to packages

2007-10-05 Thread Bruno Desthuilliers
Gerardo Herzig a écrit : > Carl Bank a écrit : >> >> Add these lines in __init__.py: >> >> from MYCLASSES.A import A >> from MYCLASSES.B import B >> >> > Ummm, that works indeed, but forces me to import all (more than A and B) > classes, rigth? Why so ? -- http://mail.python.org/mailman/listi

Re: where can I get a space supporting cgi written in python

2007-10-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I'm studying python and very interested in cgi written in python, but > i can't find a free host suporting it.who can tell where can i sign up > for a free python host? > I just wanna have a try, the space dont have to be very large, 20M or > 50M is OK FWIW, you don't

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit : > On Fri, Oct 05, 2007 at 04:11:07PM -, Grant Edwards wrote > regarding Re: Python Magazine: Issue 1 Free!: > >> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote: >> > I've just been told by the editors at Python Magazine that > the first issue is out.

Re: migrating to packages

2007-10-05 Thread Bruno Desthuilliers
Gerardo Herzig a écrit : > Bruno Desthuilliers wrote: > >> Gerardo Herzig a écrit : >> >> >>> Carl Bank a écrit : >>> >>> >>>> Add these lines in __init__.py: >>>> >>>> from MYCLASSES.A import A >>&g

Re: Python "implements " equivalent?

2007-10-05 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, Wojciech > Gryc wrote: > > >>I'm a seasoned Java programmer and quite a big fan of interfaces... >>i.e. The idea that if I make a number of distinct classes that >>implement interface X, I can pass them all as parameters to functions

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Bruno Desthuilliers
Wayne Brehaut a écrit : > On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > > >>J. Clifford Dyer a écrit : (snip) >>>Well, it's also unpythonic to start numbering a sequence at 1, but >>>it's clearly th

Re: Boolean parser..

2007-10-05 Thread Bruno Desthuilliers
Paul McGuire a écrit : (snip) May I suggest a couple cleanifications for our newbie friends around ? > from searchparser import SearchQueryParser > > products = [ "grape juice", "grape jelly", "orange juice", "orange > jujubees", > "strawberry jam", "prune juice", "prune butter", "orange >

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Bruno Desthuilliers
Wayne Brehaut a écrit : > On Thu, 04 Oct 2007 04:52:13 +0200, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > > >>Wayne Brehaut a écrit : >> >>>On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers >>><[EMAIL PROTECTED]> wrote:

Re: unit testing

2007-10-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) > > Thanks to all for the opinions. Just to clarify, I have nothing > against testing. I like doing it. I catch a lot of bugs! I dislike the > formality of the unittest module. It's unyielding. It makes testing > difficult unless your code is written with testing

Re: Segmentation fault..

2007-10-06 Thread Bruno Desthuilliers
Jorge Godoy a écrit : > Abandoned wrote: > >> Hi.. >> I run a my script and 3-4 minutes later give me an error "segmentation >> fault". >> What is the reason of this error ? >> >> I use in my script: >> Threading >> Psycopg2 >> open & write to txt >> urlopen >> >> My platform is ubuntu linux. >> >

Re: Yet another comparison of Python Web Frameworks

2007-10-06 Thread Bruno Desthuilliers
Michele Simionato a écrit : > At work we are shopping for a Web framework, so I have been looking at > the available options > on the current market. In particular I have looked at Paste and Pylons > and I have written my > impressions here: > > http://www.phyast.pitt.edu/~micheles/python/yet-anot

Re: Yet another comparison of Python Web Frameworks

2007-10-06 Thread Bruno Desthuilliers
Michele Simionato a écrit : > On Oct 6, 9:13 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> - talking about routes, you say: >> >> """ >> I have no Ruby On Rails background, so I don't see the advantages of routes. >> ""&quo

Re: Adding behaviour for managing "task" dependencies

2007-10-06 Thread Bruno Desthuilliers
David a écrit : >>Any thoughts would be most appreciated, though I would like to stress >>that I don't think Python should support the syntax I'm proposing I'd >>just like to know if I can extend a copy of it to do that. >> > > > You can use syntax like this: > > class MyJob1(Job): > depends

Re: Python Magazine: Issue 1 Free!

2007-10-06 Thread Bruno Desthuilliers
Terry Reedy a écrit : > "Steve Holden" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > | I've just been told by the editors at Python Magazine that the first > | issue is out. It's all-electronic so anyone can download and read it. > | Let them know what you think: > | > | http:/

Re: Yet another comparison of Python Web Frameworks

2007-10-07 Thread Bruno Desthuilliers
Steve Holden a écrit : > Lawrence Oluyede wrote: (snip) >> We (Michele, myself and our colleagues) have a series of stuff we need >> to stick to so the choosing of a web framework ain't that easy. Most of >> the frameworks are a vision of the author of how to do things from >> scratch but a framewo

Re: Mysql class works like php

2007-10-07 Thread Bruno Desthuilliers
gardsted a écrit : > Bruno Desthuilliers wrote: >> Andrey a écrit : >>> Hi >>> >>> just a quick question about using MySQL module... are there any api / >>> class available to give a higher level in working with Mysql in python? >>> such as &

Re: Override 'and' and 'or'

2007-10-07 Thread Bruno Desthuilliers
Dekker a écrit : > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? http://docs.python.org/ref/customization.html """ __nonzero__(self) Called to implement t

Re: Newbie packages Q

2007-10-07 Thread Bruno Desthuilliers
MarkyMarc a écrit : (snip) > And the atest and btest, shouldn't they be able to import each > other?? import is a statement. It's executed, like any other top-level code, when the module is imported (or the script loaded into the interpreter if it's called directly). So if A.py imports B.py and

Re: Override 'and' and 'or'

2007-10-07 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Sun, 07 Oct 2007 16:24:35 +0200, Wildemar Wildenburger wrote: > >> Wildemar Wildenburger wrote: >>> [whate everyone else wrote :(] >>> >>> /W >> Dangit! 4th of 4. >> Gotta type quicker. > > > That's okay, in two weeks time there will be 139 messages in this thread,

Re: Newbie packages Q

2007-10-07 Thread Bruno Desthuilliers
MarkyMarc a écrit : (snip) > It was simply to make a point. But then lets say the to files looks > like this: > > *** > atest.py: > > def printA(): > print "This is Atest from Apack" > *** > btest.py: > from Test.apack import atest

Re: Newbie packages Q

2007-10-07 Thread Bruno Desthuilliers
MarkyMarc a écrit : > On Oct 7, 6:04 pm, Bruno Desthuilliers > But how do I get this to work? >> You failed to specify how your files are organized, and what is "not >> working". >> >> But anyway, if >> - atest.py is in /Test/apack, >> - bo

Re: Problem of Readability of Python

2007-10-07 Thread Bruno Desthuilliers
Licheng Fang a écrit : > Python is supposed to be readable, but after programming in Python for > a while I find my Python programs can be more obfuscated than their C/C > ++ counterparts sometimes. Part of the reason is that with > heterogeneous lists/tuples at hand, I tend to stuff many things in

Re: Problem of Readability of Python

2007-10-08 Thread Bruno Desthuilliers
Brian Elmegaard a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> > writes: > >> Use dicts, not lists or tuples: >> >> a = dict(name='yadda', val=42) >> print a['name'] >> print a['val'] > > I guess you will th

Re: Variable scoping rules in Python?

2007-10-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Ok, I'm relatively new to Python (coming from C, C++ and Java). I'm > working on a program that outputs text that may be arbitrarily long, > but should still line up, so I want to split the output on a specific > column boundary. FWIW : http://docs.python.org/lib/mod

Re: weakrefs and bound methods

2007-10-08 Thread Bruno Desthuilliers
Mathias Panzenboeck a écrit : About the lost weakref problem: in Python, methods are just tiny wrappers around the object, class and function created at lookup time (yes, on *each* lookup) (and WWAI, they are by the function object itself, which implements the descriptor protocol). > When I ch

Re: property question

2007-10-09 Thread Bruno Desthuilliers
Manu Hack a écrit : > hi all, > > If I have a class A with A.x, A.y, A.z. A.y and A.z are property and > in order to compute the value of them, A.y depends on A.x while A.z > depends on A.y and A.x. If I call A.y, and A.z, the value A.y would > be computed twice. Is there a smart way to avoid t

Re: Static variable vs Class variable

2007-10-09 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi. > > I've got a question on the differences and how to define static and > class variables. What's a "static" variable ? A variable that doesn't move ?-) > Hence, my understanding is that static variables must be bound to the > class defining the variables Yo

Re: Static variable vs Class variable

2007-10-09 Thread Bruno Desthuilliers
Marc 'BlackJack' Rintsch a écrit : > On Tue, 09 Oct 2007 18:08:34 +, Steven D'Aprano wrote: > > >L = [] >id(L) >> >>3083496716L >> >L += [1] >id(L) >> >>3083496716L >> >>It's the same L, not rebound at all. > > It *is* rebound. To the same object, but it *is* assigned to `L`

Re: Static variable vs Class variable

2007-10-09 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : (snip) > And it is *not* rebound: Doh. Stupid me. Of course it is - but to a ref to the same object... >>> class A: ... l = [] ... >>> class B(A): pass ... >>> B.__dict__ {'__module__': '__main__', '_

Re: multimethods decorator

2007-10-10 Thread Bruno Desthuilliers
Gerardo Herzig a écrit : > Hi all. Im reading the Gido's aproach using decorators at > http://www.artima.com/weblogs/viewpost.jsp?thread=101605 > > It looks good to me, but the examples shows the functionality using > functions. > Now, when i try to give this decorator into a method, if i try the

Re: function wrappers

2007-10-10 Thread Bruno Desthuilliers
Scott David Daniels a écrit : > Ramon Crehuet wrote: >> def require_int(func): >> def wrapper(arg): >> assert isinstance(arg, int) >> return func(arg) >> return wrapper >> def p1(a): >> print a >> p2 = require_int(p1) >> >> My question is: why do p2 arguments becom

Re: multimethods decorator

2007-10-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : >> Gerardo Herzig a écrit : >>> Hi all. Im reading the Gido's aproach using decorators at >>> http://www.artima.com/weblogs/viewpost.jsp?thread=101605 >>> >>> It looks good to me, but the examples shows the functionality using >>> functions. >>> Now, when i try to give t

Re: Advice on long running processes

2007-10-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hello, > > I write a lot of CGI scripts, in Python of course. Now I need to > convert some to long-running processes. I'm having trouble finding > resources about the best practices to do that. > > I've found a lot of email discussions that say something like, "You

Re: Declarative properties

2007-10-11 Thread Bruno Desthuilliers
Artur Siekielski a écrit : > Hi. > > I would like to have declarative properties in Python, ie. something > like slots definitions in defclass in Common Lisp. It seems that even > Java will have it, using a library ( https://bean-properties.dev.java.net/ > ). > > I know about 'property' function

Re: Declarative properties

2007-10-11 Thread Bruno Desthuilliers
Artur Siekielski a écrit : > On Oct 11, 2:27 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> But why? Default getters and setters are unnecessary and if you need >> something other than the default you need to write it anyway more >> explicitly. > > I see some problems with your approa

Re: Declarative properties

2007-10-11 Thread Bruno Desthuilliers
Artur Siekielski a écrit : > On Oct 11, 4:21 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> In practice, it turns out to be a lot less work to deal with that >> occasionally than to always deal with lugging around internal >> attributes and external properties when they're really not needed.

Re: Keeping track of subclasses and instances?

2007-10-11 Thread Bruno Desthuilliers
George Sakkis a écrit : (snip) > Anyway, here's something to get you > started; all a user has to do is derive (directly or indirectly) from > InstanceTracker and, if a class C defines __init__, > super(C,self).__init__() should be called explicitly: Actually, you don't even need that restriction

Re: Declarative properties

2007-10-12 Thread Bruno Desthuilliers
Dan Stromberg a écrit : > On Thu, 11 Oct 2007 13:46:12 +, Marc 'BlackJack' Rintsch wrote: > >> On Thu, 11 Oct 2007 13:04:53 +, Artur Siekielski wrote: >> >>> On Oct 11, 2:27 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: But why? Default getters and setters are unnecessary a

Re: Declarative properties

2007-10-12 Thread Bruno Desthuilliers
Artur Siekielski a écrit : > George Sakkis wrote: >> By now you must have been convinced that default getters/setters is >> not a very useful idea in Python but this does not mean you can't do >> it; > > It's a perfect summary of my thoughts after reading this thread. I > will use public attribute

Re: Declarative properties

2007-10-13 Thread Bruno Desthuilliers
Stargaming a écrit : > On Thu, 11 Oct 2007 18:58:44 +0200, Bruno Desthuilliers wrote: > [snip] > > Your implementation seems particularly broken. You do not return anything > from `name()`, Oops, my bad ! Indeed, I forgot the 'return property(**locals())' at the end.

Re: Declarative properties

2007-10-13 Thread Bruno Desthuilliers
Dan Stromberg a écrit : > On Fri, 12 Oct 2007 09:42:28 +0200, Bruno Desthuilliers wrote: > > >>>>So what? Otherwise you carry *always* the baggage of a public >>>>property and a private attribute whether you need this or not. At >>>>least

Re: Declarative properties

2007-10-13 Thread Bruno Desthuilliers
Dan Stromberg a écrit : (snip) > My implementation may or may not be lacking (feel free to improve it - in > fact, please do!), Since you ask for it: def makeprop(name): _name = '_' + name def fget(self): return getattr(self, _name, None) def fset(self, val): set

Re: First class lexical closures

2007-10-15 Thread Bruno Desthuilliers
Jon Harrop a écrit : > Just debating somewhere else whether or not Python might be considered a > functional programming language. Lua, Ruby and Perl all seem to provide > first class lexical closures. def makeadder(x): def add(y): return x+y return add If that's what you mean, then

Re: easy but difficult

2007-10-16 Thread Bruno Desthuilliers
Paul McGuire a écrit : > On Oct 16, 5:46 am, "Amit Khemka" <[EMAIL PROTECTED]> wrote: > (snip) > Another technique that helps improve script readability is to assign > the results of the split into separate variables, instead of just a > list. This way you can refer to the items with meaningful n

Re: Why does the message send only once?

2007-10-16 Thread Bruno Desthuilliers
danfolkes a écrit : You already posted the same question here one hour and a half ago. Please avoid. -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to Send Repeated Messages to a Server Using sockets

2007-10-16 Thread Bruno Desthuilliers
danfolkes a écrit : > Hey Everyone, I am trying to send repeated messages from a "Node" to a > "Server". It works the first time I send the from the Node to Server, > but after that it either errors, or does not do anything. > > I would love some help, here is the code: Posting the trackbacks m

Re: some questions about Python and tkinter

2007-10-16 Thread Bruno Desthuilliers
fabdeb a écrit : > Hi every one, > I m a sysadmin who want to know how to use python. > I dont know anything about oriented object programation, i only know > bash and a little perl. > I have some simple questions about python. > > the first: what is the differences between a function and a classe

Re: Simple HTML template engine?

2007-10-16 Thread Bruno Desthuilliers
Adrian Cherry a écrit : > "allen.fowler" <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > > >>Hello, >> >>Can anyone recommend a simple python template engine for >>generating HTML that relies only on the Pyhon Core modules? >> >>No need for caching, template compilation, etc. >> >>Speed

Re: Last iteration?

2007-10-16 Thread Bruno Desthuilliers
Paul Hankin a écrit : > On Oct 12, 11:58 am, Florian Lindner <[EMAIL PROTECTED]> wrote: > >>Hello, >>can I determine somehow if the iteration on a list of values is the last >>iteration? >> >>Example: >> >>for i in [1, 2, 3]: >> if last_iteration: >> print i*i >> else: >> print i >

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-16 Thread Bruno Desthuilliers
answering to Dmitri O.Kondratiev > On Sunday 14 October 2007 5:06:19 pm Dmitri O.Kondratiev wrote: > >>The function I wrote (below) reverses lists all right: >> >>def reverse(xs): >>if xs == []: >>return [] >>else: >>return (reverse (xs[1:])) + [xs[0]] >> >reverse ([1,2

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-16 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : > answering to Dmitri O.Kondratiev (snip) > > def reverse(xs): > if xs: > return xs > else: > return (reverse (xs[1:])) + [xs[0]] I meant: def reverse(xs): if not xs: (etc...) of course... -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-16 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : (snip) > def myreversed(sequence): > if isinstance(sequence, basestring): > return type(sequence)().join(reversed(sequence)) > else: > return type(sequence)(reversed(sequence)) > > (in fact, that's so simple I wonder why the built-in reversed() doe

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-17 Thread Bruno Desthuilliers
Paddy a écrit : >> > story stargaming, I caught it first this time !-) > Shouldn't that be s-o-r-r-y :-) Oui :( >> <*ot> > > -- http://mail.python.org/mailman/listinfo/python-list

Re: Noob questions about Python

2007-10-17 Thread Bruno Desthuilliers
Ixiaus a écrit : > I have recently (today) just started learning/playing with Python. So > far I am excited and impressed Welcome onboard then !-) > (coming from PHP background). > > I have a few questions regarding Python behavior... > > val = 'string' > li = list(val) > print li.reverse() >

Re: Need help in updating a global variable by a thread

2007-10-17 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hello Folks, > > My first posting here and I am a stuck in figuring out the exact way > to update a global variable from within a function that doesnt return > any value (because the function is a target of the thread and I dont > know how exactly return would work in

Re: Appending a list's elements to another list using a list comprehension

2007-10-18 Thread Bruno Desthuilliers
Debajit Adhikary a écrit : > I have two lists: > > a = [1, 2, 3] > b = [4, 5, 6] > > What I'd like to do is append all of the elements of b at the end of > a, so that a looks like: > > a = [1, 2, 3, 4, 5, 6] > > I can do this using > > map(a.append, b) And what about a.extend(b) ? > How do I

Re: Noob questions about Python

2007-10-18 Thread Bruno Desthuilliers
Stargaming a écrit : > On Wed, 17 Oct 2007 22:05:36 +0200, Bruno Desthuilliers wrote: > [snip] >> Note that there's also the reverse() function that returns a reverse >> iterator over any sequence, so you could also do: >> >> li = list('allo') &g

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Abandoned a écrit : > On Oct 18, 6:51 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Thu, 18 Oct 2007 08:41:30 -0700, Abandoned wrote: >>> import cPickle as pickle >>> a="{2:3,4:6,2:7}" >>> s=pickle.dumps(a, -1) >>> g=pickle.loads(s); >>> print g >>> '{2:3,4:6,2:7}' >>> Thank you ver

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Abandoned a écrit : (snip) > import cPickle as pickle > a="{2:3,4:6,2:7}" > s=pickle.dumps(a, -1) > g=pickle.loads(s); > print g > '{2:3,4:6,2:7}' > > Thank you very much for your answer but result is a string ?? > Of course it's a string. That's what you pickled. What did you hope ? If you want

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Richard Brodie a écrit : > "Matimus" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> I think several people have given you the correct answer, but for some >> reason you aren't getting it. Instead of saving the string >> representation of a dictionary to the database... > > Mi

Re: Convert string to command..

2007-10-18 Thread Bruno Desthuilliers
Abandoned a écrit : (snip) > I'm very confused :( > I try to explain main problem... > I have a table like this: > id-1 | id-2 | value > 23 24 34 > 56 68 66 > 56 98 32455 > 55 62 655 > 56 28 123 > ( 3 millions elements) > > I select where id=5

Re: problem with Python class creating

2007-10-18 Thread Bruno Desthuilliers
dmitrey a écrit : > Hi all, > I have the code like this one: > > from myMisc import ooIter > class MyClass: Unless you have a need for compatibility with aged Python versions, you'd be better using new-style classes: class MyClass(object): > def __init__(self): pass This is the default be

Re: Convert string to command..

2007-10-19 Thread Bruno Desthuilliers
Peter Otten a écrit : (snip) > Before you go on with your odd caching schemes -- is the database properly > indexed? Something like > > CREATE UNIQUE INDEX mytable_id1_id2 ON mytable (id-1, id-2); > > (actual syntax may differ) might speed up the lookup operation > enough that you can do without

Re: how to iterate over sequence and non-sequence ?

2007-10-19 Thread Bruno Desthuilliers
stef mientki a écrit : > Steven D'Aprano wrote: > >> On Fri, 19 Oct 2007 16:19:32 +0200, stef wrote: >> >> >> >>> Well I'm not collecting data, I'm collecting pointers to data. >>> >> >> >> I beg to differ, you're collecting data. How that data is to be >> interpreted (a string, a number,

Re: documenting excepetions in Python

2007-10-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > In python, how do I know what exceptions a method s/method/callable/ A method is only a thin wrapper around a function, and functions are just one kind of callable object (classes are another, and you can define your own...) > could raise? Practically speaking, y

Re: Convert string to command..

2007-10-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Oct 18, 1:38 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Abandoned a écrit : >> (snip) >> >>> I'm very confused :( >>> I try to explain main problem... >>> I have a table like this: >>>

Re: if..else stmt

2007-10-22 Thread Bruno Desthuilliers
bigden007 a écrit : > Hi, > I have a if..else statement in my script. The statements all execute > fine, but the problem is , even if the IF part of the statement is > true, the else part executes as well. The verion of pythin i use 2.5 > Any help is appreciatiated. My crystal ball tells me the pr

Re: calling a function from string

2007-10-22 Thread Bruno Desthuilliers
james_027 a écrit : > hi, > > i have a function that I could like to call, but to make it more > dynamic I am constructing a string first that could equivalent to the > name of the function I wish to call. how could I do that? the string > could might include name of the module. > > for example >

Re: calling a function from string

2007-10-22 Thread Bruno Desthuilliers
Jarek Zgoda a écrit : > Trent Nelson napisał(a): >>> i have a function that I could like to call, but to make it more >>> dynamic I am constructing a string first that could equivalent to the >>> name of the function I wish to call. how could I do that? the string >>> could might include name of th

Re: a question about decorator

2007-10-22 Thread Bruno Desthuilliers
Trent Nelson a écrit : (snip (rather convoluted) decorator example) > When Python first parses your code, every time it runs into '@A', it > calls A() in order to get the required decorator function. It's not happening at parsing time, but when the (decorated) def statement is executed - that is

Re: Automatic Generation of Python Class Files

2007-10-22 Thread Bruno Desthuilliers
Sunburned Surveyor a écrit : > I was thinking of a way I could make writing Python Class Files What's a "Python Class File" ? > a > little less painful. If you find writing classes in Python "painful", then either you have no experience with any mainstream language or you are doing something wr

<    12   13   14   15   16   17   18   19   20   21   >