Re: functions, list, default parameters

2010-11-03 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : In message 20101021235138.609fe...@geekmail.invalid, Andreas Waldenburger wrote: While not very commonly needed, why should a shared default argument be forbidden? Because it’s safer to disallow it than to allow it. Then there are quite a few python features

Re: Python documentation too difficult for beginners

2010-11-02 Thread Bruno Desthuilliers
jk a écrit : Hi, I've been coding in PHP and Java for years, and their documentation is concise, well structured and easy to scan. Others have mentioned this apparently for years (see: http://stackoverflow.com/questions/4046166/easy-to-navigate-online-python-reference-manual/4070851 and

Re: singleton problems

2010-10-03 Thread Bruno Desthuilliers
jimgardener a écrit : hi Steven, can you explain that?I didn't quite get it. I have a module say 'managerutils' where I have a class MyManager.. What Steven was talking about was to NOT use a class at all. Modules are objects and have their own namespace. And you can use threading.locals

Re: sequence multiplied by -1

2010-10-03 Thread Bruno Desthuilliers
Stefan Schwarzer a écrit : One could argue that using L[::-1] isn't obvious It *is* obvious - once you've learned slicing. obvious doesn't mean you shouldn't bother reading the FineManual. -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling an arbitrary function with the right arguments

2010-09-27 Thread Bruno Desthuilliers
John O'Hagan a écrit : How to call a function with the right arguments without knowing in advance which function? (snip) For most use case I can think of, I can only second Steven and Chris - if your functions are interchangeable then they should have a same API. Now there's at least one

Re: This Is International Don’t-Squawk-Like-A -Parrot Day

2010-09-22 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : Next we need an International Surfin’ Bird day, a day to go around and tell everybody that the bird bird bird, the bird is the word. +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie: class and __dict__ variable.

2010-09-20 Thread Bruno Desthuilliers
Terry Reedy a écrit : On 9/19/2010 1:37 PM, mafeu...@gmail.com wrote: Hallo Group Members. From time to time I see in python code following notation that (as I believe) extends namespace of MyClass. No, it does not affect MyClass, just the instance dict. class MyClass: def

Re: Learning inheritance

2010-09-20 Thread Bruno Desthuilliers
alex23 a écrit : Python only actually executes a module the first time it's imported, Beware of multithreading and modules imported under different names... There can be issues with both in some web frameowrks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning inheritance

2010-09-20 Thread Bruno Desthuilliers
Niklasro a écrit : Good to learn what I'm doing :-) since important being able to explain choices taken farther than doing it because it works. I understand the concept of modules may not correspond to java programming where I come from. Coming from Java - and specially if you only have

Re: newbie: class and __dict__ variable.

2010-09-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Mon, 20 Sep 2010 09:27:25 +0200, Bruno Desthuilliers wrote: If the class has a .__setattr__ method, the first bypasses that method, It also bypasses object.__setattribute__ and - as a consequence - any binding descriptor by the same name as the attribute being set

Re: elementwise multiplication of 2 lists of numbers

2010-09-20 Thread Bruno Desthuilliers
harryos a écrit : hi I have 2 lists of numbers,say x=[2,4,3,1] y=[5,9,10,6] I need to create another list containing z=[2*5, 4*9, 3*10, 1*6] ie =[10,36,30,6] I did not want to use numpy or any Array types.I tried to implement this in python .I tried the following z=[] for a,b in zip(x,y):

Re: program organization question for web development with python

2010-09-17 Thread Bruno Desthuilliers
Hans a écrit : (snip) Maybe I did not make my question clear. I never tried python web programing before, so I want to start from CGI. You can indeed learn quite a few things doing raw CGI - the most important one being why frameworks are a good idea !-) I read something about web

Re: help with calling a static method in a private class

2010-09-14 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : lallous lall...@lgwm.org writes: How can I keep the class private and have the following work: [code] class __internal_class(object): @staticmethod def meth1(s): print meth1:, s @staticmethod def meth2(s): print meth2:,

