Re: Python Worst Practices

2015-02-28 Thread Ian Kelly
On Fri, Feb 27, 2015 at 9:42 PM, Dan Sommers wrote: > I don't think I've ever used the builtin function id in a program. > Ever. Not even once. Honestly, what is a valid use case? If you have a dict that you want to key on object identity rather than equality, then you can use object ids as the

Re: Python Worst Practices

2015-02-28 Thread Marko Rauhamaa
Ethan Furman : > Sure, for the ones I use as built-ins. But I went through the color > file for vim and took out the built-ins I use regularly as variables > -- and 'id' was the first one to go. Ah, yes. The id is with us from the beginning. The self seeks to gratify the whims of the id while at

Re: Python Worst Practices

2015-02-28 Thread Chris Angelico
On Sat, Feb 28, 2015 at 6:50 PM, Dan Sommers wrote: > Now if only emacs were clever enough *not* to colorize "id" when it's > one of my names and not the builtin... ;-) I think (part of) the point of the colorization is to make it obvious that you've shadowed a builtin. If you use << str = 'spam

Re: Python Worst Practices

2015-02-28 Thread Chris Angelico
On Sat, Feb 28, 2015 at 7:48 PM, Ian Kelly wrote: > On Fri, Feb 27, 2015 at 9:42 PM, Dan Sommers wrote: >> I don't think I've ever used the builtin function id in a program. >> Ever. Not even once. Honestly, what is a valid use case? > > If you have a dict that you want to key on object identit

Re: Python Worst Practices

2015-02-28 Thread BartC
On 25/02/2015 20:58, Michiel Overtoom wrote: On Feb 25, 2015, at 21:45, Mark Lawrence wrote: http://www.slideshare.net/pydanny/python-worst-practices I like the way it advises against preserving pixels by removing vowels from identifiers. Then it gives the best practice example of using "

Re: Python Worst Practices

