Re: Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
Dennis Lee Bieber wrote: > On Wed, 19 Jul 2006 18:54:55 +0200, Bruno Desthuilliers > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > >>Indeed. And when you don't need too ? (the second 'o' is not a typo) >> > >

Re: using names before they're defined

2006-07-20 Thread Bruno Desthuilliers
s = [objects[upname] for upname in desc['upstream']] downs = [objects[downname] for downname in desc['downstream']] target.links(upstream=ups, downstream=downs) return objects -- 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-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Bruno Desthuilliers wrote: > >>[EMAIL PROTECTED] wrote: > > [...] > >>>Sorry, but I kinda agree with Boris here. >> >>On what ? > > > On the argument that you are (implicitly?) disagreeing with him it's

Re: Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
e anyone making such a claim. (snip) -- 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-20 Thread Bruno Desthuilliers
read-only property named 'is_active' returning the value of an attribute named '_is_active' doesn't prevent direct access to '_is_active' attribute, neither from the class nor from the client code. HTH -- 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: Warning when new attributes are added to classes at run time

2006-07-20 Thread Bruno Desthuilliers
Matthew Wilson wrote: > On Thu 20 Jul 2006 04:32:28 AM EDT, Bruno Desthuilliers wrote: (snip) > >>>class C1(C): >>> >>>standard_attributes = ['a1', 'a2'] >> >>DRY violation here. And a potential problem with inheritance

Re: Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: > (snip) >>>>>You use accessors when you need to control access to a data attribute. >>>> >>>>Indeed. And when you don't need too ? (the second 'o' is not a typo) >>>> >>

Re: question about what lamda does

2006-07-20 Thread Bruno Desthuilliers
... # that defines 'newArgs' and 'predicate' of course ... return (recursiveFunction, lambda x: 0)[predicate](newArgs) -- 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-20 Thread Bruno Desthuilliers
mystilleef wrote: > Bruno Desthuilliers wrote: >>>>>>point 2 : so anyone *can* "illegimately tampering with an object's >>>>>>internal data" at will. >>>>>> >>>>> >>>>>And this is robust how? &

Re: Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : >> You mean: >> >> class Pythonic(object): >> def __init__(self): >> self._is_active = True >> >> @apply >> def is_active(): >> def fget(self): return self._is_active >> def fset(self): raise SomeException('sorry, read-only') >> return

Re: Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
Gerhard Fiedler a écrit : > On 2006-07-20 09:40:31, Bruno Desthuilliers wrote: > > >>>I'm not sure, but there's one thing that has a potential to be the real >>>issue: what's the common way to create a property that is read-write >>>for t

Re: [OT] Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : > On Thu, 20 Jul 2006 12:52:52 +0200, Bruno Desthuilliers > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > >>Granted. Actually, it *was* a typo - but it happened to also make sens, >>so I decided it was not a typo

Re: Accessors in Python (getters and setters)

2006-07-20 Thread Bruno Desthuilliers
Ant a écrit : > Came across this article this afternoon - thought it may be of interest > to some of those following this thread... > > http://www.devx.com/opensource/Article/31593/0/page/2 > Yeah. Presenting name mangling as the usual way to have 'private' attributes, then implementing (costly)

Re: using names before they're defined

