Re: Compare source code

2010-11-05 Thread rustom
On Nov 5, 8:25 am, Terry Reedy wrote: > On 11/4/2010 10:47 PM, Rustom Mody wrote: > > > As far as I am concerned python would not be python if its > > indentation=structure went.  However the original question -- mixing > > tabs and spaces is bad -- has got lost in the flames.  Do the most > > die

Re: Final state of underlying sequence in islice

2010-11-05 Thread Raymond Hettinger
>  Shashank Singh wrote: > > > Are there any promises made with regard to final state of the underlying > > sequence that islice slices? Currently, there are no promises or guarantees about the final state of the iterator. To the extent the pure Python version in the docs differs from the CPytho

Re: functions, list, default parameters

2010-11-05 Thread Steven D'Aprano
On Thu, 04 Nov 2010 22:34:07 +, Mark Wooding wrote: > (Based on experience with other languages, I suspect that evaluating the > default expression afresh for each call where it's needed would be more > useful; but it's way too late to change that now.) Let's call the two strategies: default

Re: Hello, Everyone. I have a problem when using Pexpect module.

2010-11-05 Thread dachuan
maybe i found why pexpect doesn't work in my environment. (but still, i don't know how solve it) my machine is actually a xen domain U, whose kernel is host's kernel. when I test pexpect module directly on host machine, it works pretty fine. and that's all I can do about it, maybe pexpect use ps

Re: Popen Question

2010-11-05 Thread Chris Torek
In article <891a9a80-c30d-4415-ac81-bddd0b564...@g13g2000yqj.googlegroups.com> moogyd wrote: >[sde:st...@lbux03 ~]$ python >Python 2.6 (r26:66714, Feb 21 2009, 02:16:04) >[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 >Type "help", "copyright", "credits" or "license" for more information.

Re: Compare source code

2010-11-05 Thread Alain Ketterlin
Terry Reedy writes: > If you add the normally redundant information in the form of explicit > dedents (anything starting with '#' and distinguishable from normal > comments), then it is not too hard to re-indent even after all indents > have been removed. I actually use such a trick in emacs, no

Re: Compare source code

2010-11-05 Thread Steven D'Aprano
On Fri, 05 Nov 2010 11:21:57 +0100, Alain Ketterlin wrote: > I really like "indentation as structure" (code is more compact and > clearer), but I really hate that it relies on me putting the right > spaces at the right place. Er what? You really like indentation as structure, but you don't like

Re: Compare source code

2010-11-05 Thread Steven D'Aprano
On Thu, 04 Nov 2010 21:47:59 +, Tim Harig wrote: > I have seen huge patches caused by nothing more then some edit that > accidently added a trailing space to a large number of lines. White > space mangling happens all the time without people even knowing about > it. How does an edit accident

Re: Compare source code

2010-11-05 Thread Steven D'Aprano
On Thu, 04 Nov 2010 20:17:35 +, Seebs wrote: >> * I /do/ have a significant problem with cutting and pasting code in >> Python. In most languages, I can haul a chunk of code about, hit >> C-M-q, and Emacs magically indents the result properly. This is, >> unfortunately, impossi

Re: Tools for turning Python code into XMI?

2010-11-05 Thread Stefan Schwarzer
Hi Lawrence, I missed your answer because I didn't expect someone to respond after all this time. :-) On 2010-10-30 04:07, Lawrence D'Oliveiro wrote: >> I'm looking for a tool which can read Python files and write >> a corresponding XMI file for import into UML tools. > > UML ... isn’t that some

Re: Compare source code

2010-11-05 Thread Alain Ketterlin
Steven D'Aprano writes: >> I really like "indentation as structure" (code is more compact and >> clearer), but I really hate that it relies on me putting the right >> spaces at the right place. > > Er what? You really like indentation as structure, but you don't like > putting in the indentation

Re: functions, list, default parameters

2010-11-05 Thread Mark Wooding
Steven D'Aprano writes: > defaults initialise on function definition (DID) > defaults initialise on function call (DIC) > > I claim that when designing a general purpose language, DID (Python's > existing behaviour) is better than DIC: > > #1 Most default values are things like True, False, None

Re: Why "flat is better than nested"?

2010-11-05 Thread J. Gerlach
Am 28.10.2010 03:40, schrieb Steven D'Aprano: > [ snip a lot of wise words ] Can I put this (translated) in the german python wiki? I guess it might help more people to understand some decisions taken during python's development - and I'm to lazy to do something similar myself ;) Greetings from B

