Re: Tuples and immutability

2014-02-27 Thread Marko Rauhamaa
John O'Hagan : > Same object, just a different name - but a different result. I get > why, but still find that odd. The general principle is stated in the language specification: http://docs.python.org/3.2/reference/simple_stmts.html #augmented-assignment-statements>: Also, when possib

Re: Can global variable be passed into Python function?

2014-02-27 Thread Marko Rauhamaa
Chris Angelico : > Simple rule of thumb: Never use 'is' with strings or ints. They're > immutable, their identities should be their values. Playing with 'is' > will only confuse you, unless you're specifically going for > introspection and such. Here's a use case for "is" with strings (or ints):

Re: extend methods of decimal module

2014-02-27 Thread Steven D'Aprano
On Fri, 28 Feb 2014 16:00:10 +1100, Chris Angelico wrote: > If we had some other tag, like 'd', we could actually construct a > Decimal straight from the source code. Since source code is a string, > it'll be constructed from that string, and it'll never go via float. Now that Python has a fast C

Re: Can global variable be passed into Python function?

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 4:39 PM, Mark H. Harris wrote: > On Thursday, February 27, 2014 10:43:23 PM UTC-6, Chris Angelico wrote: > >> Simple rule of thumb: Never use 'is' with strings or ints. They're >> immutable, their identities should be their values. Playing with 'is' >> will only confuse you

Re: posting code snippets

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 9:15 AM, Ben Finney wrote: > Since you'll be posting the code in-line, make sure it's short. Since > it'll be short, make sure it's complete — we should need nothing else to > run the code and expect to see the same behaviour you're seeing. > > Since you'll be making it sho

