Re: can't add variables to instances of built-in classes

2016-07-21 Thread Peter Otten
breamore...@gmail.com wrote: > I hereby request that the moderators take this idiot offline as he's Mark, please behave yourself. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python packages listed in PyPI

2016-07-21 Thread Rayne via Python-list
"I don't understand what difference you intend between “implementations” and “packages”." I meant whether the package is self-contained, that is, all the different implementations for different OS and versions of Python are already contained in the package itself. But you've already answered m

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Marko Rauhamaa
Rustom Mody : > The field of numerical analysis came into existence only because this > fact multiplied by the fact that computers do their (inaccurate ≠ > inexact) computations billions of times faster than we do makes > significance a very significant problem! A couple of related anecdotes invol

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Chris Angelico
On Thu, Jul 21, 2016 at 5:52 PM, Marko Rauhamaa wrote: > A couple of related anecdotes involving integer errors. > > 1. I worked on a (video) product that had to execute a piece of code >every 7 µs or so. A key requirement was that the beat must not drift >far apart from the ideal over tim

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Jul 21, 2016 at 5:52 PM, Marko Rauhamaa wrote: >> A couple of related anecdotes involving integer errors. >> >> 1. I worked on a (video) product that had to execute a piece of code >>every 7 µs or so. A key requirement was that the beat must not drift >>far apar

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Rustom Mody
On Thursday, July 21, 2016 at 12:04:35 PM UTC+5:30, Steven D'Aprano wrote: > On Thursday 21 July 2016 15:28, Rustom Mody wrote: > > BTW APL whose main domain of application is scientific chooses to enshrine > > this —equality is ε-neighborhood checking not exact equality checking — into > > its bui

How to do Integration testing of a C code/firmware in python

2016-07-21 Thread puravnshah
I am doing an Internship at a company. I have a multi threaded code/firmware in c. I have done its unit testing with cantata in c++ and now want to do Integration testing in python with the device connected to my PC. From where do I start. How and what to write. The code has various functions wi

Ide or code editor confusion

2016-07-21 Thread sigmaphine1914
I'm learning Python and something is really unclear on the chapter im on. So Python has its own IDE to write code but now it's talking about "code editors" My confusion is so I need a code editor like Sublime text? Is that what Python IDE is for? -- https://mail.python.org/mailman/listinfo/p

Re: Ide or code editor confusion

2016-07-21 Thread Chris Angelico
On Thu, Jul 21, 2016 at 11:56 PM, wrote: > I'm learning Python and something is really unclear on the chapter im on. > > So Python has its own IDE to write code but now it's talking about "code > editors" > > My confusion is so I need a code editor like Sublime text? Is that what > Python IDE i

Re: Ide or code editor confusion

2016-07-21 Thread sigmaphine1914
Beginning Python: using Python 2.6 and Python 3.1. By James Payne Part II. But I think that answered my question. Great because au was worried -- https://mail.python.org/mailman/listinfo/python-list

Re: Ide or code editor confusion

2016-07-21 Thread MRAB
On 2016-07-21 15:07, Chris Angelico wrote: On Thu, Jul 21, 2016 at 11:56 PM, wrote: I'm learning Python and something is really unclear on the chapter im on. So Python has its own IDE to write code but now it's talking about "code editors" My confusion is so I need a code editor like Sublim

Re: Ide or code editor confusion

2016-07-21 Thread Jussi Piitulainen
sigmaphine1...@gmail.com writes: > I'm learning Python and something is really unclear on the chapter im > on. > > So Python has its own IDE to write code but now it's talking about > "code editors" > > My confusion is so I need a code editor like Sublime text? Is that > what Python IDE is for? Y

Re: Ide or code editor confusion

2016-07-21 Thread Chris Angelico
On Fri, Jul 22, 2016 at 12:22 AM, wrote: > Beginning Python: using Python 2.6 and Python 3.1. By James Payne > > Part II. > > But I think that answered my question. Great because au was worried Ugh, that's extremely old now. The current versions of Python are 2.7 (first released in 2010, and get

Technique for safely reloading dynamically generated module

2016-07-21 Thread Malcolm Greene
We're designing a server application that parses a custom DSL (domain specific language) source file, generates a Python module with the associated logic, and runs the associated code. Since this is a server application, we need to reload the module after each regeneration. Is this process is simpl

Re: Technique for safely reloading dynamically generated module