Re: Refactoring similar subclasses

2010-09-13 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : I have some code that currently takes four different classes, A, B, C and D, and subclasses each of them in the same way: class MyA(A): def method(self, x): result = super(MyA, self).method(x) if result == spam: return spam spam spam

Re: include a file in a python program

2010-09-10 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Mon, 06 Sep 2010 00:57:30 +0200, bussiere bussiere wrote: i've got a python.txt that contain python and it must stay as it (python.txt) Why? Is it against the law to change it? *wink* how can i include it in my program ? import python.txt doesn't work You

Re: inspect the call stack

2010-09-10 Thread Bruno Desthuilliers
bussiere bussiere a écrit : i v'e got this : i've got toto.py : import titi def niwhom(): pass and titi.py : def nipang(): pass how can i know in titi.py that's it's toto.py that is calling titi.py and the path of toto ? how can i inspect the

Re: accessing a text file

2010-09-08 Thread Bruno Desthuilliers
Baba a écrit : Dear xyz, Your question can easily be researched online. We suggest you give it a try and to look it up yourself. This will be beneficial both to you and to us. We do encourage to ask questions only when they have been researched first. On usenet - as well as on most technical

Re: Help needed - function apparently global cannot be called.

2010-09-07 Thread Bruno Desthuilliers
Ian Hobson a écrit : Hi all you experts, This has me beat. Has anyone any ideas about what might be going wrong? This is code from within a windows service (hence no print statements - no sys.stdout to print on!). I am trying to trace through to find where the code is not working. No

Re: accessing a text file

2010-09-07 Thread Bruno Desthuilliers
Baba a écrit : (snip) If i had received a friendly response from Benjamin (as opposed to Please do us a favor and at least try to figure things out on your own) According to usenet standards and given your initial question, this is a _very_ friendly answer. --

Re: mutate dictionary or list

2010-09-07 Thread Bruno Desthuilliers
Baba a écrit : Hi I am working on an exercise which requires me to write a funtion that will check if a given word can be found in a given dictionary (the hand). def is_valid_word(word, hand, word_list): Returns True if word is in the word_list and is entirely composed of letters

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : How does that compare to, say, the Kamikaze Principle? ;) Return victorious AND not at all! (All return values are packed up and thrown...;) ... and then it raises a SystemError !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Help needed - function apparently global cannot be called.

2010-09-07 Thread Bruno Desthuilliers
Ian Hobson a écrit : (snip) you may also want to read the recent using modules thread... -- http://mail.python.org/mailman/listinfo/python-list

Re: knowing the caller of an import exec question

2010-09-07 Thread Bruno Desthuilliers
bussiere bussiere a écrit : i've got toto.py : import titi def niwhom(): pass and titi.py : def nipang(): pass how can i know in titi.py that's it's toto.py that is calling titi.py and the path of toto ? You'd have to inspect the call stack. Not for the faint at heart... And

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : Back to the topic, I tend to do this: for record in Model.objects.filter(pk=42): return record return sentinel WTF alert here... Having lots of short methods helps, because return provides both control-flow and a result value. But it abuses 'for' to mean 'if'. I

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : On Sep 7, 10:12 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: Phlip a écrit : Back to the topic, I tend to do this: for record in Model.objects.filter(pk=42): return record return sentinel WTF alert here... I don't see how anyone

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : On Sep 7, 10:36 am, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Sep 7, 2010 at 10:02 AM, Phlip phlip2...@gmail.com wrote: Back to the topic, I tend to do this: for record in Model.objects.filter(pk=42): return record return sentinel How is that any better than just

Re: Subclassing by monkey-patching

2010-09-06 Thread Bruno Desthuilliers
Jason a écrit : On Sep 5, 3:53 pm, Peter Otten __pete...@web.de wrote: m = gio.File(.).monitor_directory() C = type(m) 'C' will not necessarily be 'gio.FileMonitor' — I think the internals of the GIO methods might further subclass it in some way depending on what underlying monitors are

