Re: [Python-ideas] Make "is" checks on non-singleton literals errors

2012-10-09 Thread Chris Angelico
On Tue, Oct 9, 2012 at 1:14 PM, Guido van Rossum wrote: > Maybe we should do something more drastic and always create a new, > unique constant whenever a literal occurs as an argument of 'is' or > 'is not'? Then such code would never work, leading people to examine > their code more closely. I bet

Re: Unpaking Tuple

2012-10-09 Thread Jussi Piitulainen
Dave Angel writes: > On 10/09/2012 02:07 AM, Bob Martin wrote: > > in 682592 20121008 232126 "Prasad, Ramit" wrote: [snip mess] > > How does one unpack this post? ;-) > > Since that's not the way it arrived here, i have to ask, how do you > get these posts? Are you subscribed to individual mess

Re: Blue Screen Python

2012-10-09 Thread mikcec82
Il giorno venerdì 21 settembre 2012 16:04:48 UTC+2, mikcec82 ha scritto: > Hallo to all, > > > > I'm using Python 2.7.3 with Windows 7 @ 64 bit > > and an Intel Core i3 -2350M CPU @2.30GHz 2.3GHz. > > > > Sometimes, when I'm programming in Python on my screen compare this blue > screen: >

FW: question Python custome events

2012-10-09 Thread Hussain, Mushabbar
Hi, Is it possible to define an Event which should fire when a value of a variable changes? Something like below self.Bind(wx.EVT_ON_VAL_CHANGE, variable_to_watch, self.Callback) I need a Text ctrl UI which continuously changes values based on external data changes. Unfortunately I could not f

Re: Blue Screen Python

2012-10-09 Thread Philipp Hagemeister
On 10/09/2012 09:37 AM, mikcec82 wrote: > In my script I open and close an html (in a FOR cycle); could be this the > problem? Unless you're running your Python script as a kernel driver (and you can't do that accidentally), there is no way that your user-space program should cause a bluescreen. T

Re: mangled messages (was: Unpaking Tuple)

2012-10-09 Thread Tim Chase
On 10/09/12 02:22, Jussi Piitulainen wrote: >>> in 682592 20121008 232126 "Prasad, Ramit" wrote: > [snip mess] >>> How does one unpack this post? ;-) >> >> Since that's not the way it arrived here, i have to ask, how do you >> get these posts? > > I see a carriage return rendered as ^M at the end

pydelicious documentation

2012-10-09 Thread Andres Soto
Does somebody know where I can get the documentation for pydelicious? The documentation links ("For code documentation see doc/pydelicious or doc/dlcs.py.") in http://packages.python.org/pydelicious/README.html#id3  gave me  404 Not Found nginx/1.1.19   Prof. Dr.

Re: + in regular expression

2012-10-09 Thread Duncan Booth
Cameron Simpson wrote: >| Because "\s{6}+" >| has other meanings in different regex syntaxes and the designers didn't >| want confusion? > > I think Python REs are supposed to be Perl compatible; ISTR an opening > sentence to that effect... > I don't know the full history of how regex engines

Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ?

2012-10-09 Thread Steven D'Aprano
On Tue, 09 Oct 2012 02:00:04 +1100, Chris Angelico wrote: > On Tue, Oct 9, 2012 at 1:48 AM, Dave Angel wrote: >> import decimal >> a = decimal.Decimal(4.3) >> print(a) >> >> 5.0996447286321199499070644378662109375 > > Ah, the delights of copy-paste :) > >> The Decimal class has the

Re: Insert item before each element of a list

2012-10-09 Thread Duncan Booth
mooremath...@gmail.com wrote: > What's the best way to accomplish this? Am I over-complicating it? > My gut feeling is there is a better way than the following: > import itertools x = [1, 2, 3] y = list(itertools.chain.from_iterable(('insertme', x[i]) for i in range(len(x))

Re: pydelicious documentation

2012-10-09 Thread Alec Taylor
Hi Professor Soto, Not sure what's going on with their servers', but I was able to find the documentation on their repo: https://pydelicious.googlecode.com/svn/trunk/doc/htmlref/index.html https://pydelicious.googlecode.com/svn/trunk/doc/htmlref/HACKING.html https://pydelicious.googlecode.com/svn

Re: pydelicious documentation

