Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 03:54 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>In actual annihilation events, there is (as far as I know) >>generally a single real photon produced > > »There are only a very limited set of possibilities for > the final state. The most probable is the creat

Re: Multithreaded compression/decompression library with python bindings?

2017-10-04 Thread Stephan Houben
Op 2017-10-04, Paul Moore schreef : > On 4 October 2017 at 16:08, Steve D'Aprano wrote: >> On Wed, 4 Oct 2017 08:19 pm, Thomas Nyberg wrote: >> >>> Hello, >>> >>> I was wondering if anyone here knew of any python libraries with >>> interfaces similar to the bzip2 module which is also multithreaded

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread breamoreboy
On Thursday, October 5, 2017 at 4:22:26 AM UTC+1, Steve D'Aprano wrote: > On Thu, 5 Oct 2017 01:21 pm, Stefan Ram wrote: > > >>- Germany was the aggressor in World War 2; > >>- well, Germany and Japan; > >>- *surely* it must be Germany, Italy and Japan; > > > > This listing style reminds me of

Re: newb question about @property

2017-10-04 Thread Steve D'Aprano
On Wed, 4 Oct 2017 11:46 pm, Rhodri James wrote: > On 04/10/17 12:07, bartc wrote: >> I've seen that example brought up before. It still doesn't cut any ice. >> >> You might as well be condescending of someone who finds Joyce or Proust >> unreadable, and prefers McBain, Simenon or Chandler. (Sorr

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Tim Delaney
On 5 October 2017 at 14:22, Steve D'Aprano wrote: > The A and E in the word "are" are not vowels, since they are silent. The U > in "unicorn" and "university" are not vowels either, and if you write "an > unicorn" you are making a mistake. > There are dialects of English where the "u" in unicorn

Re: How to determine lowest version of Python 3 to run?

2017-10-04 Thread Stephan Houben
Op 2017-10-05, Ben Finney schreef : > Christopher Reimer writes: > >> How do I determine the lowest version of Python to [declare that my >> code supports]? > > You can determine that by installing all the Python versions you want to > try, and running your code's unit test suite on each of them.

Re: How to determine lowest version of Python 3 to run?

2017-10-04 Thread Ben Finney
Christopher Reimer writes: > How do I determine the lowest version of Python to [declare that my > code supports]? You can determine that by installing all the Python versions you want to try, and running your code's unit test suite on each of them. Those versions where the unit test suite fail

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Christopher Reimer
On Oct 4, 2017, at 3:49 AM, Leam Hall wrote: > > Folks on IRC have suggested using virtualenv to test code under different > python versions. Sadly, I've not found a virtualenv tutorial I understand. > Anyone have a link to a good one? > > The next step will be to figure out how to package a p

OT I before E [was Re: Lies in education [was Re: The "loop and a half"]]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:54 pm, Chris Angelico wrote: > On Thu, Oct 5, 2017 at 2:22 PM, Steve D'Aprano > wrote: >> It is, I think, an example of a stupid English language folklore that >> people repeat unthinkingly, even though the counter-examples are obvious >> and common. Like "I before E except

Re: Constants [was Re: newb question about @property]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 04:00 am, Paul Moore wrote: > I wonder - would the people who want "real constants" find the > following confusing: > from demo import foo foo = 14 foo > 14 > > It's fundamental to the way the import function works, and how names > in Python behave, but I can s

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:14 pm, Stefan Ram wrote: > Chris Angelico writes: >>You can get through a lot of life believing that mass is conserved, >>but technically it is not, as can be proven. > > Well, in fact, it is conserved. It certainly is not. The whole point of Einstein's equation E = mc²

OT aggression [was Re: Lies in education [was Re: The "loop and a half"]]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:54 pm, Chris Angelico wrote: > On Thu, Oct 5, 2017 at 2:22 PM, Steve D'Aprano > wrote: [...] >> In the East, while Japan did take the first overtly military action against >> the US, the US had (in some sense) first engaged in hostile behaviour >> against Japan by unilatera

Suggestions on storing, caching, querying json

2017-10-04 Thread Sayth Renshaw
HI Looking for suggestions around json libraries. with Python. I am looking for suggestions around a long term solution to store and query json documents across many files. I will be accessing an api and downloading approx 20 json files from an api a week. Having downloaded this year I have ov

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 2:22 PM, Steve D'Aprano wrote: > It is, I think, an example of a stupid English language folklore that people > repeat unthinkingly, even though the counter-examples are obvious and common. > Like "I before E except after C", which is utter rubbish. That's because it's only

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 01:36 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>If you were teaching people to drive a car, would you insist on teaching >>them how to pull out and rebuild the engine before sitting them in the >>drivers seat? > > If I would have to teach people to drive a car, I woul

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 01:21 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>At various stages of education, we teach many lies-to-children, including: > > Many of those lies can be perfectly true in some sense. Well of course, that's the whole point of them being "lies-to-children". In fact, on

Re: Asking help about Python

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 1:48 PM, wrote: > Hi Everyone, > > I now do need to re-compile the Python 2.7 with VisualStudio 2012. > Can anyone here kindly give me any help? I appreciate any kind of help: > hints, learning sources, or ideally show me some instructions :(. > > Thank you. This is not g

Re: How to determine lowest version of Python 3 to run?

2017-10-04 Thread MRAB
On 2017-10-05 03:23, Christopher Reimer wrote: Greetings, I've always installed the latest and greatest version of Python 3 to develop my own programs. I'm planning to release a program to the public. I could toss in a note that the program runs on the latest version of Python 3.6 but I haven'

Asking help about Python

2017-10-04 Thread yennguyen . agar
Hi Everyone, I now do need to re-compile the Python 2.7 with VisualStudio 2012. Can anyone here kindly give me any help? I appreciate any kind of help: hints, learning sources, or ideally show me some instructions :(. Thank you. -- https://mail.python.org/mailman/listinfo/python-list

Re: Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 1:21 PM, Stefan Ram wrote: > Steve D'Aprano writes: >>At various stages of education, we teach many lies-to-children, including: > > Many of those lies can be perfectly true in some sense. > I pick some examples: > >>- "AEIOU" are the English vowels; > > One is free t

Re: Easier way to do this?

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 11:11 AM, Irv Kalb wrote: > # If we have not seen this employee name before, add it to the dictionary > # like key value pair: '': [0, 0] > if not(name in employeeDataDict): > salesCountDict[name] = [0, 0] Python provides a "not in" operator, which i

Re: How to determine lowest version of Python 3 to run?

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 1:23 PM, Christopher Reimer wrote: > Greetings, > > I've always installed the latest and greatest version of Python 3 to develop > my own programs. I'm planning to release a program to the public. I could > toss in a note that the program runs on the latest version of Pyth

Re: The "loop and a half"

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 1:20 PM, Steve D'Aprano wrote: > On Thu, 5 Oct 2017 09:42 am, Stefan Ram wrote: > >> Steve D'Aprano writes: So, "bottom-up" in this case means: iterators should be taught before for-loops. >>>Why? >> >> The syntax for is (from memory): >> >> for in : >> >> . A

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 10:15 am, Thomas Jollans wrote: > If you apply that kind of thinking consistently with Python you'll get > caught in an infinite loop trying to explain attribute access before > even teaching print(). > > To call print, you need to access print.__call_. To access that > attribu

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 10:56 am, Terry Reedy wrote: >> You're right, that construct isn't used for reading from files in >> Python. It _is_ commonly used for reading from things like socket > >> mysock.connect(...) >> while True: >> data = mysock.recv() >> if not data: >> brea

Re: Creating a Dictionary

2017-10-04 Thread Chris Angelico
On Thu, Oct 5, 2017 at 12:24 PM, Stefan Ram wrote: > One might wish to implement a small language with these commands: > > F - move forward > B - move backward > L - larger stepsize > S - smaller stepsize > > . One could start with the following pseudocode for a dictionary: > > { 'F': lambda:

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 09:42 am, Stefan Ram wrote: > Steve D'Aprano writes: >>>So, "bottom-up" in this case means: iterators should be >>>taught before for-loops. >>Why? > > The syntax for is (from memory): > > for in : > > . As an example, I might show: > > for i in range( 3 ): ... > >

How to determine lowest version of Python 3 to run?

2017-10-04 Thread Christopher Reimer
Greetings, I've always installed the latest and greatest version of Python 3 to develop my own programs. I'm planning to release a program to the public. I could toss in a note that the program runs on the latest version of Python 3.6 but I haven't tested on earlier versions (i.e., 3.4 and 3.5)

Re: newb question about @property

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 09:08 am, bartc wrote: [...] > And when I tried, it didn't really work in Python 2 (extra attributes > could still be created, and .__slots__ wasn't readonly); only Py3. Not quite, but I don't blame you for the mistake. Its an easy one to make. __slots__ only works in "new sty

Re: The "loop and a half"

2017-10-04 Thread Ned Batchelder
On 10/4/17 7:37 AM, Stefan Ram wrote: bartc writes: Note that your reverse-indentation style is confusing! In Python, indentation can be significant. Sometimes, some lines in Python must be indented by 0. This dictates that Python code cannot be indented in posts to differentiate

Re: Creating a Dictionary

2017-10-04 Thread Bill
Stefan Ram wrote: One might wish to implement a small language with these commands: Explain why. What is the advantage? F - move forward B - move backward L - larger stepsize S - smaller stepsize . One could start with the following pseudocode for a dictionary: { 'F': lambda: myturtl

Lies in education [was Re: The "loop and a half"]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 07:17 am, ROGER GRAYDON CHRISTMAN wrote: > I teach a course in programming to students who have no plans to be > programmers, scientists, or engineers.And I deliberately lied today > about the for loop. Well done! (I'm not being sarcastic.) This is entirely appropriate: all

Creating a MIDI file

2017-10-04 Thread Tobiah
What would be the best library to use for creating MIDI files that I could import into a DAW like Reaper? Thanks, Tobiah -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:56 am, Paul Moore wrote: > On 4 October 2017 at 16:35, Steve D'Aprano > wrote: >> I've been programming in Python for twenty years, and I don't think I have >> ever once read from a file using a while loop. > > Twenty years isn't long enough :-) The pattern the OP is talkin

Re: Easier way to do this?

2017-10-04 Thread Irv Kalb
I'm assuming from your posts that you are not a student. If that is the case, look at my solution below. > On Oct 4, 2017, at 9:42 AM, 20/20 Lab wrote: > > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump. I have to pull out sales >

Re: The "loop and a half"

2017-10-04 Thread Terry Reedy
On 10/4/2017 1:24 PM, Grant Edwards wrote: On 2017-10-04, Steve D'Aprano wrote: It is sometimes called the loop and a half problem. The idea is that you must attempt to read a line from the file before you know whether you are at the end of file or not. Utter nonsense. There's no "must" here.

Re: The "loop and a half"

2017-10-04 Thread Thomas Jollans
On 05/10/17 00:42, Stefan Ram wrote: > Steve D'Aprano writes: >>> So, "bottom-up" in this case means: iterators should be >>> taught before for-loops. >> Why? > The syntax for is (from memory): > > for in : > > . As an example, I might show: > > for i in range( 3 ): ... > > . This raises

Re: newb question about @property

2017-10-04 Thread bartc
On 04/10/2017 17:02, Rhodri James wrote: On 04/10/17 16:33, Paul Moore wrote: It's not an advantage or a disadvantage, just an approach. Many people like it, you may not. Specifically, yes you can't "just declare a lightweight struct or record with exactly two fields". Actually you can: >>

Re: Python community "welcoming" feedback

2017-10-04 Thread Thomas Jollans
On 04/10/17 23:39, Bill wrote: > Leam Hall wrote: >> A while back I pointed out some challenges for the Python community's >> intake of new coders. Mostly focusing on IRC and the Python e-mail list. > > What is the Python e-mail list? You're on it right now! There is a two-way mirror between comp.

Re: Easier way to do this?

2017-10-04 Thread Thomas Jollans
On 04/10/17 22:47, Fabien wrote: > On 10/04/2017 10:11 PM, Thomas Jollans wrote: >> Be warned, pandas is part of the scientific python stack, which is >> immensely powerful and popular, but it does have a distinctive style >> that may appear cryptic if you're used to the way the rest of the world >

Re: Python community "welcoming" feedback

2017-10-04 Thread Bill
Leam Hall wrote: A while back I pointed out some challenges for the Python community's intake of new coders. Mostly focusing on IRC and the Python e-mail list. What is the Python e-mail list? Thanks, Bill Several people have stepped up their "welcome" game and I've been very impressed wit

Re: Easier way to do this?

2017-10-04 Thread 20/20 Lab
On 10/04/2017 01:55 PM, Ben Bacarisse wrote: 20/20 Lab writes: Looking for advice for what looks to me like clumsy code. I have a large csv (effectively garbage) dump.  I have to pull out sales information per employee and count them by price range. I've got my code working, but I'm thinkin

Re: Easier way to do this?

2017-10-04 Thread 20/20 Lab
On 10/04/2017 12:47 PM, breamore...@gmail.com wrote: On Wednesday, October 4, 2017 at 8:29:26 PM UTC+1, 20/20 Lab wrote: Any help / advice is appreciated, Matt Use the csv module https://docs.python.org/3/library/csv.html to read the file with a Counter https://docs.python.org/3/library/c

Re: Easier way to do this?

2017-10-04 Thread Ben Bacarisse
20/20 Lab writes: > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump.  I have to pull out > sales information per employee and count them by price range. I've got > my code working, but I'm thinking there must be a more refined way of > d

Re: Easier way to do this?

2017-10-04 Thread Fabien
On 10/04/2017 10:11 PM, Thomas Jollans wrote: Be warned, pandas is part of the scientific python stack, which is immensely powerful and popular, but it does have a distinctive style that may appear cryptic if you're used to the way the rest of the world writes Python. Can you elaborate on this

Re: newb question about @property

2017-10-04 Thread ROGER GRAYDON CHRISTMAN
On Wed, Oct 4, 2017 14:03 PM, bartc wrote > "A property, in some object-oriented programming languages, is a special >sort of class member, intermediate in functionality between a field (or >data member) and a method." > >But Python has some problems just in using fields. If you wanted say a

Re: The "loop and a half"

2017-10-04 Thread Christian Gollwitzer
Am 04.10.17 um 14:34 schrieb Ben Bacarisse: r...@zedat.fu-berlin.de (Stefan Ram) writes: Steve D'Aprano writes: For-each loops are MUCH easier to understand, and should be taught first. I prefer a bottom-up approach. For loops are based on iterators. So, "bottom-up" in this case

Re: Easier way to do this?

2017-10-04 Thread Thomas Jollans
On 04/10/17 18:42, 20/20 Lab wrote: > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump. I have to pull out > sales information per employee and count them by price range. I've got > my code working, but I'm thinking there must be a more re

Re: The "loop and a half"

2017-10-04 Thread ROGER GRAYDON CHRISTMAN
I teach a course in programming to students who have no plans to be programmers, scientists, or engineers.And I deliberately lied today about the for loop. In my lecture slide, I said that the for loop could only be used if you had a collection of values (e.g. list, tuple, dict, string, or ran

Re: The "loop and a half"

2017-10-04 Thread bartc
On 04/10/2017 14:44, john polo wrote: In Python Programming Fundamentals 2nd ed., the author, Kent D. Lee, brings up loop and a half in ch. 3, Repetitive Tasks (p. 82). He wrote: "Whether you are writing code in Python or some other language, this Reading Records From a File pattern comes up

Re: Easier way to do this?

2017-10-04 Thread breamoreboy
On Wednesday, October 4, 2017 at 8:29:26 PM UTC+1, 20/20 Lab wrote: > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump.  I have to pull out sales > information per employee and count them by price range. I've got my code > working, but I

Easier way to do this?

2017-10-04 Thread 20/20 Lab
Looking for advice for what looks to me like clumsy code. I have a large csv (effectively garbage) dump.  I have to pull out sales information per employee and count them by price range. I've got my code working, but I'm thinking there must be a more refined way of doing this. ---snippet of w

Re: The "loop and a half"

2017-10-04 Thread Grant Edwards
On 2017-10-04, Steve D'Aprano wrote: >> It is sometimes called the loop and a half problem. The idea is >> that you must attempt to read a line from the file before you know >> whether you are at the end of file or not. > > Utter nonsense. There's no "must" here. I'll accept the remote > possibilit

Re: Constants [was Re: newb question about @property]

2017-10-04 Thread Paul Moore
On 4 October 2017 at 17:15, Ian Kelly wrote: > On Wed, Oct 4, 2017 at 9:08 AM, Steve D'Aprano > wrote: >> But in large projects, especially those where you cannot trust every module >> in >> the project to obey the naming convention, I can see that this lack might >> contribute to the perception

Re: newb question about @property

2017-10-04 Thread Paul Moore
On 4 October 2017 at 17:02, Rhodri James wrote: > Actually you can: > class Point: > ... __slots__ = ("x", "y") > ... def __init__(self, x, y): > ... self.x = x > ... self.y = y > ... def __str__(self): > ... return "({0},{1})".format(self.x, self.y) > ... p = Point(3,4

Re: Constants [was Re: newb question about @property]

2017-10-04 Thread Ian Kelly
On Wed, Oct 4, 2017 at 9:08 AM, Steve D'Aprano wrote: > But in large projects, especially those where you cannot trust every module in > the project to obey the naming convention, I can see that this lack might > contribute to the perception, if not the fact, of Python being a bit too > unsafe for

Re: newb question about @property

2017-10-04 Thread Rhodri James
On 04/10/17 16:33, Paul Moore wrote: On 4 October 2017 at 16:03, bartc wrote: No error. Some would perceive all this as an advantage, but it means you can't just declare a lightweight struct or record 'Point' with exactly two fields x and y. You have to use other solutions ('namedtuples' or wha

Re: The "loop and a half"

2017-10-04 Thread Paul Moore
On 4 October 2017 at 16:35, Steve D'Aprano wrote: > I've been programming in Python for twenty years, and I don't think I have > ever once read from a file using a while loop. Twenty years isn't long enough :-) The pattern the OP is talking about was common in "Jackson Structured Programming" fro

Re: How best to initialize in unit tests?

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 02:23 am, Skip Montanaro wrote: [...] >> Ew. Sounds like a badly designed package. > > I will refer interested readers to the nose documentation: > > https://nose.readthedocs.io/en/latest/doc_tests/test_init_plugin/init_plugin.html > > where the author writes, "Many applicati

Re: The "loop and a half"

2017-10-04 Thread breamoreboy
On Wednesday, October 4, 2017 at 9:34:09 AM UTC+1, alister wrote: > On Wed, 04 Oct 2017 20:16:29 +1300, Gregory Ewing wrote: > > > Steve D'Aprano wrote: > >> On Wed, 4 Oct 2017 01:40 pm, Chris Angelico wrote: > >> > >>>You know, you don't HAVE to economize on letters. It's okay to call > >>>your

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 12:44 am, john polo wrote: > I'm adding to what Stefan wrote, simply to point out how a newb like me > came across this issue formally, besides actually dealing with this in > my practice. > > In Python Programming Fundamentals 2nd ed., the author, Kent D. Lee, > brings up loop

Re: Multithreaded compression/decompression library with python bindings?

2017-10-04 Thread Paul Moore
On 4 October 2017 at 16:08, Steve D'Aprano wrote: > On Wed, 4 Oct 2017 08:19 pm, Thomas Nyberg wrote: > >> Hello, >> >> I was wondering if anyone here knew of any python libraries with >> interfaces similar to the bzip2 module which is also multithreaded in >> (de)compression? Something along the

Re: newb question about @property

2017-10-04 Thread Paul Moore
On 4 October 2017 at 16:03, bartc wrote: > No error. Some would perceive all this as an advantage, but it means you > can't just declare a lightweight struct or record 'Point' with exactly two > fields x and y. You have to use other solutions ('namedtuples' or whatever, > which probably are immuta

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Wed, 4 Oct 2017 09:35 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>For-each loops are MUCH easier to understand, and should be taught first. > > I prefer a bottom-up approach. I prefer an effective approach that starts with the simplest concepts first, not the most complex. > For

Re: How best to initialize in unit tests?

2017-10-04 Thread Skip Montanaro
On Wed, Oct 4, 2017 at 9:53 AM, Steve D'Aprano wrote: > On Thu, 5 Oct 2017 12:07 am, Skip Montanaro wrote: > >> Suppose you want to test a package (in the general sense of the word, >> not necessarily a Python package). > > I'm... not sure I understand. Given that we're discussing Python, in a Pyt

Re: The "loop and a half"

2017-10-04 Thread Steve D'Aprano
On Wed, 4 Oct 2017 11:50 pm, bartc wrote: > But this is what it says about it: > > "Please reject the PEP. More variations along these lines won't make the > language more elegant or easier to learn. They'd just save a few hasty > folks some typing while making others who have to read/maintain th

Constants [was Re: newb question about @property]

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 12:41 am, Ian Kelly wrote: > Python has the simplest named constants of all: > > C = 12345 > > As long as you don't subsequently change it, it's a constant. And it's > very simple because it works just like any other variable. I do feel that the lack of constants[1] is a (mi

Re: Multithreaded compression/decompression library with python bindings?

2017-10-04 Thread Steve D'Aprano
On Wed, 4 Oct 2017 08:19 pm, Thomas Nyberg wrote: > Hello, > > I was wondering if anyone here knew of any python libraries with > interfaces similar to the bzip2 module which is also multithreaded in > (de)compression? Something along the lines of (say) the pbip2 program > but with bindings for p

Re: newb question about @property

2017-10-04 Thread bartc
On 04/10/2017 14:41, Ian Kelly wrote: On Wed, Oct 4, 2017 at 5:07 AM, bartc wrote: For that matter, I don't think Python has such a feature either. So that you write for example: const C = 123345 and then whenever C appears within the code, it's implemented as: LOAD_CONST (123345)

Re: How best to initialize in unit tests?

2017-10-04 Thread Steve D'Aprano
On Thu, 5 Oct 2017 12:07 am, Skip Montanaro wrote: > Suppose you want to test a package (in the general sense of the word, > not necessarily a Python package). I'm... not sure I understand. Given that we're discussing Python, in a Python group, what are senses are relevant? > You probably have

Re: Python-list Digest, Vol 169, Issue 5

2017-10-04 Thread ROGER GRAYDON CHRISTMAN
On Wed, Oct 4, 2017 14:54, Chris Angelico wrote: > On Wed, Oct 4, 2017 at 2:48 PM, Steve D'Aprano > wrote: >> On Wed, 4 Oct 2017 01:40 pm, Chris Angelico wrote: >> >> You know, you don't HAVE to economize on letters. It's okay to call >> your parameters "prompt" instead of "prmt". Remember, tha

Re: How best to initialize in unit tests?

2017-10-04 Thread Christopher Reimer
On Oct 4, 2017, at 6:07 AM, Skip Montanaro wrote: > > Suppose you want to test a package (in the general sense of the word, > not necessarily a Python package). You probably have specific unit > tests, maybe some doctests scattered around in doc strings. Further, > suppose that package requires y

Re: How best to initialize in unit tests?

2017-10-04 Thread Skip Montanaro
> I've not had this problem myself, but py.test has the idea of "autouse > fixtures" which would work for this situation. Define your setup call > in a function, declare it with the pytest.fixture decorator with > autouse=True, and it'll be run before every test. The declaration goes > in a conftes

Re: The "loop and a half"

2017-10-04 Thread Paul Moore
On 4 October 2017 at 14:02, Robin Becker wrote: > On 04/10/2017 11:57, Rhodri James wrote: >> >> On 04/10/17 10:01, Robin Becker wrote: >>> >>> Given the prevalence of the loop and a half idea in python I wonder why >>> we don't have a "do" or "loop" statement to start loops without a test. >> >>

Re: How best to initialize in unit tests?

2017-10-04 Thread Paul Moore
I've not had this problem myself, but py.test has the idea of "autouse fixtures" which would work for this situation. Define your setup call in a function, declare it with the pytest.fixture decorator with autouse=True, and it'll be run before every test. The declaration goes in a conftest.py file

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Paul Moore
On 4 October 2017 at 13:30, leam hall wrote: > On Wed, Oct 4, 2017 at 7:15 AM, Ben Finney > wrote: > >> Leam Hall writes: >> >> > Folks on IRC have suggested using virtualenv to test code under >> > different python versions. Sadly, I've not found a virtualenv tutorial >> > I understand. Anyone

Re: The "loop and a half"

2017-10-04 Thread john polo
On 10/3/2017 5:08 PM, Stefan Ram wrote: Steve D'Aprano writes: On Wed, 4 Oct 2017 04:45 am, Rhodri James wrote: On 03/10/17 18:29, Stefan Ram wrote: Is this the best way to write a "loop and a half" in Python? Define "best". I'd start with "define loop and a half". I encountered this ph

Re: newb question about @property

2017-10-04 Thread Ian Kelly
On Wed, Oct 4, 2017 at 5:07 AM, bartc wrote: > It is just being elitist. I have a preference for keeping things simple and > avoiding unnecessary complexity. But with programming languages many do have > a penchant for the latter. > > As an example, a recent discussion on comp.lang.c was about imp

Re: newb question about @property

2017-10-04 Thread Rhodri James
On 04/10/17 12:07, bartc wrote: I've seen that example brought up before. It still doesn't cut any ice. You might as well be condescending of someone who finds Joyce or Proust unreadable, and prefers McBain, Simenon or Chandler. (Sorry, can't think of any modern pulp novelists). I don't thin

Re: The "loop and a half"

2017-10-04 Thread bartc
On 04/10/2017 14:02, Robin Becker wrote: On 04/10/2017 11:57, Rhodri James wrote: On 04/10/17 10:01, Robin Becker wrote: Given the prevalence of the loop and a half idea in python I wonder why we don't have a "do" or "loop" statement to start loops without a test. See PEP 315.  Guido's rejec

How best to initialize in unit tests?

2017-10-04 Thread Skip Montanaro
Suppose you want to test a package (in the general sense of the word, not necessarily a Python package). You probably have specific unit tests, maybe some doctests scattered around in doc strings. Further, suppose that package requires you call an initialize function of some sort. Where does that g

Re: The "loop and a half"

2017-10-04 Thread Robin Becker
On 04/10/2017 11:57, Rhodri James wrote: On 04/10/17 10:01, Robin Becker wrote: Given the prevalence of the loop and a half idea in python I wonder why we don't have a "do" or "loop" statement to start loops without a test. See PEP 315.  Guido's rejection note is here: https://mail.python.org/

Re: The "loop and a half"

2017-10-04 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > bartc writes: >>Note that your reverse-indentation style is confusing! > > In Python, indentation can be significant. > > Sometimes, some lines in Python must be indented by 0. > > This dictates that Python code cannot be indented > in posts

Re: The "loop and a half"

2017-10-04 Thread bartc
On 04/10/2017 11:57, Rhodri James wrote: On 04/10/17 10:01, Robin Becker wrote: Given the prevalence of the loop and a half idea in python I wonder why we don't have a "do" or "loop" statement to start loops without a test. See PEP 315.  Guido's rejection note is here: https://mail.python.org

Re: The "loop and a half"

2017-10-04 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Steve D'Aprano writes: >>For-each loops are MUCH easier to understand, and should be taught first. > > I prefer a bottom-up approach. > > For loops are based on iterators. > > So, "bottom-up" in this case means: iterators should be > taught b

Re: The "loop and a half"

2017-10-04 Thread Neil Cerutti
On 2017-10-04, Stefan Ram wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: >>Maybe this way: Use a while-loop and try-catch to get values >>from an iterator until exhausted, and then introduce the >>for-loop as an abbreviation for that. > > # while-loop > > iterable = range( 3 ) > > iterator

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread leam hall
On Wed, Oct 4, 2017 at 7:15 AM, Ben Finney wrote: > Leam Hall writes: > > > Folks on IRC have suggested using virtualenv to test code under > > different python versions. Sadly, I've not found a virtualenv tutorial > > I understand. Anyone have a link to a good one? > > The Python Packaging Auth

Re: The "loop and a half"

2017-10-04 Thread Rhodri James
On 04/10/17 10:01, Robin Becker wrote: Given the prevalence of the loop and a half idea in python I wonder why we don't have a "do" or "loop" statement to start loops without a test. See PEP 315. Guido's rejection note is here: https://mail.python.org/pipermail/python-ideas/2013-June/021610.ht

Re: The "loop and a half"

2017-10-04 Thread bartc
On 04/10/2017 11:42, Stefan Ram wrote: Robin Becker writes: Given the prevalence of the loop and a half idea in python I wonder why we don't have a "do" or "loop" statement to start loops without a test. VBA has quite an orthogonal way to build loop control: pre-checked positive: Do W

Re: The "loop and a half"

2017-10-04 Thread Frank Millman
"Stefan Ram" wrote in message news:vba-loops-20171004114...@ram.dialup.fu-berlin.de... Robin Becker writes: >Given the prevalence of the loop and a half idea in python I wonder why >we don't >have a "do" or "loop" statement to start loops without a test. VBA has quite an orthogonal way to

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Ben Finney
Leam Hall writes: > Folks on IRC have suggested using virtualenv to test code under > different python versions. Sadly, I've not found a virtualenv tutorial > I understand. Anyone have a link to a good one? The Python Packaging Authority has a guide https://packaging.python.org/tutorials/install

Re: newb question about @property

2017-10-04 Thread bartc
On 04/10/2017 06:32, Steve D'Aprano wrote: On Wed, 4 Oct 2017 02:00 am, bartc wrote: Does all this advanced stuff (which I don't understand and which doesn't look very appealing either; hopefully I will never come across such code) still count as programming? I could not have hoped to see a m

Python community "welcoming" feedback

2017-10-04 Thread Leam Hall
A while back I pointed out some challenges for the Python community's intake of new coders. Mostly focusing on IRC and the Python e-mail list. Several people have stepped up their "welcome" game and I've been very impressed with the way things are going. Great job! Leam -- https://mail.pytho

Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Leam Hall
Folks on IRC have suggested using virtualenv to test code under different python versions. Sadly, I've not found a virtualenv tutorial I understand. Anyone have a link to a good one? The next step will be to figure out how to package a project; a good tutorial URL would be appreciated on that,

Multithreaded compression/decompression library with python bindings?

2017-10-04 Thread Thomas Nyberg
Hello, I was wondering if anyone here knew of any python libraries with interfaces similar to the bzip2 module which is also multithreaded in (de)compression? Something along the lines of (say) the pbip2 program but with bindings for python? Obviously the multi-threaded part will need to be handle

Re: The "loop and a half"

2017-10-04 Thread Ben Bacarisse
Steve D'Aprano writes: > On Wed, 4 Oct 2017 04:45 am, Rhodri James wrote: > >> On 03/10/17 18:29, Stefan Ram wrote: >>>Is this the best way to write a "loop and a half" in Python? >> >> Define "best". > > I'd start with "define loop and a half". What it means to me is this pattern: while

Re: The "loop and a half"

2017-10-04 Thread Robin Becker
Given the prevalence of the loop and a half idea in python I wonder why we don't have a "do" or "loop" statement to start loops without a test. C:\Python27\Lib>grep "while True" *.py | wc -l 99 C:\Python27\Lib>grep "while 1" *.py | wc -l 117 C:\Python36\Lib>grep "while True" *.py

Re: The "loop and a half"

2017-10-04 Thread alister via Python-list
On Wed, 04 Oct 2017 20:16:29 +1300, Gregory Ewing wrote: > Steve D'Aprano wrote: >> On Wed, 4 Oct 2017 01:40 pm, Chris Angelico wrote: >> >>>You know, you don't HAVE to economize on letters. It's okay to call >>>your parameters "prompt" instead of "prmt". Remember, that's part of >>>your API. >>

Re: The "loop and a half"

2017-10-04 Thread Gregory Ewing
Steve D'Aprano wrote: On Wed, 4 Oct 2017 01:40 pm, Chris Angelico wrote: You know, you don't HAVE to economize on letters. It's okay to call your parameters "prompt" instead of "prmt". Remember, that's part of your API. Whn u wste vwels lik that, dn't b srprsd whn u run ot n hav shrtg of vwel