file system iteration

2006-10-09 Thread rick
In Unix, the file system hierarchy is like a tree that has a base or 'root' that exposes objects (files and folders) that can easily be iterated over. \ \ | / / \ \ | / / \ \|/ / \ | / \|/ | | Root So, when I do os.chdir('/') I am at the base of the tree and ca

Re: file system iteration

2006-10-09 Thread rick
Gerrit Holl wrote: > The very least you can try: > > import string > string.ascii_uppercase > > for c in string.ascii_uppercase: > if os.path.isdir('%s:/' % c): > ... > > etc. > But I suppose there should be a better way. Oh yes, I do that. I spelled out the example very explicitly

Re: file system iteration

2006-10-09 Thread rick
Georg Brandl wrote: > Which application needs to walk over ALL files? Normally, you just have a > starting path and walk over everything under it. Searching for a file by name. Scanning for viruses. Etc. There are lots of legitimate reason to walk all paths from a central starting point, no??? -

Re: file system iteration

2006-10-09 Thread rick
Fredrik Lundh wrote: > what's the difference between a "starting path" and a "starting point" ? None. What starting path or point would you suggest under Windows? Is there something obvious that I'm missing? I see no starting point under windows as my initial question clearly stated. -- http://

Re: file system iteration

2006-10-09 Thread rick
Tim Golden wrote: > [Rick] > | Searching for a file by name. Scanning for viruses. Etc. > | There are lots > | of legitimate reason to walk all paths from a central > | starting point, no??? > > Well, to get you started, I think this is the kind > of thing you'l

Re: file system iteration

2006-10-09 Thread rick
Thanks Tim and Rob... this works really well! -- http://mail.python.org/mailman/listinfo/python-list

block devices

2006-10-17 Thread rick
What's the best way to read a byte of data directly from a block device (a scsi hard drive) on Linux using Python? -- http://mail.python.org/mailman/listinfo/python-list

Re: block devices

2006-10-17 Thread rick
Diez B. Roggisch wrote: > Reading it? Using read? > > f = open("/dev/foo") > f.read(1) > > Diez Wow, I didn't realize it was that simple. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

invert or reverse a string... warning this is a rant

2006-10-19 Thread rick
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x[::-1] Ruby: x = 'a_string' # Reverse the string print x.reverse The Ruby approach makes sense to me as a human being. The Python approach is not easy for me (as a human being) to rem

Re: invert or reverse a string... warning this is a rant

2006-10-19 Thread rick
Demel, Jeff wrote: > Ok, let me re-phrase: > > ...[snip]... > I've been programming professionally for over 10 years, and have never > once needed to reverse a string *or detect a palindrome*. Maybe it's a > lack of imagination on my part, but I can't think of a single instance > this might be ne

Re: invert or reverse a string... warning this is a rant

2006-10-19 Thread rick
Tim Chase wrote: > Well, there you go! Apparently, your wet paper bag has no "detect a > palendrome" exit. While you're installing such an egress to your soggy > dead-tree satchel, you could also provide similar "write a binary Glad you guys are enjoying this. We're getting off-topic and I t

Re: invert or reverse a string... warning this is a rant

2006-10-20 Thread rick
Fredrik Lundh wrote: > "Brad" <[EMAIL PROTECTED]> wrote: > >> Do you have children? How would your child feel if he brought you >> something he had made and you then told him it was awful in *sooo* many >> ways. > > If you're arguing that everything a child does and says should be rewarded... I

Re: introspection

2006-09-01 Thread rick
Fredrik Lundh wrote: > brad tilley wrote: > >> How do I import a module and then ask it to show me its methods or >> other aspects about itself during execution? I'd like to do something >> such as this: >> >> import win32api > > dir(win32api) > help(win32api) > > and also > > import inspect

optparse

2006-09-26 Thread rick
Consider the following piece of code: parser = optparse.OptionParser(usage="usage: %prog [options]", add_help_option=False) parser.add_option("-d", type="string", action="store", dest="DELIM", default="|", help="single character delimiter in quotes (default: |)") (options, args) = parser.parse

Re: optparse

