[ActivePython 2.5.1.1] Why does Python not return first line?

2009-03-15 Thread Gilles Ganault
Hello I'm stuck at why Python doesn't return the first line in this simple regex: === response = "Address :\r\t\t\r\t\t\t3 Abbey Road, St Johns Wood \r\t\t\tLondon, NW8 9AY\t\t" re_address = re.compile('Address :.+?(.+?)',re.I | re.S | re.M) address = re_address.search(response) if addr

Re: [ActivePython 2.5.1.1] Why does Python not return first line?

2009-03-15 Thread Gilles Ganault
On Mon, 16 Mar 2009 01:14:00 +0100, Gilles Ganault wrote: >I'm stuck at why Python doesn't return the first line in this simple >regex Found it: Python does extract the token, but displaying it requires removing hidden chars: = response = "Address :\r\t\t\r\t\t\t3 Abbey Road, St Johns Wood \

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

2009-03-15 Thread John Yeung
On Mar 15, 6:25 pm, John Machin wrote: > A couple of issues here: > > (1) The number of days in a month is not a constant, so "a > mathematician's sense of logic" is quite irrelevant. It's relevant in the sense that some commenters on this thread seem to want to apply some semblance of mathematic

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

2009-03-15 Thread John Yeung
On Mar 15, 7:26 pm, Chris Rebert wrote: > [...] the point is that there are likewise reasonable usecases > for the other behaviors too and one should refuse to guess in > the face of ambiguity; the std lib has, merely by default in > this case, taken this to the extreme of not implementing any > o

Re: [ActivePython 2.5.1.1] Why does Python not return first line?

