Re: is there any principle when writing python function

2011-08-27 Thread harrismh777
the python interpreter import this: import this ... study carefully. If you're not Dutch, don't worry if some of it confuses you. ... apply liberally to your function praxis. kind regards, -- m harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/g

Re: pythonw.exe

2011-08-14 Thread harrismh777
had her open a terminal for some magic... and it took her exactly 1.03 seconds to say, "Oh, the iMac has DOS installed in the utilities folder!" :-O ... blondes... :-} (she tries hard, and actually has been learning, so, we keep trying...) -- m harris FSF ...free as i

Re: Ten rules to becoming a Python community member.

2011-08-14 Thread harrismh777
is FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.python.org/mailman/listinfo/python-list

range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread harrismh777
ded to work in C for most of my integer stuff... like perfects. But now that it sparked my interest, I'm wondering if there might be some focus placed on range() performance in Python3 for the future, PEP? kind regards, -- m harris FSF ...free as in freedom/ http://webpages.charter.net/

Re: Spam

2011-08-01 Thread harrismh777
se I am interested in the same issue as your OP complaint. But, I am absolutely sure that others will view your note, and mine, as spam... see the problem? -- m harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: What's in a name?

2011-07-29 Thread harrismh777
/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: What is xrange?

2011-07-29 Thread harrismh777
m harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: os.path needs immediate attention!

2011-07-29 Thread harrismh777
ysical drives "C:\"). The forward slash actually makes some philosophical sense, and of course is more aesthetically pleasing. So, let's put our behinds in the past and slash forward ! -- m harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinu

Re: PyWart: PEP8: a seething cauldron of inconsistencies.

2011-07-28 Thread harrismh777
ut of our code... NO I say, NO ! ... just saying, probably don't really mean it. :) -- m harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming Python for Absolute Beginners

2011-07-27 Thread harrismh777
Billy Mays wrote: No one cares and don't spam the list. ... ouch, now I feel really bad... has someone not had their coffee this morning? kind regards, -- m harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.pytho

Programming Python for Absolute Beginners

2011-07-27 Thread harrismh777
- m harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: PEP8: A cauldron of inconsistencies.

2011-07-27 Thread harrismh777
harris FSF ...free as in freedom/ http://webpages.charter.net/harrismh777/gnulinux/gnulinux.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: Only Bytecode, No .py Files

2011-07-27 Thread harrismh777
Christian Heimes wrote: Now the test.py has the same mtime as test.pyc and Python won't recompile the .pyc file from the .py file as long as the magic header (168686339) is correct. ~very cool. -- http://mail.python.org/mailman/listinfo/python-list

Re: Only Bytecode, No .py Files

2011-07-26 Thread harrismh777
Christian Heimes wrote: The first four bytes of a pyc file contain the magic header. It must match the magic of the current Python version. The next four bytes contain the pyc_mtime. It must match the mtime of the corresponding .py files as returned by fstat().st_mtime. If the magic doesn't match

Re: Python 2.6 OR 3.2

2011-06-09 Thread harrismh777
Andrew Berg wrote: AFAICT, there are three reasons to learn Python 2: ... there is a fourth reason. The linux distro you are using currently was customized with python 2.x I ran into this problem this week in fact... on my HP g6 ubuntu notebook running 10.04 lucid. It ships with the 2.6.5

Re: Python 2.6 OR 3.2

2011-06-09 Thread harrismh777
Terry Reedy wrote: A couple of years ago, users were people who were already programming with 2.x. That is changing now. ... big time ! :) -- http://mail.python.org/mailman/listinfo/python-list

test_popen

2011-06-08 Thread harrismh777
Looks like my 2.7 test_popen failure is an open issue7671... since Jan 2010. Looks like it really does function ok. At any rate, I was able to test Popen myself today, and it ran fine. I needed to write a script that will disable the touch pad on this HP g series, because there is no way to do

test_popen

2011-06-08 Thread harrismh777
hi folks, I've installed 3.2 and 2.7.1 on a second development notebook from sources. 3.2 was smooth, and 2.7.1 make test failed test_popen. All other tests either passed or were skipped for valid reasons. I do not remember 3.2 failing popen... so I'm wondering about 2.7? I'm assuming (witho

Re: Dynamic Zero Padding.

