Re: why should I learn python

2007-09-07 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > On Sep 6, 4:01 pm, windandwaves <[EMAIL PROTECTED]> wrote: (snip) >> but because I am really not much of a >> programmer, it is often too detailed for me). I have limited time, >> but it does sound like something to learn, just for fun and for >> practical use. How w

Re: Organizing Code - Packages

2007-09-09 Thread Bruno Desthuilliers
xkenneth a écrit : >>Ah, yes, a couple of things: >>- avoid the 'one-class-per-file' syndrom. It's perfectly ok to have tens > > > Yes but i find it hard to edit classes easily when I have more than > one class per file. Why so ? Could it be that your classes are growing too fat ? -- http://mai

Re: Organizing Code - Packages

2007-09-09 Thread Bruno Desthuilliers
xkenneth a écrit : > On Sep 7, 2:04 pm, Wildemar Wildenburger > <[EMAIL PROTECTED]> wrote: > >>Paul Rudin wrote: >> >>>xkenneth <[EMAIL PROTECTED]> writes: >> >Ah, yes, a couple of things: >- avoid the 'one-class-per-file' syndrom. It's perfectly ok to have tens Yes but i find it

Re: How to insert in a string @ a index

2007-09-09 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi; > > I'm trying to insert XYZ before a keyword in a string. Then forget about it. Python's strings are immutable. (snip) > The python doesn't supports t1[keyword_index]="XYZhello" (string > object assignment is not supported). How do I get to this problem? Any >

Re: less obvious "super"

2007-09-10 Thread Bruno Desthuilliers
Nagarajan a écrit : (snip) > What's the difference b/w: > class A: > and > class A ( object ): > The first one creates a 'classic' (aka 'old-style') class, IOW a class using the legacy object-model of Python < 2.2. The second one creates a 'new-style' class using the new (well... sinc

Re: Enum class with ToString functionality

2007-09-10 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > On Sep 10, 2:28 am, [EMAIL PROTECTED] wrote: > >>Hi, >> >>I have the following class - >> >>class TestOutcomes: >>PASSED = 0 >>FAILED = 1 >>ABORTED = 2 >> >>plus the following code - >> >>testResult = TestOutcomes.PASSED >> >>testResultAsString >>if testR

Re: creating really big lists

2007-09-10 Thread Bruno Desthuilliers
Delaney, Timothy (Tim) a écrit : > Hrvoje Niksic wrote: > > >>Dr Mephesto <[EMAIL PROTECTED]> writes: >> >> >>>I would like to create a pretty big list of lists; a list 3,000,000 >>>long, each entry containing 5 empty lists. (snip) > >>If you're building large data structures and don't need to r

Re: creating really big lists

2007-09-10 Thread Bruno Desthuilliers
Dr Mephesto a écrit : > Hi! > > I would like to create a pretty big list of lists; a list 3,000,000 > long, each entry containing 5 empty lists. My application will append > data each of the 5 sublists, so they will be of varying lengths (so no > arrays!). > > Does anyone know the most efficient

Re: startswith( prefix[, start[, end]]) Query

2007-09-10 Thread Bruno Desthuilliers
Steve Holden a écrit : > Bruno Desthuilliers wrote: > >> Steve Holden a écrit : > > [...] > >>> >>> Probably not really necessary, though, and they do say that premature >>> optimization is the root of all evil ... >> >> >> I

Re: Enum class with ToString functionality

2007-09-10 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > On Sep 8, 9:52 am, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >>TheFlyingDutchman a écrit : (snip) >>>class TestOutcomes: >>>PASSED = 0 >>>FAILED = 1 >>>ABORTED = 2 >> >>>

Re: newbie: stani's python editor if-else

2007-09-11 Thread Bruno Desthuilliers
madzientist a écrit : > hi, > two quick questions: > > a) i am using SPE (latest version) and for some reason, when i type, > say > > if 1==2: > print "not equal" > else: > print "equal" > > the else is at the same indentation level as the preceding print > statement, and i ge

Re: newbie: stani's python editor if-else

2007-09-11 Thread Bruno Desthuilliers
Steve Holden a écrit : > madzientist wrote: >> hi, >> >> two quick questions: >> >> a) i am using SPE (latest version) and for some reason, when i type, >> say >> >> if 1==2: >> print "not equal" >> else: >> print "equal" >> >> the else is at the same indentation level as the prec

