Class Methods Vs Any Other Callable
I remember learning closures in Python and thought it was the dumbest idea ever. Why use a closure when Python is fully object oriented? I didn't grasp the power/reason for them until I started learning JavaScript and then BAM, I understood them. Just a little while ago, I had a fear of decorators because I really couldn't find a definitive source to learn them (how to with with @). How important are they? They must be important otherwise why have'em in the language? I had to learn'em and then suddenly, BAM. I understand them. My main issue with closures and decorators was hidden in the fact of how *dead simple* they were. All I needed were reasons to use them over doing it X style. So what is my point? How dead simple are class methods? I must be missing there point so I am convinced they must be dead simple. classes, functions, instance and static methods are easy. So easy in fact, I could shoot myself in the foots without looking (preferably without aiming). So, why am I stuck on the *idea* of a class method? An instance method works on the instance A Static method is basically a function nested within a class object A class method is overkill? I can call a static or class method through either the class OR any instance of it. I've never designed a method that took advantage of the class name except in cases where I needed to extend a super class *but* even in this case, I didn't use the enclosing class name... Whats the deal with class methods, why use them over anything else? What does a class method accomplish in at least one line shorter than anything else? Does it help reduce duplication or typing? I am at a lost for words that can shed at least *one* good reason to use them. What is the one greatest reason to use them? A little syntax and explanation can go a long long way. I am failing to understand them so any help is really appreciated here! -- http://mail.python.org/mailman/listinfo/python-list
Re: Class Methods Vs Any Other Callable
An instance method works on the instance A Static method is basically a function nested within a class object A class method is overkill? If anything, a static method is overkill... class Foo: [EMAIL PROTECTED] def register(cls, listener): cls.LISTENERS.append(listener) When I learned about static methods, I learned they're a way to tightly couple some functionality with a class without tying the functionality to any of the instances. I see them as nothing more than a design decision. To me they make some sense. Other than a methods signature (classmethod(cls, l) and a staticmethod(l)) a class method does anything that a static method does and gets the CLS reference for FREE? Is this why a static method is considered to be overkill? In other words, either one can be called from either the class or the instance and both work pretty much the same *but* only the class method includes the class for reference and the static method does not? The only real difference I see between an instance and either a class or static method is the whole bound/unbound thing. Otherwise, even an instance can do what the others do *just* the instance method can only make those calls through an instance and not the class. Instance methods make the most sense. A static method makes sense too *but* I can see how a class method not only does what a static method does but how a class method *also* gets the cls reference for free. Am I correct? -- http://mail.python.org/mailman/listinfo/python-list
Re: Class Methods Vs Any Other Callable
Instance methods make the most sense. A static method makes sense too *but* I can see how a class method not only does what a static method does but how a class method *also* gets the cls reference for free. I don't understand the last part - but I certainly agree on the instance methods make the most sense. But *if* you want a hierarchy of sensefulness, method classmethod staticmethod OK, I am sold. If in case I find myself needing a static-method, I'll simply make it a class-method instead. One thing that stuck out from earlier and I'll compare it to linking is the relative usefulness of cls. There are 2 conditions I can immediately come up with. 1, rename the class and the class method still works. 2, move the method from working on one particular class and it'll most likely work unchanged (w/ the same interface) in another. Other than the 2 reasons above (2 making more sense), what is a really good reason to pull out the class method. In other words, when you see one, what is the first thing that comes to mind? When you write one, what was the first thing on your mind? Other than similar to static- methods, at what point will you be glad you used one? To sum it up, what is the best role for a class-method that does not turn your work into code-soup? -- http://mail.python.org/mailman/listinfo/python-list
Re: Class Methods Vs Any Other Callable
Instance methods make the most sense. A static method makes sense too *but* I can see how a class method not only does what a static method does but how a class method *also* gets the cls reference for free. I don't understand the last part - but I certainly agree on the instance methods make the most sense. But *if* you want a hierarchy of sensefulness, method classmethod staticmethod Sorry I quoted this earlier and meant to respond to it. What I meant was, might as well use a class method over a static method AND in doing so, cls is free. I sort of repeated the same thing over and over. I think my main concern was trying to make sure I could grasp at least that much. -- http://mail.python.org/mailman/listinfo/python-list
Re: Orlando Florida Python Tutor Needed
I know you're looking for one-on-one help, direction, and/or tutelage, but since you've not received an answer (yet), here's some general info... For Decorators, have a gander at: http://www.ddj.com/web-development/184406073;jsessionid=QCNTPTSNXZP2W... http://www.ibm.com/developerworks/linux/library/l-cpdecor.html I found the first link to decorators a while back. I didn't think much of it and said to myself, I'd find it again. My googlefu wasn't on my side this time so I thank you for bringing it to my attention again. Very very good article. Cleared up some confusion on decorators and I am much better and sharper at them. I think what makes the *idea* of a decorator so hard is how *simple* it really is. From my learning them so far, I know for a fact, I've encountered situations in which decorators would have saved me from headache and grief. Now, an excellent piece of ammo for the arsenal. Lets see if I could explain a decorator in my own words. a decorator is just a pattern e.g., nothing magical about them except for the syntactical sugar '@'. The @func sugar is nothing more than a hook that embeds the following function into the @func first argument (similar to self or cls) AND then Python *implicitly* reassigns the original function name to that of the decorator which enclosed it. From this point out it's pretty much a closure or the wider known factory function but the real essence of a decorator that can make it a better closure is how *unobtrusive* it is at modifying a function *without* actually manually rewriting the original function. Also, the decorator hook '@' reduces duplication and makes explicit the idea that a function is to be *decorated*. I may have some terminology wrong but think I am actually getting the hang of decorators. very very useful indeed. I have some stuff working without a hitch though still a bit foggy on passing *args, **etc. Well, not that I plan on using them for everything but I've already experienced cases in which I know a decorator would have saved my ass. Am so glad I took the time out to learn them. I'll learn them again tomorrow and go over all the links you provided to me. Larry, thank you for the links, I really appreciate them. If you or anyone have any tips or more links on some good articles regarding them, I would surely enjoy seeing them. Now, class methods. What is one powerful common use case for them? What is one thing they can do in which could perhaps be the sole reason for their existence? heh. I'll get them too :) -- http://mail.python.org/mailman/listinfo/python-list
Orlando Florida Python Tutor Needed
I will pay anyone for a face-to-face tutoring in the Orlando Florida area. I will pay $20.00 per hour (minimum 2 hours needed). What I need are lessons in Decorators and Class methods. If I can walk away with at least 5 lessons taught in both subjects I will be happy to offer an additional $20.00. If you are interested in this offer feel free to either reply through email OR here on this thread. There are no string attached, catches, etc. I need to learn and if you can teach well, I will be happy to learn. Best Regards Victor B. Gonzalez -- http://mail.python.org/mailman/listinfo/python-list
Skill Resume Achievements, What Good Goes Here?
I spent some time working on a skill resume, the kind of resume college students put together and realized, I am not in college and everything I learned was self-taught. Of course I would like some real world achievements but don't consider throw-away code an achievement and am failing to really see any. I don't even wish to entertain the thought of lying about anything. What are some achievements an employer may be looking for in someone willing to start at ground level, entry level, intern, etc? What are some real world achievements every n00b will need under his/her belt in order to be taken seriously? -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does Python never add itself to the Windows path?
I don't understand what all the fuss is about. Add a single page to the installer and on it, have 3 radio buttons. The choices could be add to path (recommended), add to path with version, do not add to path (not recommended). Please submit a patch to sf.net/projects/python that does so. If I could I would. My only point jumping in here is this; adding python to the path has got to be more beneficially productive for everyone than not adding it at all. I don't even use Windows enough to complain about it and I thought I'll voice my agreement on it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does Python never add itself to the Windows path?
Ben Sizer wrote: I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH environment variable. I don't understand what all the fuss is about. Add a single page to the installer and on it, have 3 radio buttons. The choices could be add to path (recommended), add to path with version, do not add to path (not recommended). On a brand new installation or if the user is upgrading, add to path (recommended) should automatically be selected. If the user is downgrading, add to path with version could be the default selection? If a user truly does not want the Python installation to touch the path, they'll know to select do not add to path (not recommended) and it's the end of the story, everyone is happy... It doesn't even have to be like this *but* why not help add the install to the path? I haven't used Windows in quite a while but I've done several installations across some of the family boxes and some inside some virtual machines and every time I tried launching python through a console I temporarily got stunned with an error. I just forget and wish the install could at least remind me. No problem, I know how to add the path so no biggie at all. Some if not most python documentation assumes Python is on the path... Anyhow, I don't get why it doesn't apply by default in some way on Windows even if at the least it could be a simple reminder or tip to do so. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does Python never add itself to the Windows path?
Ben Sizer wrote: I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH environment variable. Every time, I've had to go through and add this by hand, to have something resembling a usable Python installation. No such problems on Linux, whether it be Mandrake/Mandriva, Fedora Core, or Kubuntu. So why is the Windows install half-crippled by default? I just rediscovered this today when trying to run one of the Turbogears scripts, but this has puzzled me for years now. -- Ben Sizer excellent question -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, PostgreSQL, What next?
I need to thank you all for your suggestions and recommendations. I am ultimately aiming to work in Python, PostgreSQL and Django and this link http://www.sqlalchemy.org/news.myt#item_3 sort of made my day :) I really appreciate all of your feedback and will go through Fredrik's links as soon as I get the chance. I thank you all again, I appreciate it very much! -- http://mail.python.org/mailman/listinfo/python-list
Python, PostgreSQL, What next?
Hello all, I've studied Python and studied PostgreSQL. What is the absolute next best step to take to merge these two finely together? I've heard of SQLAlchemy and some others but before I dive in, I would really like the opinion of those who tried it and other toolkits. My main concern is, I would like to completely work with a database from Python. What would you suggest I look into? Thank you for your time! -- http://mail.python.org/mailman/listinfo/python-list
Re: case insensitive dictionary
John Henry wrote: I believe the standard dictionary should be amened to allow the use of case insensitive keys - as an option. I found some work done by others to do that at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/283455 but the problem with that approach is that they lowercase the keys immediately when you create the dictionary and so the true identity of the key is lost. Of course, I can subclass it and save a copy of the real key but that's kind of messcy. In other words: If I have: pets=caselessDict() pets[Cat] = 3 pets[Dog] = 2 I would like to see: pets[cat] prints 3 pets[DOG] prints 2 but print pets.keys() should print: Cat, Dog not: cat, dog You can try to title-case the list returned with keys() like so: print [x.title() for x in pets.keys()] Not a perfect solution but you get what you want... just an idea :) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to coerce a list of vars into a new type?
I want to verify that three parameters can all be converted into integers, but I don't want to modify the parameters themselves. You can twist and tweak this version OR completely redo it. In this version a list of the conversions are returned *but* if you want to only check if such a conversion can be made, you can return a bool result instead of the list. Also integers are converted to floats. just wrap the float() in an int() if you only want ints instead and wrap again with round() or mix and do as you please to get the results you want. def convertToInteger(*args): ''' try to convert arguments to integers and return them in a list''' try: return [float(x) for x in (args)] except ValueError: print 'convertToInteger: pass compatible args OR return a default!' return funcResult = convertToInteger('1', '2', '3') if funcResult: # if conversion was perfect, choose to do what you want # ... a, b, c = funcResult # change global variables! x, y, z = funcResult # create three new variables! print a, b, c print x, y, z # ... -- http://mail.python.org/mailman/listinfo/python-list
Re: RegexBuddy (anyone use this?)
Has anyone tried this thing.. http://www.regular-expressions.info/regexbuddy.html I use kodos http://kodos.sourceforge.net/. I firmly agree using a tool like this to learn regular expressions will not only save you a ridiculous amount of time spent on trial and error *but* it's really easy and makes learning re a joy. btw, kodos is specifically created with Python's re module in mind. Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: RegexBuddy (anyone use this?)
kodos does look good but I do not have the pyqt (maybe I am slightly off) interface to use it on my system.. with another graphic interface it would be a must try software. on Ubuntu 6.06, the repos have this 'gtk2-engines-gtk-qt' and it makes QT apps look really awesome on Gnome. Not sure about Windows *but* I am sure something like it has to exist. Try looking into it. Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
JAG CHAN wrote: Friends, As I had written earlier, I am trying to learn Python. I chose IDLE as an editor to learn Python. Now I find that it is an online editor. It is not possible for me to be always on online while learning. Kindly suggest me a suitable editor (for Windows XP) which does not require me to be on online. Regards. IDLE is not an online editor. If you would like to try another I can suggest SciTE at http://scintilla.sourceforge.net/SciTEDownload.html its a simple syntax editor with good support for Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex help...pretty please?
MooMaster Wrote: I'm trying to develop a little script that does some string manipulation. I have some few hundred strings that currently look like this: cond(a,b,c) and I want them to look like this: cond(c,a,b) I zoned out on your question and created a very simple flipper. Although it will not solve your problem maybe someone looking for a simpler version may find it useful as a starting point. I hope it proves useful. I'll post my simple flipper here: s = 'cond(1,savv(grave(3,2,1),y,x),maxx(c,b,a),0)' def argFlipper(s): ''' take a string of arguments and reverse'em e.g. cond(1,savv(grave(3,2,1),y,x),maxx(c,b,a),0) - cond(0,maxx(a,b,c),savv(x,y,grave(1,2,3)),1) ''' count = 0 keyholder = {} while 1: if s.find('(') 0: count += 1 value = '%sph' + '%d' % count tempstring = [x for x in s] startindex = s.rfind('(') limitindex = s.find(')', startindex) argtarget = s[startindex + 1:limitindex].split(',') argreversed = ','.join(reversed(argtarget)) keyholder[value] = '(' + argreversed + ')' tempstring[startindex:limitindex + 1] = value s = ''.join(tempstring) else: while count and keyholder: s = s.replace(value, keyholder[value]) count -= 1 value = '%sph' + '%d' % count return s print argFlipper(s) -- http://mail.python.org/mailman/listinfo/python-list
Re: InteractiveConsole History on Linux
Why does code.InteractiveConsole support command history on Windows, but not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support history at all, and the Windows console is implementing it's own? Is there any way to get command history working with InteractiveConsole on Linux? The only time I see [A[B on Linux in a console is when I am not logged in. Check to see if you're logged in and then try again. AFAIK, Linux does support console history. I hope this helps :) -- http://mail.python.org/mailman/listinfo/python-list
Re: InteractiveConsole History on Linux
vbgunz wrote: Why does code.InteractiveConsole support command history on Windows, but not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support history at all, and the Windows console is implementing it's own? Is there any way to get command history working with InteractiveConsole on Linux? The only time I see [A[B on Linux in a console is when I am not logged in. Check to see if you're logged in and then try again. AFAIK, Linux does support console history. I hope this helps :) Sorry, I missed code.InteractiveConsole *but* maybe being logged in has something to do with it? -- http://mail.python.org/mailman/listinfo/python-list
Re: split a line, respecting double quotes
Jim wrote: Is there some easy way to split a line, keeping together double-quoted strings? using the re module I find this to probably be the easiest but in no way is this gospel :) import re rex = re.compile(r'(.*?|\S)') sub = 'a b c d e' res = [x for x in re.split(rex, sub) if not x.isspace()][1:-1] print res # - ['a', 'b', 'c', 'd e'] basically import the re module, compile a pattern, identify a string, create a list comprehension with a filter, slice out the result and print to screen. I hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: split a line, respecting double quotes
Is there some easy way to split a line, keeping together double-quoted strings? import re rex = re.compile(r'(.*?|\S)') sub = 'a b c d e' res = [x for x in re.split(rex, sub) if not x.isspace()][1:-1] print res # - ['a', 'b', 'c', 'd e'] instead of slicing the result out, you use this too: res = [x for x in re.split(rex, sub) if x[0:].strip()] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python in a nutshell - new edition ?
Let me assure you that it _won't_ be on paper this coming Saturday (two days from now). I am absolutely certain it will be worth the wait. The Python in a Nutshell book that covers 2.2 is so well written, it's practically amazing the author was able to cram so much in so little space. Although I wish a bit more detailed examples were part of the book it undoubtedly does it's job as the perfect desktop reference. I'll get the latest and maybe donate my 2.2 to the local library. I hope Alex doesn't mind :) -- http://mail.python.org/mailman/listinfo/python-list
Re: learning python idioms
After several years developing in Java, I've begun to switch to Python for several of my new projects as I have found the language quite interesting. I've read several tutorials and implemented a few sample programs and I've found that Python enables one to program in a variety of different styles (I'm not sure if this was the original intention or not). Thus, I find myself occaisionally slipping into the Java mindset when writing Python code and I wonder if this is not optimal. Python is not Java and there must be more correct ways of doing this in Python that simply writing Java code with different syntax. Is there a good reference on the internet about Python-specific idioms and just good Python style in general. Which language constructs are efficient and which aren't? I completely agree with this. I wish some people would gather and create a site dedicated to efficient Python idioms. This would be truly awesome! I hope you get good news on this! http://vbgunz.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
Fredrik_Lundh = 'wah' I bet you enjoy stealing candy from babies and dunging on the little guy every chance you get. You're suppose to be a role model in this community? Your temper tantrum and unrelenting 'look at me look at me i'm bigger and better' machismo attitude is nothing more than a decoyed ploy set out by a deluded megalomaniac. You're promoting Python or the fact that you're the son of Zeus and Hera? You're the worse sore losing cry baby I've ever witnessed on the net in my ten years here... pathetic for sure... -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
You perhaps shouldn't become so excited. Next time, if you're not sure of the correctness of your solution, try to wait a bit before posting it, and see if someone other comes up with the same thing you would have posted. George, if Frederik's first reply was replaced with yours chances are this little waste of time would have never had taken place. I am not an animal and I am capable of understanding my mistakes but trying to embarass me and belittle me in front of all of my peers here when all I tried to do was help is absolutely pathetic the first time around. I don't try to come off as a know it all here and I don't feel I should post a gospel warning label on my help signature but Fredrik could have delivered his message in a much better tone. I too am learning Python and if maybe my answer was not evident enough of that then how smart is Fredrik to persecute me for it? I don't wish to question Fredriks knowledge or his position in the whole scheme of Python but to disrespect me in the name of arrogance and call it just is a mislabel. I don't wish to carry on with this, I don't... I just have no love for a bully and Fredrik is proving himself to be just that. Good day George! -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
Steve, I have no qualm with Fredrik over this '''if you don't know how to do things, you don't need to post.''' but this ''' if you know why this is about the dumbest way to do what you're doing, and you're posted this on purpose, you really need to grow up.'''. The problem was I did post it on purpose, but not with the intent to mess anyone up over it. To top it off, this thread was done and over with (the end) with Roberts reply that came in immediately after mines. I acknowledged his was best and that I *learned* from it. It just seemed Fredriks response was an attack on me and I did take it personally because I tried my best. Sometimes I try to give back but to try and make me regret it is poor communication if the best intent is to advise me on how things are done and not done around here... Its all good. I live and I learn... -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
I read the ten commandments. I enjoyed the link. I see my mistakes. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
Well, given that you did post it on purpose and had no intent to mess anyone up over it, it is clear that the antecedent in Fredrik's if-statement is not satisfied and therefore your mind should've skipped the consequent statement when reading his response. Why get so upset about something that didn't even apply to you? :-) I wish I could've intepreted it like that... I guess that is one of the evils of being human. the uncanny ability to intepret ambiguous understatements and then say fork it when technically you're correct... it really did not apply to me... The evil of being human I suppose :P I apologize to Fredrik for my outburst but would like to request that next time a better suited address be in order even if in doubt. Not everyone is aware of egoless programming... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for my mum
maybe you can tell your moms what to do and what binaries to download or maybe you can download them for her and either send it to her through email or put it on a disc for her... I understand the Windows XP installation binary is easy enough for anyone to get going. Just follow the prompts. Once Python is installed, double clicking .py files would be almost like clicking on executables. If a gui should pop up and the Python installation went in OK, she should be able to see a Gui and not know any different in regards to what exactly is happening in the background... Start with the binary, get it installed and double click the .py files. It should just work. Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't wish to give up on a Tkinter GUI Builder :(
Ah, what I was referring to (somewhat in jest) was something to automatically *write* the code needed by the application. Simply executing it is easy enough and in fact Rapyd-Tk already does this via the save-build-run project-menu choice. sorry I misunderstood you. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
I have new a list , when it hava large number of values, I wonna to delete all the values in it,how to do? something like this will probably help. x = [1,2,3,4,5,6,7,8,9] y = x list([x.pop() for z in xrange(len(x))]) print x, y # [] [] And, if a list have 801 values, I want to get its values index from 300 to 400, could use list1[300:400],are right me? 300 will be included in your slice whereas the 400th index will be excluded. you will ultimately have 99 items in your slice. if you want values from index 300 to 400 you'll need to say [300:401]. the first index is included. the last index is excluded. good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
del list1[:] thank you for that reply. I never thought of [:] cause to be me I thought it would immediately make a copy of the list or if anything that it would delete a copy so I never played with it. nice :) del list1[:-1000] # keep max. last 1000 appended items in the list list1[:]=replace_list very much thanks for the tips. they're great! -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
No, he'll have 100 items in the slice... 300, 301,... 399 that's 100 items. you're right, sorry. [300:400] would return 100 items but the item at index 400 would not return. I suggested if he wanted it to try [300:401] as the last slice index is excluded from the return. Thanks for that :) -- http://mail.python.org/mailman/listinfo/python-list
Re: script vs inneractive
the interactive shell will immediatly show the result of an expression without you having to explicitly print the result. In all text editor, you will have to print the result if you wish to see it. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
if you don't know how to do things, you don't need to post. if you know why this is about the dumbest way to do what you're doing, and you're posted this on purpose, you really need to grow up. If this was the case who then would post any questions? I not only made my post with the best of intentions but felt attaching a strongly worded and lengthy warranty over the script performance and pythonic value would be overkill. I admit I am not the best at Python and I have no problem in being offered a more optimized solution but to insult me is childish. no? It's ok and I have no grudge with you Fredrik. I would appreciate though you simply point out my error with a suggested solution and if energy permit, tell me why my solution is not so good and why yours is better. I would value that very much. Also, not to be the dummy or anything but my solution did exactly what the first poster requested. Robert happened to point out a much better and most likely preffered alternative solution. It was great! I live and I learn. Have a good day! -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
I will not try and stop helping others because you don't like my answers. I found a perfectly good way how not to do something that wasn't exactly wrong anyway. if you can take another persons honest attempt to help someone and twist it into something it is not, I can only suggest you look in the mirror and only if you're truly perfect you continue your banter. by the way, I am not here to promote Python. but if this is of your concern, perhaps maybe you should rethink how you respond in kind towards post you do not exactly agree with. Others are reading this and it might not come off as promotional material. Also, if you're having a bad day, take a rest and relax. You just might deserve it. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to clear up a List in python?
I guess Fredrik's message was more along the lines of ``don't try to help others after a week or two toying with the language because you might be offering disservice, despite your good intentions; leave this to more experienced users``. The words might have been a bit harsher but that's just his style; you'll get used to it if you hang around here often. I much rather stand corrected than to silently remain ignorant. I take revision of my solution for all it's worth but to be belittled without correction is arrogant and unnecessary. I've been working with Python for several months now and I feel I know plenty *but* I am still learning. I personally never had to clear a list. I never thought of Roberts answer and my reasoning is in Roberts message. In the end I stood correct because Robert was nice enough to answer two birds with one stone. Fredrik on the other hand had nothing positive to add and his message seemed gestapo. Where I come from and how I grew up is quite simple. A wrong answer is better than no answer and a worthless remark is worth garbage. Why? Because no right answer is gospel and no answer no matter how dumb is cause for discourtesy. I tried and thats the bottom line. -- http://mail.python.org/mailman/listinfo/python-list
Re: NEWB: how to convert a string to dict (dictionary)
I am sure something much more elaborate will show it's face but this I made in about 10 minutes. Didn't do much testing on it but it certainly does convert your string modeled after a dictionary into a real dictionary. You might wish to check against more variations and possibilities and tweak and learn till your heart is content... def stringDict(stringdictionary): ''' alpha! convert a string dictionary to a real dictionary.''' x = str(stringdictionary[1:-1].split(':')) res = {} for index, keyval in enumerate(x.split(',')): if index == 0: keyval = keyval[2:] if index % 2 == 0: y = keyval.lstrip( ').rstrip('\ ) res[y] = None else: z = keyval.lstrip( \ ').rstrip(') res[y] = z res[y] = z[:-2] print res # {'syllable': u'cv-i b.v^ y^-f, 'ketiv-qere': 'n', 'wordWTS': u'8'} sd = {'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} stringDict(sd) keep in mind the above code will ultimately return every value as a substring of the main string fed in so may not be very helpful when trying to save int's or identifiers. None the less, I hope it is useful to some degree :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Books?
Learning Python by Mark Lutz will be the most perfect book to get you started! Perhaps there are others aimed at the non-programmer but after getting through that book (2 times) I finally left it with wings... It is a great book for the n00b in my humble opinion. After that, you'll pretty much start flying higher on your own as long as you always keep the python docs handy along with the addresses to comp.lang.python and it's IRC channel #python on irc.freenode.net... Good luck, welcome to Python! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Books?
Thanks vbgunz that was the reply I was looking for! Do you think it is wise to hold back for a 3rd edition? No, 2nd edition is literally perfect. The reason why is because almost nothing significant enough has changed since it's publication. In other words, you will not learn any outdated material. everything you learn in Learning Python is still applicable in the latest version of Python (2.4.3, 2.5). I will not be surprised in the least if typos are the only items corrected in the 3rd edition, perhaps along with a little bit of some new material. The fundamentals, the basics, the only real knowledge necessary to start getting busy in Python is found in the book. Good luck, I hope you enjoy it! -- http://mail.python.org/mailman/listinfo/python-list
Re: IronPython 1.0 Beta 7 Released
maybe I am a bit ignorant and love living in the bliss of it and maybe I am a bit tired on the subject but may I ask you a question? if i decided to use IronPython for strict cPython work, is this possible? probably dumb when I can use cPython but is it still possible in case maybe sometime down the road I wanted to use the .NET libaries? In other words, IronPython is Python but with the extra capability of working in .NET correct? Do you have some introductory information on it? I am very interested on some news that explains what IronPython is. What would you recommend I check out for a great intro on IronPython? -- http://mail.python.org/mailman/listinfo/python-list
Don't wish to give up on a Tkinter GUI Builder :(
Hello world, I tried looking everywhere for a decent Tkinter GUI builder and the closest I got to finding one before being horrified from looking at the source was vtcl @ http://vtcl.sourceforge.net. The next closest thing was page @ http://page.sourceforge.net/ Page just didn't cut it for me and I got several errors from it whereas vtcl was almost a dream come true. it was not only perfect but I had a full fledged gui design up and running at the click of a file in less than ten minutes with so many widgets neatly placed... When I looked at the source, it was in Tcl... It was huge at about 477 lines for a nice and complete interface... problem is I don't know Tcl from chinese... I assume it is Tcl because the extension on the generated file was Tcl... Man, what a let down... The following sites had nothing helpful on the subject at all... http://www.awaretek.com/toolkits.html http://wiki.python.org/moin/GuiProgramming http://groups.google.com/group/comp.lang.python http://google.com Yup, I searched it all.. Maybe I am searching with the wrong keywords or maybe not a single good gui designer for tkinter even exist? Chances are extremely high at this point the only robust GUI builder for Tkinter is probably Vim . please do not recommend Komodo... I am aware of wxPython, GTK, QT and several others but Tkinter strikes me as perfect... I am not at all worried about the looks of it just the idea of one gui on all platforms strikes me as nice! if at this point you're a veteran at Tkinter Gui design and you know for a fact no Tkinter Gui builder exist now and no plans on making one exist and you know everthing about Tkinter, please advise. Ok, even if you don't know everything do you have a suggestion? My main concern is one Gui builder for an interface for all platforms, no special editing per platform. Just one edit and its game over, hello world. Is this too much to ask for? Thank you for your time! -- http://mail.python.org/mailman/listinfo/python-list
Re: New beginner to python for advice
I am a new beginner to python, would you like give me some advice on studying it? http://www.python.org/doc/ is a real great place to start. Are you looking for different advice? -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't wish to give up on a Tkinter GUI Builder :(
Thank you very much for the link and info. It looks promising but I am still on the lookout for a drag-n-drop Gui builder like vltc so if anyone has more links to new projects I am definitely interested! PS. I do love the code generated from rapyd! -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't wish to give up on a Tkinter GUI Builder :(
What are you building? I routinely do things like these by hand www.greschke.com/unlinked/images/changeo.jpg www.greschke.com/unlinked/images/pocus.jpg www.greschke.com/unlinked/images/pis.jpg www.greschke.com/unlinked/images/petm.jpg and I can't imagine using a builder for anything 'simpler'. the reason I do not wish to go the hand-route is because I am personally very bad at math *but* am very attentive to aesthetic organization. I am somewhat more of an artist than I am an architect. I do wish to choose an editor for my designs :) I tried rapyd today, too. Started it, drug a button to the frame, but then couldn't figure out how to set the text of the button. Deleted it. :) next time don't drug it. take the button to at least one dinner and then drug it, then drag it to the frame and you'll find the text option in the left pane under options :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't wish to give up on a Tkinter GUI Builder :(
As for the code to actually make the application go, well, if there is some automatic way to make that happen it hasn't dawned on me yet. why not execute 'python -u /pathto/module.py' I could be wrong but hope I am not :) -- http://mail.python.org/mailman/listinfo/python-list
Re: find all index positions
Hello John, Thank you very much for your pointers! I decided to redo it and try to implement your suggestion. I think I did a fair job and because of your suggestion have a better iterator. Thank you! def indexer(string, substring, overlap=1): '''indexer(string, substring, [overlap=1]) - int indexer takes a string and searches it to return all substring indexes. by default indexer is set to overlap all occurrences. to get the index to whole words only, set the overlap argument to the length of the substring. The only pitfall to indexer is it will return the substring whether it stansalone or not. list(indexer('ababababa', 'aba')) [0, 2, 4, 6] list(indexer('ababababa', 'aba', len('aba'))) [0, 4] list(indexer('ababababa', 'xxx')) [] list(indexer('show chow', 'how')) [1, 6] ''' index = string.find(substring) if index != -1: yield index while index != -1: index = string.find(substring, index + overlap) if index == -1: continue yield index if __name__ == '__main__': print list(indexer('ababababa', 'aba')) # - [0, 2, 4, 6] print list(indexer('ababababa', 'aba', len('aba'))) # - [0, 4] print list(indexer('ababababa', 'xxx')) # - [] print list(indexer('show chow', 'how')) # - [1, 6] -- http://mail.python.org/mailman/listinfo/python-list
Re: find all index positions
I forgot to explain my reason for over shadowing the 'string' built-in within my iterator. To me, it doesn't matter because the string identifier is temporary within the function and dies when the function dies. Also, I personally don't use the string function and prefer ''.join('hi'), etc. Also, at least for me just starting out in Python, I find 'string' to be as readable as possible :) what do you think about that? -- http://mail.python.org/mailman/listinfo/python-list
Re: find all index positions
I thought this to be a great exercise so I went the extra length to turn it into a function for my little but growing library. I hope you enjoy :) def indexer(string, target): '''indexer(string, target) - [list of target indexes] enter in a string and a target and indexer will either return a list of all targeted indexes if at least one target is found or indexer will return None if the target is not found in sequence. indexer('a long long day is long', 'long') [2, 7, 19] indexer('a long long day is long', 'day') [12] indexer('a long long day is long', 'short') None ''' res = [] if string.count(target) = 1: res.append(string.find(target)) if string.count(target) = 2: for item in xrange(string.count(target) - 1): res.append(string.find(target, res[-1] + 1)) return res if __name__ == '__main__': print indexer('a long long day is long', 'long')# - [2, 7, 19] print indexer('a long long day is long', 'day') # - [12] print indexer('a long long day is long', 'short') # - None -- http://mail.python.org/mailman/listinfo/python-list
Re: 2 books for me
The cookbook assumes you know some Python. if you know it, you're good :) If you're new to Python and programming I would recommend 'Learning Python' by Mark Lutz and David Ascher. if you're very familiar with programming but need to catch up on Python syntax, I would recommend the Python in a nutshell by Alex Martelli. I would also recommend you always keep a copy of the official Pythons docs by your side. They're priceless in my opinion. Good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python CHM Doc Contains Broken Links on Linux in xCHM.
Thank you Razvan. You're right. I downloaded the 1.7.1 source and built it and the links do work just fine. Thank you for pointing that out! -- http://mail.python.org/mailman/listinfo/python-list
Re: Using StopIteration
sequence = ['','2'] for index, line in enumerate(sequence): if line.isspace():continue if line[:1].isdigit(): print 'index %s: starts with digit %s' % (index, line[:1]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Using StopIteration
to catch and recover from StopIterations, use this: try: raise StopIteration except StopIteration: print 'caught StopIteration!' # verbose: sys.exc_info() requires import sys -- http://mail.python.org/mailman/listinfo/python-list
Re: Memory leak in Python
how big is the set? 100MB, more? what are you doing with the set? do you have a small example that can prove the set is causing the freeze? I am not the sharpest tool in the shed but it sounds like you might be multiplying your set in/directly either permanently or temporarily on purpose or accident. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why list.sort() don't return the list reference instead of None?
to throw fire on the fuel (:P), you can get the value back to an in-place mutable change with a single expression... mylist = [2,3,4,1] print mylist.sort() or mylist might not be too pythonic or maybe it is. I guess depends on what side of the glass you might wish to view the solution :) -- http://mail.python.org/mailman/listinfo/python-list
Python CHM Doc Contains Broken Links on Linux in xCHM.
Hello! this is the main error: http://img406.imageshack.us/img406/5218/screenshotxchmerror1ae.png navigation link images broken here: http://img406.imageshack.us/img406/2822/screenshotxchmv12python24docum.png when I first open up the docs, the main page and Global Module Index links in the tree are unaccessible. They give me errors. While navigating a page like found at 2.3.7 (Set Types), the See Also link to the module 'sets' is broken also. Is this a problem with the chm docs themselves OR is it a problem with xCHM? The same chm works just fine on Windows whereas on Linux I am having problems. Anyone experiencing the same? is a fix coming? Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: Replace
pay attention to Ryan. Do not use 'str' as an identifier as you will over write the built-in doing so. this seems easiest so far. s = tyrtrbd =ffgtyuf == =tyryr =u=p ff s = s.replace('=', '=#') print s # - tyrtrbd =#ffgtyuf =#=# =#tyryr =#u=#p ff -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this a legal / acceptable statement ?
you don't have to say: if True == l_init it is suggested you simply say: if l_init: Remember the and operator requires expressions on both sides to be true to continue. If you notice, your expression on the right side of the 'and' is an assignment and so this is forbidden (SyntaxError). assignments only work on lines by themselves and no where else. if you meant == rather than = remember this, l_value doesn't exist and would pull up a NameError *but* because the first expression evaluates as false the second expression is never evaluated. refactor your code ASAP. good luck! -- http://mail.python.org/mailman/listinfo/python-list
Re: print out each letter of a word
what errors are you getting? Could it be an indentation error? I don't see anything wrong with the script except the value of fruit is missing. if fruit is a string, it should work like a charm. double check the length of the fruit with print len(fruit) and check fruit with print type(fruit) and make sure it really is a 'str'. Also, fruit has to already exist in the script e.g. 'fruit = apple'. Next time post your errors too. -- http://mail.python.org/mailman/listinfo/python-list
Re: append function problem?
seed = [1,2,3] seed.append(4) print seed # [1,2,3,4] many of the list methods are in place methods on a mutable object. In other words, doing the following results in None. seed = [1,2,3] seed = seed.append(4) print seed # None you also just wiped out your list... The append method like many other list methods simply return None. To get the value of an append, append first then access later like so. seed = [1,2,3] seed.append(4) print seed # [1,2,3,4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Extending Methods Vs Delegates
I am sorry I couldn't reply sooner! Alex, Python in a nutshell is my bible and I take it virtually everywhere! Seriously, I would highly recommend it to anyone with a little to a lot of Python experience. I apologize for misinterpreting your passage on page 80. I will look much closer at your examples, links and ideas and I hope to straighten my knowledge on the subject of delegates! Thank you for hinting on the Template Method design pattern! Sorry for any misunderstanding! -- http://mail.python.org/mailman/listinfo/python-list
Extending Methods Vs Delegates
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where confusion veered it's ugly head :( Learning Python explains on page 324: Class Interface Techniques (21.3.3 in the ebook) the following is an extender method. ''' ''' class SuperClass: def method(self): print 'SuperClass.method' class SubClass(SuperClass): def method(self): print 'SubClass.method' SuperClass.method(self) x = SubClass() x.method() ''' ''' the purpose of the above is so SubClass does not completely override the SuperClass method. This makes sense and is very easy to follow. Here is where things get a bit hazy... Learning Python also explains that the following is what is called a delegate (same page in book). ''' ''' class SuperClass: def delegateMethod(self): self.action() class SubClass(SuperClass): def action(self): print 'SubClass.action()' x = SubClass() x.delegateMethod() # calls SubClass.action() ''' ''' I went back and fourth in the Learning Python book for a clearer explanation on what exactly is a delegate and came up empty. Here is where the confusion was unleashed in all it's fury. When I decided to cross reference the idea of delegates with Python in a nutshell, it said example one above is the delegate... What? Python in a nutshell explains on page 80: Delegating to superclass method (5.1.6.2 in the ebook) that the first example above (extending to Learning Python) is the actual delegate. You're probably confused too huh? I'll try to explain. Learning Python touches on extending and delegating methods. Extending them in Learning Python seems to make perfect sense. Learning Python didn't do a great job on really explaining what a delegates purpose and application is *so* when I decided to cross reference it with Python in a nutshell, Python in a nutshell explains that extending (according to LP) is really delegating... I hope I've made some sense with this question. I ultimately wish to know just one real thing. Regardless of the name of the second example above, what is the purpose of calling a sub class method from a super class instance? What is the application to such a design? The reason I ask is because it is honest to god confusing and I've heard of delegates before... Maybe an example will help? I could be off entirely... One of the books have to be wrong or like my wife mentioned, maybe they both touch on half the truth? Any help is greatly appreciated! -- http://mail.python.org/mailman/listinfo/python-list
Re: My Generator Paradox!
I believe I understand now. the yield keyword is sort of like a cousin to return. return will bring back an object I can work with and so does yield *but* yield's object will most likely support the .next() method. So, if I worked with a function that ends with the return keyword and it returns a list, I can run list operations and list methods on it. if a function ends with the yield keyword a generator should return. So, calling the function by it's name will always reset and initialize the generator. Whereas assigning to the functions yielded return grants access to the real generator in which I can use the next() method. Maybe I've explained it wrong *but* it does make sense to me now. I just couldn't grasp it because I am still new to the keyword yield and didn't know it sort of works like return. I really wish to thank you fellas so much for your examples and explanations! I think I got it! I thank you all again! -- http://mail.python.org/mailman/listinfo/python-list
Re: My Generator Paradox!
OK. I hope my understanding of the yield keyword and generators in a general sense are now better understood. When a generator function is assigned to an identifier, no code is executed and a generator is immediately returned. When the next() method is called on the new generator, code from top to bottom executes within the generator until it reaches it's first yield. Many yields can appear within one generator. When this is the case a next method call will execute code from yield to yield. Code that appears in a loop after a yield keyword is executed on the next() method call. I hope I got it right. I love you guys for your patience and examples. It is greatly appreciated and means very much to me! Thank you fellas! -- http://mail.python.org/mailman/listinfo/python-list
My Generator Paradox!
I am afraid that this is the first time in which I would probably need something explained to me as if I were a little child. I am having a hard time getting this through my thick skull. What in the world is wrong with this!? ''' ### ''' def generatorFunction(sequence=['item1', 'item2', 'item3']): for item in sequence: yield item yieldedValue = generatorFunction() '''this seems to work perfectly.''' print '-' * 32 print yieldedValue # generator object at 0xb723014c print yieldedValue.next() # item1 print yieldedValue.next() # item2 print yieldedValue.next() # item3 '''this is where things don't make any sense!''' print '-' * 32 print generatorFunction() # generator object at 0xb723022c print generatorFunction().next()# item1 print generatorFunction().next()# item1 print generatorFunction().next()# item1 ''' ### ''' the first set of calls assigned to yieldedValue work but the second set without assignment don't. I asked for help on this at #python (I love those people in there!) and was told the following... generatorFunction() is a call (obvious) when calling the second set, I am resetting the iteration and this explains why I only and always get item1. ok. *but* why in the world does the first set of calls work? technically, isn't yieldedValue == generatorFunction() on a name basis? I mean isn't the following technically the same? generatorFunction() yieldedValue = generatorFunction() aren't they both the same? To me they should be but obviously this creates the point of this paradox. I don't understand what is happening here... Can someone care to explain why the assignment works but not the direct call? In a sense shouldn't the assignment yield the same results as the direct call and vice versa? I am confused :( Thank you for any help on this! -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument Precedence (possible bug?)
Hello, Steven D'Aprano, Terry Jan Reedy! I would really like to extend my thanks to you guys. I hope I've got it right this time! def posKeyArgs(a, b=2, c=3): print a, b, c #posKeyArgs(b=20) # too few positional arguments. a needs an arg. #posKeyArgs(10, c=30, 20) # pos_args cannot follow any kw_args. def specialArgs(*args, **kwargs): # Can't call these keywords! print args print kwargs specialArgs(args='arg1', kwargs='kwargs') # Keywords match nothing. specialArgs('string') # not converted. Collected into: ('string',) The above can begin to explain why I had problems with my first example. *args and **kwargs cannot have arguments assigned to them by keyword. Once an argument is matched by keyword, all following arguments must also be matched by keyword. This would explain why using only positional arguments, my first example would have worked right out of the box. Because, all positionals would have matched first, then all left overs would have been collected into *args, then finally any keyword args would be collected into **kwargs. So far the general consensus also seems to be not to over complicate a function definition with such parameters. This makes sense and is why I chose Python over many other options. I love the idea of explicit over implicit :) Again though, my first example was only a personal reference. Fellas, thank you all so much for helping me understand this much better. You guys are my angels of Python for sure! -- http://mail.python.org/mailman/listinfo/python-list
Argument Precedence (possible bug?)
Hello all, I am just learning Python and have come across something I feel might be a bug. Please enlightenment me... The following code presents a challenge. How in the world do you provide an argument for *arg4? ## def argPrecedence(par1, par2=0, par3=0, *par4, **par5): print 'par1 =', par1, ' # positional argument' print 'par2 =', par2, ' # keyword argument' print 'par3 =', par3, ' # keyword argument' print 'par4 =', par4, ' # argument converted to tuple' print 'par5 =', par5, ' # argument converted to dictionary' argPrecedence('arg1', arg3='arg3', arg2='arg2', arg5='arg5') # argPrecedence Results: par1 = arg1 # positional argument par2 = arg2 # keyword argument par3 = arg3 # keyword argument par4 = () # argument converted to tuple par5 = {'arg5': 'arg5'} # argument converted to dictionary ## The code above is verbose with comments because I am just learning Python and am creating my own examples and reference materials... Can you solve the problem? If so, can you share the solution? If not, is this a bug, limitation or is it a feature? Thank you for your time on this one! PS. I could be far off with this codes purpose; to try and create an example that will house all the different possible parameters (positional, keyword, * and **) in one single def statement. -- Best Regards Victor B. Gonzalez -- http://mail.python.org/mailman/listinfo/python-list
Argument Precedence (possible bug?)
Hello all, I am just learning Python and have come across something I feel might be a bug. Please enlightenment me... The following code presents a challenge. How in the world do you provide an argument for *arg4? ## def argPrecedence(par1, par2=0, par3=0, *par4, **par5): print 'par1 =', par1, ' # positional argument' print 'par2 =', par2, ' # keyword argument' print 'par3 =', par3, ' # keyword argument' print 'par4 =', par4, ' # argument converted to tuple' print 'par5 =', par5, ' # argument converted to dictionary' argPrecedence('arg1', par3='arg3', par2='arg2', par5='arg5') # argPrecedence Results: par1 = arg1 # positional argument par2 = arg2 # keyword argument par3 = arg3 # keyword argument par4 = () # argument converted to tuple par5 = {'arg5': 'arg5'} # argument converted to dictionary ## The code above is verbose with comments because I am just learning Python and am creating my own examples and reference materials... Can you solve the problem? If so, can you share the solution? If not, is this a bug, limitation or is it a feature? Thank you for your time on this one! PS. I could be far off with this codes purpose; to try and create an example that will house all the different possible parameters (positional, keyword, * and **) in one single def statement. -- Best Regards Victor B. Gonzalez -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument Precedence (possible bug?)
Please forgive my call() Change this: argPrecedence('arg1', arg3='arg3', arg2='arg2', arg5='arg5') to this: argPrecedence('arg1', par3='arg3', par2='arg2', arg5='arg5') Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument Precedence (possible bug?)
Hello all, I am just learning Python and have come across something I feel might be a bug. Please enlightenment me... The following code presents a challenge. How in the world do you provide an argument for *arg4? ## def argPrecedence(par1, par2=0, par3=0, *par4, **par5): print 'par1 =', par1, ' # positional argument' print 'par2 =', par2, ' # keyword argument' print 'par3 =', par3, ' # keyword argument' print 'par4 =', par4, ' # argument converted to tuple' print 'par5 =', par5, ' # argument converted to dictionary' argPrecedence('arg1', par3='arg3', par2='arg2', arg5='arg5') # argPrecedence Results: par1 = arg1 # positional argument par2 = arg2 # keyword argument par3 = arg3 # keyword argument par4 = () # argument converted to tuple par5 = {'arg5': 'arg5'} # argument converted to dictionary ## The code above is verbose with comments because I am just learning Python and am creating my own examples and reference materials... Can you solve the problem? If so, can you share the solution? If not, is this a bug, limitation or is it a feature? Thank you for your time on this one! PS. I could be far off with this codes purpose; to try and create an example that will house all the different possible parameters (positional, keyword, * and **) in one single def statement. -- Best Regards Victor B. Gonzalez -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument Precedence (possible bug?)
I am sorry I hung you up on a typo Peter Hansen. On line 5 *arg4 should have been *par4. I hope it makes complete sense now. Sorry. -- http://mail.python.org/mailman/listinfo/python-list
Re: Argument Precedence (possible bug?)
Please allow me some time to look at your examples. I get hung up over the smallest details because in my mind, my approach should have just worked... I learned about these parameters reading O'reilly Learning Python 2nd Edition. On page 217 of the paperback or Chapter 13.5.6 in the ebook, topic: 'Argument matching: The Gritty Details' mentions the following in verbatim... ...''' Moreover, Python internally carries out the following steps to match arguments before assignment: 1. Assign non-keyword arguments by position. 2. Assign keyword arguments by matching names. 3. Assign extra non-keyword arguments to *name tuple. 4. Assign extra keyword arguments to **name dictionary. 5. Assign default values to unassigned arguments in header. '''... As you can probably tell, I tried to follow the steps exactly, except step 5 got me lost so I tried not to question it. Anyhow, thank you very much for your time and examples. I will get back to you as soon as I am done putting your response to trial. Thank you! -- http://mail.python.org/mailman/listinfo/python-list