Re: How clean/elegant is Python's syntax?

2013-05-30 Thread Rick Johnson
On Wednesday, May 29, 2013 7:24:48 PM UTC-5, Dan Stromberg wrote: > About the only thing I don't like is: > >    var = 1, > > That binds var to a tuple (singleton) value, instead of 1. I don't understand why Python needs tuples anyway; at least not tuple literals!. I mean, i like the idea of a

Re: Short-circuit Logic

2013-05-30 Thread Rick Johnson
> On Fri, May 31, 2013 at 2:58 AM, rusi wrote: > > On May 30, 5:58 pm, Chris Angelico wrote: > > > The alternative would be an infinite number of iterations, which is far > > > far worse. > > > > There was one heavyweight among programming teachers -- E.W. Dijkstra > > -- who had some rather extre

PyWart: The problem with "print"

2013-06-02 Thread Rick Johnson
Note to those of you who may be new to Python: I will refer to "print" as a function -- just be aware that "print" was a statement before Python3000 was introduced. Introduction: --

Re: PyWart: The problem with "print"

2013-06-02 Thread Rick Johnson
On Jun 2, 12:20 pm, Chris Angelico wrote: > On Mon, Jun 3, 2013 at 3:04 AM, Rick Johnson > > * Woefully inadequate because: Switching on or off the debug > >messages is only valid in the current module that the > >function was imported. What if you want to kill

Re: PyWart: The problem with "print"

2013-06-02 Thread Rick Johnson
On Sunday, June 2, 2013 12:49:02 PM UTC-5, Dan Sommers wrote: > On Mon, 03 Jun 2013 03:20:52 +1000, Chris Angelico wrote: > > On Mon, Jun 3, 2013 at 3:04 AM, Rick Johnson > [...] > Or use the logging module. It's easy to get going quickly > (just call logging.basicConfi

Re: PyWart: The problem with "print"

2013-06-03 Thread Rick Johnson
On Sunday, June 2, 2013 1:58:30 PM UTC-5, Steven D'Aprano wrote: > On Sun, 02 Jun 2013 10:04:00 -0700, Rick Johnson wrote: Oh Steven, you've really outdone yourself this time with the theatrics. I hope you scored some "cool points" with your minions. Heck, you almost h

Re: PyWart: The problem with "print"

2013-06-03 Thread Rick Johnson
On Monday, June 3, 2013 10:16:13 PM UTC-5, Vito De Tullio wrote: > Rick Johnson wrote: > > Take your > > standard yes/no/cancel dialog, i would expect it to return > > True|False|None respectively, > you clearly mean True / False / FileNotFound. No, i clearly meant what

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Rick Johnson
On Tuesday, June 4, 2013 12:39:59 AM UTC-5, Steven D'Aprano wrote: > On Mon, 03 Jun 2013 18:37:24 -0700, Rick Johnson wrote: > Consider a simple thought experiment. Suppose we start with a sequence of > if statements that begin simple and get more complicated: > if a == 1: ...

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Rick Johnson
On Jun 4, 10:44 am, Rick Johnson wrote: > What we need is a method by which we can validate a symbol > and simultaneously do the vaidation in a manner that will > cast light on the type that is expected. In order for this > to work, you would need validators with unique "type

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Rick Johnson
On Jun 4, 11:00 am, Chris Angelico wrote: > You know, if you want a language with strict type declarations and > extreme run-time efficiency, there are some around. I don't like declaring types everywhere, i hate it. I prefer duck typed languages, HOWEVER, in order for duck typing to work consist

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Rick Johnson
On Jun 4, 12:42 pm, Ian Kelly wrote: > > By this manner, we can roll three common tests into one > > method: > > * Boolean conversion > > * member truthiness for iterables > > * type checking > How exactly does this is_valid method perform the first two? Are you > suggesting that an

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Rick Johnson
On Wednesday, June 5, 2013 11:59:07 AM UTC-5, Chris Angelico wrote: > Frankly, I don't think the language much matters. It's all > down to the skill of the programmers and testers. Ada > wasn't the source of the problem unless Ada has a bug in > it... which is going to be true of pretty much any >

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Rick Johnson
On Wednesday, June 5, 2013 6:18:13 PM UTC-5, Michael Torrie wrote: > On 06/05/2013 12:11 AM, Russ P. wrote: > > But then, what would you expect of a language that allows you to > > write > > x = 1 > > x = "Hello" > > It's all loosey goosey -- which is fine for many applications but > > certainly n

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Rick Johnson
On Wednesday, June 5, 2013 2:15:57 AM UTC-5, Chris Angelico wrote: > [...] > I cannot name a single modern programming language that does NOT have > some kind of implicit boolification. Congrats: Again you join the ranks of most children who make excuses for their foolish actions along the lines

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Rick Johnson
On Wednesday, June 5, 2013 8:37:20 PM UTC-5, Steven D'Aprano wrote: > On Wed, 05 Jun 2013 09:15:01 -0700, Russ P. wrote: > > On Wednesday, June 5, 2013 1:59:01 AM UTC-7, Mark Lawrence wrote: > >> On 05/06/2013 07:11, Russ P. wrote: > What prevents bugs is the skill of the people writing the code,

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Rick Johnson
On Thursday, June 6, 2013 1:03:24 PM UTC-5, Rick Johnson wrote: > The second covers type checking objects that enter into new > namespaces. That would cover all functions/methods arguments > (at a minimum). Yeah, before anyone starts complaining about this, i meant to say "scope&