Re: Python code-writing for the blind. Was (Re: newbie: stani's pythoneditor if-else)

2007-09-11 Thread Bruno Desthuilliers
Hamilton, William a écrit : >>From: madzientist >> >>Thanks, everybody, for the very very useful and kind responses. >> >>There is a second reason why I asked the question about automatic de- >>indenting. I am teaching myself Python partly so I can then help my >>technically astute, but blind frien

Re: creating really big lists

2007-09-11 Thread Bruno Desthuilliers
Dr Mephesto a écrit : > On Sep 8, 8:06 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >>Dr Mephesto a écrit : >> >> >>>Hi! >> >>>I would like to create a pretty big list of lists; a list 3,000,000 >>>long, each entry contai

Re: Difference between two times (working ugly code, needs polish)

2007-09-11 Thread Bruno Desthuilliers
Shawn Milochik a écrit : > I have done what I wanted, but I think there must be a much better way. > > Given two timestamps in the following format, I just want to figure > out how far apart they are (in days, seconds, whatever). > > Format: > > -MM-DD_MM:SS > > Example: > 2007-09-11_16:41

Re: Compiler Python

2007-09-11 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > anton a wrote: > >>Someone knows since as I can obtain the information detailed about >>the compiler of Python? (Table of tokens, lists of productions of >>the syntactic one , semantic restrictions...) > > > I'm not really about the syntax of your question, lol !

Re: Python Database Apps

2007-09-11 Thread Bruno Desthuilliers
Tom Brown a écrit : > On Monday 10 September 2007 19:52, [EMAIL PROTECTED] wrote: > >>Kindof a poll, kindof curiosity... >> >>What is your favorite python - database combination? I'm looking to >>make an app that has a local DB and a server side DB. I'm looking at >>python and sqlite local side

Re: Python 3K or Python 2.9?

2007-09-12 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > Python user and advocate Bruce Eckel is disappointed with the > additions (or lack of additions) in Python 3: > > http://www.artima.com/weblogs/viewpost.jsp?thread=214112 > I'd say Mr Eckel fails to graps some of the great points about Python's object model - the r

Re: __getattr__ and static vs. instantiated

2007-09-12 Thread Bruno Desthuilliers
tvaughan a écrit : > Hi, > > Let's say I have: > > class Persistable(object): > > __attrs__ = {} > > def __getattr__(self, name): > if name in self.__attrs__: > return self.__attrs__[name]['value'] > else: >

Re: Generating HTML

2007-09-12 Thread Bruno Desthuilliers
Evan Klitzke a écrit : > On Wed, 2007-09-12 at 01:33 -0300, Sebastian Bassi wrote: >> Hello, >> >> What are people using these days to generate HTML? I still use >> HTMLgen, but I want to know if there are new options. I don't >> want/need a web-framework a la Zope, just want to produce valid HTML

Re: newbie: self.member syntax seems /really/ annoying

2007-09-12 Thread Bruno Desthuilliers
Charles Fox a écrit : > I've just started playing around with Python, as a possible > replacement for a mix of C++, Matlab and Lisp. The language looks > lovely and clean with one huge exception: I do a lot of numerical > modeling, so I deal with objects (like neurons) described > mathematically

Re: unexpected behavior: did i create a pointer?

2007-09-12 Thread Bruno Desthuilliers
neoedmund a écrit : > On Sep 7, 4:07 pm, gu <[EMAIL PROTECTED]> wrote: (snip pb and code) >> now, in the second "for" cycle and in functionA() i only 'touch' copyOfA >> (altering it). as i don't touch the variable "a", i expect it not to be >> affected by any change, but copyOfA acts like a pointer

Re: newbie: self.member syntax seems /really/ annoying

2007-09-12 Thread Bruno Desthuilliers
Dave Hansen a écrit : (snip) > As others have mentioned, you can also provide local synonyms if the > dot syntax is too onerous. But make sure you use the member access > syntax if the result of an expression is an immutable type. For > example, I assume a_dot is a mutable type, such as a list.

Re: Python 3K or Python 2.9?

2007-09-13 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > 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 be hidden in the >>> compiler without ever touching the role it has (if

Re: Python 3K or Python 2.9?

2007-09-13 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : >> >>> Foo.bar(foo, "spam") >> >>> foo.bar("spam") > > That looks like a case of "There's more than one way to do it". ;) Nope, on the contrary. The nice thing with this model is that you don't have distinct rules for functions and methods, since methods are j

Re: Python 3K or Python 2.9?

2007-09-13 Thread Bruno Desthuilliers
TheFlyingDutchman a écrit : > Well I'm with Bruce Eckel - there shouldn't be any argument for the > object in the class method parameter list. def fun(obj, *args, **kw): # generic code here that do something with obj import some_module some_module.SomeClass.fun = fun This is why uniformity is

Re: Python 3K or Python 2.9?

2007-09-13 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > TheFlyingDutchman wrote: > >>Here's a FAQ item where they refer to it as I think Python should >>have done it - a special predefined variable: > > > Maybe. Personally, I like it the way it is in Python. > > Why don't you make a preprocessor which accepts method d

Re: newbie: self.member syntax seems /really/ annoying

2007-09-13 Thread Bruno Desthuilliers
Wildemar Wildenburger a écrit : > Bjoern Schliessmann wrote: > >>> No, but the point being made is that it would be better IN >>> THIS CASE. >> >> >> It wouldn't. IMHO, rewriting the code to two or three lines would be >> better. >> > > Well I think Charles' Point about making the equations look

Re: Strange method signature via COM

2007-03-02 Thread Bruno Desthuilliers
Richard Jebb a écrit : > We are trying to use the API of a Win32 app which presents the API as a COM > interface. The sample VB code for getting and setting the values of custom > data fields on an object shows a method named Value(): > > getterobj.Value("myfield") > setterobj.Valu

Re: classes and functions

2007-03-02 Thread Bruno Desthuilliers
Silver Rock a écrit : > Friends, > > I don´t see why using classes.. functions does everything already. I > read the Rossum tutotial and two other already. > > Maybe this is because I am only writing small scripts, or some more > serious misunderstandings of the language. or both ?-) If you onl

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread Bruno Desthuilliers
Shawn Milo a écrit : > I'm new to Python and fairly experienced in Perl, although that > experience is limited to the things I use daily. > > I wrote the same script in both Perl and Python, and the output is > identical. The run speed is similar (very fast) and the line count is > similar. > > N

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread Bruno Desthuilliers
John Machin a écrit : > On Mar 3, 9:44 am, "Shawn Milo" <[EMAIL PROTECTED]> wrote: > (snip) > > [big snip] > Here is my rewrite in what I regard as idiomatic reasonably-modern > Python (OMMV of course). (snip) John, I *swear* I didn't read your code before posting my own version ! -- http://m

