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
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: 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
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: 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: 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: 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('hotels.xml') while True: block = file.

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: 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: 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
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: 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 return at the end of every line). I don't

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: 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
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
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: 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: 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
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: 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, rather than putting them at the beginning, >>which

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

Re: file_name_fixer.py

2006-01-24 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > i put this together to fix a bunch of files with wierd names, please > gimme feedback, i am a newbie Ok, so let's go... Hope you won't hate me too much !-) > > #!/usr/bin/env python > import os > import sys > import string > import platform > dir = sys.argv[1] This wil

Re: Assigning to self.__class__

2006-01-26 Thread bruno at modulix
Paul McGuire wrote: > I have some places in pyparsing where I've found that the most > straightforward way to adjust an instance's behavior is to change its class. Hooray ! You've just (re)discovered the state pattern... for which the most stupid simple implementation in Python is to : >(snip) as

Re: ImportError: No module name MySQLdb

2006-01-26 Thread bruno at modulix
Fred wrote: > I hope someone can help me with the below problem... > > Thanks, > Fred > > My enviroment: > -- > Slackware Linux 10.2 > Python 2.4.2 > MySql version 4.1.14 > MySql-Python 1.2.0 > > What I am trying to do: > --- > Using MySQL, Python,

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 a[t[var]], >> var = var +1 >> prints perfectly, thanks so much guys. > >

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:

Re: Costly object creation (was : Having Trouble with Scoping Rules)

2006-01-31 Thread bruno at modulix
Charles Krug wrote: > List: > > I've a module that's not doing what I expect. My guess is that I don't > quite understand the scoping rules the way I should. > > I have an object that's costly to create. My thought was to create it > at the module level like this: (snip) > What's the correct

Re: A simple question string.replace

2006-01-31 Thread bruno at modulix
Haibao Tang wrote: > I have a two-column data file like this > 1.12.3 > 2.211.1 > 4.31.1 > ... > Is it possible to substitue all '1.1' to some value else without using > re. I suppose that you don't want '11.1' to be affected. raw_data=""" 1.12.3 2.211.1 4.31.1 """ data =

Re: test whether 2 objects are equal

2006-01-31 Thread bruno at modulix
Yves Glodt wrote: > Hello, > > > I need to compare 2 instances of objects to see whether they are equal > or not, but with the code down it does not work (it outputs "not equal") > > > #!/usr/bin/python > > class Test: > var1 = '' > var2 = '' Take care, this creates two *class* variab

Re: OO conventions

2006-02-03 Thread bruno at modulix
Blair P. Houghton wrote: (snip) > So Image.open(filename) seems right as a factory function that opens > the file, figures out what it really is, constructs the appropriate > subclass object (likely by passing a string to the constructor, e.g., > JPGImage(filename)), and returns the object via th

Re: Another try at Python's selfishness

2006-02-03 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Having read previous discussions on python-dev I think I'm not the only > Python programmer who doesn't particularly like python's "self" > parameter: bang ! You're dead ! (no no, just kidding !-) > > class Foo: old-style classes are deprecated. class Foo(object

Re: Regular expression query

2006-02-03 Thread bruno at modulix
Martin Biddiscombe wrote: > It's probably quite simple, but what I want is a regular expression If it's simple, then you probably *dont* want a regexp. > to > parse strings of the form: > > "parameter=12ab" > "parameter=12ab foo bar" > "parameter='12ab'" > "parameter='12ab' biz boz" > "parameter

Re: problems writing tuple to log file

2006-02-03 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > i am having a problem writing a tuple to a text file. my code is > below. I'd rather say you are having a problem with logic. > what i end up getting is a text file that looks like this > > burger, 7up > burger, 7up > burger, 7up Which is exactly what one would expec

Re: Compiling

2006-02-03 Thread bruno at modulix
Simon Faulkner wrote: > Pardon me if this has been done to death but I can't find a simple > explanation. > > I love Python for it's ease and speed of development especially for the > "Programming Challenged" like me but why hasn't someone written a > compiler for Python? But there *is* a compile

Re: Python on Windows

2006-02-03 Thread bruno at modulix
Simon Faulkner wrote: > I've just written my first (simple) WxPython program - yy! > > What would folks suggest is the easiest way to package it to run on > other windows PCs? I can't tell for sure since I do not use Windows, but I think Py2Exe is what you're looking for. -- bruno desthui

Re: Compiling

2006-02-03 Thread bruno at modulix
Simon Faulkner wrote: >>> I love Python for it's ease and speed of development especially for the >>> "Programming Challenged" like me but why hasn't someone written a >>> compiler for Python? >> >> >> >> But there *is* a compiler for Python. >> http://www.python.org/doc/2.4.2/lib/module-compiler.h

Re: Regular expression query

2006-02-06 Thread bruno at modulix
Giovanni Bajo wrote: > Martin Biddiscombe wrote: > > >>"parameter=12ab" >>"parameter=12ab foo bar" >>"parameter='12ab'" >>"parameter='12ab' biz boz" >>"parameter="12ab"" >>"parameter="12ab" junk" > > import shlex def extract(s): > > ... s = s.split("=")[1] > ... s = shlex.split

Re: fairly large webapp: from Java to Python. experiences?

2006-02-07 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (snip) > Does anyone here have any experience with large(ish) webapps in Python? Depends on the definition of "large(ish)". If you use KLOC as a metric, you can expect a Python solution to be 5 to 10 time smaller, so what's a 'large' app in Java may end up as a small/med

Re: Too Many if Statements?

2006-02-07 Thread bruno at modulix
slogging_away wrote: > Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 > 32 bit (Intel)] on win32, and have a script that makes numerous checks > on text files, (configuration files), so discrepancies can be reported. > The script works fine but it appears that I may have hi

