Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread Bruno Desthuilliers
alf a écrit : > Hi, > > I have a reference to certain objects. What is the most pythonic way to > test for valid reference: > > if obj: Don't do this: for o in [0, '', [], {}, ()]: print obj, bool(obj), obj is None > if None!=obs: In python, assignement is a statement, not an exp

Re: Better way to replace/remove characters in a list of strings.

2006-09-04 Thread Bruno Desthuilliers
Chris Brat a écrit : > Thanks, thats exactly what I was looking for - very neat. > Just note that both solutions rebind the name to a newly constructed list instead of modifying the original list in place. This is usually the RightThing(tm), but sometimes one wants an in-place modification. --

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-05 Thread Bruno Desthuilliers
Carl Banks wrote: > Bruno Desthuilliers wrote: >> In python, assignement is a statement, not an expression, so there's no >> way you could write 'if obj = None' by mistake (-> syntax error). So >> this style is unpythonic. Also, None is a singleton, and ident

Re: Is it just me, or is Sqlite3 goofy?

2006-09-05 Thread Bruno Desthuilliers
ssible. In it's category, it beats Access and MySQL hands down. Now if you want a real RDBMS, you've just failed to choose the right tool. May I suggest PostgreSQL ? (snip useless rant) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1]

Re: why have to "from compiler import *"

2006-09-05 Thread Bruno Desthuilliers
the current namespace. The 'import *' loads all public names from . And FWIW it's usually considered bad style (potential name clash, and can makes hard to tell where a name is defined...) HTH -- 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: SQLObject or SQLAlchemy?

2006-09-06 Thread Bruno Desthuilliers
lazaridis_com wrote: > Bruno Desthuilliers wrote: >> lazaridis_com wrote: >>> Ο/Η Bruno Desthuilliers έγραψε: >>>> lazaridis_com wrote: >>>>> John Salerno wrote: >>>>>> Are there any major differences between these two? It seems th

Re: Is it just me, or is Sqlite3 goofy?

2006-09-06 Thread Bruno Desthuilliers
d you read the manuals at all then ? >> Live with it or use a real RDBMS. > > I don't mind living with it as long as it's documented. It is. In SQLite manual. Or do you hope the Python manual to also fully document PostgreSQL, MySQL, Oracle, Apache, Posix, Win32 etc ? -- b

Re: python vs java

2006-09-06 Thread Bruno Desthuilliers
etc). Coming from C++, you'll probably need a few days to grasp Python's object model and idioms (Python looks much less like a dumbed-down C++ than Java), but my bet is that you'll be productive *way* sooner with Python, and *much* more productive. My 2 cents, -- bruno desthuillie

Re: IDE

2006-09-06 Thread Bruno Desthuilliers
as) some licencing limitations on Windows. -- 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: python vs java

2006-09-07 Thread Bruno Desthuilliers
Jason wrote: > Bruno Desthuilliers wrote: >> With a GUI ? If so, you probably want to check out wxPython or PyGTK >> (wxPython will also buy you MacOS X IIRC, and wil perhaps be easier to >> install on Windows). > > Just a warning: wxPython does operate slightly dif

Re: Question about subclassing and overriding methods

2006-09-07 Thread Bruno Desthuilliers
Or go for a saner design... > but clearly that is not happening. > Can someone explain why. Test2(2,True) calls Test2.__init__() with a Test2 instance 'self' and y=True. Test2.__init__() then calls Test.__init__() with the same instance and y=True. So the branch: if y: self.getx =

Re: Question about subclassing - version 2

2006-09-08 Thread Bruno Desthuilliers
nstanciated. You mentioned NotImplementedError, which is indeed the usual way to make something "abstract" in Python. -- 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: Question about subclassing - version 2

2006-09-08 Thread Bruno Desthuilliers
his problem? Not out of my hat. Just a few considerations on Python and OO: Python being dynamically typed, inheritence is only about sharing implementation. There's another way to do share implementation - composition/delegation. It's more flexible, and can avoid "cartesian product&quo