Re: How convert list to nested dictionary?

2010-11-05 Thread Boris Borcic
Arnaud Delobelle wrote: macm writes: Hi Folks How convert list to nested dictionary? l ['k1', 'k2', 'k3', 'k4', 'k5'] result {'k1': {'k2': {'k3': {'k4': {'k5': {}} Regards macm reduce(lambda x,y: {y:x}, reversed(l), {}) d={} while L : d={L.pop():d} -- http://mail.python.org/

Silly newbie question - Carrot character (^)

2010-11-05 Thread Matty Sarro
Hey Everyone, Just curious - I'm working on a program which includes a calculation of a circle, and I found myself trying to use pi*radius^2, and getting errors that data types float and int are unsupported for "^". Now, I realized I was making the mistake of using '^' instead of "**". I've correct

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Krister Svanlund
On Fri, Nov 5, 2010 at 2:43 PM, Matty Sarro wrote: > Hey Everyone, > Just curious - I'm working on a program which includes a calculation of a > circle, and I found myself trying to use pi*radius^2, and getting errors > that data types float and int are unsupported for "^". Now, I realized I was >

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Vlastimil Brom
2010/11/5 Matty Sarro : > Hey Everyone, > Just curious - I'm working on a program which includes a calculation of a > circle, and I found myself trying to use pi*radius^2, and getting errors > that data types float and int are unsupported for "^". Now, I realized I was > making the mistake of using

Re: How convert list to nested dictionary?

2010-11-05 Thread Peter Otten
Boris Borcic wrote: > Arnaud Delobelle wrote: >> macm writes: >> >>> Hi Folks >>> >>> How convert list to nested dictionary? >>> >> l >>> ['k1', 'k2', 'k3', 'k4', 'k5'] >> result >>> {'k1': {'k2': {'k3': {'k4': {'k5': {}} >>> >>> Regards >>> >>> macm >> >> reduce(lambda x,y: {y:x}, re

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Daniel Urban
> However, what exactly does ^ do? Bitwise XOR: http://docs.python.org/py3k/reference/expressions.html#binary-bitwise-operations -- http://mail.python.org/mailman/listinfo/python-list

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread D'Arcy J.M. Cain
On Fri, 5 Nov 2010 09:43:25 -0400 Matty Sarro wrote: > now working. However, what exactly does ^ do? I know its used in regular > expressions but I can't seem to find anything about using it as an operator. It's the XOR operator. Try "help('^')" for more detail. By the way, it's "caret", not "c

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Shashwat Anand
On Fri, Nov 5, 2010 at 7:26 PM, Krister Svanlund wrote: > On Fri, Nov 5, 2010 at 2:43 PM, Matty Sarro wrote: > > Hey Everyone, > > Just curious - I'm working on a program which includes a calculation of a > > circle, and I found myself trying to use pi*radius^2, and getting errors > > that data

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Matty Sarro
Thanks everyone, that explains it :) -Matty On Fri, Nov 5, 2010 at 9:43 AM, Matty Sarro wrote: > Hey Everyone, > Just curious - I'm working on a program which includes a calculation of a > circle, and I found myself trying to use pi*radius^2, and getting errors > that data types float and int ar

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Philip Semanchuk
On Nov 5, 2010, at 9:43 AM, Matty Sarro wrote: > Hey Everyone, > Just curious - I'm working on a program which includes a calculation of a > circle, and I found myself trying to use pi*radius^2, and getting errors > that data types float and int are unsupported for "^". Now, I realized I was > ma

Re: newbie qns : how do i use xmldiff?

2010-11-05 Thread No Name
I had to do some fishing around to figure this much out. Hope it helps. from input import * # From the xmldiff directory from fmes import * # From the xmldiff directory from format import *# From the xmldiff directory from StringIO import * # Build your original tree text1 = '123' st

What is the best way to handle a missing newline in the following case

2010-11-05 Thread chad
I have an text file with the following numbers 1 3 5 7 3 9 Now the program reads in this file. When it encounters a '\n', it will do some stuff and then move to the next line. For example, it will read 1 and then '\n'. When it sees '\n', it will do some stuff and go on to read 3. The problem i

Re: What is the best way to handle a missing newline in the following case

2010-11-05 Thread Peter Otten
chad wrote: > I have an text file with the following numbers > > 1 > 3 > 5 > 7 > 3 > 9 > > > > Now the program reads in this file. When it encounters a '\n', it will > do some stuff and then move to the next line. For example, it will > read 1 and then '\n'. When it sees '\n', it will do some

Re: What is the best way to handle a missing newline in the following case

2010-11-05 Thread danmcle...@yahoo.com
> The problem is when I get to the last line. When the program sees '\n' > after the 9, everything works fine. However, when there isn't a '\n', > the program doesn't process the last line. > > What would be the best approach to handle the case of the possible > missing '\n' at the end of the file?

Re: What is the best way to handle a missing newline in the following case

2010-11-05 Thread Paul Rudin
"danmcle...@yahoo.com" writes: >> The problem is when I get to the last line. When the program sees '\n' >> after the 9, everything works fine. However, when there isn't a '\n', >> the program doesn't process the last line. >> >> What would be the best approach to handle the case of the possible

Re: What is the best way to handle a missing newline in the following case

2010-11-05 Thread Neil Cerutti
On 2010-11-05, Paul Rudin wrote: > "danmcle...@yahoo.com" writes: >>> The problem is when I get to the last line. When the program >>> sees '\n' after the 9, everything works fine. However, when >>> there isn't a '\n', the program doesn't process the last >>> line. >>> >>> What would be the best

Re: How convert list to nested dictionary?

2010-11-05 Thread macm
Hi Folks thanks a lot all. All solutions work fine. while I am doing my home work. Reading "Learning Python" and much more. Let me ask again to close my doubts: >>> l = ['k1', 'k2', 'k3', 'k4', 'k5'] >>> d = reduce(lambda x,y: {y:x}, reversed(l), {'/':[1,2,3]}) >>> d {'k1': {'k2': {'k3': {'k4':

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Peter Pearson
On Fri, 5 Nov 2010 10:12:05 -0400, Philip Semanchuk wrote: > > BTW the more common name for this character is caret (ka-RAY). Yes, it's caret, but no, it's KA-rit, almost the same as carrot. It's straight from Latin, with no detour through French. -- To email me, substitute nowhere->spamcop, in

How to get dynamically-created fxn's source?

2010-11-05 Thread gb345
For a project I'm working on I need a way to retrieve the source code of dynamically generated Python functions. (These functions are implemented dynamically in order to simulate "partial application" in Python.[1]) The ultimate goal is to preserve a textual record of transformations performed

Exception handling with NameError

2010-11-05 Thread Zeynel
Hello, I want to append new input to list SESSION_U without erasing its content. I try this: ... try: SESSION_U.append(UNIQUES) except NameError: SESSION_U = [] SESSION_U.append(UNIQUES) ... I would think that at first try I would get the NameEr

Re: Exception handling with NameError

2010-11-05 Thread Peter Otten
Zeynel wrote: > I want to append new input to list SESSION_U without erasing its > content. I try this: > > ... > try: > SESSION_U.append(UNIQUES) > except NameError: > SESSION_U = [] > SESSION_U.append(UNIQUES) > ... > I would think that at fir

Re: How to get dynamically-created fxn's source?

2010-11-05 Thread Emile van Sebille
On 11/5/2010 9:55 AM gb345 said... In any case, the problem remains of how to extract the dynamically-generated function's source code. Are you looking for the source code of the dynamically created wrapper function (effectively the piece that calls the original function) or of the wrapped

Re: How to get dynamically-created fxn's source?

2010-11-05 Thread Peter Otten
gb345 wrote: > For a project I'm working on I need a way to retrieve the source > code of dynamically generated Python functions. (These functions > are implemented dynamically in order to simulate "partial application" > in Python.[1]) The ultimate goal is to preserve a textual record > of tran

Re: How convert list to nested dictionary?

2010-11-05 Thread Peter Otten
macm wrote: > thanks a lot all. All solutions work fine. > > while I am doing my home work. > Reading "Learning Python" and much more. > > Let me ask again to close my doubts: > l = ['k1', 'k2', 'k3', 'k4', 'k5'] d = reduce(lambda x,y: {y:x}, reversed(l), {'/':[1,2,3]}) d > {'k1'

Re: Compare source code

2010-11-05 Thread Tim Harig
On 2010-11-05, Steven D'Aprano wrote: > On Thu, 04 Nov 2010 21:47:59 +, Tim Harig wrote: > >> I have seen huge patches caused by nothing more then some edit that >> accidently added a trailing space to a large number of lines. White >> space mangling happens all the time without people even k

Re: Compare source code

2010-11-05 Thread Grant Edwards
On 2010-11-05, Tim Harig wrote: > On 2010-11-05, Steven D'Aprano wrote: >> On Thu, 04 Nov 2010 21:47:59 +, Tim Harig wrote: >> >>> I have seen huge patches caused by nothing more then some edit that >>> accidently added a trailing space to a large number of lines. White >>> space mangling ha

Re: Exception handling with NameError

2010-11-05 Thread Zeynel
On Nov 5, 1:26 pm, Peter Otten <__pete...@web.de> wrote: > Of course I'm only guessing because you don't provide enough context. > > Peter Thanks. This is the problem I am having, in general: K = [] # a container list K = ["A", "B"] ARCHIVE = [] # a list where items from K is archived ARCHIV

Re: Compare source code

2010-11-05 Thread Tim Harig
On 2010-11-04, D'Arcy J.M. Cain wrote: > On Thu, 4 Nov 2010 19:37:25 + (UTC) > Tim Harig wrote: >> On 2010-11-04, D'Arcy J.M. Cain wrote: >> You are the one who seems to be on a crusade against against braces. It > > You totally misunderstand me. I am not on a crusade of any sort. I am I

decimal.py ver 2.6,2.7 not working with python 2.7

2010-11-05 Thread robert roze
I have a 'Python 2.7' installed. It seems like the decimal.py module that comes with the Python2.7 package is not working. I hope I'm wrong, but here's why I think so: If I simply try to import the module, I get this error: >>> import decimal Traceback (most recent call last): File "", line

ANN: Leo 4.8 beta 1 released

2010-11-05 Thread Edward K. Ream
Leo 4.8 beta 1 is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.8: -- - Leo n

Re: Compare source code

2010-11-05 Thread Tim Harig
On 2010-11-05, Alain Ketterlin wrote: > Terry Reedy writes: > >> If you add the normally redundant information in the form of explicit >> dedents (anything starting with '#' and distinguishable from normal >> comments), then it is not too hard to re-indent even after all indents >> have been remo

Using %x to format number to hex and number of digits

2010-11-05 Thread Matty Sarro
I'm currently trying to convert a digit from decimal to hex, however I need the full 4 digit hex form. Python appears to be shortening the form. Example: num = 10 num = "%x"%(num) print(num) >a num = 10 num = "%#x"%(num) print(num) >0xa I need it to output as 0x0a, and the exercise is requirin

Re: Compare source code

2010-11-05 Thread Tim Harig
On 2010-11-05, Grant Edwards wrote: > On 2010-11-05, Tim Harig wrote: >> On 2010-11-05, Steven D'Aprano wrote: >>> On Thu, 04 Nov 2010 21:47:59 +, Tim Harig wrote: >>> I have seen huge patches caused by nothing more then some edit that accidently added a trailing space to a large n

Re: decimal.py ver 2.6,2.7 not working with python 2.7

2010-11-05 Thread Chris Rebert
On Fri, Nov 5, 2010 at 10:50 AM, robert roze wrote: > I have a 'Python 2.7' installed. > > It seems like the decimal.py module that comes with the Python2.7 package is > not working. I hope I'm wrong, but here's why I think so: > > If I simply try to import the module, I get this error: > imp

Re: Compare source code

2010-11-05 Thread Emile van Sebille
On 11/5/2010 11:13 AM Tim Harig said... It is simply hard for me to accept that your solution is better when it is telling us that we have to abandon thousands of tools that other solutions manage to work with without difficulty. I only work with a few tools none of which alter or strip leading

Re: Compare source code

2010-11-05 Thread John Nagle
On 11/5/2010 3:41 AM, Steven D'Aprano wrote: On Thu, 04 Nov 2010 20:17:35 +, Seebs wrote: * I /do/ have a significant problem with cutting and pasting code in Python. In most languages, I can haul a chunk of code about, hit C-M-q, and Emacs magically indents the result properl

Re: Compare source code

2010-11-05 Thread Seebs
On 2010-11-05, Steven D'Aprano wrote: > How does an edit accidentally add a trailing space to a large number of > lines? I would love to know the answer to this question. However, empirically, it happens. My guess would be cutting and pasting in some way. > So we keep coming back to work-arou

Re: Compare source code

2010-11-05 Thread Seebs
On 2010-11-05, Steven D'Aprano wrote: > On Thu, 04 Nov 2010 20:17:35 +, Seebs wrote: >> That was the thing which bit me the worst. I had a fairly large block >> of code in a first-pass ugly program. I wanted to start refactoring it, >> so I moved a big hunk of code into a method (with plans

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Philip Semanchuk
On Nov 5, 2010, at 12:43 PM, Peter Pearson wrote: > On Fri, 5 Nov 2010 10:12:05 -0400, Philip Semanchuk wrote: >> >> BTW the more common name for this character is caret (ka-RAY). > > Yes, it's caret, but no, it's KA-rit, almost the same as > carrot. It's straight from Latin, with no detour th

Re: Compare source code

2010-11-05 Thread Seebs
On 2010-11-05, Emile van Sebille wrote: > So, which of your tools are you married to that are causing your issues? Python. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia

Re: How convert list to nested dictionary?

2010-11-05 Thread macm
Hi Peter Thanks a lot for your tips and codes, Cake Recipes are good to learn! So I post just basic issues. Hopping a good soul like you can help me! But I am still learning... : ) Best Regards macm On 5 nov, 15:40, Peter Otten <__pete...@web.de> wrote: > macm wrote: > > thanks a lot all. Al

Re: Using %x to format number to hex and number of digits

2010-11-05 Thread Chris Rebert
On Fri, Nov 5, 2010 at 11:23 AM, Matty Sarro wrote: > I'm currently trying to convert a digit from decimal to hex, however I need > the full 4 digit hex form. Python appears to be shortening the form. > Example: > > num = 10 > num = "%x"%(num) > print(num) > >>a > > num = 10 > num = "%#x"%(num) >

Re: Compare source code

2010-11-05 Thread Grant Edwards
On 2010-11-05, Seebs wrote: > On 2010-11-05, Emile van Sebille wrote: >> So, which of your tools are you married to that are causing your issues? > > Python. I think you should quit using Python and choose a language that works with whatever tools are causing all your white-space corruption prob

Re: Using %x to format number to hex and number of digits

2010-11-05 Thread Grant Edwards
On Fri, Nov 5, 2010 at 11:23 AM, Matty Sarro wrote: > I'm currently trying to convert a digit from decimal to hex, however I need > the full 4 digit hex form. Python appears to be shortening the form. > Example: > > num = 10 > num = "%x"%(num) > print(num) > >>a > > num = 10 > num = "%#x"%(num) >

RE: decimal.py ver 2.6,2.7 not working with python 2.7

2010-11-05 Thread robert roze
Hi Chris, Aha! yes, you figured it out. My PYTHONPATH env variable had an old experiment in it, which happened to be called numbers.py. Take it out, and decimal.py works fine. Thank you, Bob >What does the following output for you?: > >import numbers >print(numbers.__file__) >print(dir(numbe

Re: Using %x to format number to hex and number of digits

2010-11-05 Thread Matty Sarro
I actually was able to get it working a few minutes after posting the question. My apologies for not posting a followup :) I ended up using the following format: num = 10 num = "%#0.2x"%(num) print(num) It works, however I'm not sure if it'd be considered very "pythonic" or not. Thanks for your t

Re: Compare source code

2010-11-05 Thread Ethan Furman
Tim Harig wrote: The use of whitespace was a stylistic change and stylistic holy wars exist because it is almost impossible to prove that any reasonable style has benefit over another. That whitespace causes issues is verifiable. I find it hard to concluded that that whitespace based syntax is

Re: Compare source code

2010-11-05 Thread D'Arcy J.M. Cain
On Fri, 5 Nov 2010 18:13:44 + (UTC) Tim Harig wrote: > > care about. If no one was on a crusade to convince people that > > indentation as syntax (can we call is IAS from now on?) was evil then I > > wouldn't be posting anything at all on the subject. I am being totally > > reactionary here.

*** glibc detected *** gdb: malloc(): smallbin double linked list

2010-11-05 Thread John Reid
Hi, I've compiled Python 2.7 (r27:82500, Nov 2 2010, 09:00:37) [GCC 4.4.3] on linux2 with the following configure options ./configure --prefix=/home/john/local/python-dbg --with-pydebug I've installed numpy and some other packages but when I try to run my extension code under gdb I get the er

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Matty Sarro
It's ok, people who refer to a labret piercing as a "la-BRAY" piercing are also incorrect. It's pronounced lab-RET, as its base word is the latin "labretta." French as a language shall doom us all :) On Fri, Nov 5, 2010 at 2:54 PM, Philip Semanchuk wrote: > > On Nov 5, 2010, at 12:43 PM, Peter Pe

Re: How convert list to nested dictionary?

2010-11-05 Thread macm
Ok. Done >>> def appendNested(nest, path, val): ... nest2 = nest ... for key in path[:-1]: ... nest2 = nest2[key] ... nest2[path[-1]].append(val) ... return nest ... >>> >>> l = ['k1','k2','k3','k4','k5'] >>> ndict = reduce(lambda x,y: {y:x}, reversed(l), {'/':[1,2,3]}) >>

Re: Using %x to format number to hex and number of digits

2010-11-05 Thread Tim Chase
On 11/05/10 13:23, Matty Sarro wrote: I'm currently trying to convert a digit from decimal to hex, however I need the full 4 digit hex form. Python appears to be shortening the form. Example: num = 10 num = "%x"%(num) print(num) a num = 10 num = "%#x"%(num) print(num) 0xa I need it to ou

Re: Compare source code

2010-11-05 Thread Ian
On Nov 5, 12:35 pm, John Nagle wrote: >     INTERLISP's editor allowed the user to select a block of > LISP code and make it into a function.  The selected block > would be analyzed to determine which local variables it referenced, > and a new function would be created with those parameters.  The

Re: How convert list to nested dictionary?

2010-11-05 Thread Arnaud Delobelle
Peter Otten <__pete...@web.de> writes: > Boris Borcic wrote: > >> Arnaud Delobelle wrote: >>> macm writes: >>> Hi Folks How convert list to nested dictionary? >>> l ['k1', 'k2', 'k3', 'k4', 'k5'] >>> result {'k1': {'k2': {'k3': {'k4': {'k5': {}}

Re: Final state of underlying sequence in islice

2010-11-05 Thread Terry Reedy
On 11/5/2010 4:58 AM, Raymond Hettinger wrote: Shashank Singh wrote: Are there any promises made with regard to final state of the underlying sequence that islice slices? Currently, there are no promises or guarantees about the final state of the iterator. I interpret the current doc sta

Re: Using %x to format number to hex and number of digits

2010-11-05 Thread Grant Edwards
On 2010-11-05, Tim Chase wrote: > On 11/05/10 13:23, Matty Sarro wrote: >>> I'm currently trying to convert a digit from decimal to hex, >>> however I need the full 4 digit hex form. Python appears to >>> be shortening the form. >>> Example: >>> >>> num = 10 >>> num = "%x"%(num) >>> print(num) >>>

Re: Compare source code

2010-11-05 Thread Seebs
On 2010-11-05, Ethan Furman wrote: > The verifiable benefit for me is ease of use, ease of thought, ease of > typing... I realize these are not benefits for everyone, but they are > for some -- and I would venture a guess that the ease of thought benefit > is one of the primary reasons Python i

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Terry Reedy
On 11/5/2010 9:43 AM, Matty Sarro wrote: Hey Everyone, Just curious - I'm working on a program which includes a calculation of a circle, and I found myself trying to use pi*radius^2, and getting errors that data types float and int are unsupported for "^". Now, I realized I was making the mistake

Re: Compare source code

2010-11-05 Thread Seebs
On 2010-11-05, D'Arcy J.M. Cain wrote: > The simple fact is that the combination of your tools and Python is > broken. The combination of my tools and Python is not. That's lucky > for me since I really, really like IAS. That's unlucky for people who > have to work with tools that mangle code.

Re: Compare source code

2010-11-05 Thread Seebs
On 2010-11-05, Grant Edwards wrote: > On 2010-11-05, Seebs wrote: >> On 2010-11-05, Emile van Sebille wrote: >>> So, which of your tools are you married to that are causing your issues? >> Python. > I think you should quit using Python and choose a language that works > with whatever tools are

Re: Compare source code

2010-11-05 Thread Terry Reedy
On 11/5/2010 3:33 PM, D'Arcy J.M. Cain wrote: my language. Use Perl or C or even pybraces. http://timhatch.com/projects/pybraces/ "I work with a guy who hates Python's significant whitespace and wishes that he could just use curly braces." I am offering no solutions. Except you just did

Re: Final state of underlying sequence in islice

2010-11-05 Thread Raymond Hettinger
On Nov 5, 1:05 pm, Terry Reedy wrote: > > Currently, there are no promises or guarantees about the final state > > of the iterator. > > I interpret the current doc statement as a promise that becomes > ambiguous when step > 1. You may have missed my point. I wrote the tools, the docs, and the te

Re: decimal.py ver 2.6,2.7 not working with python 2.7

2010-11-05 Thread Terry Reedy
On 11/5/2010 3:14 PM, robert roze wrote: Aha! yes, you figured it out. My PYTHONPATH env variable had an old experiment in it, which happened to be called numbers.py. Take it out, and decimal.py works fine. Python has a large test suite in Lib/test, which includes test_decimal.py. It is run d

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Nobody
On Fri, 05 Nov 2010 10:12:05 -0400, Philip Semanchuk wrote: > As others have said, ^ is for XOR. That's buried here in the > documentation: > http://docs.python.org/release/2.7/reference/... > > Not that I would have expected you to find it there since that's pretty > dense. In fact, older versio

Re: *** glibc detected *** gdb: malloc(): smallbin double linked list

2010-11-05 Thread Nobody
On Fri, 05 Nov 2010 19:39:12 +, John Reid wrote: > I've compiled > Python 2.7 (r27:82500, Nov 2 2010, 09:00:37) [GCC 4.4.3] on linux2 > > with the following configure options > ./configure --prefix=/home/john/local/python-dbg --with-pydebug > > I've installed numpy and some other packages b

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Philip Semanchuk
On Nov 5, 2010, at 5:21 PM, Nobody wrote: > On Fri, 05 Nov 2010 10:12:05 -0400, Philip Semanchuk wrote: > >> As others have said, ^ is for XOR. That's buried here in the >> documentation: >> http://docs.python.org/release/2.7/reference/... >> >> Not that I would have expected you to find it the

Re: ANN: PyQt v4.8.1 Released

2010-11-05 Thread Lawrence D'Oliveiro
In message , Дамјан Георгиевски wrote: >>> PyQt is available under the GPL and a commercial license. >> >> Surely you mean “proprietary” rather than “commercial”. There is >> nothing about the GPL that prevents “commercial” use. > > I think he means a license that *he* sells comercially :) Pre

Re: Final state of underlying sequence in islice

2010-11-05 Thread Ian
On Nov 5, 2:51 pm, Raymond Hettinger wrote: > You may have missed my point.  I wrote the tools, the docs, and the > tests. > If you interpret a "promise" in text, I can assure you it was not > intended.  The behavior *is* undefined because I never defined it. > I'm happy to clarify the docs to mak

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Seebs
On 2010-11-05, Nobody wrote: > However, it's still written for language lawyers. > IMHO, the lack of a reference manual for the language itself is a major > hole in Python's documentation. I'm a bit lost here. Could you highlight some of the differences between "a reference manual for the langu

[ANN] Lupa 0.17 released - Lua in Python

2010-11-05 Thread Stefan Behnel
Hi all, I am happy to announce the release of Lupa 0.17, Lua in Python. http://pypi.python.org/pypi/lupa/0.17 Have fun, Stefan What is Lupa? -- Lupa integrates the LuaJIT2 runtime [1] into CPython. It is a rewrite of LunaticPython in Cython with several advanced features. Thi

Re: Compare source code

2010-11-05 Thread D'Arcy J.M. Cain
On 05 Nov 2010 20:14:47 GMT Seebs wrote: > I can just see how well this attitude must work in other circumstances: I guess this message ends the topic for me. Bye. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 4

Re: Final state of underlying sequence in islice

2010-11-05 Thread Raymond Hettinger
On Nov 5, 3:52 pm, Ian wrote: > On Nov 5, 2:51 pm, Raymond Hettinger wrote: > > > You may have missed my point.  I wrote the tools, the docs, and the > > tests. > > If you interpret a "promise" in text, I can assure you it was not > > intended.  The behavior *is* undefined because I never defined

Re: Using %x to format number to hex and number of digits

2010-11-05 Thread Tim Chase
On 11/05/10 15:10, Grant Edwards wrote: On 2010-11-05, Tim Chase wrote: On 11/05/10 13:23, Matty Sarro wrote: I need it to output as 0x0a, and the exercise is requiring me to use %x to format the string. Any help would be appreciated. Though it feels hokey to me, using "%#04x" % 10 wor

Regular expression

2010-11-05 Thread Paul Hemans
I need to extract the quoted text from : _("get this") The following works: re.compile( "_\(['\"]([^'\"]+)['\"]\)" ) However, I don't want to match if there is A-Z or a-z or 0-9 or _ immediately preceding the "_" so I have tried: "[^0-9a-zA-Z]*_\(['\"]([^'\"]+)['\"]\)" "[^\w]{0,1}_\(['\"]([^'\"]+

Re: Why "flat is better than nested"?

2010-11-05 Thread Steven D'Aprano
On Fri, 05 Nov 2010 14:19:47 +0100, J. Gerlach wrote: > Am 28.10.2010 03:40, schrieb Steven D'Aprano: >> [ snip a lot of wise words ] > > Can I put this (translated) in the german python wiki? I guess it might > help more people to understand some decisions taken during python's > development - a

Re: Lupa 0.17 released - Lua in Python

2010-11-05 Thread Carl Banks
On Nov 5, 4:21 pm, Stefan Behnel wrote: > Hi all, > > I am happy to announce the release of Lupa 0.17, Lua in Python. > > http://pypi.python.org/pypi/lupa/0.17 > > Have fun, > > Stefan Thanks, interesting projection. Good idea. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare source code

2010-11-05 Thread Steven D'Aprano
On Thu, 04 Nov 2010 19:37:25 +, Tim Harig wrote: > Examples of communication channels that mangle white space abound. Yes. So what? If your communication channel mangles your data, change your communication channel, don't expect users of clean communication channels to hand-enter error-corr

Re: Compare source code

2010-11-05 Thread Steven D'Aprano
On Thu, 04 Nov 2010 17:45:58 +, Tim Harig wrote: >>> Python is the only language that I know that *needs* to specify tabs >>> versus spaces since it is the only language I know of which uses >>> whitespace formating as part of its syntax and structure. [...] > I am also aware of other langauge

Re: Compare source code

2010-11-05 Thread Steven D'Aprano
On Fri, 05 Nov 2010 18:45:39 +, Seebs wrote: > On 2010-11-05, Steven D'Aprano > wrote: >> On Thu, 04 Nov 2010 20:17:35 +, Seebs wrote: >>> That was the thing which bit me the worst. I had a fairly large block >>> of code in a first-pass ugly program. I wanted to start refactoring >>> it

Re: Regular expression

2010-11-05 Thread MRAB
On 06/11/2010 01:25, Paul Hemans wrote: I need to extract the quoted text from : _("get this") The following works: re.compile( "_\(['\"]([^'\"]+)['\"]\)" ) However, I don't want to match if there is A-Z or a-z or 0-9 or _ immediately preceding the "_" so I have tried: "[^0-9a-zA-Z]*_\(['\"]([^'

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Steven D'Aprano
On Fri, 05 Nov 2010 22:51:10 +, Seebs wrote: > On 2010-11-05, Nobody wrote: >> However, it's still written for language lawyers. > >> IMHO, the lack of a reference manual for the language itself is a major >> hole in Python's documentation. > > I'm a bit lost here. Could you highlight some

Using Python for a demonstration in historical linguistics

2010-11-05 Thread Dax Bloom
Hello, In the framework of a project on evolutionary linguistics I wish to have a program to process words and simulate the effect of sound shift, for instance following the Rask's-Grimm's rule. I look to have python take a dictionary file or a string input and replace the consonants in it with th

Re: Using Python for a demonstration in historical linguistics

2010-11-05 Thread Chris Rebert
On Fri, Nov 5, 2010 at 7:17 PM, Dax Bloom wrote: > Hello, > > In the framework of a project on evolutionary linguistics I wish to > have a program to process words and simulate the effect of sound > shift, for instance following the Rask's-Grimm's rule. I look to have > python take a dictionary fi

Re: Using Python for a demonstration in historical linguistics

2010-11-05 Thread MRAB
On 06/11/2010 02:17, Dax Bloom wrote: Hello, In the framework of a project on evolutionary linguistics I wish to have a program to process words and simulate the effect of sound shift, for instance following the Rask's-Grimm's rule. I look to have python take a dictionary file or a string input

Re: Compare source code

2010-11-05 Thread Steven D'Aprano
On Fri, 05 Nov 2010 08:17:02 +0530, Rustom Mody wrote: > However the original question -- mixing tabs and spaces is bad -- has > got lost in the flames. Do the most die-hard python fanboys deny this? > And if not is it asking too much (say in python3) that mixing tabs and > spaces be flagged as

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Philip Semanchuk
On Nov 5, 2010, at 6:51 PM, Seebs wrote: > On 2010-11-05, Nobody wrote: >> However, it's still written for language lawyers. > >> IMHO, the lack of a reference manual for the language itself is a major >> hole in Python's documentation. > > I'm a bit lost here. Could you highlight some of the

Re: Compare source code

2010-11-05 Thread Seebs
On 2010-11-06, Steven D'Aprano wrote: > On Fri, 05 Nov 2010 18:45:39 +, Seebs wrote: >> On 2010-11-05, Steven D'Aprano >> wrote: >>> Well there's your problem -- you are relying on tools that operate by >>> magic. >> Wrong. > Really? Then how did the logic get screwed up from a mere copy-an

  1   2   >