Re: How *extract* data from XHTML Transitional web pages? got xml.dom.minidom troubles..

2007-03-02 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I'm trying to extract some data from an XHTML Transitional web page. > > What is best way to do this? > > xml.dom.minidom. As a side note, cElementTree is probably a better choice. Or even a simple SAX parser. >parseString("text of web page") gives errors about it

Re: cyclic iterators ?

2007-03-02 Thread Bruno Desthuilliers
Tool69 a écrit : > Hi, > > Let say I've got a simple list like my_list = [ 'a', ',b', 'c' ]. > We can have an iterator from it by k = iter( my_list), then we can > access each of her (his ?) element by k.next(), etc. > > Now, I just wanted k to have the following cyclic behaviour (without > risi

Re: Perl and Python, a practical side-by-side example.

2007-03-04 Thread Bruno Desthuilliers
John Machin a écrit : > On Mar 3, 12:36 pm, Bruno Desthuilliers > > [snip] > >> DATE = 5 >> TARGET = 6 > > [snip] > >>Now for the bad news: I'm afraid your algorithm is broken : here are my >>test data and results: >> >>i

Re: Perl and Python, a practical side-by-side example.

2007-03-04 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Bruno Desthuilliers wrote: > >>Shawn Milo a écrit : > > >>>if recs.has_key(piid) is False: >> >>'is' is the identity operator - practically, in CPython, it >>compares memory addresses. You *dont* want t

Re: Perl and Python, a practical side-by-side example.

2007-03-04 Thread Bruno Desthuilliers
Shawn Milo a écrit : (snip) > The script reads a file from standard input and > finds the best record for each unique ID (piid). The best is defined > as follows: The newest expiration date (field 5) for the record with > the state (field 1) which matches the desired state (field 6). If > there is