2006-07-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hiya > > Could you just talk me through this... is it: > > >>schema = {'turbine1': {'class': 'Turbine', >> 'upstream' : ('frobnicator2',), >> 'downstream' : () # nothing, >> }, >> 'frobnicato

Re: function v. method

2006-07-21 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > >>danielx wrote: >> (snip) >>> >>>Obviously, such things would be omitted from your docs, but users also >>>learn by interacting with Python, which is really one of Python's great >>>virtues.

Re: Since there was talk of if-then-else not being allowed in lambda expressions, the following is from "Dive into Python"

2006-07-21 Thread Bruno Desthuilliers
gt;>> >>>Time to tear out that page. Really. >> >>Not quite - 2.5 hasn't been released in its final version yet, and many >>projects I should imagine will take a while to upgrade. > > > Ok, use > > if cond: >value = ... # expression tha

Re: function v. method

2006-07-21 Thread Bruno Desthuilliers
of othermodule, or your used the "import othermodule" form, in which case it's pretty obvious which names belongs to othermodule. Have any other, possibly valid, reason ? > And I find variable starting or ending with an underscore ugly. :-) Too bad for you. Choose another languag

Re: question about what lamda does

2006-07-21 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > >>danielx wrote: >>(snip) >> >> >>>Python's lambda really can't be as powerful as Lisp's because Python >>>does not have expressions that do case analysis (this is not lambda's &g

Re: using names before they're defined

2006-07-21 Thread Bruno Desthuilliers
urse give a name when instanciating the object: class Named(object): def __init__(self, name): self.name = name n1 = Named('n1') print n1.name => n1 But this doesn't mean there's any correspondance between this name and a name in the current (or any other) namespace: toto = n1 n1 = "lalala" print toto.name => n1 locals()[toto.name] is toto => False -- 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: Isn't there a better way?

2006-07-21 Thread Bruno Desthuilliers
dex = foo.options.index > bar.output = foo.options.output > bar.run() > > This works, but it feels hokey or unnatural to "pass" data from one > class to another. Isn't there a better way??? What's wrong with: foo = Parse_Option() bar = Processor() bar.run(fo

Re: Coding style

2006-07-21 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > > (snip) >>Other than in PHP, Python has clear rules when an object of a builtin type >>is considered false (i.e. when it's empty). So why not take advantage of >>this? > > Because the clearest rule of all is

Re: Isn't there a better way?

2006-07-22 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, T wrote: > > >>I am using an optparse to get command line options, and then pass them >>to an instance of another class: >> >> >> >># Class that uses optparse.OptionParser >>foo = Parse_Option() >> >># Class that does the real work >

Re: How to test if object is sequence, or iterable?

2006-07-22 Thread Bruno Desthuilliers
Tim N. van der Leeuw a écrit : > Hi, > > I'd like to know if there's a way to check if an object is a sequence, > or an iterable. Something like issequence() or isiterable(). > > Does something like that exist? (Something which, in case of iterable, > doesn't consume the first element of the iter

Re: Python newbie needs constructive suggestions

2006-07-22 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > What is the idiomatically appropriate Python way to pass, as a > "function-type parameter", code that is most clearly written with a > local variable? def functionWithLocal(andArg): localVar = 42 return andArg+localVar map(functionWithLocal, range(42)) > For

Re: Nested function scope problem

2006-07-22 Thread Bruno Desthuilliers
Josiah Manson a écrit : > I found that I was repeating the same couple of lines over and over in > a function and decided to split those lines into a nested function > after copying one too many minor changes all over. The only problem is > that my little helper function doesn't work! It claims tha

Re: Nested function scope problem

2006-07-22 Thread Bruno Desthuilliers
Justin Azoff a écrit : > Simon Forman wrote: > >>That third option seems to work fine. > > > Well it does, but there are still many things wrong with it > (snip) > tok = '' > tok = toc + c > should be written as > tok = [] > tok.append(c) > and later > ''.join(toc) IIRC, s

Re: Nested function scope problem

2006-07-22 Thread Bruno Desthuilliers
Justin Azoff a écrit : > Simon Forman wrote: > >>That third option seems to work fine. > > > Well it does, but there are still many things wrong with it > > if len(tok) > 0: > should be written as > if(tok): > actually, the parenthesis are useless. -- http://mail.python.org/mailman/l

Re: Nested function scope problem

2006-07-22 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, Justin > Azoff wrote: > > >>Simon Forman wrote: >> >>>That third option seems to work fine. >> >>Well it does, but there are still many things wrong with it >> >>if len(tok) > 0: >>should be written as >>if(tok): > > > I p

Re: Python newbie needs constructive suggestions

2006-07-22 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] wrote: > > >> b) give up on using an anonymous function and create a named "successor" >> function with "def", > > > This is what you have to do. Not necessarily. map(lambda x, one=1: one + x, range(42)) >

Re: function v. method

2006-07-22 Thread Bruno Desthuilliers
danielx a écrit : > Bruno Desthuilliers wrote: > >>danielx wrote: >> >>>Bruno Desthuilliers wrote: >>> >>> >>>>danielx wrote: >>>> >> >>(snip) >> >>>>>Obviously, such things would be omitted

Re: function v. method

2006-07-22 Thread Bruno Desthuilliers
danielx a écrit : > (snip) > Sigh. I TOTALLY realize that Python works by politeness and not > enforcement. I think you are misinterpreting why I think this would be > a good idea. My concern is not with control, but with convenience. Having free access to implementation is convenient IMHO. > My

Re: function v. method

2006-07-22 Thread Bruno Desthuilliers
danielx a écrit : > Bruno Desthuilliers wrote: > >>danielx a écrit : >> >>>Bruno Desthuilliers wrote: >>> >>> >>>>danielx wrote: >>>> >>>> >>>>>Bruno Desthuilliers wrote: >>>>> >&g

Re: How to test if object is sequence, or iterable?

2006-07-22 Thread Bruno Desthuilliers
Marc 'BlackJack' Rintsch a écrit : > In <[EMAIL PROTECTED]>, Bruno Desthuilliers wrote: > > >>Tim N. van der Leeuw a écrit : >> >>>Hi, >>> >>>I'd like to know if there's a way to check if an object is a sequence, &

Re: using names before they're defined

2006-07-24 Thread Bruno Desthuilliers
;s one builtin. > while in the second case you just execute the file, and besides, you > can edit it with any Python editor. > This is certainly nice when the users are able to write python code, but that's not always the case. Also, it can be dangerous to directly execute user'

Re: function v. method

2006-07-24 Thread Bruno Desthuilliers
Antoon Pardon wrote: > On 2006-07-21, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>Antoon Pardon wrote: >> >>>On 2006-07-21, fuzzylollipop <[EMAIL PROTECTED]> wrote: >>> >>> >>>>danielx wrote: >>>> >>

Re: function v. method

2006-07-24 Thread Bruno Desthuilliers
t way: the view of the Python community is that language-inforced access restrictions are useless and annoying, IOW an unnecessary pain. Which doesn't imply that messing with implementation of other modules is actually *encouraged*. Having the possibility to easily do so is quite handy when that's the only/less worse solution, but is not a recommended approach in general. -- 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: Nested function scope problem

2006-07-24 Thread Bruno Desthuilliers
Bruno Desthuilliers wrote: (snip) > First point: the nested function only have access to names that exists > in the enclosing namespace at the time it's defined. Duh. Sometimes I'd better go to bed instead of answering posts here - I'd say less stupidities. re-reading th

Re: Nested function scope problem

2006-07-24 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > >>Josiah Manson a écrit : >> >>>I found that I was repeating the same couple of lines over and over in >>>a function and decided to split those lines into a nested function >>>after copying one too man

Re: Isn't there a better way?

2006-07-24 Thread Bruno Desthuilliers
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Bruno Desthuilliers > wrote: > > >>Lawrence D'Oliveiro a écrit : >> >> >>>If you're calling a number of different routines in >>>the Processor class, all accessi

Re: Isn't there a better way?

2006-07-24 Thread Bruno Desthuilliers
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Steve > Holden wrote: > > >>Lawrence D'Oliveiro wrote: >> >>>In message <[EMAIL PROTECTED]>, Bruno Desthuilliers >>>wrote: >>> >>> >>> &g

Re: Functions, Operators, and Overloading?

2006-07-24 Thread Bruno Desthuilliers
Michael Yanowitz a écrit : > Hello: > >Maybe I am missing something, but from what I've seen, > it is not possible to overload functions in Python. That > is I can't have a > def func1 (int1, string1): >and a > def func1 (int1, int3, string1, string2): > without the second func1 o

Re: using names before they're defined

2006-07-24 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : >>>First case is a little shorter but then you have to use a parser for it >> >>There's one builtin. > > > do you mean 'configparser'? Yes. > I'm just trying to figure out how this > works. One nice thing with Python is the interactive python shell. It makes expl

Re: Newbie Q: Class Privacy (or lack of)

2006-07-25 Thread Bruno Desthuilliers
these bugs or features? Features, definitively. > If they are features, don't they create > problems as the project gets larger? My experience is that with medium/large projects, this feature can actually help to solve a lot of problems in a much more simpler and straightforward way th

Re: When is Django going to...

2006-07-25 Thread Bruno Desthuilliers
racle support > committed--but is it going to make it into any release any time soon? > You'd probably get better answers on Django's mailing-list ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) f

Re: How do I pass a list to a __init__ value/definition?

2006-07-25 Thread Bruno Desthuilliers
self.regressors = regressors[:] # makes a copy of the list 2/ deep copy, in case you need it (but read the Fine Manual before...): import copy class MultipleRegression: def __init__(self, dbh, regressors, fund): self.dbh = dbh self.regressors = copy.deepcopy(regressors) > I really

Re: How do I pass a list to a __init__ value/definition?

2006-07-25 Thread Bruno Desthuilliers
sses: * you overwrite self.regressors somewhere else * there's at least one case where you instanciate MultipleRegression with someting that is not iterable. FWIW, always try to reduce code to the minimal runnable snippet exhibiting the problem, so others have a chance to help you. As a side-effect

Re: How do I pass a list to a __init__ value/definition?

2006-07-25 Thread Bruno Desthuilliers
ot depending on any DB or whatever. Nothing prevents you from replacing these parts with mock objects returning dummy data. And this is exactly why this process very often reveals the problem... > Thanks for you help anyways, I'll try and figure out what I can. If > necessary I'll

Re: How do I pass a list to a __init__ value/definition?

2006-07-25 Thread Bruno Desthuilliers
gt;>> d {2: 2, 3: 3} >>> > which eliminates one of the variables in the list. This *won't* turn the list into an integer: >>> l = [1, 2, 3, 4] >>> while l: ... del l[0] ... >>> l [] >>> for item in l: print item ... >>> -- 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: local moduile acess from cgi-bin

2006-07-25 Thread Bruno Desthuilliers
server run under some user ("www-data" or such). > so howi can i make this user (and the web) be able to run my python > code without having to install the modules as shared. (which i dont > think they will allow me). import sys sys.path.append('/home/amir/') should

Re: Python Stripped CSS Background Image Calls

2006-07-25 Thread Bruno Desthuilliers
few chances you get any useful answer on a unspecified web framework here. -- 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: Nested function scope problem

2006-07-25 Thread Bruno Desthuilliers
; depending on whether the pointer gets used for writing and reading, or only > for reading). In most languages, you have to explicitly declare local names one way or another. Python takes the opposite route : you have to explicitly declare global names. Since you don't declare local names, binding creates the name if it doesn't already exists in the local namespace. HTH -- 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: Need a compelling argument to use Django instead of Rails

2006-07-26 Thread Bruno Desthuilliers
Joe Knapka wrote: (snip) > Classes are effectively open in Python, too, at least > where methods are concerned, since one can do > klass.__dict__["myMethod"]=myMethod. actually, klass.myMethod = myMethod is enough... -- bruno desthuilliers python -c "print '@'

Re: Problem with readlines() and uml

2006-07-26 Thread Bruno Desthuilliers
're not in the file, obviously, no - whatever "uml heading" might be. -- 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: Problem with readlines() and uml

2006-07-26 Thread Bruno Desthuilliers
ttributes - but nothing like "headings". file.readlines() iterates over lines of a opened text file - it doesn't give a damn about what this text is, xml, python code, csv or whatever. If your file contains xml and you want to interpret the xml, you have to use a xml parser. --

Re: How to find difference in years between two dates?

2006-07-26 Thread Bruno Desthuilliers
e, which has a RelativeDateTime type that seems to do what you want: http://www.egenix.com/files/python/mxDateTime.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: Need a compelling argument to use Django instead of Rails

2006-07-26 Thread Bruno Desthuilliers
ned Smalltalk's one) FWIW, Lisp-like macro-system apart, I have difficulty imagining how a language could be more dynamic than Python... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROT

Re: How to find difference in years between two dates?

2006-07-26 Thread Bruno Desthuilliers
John Machin wrote: > Bruno Desthuilliers wrote: > >>thebjorn wrote: >> >>>For the purpose of finding someone's age I was looking for a way to >>>find how the difference in years between two dates, so I could do >>>something like: >>> &

Re: Need a compelling argument to use Django instead of Rails

2006-07-26 Thread Bruno Desthuilliers
Jaroslaw Zabiello wrote: > On Wed, 26 Jul 2006 16:25:48 +0200, Bruno Desthuilliers wrote: > > >>I have difficulty imagining how a language could be more dynamic than >>Python... > > > E.g. try to extends or redefine builtin Python classes on fly. Ok, this

Re: Need a compelling argument to use Django instead of Rails

2006-07-26 Thread Bruno Desthuilliers
IMHO. Jaroslaw, don't take me wrong, I really think that Ruby is a really nice language (while not as mature as Python when it comes to implementation and libraries). But I'm afraid that all your arguments here are nothing more than the usual Ruby/Rails hype. -- 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: Need a compelling argument to use Django instead of Rails

2006-07-26 Thread Bruno Desthuilliers
Jaroslaw Zabiello wrote: > On Wed, 26 Jul 2006 18:01:50 +0200, Bruno Desthuilliers wrote: > > >>>>I have difficulty imagining how a language could be more dynamic than >>>>Python... >>> >>>E.g. try to extends or redefine builtin Python classes o

Re: How to find difference in years between two dates?

2006-07-26 Thread Bruno Desthuilliers
John Machin wrote: > Bruno Desthuilliers wrote: > >>John Machin wrote: >> >>>Bruno Desthuilliers wrote: >> >>>Which pieces of the following seem to be working to you? >> >>John, it seems you failed to notice the use of "may" and &qu

Re: extender method

2006-07-26 Thread Bruno Desthuilliers
uper): def __init__(self, **kwargs): Super.__init__(self, **kwargs) # do additional extender-specific stuff here HTH -- 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: Need a compelling argument to use Django instead of Rails

