Re: Multiple hierarchies and method overloading

2006-04-25 Thread bruno at modulix
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > "Ben Cartwright" <[EMAIL PROTECTED]> wrote: > > >>Philippe Martin wrote: >> >> >>>I renamed A_Func(self) to fix that ... but is there a cleaner way around ? >> >>When using multiple inheritence, the order of the base classes matters!

Re: OOP / language design question

2006-04-25 Thread bruno at modulix
Duncan Booth wrote: (snip) > Usually though, if a subclass doesn't immediately call the base class > constructors as the first thing it does in __init__ it indicates poor code > and should be refactored. Not necessarily. It's a common case to have some computations to do/some attributes to set i

Re: OOP / language design question

2006-04-25 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I was wondering, why you always have to remember to call bases' > constructors s/constructors/__init__/ the __init__() method is *not* the constructor. Object's instanciation is a two-stage process: __new__() is called first, then __init__(). -- bruno desthuillier

Re: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-25 Thread bruno at modulix
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > bruno at modulix <[EMAIL PROTECTED]> wrote: > > >>Lawrence D'Oliveiro wrote: >>(snip) >> >>>I think you're taking Python's OO-ness too seriously. One of the &

Re: Zope 3

2006-04-25 Thread bruno at modulix
Derick van Niekerk wrote: > I have been developing in PHP for some time now and needed to look into > application frameworks to speed up my development. I was looking into > Horde and CakePHP before I was introduced to Python. I started learing > python and within a few *hours* I already wrote my f

Re: OOP / language design question

2006-04-25 Thread bruno at modulix
Duncan Booth wrote: > bruno at modulix wrote: > > >>Duncan Booth wrote: >>(snip) >> >>>Usually though, if a subclass doesn't immediately call the base class >>>constructors as the first thing it does in __init__ it indicates poor >>>

Re: Zope 3