Re: Too Many if Statements?

2006-02-07 Thread bruno at modulix
slogging_away wrote: > I don't consider myself to be a seasoned programmer nor do I. > so if you mean > redesigning the script to make the checks and therefore reduce the > number of 'if' statements, I'm not sure if that can be done. I strongly doubt it could *not* be done !-) > The > script n

Re: Too Many if Statements?

2006-02-08 Thread bruno at modulix
Pierre Quentel wrote: > This is because Python has a hidden mechanism to detect programs > generated by Perl scripts, and make them crash with no explanation > KEYBOARD ! -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.spl

Re: Python Class use

2006-02-08 Thread bruno at modulix
S Borg wrote: > Hello, > > I am running Python on Mac OS X. The interpreter has been great for > learning the basics, but I would now like to be able to reuse code. > How do I write reusable code? I have done it "The Java way": write > the class, and save it to my home directory, then call it fr

Re: 450 Pound Library Program

2006-02-08 Thread bruno at modulix
mwt wrote: > So in a further attempt to learn some Python, I've taken the little > Library program > (http://groups.google.com/group/comp.lang.python/browse_thread/thread/f6a9ccf1bc136f84) > I wrote and added several features to it. Readers now quit when they've > read all the books in the Library.

Re: 450 Pound Library Program

2006-02-08 Thread bruno at modulix
Magnus Lycka wrote: > just a few style notes... > (snip) > > Why bother with L? The follwing is as clear I think, and solves > the problem of commas in the title. Also, don't put a space between > the callable and the parenthesis please. See the Python style guide, > PEP 008. > > aut

Re: module with __call__ defined is not callable?

2006-02-08 Thread bruno at modulix
Steve Holden wrote: (snip) > The pursuit of orthogonality, while admirable, can lead to insanity if > pushed too far. > +1 QOTW -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailm

Re: 450 Pound Library Program

2006-02-08 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Ok, > > I give up. DRY = Don't Repeat Yourself (google Pragmatic Programmers) > but SPOT? Google is little help here, SPOT is too common a word. Single Point Of Truth (or Single Point Of Transformation) And before you mention it, yes, it's *almost* the same thing as D

Re: 450 Pound Library Program

2006-02-08 Thread bruno at modulix
Magnus Lycka wrote: > [EMAIL PROTECTED] wrote: > >> Ok, >> >> I give up. DRY = Don't Repeat Yourself (google Pragmatic Programmers) >> but SPOT? Google is little help here, SPOT is too common a word. > > > The only SPOT I worked with (as I know of) was SPOT4 > (Le Systeme Pour 'l Observation de

Re: how to remove using replace function?

2006-02-09 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > i have some html that looks like this > > > 34 main, Boston, MA > > and i am trying to use the replace function to get rid of the that > i scrape out using this code: > > for oText in incident.fetchText( oRE): > strTitle += oText.strip() Why concatening

Re: Finding the public callables of self

2006-02-09 Thread bruno at modulix
Sion Arrowsmith wrote: > Russell Warren <[EMAIL PROTECTED]> wrote: (snip) > At first I thought self.__dict__ would do it, but callable methods >>seem to be excluded so I had to resort to dir, and deal with the >>strings it gives me. > > This last sentence suggests to me something like: > > a

Re: read-only attributes