Re: Perl and Python, a practical side-by-side example.

2007-03-04 Thread Bruno Desthuilliers
Peter Otten a écrit : > Bruno Desthuilliers wrote: > > >> print >> output, sorted(decorated_lines, reverse=True)[0][1] > > > Or just >print >> output, max(decorated_lines)[1] Good point. More explicit, and a bit faster too. Thanks Pe

Re: Webserver balance load

2007-03-05 Thread Bruno Desthuilliers
Jean-Paul Calderone a écrit : > On 5 Mar 2007 11:47:15 -0800, Johny <[EMAIL PROTECTED]> wrote: > >> Can anyone suggest a way how to balance load on Apache server where I >> have Python scripts running? >> For example I have 3 webservers( Apache servers) and I would like to >> sent user's request t

Re: New to Python

2007-03-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I am trying to get a program to add up input from the user to get to > the number 100 using a loop. However, I am having some issues. Here > is what I have so far. I know I am just trying to hard, but I am > stuck. Where ? May I suggest this reading ? http://www

Re: Newbie question

2007-03-05 Thread Bruno Desthuilliers
Tommy Grav a écrit : > Hi list, > >this is somewhat of a newbie question that has irritated me for a > while. > I have a file test.txt: > > 0.3434 0.5322 0.3345 > 1.3435 2.3345 5.3433 > > and this script > lines = open("test.txt","r").readlines() > for line in lines: >(xin,yin,zin) =

Re: Newbie question

2007-03-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Mar 5, 9:03 am, Stargaming <[EMAIL PROTECTED]> wrote: > >>Tommy Grav schrieb: > > >>For this case, there are list comprehensions (or map, but you shouldn't >>use it any longer): > > > > I didn't see anything in the docs about this. Is map going away or is > i

Re: Squisher -- a lightweight, self-contained alternative to eggs?

2007-03-05 Thread Bruno Desthuilliers
Adam Atlas a écrit : (snip) > If you make a ZIP archive of > this and run it through Squisher, you'll get a single .pyc file which > can be imported by any Python installation anywhere just like any > other module, without requiring users to install any supporting > mechanisms (like setuptools), s

Re: Project organization and import

2007-03-05 Thread Bruno Desthuilliers
Martin Unsal a écrit : > On Mar 5, 12:45 am, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > >>Remember that you can put code in >>the __init__.py of a package, and that this code can import sub- >>packages/modules namespaces, making the package internal organisation >>transparent to user code

Re: Project organization and import

2007-03-05 Thread Bruno Desthuilliers
Martin Unsal a écrit : (snip) > When refactoring, it's much better to move small files around than to > move chunks of code between large files. Indeed. But having hundreds or thousands of files each with at most a dozen lines of effective code is certainly not an ideal. Remember that Python let

Re: Project organization and import

2007-03-05 Thread Bruno Desthuilliers
Martin Unsal a écrit : > On Mar 5, 9:15 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote: (snip) > There are myriad other benefits of breaking up large files into > functional units. Integration history, refactoring, reuse, as I > mentioned. Better clarity of design. Easier communication and > coordina

Re: Is every number in a list in a range?

2007-03-05 Thread Bruno Desthuilliers
MonkeeSage a écrit : > On Mar 5, 1:03 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > >>I have a list ll of intergers. I want to see if each number in ll is >>within the range of 0..maxnum > > > How about: > > maxnum = 100 > inlist = range(90, 120) > for i in [i for i in inlist if i >= 0 and i

Re: Squisher -- a lightweight, self-contained alternative to eggs?

2007-03-05 Thread Bruno Desthuilliers
Adam Atlas a écrit : > Ah... heh, sorry, I misread your message as "a much more convenient > way" rather than "much more than a convenient way". !-) (snip) > But my other points still stand. Indeed. -- http://mail.python.org/mailman/listinfo/python-list

Re: Squisher -- a lightweight, self-contained alternative to eggs?

2007-03-05 Thread Bruno Desthuilliers
Stef Mientki a écrit : > Adam Atlas wrote: > >> Ah... heh, sorry, I misread your message as "a much more convenient >> way" rather than "much more than a convenient way". Anyway, I >> understand that, and I do indeed find setuptools useful and use it on >> a regular basis. >> >> But my other point

Re: Project organization and import

2007-03-06 Thread Bruno Desthuilliers
Martin Unsal a écrit : > On Mar 5, 3:11 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >>Your own experience *with Python* ? > > > No, my experience with Visual Basic. ;) > > Of course my experience with Python! Sorry but this was really not obvio