2016-07-21 Thread Chris Angelico
On Fri, Jul 22, 2016 at 12:42 AM, Malcolm Greene wrote: > We're designing a server application that parses a custom DSL (domain > specific language) source file, generates a Python module with the > associated logic, and runs the associated code. Since this is a server > application, we need to re

Re: Python packages listed in PyPI

2016-07-21 Thread Pete Forman
On 21 July 2016 at 07:28, Rayne wrote: > Thanks! One more question: Does "pip install" require Internet to work? Or > are all implementations already contained in the packages and so do not > require additional downloads? > pip install is downloading from https://pypi.python.org so yes you do ne

Re: Technique for safely reloading dynamically generated module

2016-07-21 Thread Peter Otten
Malcolm Greene wrote: > We're designing a server application that parses a custom DSL (domain > specific language) source file, generates a Python module with the > associated logic, and runs the associated code. Since this is a server > application, we need to reload the module after each regener

Re: Technique for safely reloading dynamically generated module

2016-07-21 Thread Malcolm Greene
Thank you Chris and Peter. The source file we're generating has one main function (go) with some supporting functions and classes as well. Will there be any problems referencing additional functions or classes defined in the source that gets passed to exec ... as long as references to those functi

Re: reversed(enumerate(x))

2016-07-21 Thread Ian Kelly
On Wed, Jul 20, 2016 at 1:16 PM, Random832 wrote: > On Wed, Jul 20, 2016, at 13:42, Ian Kelly wrote: >> I had occasion to write something like this: >> >> for i, n in reversed(enumerate(x)): pass >> >> How would you write this? > > I'd write my own version of enumerate with a step argument, an

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Steven D'Aprano
On Thu, 21 Jul 2016 11:14 pm, Rustom Mody wrote: > On Thursday, July 21, 2016 at 12:04:35 PM UTC+5:30, Steven D'Aprano wrote: >> On Thursday 21 July 2016 15:28, Rustom Mody wrote: >> > BTW APL whose main domain of application is scientific chooses to >> > enshrine this —equality is ε-neighborhood

Re: Technique for safely reloading dynamically generated module

2016-07-21 Thread Chris Angelico
On Fri, Jul 22, 2016 at 2:07 AM, Malcolm Greene wrote: > The source file we're generating has one main function (go) with some > supporting functions and classes as well. Will there be any problems > referencing additional functions or classes defined in the source that > gets passed to exec ... a

Re: reversed(enumerate(x))

2016-07-21 Thread Ian Kelly
On Wed, Jul 20, 2016 at 11:54 AM, Brendan Abel <007bren...@gmail.com> wrote: > You could create your own generator that wraps enumerate > > def reverse_enumerate(iterable): > for i, val in enumerate(reversed(iterable)): > yield len(iterable) - 1 - i, val > > for i, val in reverse_enumer

Max size of Python source code and compiled equivalent

2016-07-21 Thread Malcolm Greene
We're writing a DSL parser that generates Python code. While the size of our generated code will be small (< 32K), I wanted to re-assure the rest of our team that there are no reasonable code size boundaries that we need to be concerned about. I've searched for Python documentation that covers max

Re: Max size of Python source code and compiled equivalent

2016-07-21 Thread Chris Angelico
On Fri, Jul 22, 2016 at 2:51 AM, Malcolm Greene wrote: > We're writing a DSL parser that generates Python code. While the size of > our generated code will be small (< 32K), I wanted to re-assure the rest > of our team that there are no reasonable code size boundaries that we > need to be concerne

Re: Max size of Python source code and compiled equivalent

2016-07-21 Thread Malcolm Greene
> Heh, great question, and I'm curious too! But one place to get a bit more > info is the standard library. > > rosuav@sikorsky:~/cpython/Lib$ find -name \*.py|xargs ls -lS|head > -rw-r--r-- 1 rosuav rosuav 624122 Jul 17 17:38 ./pydoc_data/topics.py Brilliant! :) Thanks Chris! Malcolm -- http

Re: Technique for safely reloading dynamically generated module

2016-07-21 Thread Terry Reedy
On 7/21/2016 12:07 PM, Malcolm Greene wrote: I assume that one downside to the exec() approach is that there is no persistent namespace for this code's functions and classes, eg. after the exec() completes, its namespace disappears and is not available to code that follows? Objects only disapp

Re: Max size of Python source code and compiled equivalent