Re: Can global variable be passed into Python function?

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 10:43:23 PM UTC-6, Chris Angelico wrote: > Simple rule of thumb: Never use 'is' with strings or ints. They're > immutable, their identities should be their values. Playing with 'is' > will only confuse you, unless you're specifically going for > introspection and su

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 4:18 PM, Mark H. Harris wrote: > do I make the assumption that all functions will take a string as argument > and then let interactive users bare the responsibility to enter a string or > decimal... avoiding floats... Just have your users pass in Decimal objects. They ca

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 10:26:59 PM UTC-6, Chris Angelico wrote: > Create Decimal values from strings, not from the str() of a float, > which first rounds in binary and then rounds in decimal. > Thanks Chris... another excellent point... ok, you guys have about convinced me (which is sp

Re: Tuples and immutability

2014-02-27 Thread John O'Hagan
On Thu, 27 Feb 2014 18:19:09 +0200 Marko Rauhamaa wrote: > Eric Jacoboni : > > a_tuple[1] += [20] > > Traceback (most recent call last): > > File "", line 1, in > > TypeError: 'tuple' object does not support item assignment > > > > [...] > > > > But, then, why a_tuple is still modified?

Re: posting code snippets

2014-02-27 Thread Dave Angel
"Mark H. Harris" Wrote in message: > my isp withdrew the post service (nntp) from their server at end of 2011... > and I didn't notice till now! ha! So, I'm not using seamonkey any > longer... using google groups/ and that has been a fit to get used to, but > I'm making progress. > >

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 3:41 PM, Mark H. Harris wrote: > So, I am thinking I need to mods... maybe an idmath.py for interactive > sessions, and then dmath.py for for running within my scientific scripts... > ?? No; the solution is to put quotes around your literals in interactive mode, too.

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 9:15:36 PM UTC-6, Steven D'Aprano wrote: > Decimal uses base 10, so it is a better fit for numbers we > write out in base 10 like "0.12345", but otherwise it suffers from the > same sort of floating point rounding issues as floats do. > > > py> Decimal('1.2345'

Re: Can global variable be passed into Python function?

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 1:29 PM, Mark H. Harris wrote: > a=1024 > b=a > b=1024 > a is b > False No no no no! They're not pointing to the same integer any more. Now, if you change the "b=1024" from being a mostly-useless assignment (to another int with the same value) into being a comparison, then

Re: end quote help for a newbie

2014-02-27 Thread alex23
On 27/02/2014 8:41 PM, Chris Angelico wrote: On Thu, Feb 27, 2014 at 9:30 PM, Peter Clark wrote: # Dragons and dungeons, based on CP/M program messages from ca. 1966 # This version designed and produced by peter clark beginning in December 2013 def startandload(n):# introduce program and all

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 1:15 PM, Mark H. Harris wrote: > Its just easier to type D(2.78) than Deciaml('2.78'). It's easier to type 2.78 than 2.718281828, too, but one of them is just plain wrong. Would you tolerate using 2.78 for e because it's easier to type? I mean, it's gonna be close. Creat

Output JSON-schema from bottle application?

2014-02-27 Thread Alec Taylor
Are there libraries for doing this? I would like to autogenerate JSON-schema for use inside an API explorer. However whenever there is a schema change; I would only like to change the schema in one place (where possible). E.g.: For use here - https://github.com/salesking/json-schema-browser How

Re: extend methods of decimal module

2014-02-27 Thread Steven D'Aprano
On Thu, 27 Feb 2014 15:00:45 -0800, Mark H. Harris wrote: > Decimal does not keep 0.1 as a floating point format (regardless of > size) which is why banking can use Decimal without having to worry about > the floating formatting issue... in other words, 0.0 is not stored in > Decimal as any k

References, and avoiding use of “variable” (was: Can global variable be passed into Python function?)

2014-02-27 Thread Ben Finney
"Mark H. Harris" writes: > So, yeah, thinking about variables is just not going away. Right. I would like, ideally, for the Python documentation to avoid mentioning that term entirely; and I would hope for that to promote a better understanding of Python's data model. The wider programming comm

Re: Can global variable be passed into Python function?

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 8:07:20 PM UTC-6, Steven D'Aprano wrote: > If they point to the same piece of memory -- which, by the way, can be > moved around if the garbage collector supports it -- then A is B cannot > possibly return False. > hi Steve, long time, yes, my whole point exac

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 5:50:55 PM UTC-6, Oscar Benjamin wrote: > . . . Calling Decimal on a float performs an exact binary to > decimal conversion. Your reasoning essentially assumes that every > float should be interpreted as an approximate representation for a > nearby decimal value.

RE: Descriptor type hinting

2014-02-27 Thread Joseph L. Casale
> Surely the answer will depend on the linter you are using. Care to tell > us, or shall we guess? Hey Steven, I am using PyCharm, I have to admit I feel silly on this one. I had a buried assignment that overrode the inferred type. It wasn't until a fresh set of eyes confirmed something was awry

Re: Can global variable be passed into Python function?

2014-02-27 Thread Steven D'Aprano
On Thu, 27 Feb 2014 15:29:01 -0800, Mark H. Harris wrote: > Knowing that A points to an int, and > that B=A, now B points to the VERY SAME int... they are references > pointing to the same piece of memory. And of course we want new folks to > understand the issue of: A==B > True > A is B > False

Re: Descriptor type hinting

2014-02-27 Thread Steven D'Aprano
On Thu, 27 Feb 2014 22:21:31 +, Joseph L. Casale wrote: > How does one satisfy a lint/type checker with the return value of a > class method decorated with a descriptor? Surely the answer will depend on the linter you are using. Care to tell us, or shall we guess? -- Steven -- https://m

Re: exec and locals

2014-02-27 Thread Steven D'Aprano
On Fri, 28 Feb 2014 00:29:35 +1300, Gregory Ewing wrote: > Steven D'Aprano wrote: >> On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote: >> >>>Why not just use this version all the time? It should work in both 2.x >>>and 3.x. >> >> Because that's yucky. It's an aesthetic thing: when support

Re: Extracting parts of string between anchor points

2014-02-27 Thread Denis McMahon
On Fri, 28 Feb 2014 00:55:01 +, Denis McMahon wrote: > The code in the file at the url below processes 17 different cases. It > may help, or it may confuse. > http://www.sined.co.uk/tmp/strparse.py.txt I added some more cases to it, and then realised that the code could actually be simplifi

Re: Extracting parts of string between anchor points

2014-02-27 Thread Denis McMahon
On Thu, 27 Feb 2014 20:07:56 +, Jignesh Sutar wrote: > I've kind of got this working but my code is very ugly. I'm sure it's > regular expression I need to achieve this more but not very familiar > with use regex, particularly retaining part of the string that is being > searched/matched for.

Re: extend methods of decimal module

2014-02-27 Thread Oscar Benjamin
On 27 February 2014 23:00, Mark H. Harris wrote: > On Thursday, February 27, 2014 10:24:23 AM UTC-6, Oscar Benjamin wrote: > > from decimal import Decimal as D >> >>> D(0.1) >> Decimal('0.155511151231257827021181583404541015625') > > hi Oscar, well, that's not what I'm doing

Re: extend methods of decimal module

2014-02-27 Thread Wolfgang
On Friday, February 28, 2014 12:00:45 AM UTC+1, Mark H. Harris wrote: > On Thursday, February 27, 2014 10:24:23 AM UTC-6, Oscar Benjamin wrote: > from decimal import Decimal as D > > > >>> D(0.1) > > > Decimal('0.155511151231257827021181583404541015625') > > > > hi Oscar,

Re: Can global variable be passed into Python function?

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 11:54:44 AM UTC-6, Ned Batchelder wrote: > Mark, thanks for helping to answer the OP's question. We've covered (in > depth) in the rest of this thread, that Python *does* have the concept > of a variable, it just behaves differently than some other popular > pro

Re: posting code snippets

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 4:15:16 PM UTC-6, Ben Finney wrote: > > Post your code in-line with your message. This is for the sake of the > people whose time you're requesting, and of later readers who will find > the thread when searching the archives -- URLs to snippets are likely to > be in

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 10:24:23 AM UTC-6, Oscar Benjamin wrote: from decimal import Decimal as D > >>> D(0.1) > Decimal('0.155511151231257827021181583404541015625') > hi Oscar, well, that's not what I'm doing with my D()... I'm not just making D() mimic Decimal.

Re: Functions help

2014-02-27 Thread Rhodri James
On Tue, 25 Feb 2014 02:18:43 -, Dennis Lee Bieber wrote: On Mon, 24 Feb 2014 01:01:15 -, "Rhodri James" declaimed the following: The function "range" returns the sequence of numbers 1, 2, 3, 4 and 5 [*], so this has the same effect as if you had typed: Wrong -- it

Descriptor type hinting

2014-02-27 Thread Joseph L. Casale
How does one satisfy a lint/type checker with the return value of a class method decorated with a descriptor? It returns a dict, and I want the type hinting to suggest this versus the str|unknown its defaults to. Thanks, jlc -- https://mail.python.org/mailman/listinfo/python-list

Re: Tuples and immutability

2014-02-27 Thread Ian Kelly
On Thu, Feb 27, 2014 at 2:47 PM, Nick Timkovich wrote: > On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico wrote: >> >> On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni >> wrote: >> > But, imho, it's far from being a intuitive result, to say the least. >> >> It's unintuitive, but it's a consequence

Re: posting code snippets

2014-02-27 Thread Ben Finney
"Mark H. Harris" writes: >Its been too long... can't remember... are there rules here about >posting code snippets, or length considerations, and so forth? Post your code in-line with your message. This is for the sake of the people whose time you're requesting, and of later readers who

Re: Extracting parts of string between anchor points

2014-02-27 Thread Tim Chase
On 2014-02-27 15:45, Tim Chase wrote: > >>> r = re.compile(r"^([^:]*)(?::((?:(?!-:-).)*)(?:-:-(.*))?)?") If you want to compare both the re method and the string method, here's a test-harness to play with: import re examples = [ ("", (None, None, None)), ("Test1A", ("Test1A", None, No

Re: Deepcopying a byte string is quicker than copying it - problem?

2014-02-27 Thread Terry Reedy
On 2/27/2014 4:02 AM, Frank Millman wrote: However, deepcopying a byte string is orders of magnitude quicker than copying it. Actually, looking closer, it is the 'copy' that is slow, not the 'deepcopy' that is quick.. I have created an issue on the bug tracker - http://bugs.python.org/issue2

Re: Tuples and immutability

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 8:47 AM, Nick Timkovich wrote: > On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico wrote: >> >> On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni >> wrote: >> > But, imho, it's far from being a intuitive result, to say the least. >> >> It's unintuitive, but it's a consequence

Python VM university project

2014-02-27 Thread Dániel Bali
Hello! I hope this is the right place to ask about this, sorry if it's inappropriate. At our University we have to do a project for a class called Virtual Execution Environments. We decided that it would be great to work with/on the Python VM. The project has to revolve around one of the followin

Re: Tuples and immutability

2014-02-27 Thread Nick Timkovich
On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico wrote: > On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni > wrote: > > But, imho, it's far from being a intuitive result, to say the least. > > It's unintuitive, but it's a consequence of the way += is defined. If > you don't want assignment, don't

Re: Extracting parts of string between anchor points

2014-02-27 Thread Tim Chase
On 2014-02-27 20:07, Jignesh Sutar wrote: > I've kind of got this working but my code is very ugly. I'm sure > it's regular expression I need to achieve this more but not very > familiar with use regex, particularly retaining part of the string > that is being searched/matched for. While I suppose

Re: Extracting parts of string between anchor points

2014-02-27 Thread Cameron Simpson
On 27Feb2014 20:07, Jignesh Sutar wrote: > I've kind of got this working but my code is very ugly. I'm sure it's > regular expression I need to achieve this more but not very familiar with > use regex, particularly retaining part of the string that is being > searched/matched for. Regexps are qui

Extracting parts of string between anchor points

2014-02-27 Thread Jignesh Sutar
I've kind of got this working but my code is very ugly. I'm sure it's regular expression I need to achieve this more but not very familiar with use regex, particularly retaining part of the string that is being searched/matched for. Notes and code below to demonstrate what I am trying to achieve.

Re:How to run multiple virtualenv in product server

2014-02-27 Thread Dave Angel
YE SHANG Wrote in message: > I'm starting to learn virtualenv, I wonder how run python project developed > in virtualenv. > > Here is my situation, there is a server we can access with a common user name > and password, there are many py scripts wrote by different people on this > server. >

Re: Can global variable be passed into Python function?

2014-02-27 Thread Ned Batchelder
On 2/27/14 8:24 AM, Mark H. Harris wrote: As others have noted, python does not have a 'variable' concept (references to objects instead) and so your question is a little ambiguous. Mark, thanks for helping to answer the OP's question. We've covered (in depth) in the rest of this thread, t

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 4:07 AM, Terry Reedy wrote: > On 2/27/2014 7:07 AM, Mark H. Harris wrote: > >> Oh, and one more thing... whoever is doing the work on IDLE these >> days, nice job! It is stable, reliable, and just works/ >> appreciate it! > > > As one of 'them', thank you for the feedback

Re: extend methods of decimal module

2014-02-27 Thread Terry Reedy
On 2/27/2014 7:07 AM, Mark H. Harris wrote: Oh, and one more thing... whoever is doing the work on IDLE these days, nice job! It is stable, reliable, and just works/ appreciate it! As one of 'them', thank you for the feedback. There are still some bugs, but I hit them seldom enough that I a

Re: Tuples and immutability

2014-02-27 Thread Zachary Ware
On Thu, Feb 27, 2014 at 10:27 AM, Eric Jacoboni wrote: > Le 27/02/2014 17:13, Zachary Ware a écrit : >> >> You're not the first person to have this question :) >> >> http://docs.python.org/3/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works >> > > Oh yes, i wa

Re: Tuples and immutability

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni wrote: > But, imho, it's far from being a intuitive result, to say the least. It's unintuitive, but it's a consequence of the way += is defined. If you don't want assignment, don't use assignment :) ChrisA -- https://mail.python.org/mailman/listinf

Re: Tuples and immutability

2014-02-27 Thread Eric Jacoboni
Le 27/02/2014 17:13, Zachary Ware a écrit : > > You're not the first person to have this question :) > > http://docs.python.org/3/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works > Oh yes, i was aware of this explanation (thanks to Chris for his answer, too

Re: extend methods of decimal module

2014-02-27 Thread Oscar Benjamin
On 27 February 2014 15:42, Mark H. Harris wrote: > On Thursday, February 27, 2014 8:42:55 AM UTC-6, Oscar Benjamin wrote: > >> >> Some points: > >Thanks so much... you have clarified some things I was struggling with... > >> 1) Why have you committed the code as a .tar.gz file? > > um, to