Re: Good handling of input data (was Re: Newbie question)

2007-03-06 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Tue, 06 Mar 2007 05:57:43 -0500, Tommy Grav wrote: > > >>So how would you handle this type of error handling? >>My main problem is that occasionally there is an entry >>in the list that is a string: >> >>0.9834 134.4933 78.009 run11 27 > > > How do you want to dea

Re: Project organization and import

2007-03-06 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : >>I'd like to point out something though. More than one of the people >>who responded have implied that I am bringing my prior-language >>mindset to Python, even suggesting that my brain isn't built for >>Python. ;) In fact I think it's the other way around. I am struggli

Re: is it possible to give an instance a value?

2007-03-06 Thread Bruno Desthuilliers
manstey a écrit : > Hi, > > My question probably reflects my misunderstanding of python objects, > but I would still like to know the answer. > > The question is, is it possible for an instnace to have a value (say a > string, or integer) that can interact with other datatypes and be > passed as

Re: catching exceptions from an except: block

2007-03-07 Thread Bruno Desthuilliers
Miki a écrit : > Hello Arnaud, > > >>Imagine I have three functions a(x), b(x), c(x) that each return >>something or raise an exception. Imagine I want to define a function >>that returns a(x) if possible, otherwise b(x), otherwise c(x), >>otherwise raise CantDoIt. > > Exceptions are for error

Re: catching exceptions from an except: block

2007-03-07 Thread Bruno Desthuilliers
Larry Bates a écrit : (snip) > def d(x): > if isinstance(x, basestring): > # > # Code here for string > # > elif isinstance(x, int): > # > # Code here for int > # > elif isinstance(x, float): > # > # Code here for string >

Re: catching exceptions from an except: block

2007-03-07 Thread Bruno Desthuilliers
Arnaud Delobelle a écrit : > Hi all, > > Imagine I have three functions a(x), b(x), c(x) that each return > something or raise an exception. Imagine I want to define a function > that returns a(x) if possible, otherwise b(x), otherwise c(x), > otherwise raise CantDoIt. > > Here are three ways I

Re: catching exceptions from an except: block

2007-03-07 Thread Bruno Desthuilliers
Gabriel Genellina a écrit : > En Wed, 07 Mar 2007 19:00:59 -0300, Bruno Desthuilliers > <[EMAIL PROTECTED]> escribió: > >> this kind of cose is exactly what OO polymorphic dispatch is supposed to > > > this kind of cose? sorry s/cose/code/ > Ce genre de

Re: catching exceptions from an except: block

2007-03-07 Thread Bruno Desthuilliers
Arnaud Delobelle a écrit : > On Mar 7, 8:52 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > [snip] > >>Without knowing more about the functions and the variable it is somewhat >>hard to tell what you are trying to accomplish. If a, b, c are functions >>that act on x when it is a different type, chan

Re: catching exceptions from an except: block

2007-03-07 Thread Bruno Desthuilliers
Gabriel Genellina a écrit : > En Wed, 07 Mar 2007 18:48:18 -0300, Arnaud Delobelle > <[EMAIL PROTECTED]> escribió: > >> for f in int, float, complex: >> try: >> return f(x) >> except ValueError: >> continue >> raise CantDoIt >> >> But if the three things I want to do are

Re: Best place for a function?

2007-03-07 Thread Bruno Desthuilliers
Sergio Correia a écrit : > I'm writing a class, where one of the methods is kinda complex. The > method uses a function which I know for certain will not be used > anywhere else. This function does not require anything from self, only > the args passed by the method. > > Where should I put the fun

Re: catching exceptions from an except: block

2007-03-08 Thread Bruno Desthuilliers
MonkeeSage a écrit : > On Mar 7, 4:58 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >>except_retry: # the missing(???) keyword you're after > > What is 'except_retry'? A totally imaginary statement that would do what the OP is looking for. >

Re: Bug in python!? persistent value of an optional parameter in function!

2007-03-08 Thread Bruno Desthuilliers
C Barr Leigh a écrit : > Help! Have I found a serious bug? No. This is a FAQ. Default arguments of functions are evaled only once - when the def statement is eval'd and the function object constructed. > This seems like highly undesired behaviour to me. Possibly, but this is unlikely to change

Re: splitting common functions into a sepperate module

2007-03-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Dear, > > I have wrote a script and want to group some functions of the script > in a separate modulo so that I can import the module in other scripts > and use the same functions there.. > > The problem is that the common functions need access to some global > varia

Re: splitting common functions into a sepperate module

2007-03-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On 8 mrt, 10:36, Bruno Desthuilliers > - wrapping the functions as methods of a class, passing the whole state >> as args to the class initializer. > I already considerate this one, but I don't like it because it is not > correct in terms

Re: Where to "import"?

2007-03-08 Thread Bruno Desthuilliers
Paulo da Silva a écrit : > Hi! > > If I have two files .py such as > > m.py > from c import * avoid this kind of import except in an interactive interpreter and eventually in a package __init__.py. Better to use either: from c import c or import c ... x = c.c() > ... >

Re: Squisher -- a lightweight, self-contained alternative to eggs?

2007-03-08 Thread Bruno Desthuilliers
Adam Atlas a écrit : > Doesn't seem to work. I guess zipimport doesn't support that by > default... but if I remember correctly, Setuptools adds that. Maybe > I'll take a look at how it does it (I think by extracting the .so to / > tmp?) or to another known location, IIRC. > and see how easy it

Re: What is the best way to upgrade python?

2007-03-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi, > > i am using red hat enterprise 4. It has python 2.3 installed. What is > the best way to upgrade to python 2.4? > > I think one way is to compile python 2.4 from the source, but I can't > remove the old one since when i do 'rpm -e python', i get error like > '

Re: Where to "import"?

2007-03-08 Thread Bruno Desthuilliers
Paulo da Silva a écrit : > Bruno Desthuilliers escreveu: > >>Paulo da Silva a écrit : > > ... > > >>>c.py >>>class c: >> >>class C(object): >> >>1/ better to stick to naming conventions (class names in CamelCase) >

Re: 2 new comment-like characters in Python to aid development?

2007-03-09 Thread Bruno Desthuilliers
Nick Craig-Wood a écrit : > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> What if 2 new 'special' comment-like characters were added to Python?: >> >> >> 1. The WIP (Work In Progress) comment: > > I use # FIXME for this purpose or /* FIXME */ in C etc. > > I have an emacs macro which shows it

Re: 2 new comment-like characters in Python to aid development?

2007-03-09 Thread Bruno Desthuilliers
Nick Craig-Wood a écrit : > Robert Marshall <[EMAIL PROTECTED]> wrote: >> On Fri, 09 Mar 2007, Bruno Desthuilliers wrote: >> >>> Nick Craig-Wood a ?crit : >>>> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >>>>> What if 2 ne

Re: Best place for a function?

2007-03-11 Thread Bruno Desthuilliers
Inyeol Lee a écrit : > On Wed, Mar 07, 2007 at 05:27:04PM -0500, Sergio Correia wrote: > >>I'm writing a class, where one of the methods is kinda complex. The >>method uses a function which I know for certain will not be used >>anywhere else. This function does not require anything from self, only

Re: Python in a desktop environment

2007-03-11 Thread Bruno Desthuilliers
David Cramer a écrit : > If you had an application that you were about to begin development on > which you wanted to be cross platform (at least Mac and Windows), > would you suggest using c++ and Python? > > I'm asking because we were originally thinking about doing c# but > after attending PyCon

Re: Python in a desktop environment

2007-03-11 Thread Bruno Desthuilliers
David Cramer a écrit : > On Mar 10, 10:52 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > >>David Cramer wrote: >> >>>If you had an application that you were about to begin development on >>>which you wanted to be cross platform (at least Mac and Windows), >>>would you suggest using c++ and

Re: Need help in using mod_python