2016-07-21 Thread Peter Otten
Malcolm Greene wrote: > We're writing a DSL parser that generates Python code. While the size of > our generated code will be small (< 32K), I wanted to re-assure the rest > of our team that there are no reasonable code size boundaries that we > need to be concerned about. I've searched for Python

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Ben Bacarisse
Steven D'Aprano writes: > Or you might be using a language like Javascript, which intentionally has > only floats for numbers. That's okay, you can still perform exact integer > arithmetic, so long as you stay within the bounds of ±2**16. Small point: it's 2**52. -- Ben. -- https://mail.pyth

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Chris Kaynor
On Thu, Jul 21, 2016 at 4:54 PM, Ben Bacarisse wrote: > Steven D'Aprano writes: > > > Or you might be using a language like Javascript, which intentionally has > > only floats for numbers. That's okay, you can still perform exact integer > > arithmetic, so long as you stay within the bounds of

learning python. learning defining functions . need help

2016-07-21 Thread sigmaphine1914
having a little trouble with defining functions. i have a doc called ch5.py and when i was trying the following i had issues " Try It Out: Defining a Function Try saving the following in your file for Chapter 5, ch5.py.def in_fridge(): try: count = fridge[wanted_food]

Stupid question, just need a quick and dirty fix

2016-07-21 Thread Jordan Bayless
I'm trying to modify some code to suit my purposes and I'm just trying to filter results as necessary. Basically, the code is returning one of a number from a subset of 150 numbers. I want to only do anything with it if the number is a 'good' one. I'm by no means a Python programmer (C# for me b

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Chris Angelico
On Fri, Jul 22, 2016 at 2:19 PM, Jordan Bayless wrote: > I get various errors no matter what I do to this to try and make it work. > Variable not defined. Referenced before assignment. etc etc. I'm lost. How do > I make it work? It might be easier if you post all your code. To be honest, what I

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Jordan Bayless
On Thursday, July 21, 2016 at 11:28:55 PM UTC-5, Chris Angelico wrote: > On Fri, Jul 22, 2016 at 2:19 PM, Jordan Bayless wrote: > > I get various errors no matter what I do to this to try and make it work. > > Variable not defined. Referenced before assignment. etc etc. I'm lost. How > > do I ma

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Chris Angelico
On Fri, Jul 22, 2016 at 2:39 PM, Jordan Bayless wrote: > it seems there's a) no case statement (WTF?) and b) I'm limited to how many > elif statements I can use. The latter isn't true; and you're not using elif anyway. With no case statement, you get pushed to other, better ways of doing things,

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Michael Selik
> On Jul 22, 2016, at 12:39 AM, Jordan Bayless wrote: > > Posting the entire code snippet is tough because it's thousands of lines of > code. You could paste into a GitHub gist (https://gist.github.com/) and share the link. -- https://mail.python.org/mailman/listinfo/python-list

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Jordan Bayless
No, I tried using a bunch of elif statements earlier and when I added more than around 3 of them it threw errors. I just assumed that was some kind of limit. We both agree that's piss-poor, lazy coding. I'm just trying to find something that works though. To this point, everything I try fails.

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Paul Rubin
Jordan Bayless writes: > desired = Id < 10 or Id > 133 or Id in good_ids > When I try to validate whether I passed that check, I'm told there's a > Name error and it's not defined (using the last line of the snippet > above). Id was called IDNum in your earlier pst > Also, I guess I'm at a loss

Convert from unsigned long long to PyLong

2016-07-21 Thread Tian JiaLin
HI There, I'm using MySQLdb as the MySQL client. Recently I got a weird problem of this library. After looking into it, I suspect the problem may related to the conversion from unsigned long to PyLongObject. Here is the detail, If you are familiar with MySQLdb, the following snippet is a way t

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Steven D'Aprano
On Fri, 22 Jul 2016 03:18 pm, Michael Selik wrote: > >> On Jul 22, 2016, at 12:39 AM, Jordan Bayless wrote: >> >> Posting the entire code snippet is tough because it's thousands of lines >> of code. > > You could paste into a GitHub gist (https://gist.github.com/) and share > the link. Are yo

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Chris Angelico
On Fri, Jul 22, 2016 at 3:26 PM, Jordan Bayless wrote: > When I try to validate whether I passed that check, I'm told there's a Name > error and it's not defined (using the last line of the snippet above). You're still not posting (a) your code, or (b) the full traceback, so it's not easy for us

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Steven D'Aprano
On Fri, 22 Jul 2016 03:26 pm, Jordan Bayless wrote: > No, I tried using a bunch of elif statements earlier and when I added more > than around 3 of them it threw errors. I just assumed that was some kind > of limit. Right, because a 20+ years old programming language used by millions of professi