2006-04-25 Thread bruno at modulix
Benji York wrote: > bruno at modulix wrote: > >> Zope is a world in itself - and is certainly not the simplest tool to >> learn (nor the most pythonic). > > > Those statements apply more to Zope 2 than Zope 3 (and Zope 2 is moving > more and more toward Zope 3 thes

Re: Zope 3

2006-04-25 Thread bruno at modulix
through the tutorial (which is simply a Zope product you can > add from the main page of the ZMI (Zope Management Interface), have a peek > at the Zope book > (http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/view). Actually, the OP was asking about Zope3, which is a *very* di

Re: OOP / language design question

2006-04-26 Thread bruno at modulix
Duncan Booth wrote: > Alex Martelli wrote: > > >>>What I think I'm trying to get at is that I believe that most >>>situations where someone actually tries to do something in the base >>>initialiser which requires calling a virtual method are probably als

Re: OOP / language design question

2006-04-26 Thread bruno at modulix
Duncan Booth wrote: > bruno at modulix wrote: > > >>It's *already* split : __new__ construct the object, __init__ >>initialize it. >> >>>That's why I would go for the 2-phase construction: >> >>But that's already what you have. &g

Re: Inherit from array

2006-04-26 Thread bruno at modulix
TG wrote: > Hi there. > > I'm trying to create a simple class called Vector which inherit from > array. Which array ? [EMAIL PROTECTED] ~ $ python Python 2.4.2 (#1, Feb 9 2006, 02:40:32) [GCC 3.4.5 (Gentoo 3.4.5, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type "help", "copyright", "credits" or "licen

Re: Inherit from array

2006-04-26 Thread bruno at modulix
TG wrote: > Obviously, there is something I didn't catch in python's inheritance. Nope. Obviously, array.array doesn't respect the usual rules. > from array import array > class Vector(array): > def __init__(self,size): > print self.typecode > array.__init__(self,'f') > > >>

Re: Inherit from array

2006-04-26 Thread bruno at modulix
Philippe Martin wrote: > > bruno at modulix wrote: >>TG wrote: >> >>>Hi there. >>> >>>I'm trying to create a simple class called Vector which inherit from >>>array. >> >>Which array ? > > I think he did > > fr

Re: Inherit from array

2006-04-26 Thread bruno at modulix
Sion Arrowsmith wrote: > TG <[EMAIL PROTECTED]> wrote [something like]: >>from array import array > >>class Vector(array): >> def __init__(self,size): >> array.__init__('f') >> >>v = Vector('c') >>print repr(v) >> >>will output : >> >>array('c') > > > Is this a case of new-sytle classes

Re: OOP / language design question

2006-04-26 Thread bruno at modulix
e. But Duncan (implicitely) meant "deleting the method *and* the calls to the method". The point is that dothis() returns a value (that is not used), and doesn't modify the state of self. Or at least, this what *I* understood. > Is the point that one could refactor out the self.dot

Re: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-27 Thread bruno at modulix
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > >>Sandra-24 a écrit : >> >>>Lawrence D'Oliveiro wrote: >>> >>> In article <[EMAIL PROTECTED]>, "Sandra-24" <[EMAIL PROTECTED]> wrote: >Now that is a clever

Re: OOP / language design question

2006-04-27 Thread bruno at modulix
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > "Carl Banks" <[EMAIL PROTECTED]> wrote: > > >>bruno at modulix wrote: >> >>>[EMAIL PROTECTED] wrote: >>> >>>>I was wondering, why you always ha

Re: Inherit from array

2006-04-27 Thread bruno at modulix
TG wrote: > Hmm ... I'm definitely not a python wizard, but it seems to be quite a > special case that breaks the rules ... Yes and no. The primary use case for __new__ was to allow subclassing of immutable types. array.array is not immutable, but it's still a special case, in that it enforce typ

Re: String Exceptions (PEP 352)

2006-04-27 Thread bruno at modulix
erical cruft and warts accumulated from the past, it's time to throw away and clean up, even if it breaks a lot of things. Trying to keep compatibility at any price would be just suicidal IMHO - time to get rid of old warts and come back to simplicity. "one obvious way to do it" ru

Re: String Exceptions (PEP 352)

2006-04-27 Thread bruno at modulix
bruno at modulix wrote: > Thomas Guettler wrote: > >>Hi, >> >>I like python because it is compatible to old versions. That's way I think >>string exceptions should not be deprecated. >> >>I use string exceptions if the condition for an assertio

Re: Editing a function in-memory and in-place

2006-04-27 Thread bruno at modulix
Peter Otten wrote: (snip) > > Can you cheat and just assign another known good func_code object? def hello(): print "hello" > ... def world(): print "world" > ... def use_it(hello=hello, world=world): > ... hello() > ... world() > ... use_it() > hello > world world.func

Re: Get all attributes of a com object

2006-04-27 Thread bruno at modulix
eicwo01 wrote: > Without to know the names, is it possible to dump all attributes of a > com object? > from win32com.adsi import * from module import * is Bad(tm) > objDom = ADsOpenObject("LDAP:/ ... > print ???"all attributes"??? of objDom Look at dir() and

Re: OOP techniques in Python

2006-04-27 Thread bruno at modulix
Panos Laganakos wrote: > I've been thinking if there's a point in applying some specific OOP > techniques in Python as we do in other languages. Yes - but some of these techniques are somewhat python-specific. > i.e. we usually define private properties and provide public functions > to access th

Re: Get all attributes of a com object

2006-04-28 Thread bruno at modulix
eicwo01 wrote: > Thanks for your tips. > But dir() and inspect did not really help. Really ? def dump(obj): for name in dir(obj): print getattr(obj, name) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])

Re: Get all attributes of a com object

2006-04-28 Thread bruno at modulix
Duncan Booth wrote: > bruno at modulix wrote: > > >>eicwo01 wrote: >> >>>Thanks for your tips. >>>But dir() and inspect did not really help. >> >>Really ? >> >>def dump(obj): >> for name in dir(obj): >> print ge

Re: append function problem?

2006-04-28 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > hello, recently i tried to use list.append() function in seemingly > logical ways, What seems logical and how it really works may not be the same... As a general rule, for builtin types, destructive methods returns None. I personnaly find it a wart, but what, it's the B

Re: Non-web-based templating system

2006-04-28 Thread bruno at modulix
this data, ideally by taking an RTF >>or plaintext file as a template and replacing placeholder tags with my >>data. >>Are there any good pre-written systems that would allow me to do this? > > > Maybe the built-in string interpolation is sufficient? > &

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread bruno at modulix
lly unaware of this. > The syntax "b." is completely > different from the syntax of any other type of parameter. > > The mismatch between the number of parameters declared in the method > signature and the number of arguments actually passed There's no mismatch at this l

Re: simultaneous assignment

2006-05-02 Thread bruno at modulix
John Salerno wrote: > Is there a way to assign multiple variables to the same value, > but so > that an identity test still evaluates to False? re-phrase it according to how Python works, and you'll get the answer: "Is there a way to bind multiple names to the same object, but so the identity of

Re: simultaneous assignment

2006-05-02 Thread bruno at modulix
John Salerno wrote: > Boris Borcic wrote: > >> >>> w == x >> False >> >>> w is x >> True >> >>> > > > That's the opposite of what I want to happen. And that wouldn't be really helpful anyway !-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) fo

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread bruno at modulix
Edward Elliott wrote: > bruno at modulix wrote: > >>>that 1) b is an object not a module*, and 2) objects pass references to >>>themselves as the first argument to their methods. >> >>Nope. It's the MethodType object (a descriptor) that wraps the functio

