Re: suggestion for python function calling

2009-03-15 Thread alex goretoy
basically import os def quacks(self,value): return (1,0)[value] _aduck="~/goose" duck = if os.path.exists quacks str(_aduck) duck()() or does this get in the way with some other pre-existing syntax interpretation implementations? -Alex Goretoy http://www.goretoy.com On Sun, Mar 15, 2009 a

Re: Subprocess module: running an interactive shell

2009-03-15 Thread Joe Tyson
On 2009-03-14 20:10:29 -0400, Karthik Gurusamy said: On Mar 14, 3:03 am, Roman Medina-Heigl Hernandez wrote: Karthik Gurusamy escribió: On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez wrote: Hi, I'm experimenting with Python and I need a little help with this. What I'd like is to

Is this type of forward referencing possible?

2009-03-15 Thread Kooks are people too
If I try this: class A: someType = B class B: anotherType = A I get: : name 'B' is not defined args = ("name 'B' is not defined",) message = "name 'B' is not defined" Presumably because I'm instantiating an instance of a type object (B) that doesn't exist yet. Is there any

Re: suggestion for python function calling

2009-03-15 Thread alex goretoy
actually it would be more like import os def quacks(value): return "%s/%s%s"% (os.environ["PWD"],os.path.dirname(__file__),value) _aduck="goose" duck = if is not os.path.exists quacks str(_aduck) to perform the calls duck()() this would only with with functions that return something though,

Re: how to repeat function definitions less

2009-03-15 Thread Michele Simionato
On Sun, Mar 15, 2009 at 7:33 AM, alex goretoy wrote: > sweet, I've been wondering how those work. I've read some stuff about them > and still doesn't make sense to me. Why would I want to use itPlease > explain, thank you Well, the typical usage for class decorators is to dynamically add meth

Re: suggestion for python function calling

2009-03-15 Thread alex goretoy
or use . (dot) where variable and () (parans) where function duck()(). or duck.().() or for long sentences duck.[].()()... using dot seperator or double dot separator for application where its currently not being used, but for syntax errors -Alex Goretoy http://www.goretoy.com On Sun, Mar 15,

Re: suggestion for python function calling

2009-03-15 Thread alex goretoy
maybe this is like decorators -Alex Goretoy http://www.goretoy.com On Sun, Mar 15, 2009 at 2:20 AM, alex goretoy wrote: > or use . (dot) where variable and () (parans) where function > > duck()(). > or > duck.().() > or > for long sentences > duck.[].()()... > > using dot seperator or double do

Re: Is this type of forward referencing possible?

2009-03-15 Thread Lawrence D'Oliveiro
In message , Kooks are people too wrote: > If I try this: > > class A: > someType = B > > class B: > anotherType = A > > I get: > : name 'B' is not defined > args = ("name 'B' is not defined",) > message = "name 'B' is not defined" Try class A: pass class

Re: finally successful in ods with python, just one help needed.

2009-03-15 Thread John Machin
On Mar 15, 4:46 am, David Bolen wrote: [snip] > Note that it appears creating such a spreadsheet directly in Calc also > adds covered table cells for those cells beneath the spanned cell, but > Calc loads a file fine without those and still lets you later split > the merge and edit the underlyin

Re: ElementTree: How to return only unicode?

2009-03-15 Thread Stefan Behnel
Torsten Bronger wrote: > Hallöchen! und zurück! > Stefan Behnel writes: > >> Torsten Bronger wrote: >> >>> [...] >>> >>> My problem is that if there is only ASCII, these methods return >>> ordinary strings instead of unicode. So sometimes I get str, >>> sometimes I get unicode. Can one change

Re: ElementTree: How to return only unicode?

2009-03-15 Thread Torsten Bronger
Hallöchen! Stefan Behnel writes: > Torsten Bronger wrote: > >> Stefan Behnel writes: >> >>> Torsten Bronger wrote: >>> [...] My problem is that if there is only ASCII, these methods return ordinary strings instead of unicode. So sometimes I get str, sometimes I get unic