Re: Tuples and immutability

2014-02-27 Thread Marko Rauhamaa
Eric Jacoboni : a_tuple[1] += [20] > Traceback (most recent call last): > File "", line 1, in > TypeError: 'tuple' object does not support item assignment > > [...] > > But, then, why a_tuple is still modified? That's because the += operator 1. modifies the list object in place 2. tri

Re: Tuples and immutability

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 3:01 AM, Eric Jacoboni wrote: > I'm using Python 3.3 and i have a problem for which i've still not found > any reasonable explanation... > a_tuple = ("spam", [10, 30], "eggs") a_tuple[1] += [20] > Traceback (most recent call last): > File "", line 1, in > TypeE

Re: Tuples and immutability

2014-02-27 Thread Zachary Ware
On Thu, Feb 27, 2014 at 10:01 AM, Eric Jacoboni wrote: > Hi, > > I'm using Python 3.3 and i have a problem for which i've still not found > any reasonable explanation... > a_tuple = ("spam", [10, 30], "eggs") a_tuple[1] += [20] > Traceback (most recent call last): > File "", line 1, in

Tuples and immutability

2014-02-27 Thread Eric Jacoboni
Hi, I'm using Python 3.3 and i have a problem for which i've still not found any reasonable explanation... >>> a_tuple = ("spam", [10, 30], "eggs") >>> a_tuple[1] += [20] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment Ok... I

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 2:42 AM, Mark H. Harris wrote: >> 1) Why have you committed the code as a .tar.gz file? > > um, to save space... well, I know its tiny, but its just a habit I > have... 5kb instead of 25kb... When you commit changes, though, it has to treat it as a completely changed