2015-02-28 Thread BartC
On 28/02/2015 01:09, Steven D'Aprano wrote: Likewise: int = 23 n = int("42") Isn't it obvious that the second use of int has to be the built-in function? I wish that the computer would understand from context which one I mean. (People here would like PL/I then which apparently has *no* reser

Re: Python Worst Practices

2015-02-28 Thread Marko Rauhamaa
BartC : > (Over here it's spelled "colour"...) The language of science and technology is American English. Learn it like everybody else has to. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: requesting you all to please guide me , which tutorials is best to learn redis database

2015-02-28 Thread Denis McMahon
On Thu, 26 Feb 2015 11:14:50 -0800, Jai wrote: > i want to learn redis database and its use via python , please > guide me which tutorials i should be study, so that i can learn it > in good way Using databases via python often involves working with dictionaries or lists, lists of d

Re: Python Worst Practices

2015-02-28 Thread Chris Angelico
On Sat, Feb 28, 2015 at 9:39 PM, BartC wrote: > (People here would like PL/I then which apparently has *no* reserved words, > so you can write: "if if=then then ...") Likewise REXX has no reserved words; also, SQL went part-way there, with the notion of "non-reserved keywords". For example, "ORDE

Re: Python Worst Practices

2015-02-28 Thread Mark Lawrence
On 27/02/2015 21:40, Chris Angelico wrote: On Sat, Feb 28, 2015 at 8:37 AM, Dave Angel wrote: Right. In C and C++, instead of being the first slide, it'd be the first 3 or 4. Between header file conflicts (especially good because the stdlib itself has many multiply-defined symbols, duplicate

Re: Python Worst Practices

2015-02-28 Thread Mark Lawrence
On 28/02/2015 10:56, Marko Rauhamaa wrote: BartC : (Over here it's spelled "colour"...) The language of science and technology is American English. Learn it like everybody else has to. Marko People from Angleland use any English apart from our own, never. Next thing you'll be telling u

Re: Python Worst Practices

2015-02-28 Thread Chris Angelico
On Sun, Mar 1, 2015 at 2:33 AM, Mark Lawrence wrote: > > It also makes me wonder what idiot decided to use C as the language for the > first Python implementation? Or was it written in something else and then > ported? Guido, probably. And what other language would you suggest? What other languag

Re: Python Worst Practices

2015-02-28 Thread Cousin Stanley
> From : Tim Chase > > A quick google-and-tally for languages > and their corresponding number of keywords: > re-sorted 21 : Lua 31 : Python2.x 33 : Python3.x 33 : C 37 : Pike 40 : Perl 40 : Ruby 50 : Java 54 : Pascal

Re: Python Worst Practices

2015-02-28 Thread Rustom Mody
On Saturday, February 28, 2015 at 9:34:05 PM UTC+5:30, Cousin Stanley wrote: > > From : Tim Chase > > > > A quick google-and-tally for languages > > and their corresponding number of keywords: > > > > re-sorted > > 21 : Lua > 31 : Python2.x > 33 : Python3.x >

Re: Python Worst Practices

2015-02-28 Thread Mark Lawrence
On 28/02/2015 15:46, Chris Angelico wrote: On Sun, Mar 1, 2015 at 2:33 AM, Mark Lawrence wrote: It also makes me wonder what idiot decided to use C as the language for the first Python implementation? Or was it written in something else and then ported? Guido, probably. And what other langua

Re: Python Worst Practices

2015-02-28 Thread Chris Angelico
On Sun, Mar 1, 2015 at 3:28 AM, Mark Lawrence wrote: > I love fishing, just dangle the bait and wait to see what bites :) Yeah, you usually catch someone. Sometimes they need to be majorly sleep-deprived at half past three in the morning so they're looking at message bodies and skipping the heade

Re: Python Worst Practices

2015-02-28 Thread Mark Lawrence
On 28/02/2015 16:36, Chris Angelico wrote: On Sun, Mar 1, 2015 at 3:28 AM, Mark Lawrence wrote: I love fishing, just dangle the bait and wait to see what bites :) Yeah, you usually catch someone. Sometimes they need to be majorly sleep-deprived at half past three in the morning so they're loo

Re: Python Worst Practices

2015-02-28 Thread MRAB
On 2015-02-28 16:03, Cousin Stanley wrote: From : Tim Chase A quick google-and-tally for languages and their corresponding number of keywords: re-sorted 21 : Lua 31 : Python2.x 33 : Python3.x 33 : C 37 : Pike 40 : Perl 40 : Ruby

Re: Python Worst Practices

2015-02-28 Thread BartC
On 28/02/2015 15:33, Mark Lawrence wrote: It also makes me wonder what idiot decided to use C as the language for the first Python implementation? Or was it written in something else and then ported? Python was already slow enough even written in C. With any other implementation language, it

Re: Python Worst Practices

2015-02-28 Thread Ethan Furman
On 02/28/2015 09:56 AM, MRAB wrote: > On 2015-02-28 16:03, Cousin Stanley wrote: >> >>> From : Tim Chase >>> >>> A quick google-and-tally for languages >>> and their corresponding number of keywords: >>> >> >>re-sorted >> >> 21 : Lua >> 31 : Python2.x >> 33 : Pyt

Re: Python Worst Practices

2015-02-28 Thread Tim Chase
On 2015-02-28 17:56, MRAB wrote: > On 2015-02-28 16:03, Cousin Stanley wrote: > > > >> From : Tim Chase > >> > >> A quick google-and-tally for languages > >> and their corresponding number of keywords: > >> > > > >re-sorted > > > > 21 : Lua > > 31 : Python2.x > >

Re: Python Worst Practices

2015-02-28 Thread Mark Lawrence
On 28/02/2015 17:55, BartC wrote: On 28/02/2015 15:33, Mark Lawrence wrote: It also makes me wonder what idiot decided to use C as the language for the first Python implementation? Or was it written in something else and then ported? Python was already slow enough even written in C. With any

Re: Python Worst Practices

2015-02-28 Thread Tim Chase
On 2015-02-28 10:13, Ethan Furman wrote: > On 02/28/2015 09:56 AM, MRAB wrote: > > On 2015-02-28 16:03, Cousin Stanley wrote: > >> > >>> From : Tim Chase > >>> > >>> A quick google-and-tally for languages > >>> and their corresponding number of keywords: > >>> > >> > >>re-sorted > >>

PIL installation fails; registration problem

2015-02-28 Thread GerritM
I am reinstalling everything on my new Windows 7 laptop. I run into a problem when installing PIL 1.1.7, in combination with my Activestate Python 2.7.8. The PIL installer complains that no Python is registered. I did run Joakim Löw's script to register Python. This results in the message "*** Y

suggestions for functional style (singleton pattern?)

2015-02-28 Thread yves
Hi, For some scripts, I write in a a more functional way, using a lot of small functions outside of any class. Although it makes the code clearer for specific cases, I have found that it makes debugging and using the repl in general difficult, as as I have to re-initialise every single objects eve

Re: Python Worst Practices

2015-02-28 Thread Gregory Ewing
Chris Angelico wrote: Likewise REXX has no reserved words; also, SQL went part-way there, with the notion of "non-reserved keywords". Python sometimes has those, too. For example, the "as" in "import as" was non-reserved when it was first introduced, to avoid abruptly breaking code that used it

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread Michael Torrie
On 02/28/2015 04:12 PM, y...@zioup.com wrote: > For some scripts, I write in a a more functional way, using a lot of small > functions outside of any class. Although it makes the code clearer for > specific cases, I have found that it makes debugging and using the repl in > general difficult, as as

Re: Python Worst Practices

2015-02-28 Thread Steven D'Aprano
BartC wrote: > On 28/02/2015 15:33, Mark Lawrence wrote: > >> It also makes me wonder what idiot decided to use C as the language for >> the first Python implementation? Or was it written in something else and >> then ported? > > Python was already slow enough even written in C. Tell that to t

Re: Python Worst Practices

2015-02-28 Thread Chris Angelico
On Sun, Mar 1, 2015 at 1:08 PM, Steven D'Aprano wrote: > but overall, I think it's fair to say that IronPython is about 1.8 times the > speed of CPython. > > >> With any other implementation language, it would have ground to a halt. > > That's laughably inaccurate. I'm sure that Python could have

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread Mario Figueiredo
On Sat, 28 Feb 2015 16:12:54 -0700, y...@zioup.com wrote: >Hi, > >For some scripts, I write in a a more functional way, using a lot of small >functions outside of any class. Although it makes the code clearer for >specific cases, I have found that it makes debugging and using the repl in >general

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread yves
On 2015-02-28 19:19, Michael Torrie wrote: > You say you are trying to use a singleton pattern, but your code does > not appear to implement a singleton. From what I can read of your code, I call it a singletone because I only every create one object. I am not trying to use a singleton, I'm tryi

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread yves
On 2015-02-28 20:45, Mario Figueiredo wrote: > Problem 1: > With the exception of get_all_files(), all your functions do is to > call another standard function. This decreases performance > unnecessarily and may mislead the users of your API into thinking > these functions perform some different t

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread Michael Torrie
On 02/28/2015 09:29 PM, y...@zioup.com wrote: >> Problem 4: >> You speak of a singleton. But you haven't implemented one. It is not >> clear from your code if this class should be a singleton. I'm guessing >> not. Singletons are in fact rare. Well, let me put it another way: >> Good reasons to code

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread Michael Torrie
On 02/28/2015 09:11 PM, y...@zioup.com wrote: > On 2015-02-28 19:19, Michael Torrie wrote: >> You say you are trying to use a singleton pattern, but your code does >> not appear to implement a singleton. From what I can read of your code, > > I call it a singletone because I only every create one

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread Gregory Ewing
y...@zioup.com wrote: Thanks. I hadn't realise "singleton" meant a class built such that it could not be instanciated more than once, It doesn't have to be, it could just be a class that you refrain from instantiating more than once. But as Michael Torrie said, it's rare to need to to that in

Re: suggestions for functional style (singleton pattern?)

2015-02-28 Thread Paul Rubin
y...@zioup.com writes: > Are there better ways to address this? Any suggestion on this style? I guess I don't completely understand the question. But one way to do a singleton in python is put the initialization code into a separate module. Then the first time you import the module, the code run