2006-07-26 Thread Bruno Desthuilliers
Paul Rubin wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > >>>Ruby has nice security system (private, protected, public scopes >>>for methods and attributes, >> >>This is not "security", this is data-hiding. And IIRC, Ruby's attr

Re: How to find difference in years between two dates?

2006-07-27 Thread Bruno Desthuilliers
thebjorn wrote: > Bruno Desthuilliers wrote: > [...] > >>Possible solution: >> >>import mx.DateTime as dt >>def age(date): >>return dt.Age(dt.today(), date).years >>born = dt.Date(1967, 5, 1) >>assert age(born) == 39 > > > dealb

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Bruno Desthuilliers
estriction/ > --I guess I've been doing Java too long :) indeed !-) -- 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: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Bruno Desthuilliers
: > > What are the benefits from this? There must be something really good > (and hopefully safe) you can do with it only from the outside. I don't > have much problem over-riding functions from the inside of the class. > But from the outside, I fail to see why anyone needs to a

Re: Need a compelling argument to use Django instead of Rails

2006-07-27 Thread Bruno Desthuilliers
Jaroslaw Zabiello wrote: > On Wed, 26 Jul 2006 18:20:44 +0200, Bruno Desthuilliers wrote: > > >>May I suggest that you learn some Lisp dialect ? > > > Nope. I hate Lisp syntax. This should not prevent you from learning it - at least, you'd then avoid making

Re: Need a compelling argument to use Django instead of Rails

2006-07-27 Thread Bruno Desthuilliers
Jaroslaw Zabiello wrote: > On Wed, 26 Jul 2006 18:23:22 +0200, Bruno Desthuilliers wrote: > > >>>>Care to write an external DSL in Ruby ? >>> >>>? >> >>I mean : write a parser and interpreter for a DSL. In Ruby. > > > I see. Nope.

Re:[OT] Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Bruno Desthuilliers
Ray wrote: > Bruno Desthuilliers wrote: > >>Ray wrote: >>Ray, please, don't top-post > > > Um, top-post? I'm using Google News and it looks like it is placed > correctly in the thread... or you're referring to a different thing? http://en.wikipedia.

Re: Need a compelling argument to use Django instead of Rails

2006-07-27 Thread Bruno Desthuilliers
Kay Schluehr wrote: > Bruno Desthuilliers wrote: > > >>>>Care to write an external DSL in Ruby ? >> >>I mean : write a parser and interpreter for a DSL. In Ruby. > > > It is this kind of stuff Rubys talk about when they mention "DSLs in >

Re: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
danielx wrote: > Bruno Desthuilliers wrote: > (snip) >> >>>Surprising for me are actually two things: 1- the fact itself, and 2- that >>>term "binding", and that whatever it means > (I'll have to read more on that, >>>now that I know the

Re: using names before they're defined

2006-07-27 Thread Bruno Desthuilliers
I need a full blown app-specific DSL - which can be as simple as a Python file with dicts, lists, 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: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
Antoon Pardon wrote: > On 2006-07-27, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>danielx wrote: >> >>>Bruno Desthuilliers wrote: >>> >> >>(snip) >> >>>>>Surprising for me are actually two things: 1- the fact itsel

Re: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
Antoon Pardon wrote: > On 2006-07-27, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > (snip) >>>>It can only take you so far. Now it's time you know the truth: there are >>>>*no* 'variables' in Python (hence the term 'binding'). >&g

Re: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
Gerhard Fiedler wrote: > On 2006-07-27 09:42:16, Bruno Desthuilliers wrote: > > >>>Are you saying Python variables don't hold references to "actual" Python >>>objects? >> >>Exactly. >> >> >>>That idea has been working w

Re: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
Antoon Pardon a écrit : > On 2006-07-27, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>Antoon Pardon wrote: >> >>>On 2006-07-27, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >>> >> >>(snip) >> >>>>>&g

Re: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
Gerhard Fiedler a écrit : > On 2006-07-27 13:44:29, Bruno Desthuilliers wrote: > > >>What bother me with the "hold" term is that I understand it as meaning >>that the name is some kind of container by itself - which it is not. >>Consider the following:

Re: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
Gerhard Fiedler a écrit : > On 2006-07-25 13:33:40, Dennis Lee Bieber wrote: > > >>>Surprising for me are actually two things: 1- the fact itself, and 2- that >>>term "binding", and that whatever it means (I'll have to read more on that, >>>now that I know the term) is different for read-only and

Re: Nested function scope problem

2006-07-27 Thread Bruno Desthuilliers
Gerhard Fiedler a écrit : > On 2006-07-27 14:15:34, Dennis Lee Bieber wrote: > > >>>In a language like C the name doesn't hold anything either. The name is >>>just a way for refering to a memory space which will hold something. >>> >> >> Except for one difference... In C (and most other lan

Re: help: output arrays into file as column

2006-07-27 Thread Bruno Desthuilliers
bei a écrit : Please don't top-post > Hi,Simon, > > Thanks for your reply.It's very helpful :) > But I am sorry for my given example.Actually, my data in the arrays are > all float point datas.And I use integer in the example.The code is like > this. > ("x,v,...,h" are floating point number arra

Re: Process files in order

2006-07-27 Thread Bruno Desthuilliers
Khoa Nguyen a écrit : > Hi, > > I have a requirement to process all files in a directory in > chronological order. Access time, modification time ? Ascending, descending ?-) > The os.listdir() function, however, lists the > files in random order. Is there a similar function in Python that > allo

Re: Nested function scope problem

2006-07-28 Thread Bruno Desthuilliers
Gerhard Fiedler a écrit : > On 2006-07-27 17:10:55, Bruno Desthuilliers wrote: > > >>>Isn't being on the LHS the only way to write to a non-mutable object? >> >>You *don't* "write to a non-mutable object". You rebind the name to >&g

Re: using names before they're defined

2006-07-28 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : >>>Hiya, you might be interested in this alternative config parsing >>>program: >>>http://www.voidspace.org.uk/python/configobj.html >> >>Yes, I know it. But I don't like it. Either a simple ini file do the >>trick, or I need a full blown app-specific DSL - which can be

Re: How to find difference in years between two dates?

2006-07-28 Thread Bruno Desthuilliers
thebjorn wrote: > Bruno Desthuilliers wrote: >> Which conversion ? How do you get the data ? as a datetime object ? as a >> (y,m,d) tuple ? as a "y-m-d" string ? Else ? > > All input routines, whether they're from a web-form, database, command > line, or a

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Bruno Desthuilliers
Steve Jobless wrote: > Bruno Desthuilliers wrote: >> Steve Jobless wrote: >>> Sybren Stuvel wrote: >>> >>>> Steve Jobless enlightened us with: >>>> >>>>> The first case can be just a typo, like: >>>>> >>>&g

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Bruno Desthuilliers
Ray wrote: > Bruno Desthuilliers wrote: >>> I'd rather let a machine to do that. Wasn't computer created for tasks >>> like this? (No, not really. But...) >> There's obviously a trade-off between 'security' and flexibility. As I >> said, I

Re: Need a compelling argument to use Django instead of Rails

2006-07-28 Thread Bruno Desthuilliers
ropping at eyesight. -- 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: [OT]Newbie help - test for data type

2006-07-31 Thread Bruno Desthuilliers
ttp://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/DTML.stx/ScriptingZope.stx The mechanism is based on 'decorating' forms fields names with type annotation. In you case, this would look like: HTH -- bruno desthuilliers python -c "print '@'.join([

Re: Newbie help - test for data type

2006-07-31 Thread Bruno Desthuilliers
then the control is not successful and it's name should not appear in the request. This is defined in the html spec (sections 17.2 and 17.13.2 of html 4.01 spec). -- 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: Newbie help - test for data type

2006-07-31 Thread Bruno Desthuilliers
ment passed in the list the function works correctly >> but >> if it is passed as a string nothing happens. > > You need the isinstance() function. Not in Zope. -- 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: Newbie help - test for data type

2006-07-31 Thread Bruno Desthuilliers
on is selecteddeptcodes. > > You can use isinstance or function like that: > Zope has a better solution builtin. -- 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: class variables

2006-07-31 Thread Bruno Desthuilliers
42 >>> Foo._v 42 >>> >> All seems to work fine (case 4), but when a custom object is >> assigned, an instance variable is created instead of using theproerty >> (case 5). >> >> What goes wrong here? I'm afraid there are too much problems wit

Re: Nested function scope problem

2006-07-31 Thread Bruno Desthuilliers
gets rebound. > > Aren't you looking too much at implementation details now? > > The difference between an alias assignment and a storage assigment > is for instance totaly irrelevant for immutable objects/values like numbers. # Python a = 42 b = a del a # C int *a, *b; a = mal

Re: how to safely extract dict values

2006-07-31 Thread Bruno Desthuilliers
vals.append(mydict[key]) Too much useless lookup IMHO... vals = [] for k, v in mydict.items(): if isinstance(v, list): vals.extend(v) else: vals.append(v) !-) But this is not that different from what the OP found so ugly... -- bruno desthuilliers python -c "print '@

Re: how to safely extract dict values

2006-07-31 Thread Bruno Desthuilliers
away !-) Else, you can shorten the code a bit (NB : ignoring the 'None' case...): v = d[k] v = ([v], v)[isinstance(v, list)] And this can be hidden away in a function: def get_as_list(d, k): v = d[k] return ([v], v)[isinstance(v, list)] vals = get_as_list(mydict, mykey) I don&#

Re: how to safely extract dict values

2006-07-31 Thread Bruno Desthuilliers
terate through acts >> for val in vals: >> . > > how about: > > vals = [] > for val in mydict.values(): > try: vals.extend(val) > except: vals.append(val) >>> l = [] >>> l.extend((1, 2)) >>> l

Re: how to safely extract dict values

2006-07-31 Thread Bruno Desthuilliers
Paul Rubin wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: >> Too much useless lookup IMHO... > > Actually, you, me, and Amit all mis-read David's original exapmle. Actually, I plea not guilty - cf my answer to the OP !-) -- bruno desthuilliers python -c &q

Re: how to safely extract dict values

2006-07-31 Thread Bruno Desthuilliers
e key at all in this case. > using a try/exception case to switch between append and extend will not > work. Nope. > the scalar, coming back as a string, can certainly be iterated > and i'll end up with a bunch of characters in my list. Yes. > i like what's posted below

Re: Using Python for my web site

2006-07-31 Thread Bruno Desthuilliers
ww.sqlalchemy.org/ Now I can't tell if either one or the other beats PSP when it comes to raw perfs... My 2 cents -- 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: Need a compelling argument to use Django instead of Rails

2006-07-31 Thread Bruno Desthuilliers
what long-running application servers try to solve. mod_python is at once lower-level and a bit more powerful than PHP. It really exposes most of Apache's API to Python - which BTW doesn't make it that well-suited for shared hosting... (most of the time, updating a mod_python based app

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