Python 101 - the book kickstarter
I am writing a beginner / intermediate book for Python and would like to announce the Kickstarter project in support of the book: http://kck.st/1kX98BB Thanks! Mike -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Sphinx 1.2.2 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, I'm delighted to announce the release of Sphinx 1.2.2, now available on the Python package index at http://pypi.python.org/pypi/Sphinx. It includes about 12 bug fixes for the 1.2 release series, among them a regression in 1.2.1. What is it? === Sphinx is a tool that makes it easy to create intelligent and beautiful documentation for Python projects (or other documents consisting of multiple reStructuredText source files). Website: http://sphinx-doc.org/ IRC: #sphinx-doc on irc.freenode.net What's new in 1.2 (very short version)? === - - Dropped Python 2.4 support - - Added Python 3.3 support - - Improvement of internationalization - - Improvement of builders: html, texinfo, latex and gettext. - - Added builders: xml and pseudoxml - - Added sphinx.ext.linkcode extension - - Added more non-ASCII code point characters path support - - Added theme plugin mechanism - - Added and update 10 locales - - Added experimental support for parallel building with a new -j option - - Added docs: detailed Installing Sphinx and Sphinx Developer's Guide For the full changelog, go to http://sphinx-doc.org/changes.html. Thanks to all collaborators and contributors! cheers, Georg -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) iEYEARECAAYFAlMS4x8ACgkQN9GcIYhpnLAS6wCeNQgU9l7QrYrLhxX7OgiMVLuY fIAAoI+/BMhDyw2dzAv0TCRrRbxW/uFU =7IYV -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: Python Job Board - Call for volunteers
[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 until they moved on to spend their time on other things. We've now reached such a point again. In these years, the volume on the job board has significantly increased, as it got more and more popular. It is now at around 2-5 postings per day and most of those positions get filled quickly - which is an indication of how useful this service is to the Python community. To scale up and revive the job board, the PSF would now like to setup a *team of volunteers* to run the job board and this is our call for help. How does the job board work ? - At the moment, the job board is maintained on the legacy site (http://legacy.python.org/community/jobs/), but since we've launched our brand new website (http://www.python.org/), we'd like to move the job board over to that site. Instead of the repository based approach used on the old site, the new site has database support to aid in more easily processing and filing job listings. There's a job board mailing list which helps coordinate the task of reviewing and filing job offers. Currently, all job submissions get sent to this mailing list, but with the job board app, the submission process can be moved over to the website's database. What does it take to run the job board ? You have to review the job postings, request changes if they are too long, don't clearly state the need for Python skills, or have quality issues. After review, the job board app will then allow posting the jobs on the website by simply setting the status to published. Communication with the submitters is usually done by email and via the mailing list, so all team members can see the communication and help out if necessary. Please note: This is just a high level overview. The details need to be hashed out by the new team. Does the job board app work already ? - It does, but is disabled at the moment due to lack of volunteers. Since the site just launched there may also well be some issues with the job board app. On the positive side there's a lot happening around the site at the moment, so if you have change requests, these will usually be implemented quickly - or you can jump in, hack on the job board app and submit a pull request yourself: https://github.com/python/pythondotorg/tree/master/jobs These are exciting times and this is your chance to make a difference ! Ok, I like new challenges - where do I sign up ? Great :-) Please write to j...@python.org I have a question... If you have questions, you can write me or the PSF board at p...@python.org. Many thanks, -- Marc-Andre Lemburg Director Python Software Foundation http://www.python.org/psf/ -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: asyncio 0.4.1 released
With the help of Paul Moore there is now also a 64-bit Windows wheel file on the site: https://pypi.python.org/pypi?name=asyncioversion=0.4.1:action=display On Mon, Feb 24, 2014 at 11:01 AM, Guido van Rossum gu...@python.org wrote: *** NOTE: Python 3.3 only! This module is in the stdlib in Python 3.4. *** On the heels of Python 3.4.0rc2, I've put a new version of the asyncio package for Python 3.3 on PyPI: https://pypi.python.org/pypi/asyncio/0.4.1 There's a source distro and a 32-bit Windows wheel. (For 64-bit Windows I could use some help.) About asyncio: it's a new stdlib module for asynchronous I/O based on the yield from statement that was added to Python 3.3. It was inspired by Twisted and the async support in Tornado (amongst other influences). The original code name for the project is Tulip and this is where the latest developments happen: http://code.google.com/p/tulip/. Also check out PEP 3156: http://python.org/dev/peps/pep-3156/. For Python 2 and 3.2, Victor Stinner has created a backport named Trollius: https://pypi.python.org/pypi/trollius/0.1.5 -- --Guido van Rossum (python.org/~guido) -- --Guido van Rossum (python.org/~guido) -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[RELEASED] Python 3.3.5 release candidate 2
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team, I'm happy to announce the release of Python 3.3.5, release candidate 2. Python 3.3.5 includes a fix for a regression in zipimport in 3.3.4 (see http://bugs.python.org/issue20621) and a few other bugs. Python 3.3 includes a range of improvements of the 3.x series, as well as easier porting between 2.x and 3.x. In total, almost 500 API items are new or improved in Python 3.3. For a more extensive list of changes in the 3.3 series, see http://docs.python.org/3.3/whatsnew/3.3.html To download Python 3.3.5 visit: http://www.python.org/download/releases/3.3.5/ This is a preview release, please report any bugs to http://bugs.python.org/ The final release is scheduled one week from now. Enjoy! - -- Georg Brandl, Release Manager georg at python.org (on behalf of the entire python-dev team and 3.3's contributors) -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) iEYEARECAAYFAlMUUKoACgkQN9GcIYhpnLD5OACfTpRkcM9aXUx2XbiXoZtIgSE7 BqwAnjwpAuqc9lKJ0O3XOw5qDvDPYsNb =EGuB -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Decoding a process output
On 03/04/2014 05:05 PM, Peter Otten wrote: Francis Moreau wrote: Hi, In my understanding (I'm relatively new to python), I need to decode any bytes data provided, in my case, by a shell command (such as findmnt) started by the subprocess module. The goal of my application is to parse the command outputs. My application runs only on linux BTW and should run fine on both python 2.7 and py3k. My question is when decoding the output bytes data of the external command, which encoding should I use ? Should I guess the encoding by inspecting LANG or any LC_* environment variables ? Should I force one of those environment variable to a specific value before running my external command ? Thanks for any tips. You can use locale.getpreferredencoding(), which seems to evaluate LANG: $ python3 -c 'import locale; print(locale.getpreferredencoding())' UTF-8 $ LANG= python3 -c 'import locale; print(locale.getpreferredencoding())' ANSI_X3.4-1968 Hmm I'm confused here: when unsetting or changing LANG, the encoding is changed on the fly that makes me wonder which part of the linux system encodes the command output. I don't think it's the latter, is the libc ? Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wed, 05 Mar 2014 08:37:42 +0200, Marko Rauhamaa wrote: MRAB pyt...@mrabarnett.plus.com: Into how many versions did Lisp split in its first 23 years? :-) I'm partial to Scheme, but I'll take any version. If you had tried Python 30 years ago, you'd give it up for any serious work because it would be so slow and consume so much memory. /facepalm Python is only 23 years old, so it would have been a good trick to have tried it 30 years ago. While it was slow back then, it used LESS memory, not more. (Trading off more memory for speed is one of the ways that Python has gotten faster.) Nevertheless, people did use it for serious work, at least by the time it got to version 1.4 and quite likely much earlier. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
Following up on my own post. On Wed, 05 Mar 2014 07:52:01 +, Steven D'Aprano wrote: On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: I stopped paying attention to mathematicians when they tried to convince me that the sum of all natural numbers is -1/12. [...] In effect, the author Mark Carrol-Chu in the GoodMath blog above wants to make the claim that the divergent sum is not equal to ζ(-1), but everywhere you find that divergent sum in your calculations you can rub it out and replace it with ζ(-1), which is -1/12. In other words, he's accepting that the divergent sum behaves *as if* it were equal to -1/12, he just doesn't want to say that it *is* equal to -1/12. Is this a mere semantic trick, or a difference of deep and fundamental importance? Mark C-C thinks it's an important difference. Mathematicians who actually work on this stuff all the time think he's making a semantic trick to avoid facing up to the fact that sums of infinite sequences don't always behave like sums of finite sequences. Here's another mathematician who is even more explicit about what she's complaining about: http://blogs.scientificamerican.com/roots-of-unity/2014/01/20/is-the-sum-of-positive-integers-negative/ [quote] There is a meaningful way to associate the number -1/12 to the series 1+2+3+4…, but in my opinion, it is misleading to call it the sum of the series. [end quote] Evelyn Lamb's objection isn't about the mathematics that leads to the conclusion that the sum of natural numbers is equivalent to -1/12. That's conclusion is pretty much bulletproof. Her objection is over the use of the word equals to describe that association. Or possibly the use of the word sum to describe what we're doing when we replace the infinite series with -1/12. Whatever it is that we're doing, it doesn't seem to have the same behavioural properties as summing finitely many finite numbers. So perhaps she is right, and we shouldn't call the sum of a divergent series a sum? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
Steven D'Aprano st...@pearwood.info writes: On Wed, 05 Mar 2014 08:37:42 +0200, Marko Rauhamaa wrote: If you had tried Python 30 years ago, you'd give it up for any serious work because it would be so slow and consume so much memory. /facepalm Python is only 23 years old, so it would have been a good trick to have tried it 30 years ago. While it was slow back then, it used LESS memory, not more. Moreover, this is not an issue of Python the language as much as *implementations* (the CPython implementation has improved markedly in the intervening decades), and of *resources* very different then and now. The available CPU and memory resources for a language implementation is vastly greater today than 30 years ago. You could re-implement exactly the same compiler today as was run 30 years ago, and have its speed and memory performance remarkably better without any change in the language. If you'd run an implementation of *any* language of the time 30 years ago, it would have been far slower than implementations on today's hardware, and doubless improvements in the implementation (if the community was motivated to improve it for that long) would account for even greater speed differences. None of this is argument in favour of the changing applicability of the *language*, which is what Marko apparently wants to imply. -- \ “I got an answering machine for my phone. Now when someone | `\ calls me up and I'm not home, they get a recording of a busy | _o__) signal.” —Steven Wright | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional programming
Op 04-03-14 12:47, Steven D'Aprano schreef: On Tue, 04 Mar 2014 11:56:07 +0100, Antoon Pardon wrote: Op 04-03-14 09:56, Steven D'Aprano schreef: If you explicitly say that this is an int, then yes, that should be disallowed; It's that explicitly part that doesn't follow. Having to manage types is the most tedious, boring, annoying, *unproductive* part of languages like Java, C and Pascal. Almost always, you're telling the compiler stuff that it can work out for itself. In the same way writing unit tests is the most tedious, boring, annoying, *unproductive* part. Actually, I like writing unit tests. How do you know what the function does until you test it? I'm not a TDD fanatic, but often I write tests before I write the code, and there's really nothing nicer than seeing a whole lot of failing unit tests suddenly start working. You examine the code. Just like you examine the code to interfere the type. Well, maybe a nice BLT sandwich, when the bacon is nice and lean and the lettuce crisp and the tomato flavourful and not too soggy. But other than that, writing unit tests and seeing them pass is great. On the other hand, writing int n, m double x, y and similar three hundred times throughout your program is not terribly exciting. Even when it compiles, it doesn't mean it works. Even if your unit tests pass, that doesn't mean your program works. Amost always you are giving the program results it can work out for itself. Not even close. I'd like to see the compiler that can work out for itself that this function is buggy: Who said anything about buggy. If you want to test the function add1, what do you do? You call for example add1(5) and check that it is equal to 6. In other words you provide the result yourself you want the function to produce. def sine_rule(side_a, side_b, angle_a): Return the angle opposite side_b. return math.sin(side_b/side_a)*angle_a If you don't remember your Sine Rule from trigonometry, that's okay. Trust me, the function is badly wrong. It's rubbish really. But short of some really impressive AI coupled with a Mathematica-level of maths knowledge, how is the compiler supposed to know that? Static type testing, while valuable, cannot tell you that the program does what you wanted it to do. In the same way it can't interfere the return type you want the function to have. -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
Steven D'Aprano st...@pearwood.info: On Wed, 05 Mar 2014 08:37:42 +0200, Marko Rauhamaa wrote: If you had tried Python 30 years ago, you'd give it up for any serious work because it would be so slow and consume so much memory. /facepalm Python is only 23 years old, Some explorers roamed in Siberia around 1900 and encountered small nations with undocumented languages. They stayed with the people for some time and tried to record the basic vocabulary and grammar. The dialog sometimes went like this: - In your language, is it correct to say, I went fishing yesterday. - No. - What's wrong with it? - I didn't go fishing yesterday. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
Mathematics? The Flexible String Representation is a very nice example of a mathematical absurdity. jmf PS Do not even think to expect to contradict me. Hint: sheet of paper and pencil. -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional programming
Op 04-03-14 16:18, Steven D'Aprano schreef: Depends on the type: I suppose you can draw an analogy between records or structs and classes with no methods. But I'm not talking about creating types, I'm talking about type declarations. int x=2; # 2 is an int? Who would have guessed! How about: decimal[precision=4] x = 2.6; int[min = -10, max = 20] n = 7; -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: find and replace string in binary file
Thanks Emile. Unfortunately I have to use python 2.6 for this On Wednesday, 5 March 2014 00:13:00 UTC, emile wrote: On 03/04/2014 02:44 PM, Chris Angelico wrote: On Wed, Mar 5, 2014 at 12:18 AM, Peter Otten __pete...@web.de wrote: loial wrote: How do I read a binary file, find/identify a character string and replace it with another character string and write out to another file? Its the finding of the string in a binary file that I am not clear on. That's not possible. You have to convert either binary to string or string to binary before you can replace. Whatever you choose, you have to know the encoding of the file. If it's actually a binary file (as in, an executable, or an image, or something), then the *file* won't have an encoding, so you'll need to know the encoding of the particular string you want and encode your string to bytes. On 2.7 it's as easy as it sounds without having to think much about encodings and such. I find it mostly just works. emile@paj39:~$ which python /usr/bin/python emile@paj39:~$ python Python 2.7.3 (default, Sep 26 2013, 16:38:10) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. image = open('/usr/bin/python','rb').read() image.find(Type help, copyright, credits ) 1491592 image = image[:1491592]+Echo+image[1491592+4:] open('/home/emile/pyecho','wb').write(image) emile@paj39:~$ chmod a+x /home/emile/pyecho emile@paj39:~$ /home/emile/pyecho Python 2.7.3 (default, Sep 26 2013, 16:38:10) [GCC 4.7.2] on linux2 Echo help, copyright, credits or license for more information. YMMV, Emile -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers
On 3/5/14 4:00 AM, wxjmfa...@gmail.com wrote: Mathematics? The Flexible String Representation is a very nice example of a mathematical absurdity. jmf PS Do not even think to expect to contradict me. Hint: sheet of paper and pencil. Reminder to everyone: JMF makes no sense when he talks about the FSR, and absurdly seems to think hinting at paper and pencil will convince us he is right. Don't engage with him on this topic. -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional programming
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote in message news:5315eec0$0$29985$c3e8da3$54964...@news.astraweb.com... On Tue, 04 Mar 2014 13:30:04 +, BartC wrote: Isn't creating classes in Python similar to creating types elsewhere? Depends on the type: I suppose you can draw an analogy between records or structs and classes with no methods. But I'm not talking about creating types, I'm talking about type declarations. int x=2; # 2 is an int? Who would have guessed! Think of the int as a 'var' then: var x=2; Now you're just declaring the names. But writing 'var' as 'int' is exactly the same amount of work. However, in the sorts of languages that require you to describe types in this much detail, then the exact kind of type can be important: float/integer, signed/unsigned, short/long, character/numeric etc. Especially when declaring an array or struct element, or a pointer; in these cases, providing a sample value in initialisation data is more awkward (for one thing, because you need to initialise the instance, whereas a struct is usually declared separately as a type). But I agree that in many cases, an initialised declaration *could* often be used to infer the likely type without too much trouble: var x=2 # integer var y=3.0 # real var z=A # probably, a C-style string pointer ('char*') (And since I'm working on such a language at the moment, I felt obliged to implement exactly this. And yes, with 10 minutes' effort, something like this was working, to prove my assertion. However it is not satisfactory, which is one reason why no well-established static language is likely to adopt such a feature. It is just too untidy, too ad-hoc and undisciplined, to say that usually you need to provide an exact type, but sometimes, in such and such an instance, you don't need to bother!) -- Bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers
On 4 March 2014 23:20, Dave Angel da...@davea.name wrote: One problem with complexity claims is that it's easy to miss some contributing time eaters. I haven't done any measuring on modern machines nor in python, but I'd assume that multiplies take *much* longer for large integers, and that divides are much worse. So counting iterations isn't the whole story. Agreed but there's a big difference between log(N) iterations and N iterations! On the assumption that division by 2 is very fast, and that a general multiply isn't too bad, you could improve on Newton by observing that the slope is 2. err = n - guess * guess guess += err/2 I gues you mean like this: def sqrt(n): err = guess = 1 while err 1e-10: err = n - guess * guess guess += err/2 return guess This requires log2(10)*N iterations to get N digits. So the penalty for using division would have to be extreme in order for this to better. Using Decimal to get many digits we can write that as: def sqrt2(n, prec=1000): '''Solve x**2 = y''' eps = D(10) ** -(prec + 5) err = guess = D(1) with localcontext() as ctx: ctx.prec = prec + 10 while abs(err) eps: err = n - guess*guess guess += err/2 return guess This method works out much slower than Newton with division at 1 digits: 40s (based on a single trial) vs 80ms (timeit result). Some 37 years ago I microcoded a math package which included square root. All the math was decimal, and there was no hardware multiply or divide. The algorithm I came up with generated the answer one digit at a time, with no subsequent rounding needed. And it took just a little less time than two divides. For that architecture, Newton's method would've been too slow. If you're working with a fixed small precision then it might be. Incidentally, the algorithm did no divides, not even by 2. No multiplies either. Just repeated subtraction, sorta like divide was done. If anyone is curious, I'll be glad to describe the algorithm; I've never seen it published, before or since. I got my inspiration from a method used in mechanical, non-motorized, adding machines. My father had shown me that approach in the 50's. I'm curious. Oscar -- https://mail.python.org/mailman/listinfo/python-list
Re:find and replace string in binary file
loial jldunn2...@gmail.com Wrote in message: How do I read a binary file, find/identify a character string and replace it with another character string and write out to another file? Its the finding of the string in a binary file that I am not clear on. Any help appreciated I see from another message that you're using Python 2.6. That makes a huge difference and should have been in your query, along with a minimal code sample. Is the binary file under 100 MB or so? Then open it (in binary mode 'rb'), and read it. You'll now have a (large) byte string containing the entire file. The next question is whether you're sure that your search and replace strings are ASCII. Assuming that is probably a mistake, but it will get you started. Now the substitution is trivial: new_bytes = old_bytes.replace (search, replace) It's also possible to emulate that with find and slice, mainly if you need to report progress to the user. If the search and/or replace strings are not ASCII, you have to know what encoding the file may have used for them. You need to build a Unicode string, encode it the same way as the file uses, and then call the replace method. Now for a huge caveat. If you don't know the binary format, you're risking the creation of pure junk. Here are just two examples of what might go wrong, assuming the file is an executable. The same risks exist for other files, but I'm just supposing. If the two byte strings are not the same length, then all the remaining code and data in the file will be moved to a new spot. If you're lucky, the code will crash quickly, since all pointers referencing that code and data are incorrect. If some non-textual part of the file happens to match your search string you're going to likely trash that portion of the code. If the search string is large enough, maybe this is unlikely. But I recall taking the challenge of writing assembly programs which could be generated entirely from one or more type commands (msdos) -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional programming
On Wed, Mar 5, 2014 at 10:28 PM, BartC b...@freeuk.com wrote: But I agree that in many cases, an initialised declaration *could* often be used to infer the likely type without too much trouble: var x=2 # integer var y=3.0 # real var z=A # probably, a C-style string pointer ('char*') (And since I'm working on such a language at the moment, I felt obliged to implement exactly this. And yes, with 10 minutes' effort, something like this was working, to prove my assertion. However it is not satisfactory, which is one reason why no well-established static language is likely to adopt such a feature. It is just too untidy, too ad-hoc and undisciplined, to say that usually you need to provide an exact type, but sometimes, in such and such an instance, you don't need to bother!) C++ has something very like this, with the 'auto' keyword. It's not particularly useful for the examples you give, but can be much more so when you have templates, iterators, and so on - where the exact type declaration might be a couple dozen characters of pure syntactic salt, since you're initializing it to some function's return value. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional programming
Chris Angelico ros...@gmail.com: C++ has something very like this, with the 'auto' keyword. It's not particularly useful for the examples you give, but can be much more so when you have templates, iterators, and so on - where the exact type declaration might be a couple dozen characters of pure syntactic salt, since you're initializing it to some function's return value. Java has a widely practiced ideal that you should not tie variables to class types but instead stick to interface types. Thus, you want to declare: ListInteger li = new LinkedListInteger(); Thing is, though, you can't automatically guess this. After all, you might be after: IterableInteger li = new LinkedListInteger(); or maybe: CollectionInteger li = new LinkedListInteger(); This principle doesn't concern only collections. A well-designed application should specify interfaces for pretty much all classes to separate design blocks and APIs from implementations du jour. (Again, something that has no relevance for Python users.) Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 05/03/2014 06:10, Rustom Mody wrote: On Wednesday, March 5, 2014 11:31:04 AM UTC+5:30, alex23 wrote: On 5/03/2014 3:47 PM, Rustom Mody wrote: That python is a hll means that machine reprs are intended to be abstracted away. 'is' fails to do that -- proof of that being the discrepancy between is and == The discrepancy is because _they're fundamentally different_: Yeah I know :D Both have their uses. Yes -- see my lisp example above a = b = [1,2] c = [1,2] a is b True a is c False a == b True a == c True `==` is used to determine if they're equivalent in value. Right `is` is used to determine if two names refer to the same object. 'Same' is 'is' in a different guise and is what I object to. A python programmer who needs/wants to think of same/is in this sense should probably be using C or assembly In the exceptional circumstances when 'low-level-machine-equivalence-relation' is desired, a name carrying some of those connotations would be ok Quite frankly I haven't got the faintest idea what you're going on about, so I'll just stick with writing plain, boring, working Python code. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 05/03/2014 06:28, alex23 wrote: On 5/03/2014 4:10 PM, Rustom Mody wrote: A python programmer who needs/wants to think of same/is in this sense should probably be using C or assembly Any programmer who is obsessing about some idea of philosophical purity should probably not be using Python. The Python philosophy is beautifully put in The Zen. I particularly like Practicality beats purity although there's plenty of other pieces of the whole to consider. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On 5 March 2014 07:52, Steven D'Aprano st...@pearwood.info wrote: On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: I stopped paying attention to mathematicians when they tried to convince me that the sum of all natural numbers is -1/12. I'm pretty sure they did not. Possibly a physicist may have tried to tell you that, but most mathematicians consider physicists to be lousy mathematicians, and the mere fact that they're results seem to actually work in practice is an embarrassment for the entire universe. A mathematician would probably have said that the sum of all natural numbers is divergent and therefore there is no finite answer. Why the dig at physicists? I think most physicists would be able to tell you that the sum of all natural numbers is not -1/12. In fact most people with very little background in mathematics can tell you that. The argument that the sum of all natural numbers comes to -1/12 is just some kind of hoax. I don't think *anyone* seriously believes it. Well, that is, apart from mathematicians like Euler and Ramanujan. When people like them tell you something, you better pay attention. Really? Euler didn't even know about absolutely convergent series (the point in question) and would quite happily combine infinite series to obtain a formula. snip Normally mathematicians will tell you that divergent series don't have a total. That's because often the total you get can vary depending on how you add them up. The classic example is summing the infinite series: 1 - 1 + 1 - 1 + 1 - ... There is a distinction between absolute convergence and convergence. Rearranging the order of the terms in the above infinite sum is invalid because the series is not absolutely convergent. For this particular series there is no sense in which its sum converges on an answer but there are other series that cannot be rearranged while still being convergent: http://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#Alternating_harmonic_series Personally I think it's reasonable to just say that the sum of the natural numbers is infinite rather than messing around with terms like undefined, divergent, or existence. There is a clear difference between a series (or any limit) that fails to converge asymptotically and another that just goes to +-infinity. The difference is usually also relevant to any practical application of this kind of maths. Oscar -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 05/03/2014 06:23, Marko Rauhamaa wrote: Rustom Mody rustompm...@gmail.com: * ... which summarizes my objection in this thread: Python's 'is' leaks the machine abstraction. 'id' does it legitimately (somewhat), 'is' does it illegitimately I agree that the Python data model can be exceedingly challenging to a beginner. However, I wouldn't throw the baby away with the bathwater, but look for ingenious ways to teach it. [snip Java] Similarly, in Python: if the_list == None: *should* work (even if there's no such stipulation in Python's reference material), but why wouldn't you use the more natural: if the_list is None: Marko Really great thinking, test the name the_list, which strangely enough tells me that this beast is a list, in the same way that THIS_IS_A_CONSTANT is a constant, to see if it's None. Congratulations, you've been promoted to captain of my dream team. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: find and replace string in binary file
On 05/03/2014 09:59, loial wrote: I'm pleased to see that you have answers. In return would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On Wed, Mar 5, 2014 at 11:35 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: if the_list is None: Marko Really great thinking, test the name the_list, which strangely enough tells me that this beast is a list, in the same way that THIS_IS_A_CONSTANT is a constant, to see if it's None. Congratulations, you've been promoted to captain of my dream team. Uhh... why? What's wrong with something either being a list or being None to indicate no list? def foo(x, target_list=None): if target_list is not None: target_list = default_targets You can't use if target_list: here, because that would also catch an empty list. You need some kind of sentinel that says there isn't a list here. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers
On 05/03/2014 12:21, Oscar Benjamin wrote: Why the dig at physicists? I think most physicists would be able to tell you that the sum of all natural numbers is not -1/12. In fact most people with very little background in mathematics can tell you that. I'll put that one to the test tomorrow morning when the bin men come round. I fully expect them to dial 999 and ask that the paramedics are armed with plenty of sedatives. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers
Oscar Benjamin oscar.j.benja...@gmail.com Wrote in message: On 4 March 2014 23:20, Dave Angel da...@davea.name wrote: One problem with complexity claims is that it's easy to miss some contributing time eaters. I haven't done any measuring on modern machines nor in python, but I'd assume that multiplies take *much* longer for large integers, and that divides are much worse. So counting iterations isn't the whole story. Agreed but there's a big difference between log(N) iterations and N iterations! On the assumption that division by 2 is very fast, and that a general multiply isn't too bad, you could improve on Newton by observing that the slope is 2. err = n - guess * guess guess += err/2 I gues you mean like this: def sqrt(n): err = guess = 1 while err 1e-10: err = n - guess * guess guess += err/2 return guess This requires log2(10)*N iterations to get N digits. No idea how you came up with that, but I see an error in my stated algorithm, which does surely penalize it. The slope isn't 2, but 2x. So the line should have been guess += err/(2*guess) Now if you stop the loop after 3 iterations (or use some other approach to get a low-precision estimate, then you can calculate scale = 1/(2*estimate) and then for remaining iterations, guess += err *scale So the penalty for using division would have to be extreme in order for this to better. Using Decimal to get many digits we can write that as: def sqrt2(n, prec=1000): '''Solve x**2 = y''' eps = D(10) ** -(prec + 5) err = guess = D(1) with localcontext() as ctx: ctx.prec = prec + 10 while abs(err) eps: err = n - guess*guess guess += err/2 return guess This method works out much slower than Newton with division at 1 digits: 40s (based on a single trial) vs 80ms (timeit result). Well considering you did not special-case the divide by 2, I'm not surprised it's slower. Some 37 years ago I microcoded a math package which included square root. All the math was decimal, and there was no hardware multiply or divide. The algorithm I came up with generated the answer one digit at a time, with no subsequent rounding needed. And it took just a little less time than two divides. For that architecture, Newton's method would've been too slow. If you're working with a fixed small precision then it might be. Incidentally, the algorithm did no divides, not even by 2. No multiplies either. Just repeated subtraction, sorta like divide was done. If anyone is curious, I'll be glad to describe the algorithm; I've never seen it published, before or since. I got my inspiration from a method used in mechanical, non-motorized, adding machines. My father had shown me that approach in the 50's. I'm curious. A later message, I guess. I can't write that much on the tablet. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers
Dave Angel da...@davea.name Wrote in message: Oscar Benjamin oscar.j.benja...@gmail.com Wrote in message: On 4 March 2014 23:20, Dave Angel da...@davea.name wrote: If anyone is curious, I'll be glad to describe the algorithm; I've never seen it published, before or since. I got my inspiration from a method used in mechanical, non-motorized, adding machines. My father had shown me that approach in the 50's. I'm curious. A later message, I guess. I can't write that much on the tablet. Given a microcodable architecture with no hardware support for multiply or divide, clearly multiply will be several times as fast as divide (at least).  There was a BCD ALU, so add and subtract of decimal values was quite reasonable.  All floating point logic, however, is just microcode. Divide is implemented via repeated subtraction of the divisor from the dividend.  The count of how many subtracts is done is the quotient. Naturally, this is combined with digit shifts, so you find one quotient digit at a time.  For a 13 digit result, the maximum subtracts are 13*10. Multiply is much faster, as you know ahead of time for each column how many adds you're supposed to do.  So you can have precalculated multiples of the divisor on hand, and you can subtract instead of add when appropriate. Square root is implemented as a kind of variable division, where the divisor is changing constantly.  Everyone knows that the sum of the first n odd numbers is n squared.  So if you started with a square, you could repeatedly subtract odd numbers from it till you reached zero, and the square root will be roughly half the last odd number subtracted. So to make this work across multiple columns it turns out you can accumulate these odd numbers, doing the appropriate shifts after each column, and if you take the last number shifted, you can just add 1 and divide by 2. In many architectures, that would be as far as you can go, but in the particular one I was using, generating those pesky odd numbers was more expensive than you'd expect.  So it turned out to be quicker to just do twice as many subtracts. Instead of subtracting 1,3, 5, etc., till the value went negative, we subtract 0 and 1, 1 and 2, 2 and 3, etc.  You have twice as many subtracts, but no divide by 2 at the end.  And for each column, you need not go beyond 8 + 9, since if it were more than that, we would have picked it up in the previous column.  So you do not have to propagate the carry across the trial divisor. Supposing the correct result will be 7.1234567, you will at one stage of operations, be subtracting     71230     71231     71231     71232     71232     71233     71233     71234 The next subtract will make the result go negative, so you either do it, detect negative and undo it, or you do some compare operation. I am here glossing over all the details of normalizing the dividend so the exponent is even, and calculating the final exponent, which at first approximation is half the original one. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Op 04-03-14 16:25, Chris Angelico schreef: On Wed, Mar 5, 2014 at 2:19 AM, Jerry Hill malaclyp...@gmail.com wrote: Out of curiosity, do you think we should be doing truth checking with 'is'? True and False are singletons, and it seems to me that the justification for idenity versus equality should be just as strong there, but I don't think I've ever seen anyone even suggest that. Normal truth testing is done like this: if cond: In an other language with real booleans where an if only accepts a boolean that would be true. In python this is testing for something. This isn't truth testing, this is checking the identity of what's in cond: if cond is True: And that's specifically testing for something much tighter than truthiness. As you can see from my stats above, that's actually fairly rare. Usually you'd just accept that True, 1, yes, [1,2,3], and 1.2345 are all equally true. No I usually don't accept that. A number different from 0 is not the same as a none-empty list. I usally don't want to treat them the same. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: How to create an instance of a python class from C++
So far, so good. The object that was passed in was the Derived class object. Since you presumably only want class objects to be passed in, you might want to check that here using PyType_Check. Yes. Will do. PyTypeObject *typ = class_decl-ob_type; In Python, you instantiate a class by calling it. You should do the same in C, using PyObject_CallFunction. But as above, note that you want to call class_decl, not class_decl-ob_type. Of course. That works. Thanks. Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wednesday, March 5, 2014 2:26:12 AM UTC-6, Steven D'Aprano wrote: On Wed, 05 Mar 2014 08:37:42 +0200, Marko Rauhamaa wrote: If you had tried Python 30 years ago, you'd give it up for any serious work because it would be so slow and consume so much memory. /facepalm Python is only 23 years old, so it would have been a good trick to have tried it 30 years ago. hi Steven, QOTD, I go back to the day of the MITS Altair 8800. My high school had one. I was writing machine code for the Wang 700 series programmable desk calculator, and punching in code on the Altair 8800, with toggle switches. I'm one of the guys Bill Gates wrote his famous open letter to in 1976. I was there. In 1984 the only language being used to write *anything* in the general sphere of personal computing was either MS DEBUG.COM (one of my favorites) or BASIC---which was ubiquitous, where like almost *every* computer booted directly into a BASIC interpreter, the noted exception being the first IBM PC. The pre-cursor to python was ABC created at CWI in about 1991. One of its purposes (according to Guido) was to, and I quote, Stamp out BASIC. My first IBM machine was the famous PCjr... booted directly into cartridge BASIC, or would optionally boot DOS 2.1 from 5 floppy, where I could run, you guessed it BASICA, using the cartridge rom, or I could optionally run DEBUG.COM and code up 8086 machine code (not assembler, mind you). Well, I used my PCjr until 1992 (python was one year old, and ABC would not run on a PC); when I purchased my 486 SX. Guess what? ---still coding BASIC, DEBUG.COM... and whoohoo, Turbo Pascal At IBM we were coding Rexx on the VM370 systems, and then Rexx on the OS/2 systems; no python, and nothing much else either , oh yes, Turbo BASIC, Visual BASIC, and of course BASICA although you could then get it as GWBASIC, ... still no python. Did anyone mention that PCs back in that day were toys. And I do mean toys. They were slow, they crashed, their graphics sucked, and your storage medium was a floppy disk. Linus was working in Finland on basic... Richard Stallman was working on GNU, Guido was working at CWI on python. The PC really didn't come into its own (and they were still slow) until the Pentium4. Personal computers really did not begin to really shine until about 1998 (a mere 16 years ago) when IBM and other began to take a serious look into gnu/linux research. PCs were fast enough, had enough memory, and even had python. Of course most of us were not using it... mostly C of various brands (notably MIX) and Visual BASIC. Quick BASIC was ubiquitous by that time, and MASM had taken over for DEBUG.com. Those were the days. There has been a resurgence of interest in BASIC today; notably Mintoris, and Chipmunk. But now everyone usually has some flavor of python installed on their computer (and most don't know it) because python is being used under the covers as a scripting language of choice. Wide adoption is still coming, in the future, but the future looks good for python; competing of course with (notably) Java or Dalvik (Android Java). In my day computers were slide-rules. Businesses were still using Comptometers (still being taught on my high school) and the modern age of computing would not occur for forty years. Trust me, thirty years ago was like the dark ages of personal computing and python wasn't even a gleam in her daddy's eye. If fact, now that I think of it, Monte Python and the Holy Grail came out in 1975, one year before the MITS Altair 8800 Bill Gates open letter, and one year after I graduated from high school. {world according to me} marcus -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On 2014-03-05, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Wed, 05 Mar 2014 00:48:40 +0200, Marko Rauhamaa ma...@pacujo.net declaimed the following: Ethan Furman et...@stoneleaf.us: Okay, that looks totally cool. Maybe I'll finally get a handle on LISP! :) Lisp is conceptually simpler than Python, but awe-inspiring. One day, it will overtake Python, I believe. It's already had 54 years to become a major language... Instead it has schismed into Common Lisp and Scheme (and a few other dialects) Granted, my experience was toying with /cassette-based/ SuperSoft LISP on a TRS-80 Model III Personally, I think it hasn't taken off because special forms are harder to remember than syntax. And there are, like, *way* more than mammals needs. And then the coolest feature of the language, macros, is designed to let you, gulp, add more. Well, that or lisp's designers severely underestimated how much we like to use our programming languages as non-RPN calculators. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 2014-03-05 17:26, Ben Finney wrote: Jython is an imitation of Cpython and does a good job but not quite as in the case of 'id' Wrong. Jython and CPython both adhere to the guarantees of object identity. Both implementations follow the language reference, and neither implementation does object identity better or worse than the other. I think he means but not quite as [good in making my argument, despite the fact that the language definition runs contrary to my mistaken belief] as in [my interpretation of] 'id' :-) -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
Neil Cerutti ne...@norwich.edu: Personally, I think it hasn't taken off because special forms are harder to remember than syntax. And there are, like, *way* more than mammals needs. It hasn't taken off yet, but even mammals can evolve. Well, that or lisp's designers severely underestimated how much we like to use our programming languages as non-RPN calculators. I don't think Lisp was really originally designed. It just came out and, surprisingly, ran. As for the anti-RPN notation, yes, it can be hard to get used to. Then again, Python notation requires an initiation as well. For example: invoc = {}({}).format(fname, ', '.join(repr(x) for _, x in named_args)) Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Thu, Mar 6, 2014 at 1:11 AM, Mark H. Harris harrismh...@gmail.com wrote: My first IBM machine was the famous PCjr... booted directly into cartridge BASIC, or would optionally boot DOS 2.1 from 5 floppy, where I could run, you guessed it BASICA, using the cartridge rom, or I could optionally run DEBUG.COM and code up 8086 machine code (not assembler, mind you). My first IBM machine (first I used - the first computer I actually personally *owned* wasn't till this century) was an Epson XT-compatible. We had GW-BASIC and Q-BASIC, and a much superior form of DEBUG.EXE that came with, get this, an inbuilt mini-assembler! Yes, I could do this: -a :0100 mov ah,09 :0102 mov dx,0109 :0105 int 21 :0107 int 20 :0109 db Hello, world!,13,10,24 And it'd produce the appropriate bytes. From memory, that would be B4 09 BA 09 01 CD 21 CD 20, followed by the text string. I actually used that to write seriously-useful programs, like one that helped us keep track of which treasures we'd picked up in Colossal Caves. (For some definition of seriously-useful, anyway.) At IBM we were coding Rexx on the VM370 systems, and then Rexx on the OS/2 systems; no python, and nothing much else either , oh yes, Turbo BASIC, Visual BASIC, and of course BASICA although you could then get it as GWBASIC, ... still no python. I wasn't working at IBM itself, but when Dad switched to OS/2 for our home business, we switched too. That would have been about 1992; we used OS/2 2.1 briefly, but got properly into things with Warp 3 (Connect, and I can never remember whether it was red-box or blue-box - we had the one that came with a Windows license for Win-OS/2). Ooh, we had the most amazing fun with that... we set up, to quote my older brother, our very own personal World Wide Web! (Not very accurate, but that was the big buzz-word at the time, and hey, we did have a LAN.) And over the ensuing years, we got to know which network cards were the most reliable - mainly the Realtek ones, we had some RTL8029 cards that went into so many different computers - and if anything went wrong with drivers or anything, I'd pop the case and stick in one of my stand-bys. Either that, or we'd go search for the drivers on Hobbes, and either download 'em onto a floppy disk or LinkWiz them across - because one of the very first things we'd put onto any computer was the comms software that uses a special serial-port or parallel-port cable to transfer files. Immensely useful, until generic network drivers got better :) Did anyone mention that PCs back in that day were toys. And I do mean toys. They were slow, they crashed, their graphics sucked... Oh no! No no no! Graphics didn't suck for everyone. Maybe they did for you, you with the horrible CGA card plugged into your TV. Maybe they did for the people who used the default IBM Monochrome card that didn't do graphics at all. But no, my dad was forward-looking. He got the best. He got a Hercules Graphics Card, capable of driving the same screens the IBM Mono would, but giving us the tremendous capability of 720x348 monochrome graphics! It was awesome! Plus, for text colors we had black, white, bold black, and bold white, and - get this - underlined! Nobody else got that. Yes, those were the days. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On 2014-03-04, Marko Rauhamaa ma...@pacujo.net wrote: Ethan Furman et...@stoneleaf.us: Okay, that looks totally cool. Maybe I'll finally get a handle on LISP! :) Lisp is conceptually simpler than Python, but awe-inspiring. One day, it will overtake Python, I believe. Seriously? LISP had a _30_year_head_start_ yet Python is far ahead and pulling away... -- Grant Edwards grant.b.edwardsYow! I'm continually AMAZED at at th'breathtaking effects gmail.comof WIND EROSION!! -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wed, 05 Mar 2014 00:48:40 +0200, Marko Rauhamaa wrote: Ethan Furman et...@stoneleaf.us: Okay, that looks totally cool. Maybe I'll finally get a handle on LISP! :) Lisp is conceptually simpler than Python, but awe-inspiring. One day, it will overtake Python, I believe. That day was 25 years ago. According to the long-term TIOBE index, 25 years ago Lisp was the second most popular programming language in the world, behind only C. http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html I don't think Lisp has gotten easier, or the average programmer smarter, since then. The average programmer has difficulty with while loops, do you really think that someday they'll grok lambda calculus? *wink* Seriously, Lisp is not only one of the oldest high-level languages around, being almost as old as Fortran and Cobol, but it was one of the biggest languages of the 1970s and even into the 80s. Companies spent millions developing, and using, Lisp compilers. There were even Lisp machines, actual hardware machines not virtual, where the CPU could execute Lisp instructions directly in hardware. It did not last. It's not that the computer industry hasn't discovered Lisp, it is that they discovered it, gave it a solid workout for 20 years, and then said Nope, this isn't for us. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: How to create an instance of a python class from C++
On 2014-03-05, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Mar 4, 2014 at 5:14 PM, Bill galaxyblu...@gmail.com wrote: Hello: I can't figure out how to create an instance of a python class from 'C++': ( I am relatively new to Python so excuse some of the following. ) In a .py file I create an ABC and then specialize it: Why are you creating an ABC? Because it was the first binary computer that did calculations with electronic switching elements (gates), and it would be really cool to have one! The ABC also pioneered the use of capciators as regenerative storage elements (it's how DRAM still works today). http://en.wikipedia.org/wiki/Atanasoff%E2%80%93Berry_Computer It predated ENIAC, and it's clear that some of the features of ENIAC were inspired by the ABC after John Mauchly visited Iowa State and saw the ABC. -- Grant Edwards grant.b.edwardsYow! I can't decide which at WRONG TURN to make first!! gmail.comI wonder if BOB GUCCIONE has these problems! -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wednesday, March 5, 2014 9:47:40 AM UTC-6, Steven D'Aprano wrote: Seriously, Lisp is not only one of the oldest high-level languages around, being almost as old as Fortran and Cobol, but it was one of the biggest languages of the 1970s and even into the 80s. Lisp was specified by John McCarthy (of Berkeley, CA) in 1958. It is the second oldest computer language behind Fortran, by one year. There is a resurgence of interest in Lisp today (yes, not so much for common lisp) in the Scheme arena. The irony for AI today is that we are finally at the point where the technology can finally do what Alonzo Church and Alan Turing dreamed about. John McCarthy was *way* ahead of his time too. We are at the point where we are wondering again if computer science technology in software engineering will ever generate a thinking entity---self aware, creative, and of course able to generate on it's own, Cogito ergo sum Lisp/Scheme is awesome. But, if I want to have my little 'ol puter do some real work, up comes IDLE and out comes a script in a couple of hours that's awesome! I still play around with gnu emacs and lisp. Its fun, educational, and truly enriching beyond words. Check out the site, Lambda the Ultimate sometime: http://lambda-the-ultimate.org/ marcus -- https://mail.python.org/mailman/listinfo/python-list
Re: How to create an instance of a python class from C++
On Wed, 05 Mar 2014 16:08:00 +, Grant Edwards wrote: On 2014-03-05, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Mar 4, 2014 at 5:14 PM, Bill galaxyblu...@gmail.com wrote: Hello: I can't figure out how to create an instance of a python class from 'C++': ( I am relatively new to Python so excuse some of the following. ) In a .py file I create an ABC and then specialize it: Why are you creating an ABC? Because it was the first binary computer that did calculations with electronic switching elements (gates), and it would be really cool to have one! The ABC also pioneered the use of capciators as regenerative storage elements (it's how DRAM still works today). http://en.wikipedia.org/wiki/Atanasoff%E2%80%93Berry_Computer It predated ENIAC, and it's clear that some of the features of ENIAC were inspired by the ABC after John Mauchly visited Iowa State and saw the ABC. But it was not programmable the first programmable electronic computer was 'Colossus' which was developed during WWII but remained classified by the UK govt for many years afterwards http://en.wikipedia.org/wiki/Colossus_computer -- You are not dead yet. But watch for further reports. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to create an instance of a python class from C++
On 2014-03-05, Alister alister.w...@ntlworld.com wrote: Why are you creating an ABC? Because it was the first binary computer that did calculations with electronic switching elements (gates), and it would be really cool to have one! The ABC also pioneered the use of capciators as regenerative storage elements (it's how DRAM still works today). http://en.wikipedia.org/wiki/Atanasoff%E2%80%93Berry_Computer It predated ENIAC, and it's clear that some of the features of ENIAC were inspired by the ABC after John Mauchly visited Iowa State and saw the ABC. But it was not programmable True. It had only one program that was hard-wired into it when it was built as opposed to the external patch-cords and switches that were used on machines like Colossus and ENIAC to alter the wiring. the first programmable electronic computer was 'Colossus' which was developed during WWII but remained classified by the UK govt for many years afterwards http://en.wikipedia.org/wiki/Colossus_computer -- Grant Edwards grant.b.edwardsYow! Hmmm ... A hash-singer at and a cross-eyed guy were gmail.comSLEEPING on a deserted island, when ... -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On Wed, 05 Mar 2014 12:21:37 +, Oscar Benjamin wrote: On 5 March 2014 07:52, Steven D'Aprano st...@pearwood.info wrote: On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: I stopped paying attention to mathematicians when they tried to convince me that the sum of all natural numbers is -1/12. I'm pretty sure they did not. Possibly a physicist may have tried to tell you that, but most mathematicians consider physicists to be lousy mathematicians, and the mere fact that they're results seem to actually work in practice is an embarrassment for the entire universe. A mathematician would probably have said that the sum of all natural numbers is divergent and therefore there is no finite answer. Why the dig at physicists? There is considerable professional rivalry between the branches of science. Physicists tend to look at themselves as the paragon of scientific hardness, and look down at mere chemists, who look down at biologists. (Which is ironic really, since the actual difficulty in doing good science is in the opposite order. Hundreds of years ago, using quite primitive techniques, people were able to predict the path of comets accurately. I'd like to see them predict the path of a house fly.) According to this greedy reductionist viewpoint, since all living creatures are made up of chemicals, biology is just a subset of chemistry, and since chemicals are made up of atoms, chemistry is likewise just a subset of physics. Physics is the fundamental science, at least according to the physicists, and Real Soon Now they'll have a Theory Of Everything, something small enough to print on a tee-shirt, which will explain everything. At least in principle. Theoretical physicists who work on the deep, fundamental questions of Space and Time tend to be the worst for this reductionist streak. They have a tendency to think of themselves as elites in an elite field of science. Mathematicians, possibly out of professional jealousy, like to look down at physics as mere applied maths. They also get annoyed that physicists often aren't as vigorous with their maths as they should be. The controversy over renormalisation in Quantum Electrodynamics (QED) is a good example. When you use QED to try to calculate the strength of the electron's electric field, you end up trying to sum a lot of infinities. Basically, the interaction of the electron's charge with it's own electric field gets larger the more closely you look. The sum of all those interactions is a divergent series. So the physicists basically cancelled out all the infinities, and lo and behold just like magic what's left over gives you the right answer. Richard Feynman even described it as hocus-pocus. The mathematicians *hated* this, and possibly still do, because it looks like cheating. It's certainly not vigorous, at least it wasn't back in the 1940s. The mathematicians were appalled, and loudly said You can't do that! and the physicists basically said Oh yeah, watch us! and ignored them, and then the Universe had the terribly bad manners to side with the physicists. QED has turned out to be *astonishingly* accurate, the most accurate physical theory of all time. The hocus-pocus worked. I think most physicists would be able to tell you that the sum of all natural numbers is not -1/12. In fact most people with very little background in mathematics can tell you that. Ah, but there's the rub. People with *very little* background in mathematics will tell you that. People with *a very deep and solid* background in mathematics will tell you different, particularly if their background is complex analysis. (That's *complex numbers*, not complicated -- although it is complicated too.) The argument that the sum of all natural numbers comes to -1/12 is just some kind of hoax. I don't think *anyone* seriously believes it. You would be wrong. I suggest you read the links I gave earlier. Even the mathematicians who complain about describing this using the word equals don't try to dispute the fact that you can identify the sum of natural numbers with ζ(-1), or that ζ(-1) = -1/12. They simply dispute that we should describe this association as equals. What nobody believes is that the sum of natural numbers is a convergent series that sums to -1/12, because it is provably not. In other words, this is not an argument about the maths. Everyone who looks at the maths has to admit that it is sound. It's an argument about the words we use to describe this. Is it legitimate to say that the infinite sum *equals* -1/12? Or only that the series has the value -1/12? Or that we can associate (talk about a sloppy, non-vigorous term!) the series with -1/12? Well, that is, apart from mathematicians like Euler and Ramanujan. When people like them tell you something, you better pay attention. Really? Euler didn't even know about absolutely convergent series (the point in question) and would quite happily
Re: find and replace string in binary file
On 3/5/2014 1:59 AM, loial wrote: Unfortunately I have to use python 2.6 for this Did you try it? Emile -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On Wednesday, March 5, 2014 11:50:46 AM UTC+5:30, Ben Finney wrote: Rustom Mody writes: That python is a hll means that machine reprs are intended to be abstracted away. 'is' fails to do that -- proof of that being the discrepancy between is and == That's your proof? That is a non sequitur. Those two operators are *designed to be* different, to compare different things. How does the difference between '==' versus 'is', which are designed and documented to have different behaviour, lead to your assertion of a leaky abstraction? You have yet to respond to this question asked several times: If you wish to disagree with me, you are welcome to do so and I am obliged (up to a point I guess) to assume the disagreement is in good faith towards better understanding/usage etc of python. However... Can you explain what machine representations are leaked into Python by the is operator? So, what machine represenatation is leaked? I'll re-iterate that memory location of the object isn't a valid response. There is no necessary relation between the memory location of the object referenced by foo and the return value of 'id(foo)'. ... however you are both disagreeing with me and also saying Ive not given the answer and further disagreeing with the python standard, which I quote: Every object has an identity, a type and a value. An object's identity never changes once it has been created; you may think of it as the object's address in memory. The 'is' operator compares the identity of two objects; the id() function returns an integer representing its identity (currently implemented as its address). from http://docs.python.org/2/reference/datamodel.html So when you say I'll re-iterate that memory location of the object isn't a valid response. well... all I can say is I dont know what to say :-) -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers
On Wed, 05 Mar 2014 12:50:06 +, Mark Lawrence wrote: On 05/03/2014 12:21, Oscar Benjamin wrote: Why the dig at physicists? I think most physicists would be able to tell you that the sum of all natural numbers is not -1/12. In fact most people with very little background in mathematics can tell you that. I'll put that one to the test tomorrow morning when the bin men come round. Do you seriously think that garbos (bin men) know more about mathematics than mathematicians? I fully expect them to dial 999 and ask that the paramedics are armed with plenty of sedatives. You know that rather large piece of machinery in Europe called the Large Hadron Collider? The one which is generating some rather extraordinary proofs of fundamental physics, such as the Higgs Boson? A lot of that physics is based on theory which uses the same logic and mathematics that you are mocking. Laugh away, but the universe behaves as if the sum of the natural numbers is -1/12. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On Thu, Mar 6, 2014 at 4:43 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Physics is the fundamental science, at least according to the physicists, and Real Soon Now they'll have a Theory Of Everything, something small enough to print on a tee-shirt, which will explain everything. At least in principle. Everything is, except what isn't. That's my theory, and I'm sticking to it! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On Wed, Mar 5, 2014 at 9:43 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: At one time, Euler summed an infinite series and got -1, from which he concluded that -1 was (in some sense) larger than infinity. I don't know what justification he gave, but the way I think of it is to take the number line from -∞ to +∞ and then bend it back upon itself so that there is a single infinity, rather like the projective plane only in a single dimension. If you start at zero and move towards increasingly large numbers, then like Buzz Lightyear you can go to infinity and beyond: 0 - 1 - 10 - 1 - ... ∞ - ... -1 - -10 - -1 - 0 This makes me think that maybe the universe is using ones or two complement math (is there a negative zero?)... Chris -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 2014-03-05 09:40, Rustom Mody wrote: Every object has an identity, a type and a value. An object's identity never changes once it has been created; you may think of it as the object's address in memory. The 'is' operator compares the identity of two objects; the id() function returns an integer representing its identity (currently implemented as its address). from http://docs.python.org/2/reference/datamodel.html Note the currently, which does not mean now, always, and forever for every implementation. From http://docs.python.org/3/library/functions.html#id Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value. CPython implementation detail: This is the address of the object in memory. This is clearly documented as a *CPython implementation detail*. The id() function is free to return sequential integers, arbitrary integers, memory addresses, GUIDs-as-integers, or hashes-as-integers for some internal representation. The only thing that matters is (1) that id() returns *some* integer identifying the object, and (2) the ability to compare id(thing1) with id(thing2) and see if they are the same or different (assuming thing1 and thing2 share lifetimes during their id() calls), regardless of what is actually returned. So when you say I'll re-iterate that memory location of the object isn't a valid response. well... all I can say is I dont know what to say :-) That you live in a CPython world, unencumbered by experience in other flavors of language-spec-compliant Python interpreters where id() returns integers that *aren't* memory addresses? -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On Tue, 04 Mar 2014 21:47:21 -0800, Rustom Mody wrote: On Wednesday, March 5, 2014 10:36:37 AM UTC+5:30, Steven D'Aprano wrote: On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote: Python's 'is' leaks the machine abstraction. 'id' does it legitimately (somewhat), 'is' does it illegitimately and then later in another post: is in python leaks machine representations into the otherwise clean HLL abstraction in python Rather than respond with incredulity and declare that you have no idea what you are talking about, I'll give you the benefit of the doubt, and accept the possibility that I am wrong, or possibly misunderstanding you. Umm... I guess my language was sloppy (a bit) A machine is ultimately also an abstraction -- What is firmware/microcode? Is it a virtual machine? etc Lets leave that however and just take 'machine' as a given. Using machines as given, we build reprs for our (programmer's) data structures So data structures are abstractions that have two 'faces' -- the machine-facing and the programmer-facing What you are describing is normally called the implementation and the interface. For clarity of expression (and where you perhaps found me sloppy?? not sure...) its best to call the machine-face 'a representation' and the programmer-face 'an abstraction' Only if you wish to ignore the standard terminology used by the rest of the computing world, and furthermore re-define the term abstraction. Clearly this is a programmer-biased viewpoint. A hardware engineer would see things differently. As would the user of the app the programmer programs. This doesn't seem to be relevant. Which is why to use the locution is without appropriate framing is philosopical is a pretension to a 'God's-eye-view'. If you are privy to such a viewpoint I'd be interested to know But for the rest of us who are not, its good to remember there are only perspectives no absolute truth. And this appears to be meaningless. The best I can come up with is that you're concerned about the philosophical implications of stating that object x is object y. Quite frankly, I think that's silly. Such concerns about identity of physical entities in the real world are *irrelevant*. You seem to be making a category mistake: the word is has certain meanings in plain English, with associated philosophical problems, therefore the Python is operator must have exactly the same meanings and problems. But this is as silly as thinking that we should be able to use a computer file to cut through metal, or that equality between 1+1 and 2 is a question of human rights. The is operator has a well-defined meaning in Python. The axe of my grandfather paradox does not apply to the is operator. That definition in Python is very simple: the is operator returns True if the two operands are the same object, and false if they are different objects. That python is a hll means that machine reprs are intended to be abstracted away. 'is' fails to do that -- proof of that being the discrepancy between is and == There is no discrepancy between is and ==, since they are different operators with different semantics. You might as well claim that there is a discrepancy between + and * because 5+7 and 5*7 return different answers. Can you explain what machine representations are leaked into Python by the is operator? Do you see this as an accident of implementation, a bug that might be fixed, or a misfeature that was deliberately designed? Can you elaborate on why id() is legitimate and is is not? Let me talk of Lisp which is IMHO more philosophically sane. I'd rather you answer the questions I asked rather than change the subject to an irrelevance. [...] Decide the viewpoint -- choose the appropriate equivence predicate No claim even remotely to having a clue to metaphysical being that python's 'is' implies There is no metaphysical implication from Python's is operator. If the operator had precisely the same behaviour, but was called same, as in: a same b = returns True if a and b are the same object = returns False if a and b are not the same object would you claim there was a metaphysical implication? How about if it were called eq, like Lisp uses? -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On Tue, 04 Mar 2014 22:03:36 -0800, Rustom Mody wrote: On Wednesday, March 5, 2014 10:36:37 AM UTC+5:30, Steven D'Aprano wrote: On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote: Python's 'is' leaks the machine abstraction. 'id' does it legitimately (somewhat), 'is' does it illegitimately Can you elaborate on why id() is legitimate and is is not? Mostly a question of more or less infelicitous English leading to philosophical nonsense. [And note I put a 'somewhat'] Well it is certainly true that this discussion has lead to philosophical nonsense from one of us. I can say 'id' is just 'machine-id' is just address at some low level You can say it, but you would be wrong. I don't know how many times you have to be told. The id() function in Python is not defined as returning the address of the object. There is no guarantee that objects even have a consistent, stable addresses. Some garbage collectors will move objects around. The Python language does not claim that the id() function will return the address of objects, it says that it will return an abstract ID number that is unique for that object while the object exists. Its uglier to say Is is machine-is And before you bring it up, Jython's id is not machine-id is putting the cart before the horse. Jython is an imitation of Cpython That's wrong. Jython is not an imitation, it is an independent implementation of the same language. Since both CPython and Jython follow the specification of the language, both are legitimate Python compilers. Both the Jython and CPython id() functions are compliant with the language definition. The Jython id() function is better, because it doesn't encourage people to mistakenly and foolishly imagine that id() equals address. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Rustom Mody rustompm...@gmail.com writes: On Wednesday, March 5, 2014 11:50:46 AM UTC+5:30, Ben Finney wrote: So, what machine represenatation is leaked? I'll re-iterate that memory location of the object isn't a valid response. There is no necessary relation between the memory location of the object referenced by foo and the return value of 'id(foo)'. ... however you are both disagreeing with me and also saying Ive not given the answer and further disagreeing with the python standard, which I quote: Every object has an identity, a type and a value. An object's identity never changes once it has been created; you may think of it as the object's address in memory. The 'is' operator compares the identity of two objects; the id() function returns an integer representing its identity (currently implemented as its address). from http://docs.python.org/2/reference/datamodel.html Right. None of which constitutes a leaking abstraction. I'll repeat the point: the abstraction does not leak if the user of that abstraction has no need to deal with what lies beneath it. In other words: A helpful “you may think of it as the object's address in memory” does not constitute a leaky abstraction, because it would be just as correct to say “you may think of it as a snowflake”. There is no need for the user of the abstraction “object identity” to know anything about the object's location in memory (nor of snowflakes), nor ever to think about it when using the abstraction. You may, as the documentation suggests, think of it that way; but you may also think of it as anything else which agrees with the abstraction. The clause about “object's location in memory” is not normative, does not matter for using the abstraction, and is not part of the definition. It literally does not matter for the purpose of using the abstraction, so there's no leak. In fact, in the current Python documentation the description has changed: Every object has an identity, a type and a value. An object’s identity never changes once it has been created; you may think of it as the object’s address in memory. The ‘is‘ operator compares the identity of two objects; the id() function returns an integer representing its identity. CPython implementation detail: For CPython, id(x) is the memory address where x is stored. URL:http://docs.python.org/3/reference/datamodel.html So it's now even clearer that “memory address where the object is stored” is *not* part of the abstraction, is *not* guaranteed to be what ‘id(foo)’ returns, and is an implementation detail of one particular implementation, that can be ignored. The abstraction “object identity” behaves exactly as the documentation says it does, in the absence of any “object address in memory” concept, and this is not undermined by suggestions that the reader may already have a concept in mind which can help them to imagine the abstraction. So when you say I'll re-iterate that memory location of the object isn't a valid response. well... all I can say is I dont know what to say :-) I'd encourage you to read the documentation for comprehension. Not every word in a discussion of a concept must be normative. I'd also encourage you to report a bug, suggesting a documentation improvement if you have been misled by (the latest version of) the language reference. -- \“Of course, everybody says they're for peace. Hitler was for | `\ peace. Everybody is for peace. The question is: what kind of | _o__)peace?” —Noam Chomsky, 1984-05-14 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wed, 05 Mar 2014 16:54:59 +0200, Marko Rauhamaa wrote: I don't think Lisp was really originally designed. The history of Lisp is described here in detail: http://www-formal.stanford.edu/jmc/history/lisp/lisp.html Like all complex systems, it did not appear fully-formed in a flash of inspiration. It was both designed and evolved through experimentation. That process of *trying things* and keeping those that work is usually called design. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Thu, Mar 6, 2014 at 5:42 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 05 Mar 2014 16:54:59 +0200, Marko Rauhamaa wrote: I don't think Lisp was really originally designed. The history of Lisp is described here in detail: http://www-formal.stanford.edu/jmc/history/lisp/lisp.html Like all complex systems, it did not appear fully-formed in a flash of inspiration. It was both designed and evolved through experimentation. That process of *trying things* and keeping those that work is usually called design. There's a difference between iterative design of that nature and initial design. An initial clean design is a good basis for further iterative design; a messy initial design means backward compatibility shackles you. Originally designed is different from constantly worked on. But Lisp has enough variants that the backward compat issue isn't as major. There's no specific need for Scheme to maintain every mistake of Common Lisp, or Clojure to support everything that elisp does. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On 2014-03-05, Chris Kaynor ckay...@zindagigames.com wrote: On Wed, Mar 5, 2014 at 9:43 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: At one time, Euler summed an infinite series and got -1, from which he concluded that -1 was (in some sense) larger than infinity. I don't know what justification he gave, but the way I think of it is to take the number line from -∞ to +∞ and then bend it back upon itself so that there is a single infinity, rather like the projective plane only in a single dimension. If you start at zero and move towards increasingly large numbers, then like Buzz Lightyear you can go to infinity and beyond: 0 - 1 - 10 - 1 - ... ∞ - ... -1 - -10 - -1 - 0 This makes me think that maybe the universe is using ones or two complement math (is there a negative zero?)... If the Universe (like most all Python implementations) is using IEEE-754 floating point, there is. -- Grant Edwards grant.b.edwardsYow! This PIZZA symbolizes at my COMPLETE EMOTIONAL gmail.comRECOVERY!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: There is no metaphysical implication from Python's is operator. If the operator had precisely the same behaviour, but was called same, as in: a same b = returns True if a and b are the same object = returns False if a and b are not the same object would you claim there was a metaphysical implication? I would. You are not defining anything because you are not explaining what same object means. Set theory obeys the so-called extensionality principle: if two objects are indistinguishable in every way, they are one and the same object. Fermions in particle physics are the same way: if two fermions' quantum states coincide, they are one and the same particle. Now, that's not true for Pythons bosonic objects. You can have two objects that are identical except they are not the same. There are (at least) two ways to break the circularity between is and same-objectness: 1. Give a real or hypothetical reference implementation and state that any other implementation that produces same (or similar enough) outcomes is valid. (Each object is allocated with the malloc(3) function call. The identity of an object is the value returned by malloc(3).) 2. Give formal axioms that characterize any valid implementation. (After x = y, x is y plus a couple of dozen more formal stipulations.) As for teaching the concept in practice, both of the above approaches are probably bad. Take abstract algebra. You don't start teaching a first-grader about groups and rings and work your way down to arithmetics. Rather, you start with counting, move on to arithmetics, bring in vectors and maybe Rubik's Cube and finally try to get the students to understand the general, abstract idea behind it all. Analogously, it may be necessary to teach the children first the theory of linear memory, then variables and arrays, then pointers and singly-linked lists. Once these concrete ideas have been understood, the principles behind Python and other higher-level programming languages can be learned. How about if it were called eq, like Lisp uses? You are correct. Lisp suffers from the same problem. The underlying reference machine is simpler to present, though, as there are no classes or methods. There are only memory cells and a handful of data types (number, cons, symbol, string or nil). You really get a feel of a physical steam engine. Ten years ago a whole generation of programmers was raised who knew nothing of computing except Java. I wonder how difficult it was for them to get objects, references and identity. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 2014-03-05, Marko Rauhamaa ma...@pacujo.net wrote: Set theory obeys the so-called extensionality principle: if two objects are indistinguishable in every way, they are one and the same object. Fermions in particle physics are the same way: if two fermions' quantum states coincide, they are one and the same particle. Now, that's not true for Pythons bosonic objects. You can have two objects that are identical except they are not the same. Wrong. If the two objects are not the same, then they will have different ID values. If the ID values are the same, then you've only got one object. Two different objects are always distinguishable in Python because they will always have different ID values. There are (at least) two ways to break the circularity between is and same-objectness: I'm sorry, what problem are you trying to solve? -- Grant Edwards grant.b.edwardsYow! I'm definitely not at in Omaha! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: The id() function in Python is not defined as returning the address of the object. It might as well. If I said id() returns the address of the object in the Python VM's virtual address space, you couldn't call my bluff. Say id() returned the intantiation sequence number. I could say, the infinite linear memory starts from address 0 and each object occupies a single memory slot. That's wrong. Jython is not an imitation, it is an independent implementation of the same language. Since both CPython and Jython follow the specification of the language, both are legitimate Python compilers. Both the Jython and CPython id() functions are compliant with the language definition. The Jython id() function is better, because it doesn't encourage people to mistakenly and foolishly imagine that id() equals address. I agree with everything (how could I not) except the foolishness part: what bad consequence is there for imagining that id() equals address? If id() offers the only glimpse into the memory, we can say that id() *is* the address. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: ANN: Python Job Board - Call for volunteers
I'd like to volunteer! On Mar 5, 2014 7:13 PM, M.-A. Lemburg m...@python.org wrote: [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 until they moved on to spend their time on other things. We've now reached such a point again. In these years, the volume on the job board has significantly increased, as it got more and more popular. It is now at around 2-5 postings per day and most of those positions get filled quickly - which is an indication of how useful this service is to the Python community. To scale up and revive the job board, the PSF would now like to setup a *team of volunteers* to run the job board and this is our call for help. How does the job board work ? - At the moment, the job board is maintained on the legacy site (http://legacy.python.org/community/jobs/), but since we've launched our brand new website (http://www.python.org/), we'd like to move the job board over to that site. Instead of the repository based approach used on the old site, the new site has database support to aid in more easily processing and filing job listings. There's a job board mailing list which helps coordinate the task of reviewing and filing job offers. Currently, all job submissions get sent to this mailing list, but with the job board app, the submission process can be moved over to the website's database. What does it take to run the job board ? You have to review the job postings, request changes if they are too long, don't clearly state the need for Python skills, or have quality issues. After review, the job board app will then allow posting the jobs on the website by simply setting the status to published. Communication with the submitters is usually done by email and via the mailing list, so all team members can see the communication and help out if necessary. Please note: This is just a high level overview. The details need to be hashed out by the new team. Does the job board app work already ? - It does, but is disabled at the moment due to lack of volunteers. Since the site just launched there may also well be some issues with the job board app. On the positive side there's a lot happening around the site at the moment, so if you have change requests, these will usually be implemented quickly - or you can jump in, hack on the job board app and submit a pull request yourself: https://github.com/python/pythondotorg/tree/master/jobs These are exciting times and this is your chance to make a difference ! Ok, I like new challenges - where do I sign up ? Great :-) Please write to j...@python.org I have a question... If you have questions, you can write me or the PSF board at p...@python.org. Many thanks, -- Marc-Andre Lemburg Director Python Software Foundation http://www.python.org/psf/ -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Grant Edwards invalid@invalid.invalid: Wrong. If the two objects are not the same, then they will have different ID values. If the ID values are the same, then you've only got one object. Ok, that circularity again. Say I implement Python. Say I returned a random number for id(), how would that violate the language spec? It would violate the spec. But there would have to be a paragraph in the specification that was violated or a reference test case that failed. For example, this test would demonstrate obviously invalid behavior: print(id(x)) 129 print(id(x)) 201 I'm sorry, what problem are you trying to solve? I think the discussion spawned from the problem of teaching programming students the right idea of values and objects. A teacher would like to bring in advanced concepts last, but Python seems to force you to get them at the very beginning. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Marko Rauhamaa ma...@pacujo.net writes: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Both the Jython and CPython id() functions are compliant with the language definition. The Jython id() function is better, because it doesn't encourage people to mistakenly and foolishly imagine that id() equals address. I agree with everything (how could I not) except the foolishness part: what bad consequence is there for imagining that id() equals address? It is a false inference. A reference-compliant implementation can contradict your inference (by returning an object identity that is *not* the object's memory address). Any code you've written based on that false inference will break. The fault will be yours, for inferring an assertion that isn't implied by the definition. -- \ “The surest way to corrupt a youth is to instruct him to hold | `\ in higher esteem those who think alike than those who think | _o__) differently.” —Friedrich Nietzsche, _The Dawn_, 1881 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Marko Rauhamaa ma...@pacujo.net writes: Say I implement Python. Say I returned a random number for id(), how would that violate the language spec? You could do that, certainly. So long as that randomly-chosen integer was always the same for every object, and never the same for any other concurrently-existing object, it can just as well be assigned randomly. If you're saying that your implementation of ‘id(foo)’ would return a *different* integer when called at different times for the same object, then yes, that violates the specification for that function. It would violate the spec. But there would have to be a paragraph in the specification that was violated or a reference test case that failed. Yes. It would violate this paragraph: Every object has an identity, a type and a value. An object’s identity never changes once it has been created […] the id() function returns an integer representing its identity. URL:http://docs.python.org/3/reference/datamodel.html Again, I ask you to read these documents for comprehension. For example, this test would demonstrate obviously invalid behavior: print(id(x)) 129 print(id(x)) 201 Yes. That violates the paragraph above, and so that implementation is not compliant with the Python language reference. -- \ “I watched the Indy 500, and I was thinking that if they left | `\ earlier they wouldn't have to go so fast.” —Steven Wright | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Marko Rauhamaa ma...@pacujo.net writes: Grant Edwards invalid@invalid.invalid: Wrong. If the two objects are not the same, then they will have different ID values. If the ID values are the same, then you've only got one object. Ok, that circularity again. Yes, it's circular. In an abstract system like a programming language, where the definition only needs to describe behaviour of that system, what is your objection to circularity of definition? A great many abstract systems designed by humans are defined in terms that are ultimately circular. This does not in any way hinder them from being useful definitions of useful systems. -- \“All opinions are not equal. Some are a very great deal more | `\robust, sophisticated and well supported in logic and argument | _o__) than others.” —Douglas Adams | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Ben Finney ben+pyt...@benfinney.id.au: A reference-compliant implementation can contradict your inference (by returning an object identity that is *not* the object's memory address). Any code you've written based on that false inference will break. The fault will be yours, for inferring an assertion that isn't implied by the definition. Show me a few lines of Python that demonstrate the error of the false inference, please. When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On 5 March 2014 17:43, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 05 Mar 2014 12:21:37 +, Oscar Benjamin wrote: The argument that the sum of all natural numbers comes to -1/12 is just some kind of hoax. I don't think *anyone* seriously believes it. You would be wrong. I suggest you read the links I gave earlier. Even the mathematicians who complain about describing this using the word equals don't try to dispute the fact that you can identify the sum of natural numbers with ζ(-1), or that ζ(-1) = -1/12. They simply dispute that we should describe this association as equals. What nobody believes is that the sum of natural numbers is a convergent series that sums to -1/12, because it is provably not. In other words, this is not an argument about the maths. Everyone who looks at the maths has to admit that it is sound. It's an argument about the words we use to describe this. Is it legitimate to say that the infinite sum *equals* -1/12? Or only that the series has the value -1/12? Or that we can associate (talk about a sloppy, non-vigorous term!) the series with -1/12? This is the point. You can identify numbers with many different things. It does not mean to say that the thing is equal to that number. I can associate the number 2 with my bike since it has 2 wheels. That doesn't mean that the bike is equal to 2. So the problem with saying that the sum of the natural numbers equals -1/12 is precisely as you say with the word equals because they're not equal! If you restate the conclusion in more accurate (but technical and less accessible) way that the analytic continuation of a related set of convergent series has the value -1/12 at the value that would correspond to this divergent series then it becomes less mysterious. Do I really have to associate the finite negative value found in the analytic continuation with the sum of the series that is provably greater than any finite number? snip At one time, Euler summed an infinite series and got -1, from which he concluded that -1 was (in some sense) larger than infinity. I don't know what justification he gave, but the way I think of it is to take the number line from -∞ to +∞ and then bend it back upon itself so that there is a single infinity, rather like the projective plane only in a single dimension. If you start at zero and move towards increasingly large numbers, then like Buzz Lightyear you can go to infinity and beyond: 0 - 1 - 10 - 1 - ... ∞ - ... -1 - -10 - -1 - 0 In this sense, -1/12 is larger than infinity. There are many examples that appear to show wrapping round from +infinity to -infinity e.g. the tan function. The thing is that it is not really physical (or meaningful in any direct sense). So for example I might consider the forces on a particle, apply Newton's 2nd law and arrive at a differential equation for the acceleration of the particle, solve the equation and find that the position of the particle at time t is given by tan(t). This would seem to imply that as t increases toward pi/2 the particle heads off infinity miles West but at the exact time pi/2 it wraps around to reappear at infinity miles East and starts heading back toward its starting point. The truth is less interesting: the solution tan(t) becomes invalid at pi/2 and mathematics can tell us nothing about what happens after that even if all the physics we used was exactly true. Now of course this is an ad hoc sloppy argument, but I'm not a professional mathematician. However I can tell you that it's pretty close to what the professional mathematicians and physicists do with negative absolute temperatures, and that is rigorous. http://en.wikipedia.org/wiki/Negative_temperature The key point from that page is the sentence A definition of temperature can be based on the relationship It is clear that temperature is a theoretical abstraction. We have intuitive understandings of what it means but in order for the current body of thermodynamic theory to be consistent it is necessary to sometimes give negative values to the temperature. There's nothing unintuitive about negative temperatures if you understand the usual thermodynamic definitions of temperature. Personally I think it's reasonable to just say that the sum of the natural numbers is infinite rather than messing around with terms like undefined, divergent, or existence. There is a clear difference between a series (or any limit) that fails to converge asymptotically and another that just goes to +-infinity. The difference is usually also relevant to any practical application of this kind of maths. And this is where you get it exactly backwards. The *practical application* comes from physics, where they do exactly what you argue against: they associate ζ(-1) with the sum of the natural numbers (see, I too can avoid the word equals too), and *it works*. I don't know all the details of what they do there and whether or not
Re: Reference
On Thu, Mar 6, 2014 at 8:14 AM, Marko Rauhamaa ma...@pacujo.net wrote: When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Where's the complaints about circularity now? You're saying But of course id() returns the address, as long as we define the address as 'whatever id() returns'.. Unimpeachably logical and utterly unhelpful. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 2014-03-05 23:14, Marko Rauhamaa wrote: When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Let me translate what the rest of the group hears: When I talk about an object's memory address, I'm not referring to *what every other computer scientist/professional means by memory address rather I can simply make up my own definition for memory address so that it means something that proves my point.* It's perfectly valid for the definition of id() to return negative numbers, yet in just about every situation (both hypothetical CS worlds and out in the real world), a memory-address is defined as an unsigned number. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 05/03/2014 20:46, Marko Rauhamaa wrote: I think the discussion spawned from the problem of teaching programming students the right idea of values and objects. A teacher would like to bring in advanced concepts last, but Python seems to force you to get them at the very beginning. Nonsense, people starting out with Python have stated how easy it is to just start writing Python code. This would obviously not be possible if advanced concepts had to be learned up front. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Marko Rauhamaa ma...@pacujo.net writes: Ben Finney ben+pyt...@benfinney.id.au: A reference-compliant implementation can contradict your inference (by returning an object identity that is *not* the object's memory address). Any code you've written based on that false inference will break. The fault will be yours, for inferring an assertion that isn't implied by the definition. Show me a few lines of Python that demonstrate the error of the false inference, please. It need not be Python; it could be an extension library to which you pass the ‘id(foo)’ result, on the false assumption that it must be a memory location. Besides which, it is *you* that declares this abstraction to be leaky. If you're unable to show how that's the case, I rest on the null hypothesis: your assertion is untrue. When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Then this does not count as a leaky abstraction. All you're saying is that the ‘id(foo)’ result is a representation of the object identity, which is entirely at the level of the abstraction. Nothing is leaked. -- \ “God forbid that any book should be banned. The practice is as | `\ indefensible as infanticide.” —Dame Rebecca West | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Program Python
I'm very grateful if anyone can helpme to find a good program to develop in python lenguage. Thanks Inviato da: Ernesto Luciano Trespidi Email: keple...@hotmail.com Tel. 3299255463 -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 05/03/2014 21:33, Tim Chase wrote: On 2014-03-05 23:14, Marko Rauhamaa wrote: When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Let me translate what the rest of the group hears: When I talk about an object's memory address, I'm not referring to *what every other computer scientist/professional means by memory address rather I can simply make up my own definition for memory address so that it means something that proves my point.* It's perfectly valid for the definition of id() to return negative numbers, yet in just about every situation (both hypothetical CS worlds and out in the real world), a memory-address is defined as an unsigned number. -tkc I actually hear the spam song, except s/spam/troll/ Didn't we learn anything from the sadly still ongoing saga of our resident unicode expert? :( -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Program Python
Luciano Trespidi keple...@hotmail.com writes: I'm very grateful if anyone can helpme to find a good program to develop in python lenguage. Thanks The best program to use for developing in the Python language is the Python interpreter :-) Beyond which, you may be interested in the Python community's “tutor” forum URL:https://mail.python.org/mailman/listinfo/tutor, a great resource for asking questions about the basics of Python. -- \ “The most common of all follies is to believe passionately in | `\the palpably not true. It is the chief occupation of mankind.” | _o__)—Henry L. Mencken | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Chris Angelico ros...@gmail.com: On Thu, Mar 6, 2014 at 8:14 AM, Marko Rauhamaa ma...@pacujo.net wrote: When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Where's the complaints about circularity now? You're saying But of course id() returns the address, as long as we define the address as 'whatever id() returns'.. Unimpeachably logical and utterly unhelpful. Main thing, no harm done. The memory address is neither right nor wrong. It's completely irrelevant since it doesn't occupy a place in Python's data model. Marko -- https://mail.python.org/mailman/listinfo/python-list
script uses up all memory
I have a script that forks off other processes and attempts to manage them. Here is a stripped down version of the script: self.sleepTime = 300 self.procs = {} self.startTimes = {} self.cmd = ['python', '/usr/local/motor/motor/app/some_other_script.py'] while True: try: self.tools = Tool.objects.filter(ip__isnull=False) except Exception, e: print 'error from django call: ' + str(e) sys.exit(1) for tool in self.tools: name = tool.name if name in self.procs: if self.procs[name].poll() is None: if (datetime.datetime.now()-self.startTimes[name]) datetime.timedelta(hours=12): # it's been running too long - kill it print 'killing script for ' + name + it's been running too long self.procs[name].kill() else: continue if self.procs[name].returncode: print 'scrikpt failed for ' + name + ', error = ' + str(self.procs[name].returncode) print 'starting script.py for ' + name + ' at ' + str(datetime.datetime.now()) try: self.procs[name] = subprocess.Popen(self.cmd) self.startTimes[name] = datetime.datetime.now() except Exception, e: print 'error from Popen: ' + str(e) sys.exit(1) else: print 'starting script.py for ' + name + ' at ' + str(datetime.datetime.now()) try: self.procs[name] = subprocess.Popen(self.cmd) self.startTimes[name] = datetime.datetime.now() except Exception, e: print 'error from Popen: ' + str(e) sys.exit(1) time.sleep(self.sleepTime) The script does what it's intended to do, however after about 2 hours it has used up all the memory available and the machine hangs. Can anyone see something that I am doing here that would be using memory like this? Perhaps some immutable object needs to be repeatedly recreated? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to create an instance of a python class from C++
On Wednesday 05 March 2014 17:09:53 Grant Edwards did opine: On 2014-03-05, Alister alister.w...@ntlworld.com wrote: Why are you creating an ABC? Because it was the first binary computer that did calculations with electronic switching elements (gates), and it would be really cool to have one! The ABC also pioneered the use of capciators as regenerative storage elements (it's how DRAM still works today). http://en.wikipedia.org/wiki/Atanasoff%E2%80%93Berry_Computer It predated ENIAC, and it's clear that some of the features of ENIAC were inspired by the ABC after John Mauchly visited Iowa State and saw the ABC. But it was not programmable True. It had only one program that was hard-wired into it when it was built as opposed to the external patch-cords and switches that were used on machines like Colossus and ENIAC to alter the wiring. the first programmable electronic computer was 'Colossus' which was developed during WWII but remained classified by the UK govt for many years afterwards http://en.wikipedia.org/wiki/Colossus_computer What machine was it that had about 12,000 12AU7 vacuum tubes in it for logic? They had one of those, adapted to read the output of a bed of photocells installed in a Harris sheet fed press on the SUI campus in the later 1950's. I saw it running once, grading the test score sheets from the Iowa Tests that were being used in lieu of the high price per seat S-B IQ test in the Iowa schools. It was IIRC a somewhat difficult test when they threw it at me in the 7th grade a decade earlier, they claimed the test score were interchangeable with the S-B scores, but I somehow managed a 147 on it at the time. Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) Genes Web page http://geneslinuxbox.net:6309/gene NOTICE: Will pay 100 USD for an HP-4815A defective but complete probe assembly. -- https://mail.python.org/mailman/listinfo/python-list
Re: script uses up all memory
On Thu, Mar 6, 2014 at 9:27 AM, Larry Martell larry.mart...@gmail.com wrote: I have a script that forks off other processes and attempts to manage them. Here is a stripped down version of the script: self.sleepTime = 300 That's not a stand-alone script. What environment is it running in? Can you reproduce the problem outside of that environment? Also: Can you simply use multiprocessing rather than going through all the effort of subprocess.Popen? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: ANN: Python Job Board - Call for volunteers
I hope this means there'll soon be an option to restrict ads seen by some form of postal code or phone area code (with telecommute hopefully being an optional wildcard). On Thu, Feb 27, 2014 at 6:59 AM, M.-A. Lemburg m...@python.org wrote: [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 until they moved on to spend their time on other things. We've now reached such a point again. -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 3/5/2014 3:46 PM, Marko Rauhamaa wrote: Grant Edwards invalid@invalid.invalid: Wrong. If the two objects are not the same, then they will have different ID values. If the ID values are the same, then you've only got one object. Ok, that circularity again. Every deductive system starts with some undefined terms. These, along with axioms or postulates, are how circularity is avoided. There typically is a choice as to which concepts are taken as primitive and which are defined in terms of them. In Python, one could take 'object' and the notions of same versus different object as primitive. Say I implement Python. Say I returned a random number for id(), In CPython, the int id of an object is arbitrary, somewhat haphazard, and effectively random in the colloquial sense of the term. how would that violate the language spec? It obviously does not as long as the 'random' id obeys the id axioms of persistence and uniqueness. I think the discussion spawned from the problem of teaching programming students the right idea of values and objects. A teacher would like to bring in advanced concepts last, but Python seems to force you to get them at the very beginning. Kids learn the notion of object persistence quite early (first year, I think). Kids also learn that there are multiple ways of referring to one and the same person or object, and that some references ('teacher') can be rebound to a different person or object. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Program Python
On 2014-03-05 22:41, Luciano Trespidi wrote: I'm very grateful if anyone can helpme to find a good program to develop in python lenguage. Thanks This reminds me of the old joke: Q: Why are you scratching yourself? A: Because I'm the only one who knows where I itch! The best place to find a good program to develop in Python is to look at what you want to be able to do, but haven't found something that does what you want. Perhaps you tire of manually processing files at work and want to automate it. Perhaps you want to email your Mum on one random day each month. Perhaps you want to calculate lottery numbers according to your own personal preference. Perhaps you want to make a game. So many possibilities. So look for something that would scratch an itch you have, and go for it! :-) -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: script uses up all memory
On Wed, Mar 5, 2014 at 5:39 PM, Chris Angelico ros...@gmail.com wrote: On Thu, Mar 6, 2014 at 9:27 AM, Larry Martell larry.mart...@gmail.com wrote: I have a script that forks off other processes and attempts to manage them. Here is a stripped down version of the script: self.sleepTime = 300 That's not a stand-alone script. No, that is just the part that does the work (inside the 'while true'). I'll try and post a standalone script tomorrow. What environment is it running in? CentOS 6,4 Can you reproduce the problem outside of that environment? I will try that tomorrow. Also: Can you simply use multiprocessing rather than going through all the effort of subprocess.Popen? Perhaps. I didn't write this. A client gave it to me and said 'figure out why it uses up all the memory and hangs.' I've messed around with for days and cannot see anything that would consume so much memory. -- https://mail.python.org/mailman/listinfo/python-list
Re: script uses up all memory
On Thu, Mar 6, 2014 at 11:20 AM, Larry Martell larry.mart...@gmail.com wrote: On Wed, Mar 5, 2014 at 5:39 PM, Chris Angelico ros...@gmail.com wrote: On Thu, Mar 6, 2014 at 9:27 AM, Larry Martell larry.mart...@gmail.com wrote: I have a script that forks off other processes and attempts to manage them. Here is a stripped down version of the script: self.sleepTime = 300 That's not a stand-alone script. No, that is just the part that does the work (inside the 'while true'). I'll try and post a standalone script tomorrow. What environment is it running in? CentOS 6,4 That's not the whole environment, though. There's a mention of Django - does this run inside some framework? Can you reproduce the problem outside of that environment? I will try that tomorrow. Running as a stand-alone script, still under CentOS, would be what I mean by outside of that environment. I'm talking about making something that can be saved to my drive and executed, perhaps with a stubby subprocess script (eg import time; time.sleep(86400)). Also: Can you simply use multiprocessing rather than going through all the effort of subprocess.Popen? Perhaps. I didn't write this. A client gave it to me and said 'figure out why it uses up all the memory and hangs.' I've messed around with for days and cannot see anything that would consume so much memory. Ah. Yeah, that would be a fun little job to play with. My random thought: Do the subprocesses produce spammy log output? If so, the monitor might be collecting it all and holding it in memory in case you want it (not knowing that you don't). The default should be to leave them connected to your process's stdio streams, though, so that shouldn't be the issue. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On Thu, 06 Mar 2014 08:26:22 +1100, Chris Angelico wrote: On Thu, Mar 6, 2014 at 8:14 AM, Marko Rauhamaa ma...@pacujo.net wrote: When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Where's the complaints about circularity now? You're saying But of course id() returns the address, as long as we define the address as 'whatever id() returns'.. Unimpeachably logical and utterly unhelpful. That last sentence is wrong. There is nothing logical about just making up arbitrary definitions in this way. He could invent *any* definition, each more ridiculous than the last: - it's the object's memory address; - it's the object's phone number; - it's the number of baby elephants killed by the object; - it's the number of intergalactic empires that are, even as we speak, rushing to Earth to invade to gain possession of that object; - it's the weight in metric tonnes of the electrons in the object; (Not *actual* electrons of course, just these arbitrary inventions of Marko's definition.) - it's the length measured in seconds of the bitterness of the object's kidney; and of course: - the number of angels that can dance on the object. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: script uses up all memory
On Wed, Mar 5, 2014 at 7:33 PM, Chris Angelico ros...@gmail.com wrote: On Thu, Mar 6, 2014 at 11:20 AM, Larry Martell larry.mart...@gmail.com wrote: On Wed, Mar 5, 2014 at 5:39 PM, Chris Angelico ros...@gmail.com wrote: On Thu, Mar 6, 2014 at 9:27 AM, Larry Martell larry.mart...@gmail.com wrote: I have a script that forks off other processes and attempts to manage them. Here is a stripped down version of the script: self.sleepTime = 300 That's not a stand-alone script. No, that is just the part that does the work (inside the 'while true'). I'll try and post a standalone script tomorrow. What environment is it running in? CentOS 6.4 That's not the whole environment, though. There's a mention of Django - does this run inside some framework? The system this is part of uses Django, and this script makes use of the django ORM, but it doesn't do any web stuff itself. It just kicks off another script once for each tool found in the database, and ensure that there's just one script pre tool running at a time, and that no single script runs too long. The django part can easily be removed. Can you reproduce the problem outside of that environment? I will try that tomorrow. Running as a stand-alone script, still under CentOS, would be what I mean by outside of that environment. I'm talking about making something that can be saved to my drive and executed, perhaps with a stubby subprocess script (eg import time; time.sleep(86400)). Yes, I understand what you mean. Also: Can you simply use multiprocessing rather than going through all the effort of subprocess.Popen? Perhaps. I didn't write this. A client gave it to me and said 'figure out why it uses up all the memory and hangs.' I've messed around with for days and cannot see anything that would consume so much memory. Ah. Yeah, that would be a fun little job to play with. My random thought: Do the subprocesses produce spammy log output? If so, the monitor might be collecting it all and holding it in memory in case you want it (not knowing that you don't). The default should be to leave them connected to your process's stdio streams, though, so that shouldn't be the issue. Ohh, that's a good random thought. I'll try that tomorrow and see if that's the issue. -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On Thu, Mar 6, 2014 at 11:35 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 06 Mar 2014 08:26:22 +1100, Chris Angelico wrote: Where's the complaints about circularity now? You're saying But of course id() returns the address, as long as we define the address as 'whatever id() returns'.. Unimpeachably logical and utterly unhelpful. That last sentence is wrong. There is nothing logical about just making up arbitrary definitions in this way. He could invent *any* definition, each more ridiculous than the last: I mean logical in the sense of pure logic. If all spam is edible-food And if this-can is spam Then this-can is edible-food The opening premise is false (I wouldn't want to eat a punctured can that's been sitting around for a few months), but it's still perfectly logical. The conclusion is guaranteed to be true as long as the premises are. In that sense of the word, the statement is indeed logical. That doesn't stop it from being wrong, but it is logical. If the 'is' comparison is reflexive, And if three is four, Then four is three. Perfectly logical. He's saying that the address of an object is simply whatever id() returns for that object. Since Python doesn't currently have any other concept of object addresses, that definition isn't in conflict with anything. Then he says, look! the id() function returns the object's address. Well, duh, that's how you defined the address. It's logical. Of course it returns the address, since the address has been defined as what it returns. But it doesn't achieve anything to prove that. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Ben Finney ben+pyt...@benfinney.id.au: Marko Rauhamaa ma...@pacujo.net writes: When I talk about an object's memory address, I'm not referring to what might be revealed by gdb, for example. That is, I'm not talking about the process's virtual address space, nor am I talking about the physical address on the address bus. I can simply define that the object's memory address is whatever id() returns. Then this does not count as a leaky abstraction. All you're saying is that the ‘id(foo)’ result is a representation of the object identity, which is entirely at the level of the abstraction. Nothing is leaked. I wasn't making a point about a leaky abstraction. I was just saying talking about id() as a memory address isn't all that bad. It's a bit like rolling down your power windows or turning up the volume, when there's nothing to roll or turn. There's no risk of getting your program wrong. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
Marko Rauhamaa ma...@pacujo.net writes: Ben Finney ben+pyt...@benfinney.id.au: Then this does not count as a leaky abstraction. All you're saying is that the ‘id(foo)’ result is a representation of the object identity, which is entirely at the level of the abstraction. Nothing is leaked. I wasn't making a point about a leaky abstraction. Can we conclude that you've changed your position on this, then? You now accept that Python's object identity abstraction is not leaky? In the absence of you demonstrating a leak in that abstraction, we can ignore the assertion. -- \ “For myself, I am an optimist — it does not seem to be much use | `\ being anything else.” —Winston Churchill, 1954-11-09 | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wednesday, March 5, 2014 6:24:52 PM UTC-6, Dennis Lee Bieber wrote: I must have had a deprived life... The only debug on a home system I ever used was the one in LS-DOS. And even then, it was only because an OS update disk arrived with a bad sector and could not be copied. Not many people realized what they had in front of them. The only reason you might is if you 'grew up' on a system that required machine coding; like the Wang 700 series, or the MITS Altair 8800, or the VIC 20 with VicMon. I grew up with all three. So, before I ever learned a line of BASIC I was coding machine language (not assembler) on the three platforms above... the wang used integrated circuits, but had to processor chip; the MITS used the very first 8080 chip from Intel, and the VIC 20 used the 6502 from Motorola. My first personal computer (I did not own it, it was temporarily loaned to me) was the VIC 20. It only had 5k of memory, so anyone who did any real programming on it purchased the VicMon cartridge which was a 'machine language monitor'. It was DEBUG.COM for the VIC 20. When I got the first copy of DOS on floppy and saw DEBUG.COM I knew instantly what it was... a machine language monitor system for reading and writing machine code (8086 / 8088) in memory, or to disk sectors, or to disk as a file-name. It wasn't just a debugger---hardly! It was (and still is, yes, I still use it) a simple clean full-blown machine language monitor capable today just as then, to build sophisticated applications with 1's and 0's/ It was also my cup of tea, as it were. The folks who used the MITS Altair 8800 hated punching code in by hand; gets old fast. But not for me. I loved it, because I was as interested in the 8080 processor as I was in writing programs for it; it was great fun experimenting with memory and the processor. marcus -- https://mail.python.org/mailman/listinfo/python-list
test
test please disregard -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On 2014-03-06 01:24, Mark H. Harris wrote: On Wednesday, March 5, 2014 6:24:52 PM UTC-6, Dennis Lee Bieber wrote: I must have had a deprived life... The only debug on a home system I ever used was the one in LS-DOS. And even then, it was only because an OS update disk arrived with a bad sector and could not be copied. Not many people realized what they had in front of them. The only reason you might is if you 'grew up' on a system that required machine coding; like the Wang 700 series, or the MITS Altair 8800, or the VIC 20 with VicMon. I grew up with all three. So, before I ever learned a line of BASIC I was coding machine language (not assembler) on the three platforms above... the wang used integrated circuits, but had to processor chip; the MITS used the very first 8080 chip from Intel, and the VIC 20 used the 6502 from Motorola. The 6502 came from MOS Technology. Motorola made the 6800. My first personal computer (I did not own it, it was temporarily loaned to me) was the VIC 20. It only had 5k of memory, so anyone who did any real programming on it purchased the VicMon cartridge which was a 'machine language monitor'. It was DEBUG.COM for the VIC 20. 5K? Luxury! I started with the Science of Cambridge Mk14. Including the RAM on the I/O chip, it had 640 bytes. When I got the first copy of DOS on floppy and saw DEBUG.COM I knew instantly what it was... a machine language monitor system for reading and writing machine code (8086 / 8088) in memory, or to disk sectors, or to disk as a file-name. It wasn't just a debugger---hardly! It was (and still is, yes, I still use it) a simple clean full-blown machine language monitor capable today just as then, to build sophisticated applications with 1's and 0's/ It was also my cup of tea, as it were. The folks who used the MITS Altair 8800 hated punching code in by hand; gets old fast. But not for me. I loved it, because I was as interested in the 8080 processor as I was in writing programs for it; it was great fun experimenting with memory and the processor. -- https://mail.python.org/mailman/listinfo/python-list
Re: Origin of 'self'
Why did C++ use this? I don't really like this. It doesn't sound right. I think it's because I have trouble saying the th sound without getting my mouth full of spit. Thankfully you don't often need to use this in C++ like you do with self in Python. -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wednesday, March 5, 2014 7:40:05 PM UTC-6, MRAB wrote: The 6502 came from MOS Technology. Motorola made the 6800. Well, not exactly. The MOS 6502 is to the Motorola 6800 what the Zilog Z80 was to the Intel 8080. The same engineers who designed the 6800 moved out and then designed the 6502; actually ended up in a law suit of sorts--- but I don't remember the details. Anyway, the 6502 was bought outright by Commodore, and the rest is history with the VIC20. The engineers at Intel did the same thing... moved out and started Zilog (which still exists today) and began their work on the Z80. By the by, the Z80 is still embedded in many applications today. Although, its not on a 40 pin dip any longer; its a small square about the size of a postage stamp. That is what powers the TI 84+ and the TI 83+ graphing programable calculators. I do some machine coding on the TI 84+ because it can be done on-the-device! The 68000 is the motorola chip that powers the TI89 graphing programable calculator ( my favorite ). Its not so easy to program it with machine code, because the kernel binaries are not well documented (TI hides them) and the user community hasn't probed it enough to know how does it really work. 5K? Luxury! I started with the Science of Cambridge Mk14. Including the RAM on the I/O chip, it had 640 bytes. Oh, I know. I thought 5k was a tremendous about of memory at the time, but we soon built and expanded for the slot, added 16k of memory (hand wire-wrapped thank you) and then plugged the VicMon (actually HES MON) into that. Do you remember the IAS (Maniac) at the Institute for Advanced Study (Johnny von Neumann's baby) ? It only had 5k of memory too! They had to use punched cards or punched tape for intermediate results when they were doing their runs calculating the wave function for the hydrogen bomb. At the time, Johnny said, there will never be a need for for than five machines like this in the whole world! marcus -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On 6/03/2014 10:52 AM, Marko Rauhamaa wrote: I was just saying talking about id() as a memory address isn't all that bad. It's a bit like rolling down your power windows or turning up the volume, when there's nothing to roll or turn. There's no risk of getting your program wrong. Unless you're talking about, say, the PyPy implementation, for which id is _not_ a memory address at all. Why insist on using memory address rather than unique identifier, when the latter is fundamentally more correct? -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
In article 53176225$0$29987$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Physics is the fundamental science, at least according to the physicists, and Real Soon Now they'll have a Theory Of Everything, something small enough to print on a tee-shirt, which will explain everything. At least in principle. A mathematician, a chemist, and a physicist are arguing the nature of prime numbers. The chemist says, All odd numbers are prime. Look, I can prove it. Three is prime. Five is prime. Seven is prime. The mathematician says, That's nonsense. Nine is not prime. The physicist looks at him and says, H, you may be right, but eleven is prime, and thirteen is prime. It appears that within the limits of experimental error, all odd number are indeed prime! -- https://mail.python.org/mailman/listinfo/python-list
Re: How security holes happen
On Wednesday, March 5, 2014 8:52:31 AM UTC+8, Andrew Cooper wrote: On 03/03/2014 22:19, Cameron Simpson wrote: On 03Mar2014 09:17, Neal Becker ndbeck...@gmail.com wrote: Charles R Harris charlesr.har...@gmail.com Wrote in message: Imo the lesson here is never write in low level c. Use modern languages with well designed exception handling. What, and rely on someone else's low level C? Why is C the lowest denominator? Even with correctly written C and assembly, how can you be sure that your processor is executing the SYSRET instruction safely? (CVE-2012-0217 for anyone interested) ~Andrew It is not difficult to write C with mixed assembly codes for different CPUs. #ifdef ASM /* asm follows */ #ifdef CPUTYPES /* insert CPU ASMS for different CPUs carefully here */ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python programming
In article roy-a94c1b.22041912022...@news.panix.com, Roy Smith r...@panix.com wrote: In article ldhcau$d9v$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: On 2014-02-13, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: An S-100 wire-wrap board. Yup, been there done that! Never did S-100, but I did do a custom Unibus card (wirewrap). You know you're working with a Real Computer (tm) when the +5V power supply can deliver as much current as an arc welder. I've a 64 node Parsytec transputer system in the hall way with dual 5V 100A power supplies. Does that count? Groetjes Albert -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst -- https://mail.python.org/mailman/listinfo/python-list
Re: Reference
On Wed, 05 Mar 2014 22:23:46 +0200, Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: There is no metaphysical implication from Python's is operator. If the operator had precisely the same behaviour, but was called same, as in: a same b = returns True if a and b are the same object = returns False if a and b are not the same object would you claim there was a metaphysical implication? I would. You are not defining anything because you are not explaining what same object means. I mean exactly the same thing by same object as you do when you use it: Set theory obeys the so-called extensionality principle: if two objects are indistinguishable in every way, they are one and the same object. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Diagnose a segfault in ipython/readline
Hi, I'm getting a reproducible crash in ipython, but not sure what upstream it should belong to. The crash happens with python 2.7.6/3.3.4, with readline 6.3. Steps to reproduce: - run ipython - input some random char sequence that you never inputed (like ae3r0gka03k0k23), don't press Enter - press Up, followed by any key Backtrace pasted here: https://paste.xinu.at/cg7/ Downstream bug report on Arch Linux: https://bugs.archlinux.org/task/39144 Any help would be really appreciated! Regards, Felix Yan signature.asc Description: This is a digitally signed message part. -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On Wed, 05 Mar 2014 21:31:51 -0500, Roy Smith wrote: In article 53176225$0$29987$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Physics is the fundamental science, at least according to the physicists, and Real Soon Now they'll have a Theory Of Everything, something small enough to print on a tee-shirt, which will explain everything. At least in principle. A mathematician, a chemist, and a physicist are arguing the nature of prime numbers. The chemist says, All odd numbers are prime. Look, I can prove it. Three is prime. Five is prime. Seven is prime. The mathematician says, That's nonsense. Nine is not prime. The physicist looks at him and says, H, you may be right, but eleven is prime, and thirteen is prime. It appears that within the limits of experimental error, all odd number are indeed prime! They ask a computer programmer to adjudicate who is right, so he writes a program to print out all the primes: 1 is prime 1 is prime 1 is prime 1 is prime 1 is prime ... -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On Thu, Mar 6, 2014 at 2:06 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: They ask a computer programmer to adjudicate who is right, so he writes a program to print out all the primes: 1 is prime 1 is prime 1 is prime 1 is prime 1 is prime And he claimed that he was correct, because he had - as is known to be true in reality - a countably infinite number of primes. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with the set of real numbers (was: Finding size of Variable)
On 2014-03-06, Roy Smith r...@panix.com wrote: In article 53176225$0$29987$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Physics is the fundamental science, at least according to the physicists, and Real Soon Now they'll have a Theory Of Everything, something small enough to print on a tee-shirt, which will explain everything. At least in principle. A mathematician, a chemist, and a physicist are arguing the nature of prime numbers. The chemist says, All odd numbers are prime. Look, I can prove it. Three is prime. Five is prime. Seven is prime. The mathematician says, That's nonsense. Nine is not prime. The physicist looks at him and says, H, you may be right, but eleven is prime, and thirteen is prime. It appears that within the limits of experimental error, all odd number are indeed prime! Assuming spherical odd numbers in a vacuum on a frictionless surface, of course. -- Grant -- https://mail.python.org/mailman/listinfo/python-list