2006-09-27 Thread rick
OK, using that convention, how would I create help for , , etc. Thanks. On 9/27/2006 12:44 AM, Ben Finney wrote: > rick <[EMAIL PROTECTED]> writes: > >> usage: DelimTOFixedWidth.py [options] > > That's not the command-line argument style that op

turbogears app deployment

2006-12-24 Thread rick
I am trying to host a TuboGears app using Apache and mod_python on a machine running Windows XP SP2 Professional. Version info: apache_2.2.3-win32-x86-no_ssl.msi, python-2.4.4.msi, mod_python-3.2.10.win32-py2.4-apache2.2.exe, mpcp-1.5.tar.gz, turbogears-1.0b2-py2.4

Simple server using asyncore/asynchat

2008-01-01 Thread Rick
nel, addr = self.accept() ConnChannel(channel) connTube = ConnTube(host, port) asyncore.loop() Thanks everyone! Rick -- http://mail.python.org/mailman/listinfo/python-list

Re: Profiling gives very different predictions of best algorithm

2009-05-01 Thread Rick
#logging.basicConfig(format="%(message)s",level=logging.DEBUG) suite = unittest.TestLoader().loadTestsFromTestCase(UnitTests) unittest.TextTestRunner(verbosity=verbosity).run(suite) # Running without verbosity is equivalent to replacing the above # two lines with the following: #un

Re: Profiling gives very different predictions of best algorithm

2009-05-02 Thread Rick
On May 1, 7:38 pm, Terry Reedy wrote: > I presume in your overall time text, you ran the two versions of the > algorith 'naked'.  But, for some reason, you are profiling them embedded > inside a test suite and runner.  It does not seem that this should > affect relative timing, but I have seen so

Re: Profiling gives very different predictions of best algorithm

2009-05-05 Thread Rick
On May 2, 9:10 am, Rick wrote: > I was posting to the list mostly because I would like to know whether > I can do something different when I profile my code so that it give > results that correspond more closely to those that the nonprofiling > results give. A good comment that wa

using time.gov to get the current time

2009-12-19 Thread Rick
Is there any way to get the current time from time.gov using urllib2 or something similar? Does anyone have any examples of doing this? Thanks! Rick King Southfield MI -- http://mail.python.org/mailman/listinfo/python-list

Sending ^C

2009-12-21 Thread Rick
op. The problem is, I don't know how to deal with it when log file rotates and change name. I need then to break running 'tail -f _some_file_' and excecute 'tail -f _other_file'. Can you give me hints how to do this? Regards Rick -- http://mail.python.org/mailman/listinfo/python-list

Display file names in Tkinter Listbox

2010-05-19 Thread Rick
Hello, My first attenpt at a simple python Tkinter application. I wanted to see how to load file names into a listbox from a menu. This is what I got until the part of displaying the file names in a listbox, which I could not figfure out how to do? Any help would be appreciated. Trying to do thi

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
mes to objects > (which is what python does) and variables (which is what languages like > C have). It's very clear Rick does not have an understanding of this > either. Just because someone does not "prefer" this or that aspect of Python, does not mean they don't understa

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
s not my law, this is the law of the universe in which we live. """ But Rick you're heartless. What of the children? If we legalize drugs then kids will be addicts, some will even die!""" How many are dying now in the streets from gangland shootouts? How m

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
tion". Then, when you assigned the x,y,z values to "self.position" you thought you where assigning them to the "class level variable" named "position", HaHa, but then again you had NO idea that "class level variables" and "instance level variables&

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 understan

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
ar a knocking sound whilst driving but the sound is absent whist idling, you can deduce that the problem most likely exists in the drive-train. From there you'd need to focus in at an even smaller level of detail -- but you could not come to that conclusion if you did not possess (at mi

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
use tkinter, this would give you a start. > The code is in Lib/idlelib/aboutDialog.py. I do not know > how to make the 'dialog' be a main window instead, nor how > to replace a main window with a new set of widgets (as > opposed to opening a new window), but I presume its

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

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

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 Pyth

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

  1   2   3   4   5   6   7   8   9   10   >