2012-10-09 Thread Alec Taylor
Actually it seems this project has been official abandoned. Unofficially use this, was updated only a month ago: https://github.com/mgan59/python-pinboard On Tue, Oct 9, 2012 at 10:47 PM, Alec Taylor wrote: > Hi Professor Soto, > > Not sure what's going on with their servers', but I was able to

Creating a dictionary

2012-10-09 Thread argbsk
below is the text file i have How to create Facility as a key and then assign multiple values to it FACILITY : BACKUP FAILED BACKUP_BEFORE FAILED BACKUP_INTERCHANGE Total : 34 Passed : 32 Failed : 2 Not Run : 0 FACILITY : CDU Total : 9 Passed : 9 Failed : 0 for example Facility BACKUP is a key

Re: Insert item before each element of a list

2012-10-09 Thread Steven D'Aprano
On Mon, 08 Oct 2012 19:34:26 -0700, rusi wrote: > How about a 2-paren version? > x = [1,2,3] reduce(operator.add, [['insert', a] for a in x]) > ['insert', 1, 'insert', 2, 'insert', 3] That works, but all those list additions are going to be slow. It will be an O(N**2) algorithm. If

Re: mangled messages (was: Unpaking Tuple)

2012-10-09 Thread Jussi Piitulainen
Tim Chase writes: > On 10/09/12 02:22, Jussi Piitulainen wrote: > >>> in 682592 20121008 232126 "Prasad, Ramit" wrote: > > [snip mess] > >>> How does one unpack this post? ;-) > >> > >> Since that's not the way it arrived here, i have to ask, how do you > >> get these posts? > > > > I see a carri

Re: Blue Screen Python

2012-10-09 Thread mikcec82
Il giorno venerdì 21 settembre 2012 16:04:48 UTC+2, mikcec82 ha scritto: > Hallo to all, > > > > I'm using Python 2.7.3 with Windows 7 @ 64 bit > > and an Intel Core i3 -2350M CPU @2.30GHz 2.3GHz. > > > > Sometimes, when I'm programming in Python on my screen compare this blue > screen: >

Re: Insert item before each element of a list

2012-10-09 Thread Peter Otten
Duncan Booth wrote: > mooremath...@gmail.com wrote: > >> What's the best way to accomplish this? Am I over-complicating it? >> My gut feeling is there is a better way than the following: >> > import itertools > x = [1, 2, 3] > y = list(itertools.chain.from_iterable(('insertme', x[i]

Re: Creating a dictionary

2012-10-09 Thread Steven D'Aprano
On Tue, 09 Oct 2012 04:59:49 -0700, argbsk wrote: > below is the text file i have How to create Facility as a key and then > assign multiple values to it To use Facility as a key in a dict: d = {} d['Facility'] = 'ham' Note that keys are case-sensitive, so that 'Facility', 'facility', 'FACILIT

Re: Creating a dictionary

2012-10-09 Thread Roy Smith
In article <50741ffe$0$6574$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Tue, 09 Oct 2012 04:59:49 -0700, argbsk wrote: > > > below is the text file i have How to create Facility as a key and then > > assign multiple values to it > > To use Facility as a key in a dict: > >

Re: Creating a dictionary

2012-10-09 Thread Ulrich Eckhardt
Am 09.10.2012 13:59, schrieb arg...@gmail.com: below is the text file i have How to create Facility as a key and then assign multiple values to it The value part of a dict element can be any kind of object, like e.g. a tuple, namedtuple or even a dict. Uli -- http://mail.python.org/mailma

RE: Fastest web framework

2012-10-09 Thread Andriy Kornatskyy
How fast python web framework process routing (URL dispatch)? Here is a benchmark for various web frameworks (bottle, django, flask, pyramid, tornado and wheezy.web) running the following routing: static, dynamic, SEO and missing... with a trivial 'hello world' application (all routes are point

Re: Private methods

2012-10-09 Thread Mark Lawrence
On 09/10/2012 14:24, D.M. Procida wrote: What exactly is the point of a private method? Why or when would I want to use one? Daniele Hardly a Python question but using a search engine could have got you here, and rather faster :) http://stackoverflow.com/questions/2620699/why-private-method

Re: Private methods

2012-10-09 Thread D.M. Procida
Mark Lawrence wrote: > On 09/10/2012 14:24, D.M. Procida wrote: > > What exactly is the point of a private method? Why or when would I want > > to use one? > > > > Daniele > > > > Hardly a Python question but using a search engine could have got you > here, and rather faster :) > http://stackov