Re: Best Middle Tier Architechure?

2006-09-08 Thread Bruno Desthuilliers
Butternut Squash wrote: > What do you guys recommend for doing middle tier in python. > I want to hide the database from the application Why ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in &

Re: Question about subclassing - version 2

2006-09-08 Thread Bruno Desthuilliers
there is a more correct > term. Depends if instanciating this base class would make any sense. -- 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: Request for tips on my first python script.

2006-09-08 Thread Bruno Desthuilliers
> sys.exit(2) > #usage() > > for opt, arg in opts: > if opt in ("-l", "--latest"): > latest = int(arg) > elif opt in ("--notfound"): > ignoreNotFound = True #add notfound files to log OMG. optparse is far better than this. (snip) My overall feeling is that in most function, you're mixing too much different concerns. Each function should do *one* thing (and do it well). The most obvious problem here is about mixing application logic and UI. Application logic (what your app is effectively doing) should be as independant as possible of UI concerns. If possible, you should be able to reuse most of the application logic (except for the main() func, which in your case is the command-line UI) as a module in other applications. Now there are time when the application code needs to notify the UI. The good news is that Python makes it easy to makes this generic, using callback functions or objects provided by the UI and called when appropriate by the application logic. The key here is to come up with a clear, well-defined interface between logic code and UI code. A last point : avoid globals whenever possible. Either pass values as arguments to functions or use a kind of config object if there are too much configuration stuff. My 2 cents -- 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: Question about subclassing - version 2

2006-09-08 Thread Bruno Desthuilliers
Frank Millman wrote: > Bruno Desthuilliers wrote: >> Frank Millman wrote: >>> [EMAIL PROTECTED] wrote: >>>> There aren't abstract classes in Python. They are all >>>> concrete. >> (snip) >>> I use the term 'abstract class' in

Re: Question about subclassing - version 2

2006-09-09 Thread Bruno Desthuilliers
Maric Michaud a écrit : > Le vendredi 08 septembre 2006 10:15, Bruno Desthuilliers a écrit : > >>You >>mentioned NotImplementedError, which is indeed the usual way to make >>something "abstract" in Python. > > > Hummm, some more thoughts about this.

Re: Building Python Based Web Application

2006-09-09 Thread Bruno Desthuilliers
James Stroud a écrit : > Hello All, > > I am interested in setting up a modest invoicing system for some > consulting I am doing. I like the idea of managing this on the web and > creating invoices and printing them from a browser. However, I'm not > really sure where to start. I've played with