Re: Functions continuing to ru after returning something?

2010-08-31 Thread Bruno Desthuilliers
Peter Otten a écrit : n = 1 def f(): ... global n ... try: ... return n ... finally: ... n += 1 ... The same without a global: def f(_n=[0]): try: return _n[0] finally: _n[0] += 1 But yeps, using a generator would be better. --

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Baba a écrit : level: beginner the following code looks ok to me but it doesn't work. doesn't work is about the most useless description of a problem. Please specify what you expected and what actually happens. I would like some hints as to where my reasoning / thought goes wrong def

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Richard Arts a écrit : Now there is another solution. A palindrom is made of two symetric halves, with (odd len) or without (even len) a single char between the symetric halves, ie : * odd : ABCBA ('AB' + 'C' + 'BA') * even : ABCCBA ('ABC' + 'CBA') So you just have to extract the symetric

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Dave Angel a écrit : (snip) or (untested) def is_palindrom(s): s = s.lower() return s == s[::-1] Right, go on, make me feel a bit more stupid :-/ Who's next ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterative vs. Recursive coding

2010-08-26 Thread Bruno Desthuilliers
BartC a écrit : Steven D'Aprano st...@remove-this-cybersource.com.au wrote in message news:4c6f8edd$0$28653$c3e8...@news.astraweb.com... On Fri, 20 Aug 2010 17:23:23 +0200, Bruno Desthuilliers wrote: I onced worked in a shop (Win32 desktop / accouting applications mainly) where I

Re: Using String Methods In Jump Tables

2010-08-25 Thread Bruno Desthuilliers
Tim Daneliuk a écrit : On 8/19/2010 7:23 PM, Steven D'Aprano wrote: On Thu, 19 Aug 2010 18:27:11 -0500, Tim Daneliuk wrote: Problem: Given tuples in the form (key, string), use 'key' to determine what string method to apply to the string: table = {'l': str.lower, 'u': str.upper}

Re: Iterative vs. Recursive coding

2010-08-24 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Fri, 20 Aug 2010 17:23:23 +0200, Bruno Desthuilliers wrote: Steven D'Aprano a écrit : On Thu, 19 Aug 2010 22:00:16 +, Martin Gregorie wrote: Recursion can be quite a trick to get your mind round at first Really? Do people actually find the *concept

Re: 79 chars or more?

2010-08-20 Thread Bruno Desthuilliers
Stefan Schwarzer a écrit : Hi Neil, On 2010-08-17 14:42, Neil Cerutti wrote: (snip) Looking through my code, the split-up lines almost always include string literals or elimination of meaningless temporary variables, e.g.: self.expiration_date = translate_date(find(response,

Re: A question to experienced Pythoneers

2010-08-20 Thread Bruno Desthuilliers
Rony a écrit : It looks like I forgot to specify that the product is a totaly new product build from scratch, not an upgrade from an existing product. Still the advice to first find out what went wrong with the previous project is a very sensible one. Technical problems do exist, but from

Re: Iterative vs. Recursive coding

2010-08-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Thu, 19 Aug 2010 22:00:16 +, Martin Gregorie wrote: Recursion can be quite a trick to get your mind round at first Really? Do people actually find the *concept* of recursion to be tricky? I onced worked in a shop (Win32 desktop / accouting applications

Re: Iterative vs. Recursive coding

2010-08-20 Thread Bruno Desthuilliers
Michel Claveau - MVP a écrit : Salut ! C'est cela, la solitude du programmeur génial... @-salutations Moi aussi je t'aime, Michel !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Pop return from stack?

2010-08-19 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : Oh my ... I've seen people writing Java in Python, C++ in Python, Perl in Python, even VB in Python, but this is the first time I've meet some one who wants to write assembler in Python :) +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: passing variables as object attributes

2010-08-17 Thread Bruno Desthuilliers
Vikas Mahajan a écrit : On 16 August 2010 19:23, Nitin Pawar nitinpawar...@gmail.com wrote: you would need to define a class first with its attiributes and then you may want to initiate the variables by calling the class initilializer Actually I have to dynamically add attributes to a object.

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Bruno Desthuilliers
blur959 a écrit : Hi, all, Is there a way to get a number of files in a particular directory? I tried using os.walk, os.listdir but they are return me with a list, tuple of the files, etc. But I want it to return a number. Is it possible? len(any_sequence) --

Re: Does anyone use Quixote for web developing?

2010-08-12 Thread Bruno Desthuilliers
ph4nut a écrit : Hi all,I am learning Quixote a few days ago,,,and i have no idea about whether there is any Google Group talking about Quixote,so i post this post to check that is Quixote been talking in this group before or can i ask question about Quixote here! From the project's home page:

Re: python ide for ubuntu

2010-08-12 Thread Bruno Desthuilliers
geremy condra a écrit : (about eclipse+pydev) Or you could use a text editor and a terminal and spare yourself the agony of dealing with 600MB of Java of questionable quality ;). +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: easy question on parsing python: is not None

2010-08-09 Thread Bruno Desthuilliers
Gregory Ewing a écrit : Ethan Furman wrote: Instead of using 'is' use '=='. Maybe not as cute, but definitely more robust! It's also just as efficient if you use strings that resemble identifiers, because they will be interned, Remember : this IS an implementation detail. --

Re: Using dicts and lists as default arguments of functions

2010-08-09 Thread Bruno Desthuilliers
Johan a écrit : Dear all, Considering this test program: def tst(a={}): Stop here, we already know what will follow !-) And yes, it's one of Python's most (in)famous gotchas : default arguments values are computed only once, at function definition time (that is, when the def statement is

Re: easy question on parsing python: is not None

2010-08-06 Thread Bruno Desthuilliers
Roald de Vries a écrit : 'not None' first casts None to a bool, and then applies 'not', so 'x is not None' means 'x is True'. Obviously plain wrong : Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information.

Re: assigning variables from list data

2010-08-06 Thread Bruno Desthuilliers
Chris Hare a écrit : I have a database query result (see code below). In PHP, I would have said list(var1,var2,var) = $result Other already answered on the Python equivalent. But there's an IMHO better way, which is to use (if the DB-API connector provides it) a DictCursor, that yields

Re: easy question on parsing python: is not None

2010-08-06 Thread Bruno Desthuilliers
Richard D. Moores a écrit : On Thu, Aug 5, 2010 at 16:15, Rhodri James rho...@wildebst.demon.co.uk wrote: On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wherespythonmo...@gmail.com wrote: You're not testing for equivalence there, you're testing for identity. is and is not test

Re: The untimely dimise of a weak-reference

2010-08-02 Thread Bruno Desthuilliers
Gregory Ewing a écrit : (snip) import weakref class weakmethod(object): def __init__(self, bm): self.ref = weakref.ref(bm.im_self) self.func = bm.im_func def __call__(self, *args, **kwds): obj = self.ref() if obj is None: raise ValueError(Calling dead weak method)

Re: hasattr + __getattr__: I think this is Python bug

2010-07-28 Thread Bruno Desthuilliers
Ethan Furman a écrit : Bruno Desthuilliers wrote: Bruno Desthuilliers a écrit : Ethan Furman a écrit : Bruno Desthuilliers wrote: Duncan Booth a écrit : (snip) Or you could create the default as a class attribute from the OP: I have a class (FuncDesigner oofun) that has no attribute

Re: Nice way to cast a homogeneous tuple

2010-07-28 Thread Bruno Desthuilliers
wheres pythonmonks a écrit : Thanks ... I thought int was a type-cast (like in C++) so I assumed I couldn't reference it. Python has no C/C++ like type-cast. int is the builtin integer type, and instanciating an object in Python is done by calling it's type. Remember that in Python,

Re: python terminology on classes

2010-07-27 Thread Bruno Desthuilliers
Peng Yu a écrit : Hi I'm still kind of confused about the terminology on classes in python. Could you please let me know what the equivalent terms for the following C++ terms? C++ and Python having very different semantics and object models, there's not necessarily a straight one to one

Re: hasattr + __getattr__: I think this is Python bug

2010-07-27 Thread Bruno Desthuilliers
Ethan Furman a écrit : Bruno Desthuilliers wrote: Duncan Booth a écrit : (snip) Or you could create the default as a class attribute from the OP: I have a class (FuncDesigner oofun) that has no attribute size, but it is overloaded in __getattr__, so if someone invokes myObject.size

Re: hasattr + __getattr__: I think this is Python bug

2010-07-27 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : Ethan Furman a écrit : Bruno Desthuilliers wrote: Duncan Booth a écrit : (snip) Or you could create the default as a class attribute from the OP: I have a class (FuncDesigner oofun) that has no attribute size, but it is overloaded in __getattr__, so

Re: Why is there no platform independent way of clearing a terminal?

2010-07-27 Thread Bruno Desthuilliers
Daniel Fetchinson a écrit : Hi folks, If I'm only interested in linux and windows I know I can do import os import platform if platform.system( ) == 'Linux': clear = 'clear' else: clear = 'cls' os.system( clear ) or

Re: Why is there no platform independent way of clearing a terminal?

2010-07-27 Thread Bruno Desthuilliers
Grant Edwards a écrit : On 2010-07-27, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Daniel Fetchinson a ?crit : (snip) Why was clearing a terminal left out? What you're talking about is a shell, not a terminal (a terminal is a physical device). No, what he's

Re: hasattr + __getattr__: I think this is Python bug

2010-07-26 Thread Bruno Desthuilliers
dmitrey a écrit : (snip) This doesn't stack with the following issue: sometimes user can write in code myObject.size = (some integer value) and then it will be involved in future calculations as ordinary fixed value; if user doesn't supply it, but myObject.size is involved in calculations, then

Re: hasattr + __getattr__: I think this is Python bug

2010-07-26 Thread Bruno Desthuilliers
Duncan Booth a écrit : Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: If you don't want to create as many Whatever instances as MyClass instances, you can create a single Whatever instance before defining your class: DEFAULT_WHATEVER = Whathever() class MyClass

Re: why is this group being spammed?

2010-07-26 Thread Bruno Desthuilliers
be.krul a écrit : Why not moderate this group? This is a hi-traffic group, so it would require a huge team of moderators. -- http://mail.python.org/mailman/listinfo/python-list

Re: any issues with long running python apps?

2010-07-10 Thread Bruno Desthuilliers
Les Schaffer a écrit : i have been asked to guarantee that a proposed Python application will run continuously under MS Windows for two months time. And i am looking to know what i don't know. (snip) but none of this has anything to do with Python itself. i am sure python servers have been

Re: Only one forum app in Python?

2010-07-10 Thread Bruno Desthuilliers
Gilles Ganault a écrit : Hello I'd like to write a small web app in Python which must include a forum. So I checked the relevant article in Wikipedia, which says that only one forum app is available for Python: http://en.wikipedia.org/wiki/Comparison_of_internet_forum_software_(other)

Re: delegation pattern via descriptor

2010-07-08 Thread Bruno Desthuilliers
kedra marbun a écrit : On Jul 7, 2:46 am, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Gregory Ewing a écrit : Bruno Desthuilliers wrote: kedra marbun a écrit : if we limit our discussion to py: why __{get|set|delete}__ don't receive the 'name' 'class' from

Re: delegation pattern via descriptor

2010-07-06 Thread Bruno Desthuilliers
kedra marbun a écrit : On Jul 5, 3:42 pm, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: kedra marbun a écrit : i'm confused which part that doesn't make sense? this is my 2nd attempt to py, the 1st was on april this year, it was just a month, i'm afraid i haven't

Re: delegation pattern via descriptor

2010-07-06 Thread Bruno Desthuilliers
Gregory Ewing a écrit : Bruno Desthuilliers wrote: kedra marbun a écrit : if we limit our discussion to py: why __{get|set|delete}__ don't receive the 'name' 'class' from __{getattribute|{set|del}attr}__ 'name' is the name that is searched While it would have been technically possible

Re: delegation pattern via descriptor

2010-07-05 Thread Bruno Desthuilliers
kedra marbun a écrit : i'm confused which part that doesn't make sense? this is my 2nd attempt to py, the 1st was on april this year, it was just a month, i'm afraid i haven't got the fundamentals right yet. so i'm gonna lay out how i got to this conclusion, CMIIW **explanation of feeling (0)

Re: loading configuration files that are themselves python

2010-07-03 Thread Bruno Desthuilliers
Matthew Vernon a écrit : Hi, Is there a more idiomatic way of loading in a configuration file that's python code than: _temp=__import__(path,fromlist='cachestrs') cachestrs=_temp.cachestrs ? I mean, that's pretty ugly...Plain import doesn't work in this case because 'path' is a

Re: delegation pattern via descriptor

2010-07-03 Thread Bruno Desthuilliers
kedra marbun a écrit : if we limit our discussion to py: why __{get|set|delete}__ don't receive the 'name' 'class' from __{getattribute|{set|del}attr}__ 'name' is the name that is searched While it would have been technically possible, I fail to imagine any use case for this. --

Re: Python dynamic attribute creation

2010-07-02 Thread Bruno Desthuilliers
WANG Cong a écrit : On 07/01/10 23:19, Stephen Hansen me+list/pyt...@ixokai.io wrote: As long as setattr() exists in Python, that will be not so ordinary. :) setattr is perfectly ordinary. If you think setattr() is as ordinary as a trivial assignment, setattr IS a trivial assignment.

Re: Python dynamic attribute creation

2010-07-02 Thread Bruno Desthuilliers
WANG Cong a écrit : On 06/30/10 01:25, Ethan Furman et...@stoneleaf.us wrote: But if so why setattr() still exists? What is it for if we can do the same thing via assignments? Also, in order to be perfect, Python should accept to add dynamic attributes dynamically, something like PEP 363. That

Re: Ignorance and Google Groups (again)

2010-07-01 Thread Bruno Desthuilliers
D'Arcy J.M. Cain a écrit : On Wed, 30 Jun 2010 14:06:05 -0700 Stephen Hansen me+list/pyt...@ixokai.io wrote: Gmail and Google Groups are not one and the same. There's a number of people who subscribe to the list directly, use Gmail, and don't go anywhere near Google Groups. I know that. My

Re: List-type attributes and name strings

2010-07-01 Thread Bruno Desthuilliers
egbert a écrit : Normally you use setattr() if the name of the attribute is in a namestring: setattr(self, namestring, value) But my attributes are lists or dictionaries, and I don't seem to be able to use setattr anymore. Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on

Re: Python dynamic attribute creation

2010-07-01 Thread Bruno Desthuilliers
Stephen Hansen a écrit : On 6/30/10 10:37 PM, Aahz wrote: In article4c29ad38$0$26210$426a7...@news.free.fr, Bruno Desthuilliersbruno.42.desthuilli...@websiteburo.invalid wrote: Aahz a écrit : In article4c285e7c$0$17371$426a7...@news.free.fr, Bruno

Re: Ignorance and Google Groups (again)

2010-07-01 Thread Bruno Desthuilliers
D'Arcy J.M. Cain a écrit : On Thu, 01 Jul 2010 14:07:27 +0200 Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: And AFAICT you're wrong. I read and post to c.l.py using my newsreader (so NOT going thru GG), and my personal address is @gmail.com. But... From: Bruno

Re: Python dynamic attribute creation

2010-06-29 Thread Bruno Desthuilliers
Aahz a écrit : In article 4c285e7c$0$17371$426a7...@news.free.fr, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Aahz a écrit : In article 4c2747c1$0$4545$426a7...@news.free.fr, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Python has no pretention

Re: Python dynamic attribute creation

2010-06-28 Thread Bruno Desthuilliers
Aahz a écrit : In article 4c2747c1$0$4545$426a7...@news.free.fr, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Python has no pretention at elegance. That's not true at all. More precisely, I would agree with you if the emphasis is on pretention but not if the emphasis

Re: Python dynamic attribute creation

2010-06-28 Thread Bruno Desthuilliers
Carl Banks a écrit : On Jun 27, 3:49 am, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: WANG Cong a écrit : On 06/26/10 00:11, Neil Hodgson nyamatongwe+thun...@gmail.com wrote: WANG Cong: 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should

Re: Python dynamic attribute creation

2010-06-28 Thread Bruno Desthuilliers
Alexander Kapps a écrit : (snip) While I personally don't agree with this proposal (but I understand why some people might want it), I can see a reason. When disallowing direct attribute creation, those typos that seem to catch newcommers won't happen anymore. What I mean is this: class

Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit : On 06/25/10 15:34, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: WANG Cong a écrit : Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new

Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit : (snip) The point is why making metaprogramming easy is wonderful? Because it makes life easier ?-) AND, even if it were wonderful, why only this one, i.e. creating attributes by assignments, not other things? Like : class Test(object): a = 1 del Test.a ?-) 2)

Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit : On 06/25/10 17:25, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote: (snip) 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Perhaps, and

Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit : On 06/26/10 00:11, Neil Hodgson nyamatongwe+thun...@gmail.com wrote: WANG Cong: 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Most object oriented programming languages starting with Smalltalk have

Re: django csrf

2010-06-25 Thread Bruno Desthuilliers
Li Hui a écrit : When I add enctype=text/plain to a post form like form action=/auth method=post enctype=text/plain, there is a CSRF verification failed. error. But when I remove it, all is right. Who can tell me why? http://groups.google.com/group/django-users

Re: Python dynamic attribute creation

2010-06-25 Thread Bruno Desthuilliers
WANG Cong a écrit : Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a class dynamically by an assignment: class test: pass ... test.a = hello test.a 'hello' However, I still

Re: modifying standard library functionality (difflib)

2010-06-24 Thread Bruno Desthuilliers
Vlastimil Brom a écrit : Hi all, I'd like to ask about the most reasonable/recommended/... way to modify the functionality of the standard library module (if it is recommended at all). (snip) However, I'd like to ask, how to best maintain this modified functionality in the sourcecode. I tried

Re: the bugerrd code

2010-06-24 Thread Bruno Desthuilliers
Victoria Hernandez a écrit : The new mision I herits the buggered code (i do not the bugger). How do debugger him? Tahnk you very much. Vikhy :) http://docs.python.org/library/pdb.html#module-pdb http://docs.python.org/library/unittest.html#module-unittest --

Re: Simple list problem that's defeating me!

2010-06-24 Thread Bruno Desthuilliers
Neil Webster a écrit : Thanks for the help so far. The background to the problem is that the lists come from reading a dbf file. The code that I am trying to write is to merge lines of the dbf based on the first column. So in my example there would be three lines: a 2 3 4 b 10 11 12 a 2 3 4

Re: Using Classes

2010-06-24 Thread Bruno Desthuilliers
Mag Gam a écrit : I have been using python for about 1 year now and I really like the language. Obviously there was a learning curve but I have a programing background which made it an easy transition. I picked up some good habits such as automatic code indenting :-), and making my programs more

Re: best way to increment an IntVar?

2010-06-24 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : (snip - about Tkinter IntVar type) It is NOT a numeric variable in Python realms. So var+=increment can't be used because Python would rebind the name var to a new object -- but Tkinter would still be hooked to the original object and never see the

Re: modifying standard library functionality (difflib)

