Re: [Tutor] HI, #Include like in python
wesley chun wrote: import listen You can use the __import__ function if you want, but generally you want the import statement as above. The equivalent to 'import listen' is: listen = __import__('listen') See the tutorial here: http://docs.python.org/tutorial/modules.html you also have to make sure that your .py file is in one of the folders/directories listed in sys.path (to see it, import sys then do print sys.path). if the file is not in one of those folders, you will also get an import error. you can either add the correct directory to your PYTHONPATH environment variable, or manually add it at run-time using sys.path.append/insert. A simpler form is to put "listen.py" and "usbconnection.py" in the same directory. In the latter you can do something like import listen listener = listen.ListenClass(param1, param2) listener.begin() # Call the 'begin' method of the ListenClass object. You can use the ListenClass like normal, just state that Python should look for it in the "listen" file. Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
"Wayne Watson" wrote What is meant by "The arguments are the same as for the Popen constructor.", in Convenience Functions? In fact, what is such a function? It means that there is a function which takes the same arguments as the __init__() method of the Popen class. They are convenience functions in that you don't need to create the class to use them you can just call them directly. THe payoff is that you lose some of the flexibility of using the class, but often you don;t need that. class subprocess.Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False Why not just class Popen instead of subprocess.Popen? The notation is saying that there is a class defined in the subprocess module called Popen with a constructor that has the listed parameters. It is just a shorthand way of expressing that. In practice you would create an instance with either: import subprocess p = subprocess.Popen() OR from subprocess import Popen p = Popen() Is there a suggestion here that I need only do: from subprocess import Popen myProg=Popen() myProg.call("wolf", "-h") Even simpler, you only need: from subprocess import call myProg = call(["wolf", "-h"]) You need to put the command as the first entry of a list and each argument as a separate entry HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trouble parsing email from Outlook
Eduardo Vieira wrote: Hello, list! I hope it's not too much out of place to ask this question in the Tutor list. I'm trying to process some information from email messages that goes in a folder called: "SysAdmin". I could reproduce the recipe from Python Programming on Win32 sucessfully to read the subject line of the inbox, but not from a different folder: It can be a bit confusing working out even what to search for, and there are a few things which are similar but subtly different. Ignoring more esoteric possibilities, there are three main ways to do automatic things with Outlook / Exchange emails, all of which are feasible from Python + pywin32/ctypes/comtypes. 1) COM -> CDO ("MAPI.Session") -- that's what you're doing. Altho' technically this is using Exchange rather than Outlook, you basically need Outlook installed for this to work. 2) COM -> Outlook ("Outlook.Application") -- this is very similar to CDO but gives you a few things which are tied to Outlook rather than to the Exchange server. 3) COM -> MAPI -- this is a slightly lower-level Win32 API set which is exposed in pywin32 through the slightly confusing set of modules under win32comext/mapi Of course it's all very confusing because the CDO CLSID above uses the word "MAPI" (as it presumably calls MAPI functions under the covers) while there's another thing called CDONT which is/was a cut-down version of CDO and which you still come across from time to time. So far my code is this: import win32com.client ses = win32com.client.Dispatch("Mapi.Session") o = win32com.client.Dispatch("Outlook.Application") OK, now you've confused yourself. You don't need to use *both* Outlook automation *and* CDO automation. Just pick one. Let's go with CDO since that's effectively what you've done. ses.Logon("Default") print ses.Inbox.Messages.Item(1).Subject Right, because the Inbox is a well-known special case, you get an easy reference to it from the CDO session itself. To find other folders, you either have to walk the tree of folders if you know where to look, or to iterate over them if you just know it's there somewhere but can't guarantee where. The topmost things in a CDO Session is one or more InfoStores. You can't iterate over them directly; you have to loop over their count. Note that they are counted from 1 upwards, while the Python loop is 0-based: for i in range (len (ses.InfoStores)): info_store = ses.InfoStores[i+1] print info_store.Name If you already know the name of the one you want, eg "Mailbox - Tim Golden", you can select that one: mailbox = ses.InfoStores["Mailbox - Tim Golden"] The infostore has a RootFolder which is a CDO Folder object and once you've got that, you can just walk the tree of folders. The key collections you'll be interested in are the Folders and Messages. They can both be iterated the same way, and the function below provides a Pythonish wrapper: def cdo_iter (cdo_collection): item = cdo_collection.GetFirst () while item: yield item item = cdo_collection.GetNext () Each Folder may have a Folders attribute and a Messages attribute. To walk a tree or subtree, you can do this, making use of the function above: def cdo_walk (folder): ## can be the RootFolder or a specific folder try: folders = cdo_iter (folder.Folders) except AttributeError: folders = [] try: items = cdo_iter (folder.Messages) except AttributeError: items = [] yield folder, folders, items for subfolder in folders: for r in cdo_walk (subfolder): yield r Note that, because we're using generators, the sublists of folders and items are generated lazily. If, as in the case we're getting to, you don't need to look at messages until you've got to the folder you want, then you just don't iterate over the items iterable. Putting it together, you can find a folder called "SysAdmin" from a CDO session like this: import os, sys import win32com.client def cdo_iter (cdo_collection): item = cdo_collection.GetFirst () while item: yield item item = cdo_collection.GetNext () def cdo_walk (folder): try: folders = cdo_iter (folder.Folders) except AttributeError: folders = [] try: items = cdo_iter (folder.Messages) except AttributeError: items = [] yield folder, folders, items for subfolder in folders: for r in cdo_walk (subfolder): yield r class x_found (Exception): pass if __name__ == '__main__': session = win32com.client.gencache.EnsureDispatch ("MAPI.Session") session.Logon () try: for i in range (session.InfoStores.Count): info_store = session.InfoStores[i+1] # # Ignore Public Folders which is very big # if info_store.Name == "Public Folders": continue print "Searching", info_store.Name for folder, folders, items in cdo_walk (info_store.RootFolder): if folder.Name == "SysAdmin": for item in items: print item.Subject raise x_found except x_found: pass TJG ___
[Tutor] statistics with python
Dear python friends, someone kindly suggest me packages, modules and documentation resources (especially) to i) plot graphs using python. ii) statistical analysis using python. Thanks in advance, Bala ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] statistics with python
On Fri, Mar 20, 2009 at 6:45 AM, Bala subramanian wrote: > Dear python friends, > > someone kindly suggest me packages, modules and documentation resources > (especially) to > > i) plot graphs using python. > matplotlib is excellent and probably the most popular > > ii) statistical analysis using python. > > Your best bet is probably using the python binding for R ( http://rpy.sourceforge.net/). This also lets you use R's powerful graphing capability. Scipy.org also has some statistics packages, but nothing as complete as you can get with R. > > Thanks in advance, > Bala ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Wayne Watson wrote: Good. Thanks. Here's my code. == # Executing a Linux program under Win XP from subprocess import call myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) You must always escape \ characters in a string. do r"C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "C:\\Sandia_Meteors\\Various\\FuzzyLogic\\wolf", or "C:/Sandia_Meteors/Various/FuzzyLogic/wolf" Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html Good. Thanks. Here's my code. == # Executing a Linux program under Win XP from subprocess import call myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) == But msgs are produced ... Traceback (most recent call last): File "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/sentuser/fun-subprocess_Linux.py", line 4, in myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) File "C:\Python25\lib\subprocess.py", line 444, in call return Popen(*popenargs, **kwargs).wait() File "C:\Python25\lib\subprocess.py", line 594, in __init__ errread, errwrite) File "C:\Python25\lib\subprocess.py", line 816, in _execute_child startupinfo) WindowsError: [Error 5] Access is denied I looked for the attributes on the file and it shows "A". I'm the admin on my XP Pro, and the file is owned by Admin. wolf is a 1 meg file. Alan Gauld wrote: "Wayne Watson" wrote What is meant by "The arguments are the same as for the Popen constructor.", in Convenience Functions? In fact, what is such a function? It means that there is a function which takes the same arguments as the __init__() method of the Popen class. They are convenience functions in that you don't need to create the class to use them you can just call them directly. THe payoff is that you lose some of the flexibility of using the class, but often you don;t need that. class subprocess.Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False Why not just class Popen instead of subprocess.Popen? The notation is saying that there is a class defined in the subprocess module called Popen with a constructor that has the listed parameters. It is just a shorthand way of expressing that. In practice you would create an instance with either: import subprocess p = subprocess.Popen() OR from subprocess import Popen p = Popen() Is there a suggestion here that I need only do: from subprocess import Popen myProg=Popen() myProg.call("wolf", "-h") Even simpler, you only need: from subprocess import call myProg = call(["wolf", "-h"]) You need to put the command as the first entry of a list and each argument as a separate entry HTH, -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html Yes, good, but I tried myProg = call([r"C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]), and get exactly the same results. A.T.Hofkamp wrote: Wayne Watson wrote: Good. Thanks. Here's my code. == # Executing a Linux program under Win XP from subprocess import call myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) You must always escape \ characters in a string. do r"C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "C:\\Sandia_Meteors\\Various\\FuzzyLogic\\wolf", or "C:/Sandia_Meteors/Various/FuzzyLogic/wolf" Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Wayne Watson wrote: Yes, good, but I tried myProg = call([r"C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]), and get exactly the same results. So the next step is to find out what is wrong. In other words, experiment with the problem to get an understanding what is not working. Once you get that, you can start looking for a way to solve it. Some suggestions for possible experiments: Are you sure the program is not already finished? (ie it runs the program, and after finishing it gives an error for some reason?) What does Windows think of it when you run it without Python (ie directly from the OS, eg using a 'cmd' window (or whatever it is called nowadays, my last Win* experience was with W95))? (The error looks like an OS error, not a Python error. By trying it without Python, you can decide whether you need to convince your OS to run the program or you whether need to convince Python.) Possibly a stupid suggestion, don't you need to add '.exe' at the end? (I am pretty much clueless with Windows, so maybe this is nonense.) Alternatively, try executing a different program that you know to be working at Windows. (The python.exe would be one such program, but it may be confusing to run several python programs at the same time.) Last but not least, what error do you get when you try running something that does not exist? (Do you get the same error, or do you get a different one? If the latter, you know Python gives the path correctly to Windows.) What happens if you give it a non-executable file? (just giving wild suggestions for experiments you can do to get more understanding of why it is refusing to run the file.) Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] adding dictionary values
Hi Tutors, I have two pickled dictionaries containing word counts from two different corpora. I need to add the values, so that a word count is the sum of both. If the word "man" has a count of 2 in corpus A and a count of 3 in corpus B, then I need a new dictionary that has "man": 5. Please let me know whether the following is correct/incorrect, good/bad, etc. Your help appreciated: def addDicts(a, b): c = {} for k in a: if k not in b: c[k] = a[k] else: c[k] = a[k] + b[k] for k in b: if k not in a: c[k] = b[k] return c # test this dict1 = {"dad": 3, "man": 2} dict2 = {"dad": 5, "woman": 10} newDict = addDicts(dict1, dict2) print(newDict) # This gives {'dad': 8, 'woman': 10, 'man': 2} -- لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.محمد الغزالي "No victim has ever been more repressed and alienated than the truth" Emad Soliman Nawfal Indiana University, Bloomington ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adding dictionary values
2009/3/20 Emad Nawfal (عماد نوفل) > Hi Tutors, > I have two pickled dictionaries containing word counts from two different > corpora. I need to add the values, so that a word count is the sum of both. > If the word "man" has a count of 2 in corpus A and a count of 3 in corpus B, > then I need a new dictionary that has "man": 5. Please let me know whether > the following is correct/incorrect, good/bad, etc. > Your help appreciated: > > def addDicts(a, b): > c = {} > for k in a: > if k not in b: > c[k] = a[k] > else: > c[k] = a[k] + b[k] > > for k in b: > if k not in a: > c[k] = b[k] > return c > > # test this > dict1 = {"dad": 3, "man": 2} > dict2 = {"dad": 5, "woman": 10} > newDict = addDicts(dict1, dict2) > print(newDict) > # This gives > > {'dad': 8, 'woman': 10, 'man': 2} > > This looks like it will work, but you can accomplish this more compactly by just looping over the items in both dictionaries and making use of the default argument of the dictionaries get method. newDict = {} for k, v in dict1.items() + dict2.items(): newDict[k] = newDict.get(k,0) + v ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html I guess I haven't made clear above. This is a Red Hat Linux compiled C program. Indications from others above, suggest it is possible to execute it under Win Python. If that's true, then my guess is that something prior to the call must be done in the way of informing the call it is dealing with a non-Win program. A.T.Hofkamp wrote: Wayne Watson wrote: Yes, good, but I tried myProg = call([r"C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]), and get exactly the same results. So the next step is to find out what is wrong. In other words, experiment with the problem to get an understanding what is not working. Once you get that, you can start looking for a way to solve it. Some suggestions for possible experiments: Are you sure the program is not already finished? (ie it runs the program, and after finishing it gives an error for some reason?) What does Windows think of it when you run it without Python (ie directly from the OS, eg using a 'cmd' window (or whatever it is called nowadays, my last Win* experience was with W95))? (The error looks like an OS error, not a Python error. By trying it without Python, you can decide whether you need to convince your OS to run the program or you whether need to convince Python.) Possibly a stupid suggestion, don't you need to add '.exe' at the end? (I am pretty much clueless with Windows, so maybe this is nonense.) Alternatively, try executing a different program that you know to be working at Windows. (The python.exe would be one such program, but it may be confusing to run several python programs at the same time.) Last but not least, what error do you get when you try running something that does not exist? (Do you get the same error, or do you get a different one? If the latter, you know Python gives the path correctly to Windows.) What happens if you give it a non-executable file? (just giving wild suggestions for experiments you can do to get more understanding of why it is refusing to run the file.) Albert -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adding dictionary values
You should iterate over the keys of the dictionary: for k in a.keys(): because if you iterate over the full dictionary, your items are the values, not the keys. Otherwise your code looks correct, and I don't think its terribly bad form. You could do something interesting with sets: sa = set(a.keys()) sb = set(b.keys()) The next step could be a for loop, but if you enjoy terseness and taking advantage of language features (also should be faster for big enough dicts): c = dict( \ [(k, a[k]+b[k]) for k in sa&sb ] + \ [(k, a[k]) for k in sa-sb ] + \ [(k, b[k]) for k in sb-sa ] ) which creates a new dict from a list of key, value pairs. The list is a sum of three lists: those keys in both a and b, those only in a, and those only in b. Cheers On Friday 20 March 2009 10:11, Emad Nawfal wrote: > Hi Tutors, > I have two pickled dictionaries containing word counts from two different > corpora. I need to add the values, so that a word count is the sum of both. > If the word "man" has a count of 2 in corpus A and a count of 3 in corpus > B, then I need a new dictionary that has "man": 5. Please let me know > whether the following is correct/incorrect, good/bad, etc. > Your help appreciated: > > def addDicts(a, b): > c = {} > for k in a: > if k not in b: > c[k] = a[k] > else: > c[k] = a[k] + b[k] > > for k in b: > if k not in a: > c[k] = b[k] > return c > > # test this > dict1 = {"dad": 3, "man": 2} > dict2 = {"dad": 5, "woman": 10} > newDict = addDicts(dict1, dict2) > print(newDict) > # This gives > > {'dad': 8, 'woman': 10, 'man': 2} ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adding dictionary values
Oops! The dictionary iterates over keys, not values as I stated (and demonstrated by your working code). Consequently, the example I gave could be more succinctly expressed by: sa = set(a) sb = set(b) Sorry for the error. Cheers ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adding dictionary values
2009/3/20 greg whittier : > This looks like it will work, but you can accomplish this more compactly by > just looping over the items in both dictionaries and making use of the > default argument of the dictionaries get method. > > newDict = {} > for k, v in dict1.items() + dict2.items(): > newDict[k] = newDict.get(k,0) + v Even simpler, start with a copy of dict1: newDict = dict(dict1) for k, v in dict2.items(): newDict[k] = newDict.get(k,0) + v Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adding dictionary values
2009/3/20 Chris Fuller : > You should iterate over the keys of the dictionary: > for k in a.keys(): > because if you iterate over the full dictionary, your items are the values, > not the keys. Otherwise your code looks correct, and I don't think its > terribly bad form. You could do something interesting with sets: > sa = set(a.keys()) > sb = set(b.keys()) > > The next step could be a for loop, but if you enjoy terseness and taking > advantage of language features (also should be faster for big enough dicts): > c = dict( \ > [(k, a[k]+b[k]) for k in sa&sb ] + \ > [(k, a[k]) for k in sa-sb ] + \ > [(k, b[k]) for k in sb-sa ] > ) > > which creates a new dict from a list of key, value pairs. The list is a sum > of three lists: those keys in both a and b, those only in a, and those only > in b. > > Cheers > > On Friday 20 March 2009 10:11, Emad Nawfal wrote: >> Hi Tutors, >> I have two pickled dictionaries containing word counts from two different >> corpora. I need to add the values, so that a word count is the sum of both. >> If the word "man" has a count of 2 in corpus A and a count of 3 in corpus >> B, then I need a new dictionary that has "man": 5. Please let me know >> whether the following is correct/incorrect, good/bad, etc. >> Your help appreciated: >> >> def addDicts(a, b): >> c = {} >> for k in a: >> if k not in b: >> c[k] = a[k] >> else: >> c[k] = a[k] + b[k] >> >> for k in b: >> if k not in a: >> c[k] = b[k] >> return c >> >> # test this >> dict1 = {"dad": 3, "man": 2} >> dict2 = {"dad": 5, "woman": 10} >> newDict = addDicts(dict1, dict2) >> print(newDict) >> # This gives >> >> {'dad': 8, 'woman': 10, 'man': 2} > ___ > Tutor maillist - tu...@python.org > http://mail.python.org/mailman/listinfo/tutor > Just to add another tool to your toolbox, defaultdicts, available from version 2.5, are good for word counts, and simplifies your function no end: from collections import defaultdict def addDict(a, b): newdict = defaultdict(int, a) for k,v in b.iteritems(): newdict[k] += v return newdict you can chage the last line to "return dict(newdict)" if the returned value MUST be a dict, but there is very little advantage to doing so in properly written code. Extra credit: To do a word count with a defaultdict is simple: wordcount = defaultdict(int) for word in list_of_words: wordcount[word] += 1 Look it up in the docs if you want details of defaultdict. -- Richard "Roadie Rich" Lovely, part of the JNP|UK Famile www.theJNP.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adding dictionary values
On Fri, Mar 20, 2009 at 12:03 PM, Richard Lovely wrote: > 2009/3/20 Chris Fuller : > > You should iterate over the keys of the dictionary: > > for k in a.keys(): > > because if you iterate over the full dictionary, your items are the > values, > > not the keys. Otherwise your code looks correct, and I don't think its > > terribly bad form. You could do something interesting with sets: > > sa = set(a.keys()) > > sb = set(b.keys()) > > > > The next step could be a for loop, but if you enjoy terseness and taking > > advantage of language features (also should be faster for big enough > dicts): > > c = dict( \ > > [(k, a[k]+b[k]) for k in sa&sb ] + \ > > [(k, a[k]) for k in sa-sb ] + \ > > [(k, b[k]) for k in sb-sa ] > > ) > > > > which creates a new dict from a list of key, value pairs. The list is a > sum > > of three lists: those keys in both a and b, those only in a, and those > only > > in b. > > > > Cheers > > > > On Friday 20 March 2009 10:11, Emad Nawfal wrote: > >> Hi Tutors, > >> I have two pickled dictionaries containing word counts from two > different > >> corpora. I need to add the values, so that a word count is the sum of > both. > >> If the word "man" has a count of 2 in corpus A and a count of 3 in > corpus > >> B, then I need a new dictionary that has "man": 5. Please let me know > >> whether the following is correct/incorrect, good/bad, etc. > >> Your help appreciated: > >> > >> def addDicts(a, b): > >> c = {} > >> for k in a: > >> if k not in b: > >> c[k] = a[k] > >> else: > >> c[k] = a[k] + b[k] > >> > >> for k in b: > >> if k not in a: > >> c[k] = b[k] > >> return c > >> > >> # test this > >> dict1 = {"dad": 3, "man": 2} > >> dict2 = {"dad": 5, "woman": 10} > >> newDict = addDicts(dict1, dict2) > >> print(newDict) > >> # This gives > >> > >> {'dad': 8, 'woman': 10, 'man': 2} > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > Just to add another tool to your toolbox, defaultdicts, available from > version 2.5, are good for word counts, and simplifies your function no > end: > > from collections import defaultdict > def addDict(a, b): >newdict = defaultdict(int, a) >for k,v in b.iteritems(): >newdict[k] += v >return newdict > > you can chage the last line to "return dict(newdict)" if the returned > value MUST be a dict, but there is very little advantage to doing so > in properly written code. > > Extra credit: > To do a word count with a defaultdict is simple: > wordcount = defaultdict(int) > for word in list_of_words: >wordcount[word] += 1 > > Look it up in the docs if you want details of defaultdict. > -- > Richard "Roadie Rich" Lovely, part of the JNP|UK Famile > www.theJNP.com > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > Thanks All for the help, if I want to do this with more than two dictionaries, the obvious solution for me is to use something like the reduce functions with a list of dictionary names like: dictList = [dict1, dict2, dict3] newDict = reduce(addDicts, dictList) Is this a satisfactory solution? -- لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.محمد الغزالي "No victim has ever been more repressed and alienated than the truth" Emad Soliman Nawfal Indiana University, Bloomington ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html You understand it perfectly. Michael Farnham wrote: On Fri, 2009-03-20 at 04:35 -0700, Wayne Watson wrote: Good. Thanks. Here's my code. == # Executing a Linux program under Win XP from subprocess import call myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) If I understand your question - A C program which runs in Linux cannot run in Microsoft Windows without being recompiled. I know that many of the people who have replied in this thread know this so maybe I misunderstood the question. HTH Mike -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html To be clear. The program I'm trying to execute under Win XP was compiled on a RH Linux machine. It was not compile on a Win OS machine. It may sound far fetched some facility might be available to do this, but somewhere in my very, very distant past before the small computers, these sorts of things were possible, usually through a simulator of some sort. Wayne Watson wrote: You understand it perfectly. Michael Farnham wrote: On Fri, 2009-03-20 at 04:35 -0700, Wayne Watson wrote: Good. Thanks. Here's my code. == # Executing a Linux program under Win XP from subprocess import call myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) If I understand your question - A C program which runs in Linux cannot run in Microsoft Windows without being recompiled. I know that many of the people who have replied in this thread know this so maybe I misunderstood the question. HTH Mike -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
On Fri, Mar 20, 2009 at 8:46 AM, Wayne Watson wrote: > I guess I haven't made clear above. This is a Red Hat Linux compiled C > program. Indications from others above, suggest it is possible to execute it > under Win Python. If that's true, then my guess is that something prior to > the call must be done in the way of informing the call it is dealing with a > non-Win program. > Neither Python proper nor Popen() are actually executing the program - the Windows shell/command interpreter does that (command.com or cmd.exe, depending on your Windows version); Popen() is just a mechanism for making the request, waiting for a response, and processing the result when it comes. If you want to run a non-Windows executable on Windows, you need to use an alternate shell - someone mentioned Cygwin - although I'm not certain that even that will do it for you. What makes an executable OS-specific is not the language it's written in, but the libraries that it's compiled/linked with. If you have access to the source code, the simplest thing would probably be to recompile it on your own machine... the GCC (Gnu Compiler Collection) is free. You mentioned the 'A' attribute - in Windows, that stands for Archive, and was created as a way for early backup programs to do differential backups (i.e. you do a full backup - the backup program copies every file, clearing the A attribute as it does so; new and updated files have the A attribute set, so the next time you do a backup, the program only copies files that have the A attribute...) -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
On Fri, Mar 20, 2009 at 10:02 AM, Marc Tompkins wrote: > If you want to run a non-Windows executable on Windows, you need to use an > alternate shell - someone mentioned Cygwin - although I'm not certain that > even that will do it for you. What makes an executable OS-specific is not > the language it's written in, but the libraries that it's compiled/linked > with. If you have access to the source code, the simplest thing would > probably be to recompile it on your own machine... the GCC (Gnu Compiler > Collection) is free. > Nope, just checked the Cygwin page: What Isn't Cygwin? Cygwin is *not* a way to run native linux apps on Windows. You have to rebuild your application *from source* if you want it to run on Windows. Cygwin is *not* a way to magically make native Windows apps aware of UNIX ® functionality, like signals, ptys, etc. Again, you need to build your apps *from source* if you want to take advantage of Cygwin functionality. -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
On Fri, Mar 20, 2009 at 6:01 PM, Wayne Watson wrote: > To be clear. The program I'm trying to execute under Win XP was compiled on > a RH Linux machine. It was not compile on a Win OS machine. It may sound far > fetched some facility might be available to do this, but somewhere in my > very, very distant past before the small computers, these sorts of things > were possible, usually through a simulator of some sort. It is not a far-fetched requirement: the reverse, i.e. running windows binary under linux is often possible and regularily used, but it requires a specific tool for the job, in the linux case wine, that translates every system call. It's not an easy task, and I doubt that there is something for windows to do so, but there may be a solution using some virtualizing layer and a minimal linux installation, depending on what is needed from the red hat executable. -- Elena ``of Valhalla'' email: elena.valha...@gmail.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter Geometry Management and Other Basics
Title: Signature.html Good ideas. I particularly like the one below about pyw. Never heard of it before. Very nice in this situation. As for Tk/Tcl, I got the highly recommended book from some Python source via an interlibrary loan. My problem with it is that I really don't want to spend weeks learning Tk/Tcl. ## # testTk.py from Tkinter import * top = Tk() w = Button(top, text="Button") w.pack() top.mainloop() ## Just play with the pack or grid options and observe the effect If you have the file open in an editor and name the file as .pyw you can then easily run the file from explorer and have multiple versions displayed at the same time to compare results. Perhaps there's a geometry tutor somewhere on the web. Try the Tcl/Tk web sites they tend to be good for that kind of stuff. Its easy to translate the Tk command to Tkinter. HTH, -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
On Fri, Mar 20, 2009 at 10:02 AM, Marc Tompkins wrote: > Neither Python proper nor Popen() are actually executing the program - the > Windows shell/command interpreter does that (command.com or cmd.exe, > depending on your Windows version); Popen() is just a mechanism for making > the request, waiting for a response, and processing the result when it > comes. > I wasn't very clear here: instead of "the Windows shell/command interpreter does that..." I should have said "the underlying operating system/shell does that..." There are versions of Python for many platforms, and Python code is intended to be as cross-platform as possible, so if you were running some other operating system on your machine, Popen() would be passing your request to... whatever. And if you were running, say, Linux, and trying to execute a Windows program... that wouldn't work either. (Unless you told Popen to pass it through WINE, but I'm not even sure that's possible. There isn't an equivalent to WINE for running Linux executables under Windows, so far as I can Google.) -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
On Fri, Mar 20, 2009 at 1:01 PM, Wayne Watson wrote: > To be clear. The program I'm trying to execute under Win XP was compiled > on a RH Linux machine. It was not compile on a Win OS machine. It may sound > far fetched some facility might be available to do this, but somewhere in my > very, very distant past before the small computers, these sorts of things > were possible, usually through a simulator of some sort. > Wayne, do you have the source code? From your previous responses, I think you do. If so, what is preventing you from compiling it on windows? Maybe we can help you with that. - Greg ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html That's a lot of text to respond to, but let me see if I can broadly do it. It appears that the idea of executing Linux code under Win XP is d-e-a-d. (Let's ignore VM) I will need to recompile the c-code in some way under Win XP. Probably Cygwin. The python code I'm working on will only be available to a private audience which is comprised of Win users. Some years ago I started down the CygWiu road just to have Linux available under Win. Old habits die hard. It was erratic and I pulled it off. Cygwin seems to be still alive, so I think I will give it a shake today. I hope it can tolerate the Makefiles and libraries the 38K line program requires. My former knowledge of Makefiles died years ago. Here's the main program's header file (and part of a Makefile). Probably the tricky part is the graphic library use. In the meantime, I headed for a Cygwin download. wolf.c, the main program header. #define wolf #include #include #include #include #include "cgi-draw.h" < This guy, maybe #include "novas.h" #include "global.h" #include "calstars.h" #include "imatrix.h" #include "cnstl.h" A sample of Makefile.linux /* markstars *** main routine of WOLF inputs: input_image - path for the input fits image file. output_image - filename of the output jpg processed image. detect - if 1, detect "unepxected" stars. write_on_target - if 1, type labels on the output image. In this case, output image must be specified. inverted - if 1, the image is inverted (black background and white stars). constellations - if 1, draw constellations (greek style) lines. ... -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html Yes, I'm sure I'll need help. I just posted a message minutes before yours mentioning I'm willing to try Cygwin. The C program, wolf, is the public domain If trying to compile the program under Win is what you had in mind, then I can send you all the necessary files in a zip file. If not, then I'll be back to ask questions about what might be going wrong either here or in some Cygwin newsgroup. I distantly recall there is one. greg whittier wrote: On Fri, Mar 20, 2009 at 1:01 PM, Wayne Watsonwrote: To be clear. The program I'm trying to execute under Win XP was compiled on a RH Linux machine. It was not compile on a Win OS machine. It may sound far fetched some facility might be available to do this, but somewhere in my very, very distant past before the small computers, these sorts of things were possible, usually through a simulator of some sort. Wayne, do you have the source code? From your previous responses, I think you do. If so, what is preventing you from compiling it on windows? Maybe we can help you with that. - Greg ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux ... (Cygwin)
Title: Signature.html First questions about Cygwin is I see a 1.7 Beta download version for it, and references to 1.5 downloads. Where's 1.6? Is it past Beta? Wayne Watson wrote: That's a lot of text to respond to, but let me see if I can broadly do it. It appears that the idea of executing Linux code under Win XP is d-e-a-d. (Let's ignore VM) I will need to recompile the c-code in some way under Win XP. Probably Cygwin. The python code I'm working on will only be available to a private audience which is comprised of Win users. Some years ago I started down the CygWiu road just to have Linux available under Win. Old habits die hard. It was erratic and I pulled it off. Cygwin seems to be still alive, so I think I will give it a shake today. I hope it can tolerate the Makefiles and libraries the 38K line program requires. My former knowledge of Makefiles died years ago. Here's the main program's header file (and part of a Makefile). Probably the tricky part is the graphic library use. In the meantime, I headed for a Cygwin download. wolf.c, the main program header. #define wolf #include #include #include #include #include "cgi-draw.h" < This guy, maybe #include "novas.h" #include "global.h" #include "calstars.h" #include "imatrix.h" #include "cnstl.h" A sample of Makefile.linux /* markstars *** main routine of WOLF inputs: input_image - path for the input fits image file. output_image - filename of the output jpg processed image. detect - if 1, detect "unepxected" stars. write_on_target - if 1, type labels on the output image. In this case, output image must be specified. inverted - if 1, the image is inverted (black background and white stars). constellations - if 1, draw constellations (greek style) lines. ... -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
On Fri, Mar 20, 2009 at 1:41 PM, Wayne Watson wrote: > Yes, I'm sure I'll need help. I just posted a message minutes before yours > mentioning I'm willing to try Cygwin. The C program, wolf, is the public > domain If trying to compile the program under Win is what you had in mind, > then I can send you all the necessary files in a zip file. If not, then I'll > be back to ask questions about what might be going wrong either here or in > some Cygwin newsgroup. I distantly recall there is one. > I actually found the code http://nightskylive.net/software/ from googling. A quick "make" under msys/mingw didn't complete as I'd hoped, so you'll have to put in some work, but it doesn't look insurmountable. I think this is pretty far afield from the python-tutor group though. Maybe you could try the community that uses WOLF or the cygwin group? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
On Fri, 2009-03-20 at 04:35 -0700, Wayne Watson wrote: > Good. Thanks. > > Here's my code. > == > # Executing a Linux program under Win XP > from subprocess import call > myProg = call(["C:\Sandia_Meteors\Various\FuzzyLogic\wolf", "-h"]) If I understand your question - A C program which runs in Linux cannot run in Microsoft Windows without being recompiled. I know that many of the people who have replied in this thread know this so maybe I misunderstood the question. HTH Mike ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adding dictionary values
2009/3/20 Emad Nawfal (عماد نوفل) : > if I want to do this with more than two dictionaries, the obvious solution > for me is to use something like the reduce functions with a list of > dictionary names like: > dictList = [dict1, dict2, dict3] > newDict = reduce(addDicts, dictList) > > Is this a satisfactory solution? This will do some extra copying, as addDicts() always copies the first argument. You would do better with something like def addToDict(a, b): for k,v in b.iteritems(): a[k] += v return a newDict = reduce(addDictTo, dictList[1:], defaultdict(int, dictList[0])) or rewrite addDicts() to take a variable number of arguments and loop over the args. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux ... (Cygwin)
On Fri, Mar 20, 2009 at 1:49 PM, Wayne Watson wrote: > First questions about Cygwin is I see a 1.7 Beta download version for it, > and references to 1.5 downloads. Where's 1.6? Is it past Beta? > > Wayne Watson wrote: > > That's a lot of text to respond to, but let me see if I can broadly do it. > > It appears that the idea of executing Linux code under Win XP is d-e-a-d. > (Let's ignore VM) > I will need to recompile the c-code in some way under Win XP. Probably > Cygwin. This is really far off-topic. Please don't use this list for discussion of Cygwin and porting C code from Linux to Windows. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux in Python for Win
Title: Signature.html Yes, sounds like you got the code, and I need to go outside this group to a Cygwin forum/NG or Linux under Win. Recently, I was working with a fellow associated with this effort who knows Linux very well. He had some slight difficulty with the Makefiles, but finally got it running on my ancient (and recently resurreced in a very old Linux) machine. It came down to a few lines of the Makefile. See my post about Cygwin 1.7 or 1.6. If you are further interested, for the moment anyway here's the makefile we finally used. The g++ line was the big change. Also attached. The attachment may not make it or possibly get hung up with the moderator. CC = g++ CFLAGS = -c BIN = wolf OBJ = wolf.o calstars.o fclasses.o global.o \ novas.o novascon.o readeph0.o solarsys.o \ swedate.o swejpl.o swemmoon.o swemplan.o \ sweph.o swephlib.o cgi-draw.o imatrix.o \ cnstl.o \ wolf: $(OBJ) g++ -o wolf $(OBJ) -lm ./fits/cfitsio/libcfitsio.a # -lnsl -lsocket wolf.o: wolf.c $(CC) $(CFLAGS) wolf.c calstars.o: calstars.c $(CC) $(CFLAGS) calstars.c fclasses.o: fclasses.c $(CC) $(CFLAGS) fclasses.c global.o: global.c $(CC) $(CFLAGS) global.c imatrix.o: imatrix.c $(CC) $(CFLAGS) imatrix.c cnstl.o: cnstl.c $(CC) $(CFLAGS) cnstl.c cgi-draw.o: cgi-draw.c $(CC) $(CFLAGS) cgi-draw.c novas.o: novas.c $(CC) $(CFLAGS) novas.c novascon.o: novascon.c $(CC) $(CFLAGS) novascon.c readeph0.o: readeph0.c $(CC) $(CFLAGS) readeph0.c solarsys.o: solarsys.c $(CC) $(CFLAGS) solarsys.c swedate.o: swedate.c $(CC) $(CFLAGS) swedate.c swejpl.o: swejpl.c $(CC) $(CFLAGS) swejpl.c swemmoon.o: swemmoon.c $(CC) $(CFLAGS) swemmoon.c swemplan.o: swemplan.c $(CC) $(CFLAGS) swemplan.c sweph.o: sweph.c $(CC) $(CFLAGS) sweph.c swephlib.o: swephlib.c $(CC) $(CFLAGS) swephlib.c clean: rm -f wolf *.o core See my post to Marc about the header file and graphics use. greg whittier wrote: On Fri, Mar 20, 2009 at 1:41 PM, Wayne Watsonwrote: Yes, I'm sure I'll need help. I just posted a message minutes before yours mentioning I'm willing to try Cygwin. The C program, wolf, is the public domain If trying to compile the program under Win is what you had in mind, then I can send you all the necessary files in a zip file. If not, then I'll be back to ask questions about what might be going wrong either here or in some Cygwin newsgroup. I distantly recall there is one. I actually found the code http://nightskylive.net/software/ from googling. A quick "make" under msys/mingw didn't complete as I'd hoped, so you'll have to put in some work, but it doesn't look insurmountable. I think this is pretty far afield from the python-tutor group though. Maybe you could try the community that uses WOLF or the cygwin group? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain CC = g++ CFLAGS = -c BIN = wolf OBJ = wolf.o calstars.o fclasses.o global.o \ novas.o novascon.o readeph0.o solarsys.o \ swedate.o swejpl.o swemmoon.o swemplan.o \ sweph.o swephlib.o cgi-draw.o imatrix.o \ cnstl.o \ wolf: $(OBJ) g++ -o wolf $(OBJ) -lm ./fits/cfitsio/libcfitsio.a # -lnsl -lsocket wolf.o: wolf.c $(CC) $(CFLAGS) wolf.c calstars.o: calstars.c $(CC) $(CFLAGS) calstars.c fclasses.o: fclasses.c $(CC) $(CFLAGS) fclasses.c global.o: global.c $(CC) $(CFLAGS) global.c imatrix.o: imatrix.c $(CC) $(CFLAGS) imatrix.c cnstl.o: cnstl.c $(CC) $(CFLAGS) cnstl.c cgi-draw.o: cgi-draw.c $(CC) $(CFLAGS) cgi-draw.c novas.o: novas.c $(CC) $(CFLAGS) novas.c novascon.o: novascon.c $(CC) $(CFLAGS) novascon.c readeph0.o: readeph0.c $(CC) $(CFLAGS) readeph0.c solarsys.o: solarsys.c $(CC) $(CFLAGS) solarsys.c swedate.o: swedate.c $(CC) $(CFLAGS) swedate.c swejpl.o: swejpl.c $(CC) $(CFLAGS) swejpl.c swemmoon.o: swemmoon.c $(CC) $(CFLAGS) swemmoon.c swemplan.o: swemplan.c $(CC) $(CFLAGS) swemplan.c sweph.o: sweph.c $(CC) $(CFLAGS) sweph.c swephlib.o: swephlib.c $(CC) $(CFLAGS) swephlib.c clean: rm -f wolf *.o core ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trouble parsing email from Outlook
On Fri, Mar 20, 2009 at 2:29 PM, Eduardo Vieira wrote: > On Fri, Mar 20, 2009 at 9:04 AM, Tim Golden wrote: >> Eduardo Vieira wrote: >>> >>> Thank you very much, Tim for the thorough explanation. Much more than >>> I could expect. It will be specially useful for me a newbie python >>> amateur programmer. I will try your guidance as soon as possible >>> today, and see my progress. >> >> That's ok; might be worth posting back to the list to say >> whether it worked or not. All the posts go into the archive >> so people looking in the future for the same kind of solution >> might be interested to know if my suggestion worked or >> whether there were any other obstacles. >> >> TJG >> > Thanks again. I tried the code, trying to reformat the spaces and came > up with this code: http://paste.lisp.org/display/77353 > I'm not sure if I indented correctly, and the result it gave me was: > Searching Archive Folders > Searching Mailbox - Eduardo Silva > > I don't understand the part "for folder, folders, items in cdo_walk > (info_store.RootFolder):" > RootFolder is IPM_SUBTREE if I check the Name value > I worked! sorry, I had to just align "raise x_found" with the "for" statement, thank you very much! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter Geometry Management and Other Basics
"Wayne Watson" wrote I really don't want to spend weeks learning Tk/Tcl. You shouldn't need to. The Tk documentation is very easy to transfer to Tkinter: Here is a sample from the official reference docs for Label (found at: http://www.tcl.tk/man/tcl8.5/TkCmd/contents.htm): STANDARD OPTIONS -activebackground, activeBackground, Foreground -activeforeground, activeForeground, Background -anchor, anchor, Anchor ... -takefocus, takeFocus, TakeFocus -text, text, Text -textvariable, textVariable, Variable -underline, underline, Underline -wraplength, wrapLength, WrapLength WIDGET-SPECIFIC OPTIONS -height, height, Height -state, state, State -width, width, Width So you can use Label( option = value) for any of the listed options. If you want to see what values are possible, just click onthe option, for example state gives: -- Command-Line Name: -state Database Name: state Database Class: State Specifies one of three states for the label: normal, active, or disabled. In normal state the button is displayed using the foreground and background options. In active state the label is displayed using the activeForeground and activeBackground options. In the disabled state the disabledForeground andbackground options determine how the button is displayed. - No real Tcl knowledge required. Just remember that in Tkinter you should quote the value as a string, so: lbl = Label(text = "My Label", state='disabled') It really is quite easy. Too few Tkinter programmer shy away from the Tcl/Tk sites because they think they need to know Tcl. Its not the case 90+% of the time. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trouble parsing email from Outlook
Eduardo Vieira wrote: On Fri, Mar 20, 2009 at 2:29 PM, Eduardo Vieira wrote: On Fri, Mar 20, 2009 at 9:04 AM, Tim Golden wrote: Eduardo Vieira wrote: Thank you very much, Tim for the thorough explanation. Much more than I could expect. It will be specially useful for me a newbie python amateur programmer. I will try your guidance as soon as possible today, and see my progress. That's ok; might be worth posting back to the list to say whether it worked or not. All the posts go into the archive so people looking in the future for the same kind of solution might be interested to know if my suggestion worked or whether there were any other obstacles. TJG Thanks again. I tried the code, trying to reformat the spaces and came up with this code: http://paste.lisp.org/display/77353 I'm not sure if I indented correctly, and the result it gave me was: Searching Archive Folders Searching Mailbox - Eduardo Silva I don't understand the part "for folder, folders, items in cdo_walk (info_store.RootFolder):" RootFolder is IPM_SUBTREE if I check the Name value I worked! sorry, I had to just align "raise x_found" with the "for" statement, thank you very much! Glad you got it working. The "for folder, folders, items in..." bit is looping over each folder (with its subfolders and subitems) in turn. cdo_walk is a generator -- a function-type mechanism which keeps returning values, rather than just returning once. Because of that, you can keep looping over it as it walks down the tree of folders, recursively in this case altho' other approaches are possible. FWIW, RootFolder is nearly always IPM_SUBTREE; its name doesn't really matter: it's just a place to start looking. Sorry about the formatting. With something more than a few lines long I usually stick it in pastebin or wherever, but I was moving too quickly when I wrote that this morning! TJG ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Executing a C Program from RH Linux ... (Cygwin)
Title: Signature.html Sounds right to me. I won't. Kent Johnson wrote: On Fri, Mar 20, 2009 at 1:49 PM, Wayne Watson wrote: First questions about Cygwin is I see a 1.7 Beta download version for it, and references to 1.5 downloads. Where's 1.6? Is it past Beta? Wayne Watson wrote: That's a lot of text to respond to, but let me see if I can broadly do it. It appears that the idea of executing Linux code under Win XP is d-e-a-d. (Let's ignore VM) I will need to recompile the c-code in some way under Win XP. Probably Cygwin. This is really far off-topic. Please don't use this list for discussion of Cygwin and porting C code from Linux to Windows. Kent -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter Geometry Management and Other Basics
"Alan Gauld" wrote It really is quite easy. Too few Tkinter programmer shy away from the Tcl/Tk sites because they think they need to know Tcl. Ahem, that should have said too *many* of course not too few Sorry, Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter Geometry Management and Other Basics
I read between the lines. :-) I was just beginning to re-read it as I saw this message pop into my Send box. It looks like there are three choices for words for each option that vary slightly for each state. Only the command-line name appears to have relevance for Tkinter. In the Label case, the three states have different uses for text, but, in Grid, it appears to be only useful for command-line, Tkinter use. Well, it's worth thinking about. It certainly collects the options in one place. Alan Gauld wrote: "Alan Gauld" wrote It really is quite easy. Too few Tkinter programmer shy away from the Tcl/Tk sites because they think they need to know Tcl. Ahem, that should have said too *many* of course not too few Sorry, Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor