Re: Shebang or Hashbang for modules or not?

2007-04-13 Thread Bruno Desthuilliers
Jorgen Grahn a écrit : > On Thu, 12 Apr 2007 00:24:12 +0200, Bruno Desthuilliers <[EMAIL PROTECTED]> > wrote: > >>Chris Lasher a écrit : >> >>>Should a Python module not intended to be executed have shebang/ >>>hashbang (e.g., "#!/usr/bin/env py

Re: vocab question

2007-04-13 Thread Bruno Desthuilliers
Alan G Isaac a écrit : > Pardon the vocab question; > I'm not a computer science type. > According to the Reference Manual, > a class defintion has the structure:: > > classdef ::= "class" classname [inheritance] ":" suite > > What is the entire part before the suite called? A statemen

Re: attribute save restore

2007-04-13 Thread Bruno Desthuilliers
Carl K a écrit : > Is there a more elegant way of coding this: > > x=o.p # save .p > o.p=0 > o.m() > o.p=x # restore .p > > seems very push/pop to me - like there should be a way that doesn't need > a var (x) or the save/set lines should be done in one command. > > (personally I think .m woul

Re: Python editor/IDE on Linux?

2007-04-13 Thread Bruno Desthuilliers
Jack a écrit : > I wonder what everybody uses for Python editor/IDE on Linux? Strange as it might be, not everybody's using the same editor. > I use PyScripter on Windows, which is very good. Not sure if > there's something handy like that on Linux. Oh yes ? Why so ? The best code editor ever i

Re: Python editor/IDE on Linux?

2007-04-13 Thread Bruno Desthuilliers
7stud a écrit : > Jack wrote: > >>I wonder what everybody uses for Python editor/IDE on Linux? >>I use PyScripter on Windows, which is very good. Not sure if >>there's something handy like that on Linux. I need to do some >>development work on Linux and the distro I am using is Xubuntu. > > > Ev

Re: help

2007-04-13 Thread Bruno Desthuilliers
pierre-yves guido a écrit : > hello (I hope my english is not so bad), De ce point de vue là, ça peut aller... > I'm doing a training course and I'm a newbie in Python. My problem : > I have a form, HTML form ? GUI form ? In both cases, using which environment/libs/framework ? > and when I cl

Re: Any way to refactor this?

2007-04-13 Thread Bruno Desthuilliers
John Salerno a écrit : > Setting aside, for the moment, the utility of this method or even if > there's a better way, I'm wondering if this is an efficient way to do > it. I admit, there was some copying and pasting, which is what prompts > me to ask the question. Here's the method. (I hope it l

Re: vocab question

2007-04-13 Thread Bruno Desthuilliers
Steven Bethard a écrit : > Bruno Desthuilliers wrote: > >> Alan G Isaac a écrit : >> >>> Pardon the vocab question; >>> I'm not a computer science type. >>> According to the Reference Manual, >>> a class defintion has the structure:: &g

Re: Python editor/IDE on Linux?

2007-04-13 Thread Bruno Desthuilliers
Greg Donald a écrit : > On 4/13/07, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >> Except for real programmers... > > That's correct. We use: > > # dd if=/dev/tty of=/dev/hda1 > > and such. > Hear hear !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: help

2007-04-13 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : > pierre-yves guido a écrit : > >> hello (I hope my english is not so bad), > > > De ce point de vue là, ça peut aller... > Oh, yes, while we're at it, I forgot to mention: there's also a french Python newsgroup, fr.comp.l

Re: File DB instead of real database?

2007-04-16 Thread Bruno Desthuilliers
Jia Lu a e'crit : > Hello all > > I donot want to use a real DB like MySQL ... Whether MySQL is qualifies as a "real DB" is still an open question. But you can use SQLite, which is an embedded SQL database. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python editor/IDE on Linux?

2007-04-16 Thread Bruno Desthuilliers
Ali a écrit : > On 14 Apr, 05:48, "Jack" <[EMAIL PROTECTED]> wrote: > >>That's a good one. I got to find out what's special with Emacs :) > > > The users. > +10 OT-QOTW !-) (ouch, it hurts...) -- http://mail.python.org/mailman/listinfo/python-list

Re: strange behaviour with keyword arguments and inheritance

2007-04-17 Thread Bruno Desthuilliers
matthewperpick a écrit : > Check out this toy example that demonstrates some "strange" behaviour > with keyword arguments and inheritance. Nope. It demonstrates that default arguments are eval'd only once (when the def statement is eval'd), which is documented and a FAQ. > I have a > very rudime

Re: Python 3K or Python 2.9?

2007-09-14 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Bruno Desthuilliers wrote: >> Bjoern Schliessmann a écrit : > >>> Why don't you make a preprocessor which accepts method >>> declarations without "self" and fixes them? >> The problem being that there's no suc

Re: mass editing for keys in a dictionary

2007-09-14 Thread Bruno Desthuilliers
james_027 a écrit : > hi, > > How could I transform something like this > > dict_1 = {'customer_id':1, 'item_id':3, amount:100} > > into > > dict_2 = {'customer':1, 'item':3, amount:100} dict_2 = dict((k[:-3], v) for k, v in dict_1.iteritems()) -- http://mail.python.org/mailman/listinfo/pytho

Re: subclass of integers

2007-09-14 Thread Bruno Desthuilliers
Zentrader a écrit : > This would accept ints, floats, and decimal types. It doesn't... > import decimal Useless > class Nint(int): > def __add__(self, x, y): The prototype for __add__ is __add__(self, other) > try: > return x+y > except: > return No

Re: subclass of integers

2007-09-14 Thread Bruno Desthuilliers
Mark Morss a écrit : > I would like to construct a class that includes both the integers and > None. I desire that if x and y are elements of this class, and both > are integers, then arithmetic operations between them, such as x+y, > return the same result as integer addition. However if either

Re: Python 3K or Python 2.9?

2007-09-16 Thread Bruno Desthuilliers
John Roth a écrit : > On Sep 12, 11:35 am, TheFlyingDutchman <[EMAIL PROTECTED]> wrote: > >>On Sep 12, 4:40 am, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: >> >>>Ivan Voras wrote: >>> What does "self" have to do with an object model? It's an function/method argument that might as well b

Re: Python 3K or Python 2.9?

2007-09-16 Thread Bruno Desthuilliers
Erik Jones a écrit : > On Sep 14, 2007, at 11:54 PM, David Trudgett wrote: > >> TheFlyingDutchman <[EMAIL PROTECTED]> writes: >> (snip) >> >> Several languages use the "object.method(args)" form, which is syntactic >> sugar for "method(object, other_args)" which Ada, for instance, uses. >> Knowi

Re: Python 3K or Python 2.9?

2007-09-17 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : >> >> >> Hi, I'm new to Python, I don't even fully know the language, never done >> a full project in Python. What's more, probably I'll never will. >> But that's not the point, the point is I want YOU people to modify the >> language you know in and out, the program wi

Re: Python 3K or Python 2.9?

2007-09-17 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > > If you wanna know why the Renault Dauphine requires the driver to pull > down on the rearview mirror in order to shift into reverse you simply > need to open the hood and remove the engine and disassemble the > transmission and you will see that it has no way of dis

Re: simple regular expression problem

2007-09-17 Thread Bruno Desthuilliers
duikboot a écrit : > Hello, > > I am trying to extract a list of strings from a text. I am looking it > for hours now, googling didn't help either. > Could you please help me? > s = """ \n\n28996\n\n\n28997\n""" regex = re.compile(r'', re.S) L = regex.findall(s) print L

Re: Web Programming thru python

2007-09-17 Thread Bruno Desthuilliers
danfolkes a écrit : (top post corrected - Daniel, please, avoid top-posting...) > On Sep 17, 7:14 am, python_lover <[EMAIL PROTECTED]> wrote: >> HI, >> >> Please help how to execute a py file with xitami. >> >> I installed xitami , downloaded lrwp file. >> >> accessing the first web application pro

Re: Saving parameters between Python applications?

2007-09-17 Thread Bruno Desthuilliers
Stodge a écrit : > I'm trying to do the following. I have a Python application that is > run: > > python app1.py --location=c:\test1 > > What I want to do is save the location parameter, so I can then do (in > the same window): > > python app2.py > > And have app2.py automatically have access t

Re: Python "with"

2007-09-17 Thread Bruno Desthuilliers
Grant Edwards a écrit : > On 2007-09-17, Laurent Pointal <[EMAIL PROTECTED]> wrote: > >> Note3: Its funny to see how Python users tries to change the language, >> does this occure with C, C++, Java, C# ? > > Yes. I remember somebody I worked with once who write a C > program using a whole pile

Re: Python "with"

2007-09-17 Thread Bruno Desthuilliers
Laurent Pointal a écrit : (snip) > Note3: Its funny to see how Python users tries to change the language, s/Python users/some new Python users/, IMHO. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3K or Python 2.9?

2007-09-17 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > On Sep 17, 4:02 am, Steve Holden <[EMAIL PROTECTED]> wrote: (snip) > I made a complaint about a small design choice. It's by no mean a "small" design choice. > I also made it in the > past tense at least once ("should have done it") and explicitly > expressed that I

Re: adding a static class to another class

2007-09-17 Thread Bruno Desthuilliers
Nathan Harmston a écrit : > HI, > > I m trying to start an api in a similar way to the djangic way of > Class.objects.all(). Ie objects is a "Manager" class. > > So: > > class Foo(object): >def __init__(self): > self.test = "NEE" > > class Manager(object): > def __init__(self):

Re: can Python be useful as functional?

2007-09-18 Thread Bruno Desthuilliers
Lorenzo Stella a écrit : > Hi all, > I haven't experienced functional programming very much, but now I'm > trying to learn Haskell and I've learned that: 1) in functional > programming LISTS are fundmental; Not exactly. They are used quite a lot, yes, but that's also the case in other paradigms.

Re: Python 3K or Python 2.9?

2007-09-18 Thread Bruno Desthuilliers
Aahz a écrit : > In article <[EMAIL PROTECTED]>, > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >> But what, given that I'm an AOL user still thinking it's kewl to hide >> behind a pseudo, what else would you expect ? > > What exactly is a "

Re: adding a static class to another class

2007-09-18 Thread Bruno Desthuilliers
Nathan Harmston a écrit : > Hi, > > I guess my description was a bit rubbish in retrospec, I dont even > think the title of my email made senseit doesnt to me now: > > class Manager(object): > def __init__(self): > pass > def dosomething(self): > return "RESULTS" > > class Foo(ob

Re: super, apply, or __init__ when subclassing?

2007-09-18 Thread Bruno Desthuilliers
exhuma.twn a écrit : > This is something that keeps confusing me. If you read examples of > code on the web, you keep on seeing these three calls (super, apply > and __init__) to reference the super-class. This looks to me as it is > somehow personal preference. But this would conflict with the "Th

Re: can Python be useful as functional?

2007-09-18 Thread Bruno Desthuilliers
Kay Schluehr a écrit : > On 18 Sep., 10:13, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Lorenzo Stella a écrit : >> >>> Hi all, >>> I haven't experienced functional programming very much, but now I'm >>> trying to learn Haskell and I&

Re: super() doesn't get superclass

2007-09-18 Thread Bruno Desthuilliers
Ben Finney a écrit : > Evan Klitzke <[EMAIL PROTECTED]> writes: > >> On Tue, 2007-09-18 at 14:15 +1000, Ben Finney wrote: >>> Why does the documentation of 'super' say that it returns the >>> superclass when *that's not true*? It doesn't return the >>> superclass, it returns the next class in the

Re: Memory Problem

2007-09-18 Thread Bruno Desthuilliers
Christoph Scheit a écrit : > On Tuesday 18 September 2007 15:10, Marc 'BlackJack' Rintsch wrote: >> On Tue, 18 Sep 2007 14:06:22 +0200, Christoph Scheit wrote: >>> Then the data is added to a table, which I use for the actual >>> Post-Processing. The table is actually a Class with several "Columns"

Re: Saving parameters between Python applications?

2007-09-18 Thread Bruno Desthuilliers
Stodge a écrit : > os.path.expanduser isn't an option; I need each console/window to > maintain different values which I wouldn't get from saving to a user's > home directory. Unless I used a different file for each console/window > but that just gets me into the same situation I'm already in. I th

Re: Using pseudonyms (was Re: Python 3K or Python 2.9?)

2007-09-18 Thread Bruno Desthuilliers
Aahz a écrit : > In article <[EMAIL PROTECTED]>, > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >> Aahz a écrit : >>> In article <[EMAIL PROTECTED]>, >>> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >>>> But what, given th

Re: Using pseudonyms (was Re: Python 3K or Python 2.9?)

2007-09-18 Thread Bruno Desthuilliers
Aahz a écrit : > In article <[EMAIL PROTECTED]>, > Steve Holden <[EMAIL PROTECTED]> wrote: >> Aahz wrote: >>> In article <[EMAIL PROTECTED]>, >>> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >>>> Aahz a écrit : >>>>

Re: Newbie question

2007-09-18 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Sep 18, 1:31 pm, "Shawn Milochik" <[EMAIL PROTECTED]> wrote: > >>On 9/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> >> >>>If I have a file name: AVC1030708.14. How do I strip out certain >>>characters from the file name? I am so used to using MID, LEFT,

Re: What's with "long running processes" ?

2007-09-18 Thread Bruno Desthuilliers
walterbyrd a écrit : > I understand that Python has them, but PHP doesn't. Really ? > I think that is because mod_php is built into apache, but mod_python > is not usually in apache. Language etc aside, what the difference between mod_php and mod_python (or mod_whatever) from apache's POV ? >

Re: can Python be useful as functional?

2007-09-18 Thread Bruno Desthuilliers
Grant Edwards a écrit : > On 2007-09-18, Steve Holden <[EMAIL PROTECTED]> wrote: > >>Lorenzo Stella wrote: >>[...] >> >>>My question is: how can we call a language "functional" if >>>it's major implementation has a limited stack? Or is my code >>>wrong? >> >>So, which environment do you habitually

Re: Pseudo-Private Class Attributes

2007-09-19 Thread Bruno Desthuilliers
Ricardo Aráoz a écrit : > That is self.__attributes > > Been reading about the reasons to introduce them and am a little > concerned. As far as I understand it if you have a class that inherits > from two other classes which have both the same name for an attribute > then you will have a name clas

Re: super() doesn't get superclass

2007-09-19 Thread Bruno Desthuilliers
Ben Finney a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > >> Ben Finney a écrit : >>> Evan Klitzke <[EMAIL PROTECTED]> writes: >>>> On Tue, 2007-09-18 at 14:15 +1000, Ben Finney wrote: >>>>> [the 'super' funct

Re: super() doesn't get superclass

2007-09-19 Thread Bruno Desthuilliers
Michele Simionato a écrit : > On Sep 19, 12:36 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: > >> The next class in the MRO *is* a superclass of the *instance*. Else it >> wouldn't be in the MRO !-) > > Bruno, there is no such a thing as a superclass in

Re: lambda-funcs problem

2007-09-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > hi all, > I need to create a Python list of lambda-funcs that are dependent on > the number of the ones, for example > > F = [] > for i in xrange(N): > F.append(lambda x: x + i) > > however, the example don't work - since i in end is N-1 it yields x+ > (N-1) for

Re: ONYX

2007-09-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi everybody! Is there anything out there that can validate and parse > some "onyx-style" xml? I don't know what's "onyx-style" xml, but if it's xml, any xml parser will parse it, and any validating parser should be able to validate it given the correct DTD. -- htt

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
A.T.Hofkamp a écrit : > Hello all, > > This morning I tried to create my own read-only dictionary, and failed > miserably. > I don't understand why, can somebody enlighten me? > > Below is a brute-force experiment that cannot deal with "x in obj", plz read > the explanation below the code: >

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
Steve Holden a écrit : > A.T.Hofkamp wrote: > (snip) >> So if copying all methods of a native dictionary is not enough, what >> should I >> do to make my class work as a dictionary WITHOUT deriving from dict >> (which will >> obviously work). >> > You have to overwrite the "__new__" method to r

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : > A.T.Hofkamp a écrit : > (snip) >> # Below is produced with >> # print '\n'.join(['self.%s = self.mydict.%s' % (v,v) >> # for v in dir(dict)]) >> # commented-out func

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
A.T.Hofkamp a écrit : > Hello all, > > This morning I tried to create my own read-only dictionary, and failed > miserably. > I don't understand why, can somebody enlighten me? > (snip) > So if copying all methods of a native dictionary is not enough, what should I > do to make my class work as a

Re: Using pseudonyms (was Re: Python 3K or Python 2.9?)

2007-09-19 Thread Bruno Desthuilliers
Aahz a écrit : > In article <[EMAIL PROTECTED]>, > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > (snip) >>>>>(For those joining only recently, my full legal name is "Aahz", which I >>>>>changed from my former name precisely becau

Re: lambda-funcs problem

2007-09-19 Thread Bruno Desthuilliers
Stéphane Larouche a écrit : (snip) > > funcs = [(lambda i: lambda x: x+i)(i) for i in xrange(10)] A bit more complex than necessary... The canonical solution is funcs = [lambda x, i=i: x+i for i in xrange(10)] -- http://mail.python.org/mailman/listinfo/python-list

Re: I MEANT ONIX.... [it was Re: ONYX]

2007-09-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (top-post corrected) > On 20 Set, 12:01, [EMAIL PROTECTED] wrote: >> On 19 Set, 21:02, Bruno Desthuilliers >> >> <[EMAIL PROTECTED]> wrote: >> >>> I don't know what's "onyx-style" xml, >> i'

Re: Will Python 3.0 remove the global interpreter lock (GIL)

2007-09-20 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : (snip) > I am confused about the benefits/disadvantages of the "GIL removal". > Is it correct that the GIL is preventing CPython from having threads? > > Is it correct that the only issue with the GIL is the prevention of > being able to do multi-threading? http://doc

Re: Lookup values from one table to another based on a value

2007-09-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > If I wanted to accomplish looking up values from one table based on a > value from another table or file, how would I go about doing this in > Python? Would I build a dictionary or an array? > > exp: > > Table1: > > Site = 103 > Lane = 2 > Dir = ? # Get this from

Re: An Editor that Skips to the End of a Def

2007-09-20 Thread Bruno Desthuilliers
W. Watson a écrit : > Is there an editor that allows one to position to put the cursor and > then by pushing some button goes to the end of the def? Emacs. And you don't even have to "push some button" (just remember the correct key sequence !-) -- http://mail.python.org/mailman/listinfo/python

Re: Lookup values from one table to another based on a value

2007-09-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Sep 20, 10:34 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] a écrit : (snip) >>> Normally in Access I would just use a Dlookup and be done with it, or >>> use a Recordset in VB. Thanks guys. >> What

Re: Will Python 3.0 remove the global interpreter lock (GIL)

2007-09-20 Thread Bruno Desthuilliers
Ben Finney a écrit : (snip) > One common response to that is "Processes are expensive on Win32". My > response to that is that if you're programming on Win32 and expecting > the application to scale well, you already have problems that must > first be addressed that are far more fundamental than th

Re: Odd files; just left behind?

2007-09-20 Thread Bruno Desthuilliers
Robin Becker a écrit : > John J. Lee wrote: > >> Robin Becker <[EMAIL PROTECTED]> writes: >> >>> I see a folder .python-eggs in my home directory on one of our servers >>> with various .so files >>> >>> ~/.python-eggs/MySQL_python-1.2.2-py2.3-freebsd-6.1-SECURITY-i386.egg-tmp/_mysql.so >>> >>> >

Re: Lookup values from one table to another based on a value

2007-09-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) > > If I flipped the Table being looked up not to repeat, would that make > things easier to look up a value in? Don't repeat informations. -- http://mail.python.org/mailman/listinfo/python-list

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Bruno Desthuilliers
Ben Finney a écrit : > "W. Watson" <[EMAIL PROTECTED]> writes: > >> Is vim just an editor or is it capable of running and debugging a >> program, as well? > > (Please don't top-post. Instead, reply below each point to which > you're responding, removing quoted text irrelevant to your response.) >

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Bruno Desthuilliers
W. Watson a écrit : > How about in the case of MS Win? > > Ben Finney wrote: >> >> (Please don't top-post. Instead, reply below each point to which >> you're responding, removing quoted text irrelevant to your response.) >> Wayne, may I second Ben on his suggestion to stop top-posting ? -- http:

Re: Zope review

2007-09-21 Thread Bruno Desthuilliers
Norm a écrit : > Hi, > > without meaning to start a flame war between the various python web > tools, I was wondering if anyone had a review of the status of Zope. > For example, is it being used for new projects or just maintenance? > > I really like the look of Zope 3, and the interface/schema

Re: about __str__

2007-09-21 Thread Bruno Desthuilliers
Konstantinos Pachopoulos a écrit : > Hi, > i have the following class: > === > class CmterIDCmts: def __init__(self,commiterID,commits): >self.commiterID_=long(commiterID) >self.commits_=long(commits) > >def __str__(self)

Re: Python 3K or Python 2.9?

2007-09-21 Thread Bruno Desthuilliers
Ron Adam a écrit : > > > TheFlyingDutchman wrote: > >> I am not talking about the way it does it, but rather, the way it >> could do it or... could have done it. That requires no knowledge of >> how the interpreter currently does it unless I am proposing something >> that no interpreter in the w

Re: Odd files; just left behind?

2007-09-21 Thread Bruno Desthuilliers
Robin Becker a écrit : > Bruno Desthuilliers wrote: >> Robin Becker a écrit : >>> John J. Lee wrote: >>> >>>> Robin Becker <[EMAIL PROTECTED]> writes: >>>> >>>>> I see a folder .python-eggs in my home directory on on

Re: Odd files; just left behind?

2007-09-21 Thread Bruno Desthuilliers
Robin Becker a écrit : > Bruno Desthuilliers wrote: > >>> >>> >>> >>> it would seem simpler to have the .so files inside the site-packages >>> and there's the question of why this folder has to be obfuscated >>> (na

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Cristian a écrit : (snip) > To me, the biggest setback for new programmers is the different syntax > Python has for creating functions. Instead of the common (and easy to > grasp) syntax of foo = bar It's actually a mostly *un*common syntax when it comes to functions. The only "mainstream" langua

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Kay Schluehr a écrit : (snip) > > I checked out Io once and I disliked it. I expected Io's prototype OO > being just a more flexible variant of class based OO but Io couples a > prototype very closely to its offspring. When A produces B and A.f is > modified after production of B also B.f is modif

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Kay Schluehr a écrit : > On 22 Sep., 23:17, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > >>The attribute and method (not made distinct in Io; they're called >>"slots") is much the same as with Python; the current instance is >>checked for the object, then its parents, then _its_ parents, and s

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Cristian a écrit : > On Sep 21, 4:47 pm, "Sean Tierney" <[EMAIL PROTECTED]> wrote: > >>Just tell him that "functions are like all other variables and can >>therefore be passed by other functions or returned by other functions. >>" >> > > > > > I could """Just tell him that "functions are like

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
Cristian a écrit : > On Sep 21, 5:21 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >> Ok, then what about classes ? They also are objects-like-any-other, >> after all. So should we have this syntax too ? >> >> MyClass = class(ParentClass)

Re: about __str__

2007-09-24 Thread Bruno Desthuilliers
Mikael Olofsson a écrit : > Bruno Desthuilliers wrote: >> def __str__(self): >> return "<%s:%s>" % (self.commiterID_, self.commits_) > > I would write that in the following way: > > def __str__(self): >return "<%(commiterID_)s:%(com

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Fri, 21 Sep 2007 22:07:55 +, Cristian wrote: > >> True, there is lambda, but that is very limited. It might be useful for >> key arguments, but not much else. > > No, lambda is useful for anything that any other function is useful for, > provided that you can w

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
Matthew Woodcraft a écrit : > Cristian <[EMAIL PROTECTED]> wrote: >> To me, the biggest setback for new programmers is the different >> syntax Python has for creating functions. Instead of the common (and >> easy to grasp) syntax of foo = bar Python has the def foo(): syntax. > > [...] > >> in a

Re: sorting a list numbers stored as strings

2007-09-24 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > hi, > > I have the following list - > > ["1", "11", "2", "22"] > > how do I sort it like this - > > ["1", "2", "11", "22"] source = ["1", "11", "2", "22"] result = [t[1] for t in sorted((int(item), item) for item in source)] print result -- http://mail.python.or

Re: Database Abstraction Layer And/Or ORM

2007-09-24 Thread Bruno Desthuilliers
BJ Dierkes a écrit : > Hello all, > > I am looking for opinions on preferred methods of Database Abstraction > Layer or Object Relation Mapper (I'm using Python 2.5). I have found a > number of options such as those listed here: > > http://wiki.python.org/moin/HigherLevelDatabaseProgramming >

Re: Writing Object Data to Disk

2007-09-24 Thread Bruno Desthuilliers
David a écrit : >> I would like to know if "Pickling" the class object is the only way of >> writing it to disk for persistent storage. Also, do we have a concept >> similar to "array of objects" in Python? The number of objects is only >> known at "run-time". > > Have a look at YAML. > > http://

Re: An Editor that Skips to the End of a Def

2007-09-24 Thread Bruno Desthuilliers
W. Watson a écrit : (top-post corrected) > Bruno Desthuilliers wrote: >> W. Watson a écrit : >>> How about in the case of MS Win? >>> >>> Ben Finney wrote: >>>> >>>> (Please don't top-post. Instead, reply below each point to whic

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
NickC a écrit : > On Sep 24, 9:16 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Matthew Woodcraft a écrit : >>> One reason for the different syntax is that functions, unlike most >>> other objects, know their own names (which can be shown in tracebacks >>

Re: Can a base class know if a method has been overridden?

2007-09-24 Thread Bruno Desthuilliers
Ratko a écrit : > Hi all, > > I was wondering if something like this is possible. Can a base class > somehow know if a certain method has been overridden by the subclass? If your use case is to make sure a given ('abstract') method has been overriden, the canonical solution is to raise NotImplem

Re: Can a base class know if a method has been overridden?

2007-09-24 Thread Bruno Desthuilliers
Ratko a écrit : >> If your use case is to make sure a given ('abstract') method has been >> overriden, the canonical solution is to raise NotImplementedError in the >> base class's implementation > > I am not really interested in forcing the subclass to implement a > method. I am interested in kno

Re: Nested For and While Statements

2007-09-24 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) > My actual code has different variables, but thanks for pointing that > out. I'm so used to coding in VB, where indenting isn't a problem, so > all this indenting is new to me how Python wants it dictated. statement: block line 1 block line 2 # end state

Re: Can a base class know if a method has been overridden?

2007-09-24 Thread Bruno Desthuilliers
Ratko a écrit : > bruno a écrit >>Another solution is to compare the functions wrapped by the methods: >> >>class EvtHandler: >> def __init__(self): >> onKey = getattr(self, 'onKey') >> if onKey.im_func is EvtHandler.onKey.im_func: s/is/is not/, of course >> regi

Re: the address of list.append and list.append.__doc__

2007-09-26 Thread Bruno Desthuilliers
HYRY a écrit : >> No. a.append is a "bound method" - a method that already has an >> associated instance, that will be provided as the first argument to the >> method call. Bound methods are created "on the fly". >> > > Does this means there is no method to get the original methods from > the Boun

Re: Zope review

2007-09-26 Thread Bruno Desthuilliers
Egon Frerich a écrit : > Zope 3 uses Twisted Chapter and verse ??? -- http://mail.python.org/mailman/listinfo/python-list

Re: the address of list.append and list.append.__doc__

2007-09-26 Thread Bruno Desthuilliers
HYRY a écrit : >> There's no such thing as an "original method" - what's stored as an >> attribute of the class is a plain function. FWIW, you can get at this >> function quite easily - via the im_func attribute of the method. > > I know about im_func, but I tried the im_func attribute of append a

Re: Delete values from a string using the index

2007-09-26 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > How do I delete or remove values from a list del > or string You can't. Python's strings are immutables. > using the > index. > > If a = [1,2,3,4,5,6,7,8] and I want to get rid of 1 -5, how would I do > that? del a[0:5] print a -- http://mail.python.org/mailman

Re: A question on python performance.

2007-09-26 Thread Bruno Desthuilliers
Joe Goldthwaite a écrit : > Hi everyone, > > I'm a developer who's been using python for a couple of years. I wrote a > fairly large application using it but I was learning the language at the > same time so it most of the code kind of sucks. > > I've learned a lot since then and I've been going

Re: Using closures and partial functions to eliminate redundant code

2007-09-27 Thread Bruno Desthuilliers
Matthew Wilson a écrit : > I wrote some code to create a user and update a user on a remote box by > sending emails to that remote box. When I was done, I realized that my > create_user function and my update_user function were effectively > identical except for different docstrings and a single d

Re: "No backend servers available" using httplib

2007-09-27 Thread Bruno Desthuilliers
Henrik Lied a écrit : > Hi there! > > I'm using a recipe found on ASPN [1] to upload some data to an > external server. > > The request fails, and all I get in response is "No backend servers > available". > > So I'm wondering: Is this a known exception-message in httplib, If it was, you should

Re: True of False

2007-09-27 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I tried writing a true and false If statement and didn't get > anything? I read some previous posts, but I must be missing > something. I just tried something easy: > > a = ["a", "b", "c", "d", "e", "f"] > > if "c" in a == True: > Print "Yes" > > When I run t

Re: An Editor that Skips to the End of a Def

2007-09-27 Thread Bruno Desthuilliers
Neil Cerutti a écrit : (snip) > > Vim has Python integration if you want to control it with Python > scripts. Cool! Of course, Vim needs such a capability more than > Emacs, which has the very cool elisp scripting language. FWIW, emacs is programmable in Python too IIRC. -- http://mail.python.or

Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I have a pretty simple XMLRPCServer, something along the lines of the > example: > > server = SimpleXMLRPCServer(("localhost", 8000)) > server.register_function(pow) > server.register_function(lambda x,y: x+y, 'add') > server.serve_forever() > > Now what I want to do

Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Bruno Desthuilliers
Shawn Minisall a écrit : > Fredrik Lundh wrote: > >> Shawn Minisall wrote: >> >> >> >>> Sorry, it looks like it's on the fourth line with the 3 values on >>> line 4...its reading line 3 fine >>> >>> Traceback (most recent call last): >>> File "", line 1, in >>> main() >>> File "I:\COMP

Re: ValueError: too many values to unpack,>>>

2007-09-28 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit : > On Thu, Sep 27, 2007 at 09:50:26PM +0200, Bruno Desthuilliers wrote > regarding Re: ValueError: too many values to unpack,>>>: >> Shawn Minisall a ?crit : (snip) >>> I did and it printed everything up until the 3rd line with 3 >>&

Re: A question on python performance.

2007-09-28 Thread Bruno Desthuilliers
er order functions. So to understand decorators, you first need understand the concepts of higher order functions and closures. Both are documented in many places on the web. > Bruno Desthuilliers wrote: > >> IOW, direct access to obj.__class__.__dict__ bypasses both inheritence

Re: Delete spaces

2007-09-28 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > If I have a text file that is delimited by spaces, spaces or tabs ? > how do I import it > and get to comma delimited? Here is a row of data from the text file: > > 1110:55:14 265 8.5 > 1.4+1.1 2.5 Class-2 0 > I tried

Re: Can you please give me some advice?

2007-09-30 Thread Bruno Desthuilliers
Byung-Hee HWANG a écrit : > Hi there, > > What is different between Ruby and Python? Not much - both are hi-level dynamic object oriented languages with some functional aspects - and quite a lot (their respective object models are totally different). Also, Python, being somewhat older, has pe

Re: New to python

2007-09-30 Thread Bruno Desthuilliers
Googy a écrit : > I am new to python... > > The programming language i know well is C > Can any one recommend me the good ebook for beginners. I have loads of > ebooks but i am not able to decide which to start with which book. > Also i am learning XML so later on i can switch to books on Python a

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