2011-06-07 Thread harrismh777
Ethan Furman wrote: --> print("Testing %0*i" % (width, 1)) The '*' acts as a place holder for the width argument. very nice... -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic Zero Padding.

2011-06-07 Thread harrismh777
Friedrich Clausen wrote: I would be much obliged if someone can give me some tips on how to achieve a variably pad a number. b='04' a="testing %"+b+"i" print(a % 1) testing 0001 kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating string for FDQN

2011-06-06 Thread harrismh777
Eric wrote: Is there a library or regex that can determine if a string is a fqdn (fully qualified domain name)? I'm writing a script that needs to add a defined domain to the end of a hostname if it isn't already a fqdn and doesn't contain the defined domain. You might try the os module and the

Re: Lambda question

2011-06-06 Thread harrismh777
Steven D'Aprano wrote: For any non-trivial function, I usually start by writing the documentation (a docstring and doctests) first. How else do you know what the function is supposed to do if you don't have it documented? Yes. In my early years I was no different than any other hacker in terms

Re: Something is rotten in Denmark...

2011-06-03 Thread harrismh777
Alain Ketterlin wrote: The reason why we have the kind of lambdas we have in python (and scheme, and javascript, etc.) is just that it is way easier to implement. That's all I've said. And people have gotten used to it, without ever realizing they are using something completely different from wha

Re: Something is rotten in Denmark...

2011-06-02 Thread harrismh777
Terry Reedy wrote: Oh the irony of this proposal. You scolded us for breaking code with 2 to 3 changes, and here you propose a change more radical than anything done in Python 3, and certain to break code, introduce bugs, complicate the language, and reduce its functionality. Most of Guido's desi

Re: Something is rotten in Denmark...

2011-06-02 Thread harrismh777
Steven D'Aprano wrote: What do you expect this code to do? a = 42 funcs = [(lambda x: x+a) for i in range(10)] funcs[0](1) I do see your point with this... truly... but it did get me to think about what I *do* expect... and that is that 'a' (for the lambda) will be whatever 'a' is (now) a

Re: Something is rotten in Denmark...

2011-06-02 Thread harrismh777
Steven D'Aprano wrote: funcs = [(lambda x, i=j: x+i) for j in range(10)] Now the reader is no longer distracted by the "i=i" ugliness. That's a good idea, in fact, change made! The problem with Do What I Mean is that it so rarely Does What You Mean. At best it Does What Some Other Guy Ima

Re: Something is rotten in Denmark...

2011-06-01 Thread harrismh777
harrismh777 wrote: Allow me to clarify... I'm not speaking about whether the lambda is short-hand for def, ... that part of the docs I understand well!... no problems there. Allow me to clarify a little further... the docs are misleading in that they state that the lambda can be code

Re: Comparison operators in Python

2011-06-01 Thread harrismh777
Ian Kelly wrote: integer. However comparison between a string and an integer seems to > be permitted. Is there any rationale behind this ? It allows things like sorting of heterogeneous lists. It's generally viewed as a wart, though, and it was fixed in Python 3: Just another example (ex

Re: Something is rotten in Denmark...