2007-03-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > > > Hi, > > I am trying to setup Apache with Trac which uses mod_python. I get the > following error: > > assert have_pysqlite > 0 > > And I have verify this via command line as well, that seem no > problem. (snip) What do you get using tracd (the standalone se

Re: Need help in using mod_python

2007-03-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Mar 11, 1:02 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >>[EMAIL PROTECTED] a écrit : >> >> >> >> >>>Hi, >> >>>I am trying to setup Apache with Trac which uses mod_python. I get th

Re: can not load mod_python on apache

2007-03-12 Thread Bruno Desthuilliers
liecto a écrit : > winxp sp2 > modpython 3.3.1 > apache 2.2.4 > python 2.5 > > when i start apache ,it failed. and the error is > == > The Apache service named reported the following error: httpd.exe: Syntax error on line 166 of F:/mylg/apache-more/local/apache/Apache2/conf

Re: Python in a desktop environment

2007-03-12 Thread Bruno Desthuilliers
Grant Edwards a écrit : (snip) > > Python is _far_ more robust than C++. > I wouldn't say so - robustness is a quality of a program, not of a language !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python in a desktop environment

2007-03-12 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : > Bruno Desthuilliers wrote: > >> Grant Edwards a écrit : >> (snip) >> >>> Python is _far_ more robust than C++. >>> >> I wouldn't say so - robustness is a quality of a program, not of a >> language !-) &

Re: glob.glob output

2007-03-12 Thread Bruno Desthuilliers
Hitesh a écrit : > import string > import os > > f = open ("c:\\servername.txt", 'r') > linelist = f.read() > > lineLog = string.split(linelist, '\n') > lineLog = lineLog [:-1] > #print lineLog > for l in lineLog: > path1 = "" + l + "\\server*\\*\\xtRec*" > glob.glob(path1) And ? Wha

Re: Interface in IronPython

2007-03-12 Thread Bruno Desthuilliers
edfialk a écrit : > Hi all, I'm pretty much totally new to IronPython and have come to the > point that I need an interface to interact with a co-worker's code, > but I can't seem to find any documents or discussion on syntax for > writing an interface. > > Does anyone know of a link that talks ab

Re: Starting Python... some questions

2007-03-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I started using Python a couple of days ago - here are a few > questions: > > * Doesn't the __main__() method automatically execute when I run my > python program? Which "__main__" method ??? Anyway, the answer is no. Every code at the top-level (which includes imp

Re: Starting Python... some questions

2007-03-13 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Mon, 12 Mar 2007 21:39:11 -0700, jezonthenet wrote: > >> I started using Python a couple of days ago - here are a few >> questions: >> >> * Doesn't the __main__() method automatically execute when I run my >> python program? > > > No. > > >> * Only when I do an

Re: Python in a desktop environment

2007-03-13 Thread Bruno Desthuilliers
David Cramer a écrit : > On Mar 12, 9:56 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Diez B. Roggisch a écrit : >> >>> Bruno Desthuilliers wrote: >>>> Grant Edwards a écrit : >>>> (snip) >>>>> Python is _far_ more robu

Re: Single string print statements on multiple lines.

2007-03-13 Thread Bruno Desthuilliers
Goldfish a écrit : > http://www.catb.org/~esr/faqs/smart-questions.html > > Don't post homework questions. > Given the way the question was expressed, I don't think this particular rule applies here. Obviously, the OP is not trying to cheat (explicitelt aknowledging it is homework), and has a g

Re: glob.glob output

2007-03-13 Thread Bruno Desthuilliers
Hitesh a écrit : > On Mar 12, 4:33 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >> Hitesh a écrit : >> (snip) > Thank you for your reply. > From the return value I am trying to figure out whether the file > xtRec* exist or not. Yes, I had understood thi

Re: Iterating across a filtered list

2007-03-13 Thread Bruno Desthuilliers
Paul Rubin a écrit : > "Drew" <[EMAIL PROTECTED]> writes: > >>You're exactly on the mark. I guess I was just wondering if your first >>example (that is, breaking the if statement away from the iteration) >>was preferred rather than initially filtering and then iterating. > > > I think the multip

Re: Need help with a string plz! (newbie)

2007-03-13 Thread Bruno Desthuilliers
Grant Edwards a écrit : (snip) > I don't know if emacs still includes Zippy quotes > (of if they've been updated), but you used to be able to do > "esc-X yow" and emacs would show you a random Zippy quote. > It's still there. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to detect change of list of instances

2007-03-14 Thread Bruno Desthuilliers
manstey a écrit : > Thanks. > > All I want to know is whether the newlist, as a list of instances, is > modified. I thought equality was the way to go, but is there a simpler > way? How can I monitor the state of newlist and set a flag if it is > changed in anyway? Override the mutators - or jus

Re: Iterating across a filtered list

