Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Steven D'Aprano
On Mon, 10 Aug 2009 15:17:24 -0700, Douglas Alan wrote: > From: Steven D'Aprano wrote: > >> On Mon, 10 Aug 2009 00:32:30 -0700, Douglas Alan wrote: > >> > In C++, if I know that the code I'm looking at compiles, then I never >> > need worry that I've misinterpreted what a string literal means.

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

2009-08-11 Thread Ned Deily
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 example where "print root[0][0]" returns > "" >

Re: How to pickle a lambda function?

2009-08-11 Thread Duncan Booth
Terry wrote: > I'm trying to implement something like: > > remote_map(fun, list) > > to execute the function on a remove machine. But the problem is I > cannot pickle a lambda function and send it to the remote machine. > > Is there any possible way to pickle (or other method) any functions >

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

2009-08-11 Thread Antoine Pitrou
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, > > don't you think you should be discussing it on python-dev ? > > Yea, them's be a friendly bunch to noob ideas ;). Hey i got a better > idea, lets go to the

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

2009-08-11 Thread Diez B. Roggisch
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 hold of the "Running" string in the tag using elementTree?

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

2009-08-11 Thread Mark Lawrence
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, don't you think you should be discussing it on python-dev ? Yea, them's be a friendly bunch to noob ideas ;). Hey i got a better idea, lets go

Re: How to pickle a lambda function?

2009-08-11 Thread Terry
On Aug 11, 3:42 pm, Duncan Booth wrote: > Terry wrote: > > I'm trying to implement something like: > > > remote_map(fun, list) > > > to execute the function on a remove machine. But the problem is I > > cannot pickle a lambda function and send it to the remote machine. > > > Is there any possible

Re: Problem Regarding Handling of Unicode string

2009-08-11 Thread John Machin
On Aug 10, 9:26 pm, joy99 wrote: > Dear Group, > > I am using Python26 on WindowsXP with service pack2. My GUI is IDLE. > I am using Hindi resources and get nice output like: > एक > where I can use all the re functions and other functions without doing > any transliteration,etc. > I was trying to

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

2009-08-11 Thread Bruno Desthuilliers
r a écrit : (snip) A little note for tutorial writers: == Dear Expert, Whilst writing any tutorial on any subject matter please remember, you may be an expert, but mostly *non-experts* will be reading your material... I can only second Paul on this : just like

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

2009-08-11 Thread Brian
On Fri, Jul 31, 2009 at 6:12 PM, Kee Nethery wrote: > I too find the Python docs not very useful and it really slows down my > learning curve. > > I wonder if it would make sense to find good tech writers, get a quotes, > and get some professionally written documentation WITH LOTS OF EXAMPLES > a

Re: With or without leading underscore...

2009-08-11 Thread Bruno Desthuilliers
Carl Banks a écrit : (snip) class A(object): def __init__(self,*args,**kwargs): raise TypeError('Type not callable; use factory function instead') @classmethod def _create_object(cls,initial_value): self = object.__new__(cls) # avoid __init__ self.value = in

Is there any package implanation the following arithmetics?

2009-08-11 Thread zhongshq
Hi, I wonder if there has any package can check whether two rectangles are overlap, is a dot inside or outside a polygon, etc. Thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help in configuration for TimedRotatingFileHandler

