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: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Ranting Rick
On Jul 15, 4:53 pm, Chris Angelico wrote: > Then the construct "if bool(some_condition):" is redundant. Wrong again, pay attention Chris! It's ONLY redundant IF "some_condition" is a rich comparison: like "(a==b)" OR a boolean function: like "callable(a)". If HOWEVER we want to "truth test" an

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Ranting Rick
On Jul 15, 8:51 pm, Chris Angelico wrote: > On Mon, Jul 16, 2012 at 11:21 AM, Ranting Rick > > wrote: > > If HOWEVER we want to "truth test" an object (as in: "if obj") we > > should be FORCED to use the bool! Why? Because explicit is better than > >

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Ranting Rick
On Jul 15, 9:13 pm, Steven D'Aprano wrote: > I have just written a bunch of code with about two dozen examples similar > to this: > > for item in (seq or []): >     do_something_with(item) > > iterates over seq if it is non-empty, or the empty list. Writing it like > this would be more painful, m

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Ranting Rick
On Jul 15, 9:15 pm, Devin Jeanpierre wrote: > For example, instead of "if stack:" or "if bool(stack):", we could use > "if stack.isempty():". This line tells us explicitly that stack is a > container. Or instead of "if dist:" or "if bool(dist):" we could use > "if dist == 0:". This tells us expli

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Ranting Rick
On Jul 15, 9:58 pm, Steven D'Aprano wrote: > On Sun, 15 Jul 2012 18:21:06 -0700, Ranting Rick wrote: > > If HOWEVER we want to "truth test" an object (as in: "if obj") we should > > be FORCED to use the bool! Why? Because explicit is better than implici

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Ranting Rick
On Jul 15, 11:03 pm, Steven D'Aprano wrote: > On Sun, 15 Jul 2012 22:15:13 -0400, Devin Jeanpierre wrote: > It boggles my mind that people who are perfectly happy to program to an > interface or protocol when it comes to (say) iterables, numbers or even > big complex classes with dozens of method

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Ranting Rick
On Jul 15, 11:20 pm, Steven D'Aprano wrote: > (It's not like explicit and implicit are distinct -- everything depends > on something implicit, if only the meaning of the words you use to > describe it.) > > It certainly doesn't mean that the semantics of Python the language must > be written out

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: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Ranting Rick
On Dec 24, 9:48 am, Dave Angel wrote: > Pep8 recommends a particular style within a function name, separating > 'words of a name by underscore.  I happen to loathe that style, so I'm > clearly not the one who would critique someone for not following the > guideline.  I say getFile(), the pep says

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": > [...] &

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: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Ranting Rick
On Dec 26, 11:02 pm, Steven D'Aprano wrote: > On Wed, 26 Dec 2012 20:07:53 -0800, Rick Johnson wrote: > > My specific point is that the English word "variable" is unambiguous > > I'm sorry, do you mean "variable" the noun, or "variable" th

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

Re: PyWart: Import resolution order

2013-01-11 Thread Rick Johnson
On Friday, January 11, 2013 7:35:37 AM UTC-6, Terry Reedy wrote: > On 1/11/2013 1:13 AM, Rick Johnson wrote: > > The fact that Python looks in the stdlib _first_ is not a good idea. > > And the fact is that it does not do so. The order depends on sys.path, > and '' i

Re: PyWart: Import resolution order

2013-01-11 Thread Rick Johnson
t "lib", "userlib", or whatever) and will require them to prefix the module name with "lib." -- or "lib:" if i get my way! By doing this we solve the many problems related to module name resolution orders and we create cleaner code bases. Damn i am fu

Re: PyWart: Module access syntax

2013-01-11 Thread Rick Johnson
On Friday, January 11, 2013 10:40:36 PM UTC-6, Chris Angelico wrote: > On Sat, Jan 12, 2013 at 3:34 PM, Rick Johnson > > *The problem:* > > ... is readability. The current dot syntax used ubiquitously in paths is > > not conveying the proper information to the reader, an

Re: PyWart: Module access syntax

2013-01-13 Thread Rick Johnson
On Saturday, January 12, 2013 12:45:03 AM UTC-6, Steven D'Aprano wrote: > On Fri, 11 Jan 2013 20:34:20 -0800, Rick Johnson wrote: > > [...] > So what do you do for, say, os.path? According to the first rule, you > must write it as os:path because path is a module; according t