Re: posting code snippets

2014-02-27 Thread Tim Chase
On 2014-02-27 04:13, Mark H. Harris wrote: > are there rules here about posting code snippets, or length > considerations, and so forth? Seems like there was a place to share > code snips outside of the message area? This is the internet, so you're welcome to post code as you please. However, b

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 8:42:55 AM UTC-6, Oscar Benjamin wrote: > > Some points: Thanks so much... you have clarified some things I was struggling with... > 1) Why have you committed the code as a .tar.gz file? um, to save space... well, I know its tiny, but its just a habit I ha

How to run multiple virtualenv in product server

2014-02-27 Thread YE SHANG
I'm starting to learn virtualenv, I wonder how run python project developed in virtualenv. Here is my situation, there is a server we can access with a common user name and password, there are many py scripts wrote by different people on this server. If I develop my python project with virtual

Re: posting code snippets

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 9:01:50 AM UTC-6, Jerry Hill wrote: > -- > > Jerry Thanks guys, perfect. 'preciate it! -- https://mail.python.org/mailman/listinfo/python-list

Re: posting code snippets

2014-02-27 Thread Jerry Hill
On Thu, Feb 27, 2014 at 7:13 AM, Mark H. Harris wrote: > hi folks, >Its been too long... can't remember... are there rules here about posting > code snippets, or length considerations, and so forth? Chris' advice about just posting your code inline with your message is good. If the problem