Re: newbie: datastructure `dictionary' question

2006-09-09 Thread Bruno Desthuilliers
jason a écrit : Just some more suggestions: > def parselog(data): > other = 0 > records = {} > > for line in string.split(data, '\n'): for line in data.split('\n'): > str = line.strip() This will shadow the builtin 'str' type. You could reassign to 'line' instead, or

Re: egg and modpython

2006-09-10 Thread Bruno Desthuilliers
Wensheng a écrit : > I installed pysqlite2 using easy_install. > and got this when using it from modpython: > -- > Mod_python error: "PythonHandler etc.modpython" > > Traceback (most recent call last):

Re: Method resolution for super(Class, obj).

2006-09-10 Thread Bruno Desthuilliers
ddtl a écrit : > On 7 Sep 2006 10:42:54 -0700, in comp.lang.python you wrote: > > >>Let's examine what the mro order is for class D: >> >D.mro() >> >>[, , , >>>n__.A'>, ] >> >>When you call d.met(), the call dispatches to the D.met() method. >>After printing out 'D.met', you use super() to ge

Re: Is there a way to take a priori knowledge out of field definitions?

2006-09-11 Thread Bruno Desthuilliers
ips of and between the items of data? Looks a lot like a RDBMS... > It seems to me that if this could be done, then it could be used to > dynamically > generate the routines needed for validation, update, etc... > > But my brain strains when I try to think about how to do it... Yo

Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)

2006-09-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Bruno Desthuilliers wrote: >> [EMAIL PROTECTED] wrote: >>> Probably just me. I've only been using Access and SQL Server >>> for 12 years, so I'm sure my opinions don't count for anything. >>> >> SQLite neve

Re: Is it just me, or is Sqlite3 goofy?

2006-09-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: (snip) > Are you saying that MySQL is goofy? ;-) > This is an understatement. -- 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: egg and modpython

2006-09-12 Thread Bruno Desthuilliers
Paul Boddie wrote: > Bruno Desthuilliers wrote: >> Wensheng a écrit : >>> I installed pysqlite2 using easy_install. >>> and got this when using it from modpython: >>> ---

Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)

2006-09-12 Thread Bruno Desthuilliers
eciated. Your sarcastic, condescending tone kind of gets in > the way of the message, though. What about jokes on "waterheadretard" then ? -- 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: variable update

2006-09-12 Thread Bruno Desthuilliers
Note to the OP: if None is a valid value for the variable, you may use another object, ie: def somefunc(*args, **kw): variable = _marker = object() (...) if variable is _marker: print "not defined" (...) -- bruno desthuilliers python -c "print '@'.joi

Re: egg and modpython

2006-09-12 Thread Bruno Desthuilliers
Paul Boddie wrote: > Bruno Desthuilliers wrote: >> eggs are the Python's equivalent to Java's JAR, not a RPM-like. I said >> it was not an egg-specific issue (which is not totally accurate) because >> it mostly have to do with loading dynamic libs (.so, .dll etc)

Re: how are dictionary literals handled by the interpreter?

2006-09-14 Thread Bruno Desthuilliers
) def defaultFunc(*args, **kw): return "defaultFunc called with %s %s" % (str(args), kw) class SwitchFunc(object): def __init__(self, default, **kw): self._default = default self._switch = kw # makes the object callable. def __call__(self, case, *args, **kw): func = self._switch.get(case, self._default) return func(*args, **kw) switch = SwitchFunc(defaultFunc, a=funcA, b=funcB, c=funcC) for case in "abcX": print switch(case, "foo", q=42) HTH -- 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: When is it a pointer (aka reference) - when is it a copy?

2006-09-14 Thread Bruno Desthuilliers
g, id(arg)) def runtest(): obj = ["Life, universe and everything"] print "in runtest : obj is %s (%s)" % (obj, id(obj)) print "calling test with obj:" test(obj) print "in runtest: now obj is %s (%s)" % (obj, id(obj)) Here again, if you want your func

Re: how are dictionary literals handled by the interpreter?

2006-09-14 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Bruno Desthuilliers wrote: >> [EMAIL PROTECTED] wrote: (snip) >>> class caseFunction(object): >>> def __init__(self): >>> self.caseDict = {'a':"retval = 'a'", >>> 'b':"r

Re: page contents are not refreshed

2006-09-14 Thread Bruno Desthuilliers
waylan a écrit : (snip) > > While Steve's examples certainly do the trick in this limited case, I > assumed that the original poster was just starting with mod_python and > I was simply trying to explain the bigger picture for future reference. > As one develops more sophisticated code, simply add

Re: add without carry

2006-09-15 Thread Bruno Desthuilliers
to come up with the most possibly Q&D solution: res = int(str(5 + 7)[-1]) Like it ?-) -- 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: add without carry

2006-09-15 Thread Bruno Desthuilliers
x27; operator. For example: > > print 5 ^ 7 > > >>> 10 ^ 21 31 Not really "less than 10"... -- 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: add without carry

2006-09-15 Thread Bruno Desthuilliers
Christophe wrote: > Bruno Desthuilliers a écrit : >> Bryan Olson wrote: >>> Hugh wrote: >>>> Sorry, here's an example... >>>> >>>> 5+7=12 >>>> >>>> added without carrying, 5+7=2 >>>> >>>>

Re: Check if variable is an instance of a File object

2006-09-15 Thread Bruno Desthuilliers
;t care if the objects is a file or not - you just care if the object support the subset of the file interface you intend to use. And this, you'll only know at runtime. -- 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: Check if variable is an instance of a File object

2006-09-15 Thread Bruno Desthuilliers
the rest of the code, but if it's something like this : def show_lines(fileobj): for line in fileobj: print line it will just work... -- 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: ancestor class' __init__ doesn't call other methods

2006-09-15 Thread Bruno Desthuilliers
Luis P. Mendes a écrit : > Hi, > > I have the following problem: > > I instantiate class Sistema from another class. The result is the same > if I import it to interactive shell. > > s = Sistema("par") > > class Sistema: > def __init__(self, par): > cruza_ema = CruzaEmas(par) > >

Re: add without carry

2006-09-15 Thread Bruno Desthuilliers
Jon Ribbens a écrit : > In article <[EMAIL PROTECTED]>, Bruno Desthuilliers wrote: > >>Hugh wrote: >> >>>Sorry, here's an example... >>> >>>5+7=12 >>> >>>added without carrying, 5+7=2 >>> >>>i.e the

Re: RegexBuddy (anyone use this?)

2006-09-17 Thread Bruno Desthuilliers
Thorsten Kampe a écrit : (snip) > PS Actually the author wrote the finest and best Windows Editor and I > also use EditPad Pro under Linux (together with Wine) because of the > lack of usables editors under Linux. I guess we don't have the same definition of a "usable" editor... -- http://mail.py

Re: Pythondocs.info : collaborative Python documentation project

2006-09-18 Thread Bruno Desthuilliers
times before understanding what it means. >> > >> Where have you read that? >> >> wildemar > > I don't mean to start a flame war about this but here are some > reference of people, who like me, don't like the current python doc: > http://xahlee.org/Unix

Re: Where can i download mod_webkit from?

2006-09-18 Thread Bruno Desthuilliers
nload page, i'd greatly appreciate if you share it > with me. http://www.webwareforpython.org/WebKit/Docs/InstallGuide.html#mod-webkit """ The source code and a README file describing how to configure and build mod_webkit are located in the Webware/WebKit/Adapters/mod_webkit "

Re: Automatically installing libraries?

2006-09-18 Thread Bruno Desthuilliers
initively have a look at setuptools before proceeding to reinventing the SquareWheel(tm): http://peak.telecommunity.com/DevCenter/setuptools -- 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: Creating database structures in a portable way

2006-09-18 Thread Bruno Desthuilliers
w to generate SQLAlchemy schemas instead. My 2 cents... -- 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: Pythondocs.info : collaborative Python documentation project

2006-09-18 Thread Bruno Desthuilliers
lert ! Unusable undocumented monstruosity ahead... -- 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: Creating database structures in a portable way

2006-09-18 Thread Bruno Desthuilliers
Samuel a écrit : >>FWIW, there's a Python port of adodb: >>http://phplens.com/lens/adodb/adodb-py-docs.htm >> >>and parsing XML in Python is quite easy. So you could as well port the >>AdoDB XML to Python too. > > > That is exactly what I am trying to avoid. While implementing the > parser might

Re: new string method in 2.5 (partition)

2006-09-19 Thread Bruno Desthuilliers
John Salerno a écrit : > Forgive my excitement, especially if you are already aware of this, but > this seems like the kind of feature that is easily overlooked (yet could > be very useful): > > > Both 8-bit and Unicode strings have new partition(sep) and > rpartition(sep) methods that simplif

Re: include statement

2006-09-20 Thread Bruno Desthuilliers
in the app code, a simple 'import config', which allow acces to config vars via 'config.varname' (clean namespaces really improve maintainability). My 2 cents > Regards > > Joakim > -- 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: Nested Looping SQL Querys

2006-09-20 Thread Bruno Desthuilliers
n.query(sqlcheck1) pubType = cmi.fetch_rows(overseas1) """ May we have the url where we can see this application in action ? I know some crackers that would be really pleased to mess with your production database... -- bruno desthuilliers python -c "print '@&

Re: Nested Looping SQL Querys

2006-09-20 Thread Bruno Desthuilliers
Fuzzydave wrote: > I am back developing futher our Python/CGI based web application run by > a Postgres DB > and as per usual I am having some issues. It Involves a lot of Legacy > code. s/Legacy/Norwegian Blue/ -- bruno desthuilliers python -c "print '@'.join(

Re: new string method in 2.5 (partition)

2006-09-20 Thread Bruno Desthuilliers
John Salerno a écrit : > Bruno Desthuilliers wrote: > >> Err... is it me being dumb, or is it a perfect use case for str.split ? > > > Hmm, I suppose you could get nearly the same functionality as using > split(':', 1), but with partition you also get the se

Re: Can I inherit member variables?

2006-09-21 Thread Bruno Desthuilliers
Gabriel Genellina wrote: (snip) > When you construct an object instance, it is of a certain type from that > precise moment, and you can't change that afterwards. Err... Actually, in Python, you can. It's even a no-brainer. (snip) -- bruno desthuilliers python -c "print

Re: Can I inherit member variables?

2006-09-21 Thread Bruno Desthuilliers
init__(self, world) # 'override' World.dothat: def dothat(self, bar): bar = bar * 3 return self.world.dothat(bar) # automagically delegate other stuff: def __getattr__(self, name): return getattr(self.world, name) HTH -- bruno desthuilliers python -c "print &

Re: How to return an "not string' error in function?

2006-09-21 Thread Bruno Desthuilliers
ced', 'f', 'aazaz'] >>> "ab-eced-ff-aazaz".split('-') ['ab', 'eced', 'ff', 'aazaz'] >>> -- 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: Does WSGI offer anything for web *beginner*?

2006-09-21 Thread Bruno Desthuilliers
y all the gory details of HTTP response headers. And most also offer a data access layer over a RDBMS or an OODBMS. IOW, wsgi will not saves you from learning to use a specific web framework. Nor will it saves you from learning *at least* the HTTP protocol, and most probably html, css, Javascript etc.

Re: How to return an "not string' error in function?

2006-09-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: (please, *stop* top-posting - corrected) > Bruno Desthuilliers wrote: >> >> [EMAIL PROTECTED] wrote: >> (OT : please dont top-post) >> >>> What I tried to do is to write a string.split() module, >> So don't waste time: >

Re: Don't use regular expressions to "validate" email addresses (was: Ineed some help with a regexp please)

2006-09-22 Thread Bruno Desthuilliers
ess. Else, it may or not be a valid email address - and then the only reliable way to know is to send a mail to that address. > and > possibly belongs to the user... How do you intend to check this ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for

Re: Can I inherit member variables?

2006-09-22 Thread Bruno Desthuilliers
Gabriel Genellina wrote: > At Thursday 21/9/2006 09:14, Bruno Desthuilliers wrote: > >> > When you construct an object instance, it is of a certain type from >> that >> > precise moment, and you can't change that afterwards. >> >> Err... Actua

Re: Looking for opinions

2006-09-23 Thread Bruno Desthuilliers
crystalattice a écrit : > I've been working on a game for several months but now I'm thinking I > may be going about it the wrong way. It's an online RPG designed to > recreate a pen & paper session, kind of like the OpenRPG project. > > Originally I planned on doing something like OpenRPG with a

Re: returning None instead of value: how to fix?

2006-09-23 Thread Bruno Desthuilliers
sam a écrit : > i am starting to experiment with recursion, and decided to write a > fairly trivial little program which took a float as input, then called > a function to halve it recursively until it was less than 1: And forgot to return the result from the recursive call, I guess ?-) -- http:/

Re: returning None instead of value: how to fix?

2006-09-23 Thread Bruno Desthuilliers
Neil Cerutti a écrit : (snip) > It's not out of the kindness of our hearts that we help. Heck, I > don't know what it is. Probably I just like reading my own drivel > on the internet and occassionally helping others is a good > excuse. Lol !-) +1 OTQOTW -- http://mail.python.org/mailman/listinf

Re: something for itertools

2006-09-23 Thread Bruno Desthuilliers
George Sakkis a écrit : > Daniel Nogradi wrote: > >>In a recent thread, >>http://mail.python.org/pipermail/python-list/2006-September/361512.html, >>a couple of very useful and enlightening itertools examples were given >>and was wondering if my problem also can be solved in an elegant way >>by it

Re: Looking for opinions

2006-09-25 Thread Bruno Desthuilliers
crystalattice wrote: > Bruno Desthuilliers wrote: >> I have few experience with RPG softwares, but if your "domain" logic si >> anything more than trivially complex, it's always better to keep it as >> decoupled as possible from the user interface (unless of c

Re: PyOpenGL pour python 2.5 ???

2006-09-25 Thread Bruno Desthuilliers
Sébastien Ramage wrote: > Bonjour à tous, Hi Sébastien. Wrong newsgroup, I'm afraid - either repost here in english, or post to fr.comp.lang.python... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.&

Re: does anybody earn a living programming in python?

2006-09-26 Thread Bruno Desthuilliers
walterbyrd wrote: > If so, I doubt there are many. We're at least two here... > I wonder why that is? > I wonder why you have such an a priori ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) fo

Re: Splitting device addresses into parts

2006-09-26 Thread Bruno Desthuilliers
them ... devices = ["PCI:2:3.0", "PCI:3.4:0"] for d in device: nums = tuple(map(int, d.split(':')[1:])) print "for ", d, " : ", nums -- 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: iterator question

2006-09-26 Thread Bruno Desthuilliers
Neal Becker a écrit : > Any suggestions for transforming the sequence: > > [1, 2, 3, 4...] > Where 1,2,3.. are it the ith item in an arbitrary sequence > > into a succession of tuples: > > [(1, 2), (3, 4)...] > > In other words, given a seq and an integer that specifies the size of tuple > to r

Re: Splitting device addresses into parts

2006-09-26 Thread Bruno Desthuilliers
Fabian Steiner a écrit : > Bruno Desthuilliers wrote: > >>Fabian Steiner wrote: >> >>>I often have to deal with strings like "PCI:2:3.0" or "PCI:3.4:0" and >>>need the single numbers as tuple (2, 3, 0) or (3, 4, 0). Is there any >>>

Re: a different question: can you earn a living with *just* python?

2006-09-26 Thread Bruno Desthuilliers
John Salerno a écrit : > It's a nice thought that a person can earn a living programming with > Python, which is fun enough to use just for its own sake. But for > someone like me (i.e. no programming experience) it's always a little > disheartening to see that most (if not all) job descriptions

Re: for: else: - any practical uses for the else clause?

2006-09-26 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > A very old thread: > http://groups.google.com/group/comp.lang.python/browse_frm/thread/2c5022e2b7f05525/1542d2041257c47e?lnk=gst&q=for+else&rnum=9#1542d2041257c47e > > discusses the optional "else:" clause of the for statement. > > I'm wondering if anyone has ever fo

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
example.py, and I'd like to incorporate it > **into** part of an HTML page with nice syntax highlighting and all the > shebang. Is there an easy way to do so? I suppose this has more to do with the course presentation than with it's content !-) However, Trac's wiki is probably a go

Re: windev vs python SOS

2006-09-28 Thread Bruno Desthuilliers
ce). FWIW, you may want to post this on fclpy too - there are some "hard-core" Windows developpers there... You can also point your boss to IronPython - if MS puts some money on it, it can't be a bad tool, isn't it ?-) -- 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: windev vs python SOS

2006-09-28 Thread Bruno Desthuilliers
John Henry wrote: > I don't know what windev is A french (highly proprietary) so-called "CASE-Tool" with a so-called "5th generation language" (lol) that is mostly a dumbed-down mix of basic and pascal. It's so bad that it makes you regret VB6. -- bruno desthu

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
urn [a,b] > > should be: > return [a].extend(b) A Lisp cons is made of a reference to it's content and a reference to the rest of the list, so cons = lambda a, b : [a, b] seems the most straightforward translation. >> def car(structure) >>return structure[

Re: remove the last character or the newline character?

2006-09-28 Thread Bruno Desthuilliers
gain, you cannot *remove* anything from a string - you can just have a modified copy copy of the string. (NB : answer is just above : use str.strip()) HTH -- 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: startswith() and endswith() for re's would be more intuitive

2006-09-28 Thread Bruno Desthuilliers
e.compile('blah').atstartof(string) > re.compile('blah').atendof(string) What's wrong with: re.search(r'^blah', somestring) re.search(r'blah$', somestring) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Bruno Desthuilliers
Brendon Towle wrote: > On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote: > >> From: Bruno Desthuilliers <[EMAIL PROTECTED]> >> >> Brendon Towle wrote: >>> Some of your Lisp translations are subtly off... >> >> Seems correct to me. Lisp l

Re: best way to get data into a new instance?

2006-09-28 Thread Bruno Desthuilliers
= kw.get('titles', []) self.birthdate = kw.get(birthdate, None) # etc > Does a question like this depend on how the class will be used? I don't think it would make sens to design anything without any hint about how it's supposed to be used. My 2 cents -- bruno des

Re: a different question: can you earn a living with *just* python?

2006-09-28 Thread Bruno Desthuilliers
Roy Smith a écrit : > In article <[EMAIL PROTECTED]>, > "Carl J. Van Arsdall" <[EMAIL PROTECTED]> wrote: > > >>>Things like decorators and metaclasses certainly add power, but they add >>>complexity too. It's no longer a simple language. >>> >> >>Well, I think a simple language is a language

Re: how do you know if open failed?

2006-09-28 Thread Bruno Desthuilliers
tobiah a écrit : > SpreadTooThin wrote: > >> f = open('myfile.bin', 'rb') >> >> How do I know if there was an error opening my file? >> > try: > open('noexist') > except: > print "Didn't open" > Should be: try: f = open('noexists') except IOError, e: print >> sys.stderr, "

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-29 Thread Bruno Desthuilliers
close my eyes Well... Not quite Common Lisp yet, but : http://www.biostat.wisc.edu/~annis/creations/PyLisp/ -- 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: Pysqlite tables in RAM

2006-09-29 Thread Bruno Desthuilliers
is. If it then happens that SQLite is the bottleneck, try switching to a real RDBMS like PostgreSQL. Remember the 3 golden rules about optimisation: 1/ don't optimize 2/ don't optimize 3/ for the experts only: don't optimize My 2 cents... -- bruno desthuilliers "Premature

Re: windev vs python SOS

2006-09-29 Thread Bruno Desthuilliers
or the programmer. NB : transmitted to [EMAIL PROTECTED] who will appreciate if OT commercial adds are welcomes here. > -- > PatBiker > -- 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: windev vs python SOS

2006-09-29 Thread Bruno Desthuilliers
e this crap do something useful. Heck, compared to PC-Soft, one could find that Microsoft's marketing strategy is based on delivering smart, usable, cleanly debugged products and being helpful to users... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

Re: How to iterate through a sequence, grabbing subsequences?

2006-09-29 Thread Bruno Desthuilliers
y(s, chunksize): f = StringIO.StringIO(long_string) chunk = f.read(chunksize) while chunk: yield chunk chunk = f.read(chunksize) f.close() Now I'm sure someone will come up with a solution that's both far better and much more obvious (at least if you're Dutch ) -- bruno

Re: windev vs python SOS

2006-09-29 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Hi, > > Bruno Desthuilliers a écrit : >> I've never met a programmer that "loved" Windev. > > I have met some here (I'm the guy with a mustache-just kidding but > actually I was there). > > http://www.pcsoft.f

Re: windev vs python SOS

2006-10-02 Thread Bruno Desthuilliers
ml > http://www.pcsoft.fr/pcsoft/120pages/index.html "Facts" ? Lol ! It's about as factual as the existence of Saddam Hussein's mass destruction weapons. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.

Re: preemptive OOP?

2006-10-02 Thread Bruno Desthuilliers
de (which can boil down to a single assignement), but about the unnecessary level of indirection (which, as someone stated, is the one and only problem that cannot be solved by adding a level of indirection !-). -- 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: "Wiki in 10 minutes"

2006-10-02 Thread Bruno Desthuilliers
be appreciated. Could it be that one ? http://adminspotting.net/building-web-pages-with-python/ -- 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: strange append

2006-10-02 Thread Bruno Desthuilliers
ery nice which is the interactive python shell. This lets you try code snippets and see by yourself how it really works : [EMAIL PROTECTED] ~ $ python Python 2.4.3 (#1, Sep 29 2006, 20:26:46) [GCC 4.1.1 (Gentoo 4.1.1-r1)] on linux2 Type "help", "copyright", "credits"

Re: [OT] windev vs python SOS

2006-10-02 Thread Bruno Desthuilliers
Fredrik Lundh wrote: > Bruno Desthuilliers wrote: > >> Amanda wrote: >> (snip) >>> I am always amazed when I meet fanatics!! >> I'm always amazed when I meet PC-Soft's salespersons... > > isn't there some non-python forum where you can sort

Re: What value should be passed to make a function use the default argument value?

2006-10-03 Thread Bruno Desthuilliers
LaundroMat a écrit : > Suppose I have this function: > > def f(var=1): > return var*2 > > What value do I have to pass to f() if I want it to evaluate var to 1? > > I know that f() will return 2, but what if I absolutely want to pass a > value to f()? "None" doesn't seem to work.. Have you trie

Re: was python implemented as a object oriented langage at the beginning ?

2006-10-04 Thread Bruno Desthuilliers
has wrote: > Python's type/class > distinction Which "type/class" distinction ? -- 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: Overwrite only one function with property()

2006-11-19 Thread Bruno Desthuilliers
Kai Kuehne a écrit : > Hi list! > It is possible to overwrite only one function with the property-function? property is not function, it's a class. And it doesn't "overwrite" anything. > x = property(getx, setx, delx, 'doc') > > I just want to overwrite setx, but when I set the others to None, >

Re: basic python questions

2006-11-19 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : > [EMAIL PROTECTED] schrieb: > >> I have taken the coments and think I have implemented most. My only > > > Unfortunately, no. > >> question is how to use the enumerator. Here is what I did, I have tried >> a couple of things but was unable to figure out how to get th

Re: Python v PHP for web, and restarting Apache?

2006-11-19 Thread Bruno Desthuilliers
walterbyrd a écrit : > Fredrik Lundh wrote: > > >>modularity, modularity, and modularity. >> > > > Can't PHP be made to be just as modular? PHP has no notion of modules. > As a matter of popular practise, I suppose that is not done. I would > think that it could be. Certainly not the way Pyt

Re: Trying to understand Python objects

2006-11-22 Thread Bruno Desthuilliers
body (ie, outside methods) are attached to the class object itself (and then shared by all instances of the class), not to instances themselves. Instance attributes initialisation is usually done in the __init__(self, ...) method. HTH -- 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: Python visual IDE

2006-11-22 Thread Bruno Desthuilliers
productive with a good code editor, the command line, and a few external tools when needed. My 2 cents... -- 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: Method argument names

2006-11-22 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Hi > > Having a method: > > def method(self,x,y): > > is it possible to discover, from outside the method, that the methods > arguments are ['self', 'x', 'y']? import inspect help(inspect.getargspec) HTH -- brun

<    3   4   5   6   7   8   9   10   11   12   >