PyWart (Terminolgy): "Class"

2013-01-13 Thread Rick Johnson
I have believed for a very long time that "class" was a poor choice of keyword to designate an "object definition". Firstly, the word /class/ does not transform smoothly into CS from English. NO English definition of "class" comes anywhere close to describing the "structured source code that d

Re: PyWart (Terminolgy): "Class"

2013-01-13 Thread Rick Johnson
On Monday 1-14-2013 at 12:46 AM, Rick Johnson wrote: > [...] > "object": > > This is my favorite word however it does suffer a > "verbial" disconnection. What are we suggesting? A single > word can be very ambiguous as to intent. However, if we > couple th

Re: Python modules

2013-01-14 Thread Rick Johnson
On Monday, January 14, 2013 9:04:00 AM UTC-6, Chris Angelico wrote: > The performance cost of reimporting a module is very low; > in fact, trying to avoid it by adorning all your usage > with an extra dot-level will probably cost you a lot more, > since there'll be an extra lookup every time. Most

Re: PyWart (Terminolgy): "Class"

2013-01-14 Thread Rick Johnson
On Monday, January 14, 2013 11:26:37 AM UTC-6, Steven D'Aprano wrote: > On Sun, 13 Jan 2013 22:46:44 -0800, Rick Johnson wrote: > [...] > Your knowledge of English has failed you. Here is the first definition > from Webster's Dictionary (1913 edition): > > Cl

Re: PyWart: Module access syntax

2013-01-14 Thread Rick Johnson
On Monday, January 14, 2013 11:34:56 AM UTC-6, Steven D'Aprano wrote: > Since both os and path are modules, you here say that they need a colon > between them. This contradicts the above when you say the syntax for > os.path won't change. But you forgot the rule about accessing module members w

Re: PyWart: Module access syntax

