Re: Python is fun (useless social thread) ;-)

2006-06-20 Thread bruno at modulix
Max M wrote: > bruno at modulix wrote: > >> Max M wrote: >> >>> bruno at modulix wrote: >>> >>>>> Or did you just like what you saw and decided to learn it for fun? >>>> >>>> >>>> Well, I haven't be real

Re: Python is fun (useless social thread) ;-)

2006-06-20 Thread bruno at modulix
Max M wrote: > bruno at modulix wrote: > >>> Or did you just like what you saw and decided to learn it for fun? >> >> >> Well, I haven't be really impressed the first time - note that it was at >> the very end of the last century, with v1.5.2. &g

Re: Calling every method of an object from __init__

2006-06-20 Thread bruno at modulix
Tim Chase wrote: (snip) class Foo(object): > ... def __init__(self): > ... for method in dir(self): > ... if method == method.strip("_"): if not method.startswith('_'): -- bruno desthuilliers python -c "print '@'.join(['.'.join([

Re: Specifing arguments type for a function

2006-06-20 Thread bruno at modulix
K.S.Sreeram wrote: > bruno at modulix wrote: > >> if type(arg) is type([]): > > > Just a tiny nitpick > You can just use 'list' instead of 'type([])' I know. Note that I wrote "*A* right way to write this", not "*The* right way

Re: Specifing arguments type for a function

2006-06-20 Thread bruno at modulix
Rony Steelandt wrote: >> Paolo Pantaleo wrote: >> >>> I have a function >>> >>> def f(the_arg): >>> ... >>> >>> and I want to state that the_arg must be only of a certain type >>> (actually a list). Is there a way to do that? >> >> >> Yes and no. You can ensure that the passed object is a list, by

Re: [OT] code is data

2006-06-20 Thread bruno at modulix
Diez B. Roggisch wrote: > bruno at modulix wrote: > > >>Diez B. Roggisch wrote: >> >>>>>because lots of people know how to describe XML transformations, and >>>>>there are plenty of tools that implement such transformations >>>>>e

Re: [OT] code is data

2006-06-20 Thread bruno at modulix
Diez B. Roggisch wrote: >>> because lots of people know how to describe XML transformations, and >>> there are plenty of tools that implement such transformations >>> efficiently ? >> >> >> Efficiently enough for dynamic (runtime) use ? > > > Using XML-transformation for AST manipulation isn't my

Re: Function definition