string contains and special characters

2012-10-09 Thread loial
I am trying to match a string that containing the "<" and ">" characters, using the string contains function, but it never seems to find the lines containing the string e.g if mystring.contains("") : Do I need to escape the characters...and if so how? -- http://mail.python.org/mailman/listinf

Re: Private methods

2012-10-09 Thread Demian Brecht
On 12-10-09 06:59 AM, D.M. Procida wrote: In Python, using an underscore is simply a convention to note that a method is private - it doesn't actually hide it from other things - correct? Daniele A single underscore semantically means private. A double underscore will name mangle the functio

Re: Insert item before each element of a list

2012-10-09 Thread mooremathewl
On Monday, October 8, 2012 10:06:50 PM UTC-4, Roy Smith wrote: > In article , > (big snip) > > > > y = list(itertools.chain.from_iterable(('insertme', x[i]) for i in > > range(len(x > > > > A statement ending in four close parens is usually going to be pretty > > difficult to figure

Re: Private methods

2012-10-09 Thread Robert Kern
On 10/9/12 2:59 PM, D.M. Procida wrote: Mark Lawrence wrote: On 09/10/2012 14:24, D.M. Procida wrote: What exactly is the point of a private method? Why or when would I want to use one? Daniele Hardly a Python question but using a search engine could have got you here, and rather faster :

Re: Unpaking Tuple

2012-10-09 Thread Grant Edwards
On 2012-10-09, Bob Martin wrote: > in 682592 20121008 232126 "Prasad, Ramit" wrote: >>Thomas Bach wrote:=0D=0A> Hi there,=0D=0A> =0D=0A> On Sat, Oct 06, 2012 at = >>03:08:38PM +, Steven D'Aprano wrote:=0D=0A> >=0D=0A> > my_tuple =3D my_= >>tuple[:4]=0D=0A> > a,b,c,d =3D my_tuple if len(my_tup

Re: string contains and special characters

2012-10-09 Thread Agon Hajdari
On 10/09/2012 04:02 PM, loial wrote: > I am trying to match a string that containing the "<" and ">" characters, > using the string contains function, but it never seems to find the lines > containing the string > > e.g if mystring.contains("") : > > Do I need to escape the characters...and if

Re: Private methods

2012-10-09 Thread Tim Chase
On 10/09/12 08:59, D.M. Procida wrote: >> On 09/10/2012 14:24, D.M. Procida wrote: >>> What exactly is the point of a private method? Why or when would I want >>> to use one? > > In Python, using an underscore is simply a convention to note that a > method is private - it doesn't actually hide it

Re: string contains and special characters

2012-10-09 Thread Dave Angel
On 10/09/2012 10:02 AM, loial wrote: > I am trying to match a string that containing the "<" and ">" characters, > using the string contains function, but it never seems to find the lines > containing the string > > e.g if mystring.contains("") : > > Do I need to escape the characters...and if so

Re: mangled messages

2012-10-09 Thread Tim Chase
On 10/09/12 07:05, Jussi Piitulainen wrote: > Tim Chase writes: >> However, it might be that there is no CR+LF on the last line, >> or that one line is missing the CR, so your viewer heuristic >> (vim does this) thinks it has Unix NL-only line-endings and >> shows the ^M on all the lines that have

Re: string contains and special characters

2012-10-09 Thread Dave Angel
On 10/09/2012 10:23 AM, Dave Angel wrote: > On 10/09/2012 10:02 AM, loial wrote: >> I am trying to match a string that containing the "<" and ">" characters, >> using the string contains function, but it never seems to find the lines >> containing the string >> >> e.g if mystring.contains("") : >

Re: string contains and special characters

2012-10-09 Thread Jerry Hill
On Tue, Oct 9, 2012 at 10:02 AM, loial wrote: > I am trying to match a string that containing the "<" and ">" characters, > using the string contains function, but it never seems to find the lines > containing the string > > e.g if mystring.contains("") : > > Do I need to escape the characters..

Re: string contains and special characters

2012-10-09 Thread Mark Lawrence
On 09/10/2012 15:23, Dave Angel wrote: On 10/09/2012 10:02 AM, loial wrote: I am trying to match a string that containing the "<" and ">" characters, using the string contains function, but it never seems to find the lines containing the string e.g if mystring.contains("") : Do I need to esca

Re: string contains and special characters

2012-10-09 Thread loial
On Tuesday, 9 October 2012 15:19:33 UTC+1, Agon Hajdari wrote: > On 10/09/2012 04:02 PM, loial wrote: > I am trying to match a string that > containing the "<" and ">" characters, using the string contains function, > but it never seems to find the lines containing the string > > e.g if > mystri

surprising behaviour of global dictionaries

2012-10-09 Thread Michele Simionato
I have the following module implementing a registry of functions with a decorator: $ cat x.py registry = {} # global dictionary def dec(func): registry[func.__name__] = func print registry, id(registry) return func if __name__ == '__main__': import xlib print registry, id(re

Re: string contains and special characters

2012-10-09 Thread Ulrich Eckhardt
Am 09.10.2012 16:02, schrieb loial: I am trying to match a string that containing the "<" and ">" characters, using the string contains function, but it never seems to find the lines containing the string e.g if mystring.contains("") : I can't locate a 'contains' function anywhere, what type i

Re: surprising behaviour of global dictionaries

2012-10-09 Thread Peter Otten
Michele Simionato wrote: > I have the following module implementing a registry of functions with a > decorator: > > $ cat x.py > registry = {} # global dictionary > > def dec(func): > registry[func.__name__] = func > print registry, id(registry) > return func > > if __name__ == '__m

Re: surprising behaviour of global dictionaries

2012-10-09 Thread Michele Simionato
On Tuesday, October 9, 2012 5:24:17 PM UTC+2, Peter Otten wrote: > Seriously, you shouldn't use the main script as a library; it is put into > > the sys.modules cache under the "__main__" key. Subsequent imports under its > > real name will not find that name in the cache and import another ins

Re: surprising behaviour of global dictionaries

2012-10-09 Thread Grant Edwards
On 2012-10-09, Peter Otten <__pete...@web.de> wrote: > Welcome to python -- this is a trap every newbie falls into ;) > > Seriously, you shouldn't use the main script as a library; There must be something wrong with me. It never even occurred to me to try to import a file from within that same f

Generating C++ code

2012-10-09 Thread Jean-Michel Pichavant
Greetings, I'm trying to generate C++ code from an XML file. I'd like to use a template engine, which imo produce something readable and maintainable. My google search about this subject has been quite unsuccessful, I've been redirected to template engine specific to html mostly. Does anybody k

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-09 Thread Token Type
Thanks indeed for your tips. Now I understand the difference between tuples and dictionaries deeper. -- http://mail.python.org/mailman/listinfo/python-list

Re: surprising behaviour of global dictionaries

2012-10-09 Thread Dave Angel
On 10/09/2012 11:36 AM, Michele Simionato wrote: > On Tuesday, October 9, 2012 5:24:17 PM UTC+2, Peter Otten wrote: >> Seriously, you shouldn't use the main script as a library; it is put into >> >> the sys.modules cache under the "__main__" key. Subsequent imports under its >> >> real name will

RE: RE: Unpaking Tuple

2012-10-09 Thread Prasad, Ramit
Bob Martin wrote > in 682592 20121008 232126 "Prasad, Ramit" wrote: > >Thomas Bach wrote:=0D=0A> Hi there,=0D=0A> =0D=0A> On Sat, Oct 06, 2012 at = > >03:08:38PM +, Steven D'Aprano wrote:=0D=0A> >=0D=0A> > my_tuple =3D my_= > >tuple[:4]=0D=0A> > a,b,c,d =3D my_tuple if len(my_tuple) =3D=3D 4 e

Re: FW: question Python custome events

2012-10-09 Thread Ian Kelly
On Tue, Oct 9, 2012 at 2:35 AM, Hussain, Mushabbar wrote: > > > Hi, > > Is it possible to define an Event which should fire when a value of a > variable changes? Something like below > > > > self.Bind(wx.EVT_ON_VAL_CHANGE, variable_to_watch, self.Callback) > > > > I need a Text ctrl UI which conti

Re: surprising behaviour of global dictionaries

2012-10-09 Thread Peter Otten
Grant Edwards wrote: > On 2012-10-09, Peter Otten <__pete...@web.de> wrote: > >> Welcome to python -- this is a trap every newbie falls into ;) >> >> Seriously, you shouldn't use the main script as a library; > > There must be something wrong with me. It never even occurred to me > to try to im

Getting ipython notebook to plot inline

2012-10-09 Thread Frank Franklin
I've just managed to install ipython and get it to run by typing ipython notebook --pylab=inline Now I'm getting the following error when I try to plot something in ipython notebook: AttributeError: 'module' object has no attribute 'FigureCanvas' I've tried using imports to make this work:

Re: Generating C++ code

2012-10-09 Thread Andrea Crotti
On 10/09/2012 05:00 PM, Jean-Michel Pichavant wrote: Greetings, I'm trying to generate C++ code from an XML file. I'd like to use a template engine, which imo produce something readable and maintainable. My google search about this subject has been quite unsuccessful, I've been redirected to t

Re: Generating C++ code

2012-10-09 Thread Etienne Robillard
On Tue, 09 Oct 2012 20:55:48 +0100 Andrea Crotti wrote: > On 10/09/2012 05:00 PM, Jean-Michel Pichavant wrote: > > Greetings, > > > > I'm trying to generate C++ code from an XML file. I'd like to use a > > template engine, which imo produce something readable and maintainable. > > My google sear

share with friends

2012-10-09 Thread admin
HotNet1 hi, join small social bookmarking and share best links with pepole. Please share your friends.We are waiting for you. thank you HotNet1 team http://www.hotnet1.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Private methods

2012-10-09 Thread Steven D'Aprano
On Tue, 09 Oct 2012 11:08:13 -0600, Ian Kelly wrote: > On Tue, Oct 9, 2012 at 8:08 AM, Demian Brecht > wrote: >> A single underscore semantically means private. A double underscore >> will name mangle the function such that it's only accessible strictly >> by name through the class that it's defi

Re: Private methods

2012-10-09 Thread Demian Brecht
On 12-10-09 04:51 PM, Steven D'Aprano wrote: Really? I tend to view name mangling as a waste of time, and complex inheritance structures as something to avoid. Yep, I've been coming around to this as of late. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.o

an error in python lib?

2012-10-09 Thread Wenhua Zhao
Hi list, I just noticed that in /usr/lib/python2.7/threading.py class _Condition(_Verbose): ... def _is_owned(self): # Return True if lock is owned by current_thread. # This method is called only if __lock doesn't have _is_owned(). if self.__lock.acquire(0):

Re: IDLE Crashing in Mac OS 10.8.2 with 2.7.3

2012-10-09 Thread Kevin Walzer
On 10/9/12 11:27 AM, bkee...@gmail.com wrote: I've tried all the usual suspect of uninstalling and reinstalling IDLE and Python 2.7.3, but my IDLE environment always crashes unexpectedly on Mac OS X 10.8. Where did you get Python? What version of Tcl/Tk do you have installed? Is it the one f

Porting notmm to pep 3333 and mod_wsgi

2012-10-09 Thread Etienne Robillard
Hi, Has PEP- introduced backward incompatibilities or changes in unicode encoding and decoding or should this updated pep require python 3 to make mod_wsgi working with wsgi 1.0 (pep-333) scripts ? Moreover is it possible to use python 2.7 with mod_wsgi at all without the utf-8 encoding er

Re: an error in python lib?

2012-10-09 Thread MRAB
On 2012-10-10 01:32, Wenhua Zhao wrote: Hi list, I just noticed that in /usr/lib/python2.7/threading.py class _Condition(_Verbose): ... def _is_owned(self): # Return True if lock is owned by current_thread. # This method is called only if __lock doesn't have _is_owne

communicate with external process via pty

2012-10-09 Thread Tim Arnold
I have an external process, 'tralics' that emits mathml when you feed it latex equations. I want to get that mathml into a string. The problem for me is that tralics wants to talk to a tty and I've never done that before; it basically starts its own subshell. I have the following code which w

lxml 3.0 final released - efficient XML and HTML processing with Python

2012-10-09 Thread Stefan Behnel
Hi everyone, it's been a while since the last stable release series appeared, so I'm proud to announce the final release of lxml 3.0. http://lxml.de/ http://pypi.python.org/pypi/lxml/3.0 Changelog: http://lxml.de/changes-3.0.html In short, lxml is the most feature-rich and easy-to-use library