Re: Re-using copyrighted code

2013-06-09 Thread Rick Johnson
On Sunday, June 9, 2013 8:21:43 AM UTC-5, Malte Forkel wrote: > I have asked the PSF for help regarding the implications of the license > status of code from sre_parse.py and the missing license statement in > sre.py. I'll happily report their answer to the list I they don't reply > in this thread

Re: Re-using copyrighted code

2013-06-09 Thread Rick Johnson
On Sunday, June 9, 2013 4:08:54 PM UTC-5, zipher wrote: > >> That's not entirely correct. If he *publishes* his code (I'm using > > >> this term "publish" technically to mean "put forth in a way where > > >> anyone of the general public can or is encouraged to view"), then he > > >> is *tacitly

Re: Re-using copyrighted code

2013-06-09 Thread Rick Johnson
On Sunday, June 9, 2013 7:26:43 PM UTC-5, Steven D'Aprano wrote: > When you listen to a song on the radio, do you know how they have a > copyright announcer read out the copyright and explicitly list all the > rights they keep after each and every song and advertisment? > No, me neither. It does

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-11 Thread Rick Johnson
On Monday, June 10, 2013 9:56:43 PM UTC-5, Steven D'Aprano wrote: > On Mon, 10 Jun 2013 20:14:55 -0400, Terry Jan Reedy wrote: > > For instance, open Lib/idlelib/GrepDialog.py in an editor that colorizes > > Python syntax, such as Idle's editor, jump down to the bottom and read > > up, and (until i

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-11 Thread Rick Johnson
On Tuesday, June 11, 2013 8:34:55 AM UTC-5, Steven D'Aprano wrote: > GvR is saying that it's okay to use the names of built-in functions or > types as the names of local variables, even if that causes the built-in > to be inaccessible within that function. Looks like we've finally found the tra

Re: A certainl part of an if() structure never gets executed.

2013-06-11 Thread Rick Johnson
Umm, "Niko". (Superfluous Unicode Removed) The code you have written is very difficult to read because you are doing too much inside the conditional and you're repeating things!. For starters you could compile those regexps and re-use them: ## BEGIN SESSION ## py> import re py> s = """\ ... hel

Re: Newbie: question regarding references and class relationships

2013-06-11 Thread Rick Johnson
On Monday, June 10, 2013 8:18:52 AM UTC-5, Rui Maciel wrote: > [...] > > > class Point: > position = [] > def __init__(self, x, y, z = 0): > self.position = [x, y, z] Firstly. Why would you define a Point object that holds it's x,y,z values in a list attribute? W

Re: Newbie: question regarding references and class relationships

2013-06-11 Thread Rick Johnson
On Monday, June 10, 2013 2:56:15 PM UTC-5, Ian wrote: > [...] > There are a couple of ways you might get this to work the way you > want. One is by adding as an extra layer a proxy object, which could > be as simple as: > class Proxy(object): > def __init__(self, ref): > self.ref = ref

Re: A certainl part of an if() structure never gets executed.

2013-06-11 Thread Rick Johnson
On Tuesday, June 11, 2013 8:25:30 PM UTC-5, nagia@gmail.com wrote: > is there a shorter and more clear way to write this? > i didnt understood what Rick trie to told me. My example included verbatim copies of interactive sessions within the Python command line. You might understand them bett

Re: A certainl part of an if() structure never gets executed.

2013-06-11 Thread Rick Johnson
On Tuesday, June 11, 2013 9:14:38 PM UTC-5, alex23 wrote: > On Jun 12, 12:05 pm, Chris Angelico wrote: > > > You have to include the coding phase. > > How else would he get into an error state? > > Via copy & paste. Now that's more like it Alex! If you move to my side the Python world could

Re: A certainl part of an if() structure never gets executed.

2013-06-11 Thread Rick Johnson
On Tuesday, June 11, 2013 10:37:39 PM UTC-5, Rick Johnson wrote: > Now that's more like it Alex! Opps, it seems i falsely interpreted Chris's post as directed towards me, and then with that false assumption in mind i went on to falsely interpreted reply to Chris. Folks if you

Re: Pywart: The problem with "Rick Johnson"

2013-06-12 Thread Rick Johnson
On Wednesday, June 12, 2013 2:17:49 PM UTC-5, Terry Reedy wrote: > On 6/4/2013 11:45 PM, Mike Hansen wrote: > > Is "Rick Johnson" the alter ego of Xah Lee, or is he the result of a > > cross breeding experiement with a troll by Saruman at Isengard? > He is a Python prog

Re: My son wants me to teach him Python

2013-06-12 Thread Rick Johnson
On Wednesday, June 12, 2013 2:46:13 PM UTC-5, John Ladasky wrote: > [...] > He's a smart kid, but prefers to be shown, to be tutored, > rather than having the patience to sit down and RTFM. > Have any of you been down this road before? I would > appreciate it if you would share your experiences, o

Re: My son wants me to teach him Python

2013-06-12 Thread Rick Johnson
On Wednesday, June 12, 2013 11:08:44 PM UTC-5, Chris Angelico wrote: > No. Definitely not. Programming does NOT begin with a GUI. It begins > with something *simple*, so you're not stuck fiddling around with the > unnecessary. On today's computers, that usually means console I/O > (actually consol

Re: My son wants me to teach him Python

2013-06-13 Thread Rick Johnson
On Thursday, June 13, 2013 3:18:57 PM UTC-5, Joshua Landau wrote: > [...] > GUI is boring. I don't give a damn about that. If I had it > my way, I'd never write any interfaces again (although > designing them is fine). Console interaction is faster to > do and it lets me do the stuff I *want* to d

Re: My son wants me to teach him Python

2013-06-16 Thread Rick Johnson
On Thursday, June 13, 2013 11:05:00 PM UTC-5, Chris Angelico wrote: Chris, a GUI interface can be created for *ANY* command line functionality. By utilizing the GUI you can be more productive because a "point" and a "click" are always faster than "peck-peck-peck" * INFINITY. For instance, if i w

Re: My son wants me to teach him Python

2013-06-16 Thread Rick Johnson
On Sunday, June 16, 2013 4:52:16 PM UTC-5, Chris Angelico wrote: > Okay... I'm trying to get my head around what you've done > here. Isn't it simply that you've made a way to, with what > looks like a point-and-click interface, let the user type > in a command line? > [...] > That's no more usin

Re: Why is regex so slow?

2013-06-18 Thread Rick Johnson
On Tuesday, June 18, 2013 11:45:29 AM UTC-5, Roy Smith wrote: > I've got a 170 MB file I want to search for lines that look like: > [2010-10-20 16:47:50.339229 -04:00] INFO (6): songza.amie.history - > ENQUEUEING: /listen/the-station-one > This code runs in 1.3 seconds: >

Re: Beginner Question: 3D Models

2013-06-19 Thread Rick Johnson
On Tuesday, June 18, 2013 9:47:34 PM UTC-5, andrew...@gmail.com wrote: > I'm looking at developing a program for work that can be > distributed to others (i.e. and exe file). The > application would open various dialogue boxes and ask the > user for input and eventually perform mathematical > cal

Re: A Beginner's Doubt

2013-06-19 Thread Rick Johnson
On Wednesday, June 19, 2013 8:58:19 AM UTC-5, augus...@gmail.com wrote: > This is my first post in this group and the reason why I > came across here is that, despite my complete lack of > knowledge in the programming area, I received an order > from my teacher to develop a visually interactive pro

Re: A Beginner's Doubt

2013-06-19 Thread Rick Johnson
On Wednesday, June 19, 2013 12:57:06 PM UTC-5, Terry Reedy wrote: > > Terry (speaking to OP) said: > > Do you literally mean a full screen *window*, like a > browser maximized,

Re: Default Value

2013-06-19 Thread Rick Johnson
On Wednesday, June 19, 2013 2:17:35 PM UTC-5, Ahmed Abdulshafy wrote: > I'm reading the Python.org tutorial right now, and I found > this part rather strange and incomprehensible to me> > > Important warning: The default value is evaluated only > once. This makes a difference when the default is a

Re: A few questiosn about encoding

2013-06-19 Thread Rick Johnson
On Thursday, June 13, 2013 2:11:08 AM UTC-5, Steven D'Aprano wrote: > Gah! That's twice I've screwed that up. > Sorry about that! Yeah, and your difficulty explaining the Unicode implementation reminds me of a passage from the Python zen: "If the implementation is hard to explain, it's a bad

Re: A few questiosn about encoding

2013-06-20 Thread Rick Johnson
On Thursday, June 20, 2013 1:26:17 AM UTC-5, Steven D'Aprano wrote: > The *implementation* is easy to explain. It's the names of > the encodings which I get tangled up in. Well, ignoring the fact that you're last explanation is still buggy, you have not actually described an "implementation", no,

Re: Default Value

2013-06-20 Thread Rick Johnson
On Thursday, June 20, 2013 7:57:06 AM UTC-5, rusi wrote: > Every language has gotchas. This is one of python's. So are we purposely injecting illogic into our language just to be part of some "cool crowd" of programming languages with gotchas. "You thought intuitiveness was a virtue? Haha, we go

Re: A few questiosn about encoding

2013-06-20 Thread Rick Johnson
On Thursday, June 20, 2013 9:04:50 AM UTC-5, Andrew Berg wrote: > On 2013.06.20 08:40, Rick Johnson wrote: > > then what is the purpose of a Unicode Braille character set? > Two dimensional characters can be made into 3 dimensional shapes. Yes in the real world. But what a

Re: Default Value

2013-06-20 Thread Rick Johnson
On Thursday, June 20, 2013 10:38:34 AM UTC-5, Chris Angelico wrote: > Function defaults in Python, being implemented as > attributes on the function object, are very similar in > nature to static variables in C. Oh wait a minute. i think it's becoming clear to me now! Python functions are objects

Re: Default Value

2013-06-20 Thread Rick Johnson
On Thursday, June 20, 2013 12:12:01 PM UTC-5, rusi wrote: > Python (and all the other 'cool' languages) dont have > gotchas because someone malevolently put them there. In > most cases, the problem is seen too late and the cost of > changing entrenched code too great. Okay. So now you are admitt

Re: Default Value

2013-06-20 Thread Rick Johnson
On Thursday, June 20, 2013 7:57:28 PM UTC-5, Steven D'Aprano wrote: > On Thu, 20 Jun 2013 11:05:32 -0700, Rick Johnson wrote: > > Python functions are objects that take arguments, of > > which (the arguments) are then converted to attributes > > of the function object.

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 2:10:49 AM UTC-5, Chris Angelico wrote: > Why should that be? Why is a subroutine not allowed to > retain any state? I refuse to repeat myself for lazy readers! > You're free to write code in a purely functional style if > you like I don't want to write code in a purely

Re: Default Value

2013-06-21 Thread Rick Johnson
On Thursday, June 20, 2013 5:28:06 PM UTC-5, Lefavor, Matthew (GSFC-582.0)[MICROTEL LLC] wrote: > > [snip example showing dummy coder doing something dumb] > > +1. This is what convinces me that keeping references to > keyword arguments is actually the right thing to do. > > Perhaps I'm biased b

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 10:57:17 AM UTC-5, Steven D'Aprano wrote: > On Thu, 20 Jun 2013 11:05:32 -0700, Rick Johnson wrote: > > py> class FuncAdd(object): > > ... def __init__(self, ivalue): > > ... self.ivalue = ivalue > Notice how you are storin

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 12:47:56 PM UTC-5, Rotwang wrote: > It isn't clear to me from your posts what exactly you're > proposing as an alternative to the way Python's default > argument binding works. In your version of Python, what > exactly would happen when I passed a mutable argument as a > de

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 1:37:13 PM UTC-5, Steven D'Aprano wrote: > Okay, you're trolling. Time for another month in the kill-file. > *plonk* That's so typical of you. You start losing an argument, and when you have no remaining counter arguments, you resort to name calling. Why am i not surprise

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 2:18:27 PM UTC-5, Rick Johnson wrote: > On Friday, June 21, 2013 1:37:13 PM UTC-5, Steven D'Aprano wrote: > > > Okay, you're trolling. Steven, you wouldn't know "trolling" even if you were an honorary salad tosser at a

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 2:20:22 PM UTC-5, Neil Cerutti wrote: > Rick, it's not a wart, It's a gotcha. The reason it's a > gotcha is this: In order to predict what will happen > correctly, you have to have mastered three separate Python > concepts. > > 1. How name-binding works. > 2. How argument p

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 2:25:49 PM UTC-5, MRAB wrote: > On 21/06/2013 19:26, Rick Johnson wrote: > > > > The Apathetic Approach: > > > >

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote: > I notice that you've omitted any mention of how you'd know that the > argument was mutable. My argument has always been that mutables should not be passed into subroutines as default arguments because bad things can happen. And Python's excu

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 6:40:51 PM UTC-5, Rotwang wrote: > On 21/06/2013 19:26, Rick Johnson wrote: > [...] > I didn't ask what alternative methods of handling default > argument binding exist (I can think of several, but none > of them strikes me as preferable to how Python

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 8:31:35 PM UTC-5, Steven D'Aprano wrote: > Tuples have to go into the "Bad List" because, although > they themselves are immutable, their contents may not be. > Imagine the confusion and horror that poor developers will > experience when they do something like this: > > de

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 8:54:50 PM UTC-5, MRAB wrote: > On 22/06/2013 00:51, Rick Johnson wrote: > > On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote: > > My argument has always been that mutables should not be > > passed into subroutines as default arguments becau

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 8:38:21 PM UTC-5, Ian wrote: > The answer to this conundrum is staring you in the face. Thanks for posting a solution for this. Not sure if i'll ever need it, but nice to know. > Note that the TypeError complains that you passed it an > "unhashable" type, and not that you

Re: Default Value

2013-06-21 Thread Rick Johnson
On Friday, June 21, 2013 9:32:43 PM UTC-5, rusi wrote: > So Rick... I agree with you... all these theoreticians > should be burnt at the stake! On a more serious note: many > people make similar mistakes eg Haskellers who think > Haskell is safe. Safer (than something or other) -- Ok > Safe -- NO

Re: Default Value

2013-06-22 Thread Rick Johnson
> See my blog [...] > for a history of wishes akin to yours and lessons not > learnt. In short the problems accruing from unconstrained > imperative programming are severe and the solutions are > hard. In the meanwhile, goals such as your 'keep- > procedures-stateless' can and should certainly be >

Re: n00b question on spacing

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 8:36:43 AM UTC-5, Joshua Landau wrote: > message = "Item wrote to MongoDB database " > message += "{0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}".format(settings) > log.msg(message, level=log.DEBUG, spider=spider) If you're going to whore out parts of the string to variables i

Re: n00b question on spacing

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 10:40:24 AM UTC-5, Joshua Landau wrote: > > Plus, your use of the format syntax is incorrect. > Wut? Well what i mean exactly is not that it's illegal, i just find the use of the "getattr sugar", from WITHIN the format string, to be excessively noisy. In short, i don't

Re: Default Value

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 12:19:31 PM UTC-5, Rotwang wrote: > > On 22/06/2013 02:15, Rick Johnson wrote: > > IS ALL THIS REGISTERING YET? DO YOU UNDERSTAND? > > No, I don't. These two special cases are not sufficient > for me to determine what semantics you are propos

Re: n00b question on spacing

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 6:12:50 PM UTC-5, Chris Angelico wrote: > As a general rule, I don't like separating format strings and their > arguments. Huh? Format strings don't take arguments because Python's built-in string type is not callable. py> callable("") False "Format string" is ju

Re: newbie question

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 9:39:30 PM UTC-5, christ...@gmail.com wrote: > Writing simple program asking a question with the answer being > "yes"...how do I allow the correct answer if user types Yes, > yes, or YES? Here is a clue. py> 'e' == 'e' True py> 'E' == 'E' True -- http://mail.p

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Rick Johnson
On Sunday, June 23, 2013 11:15:38 AM UTC-5, Ian wrote: > If you're worried about efficiency, you can also > explicitly name the superclass in order to call the method > directly, like: I'm NOT worried about efficiency, i worried about readability, and using super (when super is NOT absolutely requ

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Rick Johnson
On Sunday, June 23, 2013 11:49:42 AM UTC-5, Roy Smith wrote: > For what it's worth, I never bother to inherit from object > unless I know there's something I need from new style > classes. Undoubtedly, this creates a disturbance in The > Force, but such is life. Well, in Python 3000, if you don'

Re: Stupid ways to spell simple code

2013-06-30 Thread Rick Johnson
On Sunday, June 30, 2013 1:06:35 AM UTC-5, Chris Angelico wrote: > So, here's a challenge: Come up with something really simple, and > write an insanely complicated - yet perfectly valid - way to achieve > the same thing. Bonus points for horribly abusing Python's clean > syntax in the process. Ch

Re: Question:Programming a game grid ...

2012-06-27 Thread Rick Johnson
On Jun 27, 5:21 pm, iconoclast011 wrote: > Fairly new to Python ... Is there a way to efficiently (different from my > brute > force code shown below) to set up a game grid of buttons (ie with pygame) > responding to mouse clicks ?   I would want to vary the size of the grid ... > > Thanks > > Br

Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 3:20 am, Chris Angelico wrote: > On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano > > wrote: > > "c" < first_word < second_word == third_word < "x" > > > I'm sure I don't have to explain what that means -- that standard chained > > notation for comparisons is obvious and simple. > > > In

Re: code review

2012-07-02 Thread Rick Johnson
On Jun 30, 9:06 pm, Steven D'Aprano wrote: > On Sun, 01 Jul 2012 00:05:26 +0200, Thomas Jollans wrote: > > Yes. My sole point, really, is that "normally", one would expect these > > two expressions to be equivalent: > > > a < b < c > > (a < b) < c > > Good grief. Why would you expect that? > > You

Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 11:42 am, Chris Angelico wrote: > Rick, do you realize that you have > to spoon-feed the interpreter with spaces/tabs when other interpreters > just KNOW to drop back an indentation level when you close a brace? Yes. And significant white space is my favorite attribute of Python source

Re: code review

2012-07-02 Thread Rick Johnson
On Jul 2, 2:06 pm, Thomas Jollans wrote: > On 07/02/2012 08:22 PM, Rick Johnson wrote: > > > Agreed. I wish we had one language. One which had syntactical > > directives for scoping, blocks, assignments, etc, etc... > > > BLOCK_INDENT_MARKER -> \t

Re: WxSlider Mouse Wheel Resolution

2012-07-02 Thread Rick Johnson
On Jul 2, 10:45 am, Wanderer wrote: > Is there a way to set the mouse wheel resolution for the wxPython > wx.Slider? I would like to use the graphic slider for coarse control > and the mouse wheel for fine control. Right now the mouse wheel makes > the slider jump ten counts and I would like it to

Re: WxSlider Mouse Wheel Resolution

2012-07-02 Thread Rick Johnson
On Jul 2, 3:45 pm, Rick Johnson wrote: > [...] >   MouseWheel -> cb(MEDIUM) >   MouseWheel+ControlKey -> cb(FINE) >   MouseWheel+ShiftKey -> cb(COURSE) Of course some could even argue that three levels of control are not good enough; for which i wholeheartedly agree! A REA

Re: Discussion on some Code Issues

2012-07-04 Thread Rick Johnson
On Jul 4, 6:21 pm, subhabangal...@gmail.com wrote: > [...] > To detect the document boundaries, I am splitting them into a bag > of words and using a simple for loop as, > > for i in range(len(bag_words)): >         if bag_words[i]=="$": >             print (bag_words[i],i) Ignoring that you are a

Re: simpler increment of time values?

2012-07-05 Thread Rick Johnson
On Jul 5, 10:19 am, Steven D'Aprano wrote: > The number of seconds in a day (true solar day) varies by between 13 and > 30 seconds depending on the time of the year and the position of the sun. Indeed. Which proves that a time keeping system based on the haphazard movements of celestial bodies is

Re: tkFileDialogs

2012-07-06 Thread Rick Johnson
On Jul 6, 12:22 am, brandon harris wrote: > [...] > import tkFileDialog > # Won't start in or allow navigation to APPDATA > test = tkFileDialog.askdirectory(initialdir='%APPDATA%') > # Will start in and navigate to APPDATA > test = tkFileDialog.askopenfile(initialdir='%APPDATA%') Don't you just l

Re: simpler increment of time values?

2012-07-06 Thread Rick Johnson
On Jul 5, 12:16 pm, Chris Angelico wrote: > > So it's even easier than I said. And bonus lesson for the day: Try > things in the interactive interpreter before you post. :) but first: be sure to familiarize yourself with the many built-in "python classes"(sic). Re-inventing the wheel is breaking

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-09 Thread Rick Johnson
On Jul 9, 12:58 am, Terry Reedy wrote: > When posting problem code, you should post a minimal, self-contained > example that people can try on other systems and versions. Can you > create the problem with one record, which you could give, and one > binding? Do you need 4 fields, or would 1 'work'?

Re: Python Interview Questions

2012-07-09 Thread Rick Johnson
On Jul 9, 12:40 pm, Tim Chase wrote: > The second[or higher]-order > ignorance of not knowing what pdb is (or, if you need more powerful > debugging, how to do it) is sign the person hasn't been programming > in Python much. So guru knowledge of pdb is prerequisite to being accepted as a Pythonis

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-10 Thread Rick Johnson
I've tried to condense your code using the very limited info you have provided. I have removed unnecessarily configuring of widgets and exaggerated the widget borders to make debugging easier. Read below for Q&A. ## START CONDENSED CODE ## records = range(4) CNF_SUBFRAME = { 'bd':5, # rowFram

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-10 Thread Rick Johnson
Also: Q3: Why are you explicitly setting the name of your "subFrame" widgets instead of allowing Tkinter to assign a unique name?...AND are you aware of the conflicts that can arise from such changes[1]? Q4: Are you aware of the built-in function "enumerate"[2]? I see you are passing around inde

Re: Python Interview Questions

2012-07-10 Thread Rick Johnson
On Jul 10, 4:29 am, Jean-Michel Pichavant wrote: > Why would you want to hire someone that knows something pointless as the > version where feature X has been introduced ? Just tell him that feature > X has been introducted in version Y, costless 2.5sec training. Don't you > want to hire someone t

Re: How to safely maintain a status file

2012-07-12 Thread Rick Johnson
On Jul 12, 2:39 pm, Christian Heimes wrote: > Windows's file system layer is not POSIX compatible. For example > you can't remove or replace a file while it is opened by a process. Sounds like a reasonable fail-safe to me. Not much unlike a car ignition that will not allow starting the engine if

Re: Keeping the Console Open with IDLE

2012-07-15 Thread Rick Johnson
On Sunday, July 15, 2012 10:57:00 AM UTC-5, Chris Angelico wrote: > On Mon, Jul 16, 2012 at 1:35 AM, wrote: > > Besides, you can skip most of those steps by Shift+RightClicking > > the file icon and choosing "Open Command Window Here". > > That's not standard. Me, I can invoke git bash anywhere I

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Rick Johnson
On Sunday, July 15, 2012 11:19:16 AM UTC-5, Ian wrote: > On Sun, Jul 15, 2012 at 4:56 AM, Steven D'Aprano > wrote: > > (For the record, I can only think of one trap for the unwary: time > > objects are false at *exactly* midnight.) > > Ugh, that's irritating. I can't think of any scenario where

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Rick Johnson
On Sunday, July 15, 2012 1:01:58 PM UTC-5, Ian wrote: > So now instead of having to understand how "if" handles arbitrary > values, we have to understand how "bool" handles arbitrary values. > How is that an improvement? Because we are keeping the condition consistent. We are not relying on impli

Re: How to configure Tkinter Listbox to disable state keeping selected item highlighted

2012-07-18 Thread Rick Johnson
On Tuesday, July 17, 2012 8:55:21 AM UTC-5, Sarbjit singh wrote: > I am having a problem configuring a listbox widget such that the selection > remains highlighted even while it is set (programmatically) to the DISABLED > state. Below code shows the problem: > > from Tkinter import * > master =

Re: Sudden doubling of nearly all messages

2012-07-21 Thread Rick Johnson
On Saturday, July 21, 2012 5:48:29 AM UTC-5, Dave Angel wrote: > Has anybody else noticed the sudden double-posting of nearly all > messages in the python mailing list? > > Previously, I've seen some messages double posted, and it was nearly > always a newbie, presumably posting via some low-end g

Re: Sudden doubling of nearly all messages

2012-07-21 Thread Rick Johnson
On Saturday, July 21, 2012 6:16:24 PM UTC-5, Chris Angelico wrote: > Just to clarify, I'm not advocating the [...snip...] Well. Well. Backpedaling AND brown-nosing in a single post. Nice! -- http://mail.python.org/mailman/listinfo/python-list

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Rick Johnson
On Tuesday, December 25, 2012 11:10:49 AM UTC-6, Dave Angel wrote: > We all make mistakes, like my referring to class methods when I > meant instance methods. This mistake reminded of how people in this group (maybe not you in particular) happily accept the terms "instance method" and "class me

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Rick Johnson
On Tuesday, December 25, 2012 3:08:21 PM UTC-6, Dennis Lee Bieber wrote: > Only that many of us don't believe Python has /variables/, the use > of instance/class as a modifier is thereby moot. What IS a variable Dennis? # #

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-25 Thread Rick Johnson
On Tuesday, December 25, 2012 4:56:44 PM UTC-6, Steven D'Aprano wrote: > Rick, what makes you think that this is logically inconsistent? > "Method" is the accepted name for functions attached to classes. They > report themselves as "methods": > [...] > There are two built-ins for creating differen

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Rick Johnson
On Wednesday, December 26, 2012 2:29:13 AM UTC-6, Steven D'Aprano wrote: > [snip] I won't reply to your last post on a line-by-line basis because i feel we are straying from my general point: which is that we should NEVER re-interpret existing words (in an illogical manner) whilst transforming t

Re: Over 30 types of variables available in python ?

2013-01-10 Thread Rick Johnson
> On 1-7-2013 2:53:26 AM UTC-6, chaouche yacine wrote: > > Thanks for all your comments. It appears to me that there > is a slight confusion between types and classes then, plus > other entities (protocols ?) The only "confusion" stems from improper terminology. "Class" is the worst possible wor

Re: How to change colors of multiple widgets after hovering in Tkinter

2013-01-10 Thread Rick Johnson
On Thursday, January 10, 2013 1:13:38 PM UTC-6, Peter Otten wrote: > mountdoom wrote: > > I´m trying to make a script, which will change the background and > > foreground color of widgets after hovering. Peter's advice is spot on except you may want ALL widgets to change colors on and events. I

PyWart: Module access syntax

2013-01-10 Thread Rick Johnson
Python's module/package access uses dot notation. mod1.mod2.mod3.modN Like many warts of the language, this wart is not so apparent when first learning the language. The dot seems innocently sufficient, however, in truth it is woefully inadequate! Observe: name1.name2.name3.name4.name5 C

PyWart: Import resolution order

2013-01-10 Thread Rick Johnson
Python's import resolution order is terrible.[1] The fact that Python looks in the stdlib _first_ is not a good idea. It would seem more intuitive for a custom "math" module (living in the current directory) to /override/ the stlib "math" module. The proper order is as follows: 1. Current pac

Re: PyWart: Module access syntax

2013-01-11 Thread Rick Johnson
On Friday, 1-11-2013 10:02:34 AM, Steven D'Aprano wrote: > Solution to what? You can only have a solution once you have identified a > problem. You have not identified a problem. In any case, your suggestion > is *not* obvious. The problem is that by using the dot ubiquitously we are obfuscatin

  1   2   3   4   5   6   7   8   9   10   >