Re: Message passing syntax for objects | OOPv2
On Thu, 9 May 2013 11:33:45 -0600 Ian Kelly wrote: > about Turing machines and lambda calculus that you've injected into > the conversation though just reminds me of the "Einstein was wrong" > cranks. But Einstein *was* wrong. http://www.xkcd.com/1206/ -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode humor
On Wed, 15 May 2013 15:19:00 +0200 (CEST) Jean-Michel Pichavant wrote: > > British humour includes "double entendre", which is not > > French-compliant. > > I didn't get that one. Which possibly confirm MRAB's statement. It's sort of like when Bush said "The French don't even have a word for entrepreneur." -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: .mat files processing in Python
On Mon, 27 May 2013 13:43:36 -0700 (PDT) Romila Anamaria wrote: > I am beginner > in Python programming Are you a beginner in using the Internet too? You just sent a 2.69MB message to a mailing list. You shouldn't send huge files like that in email at all but especially not to a mailing list that gets archived. Please don't ever do that again. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll... (was: Re: A few questiosn about encoding)
On Fri, 14 Jun 2013 11:06:55 +0200 Heiko Wundram wrote: > Come on now, this is _so_ obviously trolling, it's not even remotely > funny anymore. Why doesn't killfiling work with the mailing list > version of the python list? :-( A big problem, other than Mr. Support's shenanigans with his email address, is that even those of us who seem to have successfully *plonked* him get the responses to him. The biggest issue with a troll isn't so much the annoying emails from him but the amplified slew of responses. That's the point of a troll after all. The answer is to always make sure that you include the previous poster in the reply as a Cc or To. I filter out any email that has the string "supp...@superhost.gr" in a header so I would also filter out the replies if people would follow that simple rule. I have suggested this before but the push back I get is that then people would get two copies of the email, one to them and one to the list. My answer is simple. Get a proper email system that filters out duplicates. Is there an email client out there that does not have this facility? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll
On Sat, 15 Jun 2013 03:31:12 +1000 Chris Angelico wrote: > On Sat, Jun 15, 2013 at 3:13 AM, D'Arcy J.M. Cain > wrote: > > I have suggested this before but the push back I get is that then > > people would get two copies of the email, one to them and one to the > > list. My answer is simple. Get a proper email system that filters > > out duplicates. Is there an email client out there that does not > > have this facility? > > The main downside to that is not the first response, to > somebody@somewhere and python-list, but the subsequent ones. Do you > include everyone's addresses? And if so, how do they then get off the No, I think Ccing the From is enough. Other than the OP who is already *plonked* replies to the replies tend to have at least a modicum of information. > I prefer to simply mail the list. You should be able to mute entire > threads, and he doesn't start more than a couple a day usually. But then I have to deal with each thread. I don't want to deal with them at all. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll
On Fri, 14 Jun 2013 14:00:17 -0500 Tim Chase wrote: > I set that up for Xah posts and my life was far better. Has he disappeared or is my filtering just really successful? > I've since switched to Claws for my mail and miss that kill-thread > functionality. :-/ Heh. Exactly what I am using. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Sat, 15 Jun 2013 21:29:35 +1000 Ben Finney wrote: > > Bah. Plenty of us like both. In the inbox alerts me that someone > > replied to _my_ post, and in the python mail gets it nicely > > threaded. > > Your mail client doesn't alert you to a message addressed to you? Every message in my mailbox is addressed to me otherwise I wouldn't get it. Do you mean the To: line? Which address? I have about a dozen addresses not counting the plus sign addresses like the one you use for this list. Which one should I treat as special? > > Sorry, I could have sworn you said you weren't using a mail client > > for this... > > As I already said, this is demonstrating the fact that “reply to all” > is broken even for the use case of participating via email. As the person who proposed this I would like to point out that I never suggested "reply to all”. I suggested including the poster that you are replying to. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Sat, 15 Jun 2013 18:41:41 +0200 Chris “Kwpolska” Warrick wrote: > On Sat, Jun 15, 2013 at 5:40 PM, Steven D'Aprano > wrote: > > In the name of all that's good and decent in the world, why on earth > > would you do that when replying to a mailing list??? They're already > > getting a reply. Sending them TWO identical replies is just rude. > > Mailman is intelligent enough not to send a second copy in that case. > This message was sent with a CC, and you got only one copy. Actually, no. Mailman is not your MTA. It only gets the email sent to the mailing list. Your MTA sends the other one directly so Steve is correct. He gets two copies. If his client doesn't suppress the duplicate then he will be presented with both. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 15 Jun 2013 15:40:35 GMT Steven D'Aprano wrote: > On Sat, 15 Jun 2013 07:58:27 -0400, D'Arcy J.M. Cain wrote: > > I suggested including the poster that you are replying to. > > In the name of all that's good and decent in the world, why on earth > would you do that when replying to a mailing list??? They're already > getting a reply. Sending them TWO identical replies is just rude. You may disagree with my reasoning but I have presented it a few times. By the way, I did reply just to the list this time as you obviously disagree but I may forget in the future. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Mon, 17 Jun 2013 14:39:56 + (UTC) Grant Edwards wrote: > I don't want _any_ copies from from Mailman. I don't subscribe to > whatever mailing list you're talking about. I'm reading this via an > NNTP server. Keep replies in the group or on the list. And that is part of the problem. I have always argued that gatewaying the mailing list to newgroups is wrong. If this was only a mailing list there are many things we could do to reduce abuse but because of the gateway they can't be done. Not that it matters to me any more. I have finally decided that this list is just more noise to signal than I care to deal with. If anyone has any comments for me you will have to Cc me as I am outa here. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: for-loop on cmd-line
On Thu, 11 Oct 2012 13:24:22 +0200 Gisle Vanem wrote: > Hello list. I'm a newbie when it comes to Python. > > I'm trying to turn this: > > def print_sys_path(): > i = 0 > for p in sys.path: > print ('sys.path[%2d]: %s' % (i, p)) > i += 1 > > into a one-line python command (in a .bat file): Is "one liner" an actual requirement or is the requirement to run it from the command line? python -c " import sys i = 0 for p in sys.path: print('sys.path[%2d]: %s' % (i, p)) i+=1 " I don't know if this works on Windows or not. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On Mon, 22 Oct 2012 07:07:20 -0700 (PDT) ru...@yahoo.com wrote: > Re the specific problem mentioned, I just paste the original > message into an emacs window, add the quote marks and paste back > into the GG compose window. If you are on Firefox you should check out the "It's All Text!" plugin. Not sure if it is available for other browsers. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Preventing crap email from google?
On Mon, 22 Oct 2012 14:21:36 + (UTC) Grant Edwards wrote: > Same here. Here's the rule I have in slrn's .score file: Here is the procmail one that I use: :0 Hir * ^List-Id:.*python-list.python.org * ^From:.*@gmail.com * ^Newsgroups: /dev/null This still allows people using a gmail account to post to the mailing list through. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Interview Questions
On 18 Nov 2012 16:50:52 GMT Steven D'Aprano wrote: > On Sun, 18 Nov 2012 08:53:25 -0500, Roy Smith wrote: >> > Use a list when you need an ordered collection which is mutable > > (i.e. can be altered after being created). Use a tuple when you > > need an immutable list (such as for a dictionary key). > > I keep hearing about this last one, but I wonder... who *actually* > does this? I've created many, many lists over the years -- lists of > names, lists of phone numbers, lists of directory search paths, all > sorts of things. I've never needed to use one as a dictionary key. Well, as long as *you* never needed it then... CellBlock = 9 # There's a riot going on... Cell = 17 Bunk = "top" Prisoner = {(CellBlock, Cell, Bunk): "Bernie Madoff"} -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
On Wed, 12 Dec 2012 17:44:24 +1100 Chris Angelico wrote: > On Wed, Dec 12, 2012 at 5:34 PM, Steven D'Aprano > wrote: > > and you consider this "not productive, not worth my time". Code > > review with you must be *all* sorts of fun. > > He never asked for code review :) I think by posting it he sort of did. He should probably grow a thicker skin before he does so again though. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a python script under Linux
On Fri, 14 Dec 2012 14:18:28 +0100 Hans Mulder wrote: > The Pythonic way to get what you want, is to be explicit: > > #!/usr/local/bin/python2.7 -V > > If you do that, it will even work in situations where you > can't control PATH, such as CGI scripts and cron jobs. As long as you only run on one system that's OK. That won't work on NetBSD or Linux[1] for example. > There are situations where using #!/usr/bin/env makes sense, > but yours isn't one of them. #! /usr/bin/env python2.7 [1]: Well, Ubuntu anyway. I don't know about the others. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On Wed, 02 Jan 2013 23:32:33 -0500 Kene Meniru wrote: > This sounds so simple but being new to python I am finding it hard to > get started. I want to create a module which I will call "B". There > will be other modules called "C", "D", etc, which will most likely be > imported in "B". Then I want the user to import "B" ONLY into another > file I will call "A" in which commands such as the following will be > entered: > > snap_size = 10 > LinearMark(name) > LinearMark.put(name, length, rotation, (x,y,z)) Sounds messy. > The file "A" allows the user to enter commands that provide global > variables as well as to use classes provided in modules "C", "D", OK, "global variables" is the clue that you need to rethink this. Try to stay away from global variables as much as possible except for maybe some simple setup variables within the same file. Consider something like this instead. In file B: class TopClass(object): def __init__(self, snap_size, var1 = None, var2 = None): self.snap_size = snap_size self.var1 = var1 if var2 is None: self.var2 = 7 self.var3 = "GO" self.var4 = "Static string" *add class methods here* In file A: class MyClass(TopClass): def __init__(self, var1): TopClass.__init__(self, 10, var1, 8) self.var3 = "STOP" x = MyClass(42) x.var4 = "Not so static after all" In this (untested) example you create your top class in B and then subclass it in A. Notice the different way of setting variables here. In MyClass we hard code snap_size to 10, we set var1 from the argument when we instantiate it, var2 is hard coded to 8 but could be left out if we wanted the default of 7, var3 is overwritten in MyClass and var4 is changed after the class is instantiated. Hope this gives you some ideas. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
PyGreSQL 4.1 released
--- Release of PyGreSQL version 4.1 --- It has been a long time coming but PyGreSQL v4.1 has been released. It is available at: http://pygresql.org/files/PyGreSQL-4.1.tgz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection which will probably be updated shortly. Please refer to `changelog.txt `_ for things that have changed in this version. Please refer to `readme.txt `_ for general information. This version has been built and unit tested on: - NetBSD - FreeBSD - openSUSE 12.2 - Windows 7 with both MinGW and Visual Studio - PostgreSQL 8.4, 9.0 and 9.2 32 and 64bit - Python 2.5, 2.6 and 2.7 32 and 64bit -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On Thu, 03 Jan 2013 09:06:55 -0500 Kene Meniru wrote: > > OK, "global variables" is the clue that you need to rethink this. > > Try to stay away from global variables as much as possible except > > for maybe some simple setup variables within the same file. > > Consider something like this instead. > > > > The global variable is not part of the LinearMark object. It will be > used by ALL objects created. I understand the uneasiness with this so > maybe I will make it a function so it will be set with something like: Applying to all objects in your file A is not an issue. See below. > SnapSize(num) That doesn't make it any less global. > As I mentioned, the file "A" can be considered a scene file. I do not I don't know what a "scene" file is. > want the user to have to create classes there. I apologize for the But you expect them to write Python code? Classes are a very powerful part of Python and if super classes are written well they can be very simple to write. Perhaps you found my examples too complicated. That was so I could illustrate a number of methods. I wouldn't expect you to use all of them in your code. Here is a simpler example that may meet your requirements. File B: class TopClass(object): def __init__(self, snap_size): self.snap_size = snap_size def put(self, ... In file A: class MyClass(TopClass): def __init__(self): TopClass.__init__(self, 10) x = MyClass() x.put(... Now you have a new class where every instance uses a snap size of 10. Notice that this class in what you call the user's code is only three lines. That's pretty simple for your "user." If you think that that is too complicated still then maybe the user shouldn't be writing any Python code and instead look at the various ways of parsing configuration files which they can write. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't seem to start on this
On Thu, 03 Jan 2013 09:59:04 -0500 Kene Meniru wrote: > Yes, I guess that is the main thing. I do not want users to have to > write python code unless they are interested in customizing how the That works too. It's just that you had users writing Python code but assumed that a three line subclass was beyond them. Not requiring them to write any Python code is a better option than the first one (global variables) that you proposed. That's all I am trying to say. > program behaves or perhaps a building component. In that case any of > the other modules can be updated instead of "A". Actually "A" will > not be part of the packaged program. Or "A" becomes the script that parses the config file and runs the other code. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGreSQL 4.1 released
On Thu, 3 Jan 2013 15:06:29 + (UTC) Walter Hurry wrote: > Sounds good. Thanks for your efforts. I wasn't alone but I accept your thanks on behalf of the team. > Does it offer advantages oiver Psycopg2? Well, it has two interfaces, the DB-API 2.0 and the "Classic" one. The classic one is basically the one PyGreSQL started life as before we had a standard interface. We kept it as it has some advantages over the portable one but offer both. As for other advantages, I prefer to hear those from people not involved with either project. -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGreSQL 4.1 released
On Sat, 5 Jan 2013 13:23:55 +0100 Michael Poeltl wrote: > no python3 support yet? > can you tell us when pygresql will be ready for python3? Hard to say when (we all have day jobs) but it is planned for version 5.0. You can track our milestones at http://trac.vex.net:8000/pgtracker We will probably get version 4.2 released shortly and then branch 5.x and start working on Python 3 support. -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Proof that nobody reads the tests
On Sun, 6 Jan 2013 05:26:19 -0800 (PST) chaouche yacine wrote: > Oh :) sorry I didn't know they were references to monty python > sketches. That explains it then :) The name of the language itself is a reference to Monty Python. That is specifically what it was named after. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGreSQL 4.1 released
On Sat, 5 Jan 2013 08:44:17 -0500 "D'Arcy J.M. Cain" wrote: > We will probably get version 4.2 released shortly and then branch 5.x > and start working on Python 3 support. In fact, we found a few buglets and will be releasing 4.1.1 on Tuesday. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
New version of PyGreSQL 4.1.1 - bug fixes
- Release of PyGreSQL version 4.1.1 - A few problems showed up with the 4.1 release so we are releasing a quick bugfix version. It is available at: http://pygresql.org/files/PyGreSQL-4.1.1.tgz. If you are running NetBSD, look in the packages directory under databases. There is also a package in the FreeBSD ports collection. Please refer to `changelog.txt `_ for things that have changed in this version. Please refer to `readme.txt `_ for general information. This version has been built and unit tested on: - NetBSD - FreeBSD - openSUSE 12.2 - Windows 7 with both MinGW and Visual Studio - PostgreSQL 8.4, 9.0 and 9.2 32 and 64bit - Python 2.5, 2.6 and 2.7 32 and 64bit | D'Arcy J.M. Cain | da...@pygresql.org -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: PyWart: Module access syntax
On Mon, 14 Jan 2013 11:51:50 -0700 Ian Kelly wrote: > On Sun, Jan 13, 2013 at 10:22 PM, Rick Johnson > wrote: ...Whatever > If you want us to understand the syntax, then you need to define If you are going to feed the trolls can I please ask that you Cc them or send to them and Cc the list? That way those of us who filter out the trolls can filter out the responses to them as well. Thanks for understanding. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: PyWart (Terminolgy): "Class"
On 15 Jan 2013 02:08:38 GMT Steven D'Aprano wrote: > > Rick Johnson is a well-known troll. > > I disagree that Rick is a troll. Trolling requires that the troll Doesn't matter. He duck types as one. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting a string to a number by using INT (no hash method)
On Tue, 22 Jan 2013 16:27:32 + "Leonard, Arah" wrote: > > I just need a way to CONVERT a string(absolute path) to a 4-digit > > unique number with INT!!! That's all i want!! But i cannot make it > > work :( Why bother? Just wish for a zillion dollars and then you never have to program again. At least that would be theoretically possible. > *might* be able to convert a string that long into some kind of > 4-digit integer checksum, but you would *never* be able to convert > that back into a file path. Nor would it be guaranteed to be unique. In fact, if you have 10,001 files it is absolutely guaranteed to have at least one duplicate entry. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: how to avoid leading white spaces
On 03 Jun 2011 14:25:53 GMT Steven D'Aprano wrote: > source.replace(",", " ").split(" ") I would do; source.replace(",", " ").split() > [steve@sylar ~]$ python -m timeit -s "source = 'a b c,d,e,f,g h i j k'" What if the string is 'a b c, d, e,f,g h i j k'? >>> source.replace(",", " ").split(" ") ['a', 'b', 'c', '', 'd', '', 'e', 'f', 'g', 'h', 'i', 'j', 'k'] >>> source.replace(",", " ").split() ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'] Of course, it may be that the former is what you want but I think that the latter would be more common. > There's no need to use a regex just because you think that you *might*, > someday, possibly need a regex. That's just silly. If and when > requirements change, then use a regex. Until then, write the simplest > code that will solve the problem you have to solve now, not the problem > you think you might have to solve later. I'm not sure if this should be rule #1 for programmers but it definitely needs to be one of the very low numbers. Trying to guess the client's future requests is always a losing game. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a Python script on a web server
On Wed, 8 Jun 2011 11:22:53 +0530 Abhijeet Mahagaonkar wrote: > >>Python doesn't normally run in a web browser. There's two easy options: > > Is there an option of running it like php? I have never written in php, but > my understanding is that the php script will be saved in some remote server > and we will be able to run it using the url. > pls correct me if i;m wrong. Well, not wrong but perhaps not phrasing your original question correctly. > > On Wed, Jun 8, 2011 at 1:10 PM, Abhijeet Mahagaonkar > > wrote: > > > So i have requested a server space so I need some inputs on how i will be > > > able to "host" these scripts on a webserver and have them run on browsers > > > rather than on individual systems. That's the normal way to run Python on the web. You store your Python (or Perl or PHP or compiled C) programs on a web server that offers Python http://www.Vex.Net/ and when someone clicks on the link the server runs them and presents the results. This is different than something like Java or Javascript that runs in the browser. If that still doesn't answer your question then perhaps you can try to clarify exactly what it is you are trying to do. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Function declarations ?
On Wed, 8 Jun 2011 13:58:18 + (UTC) Andre Majorel wrote: > Is there a way to keep the definitions of the high-level > functions at the top of the source ? I don't see a way to > declare a function in Python. You don't declare functions in Python. You simply define them. You could define all your functions first and then call them. This is probably not a bad idea anyway. However, I suspect it doesn't solve your problem but since you haven't articulated it I can't tell. Don't present a solution and ask how it could work. Tell us what problem you are trying to solve and maybe we can suggest a solution. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can someone help please
On Thu, 21 Jul 2011 18:43:48 +0100 Gary Wood wrote: > Hi > Thanks for your reply's > and sorry guys for not explaining properly > ok the problem with the code, which i never realised before, is it sends the > first txt file as the header or subject field in an email and the rest in > the body of the email which i don't want. I would like all the txt files in > the body of an email > >> total = ' ' Change this to: total = '\n' You just need a blank line between the headers and the body of the email message. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: List spam
On Thu, 18 Aug 2011 22:37:37 +0800 Ghodmode wrote: > Make an effort to curb the spam even if it means killing the newsgroup > availability. Choose mailman or Google Groups, or another single > solution. Make it members only, but allow anyone to register with an > automated confirmation email and a CAPTCHA. Appoint a list admin who > has a few minutes each day to scan subjects of emails for spammers and > remove them from the members list. I'm not sure it would scale but I have a few lists that I protect by doing a few simple things. First, I make the list so that only members can post. I then set the list so that everyone is moderated by default. When someone posts a legitimate message I simply pass it and then unmoderate that user. It's not as onerous as it sounds. Very few people actually post and you only have to deal with those that do once. Mailman makes it pretty simple to manage too. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Stop quoting spam [was Re: Hot Girls ...]
On Fri, 19 Aug 2011 17:12:40 -0400 Matty Sarro wrote: > It was a joke, no need to be a prick about it. It was spam. You're the prick. If you think spam is funny it's because you aren't the one that has to spend your time dealing with the fallout. > If you're that offended then spend the cycles fixing the damn list so it Most of us have fixed it. We didn't see the spam until you repeated it. For whatever reason the original message was caught by our filters. You helped the spammer break through. I can assure you though that your attitude means that you won't be able to help them again. I can hear the plonking going on all over the net. Here's another one; *plonk* No point in replying. I won't hear it. Hope you don't have any important questions for the group. It just became more of a read-only list for you. > If php, red hat, and perl can manage it for their lists, why not python? Is > that a statement about python programmers? And that should get you blacklisted by anyone on the cusp. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Stop quoting spam [was Re: Hot Girls ...]
On Fri, 19 Aug 2011 17:10:49 -0400 Rodrick Brown wrote: > It's not the end of the world calm down I thought it was quite funny for a > friday joke! The first message might have been funny (if you are twelve) but the rest were annoying and insulting. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Stop quoting spam [was Re: Hot Girls ...]
On Sat, 20 Aug 2011 08:17:32 -0400 David Robinow wrote: > > I found said joke rather funny :P > Perhaps, as a retired amateur comedian, my standards are too high, How does one retire from amateur status? Do you suddenly start charging for telling jokes? :-) > but I don't think adding a smilie to a stupid post suddenly turns it > into a joke. Nevertheless, the quality of the attempt is not really > the issue here. The would-be humorist did not need to quote the spam. Well, exactly. I don't think that anyone made any comment about the quality of the joke when talking about the first posting. The only thing that people said was that he shouldn't have repeated the spam. Everyone, including the original poster, who defended the post did so on the grounds that it was funny. That's certainly debatable but no one was telling him not to post until he gets funnier. http://en.wikipedia.org/wiki/Straw_man Whether the post was funny or not is a judgment call. No one is saying not to post unfunny jokes because no one is the arbiter of what's funny. If you want to argue with the complainers, argue with their actual complaint. Tell us why it is OK to repeat spam with all the spammy URLS intact By the way, my joke above is hilarious. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Really, stop repeating spam! (Was: Hot Girls...)
On Sat, 20 Aug 2011 15:16:08 +0530 hackingKK wrote: > Well, they might be indented in the right places but i don't know if > loops, conditions, functions, if they all happen or not. > :) [Entire spam deleted AGAIN] Good grief! Haven't you seen all the followups to that posting you replied to? Are you two actually in cahoots with the spammer? Wait, I get it. The spammer, Matty and you are all on gmail. You are all the same person, aren't you? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Record seperator
On 26 Aug 2011 18:39:07 GMT greymaus wrote: > > Is there an equivelent for the AWK RS in Python? > > > as in RS='\n\n' > will seperate a file at two blank line intervals open("file.txt").read().split("\n\n") -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python fails on math
On Thu, 24 Feb 2011 04:56:46 -0800 Ethan Furman wrote: > >> The IEEE 754 compliant FPU on most machines today, though, has an 80-bit > >> internal representation. If you do a sequence of operations that retain > >> all the intermediate results in the FPU registers, you get 16 more bits > >> of precision than if you store after each operation. > > > > That's a big if though. Which languages support such a thing? C doubles > > are 64 bit, same as Python. > > Assembly! :) Really? Why would you need that level of precision just to gather all the students into the auditorium? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Just finished reading of "What’s New In Python 3.0"
On Fri, 11 Mar 2011 06:30:35 -0800 Westley Martínez wrote: [repeated posing elided] > n00m: GET A BLOG. Is it so hard to simply add him to your killfile and move on? Those of us who have already done so get to see his postings anyway if people are going to reply and repeat his trolls. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: value of pi and 22/7
On Fri, 18 Mar 2011 13:45:47 +0100 Stefan Behnel wrote: > Neil Cerutti, 18.03.2011 13:17: > > RIIght. What's a cubit? > > http://en.wikipedia.org/wiki/Cubit I don't believe that Neil was asking a serious question. http://www.youtube.com/watch?v=so9o3_daDZw -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with regex needed
On Tue, 12 Apr 2011 15:06:25 +0300 Yuri Slobodyanyuk wrote: > Thanks everybody , and especially Chris - i used split and it took me 15 > mins to make it work :) That's great. One thing though... > for nnn in hhh: > if nnn.split()[2] == str(time_tuple[1]).strip(' \t\n\r') and > nnn.split()[4] == str(time_tuple[0]).strip(' \t\n\r') and nnn.split()[3] > == str(time_tuple[2]).strip(' \t\n\r') : You are running split() on the same string three times and running strip on the same time tuple each time through the loop. I know that you shouldn't optimize before testing for bottlenecks but this is just egrecious as well as making it more difficult to read. Consider this. year = str(time_tuple[0]) # strip() not really needed here mon = str(time_tuple[1]) day = str(time_tuple[2]) for nnn in [x.split() for x in hhh]: if nnn[2] == mon and nnn[3] = day and nnn[4] = year: If strip() were needed you could leave off the argument. The default is to strip all whitespace from both ends. In fact, read up on locales to see why it is a good idea to omit the argument. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with regex needed
On Tue, 12 Apr 2011 22:11:55 +0300 Yuri Slobodyanyuk wrote: > Thanks for the insight, while this code will run once a week and > optimization isn't really a must here, it is > still a good idea not to leave half-baked code behind me, especially given > that it will be running on this server for the next 13 years ;) You don't want to embarrass yourself in 13 years, eh? :-) > I have one doubt though . Doesn't using the list comprehension here increase > number of loops per the same string ? Nope. It just optimizes the code a bit. > for nnn in [x.split() for x in hhh]: > My vision here is that after doing the comprehension it would look: > for nnn in [1st_field,2nd_field,3rd_filed,...,nth_filed]: for nnn in hhh: becomes for nnn in ('a b c', 'd e f', 'g h i'): # loops three times for nnn in [x.split() for x in hhh]: becomes for nnn in [['a','b','c'],['d','e','f'],['g','h','i']: # still three > ... and therefore would do number of loops equal to number of fields while > we really need just one ? The number of loops is still the number of objects (strings) in hhh. The only difference is that in the former case you need to split the variable inside the loop causing the production and destruction of an extra object. Be careful though. You can optimize your loops by doing too much in the for statement. You would be hard put to find a case where optimization is worth more than readability. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature suggestion -- return if true
On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing wrote: > My idiom for fetching from a cache looks like this: > >def get_from_cache(x): > y = cache.get(x) > if not y: >y = compute_from(x) >cache[x] = y > return y I prefer not to create and destroy objects needlessly. def get_from_cache(x): if not x in cache: cache[x] = compute_from(x) return cache[x] -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Read-write lock for Python
On Thu, 28 Apr 2011 19:14:45 +0200 Geoff Bache wrote: > On Thu, Apr 28, 2011 at 4:28 PM, Jean-Michel Pichavant > wrote: > > What about > > > > http://docs.python.org/library/threading.html#lock-objects > > Those aren't read-write locks. They are basic locks, which don't > distinguish between readers and writers. I need to be able to lock > between reader and writer operations, without readers locking each > other out. There really isn't any such thing as "read-write" locks. In fact, the term "locks" without any further explanation is pretty loose in any case. You can use the above method to implement your own locking scheme. However, that only works if your application is a single, multi-threaded app. Is that the case? When I saw your original question I thought that you needed something inter-process. If so then you need another scheme. I think you have to first clarify your requirements and ask again. I have gleaned a little more information from your above response, you don't require readers to be locked out during an update if I understand the requirement. There is still a lot of information missing. For example: - What is being read and written? Files? - Is this a single multi-threaded app or multiple processes? - if multiple processes, can they be counted on to cooperate? - Do update requests need to be queued or is random availability OK? Now, don't just answer the above questions. Try to start with that and think about what other requirements you have. The more information you give us, the better the answer will be. You may even find that locking is not the actual answer you need. People do have a tendency to offer solutions when they think they are asking questions. Don't pre-suppose the answer. http://www.catb.org/~esr/faqs/smart-questions.html is always a good read in these situations. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] From svn to something else?
On Fri, 29 Apr 2011 22:53:47 +1000 Ben Finney wrote: > Bazaar's support for Subversion repositories is great (it requires the > ‘bzr-svn’ plug-in, of course). Use the ‘svn-import’ subcommand to import > an entire Subversion repository to a Bazaar repository with all branches > and history intact. Anyone know how to go the other way? I recently converted all my projects over to svn from cvs and then took over another project that uses bzr. I would prefer everything to be in the same system. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: checking if a list is empty
On Wed, 11 May 2011 11:47:42 +0100 Hans Georg Schaathun wrote: > However, programming is often as much about developing ideas in a large > and complex community, where perfect universal mastery of one language > is not an option, because half the community do not normally use that > language or aren't really programmers at all. The less you assume about > the skill of the reader, the better it is. 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? Should trucks be built so that drivers don't have to learn how to split shift? Why is programming so different that we can't expect people to actually learn their discipline? This discussion is giving me some insight into some of the crap programming I see these days. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: checking if a list is empty
On Wed, 11 May 2011 15:05:45 +0100 Hans Georg Schaathun wrote: > What could elif mean other than else: if? If run by an elf? Who knows. You do, of course, if you have learned the basics of the language you are using. > if x could, for instance, mean "if x is defined". It could also mean "if x was created on a Tuesday." A short introduction to the language explains what it actually means. When did we come to the idea that people should be able to program in a language without actually learning it? The fact that Python comes so close to that possibility is nothing short of revolutionary. I suppose one day a reasoning android will be able to sit down at the terminal of a star ship computer and ask simple questions while making random hand movements across a screen but for now I am afraid that programmers still have to learn programming. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: checking if a list is empty
On Wed, 11 May 2011 16:24:47 -0500 harrismh777 wrote: > D'Arcy J.M. Cain wrote: > Non-programmers should not be expected to program in 'C' nor in lisp... > > ... but non-programmers were able to program in BASIC jes fine... They still had to learn the language. > I contend that non-programmers are able to learn rudimentary python and > work with it to solve real problems 'without' formal training in > 'programming'. When did the discussion shift from "learn the language" to "formal training?" How you learn the language is totally irrelevant. > Python is the New BASIC for 'people'. At least, it has the potential to > be that... people should be able to talk to their computers (whatever > we mean by that) and have the computer respond with real-world > solutions. We need to move away from 'canned apps' to a new day where > the masses can sit down to their computer and solve new problems with it > through intuitive language skills. Why not? That's not programming. That's using a canned app that a programmer wrote that takes your unstructured input and does something useful with it. Spreadsheets are a primitive example of that. Google is a more advanced example. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: obviscating python code for distribution
On Tue, 17 May 2011 16:39:48 +1000 Chris Angelico wrote: > You have a point there. Although I can't guarantee that all my code is > particularly *good*, certainly not what I'd want to hold up for a > novice to learn from - partly because it dates back anywhere up to two > decades, and partly because quite a few of the things I was working > with are completely undocumented! Sounds like a perfect reason to open source it. If what you say is true it could benefit you more than others, at least at the beginning. Remember, open source is a two way street. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: How To Make Fast Money Legally
On Wed, 18 May 2011 12:06:07 -0700 (PDT) "tmac641...@yahoo.com" wrote: > HOW TO MAKE EASY MONEY FAST AND LEGALLY Wow! Was this stuck in someone's mail queue since 1992? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why did Quora choose Python for its development?
On Tue, 24 May 2011 09:00:14 +0300 "Octavian Rasnita" wrote: > So, again, in Perl is just: > > %d = @l; > > Please tell me if Python has a syntax which is more clear than this for > doing this thing. How is that clear? "Shorter" != "clearer." A Python programmer looking at that sees line noise. A Perl programmer looking at "d = dict ([a])" (or even "d = dict(a,)") sees something that has something to do with creating a dictionary. At least he would know in which section of the manual to look for more information. > And again, I am not trolling anything. I am just defending a language which > has a clearer syntax for doing some things, and a shorter code for other Are Perl programmers aware of some imminent worldwide shortage of electrons that Python programmers are not? Why is there this obsession with shortness? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why did Quora choose Python for its development?
On Tue, 24 May 2011 00:17:55 -0500 John Bokma wrote: > > $d = @a; > > That will give you the number of elements in @a. What you (probably) > mean is %hash = @array; If I was even considering using Perl, this one exchange would send me screaming in the opposite direction. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why did Quora choose Python for its development?
On Tue, 24 May 2011 19:10:56 +0300 "Octavian Rasnita" wrote: > > If I was even considering using Perl, this one exchange would send me > > screaming in the opposite direction. > > If you didn't consider to change the language you prefer it means > that you are closed minded and use to fell in love with the tools you Now you are just bordering on rudeness. I never made any disparaging remarks about you. I only talked about a tool that you seem to like and I don't. In fact, I did consider and investigate Perl many years ago along with may other languages before I settled on Python. I didn't like it then and I don't like it now. However, I have never called someone "close minded" for preferring a different tool to me. > Don't make me tell here how many things I don't like in Perl. Trust me, there is no need. > I use to tell those things on Perl mailing lists and make upset their Good for you. I also have talked about things in Python that I don't like on this list. No one has ever accused me of being afraid to speak my mind. That facet of my personality has got me in a lot of trouble in my life from parents, teachers, bosses and I have even been known to speak out against the police while they were holding automatic rifles to my head. I doubt that there will ever be enough peer pressure on a mailing list to trump that. > Similarly, if you don't like something in Perl, why don't you tell > them what you don't like to the Perl programmers community and not just > have the guts to tell that in a group where the majority share your > preferences. Because I am not a missionary. Someone came to my house and told me why their way was better so I spoke up. Same thing when the JW come to my front door but I have no interest in going to their Kingdom Hall to tell them why they are wrong. > I came here on the list to find good things about Python and to learn > some things and use its good parts, and not to hear bashing about other > programming languages. Same here but someone (I don't even know who started it) felt that it was necessary to tell us all why their language was better. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why did Quora choose Python for its development?
On Tue, 24 May 2011 11:52:39 -0500 John Bokma wrote: > >> > $d = @a; > >> > >> That will give you the number of elements in @a. What you (probably) > >> mean is %hash = @array; > > > > If I was even considering using Perl, this one exchange would send me > > screaming in the opposite direction. > > To me as silly as all those people who give Python a wide berth because > of significant whitespace. I am glad that I am not so limited in that > respect. To me programming languages are like writing systems used by > humans; each has its short comings and each has its beauty. My point was that even proponents of the language can make a significant error based on the way the variable is named. It's like the old Fortran IV that I first learned where the name of the variable determined whether it was an integer or a floating point. One of my favorite quotes (not sure if it was about Perl or APL) is "I refuse to use a programming language where the proponents of it stick snippets under each other's nose and say 'I bet you can't guess what this does.'" When I first looked at Perl it looked like line noise. When I first looked at Python it looked like pseudo-code. Look, I couldn't care less what other people use. I just don't see any reason for someone to come into a Python group and start proselytizing about why their tool is better than ours any more than I would feel any need to go to a Perl group and start trying to convert them. Bottom line - they did a study once (sorry, can't point to it any more) to determine the best tool for development. Turns out that the most productive tool was generally the one that the user believed was the most productive. In hindsight I think that that was rather obvious. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why did Quora choose Python for its development?
On Wed, 25 May 2011 07:36:40 -0400 Roy Smith wrote: > Remembering that I, J, K, L, M, and N were integer was trivial if you > came from a math background. And, of course, Fortran was all about The easiest way to remember was that the first two letters of INteger gave you the range. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: The worth of comments
On Fri, 27 May 2011 00:02:23 -0700 Tim Roberts wrote: > Ruby has a lot of followers, and I am trying to get excited about it, but > it has succumbed to the same special-characters-as-syntax disease that > killed Perl. Much Ruby code is just unreadable. What? The recent Perl flame war wasn't enough entertainment for you? ;-) -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner needs advice
On Sat, 28 May 2011 07:06:53 +0200 Thomas Rachel wrote: > > "Completely incompatible"? A "lie"? > > Hard word, but it is true. Many things can and will fall on your feet > when moving. > > There are very many subtle differences. The space between "Completely incompatible" and "many subtle differences" is about the size of the Grand Canyon. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am new to python. I have a few questions coming from an armature!
On Wed, 17 Aug 2016 16:39:30 +1000 Steven D'Aprano wrote: > cond ? trueval : falseval > > Because the C syntax is horrifically ugly, whereas the Python syntax > is very close to real English syntax. Or, put another way, Python prefers English over line noise. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Multimeter USB output
On Mon, 29 Aug 2016 21:21:05 -0700 Larry Hudson via Python-list wrote: > I remember it well. It's what I used to initially learn C. I'm a > completely self-taught, hobby programmer. Been around since the MITS > Altair. How many remember that beast?? Remember it and still have it in the basement. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] Altair
On Tue, 30 Aug 2016 15:56:07 +0200 Joe wrote: > Am 30.08.2016 um 13:01 schrieb D'Arcy J.M. Cain: > > On Mon, 29 Aug 2016 21:21:05 -0700 > > Larry Hudson via Python-list wrote: > >> I remember it well. It's what I used to initially learn C. I'm a > >> completely self-taught, hobby programmer. Been around since the > >> MITS Altair. How many remember that beast?? > > > > Remember it and still have it in the basement. > > > I read a lot about the Altair in Byte in those days, but never had a > chance to touch it. Wasn't it horrible expensive? I can't remember what is was going for but I bought mine used for $1,000. It had a number of add-ons including a keyboard and floppy drives. The power supply was also beefed up. It also had a replacement bezel. It seems that the original Altair's silk screened front panel was crappy and rubbed off easily. Some company sold one but it says "Cycloid" instead of "Altair" on it. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] Altair
On Tue, 30 Aug 2016 20:51:54 +0200 Joe wrote: > I think the first BASIC Interpreter ever sold by Gates & Friend was > for this machine? How did you use your floppy drives on this machine > (Open-Write-Close)? The floppy drive came with an operating system called MDOS - Micropolis Disk Operating System. Once you loaded it by selecting the ROM address on the front panel, setting the PC and hitting RUN it took over. There was a bit of configuration, handled through the switches, that had to be done and then any further changes were done to the image in memory and saved to disk. When I finally upgraded to a whopping 64K of RAM (with a Morrow S-100 memory board) I had to blank out the section where the disk controller sat in memory. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: How to split value where is comma ?
On Wed, 7 Sep 2016 16:04:40 + Joaquin Alzola wrote: > > where is a comma there should start new line ... How can i do it ? > > Use the split > > a.split(",") > for x in a: > print(x) Seems overly complex. print(a.replace(',', '\n')) > This email is confidential and may be subject to privilege. If you > are not the intended recipient, please do not copy or disclose its > content but contact the sender immediately upon receipt. Do you realize how stupid it is to put this on a message sent all around the world? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: What you can do about legalese nonsense on email (was: How to split value where is comma ?)
On Thu, 08 Sep 2016 18:27:44 -0400 Random832 wrote: > If every lawyer in the world benefits from the interpretation that > this sort of notice is legally effective (since tomorrow it may be > they who accidentaly send privileged information), who will argue in > court that it's not? The reality is more complex, and it appears that > it may only apply if the accidental recipient is a lawyer. I really I often wonder if these automatic disclaimers actually remove any protection that they might have if they were used judiciously. If they had any validity wouldn't the fact that they are attached to every email, even ones obviously meant for the public, give someone an argument that they don't really apply? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: default argument value is mutable
On Fri, 07 Oct 2016 16:09:19 +0200 jmp wrote: > What about > > def test(): >if not hasattr(test, '_store'): test._store={'x':0} >test._store['x'] += 1 Why is everyone working so hard to avoid creating a class? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: The next major Python version will be Python 8
On Fri, 01 Apr 2016 02:02:34 +0200 Roel Schroeven wrote: > Victor Stinner schreef op 2016-03-31 23:40: > > Python 3 becomes more and more popular and is close to a dangerous > > point where it can become popular that Python 2. The PSF decided > > that it's time to elaborate a new secret plan to ensure that Python > > users suffer again with a new major release breaking all their > > legacy code. > > "2016-03-31 23:40" > You're 20 minutes early :) And too obvious. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: pylint woes
On Sun, 8 May 2016 14:21:49 +1000 Chris Angelico wrote: > if verbose: > verbiage = print > else: > def verbiage(*args): pass I have never understood why the def couldn't start on the same line as the else: if verbose: verbiage = print else: def verbiage(*args): pass The colon effectively starts a block so why not allow it? By the way, I think you meant "def verbiage(*args, **kws): pass" > Then, instead of "if verbose: print(var)", you would use > "verbiage(var)". Of course, you want something better than "verbiage" > as your name; the nature of your verbose output might give a clue as > to what name would work. How about "print"? if not verbose: def print(*args, **kws): pass -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: learning python. learning defining functions . need help
On Fri, 22 Jul 2016 08:21:17 -0700 justin walters wrote: > You could also replace that line with: > > if stock is None or type(stock) != dict: Use isinstance(). That handles classes that subclass dict as well. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Sat, 23 Jul 2016 14:13:46 +0300 Marko Rauhamaa wrote: > > for x in sequence: > > print('loop') > > > > Is that meant to print 'loop' each time around the loop, or just > > once, at the end of the loop? > > I don't see an ambiguity: obviously the print call takes place after > finishing the loop. It's ambiguous to the reader what was actually meant. Forcing a "pass" there shows the reader that the empty block was not a mistake. Explicit is better than implicit. > I wonder if there is any true case of ambiguity. I guess this is all > about an enforced aesthetic principle: GvR doesn't like the looks of > an empty block. I don't think that he would be alone. > Actually, the requirement of a dummy statement is a slight annoyance > for the programmer. After deleting a statement, you must see if you > have to put in a pass statement. And after adding a statement, you > may feel the urge to remove the redundant pass statement. If you allow empty blocks and you use it I hope that you would add a comment so that the reader knows that you meant it. for x in sequence: # this is an empty block Is that better than "pass"? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Sat, 23 Jul 2016 16:13:58 +0300 Marko Rauhamaa wrote: > "D'Arcy J.M. Cain" : > > It's ambiguous to the reader what was actually meant. Forcing a > > "pass" there shows the reader that the empty block was not a > > mistake. > > Just let the syntax speak for itself. The code means what the language > definition says it means. Exactly so given this... for x in sequence: print("Something") If the language allowed that then we know exactly what the programmer said. What we don't know is what the programmer meant. The above is a simple and obvious statement but real code is more complicated. Add a few comments and a little nesting and what used to be obvious isn't. The interpreter would still know what the programmer said but without the pass requirement it is easier for it to be not what he meant. Python has some nice features like this one that protect the programmer and allow much faster development because there is a safety net. If you like knives without handles you know where to find Perl. Gotta go. The metaphor police are at the door. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Fri, 29 Jul 2016 10:58:35 +0200 Antoon Pardon wrote: > As BartC already mentions it happens fairly often during debugging. > Something like. > > try: >Some code > except Some_Exception: ># Commented code for when I am debugging >pass I realize that that's a simplified example but really, isn't this just as easy? try: Some code # except Some_Exception: # Commented code for when I am debugging If your code block really is one line is "pass #" really so much more of a hardship than "#"? If it is a large block use "pass #@#" which is easy to remove with a search and replace. In any case, the rule about premature optimization for programs can probably be applied to developers too. Is saving a "pass" once in a while really where you need to focus your debugging efforts? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Fri, 29 Jul 2016 14:15:01 +0100 BartC wrote: > > try: > >Some code > > # except Some_Exception: > ># Commented code for when I am debugging > > Will it behave the same way when there is a Some_Exception exception? Of course not. The person writing that was an idiot. Oh wait - I wrote that. Damn! There must have been a reasonable excuse then. Naturally that part of my message was the only thing commented on. I suppose people stopped reading after that flub and missed my insightful comment on premature developer optimization. Getting more coffee now. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Fri, 29 Jul 2016 15:55:07 +0200 Antoon Pardon wrote: > I think the case where you just want to ignore the exception, but it > can at times be useful to get some extra logging information for > debuging purposes, is not that rare as you seem to suggest. The way I handle that is: DEBUG = False # near top of file ... try: block except SomeException: if DEBUG: log("Blah blah blah") Usually it's in a class so it would be "self.DEBUG". You can also get fancy with debug levels instead of True and False. My theory is that if I need to log it today there's a more than zero chance I might need to log it again one day. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Sat, 30 Jul 2016 11:15:12 +0100 BartC wrote: >> Doesn't it look like there's something missing in the Python? Both > the 'fi' or 'end', and the possibility of an 'h' statement. > > Note the Algol68-style style is more free-format where indents are > not significant. > > Anyway, if you're going to talk about annoying things forced upon you > by the language, what about: > > ":" after "else" > > "()" in "def fn():" > > "()" in "print (x)" for Python 3 > > "for i in range(N):" just to repeat a block N times... > > That's apart from the obligatory indents which, with an > 'end'-delimited scheme, are not always necessary. Has it occurred to you (as it has occurred to some of us) that Python just isn't your language? By the way, the last time I replied to you it went to the list but your address bounced. Was that a glitch or are you using an invalid address in a mailing list? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Sat, 30 Jul 2016 16:14:18 +0100 BartC wrote: > > By the way, the last time I replied to you it went to the list but > > your address bounced. Was that a glitch or are you using an > > invalid address in a mailing list? > > Do you mean my email address? That was valid once but no longer. (If > you want to send an email replace "bc" with "bcas".) Are you kidding me? It's not our job to replace things in your email address, it's yours. Fix your client. > I'm not using a mailing list; I'm posting to usenet. I don't care if you are using carrier pigeon. If you send an email address, make it a valid one. Maybe you should just change it to I_Am_a_Troll@nowhere. It's becoming increasingly obvious that you have absolutely no interest in Python and are just trying to get a rise out of people. *plonk* -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Procedures and functions [was Re: Why not allow empty code blocks?]
On Sun, 31 Jul 2016 13:32:16 +1000 Steven D'Aprano wrote: > Many beginners make the mistake of writing: > > mylist = mylist.sort() > > or try to write: > > mylist.sort().reverse() > > If we had procedures, that would be an obvious error (possibly even a > compile-time syntax error) instead of a perplexing source of mystery > bugs. While neither is a syntax error, the latter is definitely a run-time error: >>> mylist.sort().reverse() Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'reverse' -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Mon, 01 Aug 2016 00:25:58 +1000 Gordon Levi wrote: > "D'Arcy J.M. Cain" wrote: > >I don't care if you are using carrier pigeon. If you send an email > >address, make it a valid one. > > I admire those who use a valid email address on Usenet but it is an > open invitation for spammers. I doubt if there is anybody who uses > their primary email address. I never said that he had to use his primary address, just a valid one. On the other hand I have no throwaway accounts. Every address I use is a primary one. I have all sorts of methods to block spam. None of those methods involves moving my spam problem to someone else. But what do I know? I'm just some old fart who grew up being taught that society works best when you consider the other guy and take responsibility for your own messes. Old fashioned ideas I know. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Why not allow empty code blocks?
On Sun, 31 Jul 2016 11:53:47 -0400 "D'Arcy J.M. Cain" wrote: > On Mon, 01 Aug 2016 00:25:58 +1000 > On the other hand I have no throwaway accounts. Every address I use > is a primary one. I have all sorts of methods to block spam. None of > those methods involves moving my spam problem to someone else. For example... : Host or domain name not found. Name service error for name=address.invalid type=: Host not found So I have to examine every address I reply to or deal with the bounce message later. Way to move your spam problem to someone else. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Using valid emails
Time to change the subject. On Tue, 02 Aug 2016 01:30:47 +1000 Gordon Levi wrote: > "D'Arcy J.M. Cain" wrote: > >: Host or domain name not found. Name service > >error for name=address.invalid type=: Host not found > > > >So I have to examine every address I reply to or deal with the bounce > >message later. Way to move your spam problem to someone else. > > .invalid is specified in RFC 2606 for exactly that purpose. If you > don't notice that the address is invalid a server very close to you, Sure so either I have to stop and examine the address or else deal with the bounce from my SMTP server. Isn't that what I said? > probably your SMTP server, will tell you. In contrast, your valid > email address will become the target of many spam emails even if you > manage to block them. It will also be used as the source of spam so > somebody at vex.net may be fooled into believing that they are > receiving a proper email. I'm a little insulted that you think that I would ever allow someone to send mail to Vex.Net pretending to be from Vex.Net. That's just too easy to detect and block. Try it. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Using valid emails
On Tue, 2 Aug 2016 02:22:50 +1000 Chris Angelico wrote: > > I'm a little insulted that you think that I would ever allow > > someone to send mail to Vex.Net pretending to be from Vex.Net. > > That's just too easy to detect and block. Try it. > > vex.net. 10800 IN TXT "v=spf1 mx -all" > vex.net. 10800 IN MX 10 mail.vex.net. > mail.vex.net. 10800 IN A 98.158.139.68 > > So, if you're not sending mail from 98.158.139.68 and you claim to be > vex.net, you should be blocked. Exactly. I also have a further check. If you try to send me email pretending to be from Vex.Net you get a "5xx Yah Right" error. > Unfortunately, a lot of domains don't have SPF records, or have very > convoluted ones (check out gmail.com's SPF for instance). I can only fix my little corner of the Internet. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Using valid emails
On Sun, 31 Jul 2016 14:01:26 -0600 Michael Torrie wrote: > > So I have to examine every address I reply to or deal with the > > bounce message later. Way to move your spam problem to someone > > else. > > I've never had this problem. I use the mailing list side of things > and I reply to the list and I don't have bounce issues. Besides Fine for you. I actually prefer to have people explicitly reply to me (and the list) because then it winds up in my INBOX instead of the Python list folder. If I am busy I might skim over the Python folder but I always read my INBOX. The mail will stand out better. If I preferred everything in my Python folder I would just change the filter order. The idea is that as much as possible everyone should be able to get everything that they want. > that, he's not using email; he's using usenet which has never > required a valid email address, real or fake. To demand he use a > real email address is as silly as that guy that lambasts people on > this list for not using real names. That's really not the same thing at all. In fact, I don't even care if the address even works, as long as it doesn't bounce. If I didn't want to get replies I would use n...@vex.net which gets silently dropped and the address suggests that it will not be delivered. But I absolutely don't care if someone uses a fake name. I agree that such a restriction would be silly not to mention totally unenforceable. > That said, I wish he'd stop posting his arguments here on this list as > he clearly doesn't use Python for anything, and hasn't used Python for > any real amount of coding. He has no vested interest in Python so why > should his opinions matter to us? Agreed. That's why I have stopped talking to and listening to him. > As for spam, I hardly think spambots trolling Usenet are as effective > these days as they once were. And most people's anti-spam filters are > pretty good. Besides that, those of us posting to the mailing list > side of things get our real email addresses copied out into Usenet > and I haven't noticed any change in spam levels. Ditto. -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: Using valid emails
On Mon, 1 Aug 2016 12:38:27 -0600 Michael Torrie wrote: > That's not something I would ever want, nor I suspect people who are > participating in a lot of e-mail lists. To each his own. Exactly my point. Make the general case something that allows each person to control their own experience. > But more importantly, this just isn't how Usenet works. You may be I have ranted against gatewaying Usenet and email lists in the past. No one listened then. I don't suppose anyone would listen now. At least I was able to filter out Google groups where most of the garbage was coming from. :0 Hir * ^List-Id:.*python-list.python.org * ^From:.*@gmail.com * ^Newsgroups:.* /dev/null -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Unicode failure
I thought that going to Python 3.4 would solve my Unicode issues but it seems I still don't understand this stuff. Here is my script. #! /usr/bin/python3 # -*- coding: UTF-8 -*- import sys print(sys.getdefaultencoding()) print(u"\N{TRADE MARK SIGN}") And here is my output. utf-8 Traceback (most recent call last): File "./g", line 5, in print(u"\N{TRADE MARK SIGN}") UnicodeEncodeError: 'ascii' codec can't encode character '\u2122' in position 0: ordinal not in range(128) What am I missing? TIA. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode failure
On Fri, 4 Dec 2015 22:49:49 + Albert-Jan Roskam wrote: > I think you need to use a raw unicode string, ur > > >>> unicodedata.name(ur'\u2122') > 'TRADE MARK SIGN' That seems to work in 2.x but not 3.x. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode failure
On Fri, 4 Dec 2015 18:28:22 -0500 Terry Reedy wrote: > On 12/4/2015 1:07 PM, D'Arcy J.M. Cain wrote: > > I thought that going to Python 3.4 would solve my Unicode issues > > Within Python itself, that should be mostly true. As soon as you > send text to a display, the rules of the display device take over. OK but my display (xterm) can display those characters. I see it when I dump unicode text from my database. > > #! /usr/bin/python3 > > # -*- coding: UTF-8 -*- > > Redundant, as this is the default for 3.x I assumed so but belt and suspenders, right? > Tk widgets, and hence IDLE windows, will print any character from > \u to \u without raising, even if the result is blank or �. > Higher codepoints fail, but allowing the entire BMP is better than > any Windows codepage. Not sure I follow all this but to be clear, I am not using Tk, Idle or Windows. I guess I should have mentioned that I am on Unix but I thought that the hash-bang would have given that away. To be complete, I am running xterms on Xubuntu connected to NetBSD 7.0. The data is coming from a PostgreSQL 9.3.5 database. I am using a beta of PyGreSQL 5.0 (I am the lead developer for it) and I checked and the type returned is str, not bytes. The database encoding is UTF8. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: increment/decrement operators
On Sat, 5 Dec 2015 13:56:47 +0100 Robin Koch wrote: > x += y works. (Well, it should.) It does, even on objects other than numbers. >>> x = "abc" >>> y = "def" >>> x += y >>> x 'abcdef' > x++ doesn't. No but it's just a special case of the above. >>> x = 1 >>> x += 1 >>> x 2 -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Unicode failure (Solved)
On Fri, 4 Dec 2015 18:28:22 -0500 Terry Reedy wrote: > Tk widgets, and hence IDLE windows, will print any character from > \u to \u without raising, even if the result is blank or �. > Higher codepoints fail, but allowing the entire BMP is better than > any Windows codepage. Thanks to all. Following up on the various posts brought me to information that solved my problem. Basicall I added "export PYTHONIOENCODING=utf8" to my environment and "SetEnv PYTHONIOENCODING utf8" in my Apache config and now things are working as they should. Thanks all. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
codecs.StreamRecoder not doing what I expected.
More Unicode bafflement. What I am trying to do is pretty simple I think. I have a bunch of files that I am pretty sure are either utf-8 or iso-8859-1. I try utf-8 and fall back to iso-8859-1 if it throws a UnicodeError. Here is my test. #! /usr/pkg/bin/python3.4 # Running on a NetBSD 7.0 server # Installed with pkgsrc import codecs test_file = "StreamRecoder.txt" def read_file(fn): try: return open(fn, "r", encoding='utf-8').read() except UnicodeError: return codecs.StreamRecoder(open(fn), codecs.getencoder('utf-8'), codecs.getdecoder('utf-8'), codecs.getreader('iso-8859-1'), codecs.getwriter('iso-8859-1'), "r").read() # plain ASCII open(test_file, 'wb').write(b'abc - cents\n') print(read_file(test_file)) # utf-8 open(test_file, 'wb').write(b'abc - \xc2\xa2\n') print(read_file(test_file)) # iso-8859-1 open(test_file, 'wb').write(b'abc - \xa2\n') print(read_file(test_file)) I expected all three to return UTF-8 strings but here is my output: abc - cents abc - ¢ Traceback (most recent call last): File "./StreamRecoder_test", line 9, in read_file try: return open(fn, "r", encoding='utf-8').read() File "/usr/pkg/lib/python3.4/codecs.py", line 319, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 6: invalid start byte During handling of the above exception, another exception occurred: Traceback (most recent call last): File "./StreamRecoder_test", line 27, in print(read_file(test_file)) File "./StreamRecoder_test", line 15, in read_file codecs.getwriter('iso-8859-1'), "r").read() File "/usr/pkg/lib/python3.4/codecs.py", line 798, in read data = self.reader.read(size) File "/usr/pkg/lib/python3.4/codecs.py", line 489, in read newdata = self.stream.read() File "/usr/pkg/lib/python3.4/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xa2 in position 6: ordinal not in range(128) -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: codecs.StreamRecoder not doing what I expected.
On Sat, 12 Dec 2015 21:35:36 +0100 Peter Otten <__pete...@web.de> wrote: > def read_file(filename): > for encoding in ["utf-8", "iso-8859-1"]: > try: > with open(filename, encoding=encoding) as f: > return f.read() > except UnicodeDecodeError: > pass > raise AssertionError("unreachable") I replaced this in my test and it works. However, I still have a problem with my actual code. The point of this code was that I expect all the files that I am reading to be either ASCII, UTF-8 or LATIN-1 and I want to normalize my input. My problem may actually be elsewhere. My application is a web page of my wife's recipes. She has hundreds of files with a recipe in each one. Often she simply typed them in but sometimes she cuts and pastes from another source and gets non-ASCII characters. So far they seem to fit in the three categories above. I added test prints to sys.stderr so that I can see what is happening. In one particular case I have this "73 61 75 74 c3 a9" in the file. When I open the file with "open(filename, "r", encoding="utf-8").read()" I get what appears to be a latin-1 string. I print it to stderr and view it in the web log. The above string prints as "saut\xe9". The last is four actual characters in the file. When I try to print it to the web page it fails because the \xe9 character is not valid ASCII. However, my default encoding is utf-8. Other web pages on the same server display fine. I have the following in the Apache config by the way. SetEnv PYTHONIOENCODING utf8 So, my file is utf-8, I am reading it as utf-8, my Apache server output is set to utf-8. How is ASCII sneaking in? -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: codecs.StreamRecoder not doing what I expected.
On Sun, 13 Dec 2015 13:17:24 +0100 Laura Creighton wrote: > In a message of Sun, 13 Dec 2015 01:35:45 -0500, "D'Arcy J.M. Cain" > writes: > >When I try to print it to the web page it fails because the \xe9 > >character is not valid ASCII. However, my default encoding is utf-8. > >Other web pages on the same server display fine. > > > >I have the following in the Apache config by the way. > > > >SetEnv PYTHONIOENCODING utf8 > > > >So, my file is utf-8, I am reading it as utf-8, my Apache server > >output is set to utf-8. How is ASCII sneaking in? > > What is your sys.stdout.encoding ? > > just import sys and print the thing. > > I think you will find that it is not what you expect. > > Laura > >>> print(sys.stdout.encoding) utf8 That's what I was expecting. However when I add that to my web log output I get this: get_recipe() PYTHONIOENCODING: None get_recipe() encoding: 646 Dang! I was sure that I fixed that. I have this in my Apache configuration: SetEnv PYTHONIOENCODING utf8 I guess I have an Apache problem now, not a Python one. The strange thing is that this was a fix for a similar problem I asked about and it worked. Isn't there some way that I can just set the default encoding to utf8 for every Python program? Googling suggests that I can't do that but that doesn't see right. Since utf8 includes ASCII why wouldn't it be the default anyway? -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help on a project To :"Create a class called BankAccount with the following parameters "
On Thu, 24 Dec 2015 10:47:04 -0500 Joel Goldstick wrote: > Not to be rude, but if your style of methodology for asking for help > is indicative of your general attitude, and interest in learning to > write software, you may be better served to find a new calling. Its > not a good profession for people who basically say "do this for me" Or we wish it wasn't. That seems to be the style today. People claim to be programmers who only search the net for snippets to plug into their programs with no actual understanding. Or, they download a Wordpress theme and call themselves web designers. It reminds me of when one day people started claiming to be "building" computers and they didn't even own a soldering iron. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help on a project To :"Create a class called BankAccount with the following parameters "
On Thu, 24 Dec 2015 17:30:08 + (UTC) Grant Edwards wrote: > And don't get me started on those people who use those "integrated > circuits" instead of transistors, relays, and tubes... Mmmm. Tubes. Still use them in my guitar amp. Transistors just aren't the same thing. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: EOFError: marshal data too short -- causes?
On Tue, 29 Dec 2015 00:01:00 -0800 Glenn Linderman wrote: > OK, so I actually renamed it instead of zapping it. Them, actually, Really, just zap them. They are object code. Even if you zap a perfectly good .pyc file a perfectly good one will be re-created as soon as you import it. No need to clutter up you file system. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Problem with 'print'
On Sat, 9 Jan 2016 12:40:16 +0100 pablo gormi wrote: > Hello, recently I downloaded python, but when I try to execute one > file with the command 'print' it shows me a error. The error is: > > Missing parentheses in call to 'print' You downloaded Python 3. but your script was written for Python 2.. You have a few choices. Remove Python and install Python 2.7. Edit your script to bring it up to the latest version. Run 2to3 on your script or even whole directories. The first may be the easiest but you will have to do one of the others eventually so I would discourage it. There are plenty of sites (GIYF) that explain the differences between 2 and 3. You can manually edit all of your files. Current Python comes with a program called 2to3 that does 99% of the work for you. You should probably review the changes it makes (capture the output) to see if anything needs to be tweaked. This is definitely the best solution IMO. -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Stop writing Python 4 incompatible code
On Thu, 14 Jan 2016 14:43:51 +0100 Peter Otten <__pete...@web.de> wrote: > > Or we'll be hit by a big rock from space. > > Sounds like a plan. Which one? Number 9? -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Stop writing Python 4 incompatible code
On Thu, 14 Jan 2016 16:32:46 +0100 Peter Otten <__pete...@web.de> wrote: > >> > Or we'll be hit by a big rock from space. > >> Sounds like a plan. > > Which one? Number 9? > > Hm, I didn't expect this question... > > plans[-1], most certainly. Hmm. Am I being too subtle or...? from OuterSpace import plan print(plan[9]) If that's still too subtle: https://en.wikipedia.org/wiki/Plan_9_from_Outer_Space -- D'Arcy J.M. Cain Vybe Networks Inc. http://www.VybeNetworks.com/ IM:da...@vex.net VoIP: sip:da...@vybenetworks.com -- https://mail.python.org/mailman/listinfo/python-list
Release of PyGreSQL version 4.2
The PyGreSQL team is please to announce release 4.2 of PyGreSQL. It is available at: http://pygresql.org/files/PyGreSQL-4.2.tgz. If you are running NetBSD, look in the packages directory under databases for py-postgresql. There should also be a package in the FreeBSD ports collection. Please refer to the changelog for things that have changed in this version. The changelog and other information can be found at the web site http://www.pygresql.org/. This version has been built and unit tested on: - NetBSD - FreeBSD - openSUSE - Ubuntu - Windows 7 with both MinGW and Visual Studio - PostgreSQL 8.4 and 9.3 64bit - Python 2.4, 2.5, 2.6 and 2.7 32 and 64bit This is the last major release before 5.0 which will include support for Python 3.x. Only bug fixes will be applied to this branch. A beta of 5.0 is available at http://pygresql.org/files/PyGreSQL-beta.tar.gz. -- D'Arcy J.M. Cain PyGreSQL Development Group http://www.PyGreSQL.org IM:da...@vex.net -- https://mail.python.org/mailman/listinfo/python-list
Re: "IX" as shorthand for "Interface"
On Sat, 8 Oct 2011 22:21:02 -0600 Eric Snow wrote: > I'm writing a bunch of classes that have "Interface" in the name and > find that the length of the subsequent names is starting to get in the > way of readability (I don't really care about saving keystrokes). Is > "IX" conventional enough to use in place of "Interface" in a class > name? Thanks! Here's a suggestion based on my complete ignorance of you application so take it for what it is worth. If keystrokes don't matter to you consider this. class INTERFACE: pass class Something(INTERFACE): ... It isn't in the name but the definition is clearly an "INTERFACE" (whatever that is) and you also have the option of gathering things in common to INTERFACEs in the superclass. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Any idea how i can format my output file with ********************Start file*********************** usinf Python 2.7
On Sat, 9 Feb 2013 15:27:16 +0100 Morten Engvoldsen wrote: > I Have saved my output in .doc file and want to format the output with > > *Start the File > > Some data here > > > ***End of File* > > Can you let me know how can i do that using Python? Seems pretty simple. Open the file, read it into a variable, print the header, print the data and then print the footer. Which part are you struggling with? Show us your code so far. Or is the issue with the .doc file? Is it a Word document or simple text? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Shebang line on Windows?
On Mon, 25 Feb 2013 10:18:44 -0700 Michael Torrie wrote: > On 02/25/2013 06:14 AM, Dave Angel wrote: > > It's not Python that needs dos2unix, it's bash or equivalent. For > > some reason, bash shebang processing still isn't tolerant of a > > trailing cr on the line. Python doesn't care. > > Actually, the shell isn't involved in parsing the shebang line at all. > That's actually done in the kernel by the program loader. So it's the > kernel that has a problem with it; wonder if Linus would accept a > patch to ignore the tailing CR? So much the wrong solution. First of all, I don't think that Linus is on the bash development team so he can't help there. Also, bash is not the only shell in the world. And, Linux is not the only operating system in the world. There are still a lot of Unix systems (the system that Linux is a clone of) out there. FreeBSD, NetBSD, Solaris, Mac OSX, etc. You can't expect all of them to bend over backwards for every Windows wart out there. I don't run Windows myself so I can't test it but doesn't Python on Windows work fine with Unix style EOL? So why not strip out the CR and run the same file everywhere? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list