2009-08-11 Thread Vinay Sajip
On Aug 10, 3:52 pm, Dave Angel wrote: > Lokesh Maremalla wrote: > > Traceback (most recent call last): > >   File "c:\Python25\lib\logging\handlers.py", line 74, in emit > >     self.doRollover() > >   File "c:\Python25\lib\logging\handlers.py", line 274, in doRollover > >     os.rename(self.baseF

UML for Python or some other Graphical Notation Language

2009-08-11 Thread llothar
This is more an academic question right now but was there ever some work in progress how UML could be made better for Python or script languages in general. It is so extremely deep interwoven with Java/C++ language implementations that there are a lot of modified notiations necessary. Or is there

Search and write to .txt file

2009-08-11 Thread Helvin
Hi everyone, I am writing some python script that should find a line which contains '1' in the data.txt file, then be able to move a certain number of lines down, before replacing a line. At the moment, I am able to find the line '1', but when I use f.seek to move, and then rewrite, what I write g

Re: Search and write to .txt file

2009-08-11 Thread Kushal Kumaran
On Tue, Aug 11, 2009 at 4:52 PM, Helvin wrote: > Hi everyone, > > I am writing some python script that should find a line which contains > '1' in the data.txt file, then be able to move a certain number of > lines down, before replacing a line. At the moment, I am able to find > the line '1', but w

Re: dictionary help

2009-08-11 Thread Dave Angel
Krishna Pacifici wrote: Hi, kind of a newbie here, but I have two questions that are probably pretty simple. 1. I need to get rid of duplicate values that are associated with different keys in a dictionary. For example I have the following code. s={} s[0]=[10,2,3] s[10]=[22,23,24] s[20]=[45

add fields in a existing dbf

2009-08-11 Thread Alonso Luján Torres Taño
Hi! I'm trying to modify a dbf adding a new field in a python script, but I can't. Just I can add a field in new dbf created in the same script. I tryed with: db = dbf.Dbf("../filesource.dbf",new =False, readOnly=False) ... db.addField(("PESO","N",32,8)) and return error: Trace

Re: UML for Python or some other Graphical Notation Language

2009-08-11 Thread Diez B. Roggisch
llothar wrote: > This is more an academic question right now but was there ever some > work in progress how UML could be made better for Python or script > languages in general. > > It is so extremely deep interwoven with Java/C++ language > implementations that there are a lot of modified notiat

test message

2009-08-11 Thread skip
Sorry for the low content email. Testing the mail-to-news gateway on mail.python.org. Don't flame me for not using a test newsgroup. ;-) -- Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/ Getting old sucks, but it beats dying young -- http://mail.python.org/mailman/listinfo/py

Re: test message

2009-08-11 Thread Skip Montanaro
On Aug 11, 7:40 am, s...@pobox.com wrote: > Sorry for the low content email.  Testing the mail-to-news gateway on > mail.python.org.  Don't flame me for not using a test newsgroup. ;-) Posting a followup to test the return path (news-to-mail). S -- http://mail.python.org/mailman/listinfo/python-

Re: Search and write to .txt file

2009-08-11 Thread Piet van Oostrum
> Helvin (H) wrote: >H> Hi everyone, >H> I am writing some python script that should find a line which contains >H> '1' in the data.txt file, then be able to move a certain number of >H> lines down, before replacing a line. At the moment, I am able to find >H> the line '1', but when I use f.s

Extracting matrix from a text file

2009-08-11 Thread telek...@hotmail.com
Hello to all!! I am new in python, and I am running it on Mac with Smultron editor. I need to read a textfile that includes numbers (in a matrix form), indexes, and strings, like this: Marsyas-kea distance matrix for MIREX 2007 Audio Similarity Exchange Q/R1 2

Re: Search and write to .txt file

2009-08-11 Thread Mark Lawrence
Helvin wrote: Hi everyone, I am writing some python script that should find a line which contains '1' in the data.txt file, then be able to move a certain number of lines down, before replacing a line. At the moment, I am able to find the line '1', but when I use f.seek to move, and then rewrite

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Piet van Oostrum
> Steven D'Aprano (SD) wrote: >SD> If I'm reading this page correctly, Python does behave as C++ does. Or at >SD> least as Larch/C++ does: >SD> http://www.cs.ucf.edu/~leavens/larchc++manual/lcpp_47.html They call them `non-standard escape sequences' for a reason: that they are not in stand

Re: Extracting matrix from a text file

2009-08-11 Thread Mark Lawrence
telek...@hotmail.com wrote: Hello to all!! I am new in python, and I am running it on Mac with Smultron editor. I need to read a textfile that includes numbers (in a matrix form), indexes, and strings, like this: Marsyas-kea distance matrix for MIREX 2007 Audio Similarity Exchange Q/R1

Re: Search and write to .txt file

2009-08-11 Thread Dave Angel
Piet van Oostrum wrote: Helvin (H) wrote: H> Hi everyone, H> I am writing some python script that should find a line which contains H> '1' in the data.txt file, then be able to move a certain number of H> lines down, before replacing a line. At the moment, I am able to find H>

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

2009-08-11 Thread Ethan Furman
David Lyon wrote: On Mon, 10 Aug 2009 09:13:34 -0700, Ethan Furman wrote: As someone who relies heavily on the docs I will also say that the idea of giving the ability to modify the official documentation to somebody who is /learning/ the language is, quite frankly, terrifying. What is m

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

2009-08-11 Thread rurpy
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, >>> don't you think you should be discussing it on python-dev ? >> Yea, them's be a friendly bunch to noob ideas

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Ethan Furman
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 for Python 3.2 to raise

Re: Extracting matrix from a text file

2009-08-11 Thread Colin J. Williams
telek...@hotmail.com wrote: Hello to all!! I am new in python, and I am running it on Mac with Smultron editor. I need to read a textfile that includes numbers (in a matrix form), indexes, and strings, like this: Marsyas-kea distance matrix for MIREX 2007 Audio Similarity Exchange Q/R1

Profiling a Callback Function

2009-08-11 Thread Nikolaus Rath
Hello, I am trying to profile a Python program that primarily calls a C extension. From within the C extension, a callback Python function is then called concurrently in several threads. When I tried to profile this application with import c_extension def callback_fn(args): # Do all so

Re: dictionary help

2009-08-11 Thread Krishna Pacifici
Thanks for the help. Actually this is part of a much larger project, but I have unfortunately pigeon-holed myself into needing to do these things without a whole lot of flexibility. To give a specific example I have the following dictionary where I need to remove values that are duplicated wit

Re: Search and write to .txt file

2009-08-11 Thread Simon Forman
On Aug 11, 7:22 am, Helvin wrote: > Hi everyone, > > I am writing some python script that should find a line which contains > '1' in the data.txt file, then be able to move a certain number of > lines down, before replacing a line. At the moment, I am able to find > the line '1', but when I use f.

Re: dictionary help

2009-08-11 Thread MRAB
Krishna Pacifici wrote: Thanks for the help. Actually this is part of a much larger project, but I have unfortunately pigeon-holed myself into needing to do these things without a whole lot of flexibility. To give a specific example I have the following dictionary where I need to remove val

Re: add fields in a existing dbf

2009-08-11 Thread Ethan Furman
Alonso Luján Torres Taño wrote: Hi! I'm trying to modify a dbf adding a new field in a python script, but I can't. Just I can add a field in new dbf created in the same script. I tryed with: db = dbf.Dbf("../filesource.dbf",new =False, readOnly=False) ... db.addField(("PESO","N"

Re: dictionary help

2009-08-11 Thread Simon Forman
On Aug 11, 11:51 am, MRAB wrote: > Krishna Pacifici wrote: > > Thanks for the help. > > > Actually this is part of a much larger project, but I have unfortunately > > pigeon-holed myself into needing to do these things without a whole lot > > of flexibility. > > > To give a specific example I have

better way?

2009-08-11 Thread someone
Hello, I'd like to make insert into db if record not exist otherwise update. to save typing list of columns in both statements I do following query = "SELECT location FROM table WHERE location = %s AND id = %s;" result = self._getResult(db, query, [location,id]) fields = ['id', 'location', 'wl',

GOZERBOT 0.9.1 released

2009-08-11 Thread Bart Thate
here it is .. GOZERBOT 0.9.1 !! Main change this time is the distribution method, we now provide a tar.gz with all the dependencies included. This means that you can run the bot locally without any root required. Python 2.5 or higher needed, see http://gozerbot.org Enjoy ! about GOZERBOT: GOZER

Re: Is there any package implanation the following arithmetics?

2009-08-11 Thread Emile van Sebille
On 8/11/2009 1:49 AM zhongshq said... Hi, I wonder if there has any package can check whether two rectangles are overlap, is a dot inside or outside a polygon, etc. PythonCad at http://sourceforge.net/projects/pythoncad/ has intersections built in. Emile -- http://mail.python.org/mailman/l

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

2009-08-11 Thread r
On Aug 11, 1:47 am, Steven D'Aprano wrote: > On Mon, 10 Aug 2009 20:05:00 -0400, David Lyon wrote: > > Ignore feedback... tell people to freak off... > > Only useless feedback. And who decides what is useless and what isn't Steven?. You?, alex23?, Bruno?, Paul? Carl? Who makes these decisions and

Re: dictionary help

2009-08-11 Thread Krishna Pacifici
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 (and keys) represent a bloc

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

2009-08-11 Thread Maria Liukis
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 find anything for float. Any help would be greatly app

Scraping Wikipedia with Python

2009-08-11 Thread Dotan Cohen
I plan on making a geography-learning Anki [1] deck, and Wikipedia has the information that I need in nicely formatted tables on the side of each country's page. Has someone already invented a wheel to parse and store that data (scrape)? It is probably not difficult to code, and within the Wikipedi

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

2009-08-11 Thread Mark Lawrence
r wrote: On Aug 11, 1:47 am, Steven D'Aprano wrote: On Mon, 10 Aug 2009 20:05:00 -0400, David Lyon wrote: Ignore feedback... tell people to freak off... Only useless feedback. [snip] I am sorry but i feel many here would not judge fairly based on the merits of an idea without allowing "b

Re: Is "feedparser" deprecated?

2009-08-11 Thread John Nagle
Gabriel Genellina wrote: En Fri, 07 Aug 2009 16:07:48 -0300, John Nagle escribió: Feedparser requires SGMLlib, which has been removed from Python 3.0. Feedparser hasn't been updated since 2007. Does this mean Feedparser is dead? Since we have generic and easy of use XML parsers like Eleme

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

2009-08-11 Thread Maria Liukis
A bit more of googling gave me an answer: >>> import numpy as np >>> np.finfo(np.double).tiny array(2.2250738585072014e-308) >>> Thanks, Masha liu...@usc.edu On Aug 11, 2009, at 10:29 AM, Maria Liukis wrote: Hello everybody, Is somebody aware of built-in Python's funct

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

2009-08-11 Thread Steven D'Aprano
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, don't you think you should be discussing it on python

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Steven D'Aprano
On Tue, 11 Aug 2009 15:50:01 +0200, Piet van Oostrum wrote: >> Steven D'Aprano (SD) wrote: > >>SD> If I'm reading this page correctly, Python does behave as C++ does. >>Or at SD> least as Larch/C++ does: > >>SD> http://www.cs.ucf.edu/~leavens/larchc++manual/lcpp_47.html > > They call them

Networked Broadcast Messaging

2009-08-11 Thread squishywaf...@gmail.com
I'm not exactly sure what the term for this would be, but I was wondering if there were any Python packages that supported some kind of ad-hoc message broadcasting. What I'd like to do is something like this: * On a number of workhorse machines, a process listens for network messages from our broa

Re: looping through values in a dictionary and appending to a list

2009-08-11 Thread Krishna Pacifici
Nevermind, got it. Sorry. >>> Krishna Pacifici 08/11/09 2:12 PM >>> Hi, I want to append the values of a dictionary to a list. I have a dictionary sec_dict_clean and I want to append the values to a list, but am having a hard time looping through the values in the dictionary. I have tried som

Re: Scraping Wikipedia with Python

2009-08-11 Thread John Nagle
Dotan Cohen wrote: I plan on making a geography-learning Anki [1] deck, and Wikipedia has the information that I need in nicely formatted tables on the side of each country's page. Has someone already invented a wheel to parse and store that data (scrape)? Wikipedia has an API for computer

Re: Scraping Wikipedia with Python

2009-08-11 Thread Dotan Cohen
>    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. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- h

Re: Networked Broadcast Messaging

2009-08-11 Thread gregarican
On Aug 11, 2:14 pm, "squishywaf...@gmail.com" wrote: > I'm not exactly sure what the term for this would be, but I was > wondering if there were any Python packages that supported some kind > of ad-hoc message broadcasting. What I'd like to do is something like > this: > > * On a number of workhor

Re: better way?

2009-08-11 Thread Kushal Kumaran
On Tue, Aug 11, 2009 at 10:03 PM, someone wrote: > Hello, > > I'd like to make insert into db if record not exist otherwise update. > to save typing list of columns in both statements I do following > > > > > is there better or more readable way to do it? > Well, mysql, in particular, offers an "

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

2009-08-11 Thread Paul Rubin
Steven D'Aprano writes: > - if people are keen on a Python wiki, then by all means publish one, > just don't expect the Python dev team to build and manage it for you; There are already some nice ones at: http://en.wikibooks.org/wiki/Python -- http://mail.python.org/mailman/listinfo/python-

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

2009-08-11 Thread Raymond Hettinger
[Paul Rubin] > I think the Python tutorial is aimed at users who are newbies to > Python but not newbies to programming.  Writing a tutorial for total > newbies is a completely different problem, that would result in a much > different document that's less useful to the existing tutorial's > intend

Re: better way?

2009-08-11 Thread Pet
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 otherwise update. > > to save typing list of columns in both statements I do following > > > > > > is there better or more readable way

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

2009-08-11 Thread Paul Rubin
r writes: > Some say the tutorial is not meant for non-programmers, but for > programmers with no Python experience. So! How does that justify > obstruction of the tut? Why not present the same information in a way > both can easily understand? I agree that a tutorial for non-programmers would b

Re: Scraping Wikipedia with Python

2009-08-11 Thread David C Ullrich
On Tue, 11 Aug 2009 21:29:40 +0300, 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. Try

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

2009-08-11 Thread Paul Rubin
Raymond Hettinger writes: > Here is the page specifically marked for those who are new to programming: > http://wiki.python.org/moin/BeginnersGuide Oh cool, I didn't know about that one. -- http://mail.python.org/mailman/listinfo/python-list

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

2009-08-11 Thread max bianco
On Sat, Aug 8, 2009 at 12:25 AM, Steven D'Aprano wrote: > On Fri, 07 Aug 2009 13:35:26 -0700, Kee Nethery wrote: > > >> > Why exactly is posting an open comment on a bug tracker somehow >> > inferior to posting an open comment on a wiki? >> >> It's a good question and deserves a good answer. >> >>

Re: Networked Broadcast Messaging

2009-08-11 Thread Kushal Kumaran
On Wed, Aug 12, 2009 at 12:04 AM, gregarican wrote: > On Aug 11, 2:14 pm, "squishywaf...@gmail.com" > wrote: >> I'm not exactly sure what the term for this would be, but I was >> wondering if there were any Python packages that supported some kind >> of ad-hoc message broadcasting. What I'd like t

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

2009-08-11 Thread max bianco
On Thu, Aug 6, 2009 at 2:36 PM, Kee Nethery wrote: > As someone trying to learn the language I want to say that the tone on this > list towards people who are trying to learn Python  feels like it has become > anti-newbies. > > Learning a new language is difficult enough without seeing other newbie

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

2009-08-11 Thread Grant Edwards
On 2009-08-11, Paul Rubin wrote: > r writes: >> Some say the tutorial is not meant for non-programmers, but for >> programmers with no Python experience. So! How does that justify >> obstruction of the tut? Why not present the same information in a way >> both can easily understand? > > I agree

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1   2   >