Re: how do "real" python programmers work?

2006-01-13 Thread bruno at modulix
bblais wrote: > Hello, > (snip) > > In C++, I open up an editor in one window, a Unix shell in another. (snip) > In Matlab, I do much the same thing, except there is no compile phase. (snip) > In Python, there seems to be a couple ways of doing things. I could > write it in one window, and fro

Re: [OT] how do "real" python programmers work?

2006-01-13 Thread bruno at modulix
Mike Meyer wrote: (snip) > Maybe > some of the people who IDEs (instead of - well, we need a term for > development environment built out of Unix tools) "Extegrated Development environment" ?-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p

Re: Web application design question (long)

2006-01-17 Thread bruno at modulix
Fried Egg wrote: > I must not express myself very clearly. > > I don't need any help with the disassociated text algorithm. What I > need is a framework for data processing web apps, If that's your main need, and you want to use a RDBMS, then you may want to have a l

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: 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: 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: 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: 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: 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 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: 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: 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: Function mistaken for a method

2006-06-01 Thread bruno at modulix
unc-vs-meth.py", line 18, in ? > o2 = C2() > File "func-vs-meth.py", line 5, in __init__ > self.x = self.f(0) > TypeError: () takes exactly 1 argument (2 given) Not surprising at all. Functions implement the descriptor protocol[1]. When bound to a class and looked up vi

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. >

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: how to define a static field of a given class

2006-06-02 Thread bruno at modulix
built-in func to build a > static field ( something like staticfield() ) Please define "static field", I just don't understand what it could be. Now if what you want is a class attribute (ie: an attribute that is shared by all instances of a class), just declare it at the class level:

Re: Package

2006-06-02 Thread bruno at modulix
import * >>>> test1 > >>>> test2 > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'test2' is not defined > So it seems that I am very limited in the number of subpackages I can > create. Not at all. &g

Re: Writing to a certain line?

2006-06-06 Thread bruno at modulix
ently and don't care about files being human-readable, you may be better using some lightweight database system (berkeley, sqlite,...) or any other existing lib that'll take care of gory details. Else - if you want/need to stick to human readable flat text files - at least write a solid l

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: check for dictionary keys

2006-06-06 Thread bruno at modulix
re next in my code, i will check for these..: >>> >>> 1) -A and -B cannot exist together >>> 2) -A and -C cannot exist together >>> 3) -A and -B and -D cannot exist together >>> 4) and lots of other combinations to check for >> >> >>

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: 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-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: 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: creating and naming objects

2006-06-07 Thread bruno at modulix
ent() This won't work - will raise a TypeError. You defined Student.__init__() to take 2 mandatory parameters name and id,so you must pass them at call time. FWIW, you would have noticed this just by trying it into your Python shell. The interactive Python shell is a very valuable tool. It mak

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: 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: 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: 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

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 us

Re: Error in Chain of Function calls