Re: simultaneous assignment

2006-05-03 Thread bruno at modulix
John Salerno wrote: > Bruno Desthuilliers wrote: > >> But my question (sorry, it may not have been clear) was more along the >> line of : "why do you worry about identity in the given snippet ?". > > > Actually, I kind of thought that maybe it *didn't* matter in this > particular example anyway

Re: Zope Guru...

2006-05-03 Thread bruno at modulix
bruce wrote: > Hi.. > > In doing some research into Workflow apps regarding document management, I > came across Zope. Given that it's Python Based, I figured I'd shout to the > group here... Zope is Python based, but it's a world in itself, and probably not the most pythonic app around (which do

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread bruno at modulix
Bruno Desthuilliers wrote: (snip) > Since Python 3K is supposed to be the 'clean the warts and don't bother > breaking compat' rewrite of Python, you may as well propose a PEP on > this. You'll have to really prove it doesn't break anything else in the > object model, have strong and articulate arg

Re: Binary File Reading : Metastock

2006-05-03 Thread bruno at modulix
Jack wrote: > Hi > > I am having a little trouble trying to read a binary file, I would like > to write an ascii to Metastock converter in python but am not having a > lot of success. > > The file formats are > > http://sf.gds.tuwien.ac.at/00-pdf/m/mstockfl/MetaStock.pdf > > > If any one can p

Re: Sorting a list of dictionaries by dictionary key