2010-06-24 Thread Bruno Desthuilliers
Vlastimil Brom a écrit : Many thanks for your insights! Just now, I am the almost the only user of this script, hence the consequences of version mismatches etc. shouldn't (directly) affect anyone else, fortunately. So far so good. However, I'd like to ask for some clarification about

Re: From Dict to Classes yes or no and how

2010-06-22 Thread Bruno Desthuilliers
Jerry Rocteur a écrit : (snip) As part of learning Python, I'm also learning OOP! That is why I want to know if this is doable using classes. The input is not important, I end up with the dictionary as described in the question and as I asked in the question, I'd like to access the

Re: Simple list problem that's defeating me!

2010-06-22 Thread Bruno Desthuilliers
Neil Webster a écrit : Hi all, I've got a simple problem but it's defeated me and I was wondering if somebody could point out where I'm going wrong 1/ not posting working code (got a NameError) 2/ not posting the expected output 3/ not posting the actual output or offer an alternative

Re: setup server from scratch (with or without apache?)

2010-06-21 Thread Bruno Desthuilliers
News123 a écrit : Hi, So far I never really had to ask this question and this is also, why I am stil a little shaky on this topic: So far the typical LAMP server existed already and contained already a lot of existing PHP web applications, which I couldn't remove. Therefore I just used

Re: variable variables

2010-06-18 Thread Bruno Desthuilliers
someone a écrit : On Jun 18, 12:49 pm, James Mills prolo...@shortcircuit.net.au wrote: On Fri, Jun 18, 2010 at 8:31 PM, someone petshm...@googlemail.com wrote: I was looking for a short way to do it because I have a lot some_object.attr.attr or some_object.other_attr.attr in code. it looks

Re: constructing an object from another instance of the same class

2010-06-18 Thread Bruno Desthuilliers
Christoph Groth a écrit : Dear all, sometimes it is handy to have a function which can take as argument anything which can be converted into something, e.g. def foo(arg): arg = float(arg) # ... I would like to mimic this behavior of float for a user-defined type, e.g. def bar(arg):

Re: variable variables

2010-06-18 Thread Bruno Desthuilliers
someone a écrit : On Jun 18, 2:05 pm, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid wrote: (snip) Still has a code smell thing to me, but hard to say not knowing the real code and context. sorry, code is not about printing variables rather accessing, it's just example

Re: constructing an object from another instance of the same class

2010-06-18 Thread Bruno Desthuilliers
Christoph Groth a écrit : Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid writes: It seems to me that in this way I might get problems when I pass an instance of Derived_from_my_type to bar, as it will become an instance of My_type. The instance you pass to bar won't become

Re: constructing an object from another instance of the same class

2010-06-18 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : Christoph Groth a écrit : Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid writes: (snip) In C++ Forget about C++ - Python is a different beast !-) Still, it is useful and interesting to compare languages. Indeed. But you have to understand

Re: Serializing functions

2010-06-17 Thread Bruno Desthuilliers
Matteo Landi a écrit : Some weeks ago, here on the mailing list I read about picloud[1], a python library used for cloud-computing; I was impressed by its simplicity, here is an example: import cloud def square(x): ... return x * x cloud.call(square, 10) cloud.result() 100 So, I tried to

Re: gui doubt

2010-06-17 Thread Bruno Desthuilliers
Andreas Tawn a écrit : On 06/17/2010 01:04 AM, Stephen Hansen wrote: On 6/16/10 10:40 PM, madhuri vio wrote: if i want to create a button which performs the transcription of dna to rna (snip the GUI part) Seems like a simple problem... or am I missing something? def translate():

Re: C interpreter in Lisp/scheme/python

2010-06-14 Thread Bruno Desthuilliers
answering the OP - didn't show up on c.l.py On Sun, Jun 13, 2010 at 4:07 PM, bolega gnuist...@gmail.com wrote: I am trying to compare LISP/Scheme/Python for their expressiveness. Scheme is actually a lisp, isn't it ? For this, I propose a vanilla C interpreter. I have seen a book which

  1   2   3   4   5   6   7   8   9   10   >