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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Re: Programming by Contract

2009-08-11 Thread Ethan Furman
Charles Yeomans wrote: On Aug 11, 2009, at 3:30 PM, Ethan Furman wrote: Ethan Furman wrote: Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very brief look at pycontract (http://www.wayforward.net/pycontract/ ) and now I have at lea

run all scripts in sub-directory as subroutines?

2009-08-11 Thread guthrie
I want to have a program which will form a list of all *.py scripts in a sub-directory, and then call some standard messages on them. So I can add a new data source modularly by just dropping a new file into the sources directory with the appropriate methods in it. For example: path = sys.path[0]

Re: dictionary help

2009-08-11 Thread MRAB
Krishna Pacifici wrote: Wow, thanks MRAB and Simon, you guys are good. I guess I will go ahead and ask the next question that has also stumped me for awhile now. So basically I need to loop through the values in the new dictionary and append attributes of a class object. Each of the values

Re: Bug in format specification in Python 3?

2009-08-11 Thread MRAB
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 counted in the width, which was specified a

Re: Need cleanup advice for multiline string

2009-08-11 Thread Robert Dailey
On Aug 11, 3:40 pm, Bearophile wrote: > Robert Dailey: > > > This breaks the flow of scope. Would you guys solve this > > problem by moving failMsg into global scope? > > Perhaps through some other type of syntax? > > There are gals too here. > This may help:http://docs.python.org/library/textwrap

Re: Programming by Contract

2009-08-11 Thread Charles Yeomans
On Aug 11, 2009, at 3:30 PM, Ethan Furman wrote: Ethan Furman wrote: Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very brief look at pycontract (http://www.wayforward.net/pycontract/ ) and now I have at least one question: Is this

New 2.6 and wx install => DLL load failed: The specified procedure could not be found

2009-08-11 Thread RJ
I just installed python-2.6.2.msi from Python.org and wxPython2.8-win32-ansi-2.8.10.1-py26.exe and now can't import this wx. (I had 2.4, but uninstalled) This reminds me of a basic question I had before: what are the compilers used for the Win32 binaries? Is this a compiler compatibility issue?

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

2009-08-11 Thread Mark Lawrence
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 available for months. -- Kindest regards. Mark Lawrence. -

Re: Need cleanup advice for multiline string

2009-08-11 Thread Bearophile
Robert Dailey: > This breaks the flow of scope. Would you guys solve this > problem by moving failMsg into global scope? > Perhaps through some other type of syntax? There are gals too here. This may help: http://docs.python.org/library/textwrap.html#textwrap.dedent Bye, bearophile -- http://mai

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

2009-08-11 Thread r
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? -- http://mail.python.org/mailman/listinfo/python-list

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Ethan Furman
Douglas Alan wrote: On Aug 11, 2:00 pm, Steven D'Aprano wrote: test.cpp:1:1: warning: unknown escape sequence '\y' Isn't that a warning, not a fatal error? So what does temp contain? My "Annotated C++ Reference Manual" is packed, and surprisingly in Stroustrup's Third Edition, there is n

Re: Scraping Wikipedia with Python

2009-08-11 Thread Paul Rubin
Dotan Cohen writes: > Thanks. I read the first bit of that page, but did not finish it. > Grepping it for Python led to to what I need. maybe you want dbpedia. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need cleanup advice for multiline string

2009-08-11 Thread Mark Lawrence
Robert Dailey wrote: On Aug 11, 3:08 pm, 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 sco

Bug in format specification in Python 3?

2009-08-11 Thread Robert Dailey
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 counted in the width, which was specified as 8. This seems wrong t

httplib incredibly slow :-(

2009-08-11 Thread Chris Withers
Hi All, I'm using the following script to download a 150Mb file: from base64 import encodestring from httplib import HTTPConnection from datetime import datetime conn = HTTPSConnection('localhost') headers = {} auth = 'Basic '+encodestring('username:password').strip() headers['Authorization']=a

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

2009-08-11 Thread cmalmqui
On Aug 11, 9:13 am, Ned Deily wrote: > In article > <1ad8dac1-8fff-493a-a197-d847e7b6a...@c2g2000yqi.googlegroups.com>, > >  cmalmqui wrote: > > 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

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 11, 2:00 pm, Steven D'Aprano wrote: > > test.cpp:1:1: warning: unknown escape sequence '\y' > > Isn't that a warning, not a fatal error? So what does temp contain? My "Annotated C++ Reference Manual" is packed, and surprisingly in Stroustrup's Third Edition, there is no mention of the iss

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

2009-08-11 Thread cmalmqui
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

Re: Need cleanup advice for multiline string

2009-08-11 Thread Robert Dailey
On Aug 11, 3:08 pm, 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 t

Re: better way?

2009-08-11 Thread Rami Chowdhury
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 KEY UPDATE functionality longer than MySQL... PostgreSQL

Re: better way?

2009-08-11 Thread Matthew Woodcraft
"Rami Chowdhury" writes: > IIRC Postgres has had ON DUPLICATE KEY UPDATE functionality longer than > MySQL... PostgreSQL does not have ON DUPLICATE KEY UPDATE. The SQL standard way to do what the OP wants is MERGE. PostgreSQL doesn't have that either. -M- -- http://mail.python.org/mailman/lis

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

2009-08-11 Thread Mark Lawrence
r wrote: Ok people follow me here. Open your winders help file and click the "Tutorial" link. What is this FLUFF doing here!?!?! Where is the damn index? Where is the damn tutorial? I want to learn Python not read the HISTORY OF THE WORLD. Upon clicking the "Tutorial" link pre 2.6, a nice menu w

Need cleanup advice for multiline string

2009-08-11 Thread Robert Dailey
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 indents. In this case indents

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

2009-08-11 Thread r
Ok people follow me here. Open your winders help file and click the "Tutorial" link. What is this FLUFF doing here!?!?! Where is the damn index? Where is the damn tutorial? I want to learn Python not read the HISTORY OF THE WORLD. Upon clicking the "Tutorial" link pre 2.6, a nice menu was placed b

adding multiple new values to the same key in a dictionary

2009-08-11 Thread Krishna Pacifici
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_clean.values()[i])):

Re: Scraping Wikipedia with Python

2009-08-11 Thread Brian
On Tue, Aug 11, 2009 at 12:29 PM, Dotan Cohen wrote: > >Wikipedia has an API for computer access. See > > > >http://www.mediawiki.org/wiki/API > > > > Yes, I am aware of this as well. Does anyone know of a python class > for easily interacting with it, or do I need to roll my own. >

Re: better way?

2009-08-11 Thread Pet
On 11 Aug., 21:23, "Rami Chowdhury" wrote: > IIRC Postgres has had ON DUPLICATE KEY UPDATE functionality longer than   > MySQL... > Ok, I've completely failed here :) Thanks, man > > > > > On Tue, 11 Aug 2009 11:45:50 -0700, Pet wrote: > > On 11 Aug., 20:39, Kushal Kumaran > > wrote: > >> On

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

2009-08-11 Thread dmitrey
Yes, thank you, items() is the correct approach, on the other hand I have already get rid of the cycle. Regards, D. On Aug 11, 10:26 pm, "Rami Chowdhury" wrote: > Hi Dmitrey, > > I think what you're looking for is myDict.items(), or myDict.iteritems(). > > Cheers, > Rami > > On Tue, 11 Aug 2009 1

Re: Programming by Contract

2009-08-11 Thread Ethan Furman
Ethan Furman wrote: Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very brief look at pycontract (http://www.wayforward.net/pycontract/) and now I have at least one question: Is this basically another way of thinking about unit testin

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

2009-08-11 Thread Rami Chowdhury
Hi Dmitrey, I think what you're looking for is myDict.items(), or myDict.iteritems(). Cheers, Rami On Tue, 11 Aug 2009 12:15:13 -0700, dmitrey wrote: hi all, which method should I use to get iterator over (key, value) pairs for Python dict, Python v 2.6 and above? Of course I could use

Re: better way?

2009-08-11 Thread Rami Chowdhury
IIRC Postgres has had ON DUPLICATE KEY UPDATE functionality longer than MySQL... On Tue, 11 Aug 2009 11:45:50 -0700, Pet wrote: On 11 Aug., 20:39, Kushal Kumaran wrote: On Tue, Aug 11, 2009 at 10:03 PM, someone wrote: > Hello, > I'd like to make insert into db if record not exist otherw

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

2009-08-11 Thread dmitrey
hi all, which method should I use to get iterator over (key, value) pairs for Python dict, Python v 2.6 and above? Of course I could use for key in myDict.keys(): value = myDict.values() # do something with the pair key, value but searching each time for the value take some cputime that

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

2009-08-11 Thread Grant Edwards
On 2009-08-11, max bianco wrote: > I assume I am misunderstanding you here and you meant something else? > Python is paraded as a good language for beginners. I believe it is a good language for beginners. > Is this a false statement or a secondary objective? Objective of what? > Or are the d

Re: Scraping Wikipedia with Python

2009-08-11 Thread Dotan Cohen
> Try reading a little there! Starting there I went to > > http://en.wikipedia.org/wiki/Wikipedia:Creating_a_bot > > where I found a section on existing bots, comments on how the "scraping" > is not what you want, and even a Python section with a link to something > labelled  PyWikipediaBot... > T

Re: Networked Broadcast Messaging

2009-08-11 Thread Greg Taylor
On Aug 11, 3:00 pm, Kushal Kumaran wrote: > You could use the socket module to broadcast.  Using INADDR_BROADCAST > as the destination should do it.  I fail to recollect whether that > will need root privileges... Awesome, I think this is exactly what I'm looking for. Much appreciated! Greg --

  1   2   >