Re: String to sequence

2009-03-15 Thread mattia
Il Sat, 14 Mar 2009 15:30:29 -0500, Tim Chase ha scritto: >> How can I convert the following string: >> >> 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', >> EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' >> >> into this sequence: >> >> ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', >> EGC','SXF','BZR','BIQ'

Re: Is this type of forward referencing possible?

2009-03-15 Thread andrew cooke
someone else has answered this, but an extra trick that is sometimes useful is that while there is no forward referencing you can often exploit late binding and evaluation order. your example will not work because code at the class level is evaluated when the module is loaded. but code at the me

Re: List the moduels of a package

2009-03-15 Thread Lie Ryan
mattia wrote: Hi all, how can I list the modules provided by a package? >>> import package >>> help(package) -- http://mail.python.org/mailman/listinfo/python-list

Re: Integer arithmetic in hardware descriptions

2009-03-15 Thread bearophileHUGS
John Nagle: >I gave up on this when C came in; the C crowd was so casual about integer >overflow that nobody cared about this level of correctness. Today, of course, >"buffer overflows" are a way of life.< Experience shows that integer overflows are a very common bug. One of the huge advantages

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
Gary Herron writes: > Gary Herron wrote: > No, you are still misinterpreting your results. But you can be forgiven > because this is quite a subtle point about Python's attribute access. > > Here's how it works: > > On access, self.count (or self.anything) attempts to find "count" in > the inst

PyPy Progress (and Psyco)

2009-03-15 Thread andrew cooke
This looks very promising - http://www.voidspace.org.uk/python/weblog/arch_d7_2009_03_14.shtml#e1063 I am really looking forwards to PyPy having a final release. I hope it happens. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question - defining immutable class data members

2009-03-15 Thread Rhodri James
On Sun, 15 Mar 2009 13:26:17 -, Matthew Woodcraft wrote: [snip Gary Herron's explanation of instance attribute lookup falling back to class attribute lookup] It seems clear to me that Maxim understood all this when he asked his original question (you need to understand this subtlety to k

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Hendrik van Rooyen
"Tim Rowe" wrote: 8< - > . If "Finance users and non-professional > programmers find the locale approach to be frustrating, arcane and > non-obvious" then by all means propose a way of making it simpler and > clearer, but no

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Hendrik van Rooyen
"Paul Rubin" wrote: > Paul Rubin writes: > >'%.3K' % 1234567 = 1.235K # K = 1000 > >'%.:3Ki' % 1234567 = 1.206K # K = 1024 > > I meant 1.235M and 1.177M, of course. I went "tilt" like a slot machine long before I noticed.

DataObjects

2009-03-15 Thread Paulo Cheque
Please, let me know if this library is useful or not: http://code.google.com/p/python-dataobjects/ []s Paulo -- http://mail.python.org/mailman/listinfo/python-list

List the moduels of a package

2009-03-15 Thread mattia
Hi all, how can I list the modules provided by a package? -- http://mail.python.org/mailman/listinfo/python-list

Re: Encoding/decoding: Still don't get it :-/

2009-03-15 Thread Johannes Bauer
Peter Otten schrieb: > encoding = sys.stdout.encoding or "ascii" > for row in rows: > id, address = row[:2] > print id, address.encode(encoding, "replace") > > Example: > u"ähnlich lölich üblich".encode("ascii", "replace") > '?hnlich l?lich ?blich' A very good tip, Peter - I've als

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread JanC
Raymond Hettinger wrote: > No doubt that you're skeptical of anything you didn't > already know ;-) I'm a CPA, was a 15 year division controller > for a Fortune 500 company, and an auditor for an international > accounting firm. Believe me when I say it is the norm in finance. > Besides, it seem

Re: tkinter: loading file before entering mainloop