2006-05-03 Thread bruno at modulix
Nico Grubert wrote: > Hi there, > > I am looking for a way to sort a list containing dictionaries. > > This is my example list: > [{'Title': 'ABC', 'from_datetime': DateTime('2006/04/25 12:45:00 > GMT+2')}, {'Title': 'DEF', 'from_datetime': DateTime('2006/04/18 > 12:45:00 GMT+2')}, {'Title': 'GHI

Re: Sorting a list of dictionaries by dictionary key

2006-05-03 Thread bruno at modulix
Eric Deveaud wrote: (snip) > > sort can take a comparaison function. The problem with it is that it may slow down things a lot... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/ma

Re: Need Plone Information

2006-05-03 Thread bruno at modulix
bruce wrote: > Hi > > I've never used Python/Plone, and am wondering if I can talk with anyone > who's used Plone. I'm trying to determine if Plone could be easily used for > a potential application. Then you'd better post this to the plone and/or zope mailing lists. -- bruno desthuilliers

Re: __getattr__ on non-instantiated class

2006-05-03 Thread bruno at modulix
Larry Bates wrote: > Fredp wrote: > >>Hi >>I was wondering if it is possible to have the various magic methods, >>mainly __getattr__ and __setattr__, and @property attributes called >>when accessing the attribute of a non-intantiated class. >> >>Imagin something like this: >># >>class MyClass:

Re: __getattr__ on non-instantiated class

2006-05-03 Thread bruno at modulix
Fredp wrote: (snip) > I have something like a simple ORM which objects haven't a fixed number > of fields, and I need to have properties (or methods) for each of them, dumbiest possible example, but this should het you started class Field(object): # dummy def __init__(self, **kw): self._

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread bruno at modulix
param (usually named 'cls'). > >>>e.g. when it sees "def method (a,b)" >> >>This has to be in a class statement - else it's shouldn't be touched. > > Exactly, that's why I called it method and not func. Technically, they are st

Re: stripping unwanted chars from string

2006-05-04 Thread bruno at modulix
Edward Elliott wrote: > Bryan wrote: > >> >>> keepchars = set(string.letters + string.digits + '-.') > > > Now that looks a lot better. Just don't forget the underscore. :) > You may also want to have a look at string.translate() and strin

Re: This coding style bad practise?

2006-05-04 Thread bruno at modulix
Carl Friedrich Bolz wrote: > Bruno Desthuilliers wrote: > >> Martin P. Hellwig a écrit : >> >>> I created a class which creates a relative unique id string, now my >>> program just works fine and as expected but somehow I get the feeling >>> that I misused the __repr__ since I guess people expect

Re: This coding style bad practise?

2006-05-04 Thread bruno at modulix
Martin P. Hellwig wrote: > Bruno Desthuilliers wrote: > > >> >> Why not just use the call operator instead ? ie: >> >> >>> id = IDGenerator(...) >> >>> id() >> 01_20060424_151903_1 >> >>> id() >> 01_20060424_151905_2 >> > > Because of: > > id = IDGenerator("01",99) > id() >> >> Trace

Re: noob question: "TypeError" wrong number of args

2006-05-04 Thread bruno at modulix
t;different to when a function is created outside the class >>>definition and added as a method to the object at run-time. >>> >>>Thus breaking not only "explicit is better than implicit", >> >>This one can be subject to discussion. > > > All the

Re: noob question: "TypeError" wrong number of args

2006-05-04 Thread bruno at modulix
Edward Elliott wrote: > Ben Finney wrote: > >>As I understand it, the point was not what the code does, but to give >>a sample input (a Python program) for the "simple text processor" you >>described to wade through. > > > Ah, well then, there's no need for a full-blown parser. It should suffic

Re: scope of variables

2006-05-04 Thread bruno at modulix
Gary Wessle wrote: > Ryan Forsythe <[EMAIL PROTECTED]> writes: > > >>Gary Wessle wrote: >> >>>the example was an in-accuretlly representation of a the problem I am >>>having. my apologies. >>> (snip) > I finally was able to duplicate the error with a through away code > as follows, > >

Re: Python function returns:

2006-05-04 Thread bruno at modulix
;strHostname, &nPortNumber) You have to understand that Python and C are totally different beasts. A C variable is mostly symbolic name for a memory address, tagged with type infos. Assigning to a variable means storing a value at this address. Reading a variable means retrieving whatever va

Re: Swaying A Coder Away From Python

2006-05-04 Thread bruno at modulix
BartlebyScrivener wrote: > I'm picking this up via clp on Google Groups. I can't tell what Mr. > Lundh is referring to. The first line of his post is: "Tim Williams > wrote" but there's nothing that comes before. I had seen the article on > Django on Digg I think, but what is article Tim Williams i

Re: Python for Perl programmers

2006-05-05 Thread bruno at modulix
A.M wrote: > Hi, > > Is there any efficient online resource or book that help experienced Perl > programmers to Python? > My fellow coworker - experimented Perl coder - confirms that the official tutorial and diveintopython should be enough to get you started. Also, the Python Cookbook and read

Re: noob question: "TypeError" wrong number of args

2006-05-05 Thread bruno at modulix
Edward Elliott wrote: > bruno at modulix wrote: > >>Edward Elliott wrote: >> >>>Ah, well then, there's no need for a full-blown parser. It should >>>suffice to recognize a class definition and modify the parameter list of >>>every def i

Re: Subclassing array

2006-05-05 Thread bruno at modulix
TG wrote: > That's great, thanks ! > > To put it short, when I create a Stimulus object, it first seek > __new__() method. But if I don't define it, it looks for the one > defined in Vector. This raises a problem because the parameters passed > to Stimulus(params) aren't fitting with Vector parame

Re: String Exceptions (PEP 352)

2006-05-05 Thread bruno at modulix
Paul Rubin wrote: > bruno at modulix <[EMAIL PROTECTED]> writes: > >>What's wrong with: >> >>assert foo and bar and i > 10, \ >> "if foo and bar i must not be greater than 10" > > > It doesn't necessarily do anything. With op

Re: Method acting on arguements passed

2006-05-05 Thread bruno at modulix
tBook that only do the dispatch. Else - and depending on the context, needs, specs and whatnot, I'd look either at the visitor pattern (or any custom double-dispatch) or at an existing multimethod implementation (like David Mertz's multimethod or Philip Eby's protocol.dispatch). My 2 ce

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread bruno at modulix
s in production code, and have one of the first Python entry in the Daily WTF !-) What are you trying to do, exactly ? I've been scratching my head for at least 5 minutes without finding any sensible reason to write such code. > I know I can do this with a try but ... ??? Slightly ot, bu

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread bruno at modulix
Philippe Martin wrote: (snip) > > l_init really is a boolean parameter and l_value a value that _might_ exist > in a shelve. > > So I just want to have a parameter to a method so if the first value tested > is false (l_init) then the second (l_value) does not get tested ... because > it is the se

