Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
Steven D'Aprano wrote: > Because the cost isn't zero. Needing to write \\ in a string > literal when you want \ is a cost, I need to preface this entire post with the fact that I've already used ALL of the arguments that you've provided on my friend before I ever even came here with the topic, an

How to access a function's formal signature?

2009-08-11 Thread kj
In the standard Python interactive interpreter, the string printed by the help command when applied to a function includes the function's formal signature. E.g.: >>> def foo(bar, *baz, **frobozz): ... pass ... >>> help(foo) Help on function foo in module __main__: foo(bar, *baz, **frobozz)

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 10, 11:27 pm, Steven D'Aprano wrote: > On Mon, 10 Aug 2009 08:21:03 -0700, Douglas Alan wrote: > > But you're right, it's too late to change this now. > > Not really. There is a procedure for making non-backwards compatible > changes. If you care deeply enough about this, you could agitate

Re: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread Carl Banks
On Aug 11, 1:46 pm, Mark Lawrence wrote: > r wrote: > > Ah Ha! the docs are broken and i was right all along! Are the good > > folks at Python dev rolling a new installer as we speak, or we must > > wait for new version? > > As I pointed out a few minutes ago thicko, the new version has been > ava

Re: ElementTree - Howto access text within XML tag element...

2009-08-11 Thread Diez B. Roggisch
cmalmqui schrieb: On Aug 11, 9:51 am, "Diez B. Roggisch" wrote: cmalmqui schrieb: Hi, I am writing on a small XML parser and are currently stuck as I am not able to get the whole element name in ElementTree. Please see the below example where "print root[0][0]" returns "" Is there a way to get

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 11, 4:38 pm, Ethan Furman wrote: > Mind you, I'm not really vested in how Python *should* handle > backslashes one way or the other, but I am glad it has rules that it > follows for consitent results, and I don't have to break out a byte-code > editor to find out what's in my string litera

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread rurpy
On 08/11/2009 11:53 AM, Steven D'Aprano wrote: > On Tue, 11 Aug 2009 07:57:28 -0700, rurpy wrote: > >> On 08/11/2009 01:47 AM, Antoine Pitrou wrote: >>> r gmail.com> writes: On Aug 9, 11:02 pm, David Lyon wrote: > Since you're talking about documentation, which is a part of python, >

Re: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread Mark Lawrence
Carl Banks wrote: On Aug 11, 1:46 pm, Mark Lawrence wrote: r wrote: Ah Ha! the docs are broken and i was right all along! Are the good folks at Python dev rolling a new installer as we speak, or we must wait for new version? As I pointed out a few minutes ago thicko, the new version has been

create shell history with python

2009-08-11 Thread Joel Juvenal Rivera Rivera
I been thinking how to make a 'bash like history shell' in python, i don't know if with stdin and stdout i can accomplish this or do i need something like curses and stuff like that, anyway im start to figure this out. Does any body has try this? or have any interesting idea? --Joel Rivera -- h

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread Paul Boddie
On 11 Aug, 23:50, ru...@yahoo.com wrote: > > However, were the Python docs site to provide a wiki, along > with a mechanism to migrate suggestions developed on the wiki > into the docs, it might well be a viable (and easier because of > the wysiwyg effect) way of improving the docs.  As other have

Re: create shell history with python

2009-08-11 Thread Chris Rebert
On Tue, Aug 11, 2009 at 6:09 PM, Joel Juvenal Rivera Rivera wrote: > I been thinking how to make a 'bash like history shell' in python, > i don't know if with stdin and stdout i can accomplish this or do i > need something like curses and stuff like that, anyway im start to > figure this out. > Doe

Re: create shell history with python

2009-08-11 Thread Joel Juvenal Rivera Rivera
Wow i didn't know that module this solves everything... i guess python has a lot more batteries than i thought . Thank you Chris El mar, 11-08-2009 a las 18:15 -0400, Chris Rebert escribió: > On Tue, Aug 11, 2009 at 6:09 PM, Joel Juvenal Rivera > Rivera wrote: > > I been thinking how to make a '

Re: create shell history with python

2009-08-11 Thread Diez B. Roggisch
Joel Juvenal Rivera Rivera schrieb: I been thinking how to make a 'bash like history shell' in python, i don't know if with stdin and stdout i can accomplish this or do i need something like curses and stuff like that, anyway im start to figure this out. Does any body has try this? or have any in