2006-06-20 Thread bruno at modulix
faulkner wrote: (pelase don't top-post - fixed) > aarondesk wrote: > (snip) >>Now I've tried putting the function declaration after the call but the >>program wouldn't work. Is there anyway to put function declarations at >>the end of the program, rather than putting them at the beginning, >>which

Re: [OT] code is data

2006-06-19 Thread bruno at modulix
Fredrik Lundh wrote: > Laurent Pointal wrote: >> Bruno Desthuilliers wrote: >>> Anton Vredegoor wrote: The idea is to have a way to transform a Python (.py) module into XML and then do source code manipulations in XML-space using ElementTree. > >>> > >>> My my my... I'm not against th

Re: Formatted string to object

2006-06-19 Thread bruno at modulix
janama wrote: > Hi, > > can such a thing be done somehow? > > > aaa = self.aaa > bbb = %s.%s % ('parent', 'bbb') Given the first line, I assume this is inside a method body, and parent is a local var. Then the answer is: bbb = getattr(locals()['parent'], 'bbb') read the doc for these two func

Re: Formatted string to object

2006-06-19 Thread bruno at modulix
Tim Chase wrote: >> Can you use strings or %s strings like in the above or >> >> aaa = 'string' >> aaa.%s() % 'upper' >> >> Somehow? > > > Looks like you want to play with the eval() function. > aaa = 'hello' result = eval("aaa.%s()" % 'upper') result > 'HELLO' Using eval() or ex

Re: [OT] code is data

2006-06-19 Thread bruno at modulix
Anton Vredegoor wrote: > bruno at modulix wrote: > >> I still don't get the point. > > > Well, I've got to be careful here, lest I'd be associated with the > terr.., eh, the childp..., eh the macro-enablers. > > The idea is to have a way to transf

Re: Just out of curiosity: Which languages are they using at Google and what for?

2006-06-19 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I know Google are using Python for testing purposes. Not only: """ Where is Python used? * The Google build system is written in python. All of Google's corporate code is checked into a repository and the dependency and building of this code is managed by python.

Re: Check if a file is closed

2006-06-19 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > How to check if a file is closed? >>> f = open('trashme.txt', 'w') >>> f >>> dir(f) ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'close', '

Re: code is data

2006-06-19 Thread bruno at modulix
Ravi Teja wrote: (snip) > Annoted variables, symbols and code > layout visually cue more efficiently to the object nature than do > explicit text definitions. Of course, this is only sensible when there > aren't too many of any of those. In that case, the cognitive cost of > notation outweighs the

Re: code is data

2006-06-19 Thread bruno at modulix
Ravi Teja wrote: > BJörn Lindqvist wrote: > >>>Personally, I would like to see macros in Python (actually Logix >>>succeeding is good enough). But I am no language designer and the >>>community has no interest in it. When I absolutely need macros, I will >>>go elsewhere. >> >>One must wonder, when

Re: code is data

2006-06-19 Thread bruno at modulix
BJörn Lindqvist wrote: >> Personally, I would like to see macros in Python (actually Logix >> succeeding is good enough). But I am no language designer and the >> community has no interest in it. When I absolutely need macros, I will >> go elsewhere. > > > One must wonder, when is that? When do y

Re: [OT] code is data

2006-06-19 Thread bruno at modulix
Anton Vredegoor wrote: > With the inclusion of ElementTree (an XML-parser) in Python25 and recent > developments concerning JSON (a very Pythonesque but somewhat limited > XML notation scheme, let's call it statically typed XML) JSON stands for JavaScript Object Notation, and has *nothing* to do w

Re: any subway web dev experiences

2006-06-19 Thread bruno at modulix
a wrote: > subway is pythons ruby on rails competitor Nope - it's a Python MVC web framework. Like Django, Pylons and Turborgears. And FWIW, there have been recently some discussions about merging Subway and Turbogears. > pls tell me if u hav any expereinces Please take time to learn and write r

Re: Python is fun (useless social thread) ;-)

2006-06-17 Thread bruno at modulix
John Salerno wrote: (snip) > So out of curiosity, I'm just wondering how everyone else came to learn > it. If you feel like responding, I'll ask my questions for easy quoting: > > Did you have to learn it for a job? It has never been an official requirement for any of the jobs I got since I'm a

Re: Legitimate use of the "is" comparison operator?

2006-06-17 Thread bruno at modulix
Mike Duffy wrote: > I just recently realized that the comparison operator "is" actually > works for comparing numeric values. It's only an implementation detail of CPython (and is only true for small integers - you'll find the limit in the CPython source code), not part of the language specificati

Re: any subway experiences

2006-06-17 Thread bruno at modulix
a wrote: > thanks for reading > Too long experience with Paris (France) subway... Left Paris, feel better now !-) -- 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/pyt

Re: Python is fun (useless social thread) ;-)

2006-06-16 Thread bruno at modulix
BartlebyScrivener wrote: (snip) > I am not touching OO, classes, You may not be aware of this, but as soon as you're programming in Python, you *are* using OO. Strings are objects, dicts are objects, tuples are objects, lists are objects, numbers are objects, and even functions and modules are ob

Re: Python is fun (useless social thread) ;-)

2006-06-16 Thread bruno at modulix
Scott David Daniels wrote: > BartlebyScrivener wrote: > >> I am not touching OO, classes, or GUIs until I understand >> EVERYTHING else. Could take a few years. ;) > > > You know how modules separate globals, right? That is, what you > write in one module doesn't affect the names in anothe

Re: Python is fun (useless social thread) ;-)

2006-06-16 Thread bruno at modulix
BartlebyScrivener wrote: >>>I'd like something a bit like a module, >>>but I'd like to make several of them, >>>and not have them interfere with each other." > > > Thank you. I sense what you are saying, but at this point I'd be > thinking, "Why not just make several modules?" :) Because you wa

Re: Python is fun (useless social thread) ;-)

2006-06-16 Thread bruno at modulix
BartlebyScrivener wrote: (snip) > Also, it seems to be a minimalist > language. *seems* minimalist, but is really not - have a look at the object model (metaclasses, descriptors etc), at closures and HOFs and decorators, at list-comp and generators and (coming in 2.5) coroutines... Definitively

Re: a good programming text editor (not IDE)

2006-06-16 Thread bruno at modulix
BartlebyScrivener wrote: >>>Most IDEs are rather weak as text editors compared to emacsen. > > > That's true, but even emacs and xemacs don't offer simple automatic > word wrap (i.e. wrap a line without splitting words or putting an eol > or hard carriage return at the end of every line). I don't

Re: a good programming text editor (not IDE)

2006-06-16 Thread bruno at modulix
BartlebyScrivener wrote: > Emacs must be dying if this thread could get all the way to 20 with > nobody arguing with the vi folks. No need to argue. I started with vim, and finally switched to emacs less than one year later. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] f

Re: a good programming text editor (not IDE)

2006-06-16 Thread bruno at modulix
John Salerno wrote: > Ant wrote: > >> jEdit is for me still the best text editor available. Very extensible >> with macros (which can be written in Jython with the appropriate plugin >> installed). > > > I like the idea of being extensible, but of course I can only write in > Python. Jython is

Re: a good programming text editor (not IDE)

2006-06-16 Thread bruno at modulix
BartlebyScrivener wrote: > I see Eclipse mentioned here a lot. If you go for a Mammoth-weight GUI-only Java IDE and have a really powerful computer, why not ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -

Re: a good programming text editor (not IDE)

2006-06-16 Thread bruno at modulix
John Salerno wrote: (snip) > Based on another thread, I tried out Scite, but no matter what I do it > doesn't seem to remember the window size and position, or any options I > choose (like showing line numbers). This is in the configuration files. Don't remember which and where, but I clearly rem

Re: how you get Python files on websites?

2006-06-15 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (snip) > i have a few questions about Python > > 1. Can Python work with databases like MySql,Oracle? (i think it sounds > silly) http://www.google.com/search?q=%2Bpython+%2Bdb > 2.the Python files have .py extension and i used Windows Command > Prompt(DOS) to execute th

Re: __cmp__ method

2006-06-15 Thread bruno at modulix
JH wrote: > Hi > > Can anyone explain to me why the following codes do not work? I want to > try out using __cmp__ method to change the sorting order. I subclass > the str and override the __cmp__ method so the strings can be sorted by > the lengh. I expect the shortest string should be in the fro

Re: Quacker

2006-06-14 Thread bruno at modulix
Quacker wrote: > Very interesting! > indeed. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: Tiddlywiki type project in Python?

2006-06-14 Thread bruno at modulix
jkn wrote: (snip) > Does the idea of embedding python in a browser instead of Javascript > make any sense at all? >From a purely theoretical POV, yes, this idea makes sens - Python could be an interesting alternative to javascript for client-side scripting (and I'd really prefer using Python for t

Re: Tiddlywiki type project in Python?

2006-06-14 Thread bruno at modulix
jkn wrote: > Hi all > I'm trying out, and in general finding really useful, the various > TiddlyWiki variants that I guess many people here know about, for > organising my activities in a GTD way. One mild annoyance is in the > speed of the Javascript applications. I fancy having a go at writin

Re: Looping through a file a block of text at a time not by line

2006-06-14 Thread bruno at modulix
Rosario Morgan wrote: > Hello > > Help is great appreciated in advance. > > I need to loop through a file 6000 bytes at a time. I was going to > use the following but do not know how to advance through the file 6000 > bytes at a time. > > file = open('hotels.xml') while True: block = file.

Re: Test functions and test discovery

2006-06-14 Thread bruno at modulix
Ben Finney wrote: (snip) > if __name__ == "__main__": > test_funcs = [x for name, x in globals() > if name.startswith("test") and hasattr(x, "__call__") > ] Any reason not to use callable(x) here ? (instead of hasattr(x, "__call__")) -- bruno desthuilliers python

Re: What's wrong in this HTML Source file of a Bank

2006-06-13 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > I have posted the same question in alt.html but no one yet replied. You should ask your butcher. Now please stop posting off-topic. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])"

Re: What's wrong in this HTML Source file of a Bank

2006-06-13 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Several times I logged-in successfully but after log-in I can't use > features/services which were shown prior to my login. Can anyone exoert > > from this forum check , is it technical fault of Bank Web Site or this > problem pertaining to the user(me). It's definitiv

Re: "parent" in a class __init__ def?

2006-06-13 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > bruno at modulix wrote: > >>[EMAIL PROTECTED] wrote: >> >>> Intuitively, the name lookup on >>>self.parent.foo would be faster than if you passed in the object in >>>question >> >> >>Each dot means doing

Re: Searching and manipulating lists of tuples

2006-06-12 Thread bruno at modulix
MTD wrote: > Hello, > > I'm wondering if there's a quick way of resolving this problem. > > In a program, I have a list of tuples of form (str,int), where int is a > count of how often str occurs > > e.g. L = [ ("X",1),("Y",2)] would mean "X" occurs once and "Y" occurs > twice > > If I am given

Re: Function to remove elements from a list working, but python hangs :((

2006-06-12 Thread bruno at modulix
Girish Sahani wrote: (please don't top-post) > Hey Bruno...you are seeing the wrong post :P...please ignore this and > check out the one with (corrected) appended at the end... You should have posted the correction in the same thread. > Also, i used the list comprehension thingy which u have gi

Re: Function to remove elements from a list not working

2006-06-12 Thread bruno at modulix
Girish Sahani wrote: > Hi, > I am trying to convert a list of pairs (l4) to list l5 by removing those > pairs from l4 which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not give the correct output. Pleas

Re: "parent" in a class __init__ def?

2006-06-12 Thread bruno at modulix
Ray Schumacher wrote: > What is the feeling on using "parent" in a class definition "parent" is just a name. What is the semantic for this name ? Parent class (ie: superclass) ? Container ? Else ? > that class > methods Takes care, "class method" has a very defined meaning in Python - a class m

Re: "parent" in a class __init__ def?

2006-06-12 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (meta : please don't top-post) > Intuitively, the name lookup on > self.parent.foo would be faster than if you passed in the object in > question Each dot means doing a lookup in a namespace. The more dots, the more lookups. And lookups do have a cost. -- bruno desthui

Re: Python or Ajax?

2006-06-12 Thread bruno at modulix
Redefined Horizons wrote: > I've been hearing a ot about AJAX lately. I may have to build a web > application in the near future, and I was curoius: > > How does a web application that uses Python compare with one that uses > AJAX? How does a car that has a diesel motor compare with one that is r

Re: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread bruno at modulix
Girish Sahani wrote: >>Girish Sahani wrote: >> (snip) >>>Before the >>>main function, i have defined the other functions such as >>>genColocations,genTableInstances,etc. Output of genColocations is to be >>>given to the next function genTableInstances,output of this function to >>>tiCount and find

Re: regexp questoin

2006-06-09 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > hi > > i created a script to ask user for an input that can be a pattern > right now, i use re to compile that pattern > pat = re.compile(r"%s" %(userinput) ) #userinput is passed from > command line argument > if the user key in a pattern , eg [-] , and my script will

Re: References and copying

2006-06-09 Thread bruno at modulix
[EMAIL PROTECTED] wrote: >>Where can I find a good explanation when does an interpreter copy the >>value, and when does it create the reference. > > Any good Python book. I have Learning Python and Programming Python 2nd > edition and they are very good IMO. > > >>I thought I understand >>it, bu

Re: [noob question] References and copying

2006-06-09 Thread bruno at modulix
zefciu wrote: > Hello! > > Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. Unless you explicitely ask for a copy (either using the copy module or a specific function or method), you'll get a reference. > I thought I understan

Re: removing dictionary key-pair

2006-06-09 Thread bruno at modulix
bruno at modulix wrote: > JD wrote: > >>Hello, >> >>I try to remove a dictionary key-pair (remove an entry), >>but I'm unsuccessful. Does anyone know how to achieve this? >> >>Thanks > > > mydict = {"key" : "value&qu

Re: removing dictionary key-pair

2006-06-09 Thread bruno at modulix
JD wrote: > Hello, > > I try to remove a dictionary key-pair (remove an entry), > but I'm unsuccessful. Does anyone know how to achieve this? > > Thanks mydict = {"key" : "value"} del mydict(key) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p

Re: Error in Chain of Function calls

2006-06-09 Thread bruno at modulix
Girish Sahani wrote: >>Girish Sahani wrote: >> >> >>>However i am getting an error at the line marked with ***. >> >>what error ? > > ...line 266, in colocationMiner Great. We now know at which line of an unknown file an unknown error happens. Will use my PythonPsychicPowers(tm) now to see waht's

Re: what are you using python language for?

2006-06-09 Thread bruno at modulix
baalbek wrote: > To score with the chicks! > > A Python script roams the nightclubs for beautiful women, finds an > appropriate woman based on my preferances, charms her with its sleek > Pythonic manners, calls for a cab and brings the lady to my recidency. > > Works like a charm! Is that OSS ?-

Re: Error in Chain of Function calls

2006-06-09 Thread bruno at modulix
Girish Sahani wrote: > Hi, > > There is a code in my main function which is something like: > > while prunedFinal != []: > prunedNew = genColocations(prunedK) *** > tableInstancesNew = genTableInstances(prunedNew,tableInstancesK) > tiCountDict = tiCount

Re: dynamic inheritance

2006-06-09 Thread bruno at modulix
alf wrote: > is there any way to tell the class the base class during runtime? > Technically, yes - the solution depending on your definition of "during runtime" FWIW, the class statement is evaled at import/load time, which is "during runtime" So if you want to use one or other (compatible)

Re: follow-up to FieldStorage

2006-06-08 Thread bruno at modulix
Tim Roberts wrote: > John Salerno <[EMAIL PROTECTED]> wrote: > > >>Bruno Desthuilliers wrote: >> >>>John Salerno a écrit : >>> If I want to get all the values that are entered into an HTML form and write them to a file, is there some way to handle them all at the same time, or must

Re: Instead of saving text files i need as html

2006-06-08 Thread bruno at modulix
Shani wrote: > I have the following code which takes a list of urls > "http://google.com";, without the quotes ofcourse, and then saves there > source code as a text file. I wan to alter the code so that for the > list of URLs an html file is saved. What you write in a text file is up to you - an

Re: language-x-isms

2006-06-08 Thread bruno at modulix
Bryan wrote: > does anyone know if there is a collection somewhere of common python > mistakes or inefficiencies or unpythonic code that java developers make > when first starting out writing python code? Try googling for "python is not java" !-) -- bruno desthuilliers python -c "print '@'.joi

Re: [0T]Use of Python in .NET

2006-06-07 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Hi, > I am developing a code which has MVC (Model - View - Controler) > architecture.My view is in .NET. And my controller is in Python.So can > i call Python script from .NET? This is a question that I would have asked myself before actually trying to do anything el

Re: creating and naming objects

2006-06-07 Thread bruno at modulix
Brian wrote: > Thank you all for your response. I think that I am getting it. Based > on those responses, would I be correct in thinking that this would be > the way to initialize my Student object and return the values? > > class Student: Do yourself a favour: use new-style classes class Stud

Re: Writing to a certain line?

2006-06-07 Thread bruno at modulix
Christophe wrote: > bruno at modulix a écrit : (snip) >> Wrong guess - unless, as Fredrik suggested, you have an infinite disk >> with an infinite file on it. If so, please share with, we would be >> *very* interested !-) > > > Use /dev/zero as source and /d

Re: Writing to a certain line?

2006-06-07 Thread bruno at modulix
Tommy B wrote: > bruno at modulix wrote: (snip) >>import os >>old = open("/path/to/file.txt", "r") >>new = open("/path/to/new.txt", "w") >>for line in old: >> if line.strip() == "Bob 62" >>line = line.

Re: what are you using python language for?

2006-06-06 Thread bruno at modulix
hacker1017 wrote: > im just asking out of curiosity. > Err... Programming ?-) Sorry... Actually, mostly web applications (CMS, groupware, small/medium business apps etc), and admin utilities. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in

Re: Writing to a certain line?

2006-06-06 Thread bruno at modulix
Rene Pijlman wrote: > bruno at modulix: > >>You can't do this in place with a text file (would be possible with a >>fixed-length binary format). > > > More precise: it's possible with any fixed-length change, in both binary > and text files, with both fix

Re: check for dictionary keys

2006-06-06 Thread bruno at modulix
John Machin wrote: > On 5/06/2006 10:46 PM, Bruno Desthuilliers wrote: > >> [EMAIL PROTECTED] a écrit : >> >>> hi >>> in my code, i use dict(a) to make to "a" into a dictionary , "a" comes >>> from user input, so my program does not know in the first place. Then >>> say , it becomes >>> >>> a = {

Re: the most efficient method of adding elements to the list

2006-06-06 Thread bruno at modulix
alf wrote: > Hi, > > Would it be .append()? Does it reallocate te list with each apend? > > l=[] > for i in xrange(n): > l.append(i) > FWIW, you'd have the same result with: l = range(n) More seriously (and in addition to other anwsers): you can also construct a list in one path: l

Re: Writing to a certain line?

2006-06-06 Thread bruno at modulix
Tommy B wrote: > I was wondering if there was a way to take a txt file and, while > keeping most of it, replace only one line. This is a FAQ (while I don't know if it's in the FAQ !-), and is in no way a Python problem. FWIW, this is also CS101... You can't do this in place with a text file (wo

Re: Package

2006-06-02 Thread bruno at modulix
Matthieu Pichaud wrote: > I have a problem organizing my programs in packages and subpackages. > > I use python.2.3.3 > I built a test structure to try to understand how it worked: > > /test > /test/__init__.py(containing: __all__=['test1']) > /test/test1/ > /test/test1/__init__.py(contai

Re: how to define a static field of a given class

2006-06-02 Thread bruno at modulix
feel_energetic wrote: > Hi, > > I already knew how to define a static method of a class( using > staticmethod() ), FWIW, it's probably one of the most useless construct in Python IMHO. classmethod are really much more useful to me. > but I find there isn't a built-in func to build a > static

Re: Inheritance structure less important in dynamic languages?

2006-06-02 Thread bruno at modulix
Marvin wrote: > Hi, > > It's been claimed s/claimed/observed/ In Python and Ruby, class hierarchies tends to be *really* flat when compared to Java or C++. > that inheritance structures are less important in dynamic > languages like Python. Why is that Don't you guess ?-) A very obvious poin

Re: Conditional Expressions in Python 2.4

2006-06-02 Thread bruno at modulix
A.M wrote: > Hi, > > > > I am using Python 2.4. I read the PEP 308 at: > > http://www.python.org/dev/peps/pep-0308/ > > I tried the statement: > > a= "Yes" if 1==1 else "No" > > but the interpreter doesn't accept it. > > Do we have the conditional expressions in Python 2.4? No, AFAIK they'

Re: Function mistaken for a method

2006-06-01 Thread bruno at modulix
Eric Brunel wrote: > Hi all, > > I just stepped on a thing that I can't explain. Here is some code > showing the problem: > > - > class C: Do yourself a favour : use new-style classes. class C(object) > f = None > def __init__(self): > if self.f is not None:

Re: Function mistaken for a method

2006-06-01 Thread bruno at modulix
Peter Otten wrote: > Eric Brunel wrote: > > >>My actual question is: why does it work in one case and not in the other? >>As I see it, int is just a function with one parameter, and the lambda is >>just another one. So why does the first work, and not the second? What >>'black magic' takes place

Re: How do you practice programming?

2006-06-01 Thread bruno at modulix
Ray wrote: > bruno at modulix wrote: > >>1/ programming >>2/ programming >>3/ lurking here, reading posts and sometimes trying to answer, reading >>source code of the oss apps/frameworks I'm working with, searching >>practical solutions in the cookbo

Re: How do you practice Python?

2006-06-01 Thread bruno at modulix
Ray wrote: > bruno at modulix wrote: > >>>In our field, we don't always get to program in the language we'd like >>>to program. So... how do you practice Python in this case? Say you're >>>doing J2EE right now. >> >>Hopefully not ! >

Re: Best way to do data source abstraction

2006-06-01 Thread bruno at modulix
Arthur Pemberton wrote: > What is the best way to do data source abtraction? For example have > different classes with the same interface, but different > implementations. > > I was thinking of almost having classA as my main class, and have > classA dynamically "absorb" classFood into to based on

Re: How do you practice programming?

2006-06-01 Thread bruno at modulix
Ray wrote: > OK, maybe I shoot a more general question to the group since there are > so many great programmers here: how do you practice your craft? I'm certainly not one of them, but... (snip) > How do you do your practice? > 1/ programming 2/ programming 3/ lurking here, reading posts and so

Re: How do you practice Python?

2006-06-01 Thread bruno at modulix
Ray wrote: > In our field, we don't always get to program in the language we'd like > to program. So... how do you practice Python in this case? Say you're > doing J2EE right now. Hopefully not ! > How do you practice Python to keep your skills > sharp? How *would* I do ? Well, perhaps I'd use J

Re: Best Python Editor

2006-05-31 Thread bruno at modulix
Manoj Kumar P wrote: > Hi, > > Can anyone tell me a good python editor/IDE? > It would be great if you can provide the download link also. I hate to be the one answering this, but this is *really* a FAQ - as you would have known if you had google'd this group for this. -- bruno desthuilliers py

Re: Very good Python Book. Free download : Beginning Python: From Novice to Professional

2006-05-30 Thread bruno at modulix
Moneyhere wrote: > Good :) > Can someone provide this ebook? . > I'm looking forwards it. > http://www.amazon.com/gp/product/0130410659/002-1715230-0496030?v=glance&n=283155 -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.

Re: TIming

2006-05-30 Thread bruno at modulix
WIdgeteye wrote: > HI, > I am trying to write a little program that will run a program on > scedule. There are usually existing programs to do so on most platforms (cron on *n*x, the Windows scheduler, etc). -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('

Re: Python keywords vs. English grammar

2006-05-24 Thread bruno at modulix
defcon8 wrote: > 1. Does it matter? > 2. Is it affecting your productivity. > 3. Are you not trying to programme? > 4. It is open source, change it and stop whining. > What about trying emacs +x doctor ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]

Re: Python Programming Books?

2006-05-24 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (snip) > So now i'm hear to use all of your collective expertise for the ideal > book for a beginning programming who want's to start with python. 'ideal' greatly depends on the reader !-) But FWIW, this is a FAQ (well : 2): http://www.python.org/doc/faq/general/#i-ve-ne

Re: Best way to handle exceptions with try/finally

2006-05-24 Thread bruno at modulix
Carl J. Van Arsdall wrote: (snip) Not an answer to your question, just a few comments on your code: > class Shared: class Shared(object): >def __init__(self): >self.__userData= {} >self.__mutex = threading.Lock() #lock object Don't use __names unless yo

Re: dict literals vs dict(**kwds)

2006-05-24 Thread bruno at modulix
George Sakkis wrote: > Bruno Desthuilliers wrote: > > >>George Sakkis a écrit : >> >>>Although I consider dict(**kwds) as one of the few unfortunate design >>>choices in python since it prevents the future addition of useful >>>keyword arguments (e.g a default value or an orderby function), I've

Re: Python - Web Display Technology

2006-05-23 Thread bruno at modulix
Ben Finney wrote: > "SamFeltus" <[EMAIL PROTECTED]> writes: > > >>I keep trying to understand why people like HTML/JS, I don't think I >>am gonna understand. > > > It's fairly simple: HTML, CSS and JavaScript have all been > standardised independent of any single corporation, and are freely > i

Re: Name conflict in class hierarchy

2006-05-23 Thread bruno at modulix
Scott David Daniels wrote: > bruno at modulix wrote: > >> Ralf Muschall wrote: >> >>> Jeffrey Barish wrote: >>> >>> [overriding of base class member functions by subclass] >>> In Python, a function not intended to be overriden should

Re: how to change sys.path?

2006-05-23 Thread bruno at modulix
Ju Hui wrote: > is python search module by paths in sys.path? sys.path is the list of path where the Python interpreter will search modules, yes. > how to change it manuallly? "manually" ?-) You mean "dynamically, by code" ? If yes, it's just a list. You can modify it like you'd do for any othe

Re: global name not defined

2006-05-23 Thread bruno at modulix
NetKev wrote: (snip) > def process_log(self, logfile, offset): > if new_denied_hosts: > info("new denied hosts: %s", str(new_denied_hosts)) > [warn_Admin(ip) for ip in new_denied_hosts] This uselessly builds a list. List comprehension is meant to create lists, n

Re: Class probkem - getting msg that self not defined

2006-05-23 Thread bruno at modulix
Andrew Robert wrote: > Hey Bruno, > > > Although I have not tested it, this appears to be it exactly. > > > Some confusion though. > > > > >>import struct >> >>class TriggerMessage(object): >>def __init__(self,data): >>""" >>Unpacks the passed binary data based on the >

Re: problem with writing a simple module

2006-05-22 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > ello there. i am having a problem getting a module to work right. > > i wrote a class that is going to be used in a few different scripts in > the same directory. > > it looks like this: > > #!/usr/bin/python This is not needed for a module. (snip code) > the file is

Re: string.count issue (i'm stupid?)

2006-05-22 Thread bruno at modulix
Matteo Rattotti wrote: > Hi all, > > i've noticed a strange beaviour of string.count: > > in my mind this code must work in this way: > > str = "a_a_a_a_" dont use 'str' as an identifier, it shadows the builtin str type. > howmuch = str.count("_a_") > print howmuch -> 3 > > but the count retu

Re: PEP-xxx: Unification of for statement and list-comp syntax

2006-05-22 Thread bruno at modulix
Edward Elliott wrote: > George Sakkis wrote: > > >>Em Dom, 2006-05-21 às 17:11 +0200, Heiko Wundram escreveu: >> >>>for node in tree if node.haschildren(): >>> >>> >>>as syntactic sugar for: >>> >>>for node in tree: >>>if not node.haschildren(): >>>continue >>> > > [snip] > >>2) "There should b

Re: Name conflict in class hierarchy

2006-05-22 Thread bruno at modulix
Ralf Muschall wrote: > Jeffrey Barish wrote: > > [overriding of base class member functions by subclass] > (snip) > > In Python, a function not intended to be overriden should be either > have a name starting with an underscore actually with *two* underscores. The single-leading-underscore nami

Re: altering an object as you iterate over it?

2006-05-22 Thread bruno at modulix
Paul McGuire wrote: > "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] > >>bruno at modulix a écrit : >>(snip) >> >>(responding to myself) >>(but under another identity - now that's a bit schizophrenic

Re: altering an object as you iterate over it?

2006-05-19 Thread bruno at modulix
John Salerno wrote: > What is the best way of altering something (in my case, a file) while > you are iterating over it? I've tried this before by accident and got an > error, naturally. > > I'm trying to read the lines of a file and remove all the blank ones. > One solution I tried is to open the

Re: Modifying a variable in a non-global outer scope?

2006-05-19 Thread bruno at modulix
Edward C. Jones wrote: > #! /usr/bin/env python > """ > When I run the following program I get the error message: > > UnboundLocalError: local variable 'x' referenced before assignment > > Can "inner" change the value of a variable defined in "outer"? Not this way > Where > is this explained i

Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.

2006-05-19 Thread bruno at modulix
Ian Bicking wrote: > glomde wrote: > >>i I would like to extend python so that you could create hiercical >>tree structures (XML, HTML etc) easier and that resulting code would be >>more readable than how you write today with packages like elementtree >>and xist. >>I dont want to replace the packa

  1   2   3   4   5   6   >