ANN: Python Job Board - Call for volunteers

2014-02-27 Thread M.-A. Lemburg
[Please help spread the word by forwarding to other relevant mailing lists, user groups, etc. world-wide; thanks :-)] Dear Python Community, for many years, the Python Job board (http://legacy.python.org/community/jobs/) was run by volunteers - most of the time by just one volunteer at a time un

Re: extend methods of decimal module

2014-02-27 Thread Oscar Benjamin
On 27 February 2014 12:07, Mark H. Harris wrote: > > I have created a project here: > > https://code.google.com/p/pythondecimallibrary/ > > I wrote a dmath.py library module for use with the C accelerated decimal > module, that I would like to see merged into the C Python distribution so > that

Re: Can global variable be passed into Python function?

2014-02-27 Thread Mark H. Harris
On Friday, February 21, 2014 12:37:59 AM UTC-6, Sam wrote: > I need to pass a global variable into a python function. However, the global > variable does not seem to be assigned after the function ends. Is it because > parameters are not passed by reference? How can I get function parameters to

Re: SSH/Telnet program to Router/switch

2014-02-27 Thread Rodrick Brown
Sent from my iPhone > On Feb 20, 2014, at 5:59 AM, Ferrous Cranus wrote: > > Τη Τετάρτη, 19 Φεβρουαρίου 2014 10:45:53 π.μ. UTC+2, ο χρήστης Wojciech > Łysiak έγραψε: >>> On 19.02.2014 09:14, Sujith S wrote: >>> >>> Hi, >> >> >>> I am new to programming and python. I am looking for a python

Re: posting code snippets

2014-02-27 Thread Chris Angelico
On Thu, Feb 27, 2014 at 11:13 PM, Mark H. Harris wrote: > hi folks, >Its been too long... can't remember... are there rules here about posting > code snippets, or length considerations, and so forth? >Seems like there was a place to share code snips outside of the message > area? The co

posting code snippets

2014-02-27 Thread Mark H. Harris
hi folks, Its been too long... can't remember... are there rules here about posting code snippets, or length considerations, and so forth? Seems like there was a place to share code snips outside of the message area? A related question, is there a python repository for uploading p

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Wednesday, February 19, 2014 4:10:22 PM UTC-6, Terry Reedy wrote: > Or just dmath. I think this is a better idea than suggesting additions > to decimal itself. For one thing, anything put in decimal would be > subject to change if the function were to be added to the standard. It > is worth

Re: exec and locals

2014-02-27 Thread Chris Angelico
On Thu, Feb 27, 2014 at 10:29 PM, Gregory Ewing wrote: > Steven D'Aprano wrote: >> >> On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote: >> >>> Why not just use this version all the time? It should work in both 2.x >>> and 3.x. >> >> >> Because that's yucky. It's an aesthetic thing: when sup

Re: exec and locals

2014-02-27 Thread Gregory Ewing
Steven D'Aprano wrote: On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote: Why not just use this version all the time? It should work in both 2.x and 3.x. Because that's yucky. It's an aesthetic thing: when supported, I want the Python interpreter to manage the context manager. More y

Re: Python : parsing the command line options using optparse

2014-02-27 Thread Ganesh Pal
> > They must be running an older version of FreeBSD since the default version > of python is 2.7. > > There is a FreeBSD package for argparse, the command would be something > like >pkg_add -r install py26-argparse > > > Rod > > Yes Iam running a older version of FreeBSD ( Iam actually run

Re: end quote help for a newbie

2014-02-27 Thread Chris Angelico
On Thu, Feb 27, 2014 at 9:30 PM, Peter Clark wrote: > Hi, I have just started trying to use python version 3, under windows XP, I > have got a simple script (attached) to run as I want in Interpreter mode. > It is saved as a .py file. If I double click on the file the python screen > opens and app

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Wednesday, February 19, 2014 4:29:27 PM UTC-6, Oscar Benjamin wrote: > Actually the performance difference isn't as big as you might think. > > Oscar You're right. At least my own benchmark on my native exp() vs the built-in was about ~same ~same. I was hoping that Stefan had used FFT...

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
> > Have you looked at the gmpy2 ( https://code.google.com/p/gmpy/ ) module? > > casevh No... was not aware of gmpy2... looks like a great project! I am wondering why it would be sooo much faster? I was hoping that Stefan Krah's C accelerator was using FFT fast fourier transforms for mul

Re: Deepcopying a byte string is quicker than copying it - problem?

2014-02-27 Thread Florian Leitner
On 27.02.14, 7:30 , Frank Millman wrote: > Hi all > > I noticed this a little while ago, but dismissed it as a curiosity. > On reflection, I decided to mention it here in case it indicates a > problem. > > This is with python 3.3.2. > > C:\>python -m timeit -s "import copy" "copy.copy('a'*1000)"

Re: end quote help for a newbie

2014-02-27 Thread Peter Clark
On Thursday, 30 January 2014, 21:27, Peter Clark wrote:   Thank-you.  Please no-one reply to this post.  I just want to put on record my complete p-offed-ness, that having spent 10 days sorting out and hypertexting a library of documentation, I now have to start all over. Please do not respond,

Re: exec and locals

2014-02-27 Thread Alister
On Thu, 27 Feb 2014 00:31:56 +, Steven D'Aprano wrote: > On Wed, 26 Feb 2014 14:00:59 +, Alister wrote: > >> On Wed, 26 Feb 2014 13:15:25 +, Steven D'Aprano wrote: >> >>> I have to dynamically generate some code inside a function using exec, >>> but I'm not sure if it is working by a

Re: Deepcopying a byte string is quicker than copying it - problem?

2014-02-27 Thread Frank Millman
"Frank Millman" wrote in message news:lemm11$18r$1...@ger.gmane.org... > Hi all > > I noticed this a little while ago, but dismissed it as a curiosity. On > reflection, I decided to mention it here in case it indicates a problem. > > This is with python 3.3.2. > > C:\>python -m timeit -s "impor

Re: Deepcopying a byte string is quicker than copying it - problem?

2014-02-27 Thread Peter Otten
Frank Millman wrote: > Hi all > > I noticed this a little while ago, but dismissed it as a curiosity. On > reflection, I decided to mention it here in case it indicates a problem. > > This is with python 3.3.2. > > C:\>python -m timeit -s "import copy" "copy.copy('a'*1000)" > 10 loops, best

Re: Deepcopying a byte string is quicker than copying it - problem?

2014-02-27 Thread Ian Kelly
On Wed, Feb 26, 2014 at 11:30 PM, Frank Millman wrote: > Hi all > > I noticed this a little while ago, but dismissed it as a curiosity. On > reflection, I decided to mention it here in case it indicates a problem. > > This is with python 3.3.2. > > C:\>python -m timeit -s "import copy" "copy.copy(