Re: for key, value in dict.() - how to get? (which func)

2009-08-11 Thread Diez B. Roggisch
dmitrey schrieb: Yes, thank you, items() is the correct approach, on the other hand I have already get rid of the cycle. Most certainly items() is *not* the correct approach if you are concerned so much with performance, because items() first creates a list of key/value-pairs, where iteritems

Re: httplib incredibly slow :-(

2009-08-11 Thread Aahz
In article , Chris Withers wrote: > >Does anyone know of an alternative library for creating http requests >and getting their responses that's faster but hopefully has a similar >interface? PyCurl -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "...string ite

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread RJ
At 03:08 PM 8/11/2009, you wrote: I recommend going to the existing Wiki and looking at what there is already: http://wiki.python.org/moin/Documentation http://wiki.python.org/moin/CategoryDocumentation I also can't see how to get from http://wiki.python.org/moin/Documentation to http://wik

Re: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread r
...(Carl Banks doing what he does best) > > I'm mailing you to kindly request, again, that you please stop > > validating "r"'s disruptiveness by responding to him on > > comp.lang.python.  Thank you. Carl, You have no right to tell people when where and how they should speak to anyone. And how da

[OT] From: header - WAS: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread Chris Jones
Hello Paul, This is strictly OT, but when you get a chance, could you contact me off list at the above address? I need your help with the From: email address specified in your posts to the list. Thanks, CJ -- http://mail.python.org/mailman/listinfo/python-list

Re: httplib incredibly slow :-(

2009-08-11 Thread Chris Withers
Aahz wrote: In article , Chris Withers wrote: Does anyone know of an alternative library for creating http requests and getting their responses that's faster but hopefully has a similar interface? PyCurl This seems to be a wrapper around libcurl. Does it work on Windows? If so, where can

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread Carl Banks
On Aug 11, 3:08 pm, Paul Boddie wrote: > Certainly, the documentation situation with > Python is not ideal; otherwise, people would not be complaining about > it so frequently. I will not take an opinion on whether Python's documentation is ideal (more on why below) but I will opine that the conc

Re: How to access a function's formal signature?

2009-08-11 Thread Carl Banks
On Aug 11, 2:30 pm, kj wrote: > In the standard Python interactive interpreter, the string printed > by the help command when applied to a function includes the function's > formal signature.  E.g.: > > >>> def foo(bar, *baz, **frobozz): > > ...   pass > ...>>> help(foo) > > Help on function foo i

Re: Bug in format specification in Python 3?

2009-08-11 Thread AggieDan04
On Aug 11, 3:28 pm, Robert Dailey wrote: > Hello, > > According to the Python 3.1 documentation, I can have a format > specification like so: > > print( 'This is a hex number: {:#08x}'.format( 4 ) ) > > This will print: > > This is a hex number: 0x04 > > I notice that the '0x' portion is count

Re: Monkeypatching an object to become callable

2009-08-11 Thread Nikolaus Rath
Bruno Desthuilliers writes: > 7stud a écrit : > (snip) >> class Wrapper(object): >> def __init__(self, obj, func): >> self.obj = obj >> self.func = func >> >> def __call__(self, *args): >> return self.func(*args) >> >> def __getattr__(self, name): >> ret

Re: Windows 7 : any problems installing or running Python ?

2009-08-11 Thread Mark Hammond
On 9/08/2009 10:42 PM, Tim Roberts wrote: Dave WB3DWE wrote: Anybody tried it ? Is anything broken, ie is the whole shootin' match good to go ? I'm esp interested in WConio for 3.0/3.1 which I use heavily. I've been running the 32-bit builds of Python 2.5, PyWin32, and wxPython on Windows 7 6

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread exarkun
On 11 Aug, 11:37 pm, pavlovevide...@gmail.com wrote: I will not take an opinion on whether Python's documentation is ideal (more on why below) but I will opine that the conclusion doesn't follow from your premise. People's expectations of what documentation should be are too different, there wi

Re: Problem when fetching page using urllib2.urlopen

2009-08-11 Thread Diez B. Roggisch
dorzey wrote: > "geturl - this returns the real URL of the page fetched. This is > useful because urlopen (or the opener object used) may have followed a > redirect. The URL of the page fetched may not be the same as the URL > requested." from > http://www.voidspace.org.uk/python/articles/urllib2.

Re: Problem when fetching page using urllib2.urlopen

2009-08-11 Thread dorzey
On 10 Aug, 18:11, "Diez B. Roggisch" wrote: > dorzey wrote: > > "geturl - this returns the real URL of the page fetched. This is > > useful because urlopen (or the opener object used) may have followed a > > redirect. The URL of the page fetched may not be the same as the URL > > requested." from

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
I wrote: > But you're right, it's too late to change this now. P.S. But if it weren't too late, I think that your idea to have "\s" be the escape sequence for a backslash instead of "\\" might be a good one. |>ouglas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread rurpy
On Aug 11, 2:46 pm, Mark Lawrence wrote: > r wrote: > > Ah Ha! the docs are broken and i was right all along! Are the good > > folks at Python dev rolling a new installer as we speak, or we must > > wait for new version? > > As I pointed out a few minutes ago thicko, the new version has been > ava

hashability

2009-08-11 Thread James Stroud
Hello All, I wrote the function to test hashability of arbitrary objects. My reason is that the built-in python (2.5) hashing is too permissive for some uses. A symptom of this permissiveness comes from the ability to successfully hash() arbitrary objects: py> class C(object): pass ...

Re: Networked Broadcast Messaging

2009-08-11 Thread David Bolen
"squishywaf...@gmail.com" writes: > * Machines can come and go. Since messages are not directly sent to a > specific IP address from our Python script, the messages are simply > broadcasted to those who are there to listen. If nobody is subscribed > to the message type being sent, nothing happens

Re: Any built-in function for smallest positive floating point number?

2009-08-11 Thread Xavier Ho
On Wed, Aug 12, 2009 at 3:29 AM, Maria Liukis wrote: > Hello everybody, > Is somebody aware of built-in Python's function that would return > a value for smallest positive double precision floating point number > (analogous to 'realmin' in Matlab). Python has built-in sys.maxint but I > could not

Re: Any built-in function for smallest positive floating point number?

2009-08-11 Thread Xavier Ho
I got it to work with Python 2.6.2. >>> import struct >>> struct.unpack('d', struct.pack('Q', 1))[0] 4.9406564584124654e-324 Python 3.1 will print 5e-324, which is fair enough. Cheers, Xavier -- http://mail.python.org/mailman/listinfo/python-list

Re: hashability

2009-08-11 Thread Carl Banks
On Aug 11, 5:54 pm, James Stroud wrote: > Hello All, > > I wrote the function to test hashability of arbitrary objects. My reason > is that the built-in python (2.5) hashing is too permissive for some > uses. A symptom of this permissiveness comes from the ability to > successfully hash() arbitrar

Re: Any built-in function for smallest positive floating point number?

2009-08-11 Thread Xavier Ho
Actually, that was double precision. You asked for float precision. >>> struct.unpack('f', struct.pack('L', 1))[0] 1.4012984643248171e-45 which is the same as: >>> 2**-149 1.4012984643248171e-45 I think that's it. Sorry for posting to the list three times in a row. corrections welcome. -- http:

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread rurpy
On Aug 11, 4:08 pm, Paul Boddie wrote: > On 11 Aug, 23:50, ru...@yahoo.com wrote: > > However, were the Python docs site to provide a wiki, along > > with a mechanism to migrate suggestions developed on the wiki > > into the docs, it might well be a viable (and easier because of > > the wysiwyg ef

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread Paul Rubin
Carl Banks writes: > On> For example, kj (who started this mess of thread) complained that > pydoc didn't give exhaustive usage documentation. In contrast, I > think pydoc gives too much information. I would rather have only the > bare minimum; I don't want to pan through ten paragraphs just to

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 10:54 am, James Stroud wrote: > I wrote the function to test hashability of arbitrary objects. My reason > is that the built-in python (2.5) hashing is too permissive for some > uses. A symptom of this permissiveness comes from the ability to > successfully hash() arbitrary objects: A

Frustrated with scopes

2009-08-11 Thread andrew cooke
Is there a way to make this work (currently scope and join are undefined at runtime when the inner class attributes are defined): class _StreamFactory(object): @staticmethod def __call__(lines, source, join=''.join): class Line(object): __source = source

Re: Frustrated with scopes

2009-08-11 Thread andrew cooke
correction: "source" and "join" are undefined. Sorry, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: hashability

2009-08-11 Thread James Stroud
Carl Banks wrote: On Aug 11, 5:54 pm, James Stroud wrote: To prevent users of one of my libraries from falling into this and similar traps (which have potentially problematic consequences), Even so, I would consider whether some of your users might, like me, also find this terribly useful, a

Unsigned char array to an unsigned longlong array

2009-08-11 Thread Jus
Hello, I'm using Python 2.6.2. Is there a way to have an Array of unsigned longlong (C Type: unsigned longlong, Minimum size if bytes: 8) ? I found a page on the internet (http://mail.python.org/pipermail/patches/2005-April/017430.html

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 12:15 pm, James Stroud wrote: > I realize I left out my use. The intent of the function is to flag > objects that will make useful keys for a persistent dictionary. The > {C():4}[C()] example demonstrates why I want to avoid certain types of > keys--I don't want users to do things like

Re: adding multiple new values to the same key in a dictionary

2009-08-11 Thread Dave Angel
Krishna Pacifici wrote: Hi, I want to be able to add multiple new values to a key in a dictionary. I have tried the following: sec_dict_clean= {88: [87, 89, 78, 98], 58: [57, 59, 48, 68], 69: [79], 95: [94, 96, 85]} for i in range(len(sec_dict_clean.values())): for j in range(len(sec_dict_

Re: Need cleanup advice for multiline string

2009-08-11 Thread Dave Angel
Robert Dailey wrote: Hey guys. Being a C++ programmer, I like to keep variable definitions close to the location in which they will be used. This improves readability in many ways. However, when I have a multi-line string definition at function level scope, things get tricky because of the indent

Re: Is there any package implanation the following arithmetics?

2009-08-11 Thread William
What you want is: http://www.cgal.org/ I believe it has python bindings. Cheers, William From: Emile van Sebille To: python-list@python.org Sent: Tuesday, August 11, 2009 12:49:19 PM Subject: Re: Is there any package implanation the following arithmetics? On

releasing expy 0.1.1

2009-08-11 Thread Yingjie Lan
Hi all, This is to announce the release of expy 0.1.1 for those who are interested. Thanks a lot for the interest from this list. For more information, please see http://expy.sf.net/ Note: expy is an express way to extend Python. Why consider expy? Here are some good reasons: (I). WYSIWYG.

Re: getting a "simple" program to work

2009-08-11 Thread John Haggerty
just checking to see if there is any input that may have been misdirected to a spam filter. Would love to see some feedback if I may On Sun, Aug 9, 2009 at 6:42 PM, John Haggerty wrote: > ok so I know this is one of those "weird" requests but here me out. > So far I have an issue with a package

fileinput

2009-08-11 Thread naaman
I'm writing my first Python script and I want to use fileinput to open a file in r+ mode. Tried fileinput.input(sys.argv[1:],"r+") but that didn't work. ANy ideas? Need to find and overwrite a line in a file several times. I can do it using open and seek() etc. but was wondering if I can use filei

Re: getting a "simple" program to work

2009-08-11 Thread Chris Rebert
On Sun, Aug 9, 2009 at 8:42 PM, John Haggerty wrote: > ok so I know this is one of those "weird" requests but here me out. > So far I have an issue with a package for python called "libgmail" which is > basically a gmail interface for python to send messages remoetly. > Works ok except that the 'se

Re: getting a "simple" program to work

2009-08-11 Thread John Haggerty
On Tue, Aug 11, 2009 at 10:46 PM, Chris Rebert wrote: > On Sun, Aug 9, 2009 at 8:42 PM, John Haggerty wrote: > > ok so I know this is one of those "weird" requests but here me out. > > So far I have an issue with a package for python called "libgmail" which > is > > basically a gmail interface fo

Re: hashability

2009-08-11 Thread James Stroud
Asun Friere wrote: On Aug 12, 12:15 pm, James Stroud wrote: I realize I left out my use. The intent of the function is to flag objects that will make useful keys for a persistent dictionary. The {C():4}[C()] example demonstrates why I want to avoid certain types of keys--I don't want users to

Re: hashability

2009-08-11 Thread James Stroud
Asun Friere wrote: Perhaps the best solution would be for the unitiated to correct their misaprehensions Can you come give a class to my users? -- http://mail.python.org/mailman/listinfo/python-list

Re: hashability

2009-08-11 Thread Chris Rebert
2009/8/11 Asun Friere : > On Aug 12, 12:15 pm, James Stroud wrote: > >> I realize I left out my use. The intent of the function is to flag >> objects that will make useful keys for a persistent dictionary. The >> {C():4}[C()] example demonstrates why I want to avoid certain types of >> keys--I don

Re: Frustrated with scopes

2009-08-11 Thread James Stroud
andrew cooke wrote: Is there a way to make this work (currently scope and join are undefined at runtime when the inner class attributes are defined): class _StreamFactory(object): @staticmethod def __call__(lines, source, join=''.join): class Line(object): __source

Re: better way?

2009-08-11 Thread Pet
On 11 Aug., 22:19, "Rami Chowdhury" wrote: > Ah, my apologies, I must have been getting it confused with ON UPDATE   > [things]. Thanks for correcting me. > > On Tue, 11 Aug 2009 13:10:03 -0700, Matthew Woodcraft   > > wrote: > > "Rami Chowdhury" writes: > > >> IIRC Postgres has had ON DUPLICATE

Re: Bug in format specification in Python 3?

2009-08-11 Thread greg
Robert Dailey wrote: I notice that the '0x' portion is counted in the width, which was specified as 8. This seems wrong to me. Is this by design? If so, why? Yes, it's the total field width. This is consistent with the other formats, in which it includes decimal points, signs, etc. If you don

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-11 Thread greg
ru...@yahoo.com wrote: Such a reorg is not a simple matter of moving a file from here to there. It will require a lot moving about of sections and a lot of word-smithing to glue them back together again in a coherent way. Concerning this particular issue, not everyone would agree that the doc

Re: Frustrated with scopes

2009-08-11 Thread James Stroud
James Stroud wrote: > def stream_factory: > class Line(object): > __source = source > __join = join > # etc. > return Line > of course I meant "def stream_factory(lines, source, join=''.join):" James -- http://mail.python.org/mailman/listinfo/python-list

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 3:32 pm, James Stroud wrote: > You should be more imaginative. I'm by no means discounting that there might be some actual problem you're trying to solve here, but I honestly can't see it. There really is no need to get personal about this, so rather than asking for a level of imagin

Re: hashability

2009-08-11 Thread Chris Rebert
2009/8/11 Asun Friere : > On Aug 12, 12:15 pm, James Stroud wrote: > >> I realize I left out my use. The intent of the function is to flag >> objects that will make useful keys for a persistent dictionary. The >> {C():4}[C()] example demonstrates why I want to avoid certain types of >> keys--I don

Re: hashability

2009-08-11 Thread Chris Rebert
On Wed, Aug 12, 2009 at 2:25 AM, Chris Rebert wrote: > 2009/8/11 Asun Friere : >> On Aug 12, 12:15 pm, James Stroud wrote: Apologies for the possible repeated post. Gmail failed to mark the draft as sent for some reason. - Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 3:52 pm, Chris Rebert wrote: > Thought Experiment: > Consider, for each dict, the case of pickling it twice to 2 separate files. > When loaded from both files into the same program, the spam-ham dicts > will work as expected between each other. > The dicts with C()s will not. For examp

Re: hashability

2009-08-11 Thread David Stanek
On Wed, Aug 12, 2009 at 2:18 AM, Asun Friere wrote: > On Aug 12, 3:32 pm, James Stroud > wrote: > >> You should be more imaginative. > > I'm by no means discounting that there might be some actual problem > you're trying to solve here, but I honestly can't see it. How about a cache? Hashing by id

Re: hashability

2009-08-11 Thread James Stroud
Asun Friere wrote: On Aug 12, 3:32 pm, James Stroud wrote: You should be more imaginative. I'm by no means discounting that there might be some actual problem you're trying to solve here, but I honestly can't see it. There really is no need to get personal about this, so rather than asking

<    1   2