2006-02-10 Thread bruno at modulix
limodou wrote: > On 2/10/06, john peter <[EMAIL PROTECTED]> wrote: (snip) >> what do i have to do if i want my application code to have >>read-only >> attributes? >> > I think you may consider property() built-in function: > > property( [fget[, fset[, fdel[, doc) > > Return a property attrib

Re: breaking from loop

2006-02-10 Thread bruno at modulix
Ritesh Raj Sarraf wrote: > Hi, > > Following is the code: > > def walk_tree_copy(sRepository, sFile, sSourceDir, bFound = None): > try: > if sRepository is not None: You're being overly defensive here. Passing None as first arg is clearly a programming error, so the sooner you detect

Re: Too Many if Statements?

2006-02-10 Thread bruno at modulix
slogging_away wrote: > It appears it may not be a 'if' statment limitation at all. This is > because I added another 800 element array Looks like a memory problem then... > in which to store the various > error messages generated when a configuration file error is deteceted > based on their sev

Re: Too Many if Statements?

2006-02-13 Thread bruno at modulix
slogging_away wrote: > bruno at modulix wrote: > > >>Looks like a memory problem then... > > > The system I am using has 2GB of memory, (unless you are syaing the > memory is faulty). Nope, just that I don't know of any system with unlimited memory. BTW, havin

Re: Another n00b: Removing the space in "print 'text', var"

2006-02-13 Thread bruno at modulix
HappyHippy wrote: > More of a minor niggle than anything but how would I remove the > aforementioned space? > eg. > strName = 'World' > print 'Hello', strName, ', how are you today?' Already got an anwser, now just a coding-style suggestion: hungarian notation is *evil*. And even *more* evil wi

Re: Location of Python modules

2006-02-13 Thread bruno at modulix
Byte wrote: > Pretty much self explanatry, where are Python modules stored in Linux? > (i.e. in /usr/bin/local, or where?) > Depends on how you installed Python (or how your distro package system installed it). But it's usually in $PREFIX/lib/pythonX.X , with $PREFIX being one of /usr or /usr/loca

Re: Loop Backwards

2006-02-14 Thread bruno at modulix
Dave wrote: > This should be simple, but I can't get it: > > How do you loop backwards through a list? > > For example, in, say, Javascript: > > for (var i = list.length - 1; i >=0; i--) { > do_stuff() > } > > I mean, I could reverse the list, but I don't want to. I want it to > stay exact

Re: Python / Apache / MySQL

2006-02-14 Thread bruno at modulix
vpr wrote: > Hi All > > I want to build an Website using Apache / Python and MySQL. Good choice, good choice, bad choice... Why not using PostgresSQL (if you need a *real* RDBMS) or SQLite (if you don't...) > I dont want to spend to much time hacking html. I'm looking for some > recommendations

Re: Pythonic gui format?

2006-02-14 Thread bruno at modulix
DH wrote: > Bruno Desthuilliers wrote: > >>> I am currently seeking for pythonic alternative for XML. >> >> >> A pretty obvious one is dicts and lists. What about (Q&D): > > > That's like JSON: http://www.json.org/example.html No, it's pure Python. It happens that JSON looks pretty close to Py

Re: Python / Apache / MySQL

2006-02-14 Thread bruno at modulix
Kalle Anke wrote: > On Tue, 14 Feb 2006 10:32:34 +0100, Sybren Stuvel wrote > (in article <[EMAIL PROTECTED]>): > > >>I second Bruno: swap MySQL in favour of PostgreSQL. > > > And the reason is ?? (apart from PostgreSQL being larger and more complete, > what are the differences for "simple" us

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread bruno at modulix
Steven D'Aprano wrote: > I came across this unexpected behaviour of getattr for new style classes. > Example: > > class Parrot(object): > > ... thing = [1,2,3] > ... > getattr(Parrot, "thing") is Parrot.thing > > True > getattr(Parrot, "__dict__") is Parrot.__dict__ > > False

Re: [OT] Pythonic gui format?

2006-02-14 Thread bruno at modulix
Christoph Zwerschke wrote: > Bruno Desthuilliers schrieb: > >> Gregory Petrosyan a écrit : >> >>> I am currently seeking for pythonic alternative for XML. >> >> (snip) > Bruno, before writing another simple GUI, Sorry, Christoph, wrong attribution !-) -- bruno desthuilliers python -c "pr

Re: Pythonic gui format?

2006-02-14 Thread bruno at modulix
DH wrote: > bruno at modulix wrote: > >> DH wrote: >> >>> Bruno Desthuilliers wrote: >>> >>>>> I am currently seeking for pythonic alternative for XML. >>>> >>>> >>>> A pretty obvious one is dicts and

<    1   2   3   4   5   6   >