2009-03-15 Thread Peter Billam
On 2009-03-14, Peter Otten <__pete...@web.de> wrote: > Well, I don't know where the ymid[...] values come from. If you can > guarantee that ymid[track_num] - ymid[track_num-1] > 50 at some point > you could reschedule loadFile() from within loadFile() and return > immediately as long as that condit

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
"Rhodri James" writes: > On Sun, 15 Mar 2009 13:26:17 -, Matthew Woodcraft >> It seems clear to me that Maxim understood all this when he asked his >> original question (you need to understand this subtlety to know why >> the trick he was asking about only works for immutable values). > > It

Re: Is this type of forward referencing possible?

2009-03-15 Thread Paul McGuire
On Mar 15, 6:33 am, "andrew cooke" wrote: > someone else has answered this, but an extra trick that is sometimes > useful is that while there is no forward referencing you can often exploit > late binding and evaluation order. > > your example will not work because code at the class level is evalu

Re: Is this type of forward referencing possible?

2009-03-15 Thread andrew cooke
Paul McGuire wrote: > On Mar 15, 6:33 am, "andrew cooke" wrote: >> someone else has answered this, but an extra trick that is sometimes >> useful is that while there is no forward referencing you can often >> exploit late binding and evaluation order. [...] > Not the same. The OP wanted someType

Re: PyPy Progress (and Psyco)

2009-03-15 Thread Gerhard Häring
andrew cooke wrote: This looks very promising - http://www.voidspace.org.uk/python/weblog/arch_d7_2009_03_14.shtml#e1063 I am really looking forwards to PyPy having a final release. I hope it happens. Me too. I doubt it, though. From an outside view, the project seems to lack focus. To me, i

Re: how to repeat function definitions less

