Re: [newbie] advice and comment wanted on first tkinter program
Op woensdag 22 januari 2014 16:43:21 UTC+1 schreef Alister: > On Wed, 22 Jan 2014 06:45:53 -0800, Jean Dupont wrote: > > > Op maandag 20 januari 2014 10:17:15 UTC+1 schreef Alister: > >> On Sun, 19 Jan 2014 20:04:05 -0800, Jean Dupont wrote: > >> > >> > Op zaterdag 18 januari 2014 16:12:41 UTC+1 schreef Oscar Benjamin: > >> >> On 18 January 2014 14:52, Jean Dupont > >> >> wrote: > >> >> > > >> >> > Thanks Peter and Terry Jan for the useful suggestions. One thing > >> >> > which I > >> >> >find a bit weird: when asking for Python-help concerning raspberry > >> Personally use Geany stand alone and not under idle, pressing F5 > >> should save & run the code you are currently editing. Would running > >> under idle give any other benefits? > > I don't know yet, but I just wanted to try out which of the following > > three I'd like best: > > 1. idle+leafpad 2. idle+geany 3. plain geany > > > > It's normal for a newbie to start with (1) as that is the default on > > raspbian, > > however I still don't understand why (2) does not work... > > > When I play with my Pi I tend to use another computer for all my editing > (sshfs is a quick & easy way for me to mount the necessary parts of the > PI file system so I don't have to keep transferring files) Thanks for the suggestion, I'm going to try it out kind regards, jean -- https://mail.python.org/mailman/listinfo/python-list
Re: [newbie] advice and comment wanted on first tkinter program
Op woensdag 22 januari 2014 15:45:53 UTC+1 schreef Jean Dupont: > Op maandag 20 januari 2014 10:17:15 UTC+1 schreef Alister: > > On Sun, 19 Jan 2014 20:04:05 -0800, Jean Dupont wrote: > > > > > Op zaterdag 18 januari 2014 16:12:41 UTC+1 schreef Oscar Benjamin: > > >> On 18 January 2014 14:52, Jean Dupont wrote: > > >> > > > >> > Thanks Peter and Terry Jan for the useful suggestions. One thing > > >> > which I > > >> >find a bit weird: when asking for Python-help concerning raspberry pi > > >> >code > > >> > or problems, a lot of people don't seem to be interested in helping > > >> > out, > > >> > that's of course their choice, but maybe they don't seem to be aware > > >> > the raspberry pi is often the motivation for starting to learn to > > >> > program in > > >> >Python. And as such such a reaction is a bit disappointing. > > >> Hi Jean, > > >> What makes you say that? Did you previously ask questions about > > >> Rasberry Pi code on this list? > > > It was not about code but about python-coding in IDLE (that's the > > > default on raspbian): > > > I started a thread "[newbie] starting geany from within idle does not > > > work" both here and in the raspberry pi forum. I just wondered why I > > > never got an answer concerning that topic. > > > > > >> If you did I wouldn't have answered those questions because I've never > > >> used a Raspberry Pi and know nothing about them (except that they > > >> encourage using Python somehow). I think that there's actually a list > > >> that is specifically for Raspberry Pi Python questions that might be > > >> more helpful although I don't know what it is... > > > Here is the url to that forum > > > > > > http://www.raspberrypi.org/forum/ > > > > > > kind regards, > > > jean > > > > Personally use Geany stand alone and not under idle, pressing F5 should > > save & run the code you are currently editing. Would running under idle > > give any other benefits? > I don't know yet, but I just wanted to try out which of the following three > I'd like best: > 1. idle+leafpad > 2. idle+geany > 3. plain geany > > It's normal for a newbie to start with (1) as that is the default on raspbian, > however I still don't understand why (2) does not work... I finally found out where I was wrong: leafpad is _not_ the default choice in IDLE, IDLE has its own built in editor and IDLE does not allow to use another editor. The confusion stemmed from the properties I got when right clicking on the IDLE-icon on the raspbian desktop, which shows "Open with" and then suggests the default choice is Leafpad and Geany as a second choice, it has however nothin to do with IDLE as such. kind regards, jean -- https://mail.python.org/mailman/listinfo/python-list
Re: Help: python 3.3.3 (AMD64) scripts fail as non-admin user on Windows Server 2012 R2
On 26/01/2014 22:30, Luis Marsano wrote: > I've installed python for all users with full permissions to all users > (see picture). > Python runs for all users. > However, scripts only work when I run as Administrator. > Running a script always results in an "ImportError: cannot import name" error. As Steven's pointed out, this looks more like a Windows permissions issue. However, it would still be worth identifying what's going on, as I haven't run Python on a 2012 box (and I doubt if many other people have either). I'm getting a VM run up to try it out but that will take a while. It may be that some hardened security is preventing Python from reading its own files. Could you, please, do the simplest of imports which fails, and post the traceback from the console in its entirety? (In other words, something like this): """ Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import willnotimport Traceback (most recent call last): File "", line 1, in ImportError: No module named 'willnotimport' >>> """ It would be good to know whether *anything* imports, ie whether stdlib imports work, or whether it's just user-installed modules. Thanks TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
me wrote: Not me, you ;) > Since this code is for a personal research project I'm not as concerned > about code quality as I would be if I was getting paid to write > production code...and if it was production code I'd only prototype a > proof-of-concept in python and then rewrite in c++. Another way to improve code quality is to write less code yourself and instead to rely on well-tested libraries: import argparse parser = argparse.ArgumentParser() parser.add_argument("-d", "--basedir", default="/process") parser.add_argument("-i", "--inpipe", default="/tmp/TCdaemonIN") parser.add_argument("-#", "--maxjobs", type=int, default=8) parser.add_argument("-o", "--outpipe", default="/tmp/TCdaemonOUT") print parser.parse_args() Seriously, code quality doesn't magically improve by a switch of language. You may make fewer newbie errors in C++, but once you get over the instinctive "Ducktype and unit tests? I'll do it with these three undebuggable templates and get type checks for free from the compiler." the simpler and often more concise Python solutions will start to pay off. -- https://mail.python.org/mailman/listinfo/python-list
Re: Lists inside dictionary and how to look for particular value
mick verdu wrote: > ThanK you. It solved my problem. > Can someone tell me how can i print particular value inside list of key. > > I know how to print J['PC2'][1] means will print IP. but I want the user > to input some element and I will print element just before that element. > > e.g. if user inputs 192.168.0.2, program will print 02:02:02:02:02:02. > If user inputs 192.168.0.1 I will print 01:01:01:01:01:01. IP_INDEX = 1 MAC_INDEX = 0 record = J["PC2"] def is_ip(s): return "." in s def is_mac(s): return ":" in s s = raw_input("Enter MAC or IP: " if is_mac(s): print record[IP_INDEX] elif is_ip(s): print record[MAC_INDEX] else: print "not a MAC or IP" You can of course replace the is_ip() and is_mac() implementation with better ones. -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Mon, Jan 27, 2014 at 6:44 PM, me wrote: > On Sun, 26 Jan 2014 23:17:29 -0800, Ethan Furman wrote: > >> On 01/26/2014 10:46 PM, me wrote: >>> >>> [...] I'm satisfied that the except: syntax yields undefined behavior, >>> and in my mind it shouldn't be >>> syntactically allowed then. >> >> Two points: >> >>1) Python is not C++ >> >>2) You asked for help; you received it. Coming back >> with an attitude of "Python must be broken, I'll work around it" >> is going to quickly lose you the support of those willing to help >> again. > > > Whatever...lighten up dude! When you use a language, you should be working with it, not fighting against it. It doesn't do to complain that REXX ought to have IEEE floating-point semantics, or that 8086 assembly language really would benefit from a native hashtable type. Python works a certain way, and part of that is its use of exceptions - which are integral to the language, rather than being (as in C++) somewhat tacked-on. Assuming that anything that isn't the way you expect it is inherently broken, and saying so on a mailing list, is a good way to alienate those who are offering you help for no reimbursement... and "lighten up dude" doesn't help. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Mon, 27 Jan 2014 20:01:33 +1100, Chris Angelico wrote: > On Mon, Jan 27, 2014 at 6:44 PM, me wrote: >> On Sun, 26 Jan 2014 23:17:29 -0800, Ethan Furman wrote: >> >>> On 01/26/2014 10:46 PM, me wrote: [...] I'm satisfied that the except: syntax yields undefined behavior, and in my mind it shouldn't be syntactically allowed then. >>> >>> Two points: >>> >>>1) Python is not C++ >>> >>>2) You asked for help; you received it. Coming back >>> with an attitude of "Python must be broken, I'll work around it" >>> is going to quickly lose you the support of those willing to >>> help again. >> >> >> Whatever...lighten up dude! > > When you use a language, you should be working with it, not fighting > against it. It doesn't do to complain that REXX ought to have IEEE > floating-point semantics, or that 8086 assembly language really would > benefit from a native hashtable type. Python works a certain way, and > part of that is its use of exceptions - which are integral to the > language, rather than being (as in C++) somewhat tacked-on. Assuming > that anything that isn't the way you expect it is inherently broken, and > saying so on a mailing list, is a good way to alienate those who are > offering you help for no reimbursement... and "lighten up dude" doesn't > help. > > ChrisA You feel better now that you too have vented? I had a productive discussion with a couple of top level posters who helped me solve my problem and they receive appropriate kuddos. Now it seems that some lonely individuals who maybe just want some attention are coming out of the woodwork. The thread is done so lets give it a rest. The condescending attitude about proper USENET tech help is just as annoying as perhaps my "opinions" seem. If someone is so sensitive as to not be able to discuss a technical matter without making it personal or seeing it as an attack against their religion then I neither want nor need their input. There are plenty of technical resources in the world that don't require idol worship. Regards -- https://mail.python.org/mailman/listinfo/python-list
Re: Highlighting program variables instead of keywords?
Skip Montanaro writes: > I think this might have value, especially if to could bounce back and forth > between both schemes. Is anyone aware of tools like this for Python? Bonus > points for pointers to an Emacs implementation. There has been a recent thread on some emacs group about this. Dunno how far it has gone wrt Python support, but the following mode appeared in MELPA archives in the last couple of days: https://github.com/ankurdave/color-identifiers-mode hth, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
O > My python stuff is all rapid application development for personal > projects. If I need to do anything serious I take the time to do it in > C+ > +. Many people "Prototype" in python & then re-factor into a compiled language later if needed (often it turns out there is not really any need :-) ) > > It's the intendation specific requirements that throw me. I haven't > seen such a hork since RPG. ;^) > But i bet you almost certainly indent your C++ cod in a similar manor on a voluntary basis, don't worry you will soon get used to it & quite probably start to like it. -- Hempstone's Question: If you have to travel on the Titanic, why not go first class? -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On 2014-01-27, me wrote: > The thread is done so lets give it a rest. The condescending > attitude about proper USENET tech help is just as annoying as > perhaps my "opinions" seem. If someone is so sensitive as to > not be able to discuss a technical matter without making it > personal or seeing it as an attack against their religion then > I neither want nor need their input. There are plenty of > technical resources in the world that don't require idol > worship. Oh, it's all right. I'm sure that we can handle this situation maturely, just like the responsible adults that we are. Isn't that right, Mr... Poopy-Pants? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On Monday, 27 January 2014 00:24:11 UTC-5, Dave Angel wrote: > matt.s.maro...@gmail.com Wrote in message: > > > School assignment is to create a tab separated output with the original > > given addresses in one column and then the addresses split into other > > columns (ex, columns for city, postal code, street suffix). > > > > > > Here is my code: > > > > > > inHandler = open(inFile, 'r') > > > outHandler = open(outFile, 'w') > > > outHandler.write("FarmID\tAddress\tStreetNum\tStreetName\tSufType\tDir\tCity\tProvince\tPostalCode") > > > for line in inHandler: > > > str = line.replace("FarmID\tAddress", " ") > > > outHandler.write(str[0:-1]) > > > > > > str = str.replace(" ","\t", 1) > > > str = str.replace(" Rd, ","\tRd\t\t") > > > str = str.replace("Rd ","\tRd\t\t") > > > str = str.replace("Ave, ","\tAve\t\t") > > > str = str.replace("Ave ","\tAve\t\t") > > > str = str.replace("St ","\tSt\t\t") > > > str = str.replace("St, ","\tSt\t\t") > > > str = str.replace("Dr, ","\tDr\t\t") > > > str = str.replace("Lane, ","\tLane\t\t") > > > str = str.replace("Pky, ","\tPky\t\t") > > > str = str.replace(" Sq, ","\tSq\t\t") > > > str = str.replace(" Pl, ","\tPl\t\t") > > > > > > str = str.replace("\tE, ","E\t") > > > str = str.replace("\tN, ","N\t") > > > str = str.replace("\tS, ","S\t") > > > str = str.replace("\tW, ","W\t") > > > str = str.replace(",\t","\t\t") > > > str = str.replace(", ON ","\tON\t") > > > > > > outHandler.write(str) > > > > > > inHandler.close() > > > outHandler.close() > > > > > > > > > Here is some sample addresses, there are over 100: > > > > > > FarmID Address > > > 1 1067 Niagara Stone Rd, Niagara-On-The-Lake, ON L0S 1J0 > > > 2 4260 Mountainview Rd, Lincoln, ON L0R 1B2 > > > 3 25 Hunter Rd, Grimsby, ON L3M 4A3 > > > 4 1091 Hutchinson Rd, Haldimand, ON N0A 1K0 > > > 5 5172 Green Lane Rd, Lincoln, ON L0R 1B3 > > > 6 500 Glenridge Ave, St. Catharines, ON L2S 3A1 > > > 7 471 Foss Rd, Pelham, ON L0S 1C0 > > > 8 758 Niagara Stone Rd, Niagara-On-The-Lake, ON L0S 1J0 > > > 9 3836 Main St, Lincoln, ON L0R 1S0 > > > > > > > > > > > > I have everything worked out, except that the final output places the > > farmID at the end of postal code as seen in the example below (notice the > > brackets showing where the farmID is placed): > > > > > > FarmID Address StreetNum StreetName SufType Dir City > > ProvincePostalCode > > > 1 1067 Niagara Stone Rd, Niagara-On-The-Lake, ON L0S 1J0(1) 1067 > > Niagara Stone Rd Niagara-On-The-Lake ON L0S 1J0 > > > > > > Any ideas on how to fix this? Keep in mind as well that the farmID will > > have 2 characters at a certain point. > > > > > > > Your specific concern is triggered by having two writes in the loop. > > > > Get rid of the first and you're marginally closer. > > > > But really, you've got much bigger troubles. All those > > unrestricted replace calls are not at all robust. But maybe > > you'll get away with it for a school assignment if the test data > > is very limited. > > > > Better would be to treat it like a parsing problem, figuring what > > delimiter rule applies to each field, and building a list Then > > use str.join to build the line for the outHandler. > > > > > > -- > > DaveA The code that I used is the proper way that we were supposed to complete the assignment. All I need now is an 'if...then' statement to get rid of the unwanted FarmID at the end of the addresses. I just don't know what will come after the 'if' part. -- https://mail.python.org/mailman/listinfo/python-list
Re: Unwanted Spaces and Iterative Loop
On 27/01/2014 01:58, matt.s.maro...@gmail.com wrote: On Sunday, 26 January 2014 20:56:01 UTC-5, Chris Angelico wrote: On Mon, Jan 27, 2014 at 12:15 PM, wrote: I`m not reading and writing to the same file, I just changed the actual paths to directory. For next time, say "directory1" and "directory2" to preserve the fact that they're different. Though if they're file names, I'd use "file1" and "file2" - calling them "directory" implies that they are, well, directories :) ChrisA Thanks, but any chance you could help me out with my question of removing the FarmID from the postal code? Any chance that you could read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing above? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Highlighting program variables instead of keywords?
On 27/01/2014 01:46, Skip Montanaro wrote: What it is doing is color coding user-supplied identifiers, with different color for each one. I found that confusing to read. I think it would take some time to get used to, and I don't think it would be the only way I'd like to view my program. I think an interactive pylint (or pyflakes or frosty) type capability would be useful, highlighting a subset of the messages it produces, like variables which were assigned but never used, or using undefined variables. It might be best supported by actually running the checker in the background, then using its messages to direct where to highlight suspect bits of code. Skip Pydev uses pylint interactively, must have saved me hours by flagging up (potential) problems up as I type. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On 27/01/2014 07:17, me wrote: My python stuff is all rapid application development for personal projects. If I need to do anything serious I take the time to do it in C+ +. For me at least you'll fit in extremely well here with a sense of humour like that. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: [RELEASED] Python 3.3.4 release candidate 1
On 27/01/2014 07:36, Georg Brandl wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team, I'm reasonably happy to announce the Python 3.3.4 release candidate 1. "Reasonably" happy? Is there a smiley missing there, or what? :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On Mon, 27 Jan 2014 05:32:08 -0800, matt.s.marotta wrote: > The code that I used is the proper way that we were supposed to complete > the assignment. All I need now is an 'if...then' statement to get rid > of the unwanted FarmID at the end of the addresses. I just don't know > what will come after the 'if' part. Show us what you do know. If you don't know the "if", what about the "then"? if : do what? What do you intend to do inside the if? Under what circumstances would you do it? If you can answer those questions in English, then we can help you write code to do it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Mon, 27 Jan 2014 09:32:43 +, some guy who calls himself "me" wrote: > On Mon, 27 Jan 2014 20:01:33 +1100, Chris Angelico wrote: > >> On Mon, Jan 27, 2014 at 6:44 PM, me wrote: >>> On Sun, 26 Jan 2014 23:17:29 -0800, Ethan Furman wrote: >>> On 01/26/2014 10:46 PM, me wrote: > > [...] I'm satisfied that the except: syntax yields undefined > behavior, > and in my mind it shouldn't be > syntactically allowed then. Two points: 1) Python is not C++ 2) You asked for help; you received it. Coming back with an attitude of "Python must be broken, I'll work around it" is going to quickly lose you the support of those willing to help again. >>> >>> >>> Whatever...lighten up dude! >> >> When you use a language, you should be working with it, not fighting >> against it. It doesn't do to complain that REXX ought to have IEEE >> floating-point semantics, or that 8086 assembly language really would >> benefit from a native hashtable type. Python works a certain way, and >> part of that is its use of exceptions - which are integral to the >> language, rather than being (as in C++) somewhat tacked-on. Assuming >> that anything that isn't the way you expect it is inherently broken, >> and saying so on a mailing list, is a good way to alienate those who >> are offering you help for no reimbursement... and "lighten up dude" >> doesn't help. >> >> ChrisA > > You feel better now that you too have vented? I had a productive > discussion with a couple of top level posters who helped me solve my > problem and they receive appropriate kuddos. Now it seems that some > lonely individuals who maybe just want some attention are coming out of > the woodwork. A word to the wise: Chris is one of the most frequent and helpful posters here. So is Ethan. Both of them know what they're talking about, so when they give you advice, you could do a lot worse than to listen. Some examples of "a lot worse": you could arrogantly dismiss them by saying "whatever". Or you could make assumptions about their personal lives ("lonely individuals"). [Aside: you seem to be making a habit of jumping to wrong conclusions based on incorrect and illogical interpretations of minimal evidence. That's a poor habit to get into, and especially poor for a programmer.] > The thread is done so lets give it a rest. The condescending attitude > about proper USENET tech help is just as annoying as perhaps my > "opinions" seem. If someone is so sensitive as to not be able to > discuss a technical matter without making it personal or seeing it as an > attack against their religion then I neither want nor need their input. > There are plenty of technical resources in the world that don't require > idol worship. What does idol worship have to do with anything? Oh wait, do you think Ethan and Chris are pissed off because you're not genuflecting at Python's awesomeness? That's another comically wrong conclusion. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Monday, January 27, 2014 3:32:43 AM UTC-6, me wrote: > On Mon, 27 Jan 2014 20:01:33 +1100, Chris Angelico wrote: > > [snip chris reply] > > You feel better now that you too have vented? I had a > productive discussion with a couple of top level posters > who helped me solve my problem and they receive > appropriate kuddos. Now it seems that some lonely > individuals who maybe just want some attention are coming > out of the woodwork. You can kindly ignore Chris, he is just one of our well known *resident* "lonely individuals", seeking attention yet again! And his constant blabbing about and idol worship of REXX is more annoying than all of xah lee post combined, however, i do just enjoy watching him "casually" weaving in those examples as though he does not have an agenda to push. @Chris: Two can play at this game! -- https://mail.python.org/mailman/listinfo/python-list
Re: Highlighting program variables instead of keywords?
On 01/26/2014 06:54 PM, Roy Smith wrote: Chris Angelico wrote: That said, though, I grew up without syntax highlighting of any sort, and didn't think it particularly important; but now that I have editors with all those sorts of features, I do find them handy. Same here, except I'd replace "find them handy" with "totally addicted to". +1000 -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Tue, Jan 28, 2014 at 2:33 AM, Rick Johnson wrote: > You can kindly ignore Chris, he is just one of our well > known *resident* "lonely individuals", seeking attention yet > again! And his constant blabbing about and idol worship of REXX is > more annoying than all of xah lee post combined, however, i > do just enjoy watching him "casually" weaving in those > examples as though he does not have an agenda to push. > > @Chris: Two can play at this game! Heh. If you'd said Pike instead of REXX, I might have believed you :) I've said more about Pike than is perhaps appropriate, but of late, I've actually not been the one to most often quote REXX code. Actually, REXX as a language has been majorly left behind. Back in the early 1990s it was blessed with support for non-English text in the form of DBCS (at least, the OS/2 REXX implementation was - don't know how standard that was), but then nobody ever went in and made it all Unicode instead, so now we have a bytes-only language. Has its coolnesses, but far too much of it is done with language magic (eg the PARSE statement - there's no way to interact with that, no way to make anything dynamic, so even though it is, in many ways, much cleaner than C's sscanf or Perl's regular expressions, it's just plain impossible to extend). Still, it was my first taste of arbitrary-precision arithmetic, and for that (and plenty more) I am well appreciative. Frankly, I don't "idol worship" *any* language. There is not a single language that I've ever used which has no flaws. And I can't think of any language with which I have no fundamental disagreements on major design points. (Note that there's a difference between those two. Flaws are objective (and I'm not talking about bugs, I'm talking about stuff where the author agrees that it's wrong but it's too late to change now), design disagreements are personal. For instance, I personally believe that disallowing assignment-as-expression cuts out more value than it gains by preventing bugs (as we've seen lately, people can just get it wrong the other way, comparing as a statement), but I respect Guido's decision on that and don't see it as a problem to be fought. A lot of Python's worst flaws were fixed in 3.x (input() -> eval(), print as a statement, etc), but there are still a few oddities that can't easily be fixed. They don't stop the language from being useful and awesome. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: [RELEASED] Python 3.3.4 release candidate 1
On Jan 27, 2014, at 8:55 AM, Mark Lawrence wrote: > On 27/01/2014 07:36, Georg Brandl wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> On behalf of the Python development team, I'm reasonably happy to announce >> the >> Python 3.3.4 release candidate 1. >> > > "Reasonably" happy? Is there a smiley missing there, or what? :) > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what you > can do for our language. > > Mark Lawrence I'm guessing it is an editorial comment about Mac users/developers. But maybe I'm being defensive... ;-) -Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On Tue, Jan 28, 2014 at 2:03 AM, wrote: > On Monday, 27 January 2014 09:57:32 UTC-5, Chris Angelico wrote: >> On Tue, Jan 28, 2014 at 1:23 AM, wrote: >> >> > If the farmID < 10: >> > remove one character from the address column >> > Elif farmID > 10: >> > remove two characters from the address column >> >> What if farmID == 10? >> >> ChrisA > > Ok, sorry this is how it should be. > > If the FarmID < 10: > remove one character from the address column > > If the FarmID > 9: > remove two characters from the address column > > My issue is I can't figure out what statement to use to define FarmID. More commonly, that would be written as if farmID < 10: # remove one character else: # remove two characters Though this still suffers from the limitation of not handling 100 or 1000, so you might want to look at len(str(farmID)) instead. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On Monday, 27 January 2014 08:54:20 UTC-5, Steven D'Aprano wrote: > On Mon, 27 Jan 2014 05:32:08 -0800, matt.s.marotta wrote: > > > > > The code that I used is the proper way that we were supposed to complete > > > the assignment. All I need now is an 'if...then' statement to get rid > > > of the unwanted FarmID at the end of the addresses. I just don't know > > > what will come after the 'if' part. > > > > Show us what you do know. If you don't know the "if", what about the > > "then"? > > > > > > if : > > do what? > > > > > > What do you intend to do inside the if? Under what circumstances would > > you do it? > > > > If you can answer those questions in English, then we can help you write > > code to do it. > > > > > > -- > > Steven If the farmID < 10: remove one character from the address column Elif farmID > 10: remove two characters from the address column -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On Tue, Jan 28, 2014 at 1:23 AM, wrote: > If the farmID < 10: > remove one character from the address column > Elif farmID > 10: > remove two characters from the address column What if farmID == 10? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On Monday, 27 January 2014 09:57:32 UTC-5, Chris Angelico wrote: > On Tue, Jan 28, 2014 at 1:23 AM, wrote: > > > If the farmID < 10: > > remove one character from the address column > > Elif farmID > 10: > > remove two characters from the address column > > What if farmID == 10? > > ChrisA Ok, sorry this is how it should be. If the FarmID < 10: remove one character from the address column If the FarmID > 9: remove two characters from the address column My issue is I can't figure out what statement to use to define FarmID. -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On 27/01/2014 14:23, matt.s.maro...@gmail.com wrote: On Monday, 27 January 2014 08:54:20 UTC-5, Steven D'Aprano wrote: On Mon, 27 Jan 2014 05:32:08 -0800, matt.s.marotta wrote: The code that I used is the proper way that we were supposed to complete the assignment. All I need now is an 'if...then' statement to get rid of the unwanted FarmID at the end of the addresses. I just don't know what will come after the 'if' part. Show us what you do know. If you don't know the "if", what about the "then"? if : do what? What do you intend to do inside the if? Under what circumstances would you do it? If you can answer those questions in English, then we can help you write code to do it. -- Steven If the farmID < 10: remove one character from the address column Elif farmID > 10: remove two characters from the address column Would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing above, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On 27/01/2014 15:53, Chris Angelico wrote: Frankly, I don't "idol worship" *any* language. I worship English because it's so easy to learn. Ducks and runs :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Mon, Jan 27, 2014 at 1:17 AM, me wrote: > It's the intendation specific requirements that throw me. I haven't seen > such a hork since RPG. ;^) Best I can tell, the only thing RPG and Python have in common is the fact that they're "programming languages", though I'm being a little generous to RPG there. I'll note that RPG (IV) is the only language I've ever been formally trained in, unfortunately. I've mostly forgotten it though, so that's a plus :) Python's significant indentation is really quite nice and intuitive. The basic rule of thumb is if a line ends in a colon, the next line needs to be indented one more level. If you're continuing the same logical block, keep the same indention level. When a logical block is finished (whether by a raise, continue, break, or return statement, or just by "falling off the end" of the block), indent the next line one level less. Parentheses () (and brackets [] and braces {}) create what amounts to a 'virtual line', \n characters are basically ignored until the closing parenthesis is found (as long as they aren't in a non-triple-quoted string literal). As long as you don't try to mix tabs and spaces for your indentation (either is fine on its own, but spaces are generally preferred), it's very straightforward and allows you to better see the flow of the program with no question as to whether there is anything hidden within a block. I've been using C more in the past two weeks than I really expected to all this year, and have been bitten more than once by missing braces. Indenting intentionally is just a much cleaner, clearer way to do things (in my opinion, of course). >> Also, you can iterate over a (sys.argv) in a for >> loop, replacing 'l', 'idx', and the while loop; something like >> >> for arg in a: >> if arg == '-h': >> print help # help being defined elsewhere... >> elif arg == '-hh': >> # no really, print help >> print 'help' > > Understood, except that some parameters take multiple elements...thus why > I manually reference the indexes. Try this on for size, then: a_iter = iter(a) for arg in a_iter: print('current', arg) if arg == '-#': print('next', next(a_iter)) > Yup. Every language and platform has multiple arg parsing libraries. > Didn't feel like taking the time to research any since most of my python > ramblings are usually pyQT4 bindings to QT4 gui and postgresql apps. As with most modules in the standard library, I would bet you can get started using argparse in probably 15 minutes or less. The online documentation of the language and standard library is already quite good, and there is constant effort going into improving it. You might also want to play around with the 'help()' function in the interactive interpreter, it may have answered your original question without ever having had to ask here: >>> help(sys.exit) Help on built-in function exit in module sys: exit(...) exit([status]) Exit the interpreter by raising SystemExit(status). If the status is omitted or None, it defaults to zero (i.e., success). If the status is numeric, it will be used as the system exit status. If it is another kind of object, it will be printed and the system exit status will be one (i.e., failure). > Pointing out that sys.exit() raises a low level exception was the point I > was missing. Thx! You're welcome, I'm glad I could help :) As a general reply to the 'attitude' portion of this thread: "mutual respect" is the name of the game here. If you show respect (whether you've already received it or not), you're likely to receive respect. If not, don't be surprised by heated responses. This applies equally to everyone, I'm not pointing fingers at anyone in particular. Regards, -- Zach -- https://mail.python.org/mailman/listinfo/python-list
EncodedFile/StreamRecoder
I'd never heard of these and personally have no use for them, but came across them here http://bugs.python.org/issue20405#msg209430 and thought they might be of use to some of you. Quoting from the message:- "The purpose of EncodedFile/StreamRecoder was to convert an externally used encoding to a standard internal one - mainly to allow programs that didn't want to use Unicode for processing to still benefit from the codecs that come with Python. E.g. the example at the end of codecs.py allows using Latin-1 within the application, while talking to the console using UTF-8." -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Remove unwanted characters from column
On Sun, 26 Jan 2014 19:49:01 -0800, matt.s.marotta wrote: > School assignment is to create a tab separated output with the original > given addresses in one column and then the addresses split into other > columns (ex, columns for city, postal code, street suffix). If you're trying to create fixed width output from variable width fields, format specifiers may be better to use than tabs. The problem with tabs is that columns end up misaligned when the data fields in a column contain a mixture of items of less length than the tab spacing and items of greater length than the tab spacing, unless you can work out the tab spacing and adjust accordingly. For example, my code which uses the re module to separate the various record components and a format specifier to print the text and html versions (and csvwriter for the csv) them creates the outputs seen here: http://www.sined.co.uk/tmp/farms.txt http://www.sined.co.uk/tmp/farms.csv http://www.sined.co.uk/tmp/farms.htm -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Mon, 27 Jan 2014 10:23:49 -0600, Zachary Ware wrote: >> Understood, except that some parameters take multiple elements...thus >> why I manually reference the indexes. > > Try this on for size, then: > > a_iter = iter(a) > for arg in a_iter: > print('current', arg) > if arg == '-#': > print('next', next(a_iter)) And check out add_argument's "nargs" option: http://docs.python.org/3/library/argparse.html#nargs HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On 27/01/2014 07:17, me wrote: It's the intendation specific requirements that throw me. I haven't seen such a hork since RPG. ;^) Programming with a rocket propelled grenade is vastly superior to programming in C++. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On 01/27/2014 02:32 AM, me wrote: > You feel better now that you too have vented? Sorry but the emotional intent you're reading in to Chris's post is completely misplaced. I don't know why you chose to be offended by it. Chris's comments about C++ are accurate, but not intended to be a personal affront to you. They are just statements of fact. -- https://mail.python.org/mailman/listinfo/python-list
Run python script with CMD error
Hi everyone; Im new with python and i just installed it and added it to the path.I have already a script that i want to execute(run) but every time i do this commend python > client.py in CMD to execute it,i got this error. Any solutions please? > File ", line 29 except Exception, e: ^ SyntaxError: invalid syntax -- https://mail.python.org/mailman/listinfo/python-list
Re: Run python script with CMD error
raed...@gmail.com wrote: > Hi everyone; > > > Im new with python and i just installed it and added it to the path.I have > already a script that i want to execute(run) but every time i do this > commend python > >> client.py > > in CMD to execute it,i got this error. Any solutions please? > >> File ", line 29 except Exception, e: ^ SyntaxError: invalid syntax It is important for us to know the version of Python you are using. In Python 3 the above line has to be written except Exception as e: If the script was not written by you instead of fixing all the incompatibilities that may occur you should download and install Python 2.7 and run the script with that. -- https://mail.python.org/mailman/listinfo/python-list
Re: Run python script with CMD error
Look at lines around 29 On Jan 27, 2014 2:45 PM, wrote: > Hi everyone; > > > Im new with python and i just installed it and added it to the path.I have > already a script that i want to execute(run) but every time i do this > commend python > > > client.py > > in CMD to execute it,i got this error. Any solutions please? > > > File ", line 29 except Exception, e: ^ SyntaxError: invalid syntax > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Run python script with CMD error
I m using Python 3.3 and the script is not written by me therefore i'm gonna try to install 2.7 instead and i will let you know the result. Thank you Peter -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Monday, January 27, 2014 9:53:37 AM UTC-6, Chris Angelico wrote: > Heh. If you'd said Pike instead of REXX, I might have > believed you :) I've said more about Pike than is perhaps > appropriate, but of late, I've actually not been the one > to most often quote REXX code. Yes in my haste to inject a jab at you i pulled the trigger before fully retracting the gun from my holster... OUCH! It was indeed "Pike" that i meant. But, although you *do* mention it quite a lot, i don't think mentioning any language should be off topic because heck, someone could learn something new. > [snip] > For instance, I personally believe that disallowing > assignment-as-expression cuts out more value than it gains > by preventing bugs (as we've seen lately, people can just > get it wrong the other way, comparing as a statement), I myself wish for such a Python feature -- but alas, we are but slaves to whims of the dutch! > but I respect Guido's decision on that and don't see it as > a problem to be fought. A lot of Python's worst flaws were > fixed in 3.x (input() -> eval(), print as a statement, > etc), I agree that those are flaws, but not enough of a flaw to break code. "input" is only used by neophytes, so who cares about breaking that one, but "print" is almost everywhere! But let's go back to "input" for a bit... Why do we even need an "input" function anyway if all it is going to do is read from stdin? Would not $stdin.read have been better choice? Or simply "read" if you're a global namespace pollution fanboy! Heck, if you're going to have a function for writing strings to $stdout, and also, you're going to have a function for reading strings from $stdin, then you need to recognize the diametric relation between these functions, and as such, your first design consideration should be to maintain a consistency between them input (reads a string from stdin) print (writes a string to stdout) It is my strong believe that defining an "input" method that "magically" evals the input string is just plain evil. Why you ask? Because doing so injects superfluous magic whist simultaneously blinding the noob to the fact that strings are the mutually inclusive love interest of both "Mrs.Input" and "Mr.Output". -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Tue, Jan 28, 2014 at 7:22 AM, Rick Johnson wrote: > maintain a consistency between them > > input (reads a string from stdin) > print (writes a string to stdout) > > It is my strong believe that defining an "input" method that > "magically" evals the input string is just plain evil. Fortunately, as of Python 3, that parallel is maintained. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: buggy python interpretter or am I missing something here?
On Mon, 27 Jan 2014 12:22:22 -0800, Rick Johnson wrote: > "input" is only used by neophytes, so who cares about breaking that one, > but "print" is almost everywhere! Heh heh heh, how very "Ranting Rick" to think that a function for listening to input is unimportant, while a function for spraying output all over the place is vital. > But let's go back to "input" for a bit... > > Why do we even need an "input" function anyway if all it is going to do > is read from stdin? That's not all it does. For example, it handles backspacing, so that typing H E L O O BACKSPACE BACKSPACE L O gives "HELLO" rather than "HELOO\x7f\x7fO". Of course, somebody as awesome as Rick will have never made a mistake in his life, but for the rest of us mere mortals, that feature alone makes a dedicated input function worthwhile. But there's more! On systems with readline, not only does input handle backspacing, but it handles all sorts of editing functionality, such as arrow keys and various editing commands. So typing A LEFT-ARROW B gives "BA" rather than "A\x1b[DB". input also provides visual feedback while you type, an optional prompt, handling of newlines, buffering, and possibly more. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Highlighting program variables instead of keywords?
Skip Montanaro wrote: > My son sent me a link to an essay about highlighting program data instead > of keywords: > > https://medium.com/p/3a6db2743a1e/ > > I think this might have value, especially if to could bounce back and > forth between both schemes. Is anyone aware of tools like this for Python? AFAIK kdevelop support this. http://kdevelop.org/sites/kdevelop.org/files/photos/kdev_python_1.png -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Need help with pushing technology ... and a bit more ...
Background: === We are studying the possibility of creating a system that will have the following entities: Customer(s) (appCustomer) Service Provider(s) (appProviders) and Manager(s) Server(s) appCustomers will have all appServices available to them and appServices will have at least one appManager and zero to many appServers. Each one of these entities will run an application on android, ios and windoze phone at least, as well as (hopefully) linux, osx and windoze (these last three are needed for appManagers) An appCustomer will use either an application or a given web site to request services via HTTP from the available appProviders. Our system should immediately upon receiving this order, notify all involved appManagers and appServers, report back to appCustomer who got notified of his/her request. appManagers and appServers will interact with the system via applications in order to notify appCustomer/appManager(s) of any progress in serving the appService, until its completion. All notification must be logged so that anyone involved in a given appService can check all activity and, for example, to allow appManagers to supervise the completion of a given appService request. Reading the previous explanation I notice this is pretty much your common “Purchase Order System” except we need real time, bullet proof communications between all players, along with the possibility of SMS and mail capabilities as well as logs for all communication media. Our system is to go live immediately with one (paying) customer representing around 100 appCustomers. We are expecting the live system to produce anywhere between 500 to 2000 notifications per day which is not a lot but (expected) growth will be exponential and might reach about a million notifications in about a year or two. Observations: = I'd like to keep this project python/C/C++ only, or at least as much as possible. I'm not a seasoned python/C/C++ programmer though; but I'm in l.o.v.e. with python and C and C++. I understand even less about communications and I know I have to use some way to push all notifications, but I have not been able to find a solution that will work on all needed platforms (android, ios, windows phone, linux, osx and windows). I wouldn't mind using two or three different push technologies if that was the case but: Questions: == Isn't there a better way to push notifications? Do I forcibly have to use a service such as “Urban Airship”, “Pushwoosh”, “Amazon SNS”, “Windows Azure Notification Hubs”, “Pushover”, “Prowl” or “Notify My Android”?? Would it be possible to build our own push service by using a combination of telnet, xmlrpc, websockets or xmpp along with twisted, tornado or gevent; living along with django and possible mezzanine in my “perfect python world”? Am I asking too much or am I so lost I don't even make sense? I've been reading about all these topics/products in the las couple of days and every line I read seems to get me the more confused... When I was initially involved in this idea I thought it was all about finding a nice library for a good real time communications protocol (https://groups.google.com/forum/#!topic/django-users/vZQ3C4DS73g) but, as I said before; I know nothing about communications and in spite of all the good intentions of those answering that post; I am yet to make sense of everything. I do not ask for a solution to my situation but at least some light as to what might be a good path to follow … I will make sure you confess a solution once I figure out what are you talking about :) I will really appreciate and and all comments, ideas and recommendations … even epithets! Thanks a lot in advanced! Mario R. Osorio -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with my 8-year old son's first program. I'm stuck
First, forget about the def a() statement. def is for defining a function and this is not a function. Second, research the difference between == (logical test) and = (assignment operator). Third, take a look at the length of "op" just after the readline(). You can add a line that says print(len(op)) right after the readline to see what's goingon. There's a new line character in there. Try using op = op.strip() before you do all the if statements. That will remove the trailing newline, and change the first test back to op == "d". Hope this helps. John >PS: At the first statement, we've also tried >op == "d": >But that doesn't work either. >On Saturday, January 25, 2014 10:02:15 AM UTC, justinp...@gmail.com wrote: >> My son is learning Python and I know nothing about computers. >> >> He's written a simple calculator program that doesn't work. For the life of >> me, I can't see why. >> --= Posted using GrabIt = --= Binary Usenet downloading made easy =- -= Get GrabIt for free from http://www.shemes.com/ =- -- https://mail.python.org/mailman/listinfo/python-list
Web service in Python
I installed rapidsms in local for send messages. The application tested with local server. Now i would like to store the incoming messages in another database via a php application. Means when a message received in rapidsms (Django-Python) app, i want to call a php application function and store message in php app database. For this which method is best? Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Highlighting program variables instead of keywords?
Different, but a little bit related. The work which is done actually on the possibility (not implemented but alreay realized) to colorize (style") the different graphemes of a glyph is very interesting. Python with its absurd Flexible String Representation just become a no go for the kind of task. (Should not be too complicate to understand.) jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: Web service in Python
yiitest...@gmail.com writes: > I installed rapidsms in local for send messages. The application tested with > local server. Now i would like to store the incoming messages in another > database via a php application. Means when a message received in rapidsms > (Django-Python) app, i want to call a php application function and store > message in php app database. For this which method is best? As you describe your wishes (the description could be a bit more precise), the web service would not be in Python but in PHP. When your PHP application would provide a SOAP/WSDL webservice, then you could use a Python webservice client, e.g. "suds", to interface with such a webservice. When your PHP application would provide a REST webservice, other Python libraries ("urllib", "json", ...) could be used. Details much depend on the kind of webservice provided by the PHP application. In typical case, I find the approach a bit convoluted. In those cases, the Python application would directly store the messages in the database - not send them to a second web service for storing. But, there are cases where the approach may make sense - e.g. when there is already such a second web service (which just needs to be used). -- https://mail.python.org/mailman/listinfo/python-list
Re: Need Help with Programming Science Project
On 24/01/2014 8:05 PM, theguy wrote: I have a science project that involves designing a program which can examine a bit of text with the author's name given, then figure out who the author is if another piece of example text without the name is given. This sounds like exactly the sort of thing NLTK was made for. Here's an example of using it for this requirement: http://www.aicbt.com/authorship-attribution/ -- https://mail.python.org/mailman/listinfo/python-list