2007-03-14 Thread Bruno Desthuilliers
Paul Rubin a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: (snip) >> Python has had functions as first class objects and >> (quite-limited-but) anonymous functions, map(), filter() and reduce() >> as builtin funcs at least since 1.5.2 (quite some years

Re: Iterating across a filtered list

2007-03-14 Thread Bruno Desthuilliers
Arnaud Delobelle a écrit : > On Mar 13, 8:53 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >> Paul Rubin a écrit : > > [snip] > >>> Iterators like that are a new Python feature >> List comps are not that new (2.0 or 2.1 ?): >> print "

Re: Attribute monitoring in a class

2007-03-14 Thread Bruno Desthuilliers
Joel Andres Granados a écrit : > Hi list: > > I have googled quite a bit on this matter and I can't seem to find what > I need (I think Im just looking where I'm not suppose to :). I'm > working with code that is not of my authorship and there is a class > attribute that is changes by directly

Re: Quick Filter Dictionary

2007-03-14 Thread Bruno Desthuilliers
abcd a écrit : > On Mar 14, 7:29 am, "abcd" <[EMAIL PROTECTED]> wrote: >> Hi, >>I have a dictionary which may contain various keys/values, however, >> it will always contain 'name' and 'age' keys. >> >>This dictionary is kept inside a class, such as >> >> class Person: Do yourself

Re: Constructor of object

2007-03-14 Thread Bruno Desthuilliers
inline a écrit : > Hello! > I want to assign self to object of parent class in constructor, Isn't it the other way round ?-) > like > > def my_func(): > ... > return ParentClass() > > class MyClass (ParentClass): > def __init__(self): > self = my_func() First point : __init

Re: os.path.basename() - only Windows OR *nix?

2007-03-14 Thread Bruno Desthuilliers
Thomas Ploch a écrit : > Hello, > > I have a cgi script that handles fileuploads from windows and *nix > machines. i need os.path.basename(filename) to get the pure filename. > > For *nix, thats not a problem, but for windows, it always returns the > full path: > > > > #/usr/bin/env python >

Re: Converting a list to a dictionary

2007-03-14 Thread Bruno Desthuilliers
Samuel a écrit : > Hi, > > is there a short version for this? > > res_dict = {} > for resource in res_list: > res_dict[resource.get_id()] = resource > > This does not work: > > res_dict = dict([r.get_id(), r for r in res_list]) res_dict = dict((r.get_id(), r) for r in res_list) or if you ha

Re: Beginner question: difference between lists and tuples

2007-03-14 Thread Bruno Desthuilliers
KDawg44 a écrit : > Hi, > > I am trying to learn python. I am working through a tutorial on > python.org. I am trying to figure out how lists are different than > tuples other than changing values at specific indices. http://www.python.org/doc/faq/general/#why-are-there-separate-tuple-and-list-

Re: Attribute monitoring in a class

2007-03-15 Thread Bruno Desthuilliers
Gabriel Genellina a écrit : > En Wed, 14 Mar 2007 10:01:54 -0300, Joel Andres Granados > <[EMAIL PROTECTED]> escribió: > >> Bruno Desthuilliers wrote: >>> Joel Andres Granados a écrit : > >>>> I'm >>>> working with code that is no

Re: print and softspace in python

2007-03-15 Thread Bruno Desthuilliers
Phoe6 a écrit : > print and softspace in python > In python, whenever you use >>>print statement Drop the '>>>' part. It's just the default Python shell prompt. > it will append a > newline by default. If you don't want newline to be appended, you got > use a comma at the end (>>>print 10,) > Whe

Re: dict.items() vs dict.iteritems and similar questions

2007-03-15 Thread Bruno Desthuilliers
Steve Holden a écrit : > [EMAIL PROTECTED] wrote: >> Laurent Pointal: >>> you may prefer range/items when processing of the result >>> value explicitly need a list (ex. calculate its length) >> >> Creating a very long list just to know the len of an iterator is >> barbaric, so sometimes I use this:

Re: Multiline code - trailing slash usage

2007-03-15 Thread Bruno Desthuilliers
abcd a écrit : > When do I need to use a trailing slash to separate code over multiple > lines. > > For example: > > x = "hello world, this is my multiline " + \ > "string" Here you don't need the + > x = {'name' : \ > 'bob'} And here you don't need the antislash > Do I need to

<    9   10   11   12   13   14   15   16   17   18   >