2009-03-15 Thread MRAB
alex goretoy wrote: I would imagine that I could do this with a generator and setattr, but I am still learning how to do that kinda of codingmaybe if I had a dictionary like this and then loaded it d={ "site_name":["s","site",'sites','site_name','site_names'], "jar_name":["j","jar"

Is this type of forward referencing possible?

2009-03-15 Thread R. David Murray
Kooks are people too wrote: > If I try this: > > class A: > someType = B > > class B: > anotherType = A > > I get: > : name 'B' is not defined > args = ("name 'B' is not defined",) > message = "name 'B' is not defined" > > Presumably because I'm instantiating an instance o

Re: Is this type of forward referencing possible?

2009-03-15 Thread Miles
On Sun, Mar 15, 2009 at 11:33 AM, Paul McGuire wrote: > I'm guessing the class mapping is all part of an overall design, so I > would define all of these after creating A and B as empty classes: > > class A: pass > class B: pass > > A.someType = B > B.anotherType = A While this would work in the g

Re: Style question - defining immutable class data members

2009-03-15 Thread Rhodri James
On Sun, 15 Mar 2009 15:05:04 -, Matthew Woodcraft wrote: "Rhodri James" writes: On Sun, 15 Mar 2009 13:26:17 -, Matthew Woodcraft It seems clear to me that Maxim understood all this when he asked his original question (you need to understand this subtlety to know why the trick h

Re: Style question - defining immutable class data members

2009-03-15 Thread Bruno Desthuilliers
Maxim Khitrov a écrit : On Sat, Mar 14, 2009 at 2:07 PM, Gary Herron wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object): def __init__(self):

Re: Style question - defining immutable class data members

2009-03-15 Thread Aaron Brady
On Mar 15, 8:56 am, "Rhodri James" wrote: > On Sun, 15 Mar 2009 13:26:17 -, Matthew Woodcraft   > > wrote: > > [snip Gary Herron's explanation of instance attribute lookup > falling back to class attribute lookup] > > > It seems clear to me that Maxim understood all this when he asked his > >

How to add months to a date (datetime object)?

2009-03-15 Thread tinnews
I have a date in the form of a datetime object and I want to add (for example) three months to it. At the moment I can't see any very obvious way of doing this. I need something like:- myDate = datetime.date.today() inc = datetime.timedelta(months=3) myDate += inc but, of course, ti

Re: Style question - defining immutable class data members

2009-03-15 Thread M R A Barnett
Aaron Brady wrote: [snip] However, in my (opined) interpretation, 'list.append(...) is an in- place operation' is a factual error. In-place operations -also- rebind their 'argument' (FLOBW for lack of better words). 'append' is a by-side-effect operation. However colloquially it's mostly accur

Re: Style question - defining immutable class data members

2009-03-15 Thread John Posner
(My apologies if the thread has already covered this.) I believe I understand the WHAT in this situation, but I don't understand the WHY ... Given this class definition: class Cls(object): x = 345 ... I observe the following, using IDLE 2.6.1: >>> inst = Cls() >>> Cls.x is inst.x True

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 10:28 AM, wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >    myDate = datetime.date.today() >    inc = datetime.timed

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Vlastimil Brom
2009/3/15 : > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >    myDate = datetime.date.today() >    inc = datetime.timedelta(months=3) >    myDate +=

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it. At the moment I can't see any very > obvious way of doing this. I need something like:- > > myDate = date

Re: Style question - defining immutable class data members

2009-03-15 Thread Aaron Brady
On Mar 15, 12:39 pm, John Posner wrote: > (My apologies if the thread has already covered this.) I believe I understand > the WHAT in this situation, but I don't understand the WHY ... > > Given this class definition: > >   class Cls(object): >       x = 345 > > ... I observe the following, using

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
I will also actually need to nest it like so d={ "site_name":["s","site",' > > sites','site_name','site_names'], >"jar_name":["j","jar",'jars','jar_name','jar_names'], "options":{ "src_name":["ss","src","source"], "mod_name":['m',"mod",'mods',"module","modules"], } -Al

Re: How to add months to a date (datetime object)?

2009-03-15 Thread tinnews
Roy Smith wrote: > In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk > wrote: > > > I have a date in the form of a datetime object and I want to add (for > > example) three months to it. At the moment I can't see any very > > obvious way of doing this. I need something

Re: How to add months to a date (datetime object)?

2009-03-15 Thread tinnews
Chris Rebert wrote: > On Sun, Mar 15, 2009 at 10:28 AM, wrote: > > I have a date in the form of a datetime object and I want to add (for > > example) three months to it.  At the moment I can't see any very > > obvious way of doing this.  I need something like:- > > > >    myDate = datetime.date.

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
this means i have to check if d[i] is list or dict and iterate over properties -Alex Goretoy http://www.goretoy.com On Sun, Mar 15, 2009 at 1:03 PM, alex goretoy wrote: > I will also actually need to nest it like so > > d={ >"site_name":["s","site",' >> >> sites','site_name','site_names'],

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Andre Engels
On Sun, Mar 15, 2009 at 7:00 PM, wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >> > I have a date in the form of a datetime object and I want to add (for >> > example) three months to it.  At the moment I can't see any very >

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 11:00 AM, wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >> > I have a date in the form of a datetime object and I want to add (for >> > example) three months to it.  At the moment I can't see any very

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Ned Deily
In article <49bd42ac$0$512$bed64...@news.gradwell.net>, tinn...@isbd.co.uk wrote: > I was just hoping there was some calendar object in Python which could > do all that for me (I need the handling of 31st and February etc.) Whatever your requirement, chances are dateutil will be of help:

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread Rhodri James
On Sat, 14 Mar 2009 08:20:21 -, Hendrik van Rooyen wrote: "Tim Rowe" wrote: 8< - . If "Finance users and non-professional programmers find the locale approach to be frustrating, arcane and non-obvious" then by all

Re: PyWin32 for Python 3.x

2009-03-15 Thread John Nagle
Tim Golden wrote: John Nagle wrote: Any idea when PyWin32 will be available for Python 3.x? John Nagle Release 213 is out already: http://sourceforge.net/project/showfiles.php?group_id=78018&package_id=79063&release_id=661475 I think it's still considered a little bit

Re: PyWin32 for Python 3.x

2009-03-15 Thread Tim Golden
John Nagle wrote: That "wizard" won't even install unless Python 3.0 is "in the registry", which apparently means "installed as the default Python". No, it just means "installed somewhere". I have 6 different versions of Python installed on this box. The choice of which is "the default" is m

Re: Style question - defining immutable class data members

2009-03-15 Thread Rhodri James
On Sun, 15 Mar 2009 17:55:25 -, Aaron Brady wrote: On Mar 15, 12:39 pm, John Posner wrote: (My apologies if the thread has already covered this.) I believe I understand the WHAT in this situation, but I don't understand the WHY ... [snip] My question is ... WHY does the interprete

Re: PyPy Progress (and Psyco)

2009-03-15 Thread Fuzzyman
On Mar 15, 3:46 pm, Gerhard Häring wrote: > andrew cooke wrote: > > This looks very promising - > >http://www.voidspace.org.uk/python/weblog/arch_d7_2009_03_14.shtml#e1063 > > > I am really looking forwards to PyPy having a final release.  I hope it > > happens. > > Me too. I doubt it, though. Fro

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-15 Thread MRAB
Rhodri James wrote: [snip] Frankly, I'd much rather fix the locale system and extend the format syntax to override the default locale. Perhaps something like financial = Locale(group_sep=",", grouping=[3]) print("my number is {0:10n:financial}".format(1234567)) It's hard to think of a way

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Casey Webster
On Mar 15, 2:00 pm, tinn...@isbd.co.uk wrote: > No, it's perfectly possible applying simple logic.  My reminder > program manages it perfectly well.  I have, for example, two sets of > three monthly reminders. > >     One starts on Jan 19th and repeats three monthly, that means Jan >     19th, Apri

Re: Is this type of forward referencing possible?

2009-03-15 Thread Kooks are people too
On Mar 15, 9:22 am, Miles wrote: >(I > suspect the OP neglected to point out that A and B likely both inherit > from db.Model). > -Miles yes, I did neglect to state that A and B inherit from db.Model. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Yeung
On Mar 15, 3:10 pm, Casey Webster wrote: > The example you give does have fairly obvious logic. But how does it > handle Feb 28th, 2009 + 3 months?  To me, there are two "obvious" > answers: May 28th, 2009 or May 31st, 2009.  The question is intent; is > Feb 28th an arbitrary day of the month, or

ANN: OpenOpt 0.23 - free numerical optimization framework

2009-03-15 Thread dmitrey
Hi all, OpenOpt 0.23, a free numerical optimization framework (license: BSD) with some own solvers and connections to tens of 3rd party ones, has been released. Our new homepage: http://openopt.org Introduction to the framework: http://openopt.org/Foreword All release details are here: http://op

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
this is what I did to define all my color functions by color name, but I am still going to need a good solution for args #import functions by color name into current namespace > for color in self.colors.keys(): > setattr(self, color,lambda x,y=color,z="INFO": > self._he

Re: PyWin32 for Python 3.x

2009-03-15 Thread John Nagle
Tim Golden wrote: John Nagle wrote: That "wizard" won't even install unless Python 3.0 is "in the registry", which apparently means "installed as the default Python". No, it just means "installed somewhere". I have 6 different versions of Python installed on this box. The choice of which is

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article <49bd4252$0$512$bed64...@news.gradwell.net>, tinn...@isbd.co.uk wrote: > > Well, before you can "add three months" to something, you need to explain > > what that means. > [...] > No, it's perfectly possible applying simple logic. I didn't say it was not possible. I just said that

Re: PyWin32 for Python 3.x

2009-03-15 Thread Tim Golden
John Nagle wrote: Well, of some other packages I use: MySQLdb: "Python versions 2.3-2.5 are supported." Ref: http://sourceforge.net/projects/mysql-python M2Crypto: Latest version is for Python 2.6. Ref: http://chandlerproject.org/bin/view/Projects/MeTooCrypto Somebody

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article , Chris Rebert wrote: > Besides your behavior, one could equally well argue that a 31st repeat > on months without a 31st should just be dropped, or that it should > carry over onto the 1st of the next month (ignoring the complications > of February). Which behavior one needs is compl

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
Michele I tried your way but I dont seem to have a good grasp on the concept yet, will read up more for now I think I will try to make it work same way as colors only with decorator as def inside def instead of @, that doesn't make sense quite yet -Alex Goretoy http://www.goretoy.com On Sun, M

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article , Chris Rebert wrote: > Which makes some sense considering a month can range from 28-31 days, > which would make the delta oddly fuzzy. BTW, what date is "One month after August 10, 1752"? Extra points if you refuse the answer the question on the grounds that it's incompletely spe

Set overlapping

2009-03-15 Thread mattia
How can I determine the common values found in two differents sets and then assign this values? E.g. dayset = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] monthset = ["Jan", "Feb", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] this are the "fixed and standard" sets. Then I

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:30 PM, Roy Smith wrote: > In article , >  Chris Rebert wrote: > >> Which makes some sense considering a month can range from 28-31 days, >> which would make the delta oddly fuzzy. > > BTW, what date is "One month after August 10, 1752"?  Extra points if you > refuse the

Re: Set overlapping

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:41 PM, mattia wrote: > How can I determine the common values found in two differents sets and > then assign this values? > E.g. > dayset = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] > monthset = ["Jan", "Feb", "Apr", "May", "Jun", "Jul", "Aug", "Sep", > "Oct", "Nov

Re: PyPy Progress (and Psyco)

2009-03-15 Thread andrew cooke
Fuzzyman wrote: > On Mar 15, 3:46 pm, Gerhard Häring wrote: [...] >> Me too. I doubt it, though. From an outside view, the project seems to >> lack focus. To me, it looks like a research platform, and producing a >> successor to CPython seems to be just one out of a dozen projects. [...] > Well, I

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
this is the final result of the args i will be parsing for now d={ "site_name":["s","sn","site",'sites','site_name','site_names'], "jar_name":["j","jn","jar",'jars','jar_name','jar_names'], "file_name":["f","fn",'file','files','filename','filenames','file_name','fi

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
John Posner writes: > My question is ... WHY does the interpreter silently create the > instance attribute at this point, causing a "surprising decoupling" > from the class attribute? WHY doesn't the interpreter behave as it > would with a simple, non-instance variable: > > python > Python 2

Re: Style question - defining immutable class data members

2009-03-15 Thread Bruno Desthuilliers
Rhodri James a écrit : On Sun, 15 Mar 2009 17:55:25 -, Aaron Brady wrote: On Mar 15, 12:39 pm, John Posner wrote: (snip) Is there a beneficial effect of silently creating the instance attribute, which outweighs the detrimental effects: (1) inconsistency, (2) the "surprising" decoupli

Re: Style question - defining immutable class data members

2009-03-15 Thread Matthew Woodcraft
"Rhodri James" writes: > But do you, though? The only occasion I can think of that I'd want > the search to go past the instance is this "auto-initialisation", > and frankly I'd rather do that in an __init__ anyway. Perhaps > static methods or class methods work that way, I don't know how > the

Re: Style question - defining immutable class data members

2009-03-15 Thread Bruno Desthuilliers
John Posner a écrit : (My apologies if the thread has already covered this.) I believe I understand the WHAT in this situation, but I don't understand the WHY ... Given this class definition: class Cls(object): x = 345 ... I observe the following, using IDLE 2.6.1: inst = Cls() Cls.x is inst

Re: ipython / vs \ in readline on MS Windows (and ipython help grepper)

2009-03-15 Thread Tim Roberts
Jason Scheirer wrote: > >Cygwin does not magically change the platform you are on, the fact >that you are on Windows is hard-coded into the Python.exe binary. Look >for references to os.path.sep in IPython. Windows does let you use >forward slashes as path separators, though, so I am not entirely

Re: Style question - defining immutable class data members

2009-03-15 Thread R. David Murray
M R A Barnett wrote: > Aaron Brady wrote: > [snip] > > However, in my (opined) interpretation, 'list.append(...) is an in- > > place operation' is a factual error. In-place operations -also- > > rebind their 'argument' (FLOBW for lack of better words). 'append' is > > a by-side-effect operation.

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Roy Smith
In article , Chris Rebert wrote: > Not that that date could even be represented by most programs since > it's before 1970. Talk about recentism! :-) > I've always wondered how historians using computers deal with that > limitation... The unix time format it well known for being extremely limit

Re: How to add months to a date (datetime object)?

2009-03-15 Thread CM
On Mar 15, 1:28 pm, tinn...@isbd.co.uk wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >     myDate = datetime.date.today() >     inc = datetime.

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Machin
On Mar 16, 7:30 am, Roy Smith wrote: > In article , >  Chris Rebert wrote: > > > Which makes some sense considering a month can range from 28-31 days, > > which would make the delta oddly fuzzy. > > BTW, what date is "One month after August 10, 1752"?  Extra points if you > refuse the answer the

Re: How to add months to a date (datetime object)?

2009-03-15 Thread John Machin
On Mar 16, 6:55 am, John Yeung wrote: > On Mar 15, 3:10 pm, Casey Webster wrote: > > > The example you give does have fairly obvious logic. But how does it > > handle Feb 28th, 2009 + 3 months?  To me, there are two "obvious" > > answers: May 28th, 2009 or May 31st, 2009.  The question is intent;

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
ok now for the final result, i decided to split options out to a separate dict of lists, does this look right to every one, I currently have error somewhere else in my code so can't test this right now, Is this a good method to do this? or is there another option? self.opt={} self.

Re: PyWin32 for Python 3.x

2009-03-15 Thread Mark Hammond
On 16/03/2009 6:05 AM, John Nagle wrote: Tim Golden wrote: John Nagle wrote: Any idea when PyWin32 will be available for Python 3.x? John Nagle Release 213 is out already: http://sourceforge.net/project/showfiles.php?group_id=78018&package_id=79063&release_id=661475 I think it's still con

Re: Get pixel colors from images in Python 3

2009-03-15 Thread Tim Roberts
Cro wrote: > >As the title sais, i am trying to extract pixel colors from images, in >Python 3. >... >Can anyone suggest how to do that ? >The bigger problem is that i need to extract pixel colors for many >types of images : JPEG, PNG, BMP, GIF. For this, i might need >different codecs... I am not

Re: Style question - defining immutable class data members

2009-03-15 Thread John Posner
Matthew Woodcraft said: > I doubt it's because anyone particularly wanted this > behaviour; it just > falls out of the way '+=' is defined. > > At the point where 'inst.x += 1' is compiled, > Python doesn't know > whether 'inst.x' is going to turn out to be a class > attribute or an > instance a

Re: can error messages be improved or can they be overridden ?

2009-03-15 Thread Stef Mientki
thanks RDM, I finally had a case where I really needed it, so it tried, works perfect, except the marked lines should be indented 1 more. cheers, Stef rdmur...@bitdance.com wrote: "andrew cooke" wrote: rdmur...@bitdance.com wrote: [...] (You know, I really ought to revisit that routin

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Steve Holden
Roy Smith wrote: > In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk > wrote: > >> I have a date in the form of a datetime object and I want to add (for >> example) three months to it. At the moment I can't see any very >> obvious way of doing this. I need something lik

Correct URL encoding

2009-03-15 Thread mattia
I'm using urlopen in order to download some web pages. I've always to replace some characters that are in the url, so I've come up with: url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace (":", "%3A") There isn't a better way of doing this? -- http://mail.python.org/mailman/list

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:17 PM, Steve Holden wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >>> I have a date in the form of a datetime object and I want to add (for >>> example) three months to it.  At the moment I can't see a

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:21 PM, mattia wrote: > I'm using urlopen in order to download some web pages. I've always to > replace some characters that are in the url, so I've come up with: > url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace > (":", "%3A") > There isn't a better

Re: Style question - defining immutable class data members

2009-03-15 Thread Aaron Brady
On Mar 15, 1:50 pm, "Rhodri James" wrote: > On Sun, 15 Mar 2009 17:55:25 -, Aaron Brady   > wrote: > > > On Mar 15, 12:39 pm, John Posner wrote: > >> (My apologies if the thread has already covered this.) I believe I   > >> understand the WHAT in this situation, but I don't understand the WH

Re: can error messages be improved or can they be overridden ?

2009-03-15 Thread andrew cooke
rdmur...@bitdance.com wrote: > "andrew cooke" wrote: >> rdmur...@bitdance.com wrote: >> [...] >> > (You know, I really ought to revisit that routine and make it part >> > of my standard development toolbox.) >> >> please post it > > OK. I dug it up, cut out the stuff that was specific to the

[ANN] pxyser --- python xml serialization (beta release 0.1).

2009-03-15 Thread Daniel Molina Wegener
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 pxyser --- python xml serialization (beta release 0.1). pyxser is a C written extension that serializes/deserializes python objects in XML format. It uses a DTD to create a valid XML tree under UTF-8 encoding. the project web page is at: http://pr

Re: Correct URL encoding

2009-03-15 Thread Graham Breed
mattia wrote: I'm using urlopen in order to download some web pages. I've always to replace some characters that are in the url, so I've come up with: url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace (":", "%3A") There isn't a better way of doing this? Yeah, shame there's

Re: how to repeat function definitions less

2009-03-15 Thread MRAB
alex goretoy wrote: ok now for the final result, i decided to split options out to a separate dict of lists, does this look right to every one, I currently have error somewhere else in my code so can't test this right now, Is this a good method to do this? or is there another option? [snip]

is there an easy way to parse a nested list ?

2009-03-15 Thread Stef Mientki
hello, I need to parse a nested list, given as a string, like this line = " A [ B [ C+2 ] + 3 ] " ( I probably can do it with find, but I guess that's not the most elegant way, besides recusrion is not my strongest point) which should be parsed so I get an list from inner to outer side (d

Re: tkinter: loading file before entering mainloop

2009-03-15 Thread John McMonagle
Peter Billam wrote: > On 2009-03-14, Peter Otten <__pete...@web.de> wrote: >> Well, I don't know where the ymid[...] values come from. If you can >> guarantee that ymid[track_num] - ymid[track_num-1] > 50 at some point >> you could reschedule loadFile() from within loadFile() and return >> immediat

Re: Correct URL encoding

2009-03-15 Thread gervaz
On Mar 16, 12:38 am, Graham Breed wrote: > mattia wrote: > > I'm using urlopen in order to download some web pages. I've always to > > replace some characters that are in the url, so I've come up with: > > url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace > > (":", "%3A") > > T

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:54 PM, gervaz wrote: > On Mar 16, 12:38 am, Graham Breed wrote: >> mattia wrote: >> > I'm using urlopen in order to download some web pages. I've always to >> > replace some characters that are in the url, so I've come up with: >> > url.replace("|", "%7C").replace("/", "

Re: Correct URL encoding

2009-03-15 Thread mattia
Il Sun, 15 Mar 2009 17:05:16 -0700, Chris Rebert ha scritto: > On Sun, Mar 15, 2009 at 4:54 PM, gervaz wrote: >> On Mar 16, 12:38 am, Graham Breed wrote: >>> mattia wrote: >>> > I'm using urlopen in order to download some web pages. I've always >>> > to replace some characters that are in the ur

  1   2   >