2011-06-01 Thread harrismh777
Terry Reedy wrote: function (I know, not so) is built-in. There is little to nothing indicating in the docs that this is not so On the contrary, the docs very explicitly say that a lambda expression is equivalent to a def statement. Allow me to clarify... I'm not speaking about whether the la

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
Terry Reedy wrote: This is early-binding versus late-binding. Python is a late-binding language. ok ... Are you asking about changing all function compilation or only when functions are defined with lambda expressions? At least lambda expressions, but (see below) any other built-in

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
harrismh777 wrote: PS Ian calls the second construct "working by mistake..." oops, actually he called it, "working by accident... " -- http://mail.python.org/mailman/listinfo/python-list

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
Martin Manns wrote: After being confused I figured out it is a 3.x example: Actually, it is a compatibility example between 2.x and 3.x, compare below for different behavior from two seemingly identical compatible constructs, one from 3.2, and the other from 2.6.4: Python 3.2 (r32:88445,

Re: Something is rotten in Denmark...

2011-05-31 Thread harrismh777
Terry Reedy wrote: You have been hypnotizeed by lambda. (lambda n: i+n) is a *constant expression*, so you get 10 'equal' functions. 'hypnotized' indeed! ... ok, so let me see if I get this... the lambda defers lookup|bind of its references until such time as the lambda is 'called' and not

Something is rotten in Denmark...

2011-05-30 Thread harrismh777
fs=[] fs = [(lambda n: i + n) for i in range(10)] [fs[i](1) for i in range(10)] [10, 10, 10, 10, 10, 10, 10, 10, 10, 10] <=== not good ( that was a big surprise! . . . ) ( let's try it another way . . . ) fs =[] def g(i): return (lambda n: i + n) fs = [g(i) for i in range(10)]

Re: Beginner needs advice

2011-05-30 Thread harrismh777
Chris Angelico wrote: Hmm. If you did write those two scripting languages, we would finally be able to type "man woman" to get docs on how to talk to women... Which just wouldn't be fair, because her use of man man would lead her no closer to understanding how men speak... (er, think, um.

Re: python in school notebooks/laptops

2011-05-30 Thread harrismh777
Chris Angelico wrote: Is it a waste of time to try to get school admins to put python in > their school laptops? No, absolutely no... Python advocacy is necessary in this venue ! Possibly the best way to encourage Python deployment would be to require it to run some internal scr

Re: Beginner needs advice

2011-05-30 Thread harrismh777
Jason Tackaberry wrote: At least, his arguments make more sense if I read him as arguing from the "not completely compatible" position. It's possible he is intentionally equivocating for dramatic effect. yes -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner needs advice

2011-05-30 Thread harrismh777
Ian Kelly wrote: You have just misrepresented Steven's argument, which is rather ironic considering that you're the one who brought up straw-men. Steven did not use one code snippet to demonstrate that Python 2 and Python 3 are fully compatible. The code snippet merely demonstrated that Python

Re: Beginner needs advice

2011-05-30 Thread harrismh777
Steven D'Aprano wrote: LOL I invite you to consider the difference between a legally dead person moments before being resuscitated by a paramedic, ( ... alive ) versus a chicken that has just been beheaded and is still running around the yard, ( ... alive ) versus a million-

Re: Beginner needs advice

2011-05-28 Thread harrismh777
Steven D'Aprano wrote: A straw man is not when somebody points out holes in your argument, or unwanted implications that you didn't realise were there. It is when somebody makes claims on your behalf that you did not make to discredit you, not because you don't understand the implications of your

Re: Beginner needs advice

2011-05-28 Thread harrismh777
Chris Angelico wrote: Both versions of Python are the same language, because they "think" the same way; I appreciate your thought. And there is an obvious continuity in philosophy between 2.x and 3.x; in fact even a cursory study of the history of python demonstrates a concerted effort t

Re: Beginner needs advice

2011-05-28 Thread harrismh777
Ethan Furman wrote: Um -- how can you have on the one hand "completely not compatible" and on the other "code that can cross-execute on either version"? Great question ! .. .it has to do with education. ... if you learn 2.x (only) and attempt to program on the 3.x platform, (without helps, ed

Re: Beginner needs advice

2011-05-27 Thread harrismh777
Chris Angelico wrote: To say that "most" 2.x code is incompatible with 3.x is to deny the 2to3 utility, Oh, yes absolutely. Please don't misunderstand... anyone... I'm not saying that code cannot be migrated... migration can usually occur between incompatible releases and and between langu

Re: Beginner needs advice

2011-05-27 Thread harrismh777
Steven D'Aprano wrote: Would you care to revise your claims? No. You have erected a straw-man... once again. Most 2.x code *will not* run correctly in 3.x/ Most of the best improvements and enhancements of 3.x will not back-port to below 2.7, and almost none of them will back-port before

Re: Python's super() considered super!

2011-05-27 Thread harrismh777
Steven D'Aprano wrote: Python causes trouble by letting the users get at the internals, but > things like this make it worthwhile. Only if by "worthwhile" you mean "buggy as hell". I *don't* believe this... the king of metaphors and bogus analogies has come up with 'buggy as hell' !!?

Re: Beginner needs advice

2011-05-27 Thread harrismh777
Colin J. Williams wrote: It would be safer to stick with Python 2.7 initially and then consider the transition to 3.2 later. I must disagree with Colin's statement. If you are a complete beginner with Python... then there is going to a learning curve for you... and that curve should be 3.2---

Re: Abandoning Python

2011-05-27 Thread harrismh777
Paul Rubin wrote: Haskell probably has the most vibrant development community at the moment but its learning curve is quite steep, and it has various shortcomings some of which are being worked on but others of which may be insurmountable. Yes. You might want to lurk on: http://lambda-the-u

Re: English Idiom in Unix: Directory Recursively

2011-05-27 Thread harrismh777
Steven D'Aprano wrote: You really do need to know whether the car you drive uses leaded or unleaded. Actually, you need to know whether your car can burn 85 gas (at about 60 cents /gallon cheaper... and, whether 85 gas will have enough energy to move the car without using 35% more fuel...

Re: I installed Python 3 on Fedora 14 By Downloading python3.2 bziped source tarball and install it according to the README, Now How shall I uninstalled python 3.2?

2011-05-24 Thread harrismh777
Varuna Seneviratna wrote: Now How shall I uninstalled python 3.2? What --prefix did you use? default? -- http://mail.python.org/mailman/listinfo/python-list

Re: I installed Python 3 on Fedora 14 By Downloading python3.2 bziped source tarball and install it according to the README, Now How shall I uninstalled python 3.2?

2011-05-24 Thread harrismh777
Varuna Seneviratna wrote: Now How shall I uninstalled python 3.2? Now, how shall I remove Python 3.2 ? ... very carefully. It might be nice if there were a label in the Makefile so this would work: sudo make removeall ... but alas,why do you want to un-install Python3.2 ? -

Re: obviscating python code for distribution

2011-05-20 Thread harrismh777
Steven D'Aprano wrote: ... as it goes, De Carte leads his horse into town;-)and having >> hitched it to the rail outside the local saloon and sauntering up to >> the bar, the tender asks, "Would you be hav'in an ale sir?" >> >> ... De Carte replies, "I think not..." ... and then disap

Re: Python 2.6.7 release candidate 2 now available

2011-05-20 Thread harrismh777
Barry Warsaw wrote: We will support Python 2.6 in security-fix only mode until October 2013. Where can I read about the criteria for security-fix only? Who decides whether the security fix is critical? thanks, kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list

Re: obviscating python code for distribution

2011-05-20 Thread harrismh777
Steven D'Aprano wrote: Nonsense. How do you (generic "you", not any specific person) know that you are not an idiot? lol Sum, ergo Idiot cogitat. Reminds me of a philosophical story I heard one time from my religion professor... ... as it goes, De Carte leads his horse into town ;-)

Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread harrismh777
Chris Angelico wrote: I believe the 'bc' command-line calculator can do a-p non-i, and I know REXX can Yes, bc is wonderful in this regard. Actually, bc does this sort of thing in 'circles' around Python. This is one of Python's weaknesses for some problem solving... no arbitrary precision.

Re: obviscating python code for distribution

2011-05-19 Thread harrismh777
geremy condra wrote: Anonymous, "Maximum Linux Security: A Hacker's Guide to Protecting > Your Linux Server and Workstation," Indianapolis: > Sams Publishing, 2000. This is a good volume, but very dated. I'd probably pass on it. Actually, although dated, its still a very go

Re: obviscating python code for distribution

2011-05-18 Thread harrismh777
Littlefield, Tyler wrote: I know about rate limiting and dos attacks, as well as some others, but I think there's a lot more that I don't know--can someone kind of aim me in the right direction for some of this? I want to be able to take techniques, break my server and then fix it so that can't b

Re: [ann] pyjamas 0.8alpha1 release

2011-05-17 Thread harrismh777
Terry Reedy wrote: No, because I think you are exaggerating. That said, I think core Python is pretty close to 'complete' and I would not mind further syntax freezes like the one for 3.2. I am exaggerating only to the extent that someone can imagine folks becoming just annoyed with PEP progr

Re: [ann] pyjamas 0.8alpha1 release

2011-05-17 Thread harrismh777
Terry Reedy wrote: Like it or not, Python 3 is the future of Python. It is the Python that many Python newcomers learn first, and perhaps ever will. Yes, no doubt, and I'm genuine about that... ... but there is something else to consider, as I'm sure you are aware. At some point Python is goi

Re: Convert AWK regex to Python

2011-05-17 Thread harrismh777
J wrote: Hello, Hello, J, This is totally off-topic, but I was wondering why you are posting with double messages (triple) all over the place? Your reply-to is set to comp.lang.pyt...@googlegroups.com, and you cc to python-list@python.org... and you're stuff is showing up in newsgr

Re: problem with GKT module?

2011-05-16 Thread harrismh777
alister ware wrote: def callback(self,widget,data=None): print widget #gives reference to radio button ok print widget.name #widget name on windoze, None on linux Well, you're obviously using Python 2.x ... ... have you

Re: obviscating python code for distribution

2011-05-16 Thread harrismh777
Steven D'Aprano wrote: To put it in a nutshell, you can't trust*anything*. See the classic paper by Ken Thompson, "Reflections on Trusting Trust": This is true, but there's another way to put it pro-active--- ... expect the client to be untrustworthy. In other words, write the server code

Re: TypeError: __init__() takes exactly 1 positional argument (2 given)

2011-05-15 Thread harrismh777
Gnarlodious wrote: class GnomonBase(object): def __init__(self, bench): <=== (1) (2) # do stuff This only answers the surface question I have not taken any time to see or understand what (if anything) you are doing which might make any sense... only that the messa

Re: obviscating python code for distribution

2011-05-15 Thread harrismh777
Littlefield, Tyler wrote: I'm putting lots of work into this. I would rather not have some script kiddy dig through it, yank out chunks and do whatever he wants. I just want to distribute the program as-is, not distribute it and leave it open to being hacked. Protection via obfuscation is inval

Re: checking if a list is empty

2011-05-15 Thread harrismh777
Steven D'Aprano wrote: I'm afraid I don't understand what you mean. Can you explain please, http://www.informatik.uni-bremen.de/agbkb/lehre/ws06-07/casl/slides/Datatypes-II.pdf Geeze, I wonder if software is mathematics kind regards, m harris -- http://mail.python.org/mailman/li

Re: turn monitor off and on

2011-05-15 Thread harrismh777
Gregory Ewing wrote: I'm not so sure about that. If the monitor is an LCD and isn't doing anything to reduce its own power usage, then the backlight is still running and using just as much power, whether the screen is black or not. Depends on dpmi. Some monitors turn off the backlight, and som

Re: problem with GKT module?

2011-05-15 Thread harrismh777
Alister Ware wrote: I have a simple call back defined for a radio button widget when I use widget.name in linux I get a value of None, windows returns the widget name as I would expect. First, not familiar with your issue... ... but might be able to help you think through it... I am assum

Re: checking if a list is empty

2011-05-15 Thread harrismh777
rusi wrote: But on further examination (with Leibniz law above) Dijkstra's 2<3 = True will work consistently in all contexts but [1,2,3] = True will work sometimes and fail sometimes. It would have to be written 2<3 == True; [1,2,3] == True; otherwise, ... +1 QOTW -- http://mail.python.org/

Re: turn monitor off and on

2011-05-14 Thread harrismh777
Terry Reedy wrote: The computer cannot turn off the monitor. ... this was my point ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: turn monitor off and on

2011-05-14 Thread harrismh777
Steven D'Aprano wrote: I've never tried turning my monitor on/off without using my finger... You've never had your PC turn your monitor off after X minutes of inactivity? I know you're being funny, but actually, no-- I don't. That's a back-in-the-day thing... all of my monitors (and I on

Re: unicode by default

2011-05-14 Thread harrismh777
Terry Reedy wrote: Is there a unix linux package that can be installed that drops at least 'one' default standard font that will be able to render all or 'most' (whatever I mean by that) code points in unicode? Is this a Python issue at all? Easy, practical use of unicode is still a work in pro

Re: turn monitor off and on

2011-05-14 Thread harrismh777
harrismh777 wrote: def turnOnMonitor(): SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) Wonder what the equivalent of this is in Linux... ? -- http://mail.python.org/mailman/listinfo/python-list

Re: turn monitor off and on

2011-05-14 Thread harrismh777
harrismh777 wrote: def turnOnMonitor(): SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) I've never tried turning my monitor on/off without using my finger... gonna have to play with this... wouldn't that

Re: turn monitor off and on

2011-05-14 Thread harrismh777
Astan Chee wrote: import time import win32gui import win32con import win32api def turnOffMonitor(): SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2) def turnOnMonitor(): SC_MONITORPOWER = 0xF170 win32gui.SendMessage(w

Re: checking if a list is empty

2011-05-13 Thread harrismh777
Ian Kelly wrote: >> Well, at least Haskell is probably better as an introductory language >> than Lisp or Scheme. But what schools actually do this? http://www.inf.ed.ac.uk/teaching/courses/inf1/fp/ http://www.cs.ou.edu/~rlpage/fpclassSpring97/ There are lots of these... the two above

Re: checking if a list is empty

2011-05-13 Thread harrismh777
Ian Kelly wrote: Well, at least Haskell is probably better as an introductory language than Lisp or Scheme. But what schools actually do this? http://www.cs.kent.ac.uk/teaching/resources/haskell/HugsResources.html http://research.cs.queensu.ca/home/cisc260/2010w/haskell.html These are just

Re: unicode by default

2011-05-13 Thread harrismh777
jmfauth wrote: to worry about encodings are when you're encoding unicode characters > to byte strings, or decoding bytes to unicode characters A small but important correction/clarification: In Unicode, "unicode" does not encode a*character*. It encodes a*code point*, a number, the integer as

Re: checking if a list is empty

2011-05-13 Thread harrismh777
ru...@yahoo.com wrote: http://www.codinghorror.com/blog/2006/07/separating-programming-sheep-from-non-programming-goats.html A later paper by the same authors... (http://www.eis.mdx.ac.uk/research/PhDArea/saeed/paper3.pdf) These papers are fascinating reading, not only for philosophy sake i

Re: unicode by default

2011-05-11 Thread harrismh777
Terry Reedy wrote: It does not matter how Python stored the unicode internally. Does this help? Your intent is signalled by how you open the file. Very much, actually, thanks. I was missing the 'internal' piece, and did not realize that if I didn't specify the encoding on the open that pytho

Re: unicode by default

2011-05-11 Thread harrismh777
Ben Finney wrote: I'd phrase that as: * Text is a sequence of characters. Most inputs to the program, including files, sockets, etc., contain a sequence of bytes. * Always know whether you're dealing with text or with bytes. No object can be both. * In Python 2, ‘str’ is the type f

Re: unicode by default

2011-05-11 Thread harrismh777
John Machin wrote: On Thu, May 12, 2011 2:14 pm, Benjamin Kaplan wrote: If the file you're writing to doesn't specify an encoding, Python will default to locale.getdefaultencoding(), No such attribute. Perhaps you mean locale.getpreferredencoding() >>> import locale >>> locale.getpreferred

Re: checking if a list is empty

2011-05-11 Thread harrismh777
alex23 wrote: through intuitive language skills. Why not? Because the vast majority of them don't seem to want to be bothered? That could very well be... but I have a hope for them. I honestly think its not because they don't want to be bothered, rather they just think its too far past the

Re: unicode by default

2011-05-11 Thread harrismh777
Steven D'Aprano wrote: You need to understand the difference between characters and bytes. http://www.joelonsoftware.com/articles/Unicode.html is also a good resource. Thanks for being patient guys, here's what I've done: astr="pound sign" asym=" \u00A3" afile=open("myfile", mode='w') afil

Re: unicode by default

2011-05-11 Thread harrismh777
John Machin wrote: (1) You cannot work without using bytes sequences. Files are byte sequences. Web communication is in bytes. You need to (know / assume / be able to extract / guess) the input encoding. You need to encode your output using an encoding that is expected by the consumer (or use an

Re: checking if a list is empty

2011-05-11 Thread harrismh777
harrismh777 wrote: Lists by themselves, empty or not, cannot have a 'truth' in an of themselves. ... forgot., Based on Ian's comment a couple of days ago... if alist: ... is actually : if bool(alist): I think this is more than just semantics or sill

Re: unicode by default

2011-05-11 Thread harrismh777
Ian Kelly wrote: Ian, Benjamin, thanks much. The `unicode' class was renamed to `str', and a stripped-down version of the 2.X `str' class was renamed to `bytes'. ... thank you, this is very helpful. > If I do not specify any code points above ascii 0xFF does any of this > matter

Re: checking if a list is empty

2011-05-11 Thread harrismh777
Steven D'Aprano wrote: modelled. Lists do not have truth values in the application domain Yes they do. Empty lists are nothing, ergo false, and non-empty lists are something, ergo true. No they don't. Empty lists are empty lists... which just happen to become False when type cast bool(lis

unicode by default

2011-05-11 Thread harrismh777
hi folks, I am puzzled by unicode generally, and within the context of python specifically. For one thing, what do we mean that unicode is used in python 3.x by default. (I know what default means, I mean, what changed?) I think part of my problem is that I'm spoiled (American, ascii he

Re: checking if a list is empty

2011-05-11 Thread harrismh777
D'Arcy J.M. Cain wrote: Non-programmers should be able to program? Should non-doctors be able to doctor? Should cars be built so that anyone can intuitively fix them without a mechanic? Non-programmers should not be expected to program in 'C' nor in lisp... ... but non-programmers were

Re: checking if a list is empty

2011-05-11 Thread harrismh777
Hans Georg Schaathun wrote: Code is quite often published to document algorithms, methods and formulæ for the purpose of scientific research. Since there is no universal language which suits everything and everyone, this is exactly what happens. One has to have the rudimentary knowledge to read

Re: checking if a list is empty

2011-05-09 Thread harrismh777
Steven D'Aprano wrote: If I were talking to a programming n00b, I would have been more careful, but you've made numerous references to your long, long programming experience and I thought you would be able to draw the obvious connection without me insulting you by stating the obvious. Pedantics

Re: checking if a list is empty

2011-05-09 Thread harrismh777
Steven D'Aprano wrote: Python uses a boolean algebra where there are many ways of spelling the true and false values. The "not" operator returns the canonical bool values: Take note of the distinction between lower-case true/false, which are adjectives, and True/False,

Re: checking if a list is empty

2011-05-09 Thread harrismh777
Ian Kelly wrote: "bool(list)" describes whether the list contains something. "Not" being a logical operator, it stands to reason that "not list" should mean the same thing as "not bool(list)". Ian, James, Agreed, and thank you. This *is* the explanation I was trying to prompt D'Aprano fo

Re: What other languages use the same data model as Python?

2011-05-09 Thread harrismh777
Gregory Ewing wrote: +-+ +---+ | | a | --+>| | +---+ | | +-+ ^ +---+

Re: checking if a list is empty

2011-05-08 Thread harrismh777
Steven D'Aprano wrote: Python is the new kid on the block, Nonsense. Python is 20 years old (1991), which makes it older than: Java, PHP, Ruby (1995) Javascript (1996) C# (2000) Visual Basic .Net (2001) Python is the new kid on the block. ... not chronologically perhaps, but measured

Re: checking if a list is empty

2011-05-08 Thread harrismh777
Steven D'Aprano wrote: which is irony extreme since 'not' is typically considered a logical > operator. Because "not" is typically used as a logical operator. In English, it negates a word or statement: "the cat is not on the mat" --> "the cat is on the mat" is false. Your pedantic bogu

Re: What other languages use the same data model as Python?

2011-05-07 Thread harrismh777
Steven D'Aprano wrote: Nobody talking about (say) Solitaire on a computer would say: "Blat the pixels in the rect A,B,C,D to the rect E,F,G,H. That will free up the Ace of Spades and allow you to memcopy the records in the far right column of the tableau into the foundation." but when it come

Re: checking if a list is empty

2011-05-07 Thread harrismh777
Steven D'Aprano wrote: ... if not li says nothing about what li is supposed to 'be' Yes, and? Neither does: isempty(li) # li could be anything that polymorphic isempty can deal with li.isempty() # li could be anything with a "isempty" method len(li) == 0 # li could be anything with a length

Re: checking if a list is empty

2011-05-06 Thread harrismh777
Terry Reedy wrote: (2) if not li: This is fine. This is the intended way. Anything in addition is extra noise and wasted calculation. In other words, let Python do the boilerplate work for you. I agree, but I don't like it. ... if not li says nothing about what li is supposed to 'be' a

Re: string formatting

2011-05-06 Thread harrismh777
harrismh777 wrote:OP wrote: (1) "the %s is %s" % ('sky', 'blue') (2) "the {0} is {1}".format('sky', 'blue') (3) "the {} is {}".format('sky', 'blue') On the other hand, consider this 3.x

Re: What other languages use the same data model as Python?

2011-05-06 Thread harrismh777
Chris Torek wrote: with the Python-named-Monty, we have "rigidly defined areas of >doubt and uncertainty". These exist for good reasons: to allow >different implementations. Oops, attribution error: this comes from Douglas Adams rather than Monty Python. Well, its certainly Monte-esq I li

  1   2   3   >