2013-01-14 Thread Rick Johnson
d to use a structured package approach to tame this wild beast called Tkinter. Look, maybe nobody has the time to deal with this module, so if you need some help, then feel free to ask for my assistance. All Guido has to do is send me a private email and say: """ Hello Rick! Y

PyWart: Exception error paths far too verbose

2013-01-15 Thread Rick Johnson
Python needs to trim the path to the source file from which the exception was caught and only display the relative path starting from your personal library folder. For example. Say your personal library exists in: C:\users\user\documents\python\lib ...then there is no need to post THAT por

Re: PyWart: Exception error paths far too verbose

2013-01-16 Thread Rick Johnson
On Wednesday, January 16, 2013 8:20:12 AM UTC-6, Michael Torrie wrote: > On 01/15/2013 10:59 PM, Rick Johnson wrote: > > Why do i need to see "C:\users\user\documents\python\lib" EVERY time? > > You're thinking about things from a very windows-centric point o

Re: PyWart: Exception error paths far too verbose

2013-01-16 Thread Rick Johnson
On Wednesday, January 16, 2013 3:53:55 AM UTC-6, Terry Reedy wrote: > I agree with the complaint and you may have the germ of a good idea. The > problem is that for some tracebacks, paths jump all over the place > rather than having a common prefix. Dealing with this might require > preprocessi

Re: PyWart: Exception error paths far too verbose

2013-01-16 Thread Rick Johnson
cripts on the desktop? So you can easily double click and run them? *giggles* Steven, have you heard of the new invention called a symbolic link? http://en.wikipedia.org/wiki/Symbolic_link > > Rick said: > > Since all directories *BELOW* the directory that holds > > your pe

PyTut: (Teminology) To clone, copy, or spawn -- that is the question!

2013-01-16 Thread Rick Johnson
PyTut: (Teminology) To clone, copy, or spawn -- that is the question! I've many time seen these three words applied improperly as symbols and believe i should explicitly define these terms in a programming context so that we all might use them correctly. Also notice that i did not mention "de

Re: PyWart: Exception error paths far too verbose

2013-01-18 Thread Rick Johnson
On Wednesday, January 16, 2013 6:51:31 PM UTC-6, Terry Reedy wrote: > I missed in your original post that you only want one consistent > personal library path abbreviated, leaving everything else alone. So the > above is not applicable. And a custom excepthook very easy. > > How should the trace

Re: Beginner Tutorials

2013-01-18 Thread Rick Johnson
On Friday, January 18, 2013 11:04:39 AM UTC-6, Rik wrote: > The reason for disabling right-click has nothing to do > with protecting content, and everything to do with > stopping my students from taking the lazy way out. > > Given the chance, they'll copy/paste the code and download > the designs

Re: Beginner Tutorials

2013-01-18 Thread Rick Johnson
On Friday, January 18, 2013 10:36:09 PM UTC-6, Evan Driscoll wrote: > I have only skimmed this thread and so am unsure exactly what is being > protected against casual copy/paste, but at least on its face I would > *vehemently* disagree with your statement. Well if you skim just a wee bit more you

Re: Changing the font size of anOptionMenu widget

2013-01-24 Thread Rick Johnson
Ignoring the fact that the Tkinter.Optionmenu is by far the worst widget in the toolkit, not to mention that the whole idea of "Tkinter X_Variables" was a poor attempt to reuse code at the expense destroying the simple and intuitive interface of "get" and "set"; here is your answer: ## START

Re: Fonts & Tinker

2013-01-27 Thread Rick Johnson
On Friday, January 25, 2013 10:41:36 PM UTC-6, Angel wrote: > I am changing the default font for a Tkinter application: > > > > class FuelControl(Tkinter.Frame): > > def __init__(self,master): > > self.version='0.02' > > self.font=tkFont.Font(family="Helvetica",size=18) >

Re: simple tkinter battery monitor

2013-01-27 Thread Rick Johnson
On Sunday, January 27, 2013 4:59:20 PM UTC-6, leonix...@gmail.com wrote: > I tried to write a simple battery monitor for laptops > which shows normally just the battery percentage, and when > is clicked some more info. > > If I click just one time it works, but if I click a second > time, the addi

The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-23 Thread Rick Johnson
Here is a grep from the month of September 2011 showing the rampantly egregious misuse of the following words and phrases: * pretty * hard * right * used to * supposed to "Pretty" is the most ludicrous of them all! As you will see, "pretty" is used superfluously, over and over again! In fac

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-24 Thread Rick Johnson
On Jan 23, 11:57 pm, Rick Johnson wrote: > Here is a grep from the month of September 2011 showing the rampantly > egregious misuse of the following words and phrases: Actually my custom script had a small flaw which kept it from capturing ALL the atrocities. Here is a run with the bu

PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Rick Johnson
In particular i find the "extension notation" syntax to be woefully inadequate. You should be able to infer the action of the extension syntax intuitively, simply from looking at its signature. I find myself continually needing to consult the docs because of the lacking or misleading style of the c

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Rick Johnson
On Jan 25, 11:16 am, Rick Johnson wrote: > {!()...} or (!...) # Non Capturing. Yuck: on second thought, i don't like {!()...}, mainly because non- capturing groups should use the parenthesis delimiters to keep the API consistent. Try this instead --> (!:...) > {NG=identifier...}

Re: Where to put data

2012-01-25 Thread Rick Johnson
On Jan 25, 11:26 am, bvdp wrote: > I've got 2 issues with this: > >    1. I don't know if putting data in the python tree is "legit". >    2. I'd have to do a lot of rewritting. My modules currently use: I would not put anything in the toplevel Python folder. You need to place everything under s

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread Rick Johnson
On Jan 25, 11:26 am, K Richard Pixley wrote: > I disagree on all points. > > "Pretty" means "mostly".  The difference in meaning is significant. > "I'm sure" is definitive.  "I'm pretty sure" leaves room for variation. But "pretty" does not translate well as a quantifier, even though that's exact

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Rick Johnson
On Jan 25, 2:17 pm, Ian Kelly wrote: > On Wed, Jan 25, 2012 at 10:16 AM, Rick Johnson > Did you read the very first sentence of the re module documentation? > "This module provides regular expression matching operations *similar > to those found in Perl*" (my emphas

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Rick Johnson
On Jan 25, 3:41 pm, Duncan Booth wrote: > Rick Johnson wrote: > > On Jan 25, 2:17ÿpm, Ian Kelly wrote: > >> On Wed, Jan 25, 2012 at 10:16 AM, Rick Johnson > > >> Did you read the very first sentence of the re module documentation? > >> "This

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread Rick Johnson
On Jan 25, 3:45 pm, Ian Kelly wrote: > On Wed, Jan 25, 2012 at 1:14 PM, Rick Johnson > > wrote: > > Wow, why i am not surprised! Let's pick one usage at random and try to > > understand it. "I think XYZ is pretty easy." You don't even need > > &quo

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Rick Johnson
On Jan 25, 5:28 pm, Devin Jeanpierre wrote: > Perhaps you should perform some experiments to prove intuitiveness [of your > syntax]? I've posted my thoughts and my initial syntax. You (and everyone else) are free to critic or offer suggestions of your own. Listen, none of these issues that plagu

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Rick Johnson
On Jan 25, 5:36 pm, Ian Kelly wrote: > On Wed, Jan 25, 2012 at 2:19 PM, Rick Johnson > > wrote: > > I disagree here. > > Whist some people may be "die-hard" fans of the un-intuitive perl > > regex syntax, i believe many, if not exponentially MORE p

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread Rick Johnson
On Jan 25, 6:20 pm, Ian Kelly wrote: > On Wed, Jan 25, 2012 at 4:23 PM, Rick Johnson > > """I was frightened that the finals might be difficult this year, > > however to my surprise, they were not.""" > > > In this case the writer does no

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread Rick Johnson
On Jan 25, 6:28 pm, Jugurtha Hadjar wrote: > I am sincerely sorry if my English offends some purists, but I > am making efforts to write correctly, and making mistakes to learn. To > learn this and many other things... Hello Jugurtha, You English does not offend me. i want you to realize that i

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread Rick Johnson
On Jan 25, 8:02 pm, Ian Kelly wrote: > On Wed, Jan 25, 2012 at 6:00 PM, Rick Johnson > wrote: > > On Jan 25, 6:20 pm, Ian Kelly wrote: > >> On Wed, Jan 25, 2012 at 4:23 PM, Rick Johnson > > My writing skills are not in question here, however your reading and > &g

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Rick Johnson
On Jan 25, 8:24 pm, Devin Jeanpierre wrote: > On Wed, Jan 25, 2012 at 7:14 PM, Rick Johnson > > wrote: > > It is germane in the fact that i believe PyParsing, re, and my new > > regex module can co-exist in harmony. > > If all you're going to change is the parse

Re: Weird newbie question

2012-01-26 Thread Rick Johnson
On Jan 26, 4:05 pm, Matty Sarro wrote: > Here's my code: > > from sys import argv > script,filename=argv > txt=open(filename) > print "Here is your file %r:" % filename > print txt.read() > print "I'll also ask you to type it again:" > file_again=raw_input("> ") > txt_again=open(file_again) > pri

Re: Question about name scope

2012-02-01 Thread Rick Johnson
On Feb 1, 11:11 am, Olive wrote: > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. Seeing is believing! >>> dir() ['__builtins__', '__doc__', '__name__', '__package__'] >>> from

Re: changing sys.path

2012-02-01 Thread Rick Johnson
On Feb 1, 10:15 am, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. > > If I take these p

Re: copy on write

2012-02-01 Thread Rick Johnson
On Jan 13, 10:48 am, Devin Jeanpierre wrote: > On Fri, Jan 13, 2012 at 10:13 AM, Grant Edwards > wrote: > > On 2012-01-13, Devin Jeanpierre wrote: > >> On Fri, Jan 13, 2012 at 7:30 AM, Chris Angelico wrote: > There's a bit of a feeling > that code should "do what it looks like" and be sort of

Re: copy on write

2012-02-06 Thread Rick Johnson
On Feb 2, 11:28 pm, Chris Angelico wrote: > On Fri, Feb 3, 2012 at 4:04 PM, Steven D'Aprano > > wrote: > > No matter what Python did, somebody would complain. > > +1 > > This is, I think, the ultimate truth of the matter. People would not complain if they did not care. The only useless complaint

Re: Common LISP-style closures with Python

2012-02-06 Thread Rick Johnson
On Feb 3, 6:27 pm, Antti J Ylikoski wrote: > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python.  It > is done as follows: > [...] do my eyes not see nor my ears not hear? a thread about common Lisp and Xan Le

Re: iterating over list with one mising value

2012-02-07 Thread Rick Johnson
On Feb 7, 8:46 am, Dave Angel wrote: > On 02/07/2012 07:27 AM, Sammy Danso wrote:> Hello experts, > > I am having trouble accessing the content of my list. > > my list content has 2-pair value with the exception of one which has single > > value. here is an example  ['a', 1, 'b', 1, 'c', 3, 'd']

Re: convert perl-script for voltcraft voltmeter to python [newbie]

2012-02-07 Thread Rick Johnson
On Feb 7, 11:44 am, Dennis Lee Bieber wrote: > > [...] > >         Well, since readline() pretty much by definition wants a line-ending > character before returning, it obviously won't work. (Side comment: > readline() isn't even shown as part of the basic Serial class -- it is > in a class FileLi

Re: Python usage numbers

2012-02-11 Thread Rick Johnson
On Feb 11, 8:23 pm, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 12:28:30 +1100, Chris Angelico wrote: > > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow > > wrote: > >> However, in at > >> least one current thread (on python-ideas) and at a variety of times in > >> the past, _some_ people have foun

Re: ANN: Sarge, a library wrapping the subprocess module, has been released.

2012-02-12 Thread Rick Johnson
On Feb 12, 9:35 am, Anh Hai Trinh wrote: > > It's not hard for the user > > I think most users like to use Python, or they'd use Bash. I think people > prefer not another language that is different from both, and having little > benefits. My own opinion of course. Objection! Does the defense RE

Re: ANN: Sarge, a library wrapping the subprocess module, has been released.

2012-02-12 Thread Rick Johnson
On Feb 12, 2:13 pm, Vinay Sajip wrote: > wc(ls("/etc", "-1"), "-l") > > is not as readable as > > call(“ls /etc –1 | wc –l”) And i agree! I remember a case where i was forced to use an idiotic API for creating inputbox dialogs. Something like this: prompts = ['Height', 'Width', 'Color'] values

Re: Python usage numbers

2012-02-12 Thread Rick Johnson
On Feb 12, 12:10 am, Steven D'Aprano wrote: > On Sat, 11 Feb 2012 18:36:52 -0800, Rick Johnson wrote: > >> "I have a file containing text. I can open it in an editor and see it's > >> nearly all ASCII text, except for a few weird and bizarre characters >

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Rick Johnson
On Feb 13, 2:05 am, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 20:48:54 -0800, Rick Johnson wrote: > > Do you think that cost of healthcare is the problem? Do you think the > > cost of healthcare insurance is the problem? NO! The problem is people > > expect entitle

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Rick Johnson
On Feb 13, 10:12 am, Steven D'Aprano wrote: > On Mon, 13 Feb 2012 08:01:59 -0800, Rick Johnson wrote: > > Evolution knows how to handle degenerates. > > And yet here you still are. Embrace the perfection of evolution, and both our needs shall be met! -- http://mail.python.

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Rick Johnson
On Feb 13, 12:38 pm, Ian Kelly wrote: > I hate being suckered in by trolls, but this paragraph demands a response. > > On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson > > wrote: > > You are born with rights. Life, Liberty, and the pursuit of happiness. > > Hea

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-13 Thread Rick Johnson
On Feb 13, 3:46 pm, Michael Torrie wrote: > On 02/13/2012 09:01 AM, Rick Johnson wrote: > > > Look, i hate super rich, arrogant people just as much i hate selfish > > people. > > But wait, Rick.  You are a man of contradictions.  We all are, but you > seem to bluster o

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
; way. I NEVER said we should adopt such a society. That is anarchy. And anarchy will NEVER move us forward as a species. > This is a failure to acknowledge the is/ought problem, and is usually > compounded (Rick is no exception) by the equally mistaken view that there > exist > &qu

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
On Feb 13, 10:41 am, Tim Wintle wrote: > Imagine you go to a doctor and say "I've got the flu, can you give me > antibiotics". > > In a Private healthcare system: > >  * The doctor gets paid for retaining a client. >  * He is incentivised to do what you request. > ... so he gives you the antibiot

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
On Feb 14, 5:31 am, Duncan Booth wrote: > Rick Johnson wrote: > > BS! With free healthcare, those who would have allowed their immune > > system fight off the flu, now take off from work, visit a local > > clinic, and get pumped full of antibiotics so they can creat

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
On Feb 14, 6:44 pm, Chris Angelico wrote: > If you truly believe that only the best should be allowed to survive > and that you are not of the best, then the logical thing to do is to > immediately destroy yourself. Oddly enough, though, I don't see many > eugenics proponents committing mass suic

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Rick Johnson
On Feb 15, 2:56 am, John O'Hagan wrote: > You have just demonstrated that you are the worst kind of racist. Not only > have > you blamed the victim on a truly monstrous scale, you have assigned blame not > to > individuals, but to entire "races". Your tabloid sensationalism is the worst i've s

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread Rick Johnson
On Feb 15, 9:18 am, Mark Lawrence wrote: > As you didn't answer my question from some days back I'll ask it agin. > Please explain why previously healthy people get struck down with Common > Fatigue Syndrome amongst other things. Why do you seek my counsel regarding medical ailments? Do you belie

Re: Is this the right list?

2012-02-16 Thread Rick Johnson
On Feb 15, 4:04 pm, Terry Reedy wrote: > On 2/15/2012 4:51 PM, Alan McKay wrote: > > > Is this the right list? This is neither the "right" or "left" list, however, it may be either the correct or incorrect depending on your question. -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter.Toplevel

2012-02-17 Thread Rick Johnson
On Feb 16, 8:39 pm, y...@zioup.com wrote: > With a tkinter.Toplevel, how can I "disable" the parent windown and all its > widget, in the same fashion as tkinter.messagebox? The answer lies within the tkSimpleDialog source code; which is pure python. Look in the __init__ method of Dialog class. My

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-17 Thread Rick Johnson
On Mon, Feb 13, 2012 at 7:23 PM, Ian Kelly wrote: > On Mon, Feb 13, 2012 at 2:01 PM, Rick Johnson > I make a middle-class income and do not feel that I am anywhere near > being "enslaved" by my income taxes, which amount to less than 10% of > my gross income after deduct

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-17 Thread Rick Johnson
On Feb 13, 7:37 pm, Chris Angelico wrote: > On Tue, Feb 14, 2012 at 11:39 AM, Rick Johnson > > wrote: > > # Py>=3.0 > > py> sum(earner.get_income(2012) for earner in earners2012) / > > len(earners2012) > > average_income > > > Once you exceed that

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-18 Thread Rick Johnson
On Feb 18, 1:28 am, Ian Kelly wrote: > On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson > If I were to [sum my tax burden], it would > probably come to around 30%, which still doesn't bother me, in part > because I know that it comes back to benefit the society I live in, > and

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-18 Thread Rick Johnson
On Feb 18, 10:15 am, Mark Lawrence wrote: > On 18/02/2012 15:02, Rick Johnson wrote: > > > But do you think you'll get a higher return for your investment? Is it > > possible to get a higher return on your investment in this type of > > system? NO! You better off

Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-24 Thread Rick Johnson
On Feb 23, 6:30 pm, Alex Willmer wrote: > [...] > as a standard looping-with-index construct. In Python for loops don't > create a scope, so the loop variables are available afterward. I've > sometimes used this to print or return a record count e.g. > > for i, x in enumerate(seq): >    # do stuff

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Rick Johnson
On Feb 24, 8:39 am, Miki Tebeka wrote: > float('infinity') should be good enough. Yes, that is the answer however the implementation is inconsistent. py> float("inf") inf py> float("infinity") inf py> int("inf") Traceback (most recent call last): File "", line 1, in int("inf") ValueError:

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Rick Johnson
On Feb 24, 8:25 am, Neil Cerutti wrote: > > What Python needs is some constant that can be compared to ANY > > numeric type and that constant will ALWAYS be larger! > > What's the point of that? > > The only time I've naively pined for such a thing is when > misapplying C idioms for finding a min

Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Rick Johnson
On Feb 24, 9:21 am, Mel Wilson wrote: > Easily fixed: > > [...snip code...] Yes i could write my own implementation of INFINITY if i wanted, although i would have returned True and False as apposed to 1 and 0 AND used the identifiers Infinity and Infinitesimal, but i digress :- P. However, INFI

<    1   2   3   4   5   6   7   8   9   10   >