2009-03-15 Thread Benjamin Kaplan
On Sun, Mar 15, 2009 at 8:14 PM, Gilles Ganault wrote: > Hello > > I'm stuck at why Python doesn't return the first line in this simple > regex: > > === > response = "Address :\r\t\t\r\t\t\t3 Abbey Road, > St Johns Wood \r\t\t\tLondon, NW8 9AY\t\t" > > re_address = re.compile('Address > :

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

2009-03-15 Thread Tim Rowe
2009/3/14 Hendrik van Rooyen : > No account seems to be taken of the fact that the locale approach > is a global one that forces uniformity on everything done on a PC > or by a user. Not so. Under .NET, for instance, the global settings will give you a default CultureInfo class, but you can creat

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

2009-03-15 Thread Rhodri James
On Sun, 15 Mar 2009 19:00:43 -, MRAB wrote: 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:finan

Re: Style question - defining immutable class data members

2009-03-15 Thread R. David Murray
John Posner wrote: > Summary: I no longer suspect that "Python is broken". I *do* think that > there's a situation that is potentially quite confusing: > > * In the statement "self.x = self.x + 1", the two "self.x" names can > sometimes refer to different objects. But this is fundamental to Py

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

2009-03-15 Thread MRAB
Rhodri James wrote: On Sun, 15 Mar 2009 19:00:43 -, MRAB wrote: 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 nu

Re: Style question - defining immutable class data members

2009-03-15 Thread John Posner
Earlier, I said: > I'll look into what the standard Python doc set says on this > matter. > RTFM, in section "Augmented assignment statements" of python301.chm: --- For targets which are attribute references, the initial value is retrieved with a getattr() and the result is assigned with a se

Re: Style question - defining immutable class data members

2009-03-15 Thread Rhodri James
On Sun, 15 Mar 2009 23:26:04 -, Aaron Brady wrote: 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 WH

Re: Integer arithmetic in hardware descriptions

2009-03-15 Thread JanC
bearophileh...@lycos.com wrote: > Some C# designers come from Pascal (where overflow is considered an > important thing), and they have added to dotnet ways to find when an > overflow occurs, globally in a program, locally in a piece of code, or > even in a single part of an expression. This is mu

Re: PyPy Progress (and Psyco)

2009-03-15 Thread JanC
andrew cooke wrote: > 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 do

Re: Style question - defining immutable class data members

2009-03-15 Thread Tim Wintle
On Sun, 2009-03-15 at 10:39 -0700, 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 ... > Is there a beneficial effect of silently creating the instance attribute, > which outweighs the

Re: Style question - defining immutable class data members

2009-03-15 Thread Tim Wintle
On Mon, 2009-03-16 at 04:02 +, Tim Wintle wrote: > On Sun, 2009-03-15 at 10:39 -0700, John Posner wrote: Doh, reply out of thread there - I meant to reply to Rhodi's comment further down. > Is there any actual advantage to self.attribute picking up > Class.attribute instead of raising a NameEr

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

2009-03-15 Thread Aahz
In article , Roy Smith wrote: >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 Febr

Re: Why does Python not return first line?

2009-03-15 Thread John Machin
On Mar 16, 11:25 am, Gilles Ganault wrote: > On Mon, 16 Mar 2009 01:14:00 +0100, Gilles Ganault > wrote: > > >I'm stuck at why Python doesn't return the first line in this simple > >regex > > Found it: Python does extract the token, but displaying it requires > removing hidden chars: > > = >

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
i did this because this will read colors into a nested variable How would i make this work the way you suggest? I already have it working now :) Not able to set to dict value with setattr, how to do this too(sorry if off subject)? I can set it like this: for i in self.opt['p

Re: how to repeat function definitions less

2009-03-15 Thread alex goretoy
what is I just set "colors": self.opt['arg_opts_options']['imp_colors'] then they are both pointing to the same place, correct? -Alex Goretoy http://www.goretoy.com On Sun, Mar 15, 2009 at 11:16 PM, alex goretoy wrote: > i did this because this will read colors into a nested variable > > How

setattr() on "object" instance

2009-03-15 Thread Sean DiZazzo
Why is it that you can setattr() on an instance of a class that inherits from "object", but you can't on an instance of "object" itself? >>> o = object() >>> setattr(o, "x", 1000) Traceback (most recent call last): File "", line 1, in AttributeError: 'object' object has no attribute 'x' >>> cl

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

2009-03-15 Thread John Machin
On Mar 16, 3:08 pm, a...@pythoncraft.com (Aahz) wrote: > In article , > Roy Smith   wrote: > > >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

Re: multiprocessing.sharedctypes and built-in locks

2009-03-15 Thread Ahmad Syukri b
On Mar 15, 6:19 am, Aaron Brady wrote: > > Your code hung on my machine.  The call to 'main()' should be in an > 'if __name__' block: > > if __name__== '__main__': >     main() > > Is it possible you are just seeing the effects of the non-atomic > '__iadd__' operation?  That is, the value is read,

Re: Integer arithmetic in hardware descriptions

2009-03-15 Thread bearophileHUGS
JanC: > In most "modern" Pascal dialects the overflow checks can be (locally) > enabled or disabled with compiler directives in the source code, I think that was possible in somewhat older versions of Pascal-like languages too (like old Delphi versions, and maybe TurboPascals too). >so the "spee

Re: PyWin32 for Python 3.x

2009-03-15 Thread John Nagle
Tim Golden wrote: 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/Me

Re: Style question - defining immutable class data members

2009-03-15 Thread Gary Herron
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 IDLE 2.6.1: inst = Cls() Cls.

Problem while copying a file from a remote filer

2009-03-15 Thread venutaurus...@gmail.com
Hi all, I have to write an application which does a move and copy of a file from a remote machine to the local machine. I tried something like: file = ur"venuwin2008\\C\\4Folders\\Folder02\\Folder002\ \TextFile_06.txt" dest = "C:\\test" shutil.copy(file,dest) But it is throwing an error

Re: setattr() on "object" instance

2009-03-15 Thread Ahmad Syukri b
On Mar 16, 1:21 pm, Sean DiZazzo wrote: > Why is it that you can setattr() on an instance of a class that > inherits from "object", but you can't on an instance of "object" > itself? > > >>> o = object() > >>> setattr(o, "x", 1000) > > Traceback (most recent call last): >   File "", line 1, in >

Re: PyWin32 for Python 3.x

2009-03-15 Thread John Machin
On Mar 16, 7:27 am, Tim Golden wrote: [snip] > people take to categorise their packages appropriately. It > could well be the case that a number of packages will work > in Python 3.x without modification but their entry probably > won't reflect that unless their maintainer's gone to the > troubl

Re: Problem while copying a file from a remote filer

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 10:24 PM, venutaurus...@gmail.com wrote: > Hi all, >      I have to write an application which does a move and copy of a > file from a remote machine to the local machine. I tried something > like: > > file = ur"venuwin2008\\C\\4Folders\\Folder02\\Folder002\ > \TextFile

Re: VMware and pywin32 error...

2009-03-15 Thread dash
Joshua Kugler schrieb: dot wrote: has anyone experience with installing Python and pywin32 to Windows XP Pro running in a VMware environment? At the end of installing pywin32 I get following error: Traceback (most recent

Re: VMware and pywin32 error...

2009-03-15 Thread dash
Joshua Kugler schrieb: dot wrote: has anyone experience with installing Python and pywin32 to Windows XP Pro running in a VMware environment? At the end of installing pywin32 I get following error: Traceback (most recent

Re: VMware and pywin32 error...

2009-03-15 Thread dash
Joshua Kugler schrieb: dot wrote: has anyone experience with installing Python and pywin32 to Windows XP Pro running in a VMware environment? At the end of installing pywin32 I get following error: Traceback (most recent

Re: Style question - defining immutable class data members

2009-03-15 Thread Gary Herron
John Posner wrote: 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 inst

<    1   2