2006-06-09 Thread bruno at modulix
> 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 findPI, and so on. > However i am getting an error at the line m

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: >>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. W

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: 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: [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: 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: 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: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread bruno at modulix
tances,output of this function to >>>tiCount and findPI, and so on. >>>However i am getting an error at the line marked with ***. >> >>Which error ? How do you hope us to be of any help here if you don't *at >>least* provide the full traceback ? FWIW, the can

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: "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: "parent" in a class __init__ def?

2006-06-12 Thread bruno at modulix
ery defined meaning in Python - a class method is a method that takes the class object - not the instance - as first param. > can refer to, vs. some other organization ? > Should all relevant objects/vars just be passed into the method as needed? There's no absolute rule about this

Re: Function to remove elements from a list not working

2006-06-12 Thread bruno at modulix
> You did not test this code, did you ? >>> getl5() Traceback (most recent call last): File "", line 1, in ? File "/usr/tmp/python-961l_S.py", line 7, in getl5 NameError: global name 'element' is not defined >>> The SimpleStupid(tm) way to do this

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 thing

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: "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: 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: 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: 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: 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('h

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

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 us

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: __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: 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: a good programming text editor (not IDE)

2006-06-16 Thread bruno at modulix
to effectively use a powerful and extensible test editor is the WiseThingTodo(tm). > (probably Vim, > since I hear it's lighter and faster). It's a bit faster at startup, yes. Else, I'm not sure it makes a real difference wrt/ performances and power. It's more a matter

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: > 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: > 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
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 r

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... Defini

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 > thin

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: (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: 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: Legitimate use of the "is" comparison operator?

2006-06-17 Thread bruno at modulix
isinstance(obj, klass) instead - and yet better, don't check type at all if you can avoid it. > and I was just wondering whether or not > it is considered bad practice in the Python Community to use it for > numerics as well. It's even worse than a bad practice : it's an er

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

2006-06-17 Thread bruno at modulix
impressed the first time - note that it was at the very end of the last century, with v1.5.2. But still I found the language suprisingly simple to get up and running with - seemed like the language was almost always reading my mind about how I would have named a librairy, function or whatever !-) S

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: [OT] code is data

2006-06-19 Thread bruno at modulix
for a long time already, and metatypes and > generators are having some strange unexplored possibilities too, but the > day will come soon (and at last when PyPy is reaching execution speeds > close to cPython) where Python will be able to swallow smaller > languages, and finally it will b

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: 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
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: 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: 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: [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: 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: 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: [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: 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, ra

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: [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: Specifing arguments type for a function

2006-06-20 Thread bruno at modulix
an iterable - and the exception >> will >> come from arg not being iterable. >> >> But what you can't do is make python complain about this: >> >> def f(arg): >> for e in arg: >> print e >> >> >> f(100) >> &

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: 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: 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: 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

Difference between two dates in seconds

2006-09-27 Thread Claes at work
Hi, I am learning Python and want to perform what I think is a very simple task: calculating the difference between two dates in seconds. Reading through the documentation I am puzzled: I can't find a way to do this without doing manually what I think belongs to a standard library method. Please

Re: Difference between two dates in seconds

2006-09-27 Thread Claes at work
On 9/27/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Claes at work wrote: > > why would you have to do that yourself? why not let Python do it for > you? here's the code: > > seconds = td.days * 86400 + td.seconds > Thanks, but that is exactly what I mea

Re: file_name_fixer.py

2006-01-24 Thread bruno at modulix
perfect usecase for regexps... > if oldname != newname: > if os.path.isfile(newname) or os.path.isdir(newname): > print oldname, "-->\n", newname, "\t\t\tERROR: file/dir > exists\n" > else: > pr

Re: Assigning to self.__class__

2006-01-26 Thread bruno at modulix
anyway !-) > Is this intended capability for Python > objects, AFAIK, yes. > or am I taking advantage of a fortuitous accident, which may get > undone at a future time? It's certainly not a fortuitous accident. -- bruno desthuilliers python -c "print '@'.jo

Re: ImportError: No module name MySQLdb

2006-01-26 Thread bruno at modulix
e that I do NOT get the error when running the script normally from > Python. So I'd say it has something to do with sys.path Is there anything "non-standard" with your config ? Like modules installed as a user and/or outside of /usr/lib/pythonXXX/site-packages/ ? > I have re

Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Danny wrote: > I think I should paste some of the programs code a little more of what I > want... probably... > var = 0 > while var <= 5: > print a[t[var]] > var = var +1 > > a is a dectionary (very big) and t is a string of text. (if that's > important right now). It might be important

Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Jeffrey Schwab wrote: > Danny wrote: > >> Great! It's been solved. >> >> The line, as Glaudio said has a "," at the end and that makes it go >> onto one line, thanks so much man! >> >> var = 0 >> while <= 5: >> print

Re: Question about isinstance()

2006-01-27 Thread bruno at modulix
Dave Benjamin wrote: (snip) > You *could* have "b.__eq__" just call "a.__eq__", Which could lead to strange results (well, actually a good ole infinite recursion) if b.__eq__ happens to call b.__eq__ too !-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split(

Re: Question about isinstance()

2006-01-27 Thread bruno at modulix
Mr.Rech wrote: > All in all it seems that the implementation that uses isinstance() is > better in this case... You could also use something like Zope's Interfaces... But I'm not sure it's worth the extra complexity. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.

Re: generating method names 'dynamically'

2006-01-27 Thread bruno at modulix
Daniel Nogradi wrote: > Is it possible to have method names of a class generated somehow dynamically? >>> class Dummy(object): ... pass ... >>> def mymethod(self, *args, **kw): ... pass ... >>> setattr(Dummy, 'a_dynamically_generated_method_name', mymethod) >>> >>> Dummy.a_dynamically_generate

Re: any way to customize the is operator?

2006-01-27 Thread bruno at modulix
Lonnie Princehouse wrote: >>(objects are not allowed to lie about who they are, or what they are). > > > Dangit! I need to find a less honest programming language. Anyone > have a Perl cookbook handy? ... > +1 QOTW (approved by a fellow Perl programmer FWIW !-) -- bruno desthuilliers python

Re: Question about isinstance()

2006-01-27 Thread bruno at modulix
bruno at modulix wrote: > Dave Benjamin wrote: > (snip) > > >>You *could* have "b.__eq__" just call "a.__eq__", > > > Which could lead to strange results (well, actually a good ole infinite > recursion) if b.__eq__ happens to call b.__eq__

Re: LDAPUserFolder mapping roles

2006-01-30 Thread bruno at modulix
Marcel Hartmann wrote: > I'm using LDAPUserFolder for Zope 2.7.6 and it works fine. > > Is it possible to do the mapping to zope roles by the _value_ of the > group and not the group name? > We defined in LDAP many groups to define access to different > applications - one is named "zope". I want t

Re: Cheetah template driven object output? Pythonically?

2006-01-30 Thread bruno at modulix
Fried Egg wrote: > This may be trivial or stupid or both, but does anyone have a recipe > for gracefully using Cheetah to generate a text representation of an > object, but embedded in the object (so that it can be pickled, > unpickled, and told to display itself)? > > Here is what I am thinking:

<    1   2   3   4   5   6   7   >