Re: Is this a legal / acceptable statement ?

2006-05-05 Thread bruno at modulix
Philippe Martin wrote: > bruno at modulix wrote: > > >>Philippe Martin wrote: >>(snip) >> >>>l_init really is a boolean parameter and l_value a value that _might_ >>>exist in a shelve. >>> >>>So I just want to have a parameter to

Re: Drop Down Menus...

2006-05-05 Thread bruno at modulix
bruce wrote: > Hi... > > Never used python, but I have a question regarding Drop Down Menus. Does > Python allow me to create a website, Yes. > that will permit the user to create > Drop Down menus that can be initiated with the right mouse click? Not sure to understand what you mean, but this

Re: to thine own SELF be true...

2006-05-05 Thread bruno at modulix
Mark Harrison wrote: > Is there a way to do something equivalent to "import * from self"? (snip) > > Is there a way to get rid of those the "self." references, No. > or is this > just something I need to get my brain to accept? Yes. And FWIW, "from somemodule import *" is usually considered bad

Re: easy way to dump a class instance?

2006-05-05 Thread bruno at modulix
Mark Harrison wrote: > Is there a way to automatically print all the instance > data in a class? This is for debugging, I would like > to do something like dump(self) to snapshot the state > of the object. def dump(obj): buf = ['%r %s :' % (obj, str(obj)] for name in dir(obj): attr = geta

Re: Is this a good use of __metaclass__?

2006-05-09 Thread bruno at modulix
CServer). (snip) > >>You would then have a 'server' class that just provides common >>services and dispatch to specialized objects. > > Neat. It won't play nice with dir() or SimpleXMLRPCServer's > introspection functions though (system.listMethods(), >

Re: Is this a good use of __metaclass__?

2006-05-09 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I played around with my old code before I saw your post, and I believe > I've found a solution that's a bit neater than what I had before. I > thought I could just as well post it if you're interested and have the > time. This one uses multiple inheritance, but it's legal

Re: utility functions within a class?

2006-05-09 Thread bruno at modulix
John Salerno wrote: > John Salerno wrote: > >> [EMAIL PROTECTED] wrote: >> >>> Even if you don't end up referring to self or any instance >>> attributes within the method >> >> >> Hmm, follow-up: I *do* plan to refer to instance attributes inside >> these methods (self.something), but does that re

Re: utility functions within a class?

2006-05-09 Thread bruno at modulix
John Salerno wrote: > [EMAIL PROTECTED] wrote: > >> I'm having trouble deciphering what this bit means - "but these >> functions will be called from another method in the class, not from the >> instance itself", I don't think it makes sense. > > > Yeah, I'm starting to see that as I tried to imp

Re: utility functions within a class?

2006-05-09 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > John Salerno wrote: > >>What I originally meant was that they would not be called from an >>instance *outside* the class itself, i.e. they won't be used when >>writing another script, they are only used by the class itself. > > > Yep, so you want to encapsulate the fun

Re: utility functions within a class?

2006-05-09 Thread bruno at modulix
John Salerno wrote: > John Salerno wrote: > >> [EMAIL PROTECTED] wrote: >> >>> John Salerno wrote: >>> What I originally meant was that they would not be called from an instance *outside* the class itself, i.e. they won't be used when writing another script, they are only used by th

Re: Python's regular expression?

2006-05-09 Thread bruno at modulix
Davy wrote: > Hi all, > (snip) > Does Python support robust regular expression like Perl? Yes. > And Python and Perl's File content manipulation, which is better? >From a raw perf and write-only POV, Perl clearly beats Python (regarding I/O, Perl is faster than C - or it least it was the last

Re: Memory leak in Python

2006-05-09 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I have a python code which is running on a huge data set. After > starting the program the computer becomes unstable and gets very > diffucult to even open konsole to kill that process. What I am assuming > is that I am running out of memory. > > What should I do to make

Re: List of lists of lists of lists...

2006-05-09 Thread bruno at modulix
(mylist) > > Is there a more elegant way to do it? for N: mylist = [mylist] > The maine idea is: from a list having the numbre of steps along N > dimensions, generate a list with an item at each possible point. > > Example 1: N=2 list=[2,3] result=[[1,2],[1,2],[1,2]] > Examp

Re: Why list.sort() don't return the list reference instead of None?

2006-05-09 Thread bruno at modulix
Lawrence Oluyede wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > >>However, I wonder why L.sort() don't return the reference L, the >>performance of return L and None may be the same. > > > It's not "the same". sort() does not return anything. Yes it does : it returns the None ob

Re: Why list.sort() don't return the list reference instead of None?

2006-05-09 Thread bruno at modulix
vbgunz wrote: > to throw fire on the fuel (:P), you can get the value back to an > in-place mutable change with a single expression... > > mylist = [2,3,4,1] > print mylist.sort() or mylist > > might not be too pythonic or maybe it is. I guess depends on what side > of the glass you might wish to

Re: multiline strings and proper indentation/alignment

2006-05-10 Thread bruno at modulix
John Salerno wrote: > Gary Herron wrote: > >> Gary John Salerno wrote: >> >>> How do you make a single string span multiple lines, but also allow >>> yourself to indent the second (third, etc.) lines so that it lines up >>> where you want it, without causing the newlines and tabs or spaces to >>>

Re: interactive shell -- reload definitions?

2006-05-10 Thread bruno at modulix
Metalone wrote: > I have a question about the interactive Python shell. Is it possible > to reload a file and get the new definitions. > > For example, if I do > import xyz > > Then I find a bug in some function in xyz. > So, I edit xyz.py > > I would like to reload the definitions in xyz.py wi

Re: problemi con POST

2006-05-10 Thread bruno at modulix
Heavy wrote: > Sorry, > you got reason, I thought I can write in my language, cause this is the > first time that I post a question in this group... usually, the comp.* usenet hierarchy is english-speaking. > My problem is that I > have to receive parameters from a POST method, i try to read th

Re: Memory leak in Python

2006-05-10 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (top-post corrected) > > bruno at modulix wrote: > >>[EMAIL PROTECTED] wrote: >> >>>I have a python code which is running on a huge data set. After >>>starting the program the computer becomes unstable and gets very >>>dif

Re: 2 books for me

2006-05-11 Thread bruno at modulix
ter.I am > not sure what package is best for and would like to know before I > order one of those three. I don't which is "better", but wxPython is still the best choice IMHO if you worry about portability and licencing issues. But what don't you take the time

Re: Python memory deallocate

2006-05-11 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Ok, this is true. > > Well, you consider that my app has a first windows, where I choose, for > example, the application 1. > The application 1 will be started, and it will allocate 200Mb total. > Now I want to abort this operation, and i will return to main initial > w

Re: Python memory deallocate

2006-05-11 Thread bruno at modulix
the problem *actually* was with Python - just that it *may* have to do with a memory management issue fixed in 2.5. And, while we're at it : your application uses a GUI toolkit and does image manipulations, so the problem can also come from one of these packages... I also suggested that it may h

Re: Reg Ex help

2006-05-12 Thread bruno at modulix
Edward Elliott wrote: (snip) >>don a écrit : >> >>>Also if there is a better way than using regex, please let me know. >> (snip) > > I wouldn't call these better (or worse) than regexes, but a slight variation > on the above: > > marker = s.index('/CHECKEDOUT') > branch = s [s.rindex('/', 0, mark

Re: Decorator

2006-05-12 Thread bruno at modulix
Lad wrote: > I use Python 2.3. > I have heard about decorators in Python 2.4. What Python 2.4 adds is only syntactic sugar for decorators. You can do the same - somewhat more explicitely - in 2.3. > What is the decorator useful for? FWIW, I'm not sure the name 'decorator' is such a great idea. A

Re: deleting texts between patterns

2006-05-12 Thread bruno at modulix
be delete > line13 <---to be delete > xyz > line15 > line16 > line17 > line18 > > I wish to delete lines that are in between 'abc' and 'xyz' and print > the rest of the lines. Which is the best way to do it? Should i get > everything into a list, g

Re: compiling module from string and put into namespace

2006-05-12 Thread bruno at modulix
glomde wrote: > Hi, > > I want to create a function that preprocesses a file and then imports > the parsed file. > > What I found out is that you can do something like this: > > def ImportFile(fileName): > parsedCode = Parser(fileName).Parse() > module = new.module(name) > exec parse

Re: deleting texts between patterns

2006-05-12 Thread bruno at modulix
bruno at modulix wrote: > [EMAIL PROTECTED] wrote: > (snip) > > Don't know if it's better for your actual use case, but this avoids > reading up the whole file: > def skip(iterable, skipfrom, skipuntil): > """ example usage : > >>&

Re: deleting texts between patterns

2006-05-12 Thread bruno at modulix
Fredrik Lundh wrote: (snip) > to print to a file instead of stdout, just replace the print line with a > f.write call. > Or redirect stdout to a file when calling the program !-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTEC

Re: NEWBIE: Tokenize command output

2006-05-12 Thread bruno at modulix
Tim Chase wrote: (snip) > starLines = [line for line in p.readlines() if line.startswith("*")] files are iterators, so no need to use readlines() (unless it's an old Python version of course): starLines = [line for line in p if line.startswith("*")] > or you may optionally want to prune of the "

Re: Python memory deallocate

2006-05-12 Thread bruno at modulix
Fredrik Lundh wrote: > bruno at modulix" wrote: > > >>*please* re-read carefully what I and Diez wrote earlier in this thread >>before jumping to possibly erroneous conclusion. I didn't say that the >>problem *actually* was with Python - just that it *may*

Re: design a Condition class

2006-05-12 Thread bruno at modulix
Carl J. Van Arsdall wrote: (snip) > I just wanted to make the comment that there already exists a > Condition() class in the threading module. If you plan on using your > class with the threading module you might wish to use another name. > As far as I remember, Python has namespaces, so I don't

Re: design a Condition class

2006-05-12 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Hello, > > i posted for suggestions a little idea even if it still needs further > thoughts but as i'm sure you could help :) > > if would like to implement some kind of Condition class which i coud > use to build bricks of more complex condition, conditions are based o

Re: NEWBIE: Tokenize command output

2006-05-12 Thread bruno at modulix
Tim Chase wrote: >>> starLines = [line for line in p.readlines() if line.startswith("*")] >> >> >> files are iterators, so no need to use readlines() (unless it's an old >> Python version of course): >> >> starLines = [line for line in p if line.startswith("*")] > > > Having started with some old

Re: Decorator

2006-05-12 Thread bruno at modulix
Martin Blume wrote: > "bruno at modulix" schrieb > (snip) >>def deco(func): >> print "decorating %s" % func.__name__ >> def _wrapper(*args, **kw): >>print "%s called " % func.__name__ >>res = func(*args, **kw) >>

Re: NEWBIE: Tokenize command output

2006-05-12 Thread bruno at modulix
Duncan Booth wrote: > bruno at modulix wrote: > > >>>Otherwise, just to be informed, what advantage does rstrip() have over >>>[:-1] (if the two cases are considered uneventfully the same)? >> >>1/ if your line doesn't end with a newline, lin

Re: listener program in Python

2006-05-12 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > >>I basically want to remotely shut down windows from linux and write >>such a program in python. > FWIW, s/from linux/from another machine/ -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p

Re: Decorator

2006-05-12 Thread bruno at modulix
t him/her to the documentation. >>>Another question: Isn't decorating / wrapping >>> usually done at runtime, so that the @deco >>>notation is pretty useless (because you'd >>>have to change the original code)? >> >>Please explain why that

Re: which is better, string concatentation or substitution?

2006-05-12 Thread bruno at modulix
Ted wrote: > Thank you Roy. > > It seems if you lurk here long enough you eventually get all you > questions answered without even asking! > ;-) > +1 QOTW please avoid top-posting, and please avoid posting back a long message just to add three lines. -- bruno desthuilliers python -c "print '

Re: Decorator

2006-05-12 Thread bruno at modulix
Martin Blume wrote: > "bruno at modulix" schrieb > >>[snip] >> >>The use case for @decorator is for wrapping functions >>or method *in the module/class itself*. > > That was the question. What's the use of doing it > like that in the modul

Re: retain values between fun calls

2006-05-15 Thread bruno at modulix
x27;d only once - when the def block is eval'd, which is usually at import time. > # it does > def f(a, L=[]): > L.append(a) Here, you are modifying the (list) object bound to local name L. > return L > print f('a') > print f('b') > >

Re: Web framework to recommend

2006-05-15 Thread bruno at modulix
Jacky wrote: > Hi all, > > I just started learning Python and would like to starting writing some > web-based applications with Python. > > I did have pretty much experience with doing so with PHP and Java, but > Python seems a bit different for me. > > Do you guys have some good web framework t

Re: Web framework to recommend

2006-05-15 Thread bruno at modulix
RADO and JSF), so all recommendations are > welcomed :) You might want to have a look at Turbogears. > Thank you! > > (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: How to organise classes and modules

2006-05-15 Thread bruno at modulix
to, almost the same thing: > >>>> from Foo import Foo >>>> Foo.bar() > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unbound method bar() must be called with Foo instance as > first argument (got nothing instead) &

Re: Web development with python.

2006-05-15 Thread bruno at modulix
ent System """ (http://www.plone.org) FWIW, it's based on Zope, which is a Python-based web application server > I am confused on what Turbogears is aswell A Python web MVC framework. > because of the lack of > documentation for it. I think there's at least e

<    1   2   3   4   5   6   7   >