ANN: Assembly Line 0.5
I've uploaded a new version of my PyWeek 6 game, Assembly Line. http://media.pyweek.org/dl/6/gregpw6/AssemblyLine-0.5.zip As a potential Pyggy entry, I'm keen to get some testing and feedback on it. This version is greatly expanded. Some of the new features include: * More machine types and enhanced machine functionality * Simulation of a market that's buying your products * Multiple factories * Extensive reports showing what's going on with sales and finances * Sales and profit targets to aim for, and salary raises to seek after Note that not all the products and machines are available at once now. The new machines will become available as the game progresses (about one every two months of game time) and you need to spend money to research new products. I still haven't done much playtesting or balancing -- I've verified that the Phunky Phrisbee, Mojo Mallet and Supa Slice can be manufactured and sold at a profit, but I don't know about the others yet. -- Greg -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
[ANN] Leipzig Python User Group - Meeting, May 13, 2008, 08:00pm
=== Leipzig Python User Group === We will meet on Tuesday, May 13 at 8:00 pm at the training center of Python Academy in Leipzig, Germany ( http://www.python-academy.com/center/find.html ). Christian Theune will give a talk about Grok ( http://grok.zope.org ). Food and soft drinks are provided. Please send a short confirmation mail to [EMAIL PROTECTED], so we can prepare appropriately. Everybody who uses Python, plans to do so or is interested in learning more about the language is encouraged to participate. While the meeting language will be mainly German, we will provide English translation if needed. Current information about the meetings are at http://www.python-academy.com/user-group . Mike == Leipzig Python User Group === Wir treffen uns am Dienstag, 13.05.2008 um 20:00 Uhr im Schulungszentrum der Python Academy in Leipzig ( http://www.python-academy.de/Schulungszentrum/anfahrt.html ). Christian Theune wird einen Vortrag über Grok ( http://grok.zope.org ) halten. Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter [EMAIL PROTECTED] wäre nett, damit wir genug Essen besorgen können. Willkommen ist jeder, der Interesse an Python hat, die Sprache bereits nutzt oder nutzen möchte. Aktuelle Informationen zu den Treffen sind unter http://www.python-academy.de/User-Group zu finden. Viele Grüße Mike -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
REMINDER: Python Sprint Weekend This Weekend!
Just a friendly reminder that this weekend is the Python sprint weekend! Look forward to seeing everyone on #python-dev irc.freenode.net over the course of the weekend! Trent. On 16 Apr, 18:52, Trent Nelson wrote: Following on from the success of previous sprint/bugfix weekends and sprinting efforts at PyCon 2008, I'd like to propose the next two Global Python Sprint Weekends, taking place on the following dates: * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) It seems there are a few of the Python User Groups keen on meeting up in person and sprinting collaboratively, akin to PyCon, which I highly recommend. I'd like to nominate Saturday across the board as the day for PUGs to meet up in person, with Sunday geared more towards an online collaboration day via IRC, where we can take care of all the little things that got in our way of coding on Saturday (like finalising/preparing/reviewing patches, updating tracker and documentation, writing tests ;-). For User Groups that are planning on meeting up to collaborate, please reply to this thread on [EMAIL PROTECTED] and let every- one know your intentions! As is commonly the case, #python-dev on irc.freenode.net will be the place to be over the course of each sprint weekend; a large proportion of Python developers with commit access will be present, increasing the amount of eyes available to review and apply patches. For those that have an idea on areas they'd like to sprint on and want to look for other developers to rope in (or just to communicate plans in advance), please also feel free to jump on this thread via python-dev@ and indicate your intentions. For those that haven't the foggiest on what to work on, but would like to contribute, the bugs tracker at http://bugs.python.org is the best place to start. Register an account and start searching for issues that you'd be able to lend a hand with. All contributors that submit code patches or documentation updates will typically get listed in Misc/ACKS.txt; come September when the final release of 2.6 and 3.0 come about, you'll be able to point at the tarball or .msi and exclaim loudly ``I helped build that!'', and actually back it up with hard evidence ;-) Bring on the pizza and Red Bull! Trent. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Python Bootcamp at Big Nerd Ranch
It's just a flesh wound! - Student Review Just a quick reminder that it's not too late to register for my upcoming Python Bootcamp course at Big Nerd Ranch, June 9 - 13 in Atlanta, GA. http://www.bignerdranch.com/classes/python.shtml This class is an intense hands-on introduction to Python and its standard libraries. Even if you've used Python before, this class may have a lot to offer as it is fully up-to-date with modern Python features. The above web site has more information, but feel free to contact me personally for more details about the class. Cheers, David Beazley (Course Instructor) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Plotdb fiction writer's database.
I am pleased to announce the availability of an application developed to aid fiction writers on Linux. It is called plotdb, the plot database. It is designed to help track all the components of a story, including characters, objects, concepts and locations, and to attach them to chapters and scenes in a way that facilitates the story-writing component of authoring. I wrote this application to scratch an itch I had for free (as in beer and as in freedom) novel writing software for Linux. The pure python version of plotdb is v.0.3. This sounds extremely low, like pre-alpha, but the application began existence in the early fall of 2007 using a different database engine. Recently, I decided to move to sqlite as the database back end, which is supported as a native module in python 2.5.x. The first release of the version written in pure python was dated 4/30/2008. I have used the original version of this software extensively since it's initial incarnation in August of 2007. I have used this pure python version since I ported it to sqlite. There is no real difference that I can see in the two versions, except the pure python version is easier to maintain, albeit slightly slower. I would consider this beta quality software, tested somewhat in real usage but not full production yet. I am currently writing a novel and use this software daily for that purpose. I, David May, am the sole party of blame in the production of this application. It was conceived and written by me from scratch. You can get plotdb with my compliments at: http://w3.cnm.edu/~dmay/plotdb.html plotdb is released under GPL v.2. I am willing, as time permits, to incorporate changes made by users into the application. I am particularly interested in portability changes that allow plotdb to be used on Windows or Mac, since I use Linux almost exclusively. You can contact me at dmay at cnm dot edu If this is not the correct forum to announce this software, please accept my apologies in advance. And thanks in advance for any direction anyone can provide on where else this should be posted to capture the largest audience of interest. I do not lurk this list, so please respond to my email as well as (or in lieu of) posting to the list. Kind regards, David F. May -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: The Importance of Terminology's Quality
George Neuner gneuner2/@/comcast.net wrote: On Wed, 7 May 2008 16:13:36 -0700 (PDT), [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: +---+ .:\:\:/:/:. | PLEASE DO NOT |:.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: | | '=(\ 9 9 /)=' | Thank you, | ( (_) ) | Management | /`-vvv-'\ +---+ / \ | |@@@ / /|,|\ \ | |@@@ /_// /^\ \\_\ @x@@x@| | |/ WW( ( ) )WW \/| |\| __\,,\ /,,/__ \||/ | | | jgs (__Y__) /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ == jue -- http://mail.python.org/mailman/listinfo/python-list
The del statement
One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]: Equivalent to x.__delitem__(i) (3) del x.a: Equivalent to x.__delattr__('a') (or delattr(x,'a')) (1) is useful, or even necessary, at least as long as there are only two namespaces (local and global) instead of a separate namespace per block, so that's ok for now. The other two though, don't justify IMO a separate statement. I would strongly prefer (2) to be implemented by a normal method instead of a special syntax and method. See the inconsistency: s = ['a', 'b'] s.pop(0) del s[0] Likewise for dicts. Why not s.del(0) ? And just in case someone argues for the same reason we have __getitem__ and __setitem__, it is not the same; the syntax for get/set (s[0], s[0] = 'a') doesn't introduce a new keyword (or overload an existing one), it is pretty intuitive and used across many languages. As for (3), it is pretty uncommon to deserve its own syntax; delattr() or directly modifying self.__dict__ are good enough. I understand that no more proposals are accepted for Python 3 but it looks like a missed opportunity to make the language a bit simpler and more consistent. Anyone else have an opinion on this? George -- http://mail.python.org/mailman/listinfo/python-list
Re: The del statement
George Sakkis wrote: One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]: Equivalent to x.__delitem__(i) (3) del x.a: Equivalent to x.__delattr__('a') (or delattr(x,'a')) Note that the 'X = Y' construct has the corresponding three meanings: (1) x = 4 # Bind x to 4 in the 'current namespace' (2) x[i] = 4 # equivalent to x.__setitem__(i, 4) (3) x.a = 4 # Equivalent to x.__setattr__('a', 4) What conclusion should we draw from that? -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Am I missing something with Python not having interfaces?
Am Mittwoch 07 Mai 2008 22:39:30 schrieb Luis Zarrabeitia: There you have it, interfaces are not enough to ensure that the implementors actually implement the methods. They are useful for warning at compile time if there is a missing method, but nothing more. It's not the fault of the enviroment, if the coder is to stupid to use it the right way. I believe you could achieve a very similar warning in python using some kind of Interface metaclass (too lazy right now to hack a proof of concept, but it looks doable). Of course. And unlike Javas interfaces, it ensure a more dynamic coding-style, without great tools which check all the time for correct behaviour. -- http://mail.python.org/mailman/listinfo/python-list
python newbie: some surprises
When I started coding in python, these two things surprised me. 1. my code is inconsistently indented with the combination of tabs and spaces. Even lines looked intended, but it is not. 2. python requires to pass self to all instance methods and I missed : often. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: strftime() argument 1 must be str, not unicode
Andrii V. Mishkovskyi [EMAIL PROTECTED] wrote: 2008/5/7 Alexandr N Zamaraev [EMAIL PROTECTED]: Subj is bag? Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from datetime import datetime datetime.today().strftime('%Y_%m_%d %H_%M_%S.csv') '2008_05_07 12_30_22.csv' datetime.today().strftime(u'%Y_%m_%d %H_%M_%S.csv') Traceback (most recent call last): File stdin, line 1, in module TypeError: strftime() argument 1 must be str, not unicode Unicode and str objects are not the same. Why do you think that this is a bug? I think that's a perfectly reasonable thing to expect. At the risk of over-generalization, there is no good reason why, by this point in time, all of the standard library routines that accept strings shouldn't also accept Unicode strings. It's the duck typing principle. Unicode strings look, walk, and talk like regular strings. An error like this is not intuitive. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
How to gather information about the system hardware?
Hi, I'm looking for a method of gathering information about the system hardware and software installed using Python. I would like to do it in UNIX and in Windows. I think that it would be good in Windows to look in the registry and be able to parse and search it. Any pointer to information would be appreciated. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Am I missing something with Python not having interfaces?
Am Donnerstag 08 Mai 2008 00:12:26 schrieb [EMAIL PROTECTED]: very often sees do-nothing catch-all try/catch blocks in Java - which is way worse than just letting the exception propagate. I find all this totally pointless, because there's just no way for a compiler to check if your code is logically correct. But it's enough if the called method exists and returns the correct type. At least it prevents a crash. Interfaces work at compile-time, while method-stubs raise at their first call, so in worst case, never. And then ? If it's never called, why bother implementing it ? You never can't say when it's called at least, that's the point. That's the point. Interfaces garantee that a duck is a duck, an not only a chicken that quack. Who cares if it's a chicken as long as it quacks when you ask her to ? Now *This* is the whole point of chicken^Mduck typing, isn't it ?-) Ducks can also swim and fly. And if you need a really duck, but have onyl a chicken while the coder was to bored to make one... Of course, in the practical world that all doesn't matter. But in the theoretical world of the big coding farms, called business, that's one cornerstone of success, in the tinking of managers and so. -- http://mail.python.org/mailman/listinfo/python-list
Re: python newbie: some surprises
v4vijayakumar wrote: When I started coding in python, these two things surprised me. 1. my code is inconsistently indented with the combination of tabs and spaces. Even lines looked intended, but it is not. Even the standard editor Idle tries to guess the intendation, so this was never a problem for me. Though these days I use PyDev a lot. 2. python requires to pass self to all instance methods A lot of editors help you with these 'unnecessary' things by auto-completion might be worth looking into one. and I missed : often. :) Still do after 5 years of python abuse :-) -- mph -- http://mail.python.org/mailman/listinfo/python-list
Problems with os.walk
Hi everyone The following code: scriptPath = os.path.dirname(__file__) (dirpath, dirnames, filenames) = os.walk(scriptPath) print 'dirpath\n' print dirpath print 'dirnames\n' pprint.pprint(dirnames) print 'filenames\n' pprint.pprint(filnames) Fails on the os.walk call with the following error: (dirpath, dirnames, filenames) = os.walk(scriptPath) ValueError: need more than 1 value to unpack Any ideas what could be wrong? Thx greetings Dominique * This e-mail and any files attached are strictly confidential, may be legally privileged and are intended solely for the addressee. If you are not the intended recipient please notify the sender immediately by return email and then delete the e-mail and any attachments immediately. The views and or opinions expressed in this e-mail are not necessarily the views of De La Rue plc or any of its subsidiaries and the De La Rue Group of companies, their directors, officers and employees make no representation about and accept no liability for its accuracy or completeness. You should ensure that you have adequate virus protection as the De La Rue Group of companies do not accept liability for any viruses. De La Rue plc Registered No.3834125, De La Rue Holdings plc Registered No 58025 and De La Rue International Limited Registered No 720284 are all registered in England with their registered office at: De La Rue House, Jays Close, Viables, Hampshire RG22 4BS * -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the purpose of ptyhon in Windows
On May 7, 9:35 pm, Max Erickson [EMAIL PROTECTED] wrote: WolfgangZ [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: hi All, http://mail.python.org/mailman/listinfo/python-list At least I'm living in a free country and nobody forces me to learn python. So I don't fully understand why you HAVE TO learn it. When your problems can be solved in a different programming language than you should be free to use whatever you like. And also why should it be forbidden to create a new programming language? Diversity and competition is usually not bad. -- http://mail.python.org/mailman/listinfo/python-list I imagine that there is some English as a second language getting involved and the intent of the question was more like What is python useful for on Windows?, which has pretty much the same meaning but is open to a slightly friendlier interpretation(i.e., tell me how I can use python instead of tell me why I should use python). The other question might be more like I already know VBS, what do I gain by learning python?. (the answers could be lots of things, including full applications and among other things, you can use it on other platforms, and you might prefer the syntax.) max thanks to all, Can you all forward me some sites where there may examples of work done on Python and that which I amy bring into some application -- http://mail.python.org/mailman/listinfo/python-list
Re: DISLIN 9.3 stuck
On 8 Mai, 02:55, adolfo [EMAIL PROTECTED] wrote: ... 1- The strange thing is that I went to thedislindirectory in the C: drive and there was no disli.pyd file anywhere. I found the file in the My Documents subdirectory where I had originally unzipped thedislinarchived files I downloaded and from where I run the setup. The name of the Dislin module for Python 2.5 is dislin.pyd, not disli.pyd. It's copied by the setup program to the directory c:\dislin\python if you have choosed the default installation directory c:\dislin. you should set environment variableDISLINtoo (see python.inf, which you can find in thedislin-distribution) 2 - Well I have followed theDISLIN9.3 inf file for Python 2.5.2 for Windows. It contains commands for a unix command line unzip -o dl_93_py.zip setup first and then... and then: Windows 98/ME Add the following commands to the autoexec.bat file PATH=c:\dislin\win;%PATH% SETDISLIN=c:\dislin SET PYTHONPATH=c:\dislin\python Windows NT/2000/XP/Vista The environment variables can be set or modified with the Control Panel (see - Control Panel - System - Advanced - Environment Variables). *** I have followed all these directions butDISLINstill does not shop up as a module when making the Python calls. The environment variable for Python is PYTHONPATH without any blanks. You can check the variable with the command 'echo %PYTHONPATH%' at a command prompt. Regards, Helmut -- http://mail.python.org/mailman/listinfo/python-list
Re: anagram finder / dict mapping question
On Thu, 08 May 2008 15:42:07 +1000, dave [EMAIL PROTECTED] wrote: This is what i've came up with. My problem is that I can't get them to properly evaluate.. when comparewords() runs it finds itself... Should I have the keys of mapdict iterate over itself? Is that possible? def annafind(): fin = open('text.txt') # file has one word per line mapdic = {} # each word gets sorted goes in here for line in fin: rawword = line.strip() word = list(rawword) word.sort() mapdic[''.join(word)] = 0 return mapdic def comparewords(): ***not working as intended fin = open('text.txt') for line in fin: line = line.strip() word = list(line) word.sort() sortedword = (''.join(word)) if sortedword in mapdic: print line On 2008-05-07 19:25:53 -0600, Kam-Hung Soh [EMAIL PROTECTED] said: On Thu, 08 May 2008 11:02:12 +1000, dave [EMAIL PROTECTED] wrote: Hi All, I wrote a program that takes a string sequence and finds all the words inside a text file (one word per line) and prints them: def anagfind(letters): #find anagrams of these letters fin = open('text.txt') #one word per line file wordbox = [] #this is where the words will go for line in fin: word = line.strip() count = 0 for char in letters: if char not in word: break else: count += 1 if count == len(word): wordbox.append(word) return wordbox Now I'd like to modify the code to naturally find all anagrams inside a wordlist. What would be the best way to do this? Using Hints? Is it possible to iterate over dict keys? How can I make a dict that maps from a set of letters to a list of words that are spelled from those letters? Wouldn't I need to make the set of letters a key in a dict? As always - Thanks for helping someone trying to learn... Dave Suggestion: for each word, sort their characters and use them as the dictionary key. If two words have the same combination of characters, then they are anagrams. For example: edam and made are anagrams because they have the letters 'a', 'd', 'e' and 'm'. Refer Programming Pearls by Jon Bentley. -- Kam-Hung Soh a href=http://kamhungsoh.com/blog;Software Salariman/ a Your code is always going to return the same list because every word is an anagram of itself. Tip: Create a list for each dictionary key, then add a word to the list if that word is not in the list. So: mapdic('adem') -- [edam, made] P.S. When replying, the convention is to add your response to the bottom, not top of the message. -- Kam-Hung Soh a href=http://kamhungsoh.com/blog;Software Salariman/a -- http://mail.python.org/mailman/listinfo/python-list
Re: strftime() argument 1 must be str, not unicode
Tim Roberts wrote: I think that's a perfectly reasonable thing to expect. At the risk of over-generalization, there is no good reason why, by this point in time, all of the standard library routines that accept strings shouldn't also accept Unicode strings. However, file(fname), open(fname), os .*, os.path .*, time.strftime(format) take unicode parameters. See http://bugs.python.org/issue2782 -- http://mail.python.org/mailman/listinfo/python-list
Re: strftime() argument 1 must be str, not unicode
2008/5/8 Tim Roberts [EMAIL PROTECTED]: Andrii V. Mishkovskyi [EMAIL PROTECTED] wrote: 2008/5/7 Alexandr N Zamaraev [EMAIL PROTECTED]: Subj is bag? Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from datetime import datetime datetime.today().strftime('%Y_%m_%d %H_%M_%S.csv') '2008_05_07 12_30_22.csv' datetime.today().strftime(u'%Y_%m_%d %H_%M_%S.csv') Traceback (most recent call last): File stdin, line 1, in module TypeError: strftime() argument 1 must be str, not unicode Unicode and str objects are not the same. Why do you think that this is a bug? I think that's a perfectly reasonable thing to expect. At the risk of over-generalization, there is no good reason why, by this point in time, all of the standard library routines that accept strings shouldn't also accept Unicode strings. It's the duck typing principle. Unicode strings look, walk, and talk like regular strings. An error like this is not intuitive. On a second thought -- both of you (you and Alexander) are right. I changed mind and posted a bug on Roundup already (bug #2782). -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list -- Wbr, Andrii Mishkovskyi. He's got a heart of a little child, and he keeps it in a jar on his desk. -- http://mail.python.org/mailman/listinfo/python-list
POP connection timeout.
Hi All I am have written an application that queries a POP mailbox and downloads messages. When the application tries to connect to the mail server, but takes too long (eg. longer than 60 seconds) I want to have it time out. Something like try: pop = poplib.POP3(POPHOST, POPPORT) except someerror, err: print Connecting to mail box has timed out:\n, err I know that in python 2.5 I could pass an additional timeout parameter to the above statement ( ie: pop = poplib.POP3(POPHOST, POPPORT, TIMEOUTINSECONDS), but I am using python 2.4. Can anyone help me implement this timeout functionality. Regards Nicol -- The three things to remember about Llamas: 1) They are harmless 2) They are deadly 3) They are made of lava, and thus nice to cuddle. -- http://mail.python.org/mailman/listinfo/python-list
Re: The del statement
Arnaud Delobelle [EMAIL PROTECTED] wrote: George Sakkis wrote: One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]: Equivalent to x.__delitem__(i) (3) del x.a: Equivalent to x.__delattr__('a') (or delattr(x,'a')) Note that the 'X = Y' construct has the corresponding three meanings: (1) x = 4 # Bind x to 4 in the 'current namespace' (2) x[i] = 4 # equivalent to x.__setitem__(i, 4) (3) x.a = 4 # Equivalent to x.__setattr__('a', 4) I think you both missed a case: (1b) global x; del x# Remove x from global namespace (1b) global x; x = 4# Bind x to 4 in the global namespace What conclusion should we draw from that? That Python is simple and consistent. -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
På Thu, 08 May 2008 04:14:35 +0200, skrev Kyle McGivney [EMAIL PROTECTED]: • Module, Block, in Mathematica is in lisp's various “let*”. The lisp's keywords “let”, is based on the English word “let”. That word is one of the English word with multitudes of meanings. If you look up its definition in a dictionary, you'll see that it means many disparate things. One of them, as in “let's go”, has the meaning of “permit; to cause to; allow”. This meaning is rather vague from a mathematical sense. Mathematica's choice of Module, Block, is based on the idea that it builds a self-contained segment of code. (however, the choice of Block as keyword here isn't perfect, since the word also has meanings like “obstruct; jam”) If the purpose of let is to introduce one or more variable bindings, then I don't see how changing to block or module would improve anything. I've always found it fairly intuitive to parse (let ((x 5)) ...) to let x be five. Additionally, replacing let with the synonyms you provided would approximately yield permit x to be five or allow x to be five. In my mind you have constructed an argument in favor of let here (obviously it's better than block, because nobody's going to come along and be confused about whether let will obstruct or jam them :) How about bind? (bind ((v f (mod i)) ((a b) list) (t (rem q))) 1. is a multiple-value-bind 2. is a destructuring-bind 3. is a let http://common-lisp.net/project/metabang-bind/ To me this is a example of where the ANSI group could have spent more time on naming. -- John Thingstad -- http://mail.python.org/mailman/listinfo/python-list
Re: explain this function to me, lambda confusion
[EMAIL PROTECTED] wrote: Here is a simple lambda that implements an exclusive or: def XOR(x,y) : return lambda : ( ( x ) and not ( y ) ) or ( not ( x ) and ( y ) ) (Because of the resemblance to C macros, I have been cautious and written the lambda with lots of parentheses.) To use this in later code, we define instances of the lambda with specific function arguments. topping = XOR( cream, icecream) sauce = XOR( tomato, BBQ ) We now have two øfunctionsñ, topping() and sauce() which we can use later to test flags. cream = True icecream = False print topping() True No, no, no, no, no! You have got it entirely wrong here. Your XOR function simply returns a function which gives you the result of xoring the parameters AT THE TIME WHEN YOU ORIGINALLY CREATED IT. I'm guessing that you had already set cream and icecream (otherwise the call to XOR would have thrown an exception) and at leas one was true. Try setting them both False at the beginning: cream = False icecream = False topping = XOR( cream, icecream) cream = True icecream = False print topping() False Using a lambda was a completely pointless exercise here, you could have just returned the result directly: def XOR(x,y): return x^y topping = XOR(cream, icecream) print topping True Same thing for your TFF function: def TFF(x,y,z) : return x and not y and not z AddOnly = TFF( options.AddAction, options.ReplaceAction, options.DeleteAction ) DeleteOnly = TFF( options.DeleteAction, options.AddAction, options.ReplaceAction ) ReplaceOnly = TFF( options.ReplaceAction, options.AddAction, options.DeleteAction ) if not (DeleteOnly or AddOnly or ReplaceOnly): print Error: Exactly one of [ --add | --replace | --delete ] allowed. parser.print_help() exit which boils down to: if (options.AddAction + options.ReplaceAction + options.DeleteAction) != 1: print Error: ... -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
| PLEASE DO NOT | :.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: I don't think Xah is trolling here (contrary to his/her habit) but posing an interesting matter of discussion. Don't know to which point it fits, but I would like to do some rather novel comment on operator naming: As a non native english speaker, the first time I ever encountered the word if was when learning to program. The same can be said of the other words (for, then, else...) This caused my brain to adscribe them meanings completely outside the context of everyday language. My point is that perhaps this is advantageous. So, contrary to tradition (which considers a desirable goal to write programs as close as possible to everyday english), I found convenient that programming languages use words different from the words of my native tongue. I suspect that is why car and cdr have caught on vs. first end rest. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with os.walk
[EMAIL PROTECTED] writes: (dirpath, dirnames, filenames) = os.walk(scriptPath) You're supposed to loop over values in different directories, like this: for dirpath, dirnames, filenames in os.walk(scriptPath): ... handle dirpath with dirnames and filenames ... The loop will be executed for each subdirectory (direct and indirect) of scriptPath. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to gather information about the system hardware?
On May 8, 2:14 am, Florencio Cano [EMAIL PROTECTED] wrote: Hi, I'm looking for a method of gathering information about the system hardware and software installed using Python. I would like to do it in UNIX and in Windows. I think that it would be good in Windows to look in the registry and be able to parse and search it. Any pointer to information would be appreciated. Thanks. The 'platform' module gives a lot of information about the hardware and OS. To access the Windows Registry, you can use the '_winreg' module. -- http://mail.python.org/mailman/listinfo/python-list
Re: The del statement
Duncan Booth wrote: Arnaud Delobelle [EMAIL PROTECTED] wrote: George Sakkis wrote: One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]: Equivalent to x.__delitem__(i) (3) del x.a: Equivalent to x.__delattr__('a') (or delattr(x,'a')) Note that the 'X = Y' construct has the corresponding three meanings: (1) x = 4 # Bind x to 4 in the 'current namespace' (2) x[i] = 4 # equivalent to x.__setitem__(i, 4) (3) x.a = 4 # Equivalent to x.__setattr__('a', 4) I think you both missed a case: (1b) global x; del x# Remove x from global namespace (1b) global x; x = 4# Bind x to 4 in the global namespace This is why you put 'current namespace' in quotes! But all three of us missed the case: (1-3000) What about nonlocal? That Python is simple and consistent. Seems reasonable to me. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Python module for SNMP bindings ?
Hi, While looking around for Python API's to do SNMP, found the following link with a high level comparison -- http://urchin.earth.li/~twic/SNMP_in_Python.html i.e. options seems to be: PySNMP (complete SNMP impl.), SNMPy, yapSNMP (Net-SNMP bindings). Of those, yapSNMP seems to be most promising. Any comments ? -- regards, Banibrata http://www.linkedin.com/in/bdutta http://octapod.wordpress.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't drag and drop onto .py in Windows XP?
Roger Upole [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Sizer wrote: It's just a little weird that I can't just drag and drop file names onto .pyw or .py files. Am I missing something here? Thanks for any help. You can register a DropHandler for the Python file class. Put this in a .reg file and merge it into the registry: REGEDIT4 [HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler] @={86C86720-42A0-1069-A2E8-08002B30309D} Sir, you rock! I found that it actually worked a little better if I used a generic wsh drop handler instead of the .exe handler, but I would never have known where to start looking without your suggestion. I ended up with the following .reg file, and now I can drag and drop files onto my .py, .pyw, and .pyc files and off they go as you'd expect. It kind of seems like this should be the default installer behavior unless there's a good reason not to do it. Thanks again for your help. REGEDIT4 [HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler] @={60254CA5-953B-11CF-8C96-00AA00B8708C} [HKEY_CLASSES_ROOT\Python.NoConFile\shellex\DropHandler] @={60254CA5-953B-11CF-8C96-00AA00B8708C} [HKEY_CLASSES_ROOT\Python.CompiledFile\shellex\DropHandler] @={60254CA5-953B-11CF-8C96-00AA00B8708C} -- http://mail.python.org/mailman/listinfo/python-list
Re: The del statement
Arnaud Delobelle [EMAIL PROTECTED] wrote: Duncan Booth wrote: Arnaud Delobelle [EMAIL PROTECTED] wrote: George Sakkis wrote: One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]: Equivalent to x.__delitem__(i) (3) del x.a: Equivalent to x.__delattr__('a') (or delattr(x,'a')) Note that the 'X = Y' construct has the corresponding three meanings: (1) x = 4 # Bind x to 4 in the 'current namespace' (2) x[i] = 4 # equivalent to x.__setitem__(i, 4) (3) x.a = 4 # Equivalent to x.__setattr__('a', 4) I think you both missed a case: (1b) global x; del x# Remove x from global namespace (1b) global x; x = 4# Bind x to 4 in the global namespace This is why you put 'current namespace' in quotes! But all three of us missed the case: I'd assumed you were just trying to say that the current namespace might be different things: locals or a class namespace. I would say that the global statement makes the assign/del refer to a non-current namespace. (1-3000) What about nonlocal? What about nonlocal? You can't (in Python 2.x) assign or del a name from an enclosing scope if that's what you mean. If that isn't what you mean then you'll have to explain it to me in simpler terms. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to use subprocess.Popen execute find in windows
En Wed, 07 May 2008 23:29:58 -0300, [EMAIL PROTECTED] escribió: On 5月7日, 上午9时45分, Justin Ezequiel [EMAIL PROTECTED] wrote: On May 6, 5:19 pm, [EMAIL PROTECTED] wrote: p1 = Popen(['netstat', '-an'], stdout = PIPE) p2 = Popen(['find', '445'], stdin = p1.stdout, stdout = PIPE) print p2.stdout.read() It doesn't work. Because subprocess.Popen execute find like this. C:\find \445\ It adds a '\' before each ''. How to remove the '\'? Thank you. cannot help with the backslashes but try findstr instead of find Thank you. findstr doesn't need quotes, so it works. Build the command line yourself -instead of using a list of arguments-. Popen doesn't play with the quotes in that case: p1 = Popen(['netstat', '-an'], stdout = PIPE) # using list p2 = Popen('find 445', stdin = p1.stdout, stdout = PIPE) # using str print p2.communicate()[0] -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP + TinyButStrong Python replacement
[EMAIL PROTECTED] ha scritto: On 7 mai, 16:17, pistacchio [EMAIL PROTECTED] wrote: George Sakkis ha scritto: (snip) What does it matter if it's a single file or a dozen under a package ? Installation for pure Python packages can be as simple as copying the package under any directory in your PYTHONPATH. well, it doesn't matter if it's a single file or a package, but it _does_ matter if you have to put them under the path where python is installed because, in a typical shared web hosting environment (such the one that i use) you don't have access to system directories. You *never* have to install anything in the default path - install your python libs wherever you want, and just make sure this wherever is in your python path (usually via the PYTHONPATH environment variable). again, in a shared environment, you don't have access to environment variables. all you can do is copy files in your own little directory, and that's it. this directory is never something like /share/python, but something like /home/averagejoe. and /home/averagejoe is not usually in the PYTHONPATH Check out Mako (http://www.makotemplates.org/), it's pretty powerful and fast. woudl you suggest mako over cheetah? As far as I'm concerned, I would. Now if you're looking for a somewhat barebone MVC framework, you may want to have a look at web.py. i've tried mako. sees to work fine for me, both for its potential and for its installation method. in fact i just copied it under my own directory /home/averagejoe test.py /mako mako stuff and the following testcase worked well: from mako.template import Template mytemplate = Template(hello world!) print mytemplate.render() can i do the same with web.py? mind that i work under an apache environment (mod_python). now, back to mako. can you provide an example of blocks and nested blocks in mako? the documentation doesn't seem to be too clear in this reguard. for example, if i want to show a table with a list of restaurants (gathered from a db query), i can construct a template like this: table % for rest in restaurants: tr${rest}tr % endfor /table but what if if each restaurant has a list of dishes (pasta, pizza, meat, pie) and some (or each) dish has the ingrediets? is it just like embedding pure python into the template ( like $(rest['dish']) and $rest['dish']['ingredient']) )? thanks for you interest -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
From: [EMAIL PROTECTED] [EMAIL PROTECTED] the importance of naming of functions. I agree, that's a useful consideration in the design of any system based on keywords, such as names of functions or operators. (I'm not using keyword in the sense of a symbol in the KEYWORD package.) the naming in Mathematica, as Stephen Wolfram implied in his blog above, takes the perspective of naming by capturing the essense, or mathematical essence, of the keyword in question. For concepts adapted from mathematics, that naming meta-convention makes sense. For concepts adapted from data-processing, it's not so clearly good. lambda, widely used as a keyword in functional languages, is named just Function in Mathematica. That makes sense, but then what does Mathematica call the special operator which Common Lisp calls Function? Or is that not provided, and the programmer must case-by-case handcode what they really mean? (function foo) == (symbol-function 'foo) ;so FUNCTION not really needed there (function (lambda (x) (+ x y)) ;y is a lexical variable to be encapsulated ; into the resultant closure How would you do something like that in mathematica? Module, Block, in Mathematica is in lisp's various let* The lisp's keywords let, is based on the English word let. No, that's not correct. It's based on the mathematical use of let: Let R be the complete ordered field of real numbers. Let S be the subset of R consisting of numbers which satisfy equations expressed in transcendental functions with rational parameters. Prove that S is dense in R. (Yeah, the question is trivial, but I'm just showing how let might be used.) I see nothing wrong with LET used in that way in Lisp. Bind would be good too. I don't like Module or Block at all, because those words convey nothing about binding some temporary local name to represent some globally-definable concept, and they actually mis-lead because module can mean either something like a vector space over a ring, or a set of functions/methods that serve some small problem domain within a larger library of functions/methods, or a set of lectures on a single-topic within a curriculum, while Block sounds more like just some random consecutive interval of statements rather having nothing specific to do with bindings. TAGBODY or PROGN would be more properly called Block perhaps. One easy way to confirm this, is taking a keyword and ask a wide audience, who doesn't know about the language or even unfamiliar of computer programing, to guess what it means. That is a biassed question because the only options are the words you choose in advance. Better would be to reverse the question: Ask random people on the street what they would like to call these concepts: 1 You set up a temporary relation between a name and some datum, such that all references to that name give you that same datum. For example you might set up the name 'n' to temporarily mean 5. Fill in the missing word: (word (n 5) say ouch n times) 2 You set up a rule by which one step of data-processing is performed, taking input to produce output. For example you set up a rule by which the input value is divided by two if it's even but multiplied by three and then 1 added if it was odd. Fill in the missing word: (word (n) if n even n/2 else 3*n+1) 3 You set up a rule as above, but also give it a permanent name. Fill in the missing word: (word collatz (n) if n even n/2 else 3*n+1) 4 You already have a rule that takes two input data and produces one output. (oldword foo (x y) absolute value of difference between x and y) You now know one of the two inputs, and that info won't change for a while, and you hate to keep repeating it. So you want to define a new rule that has that one known parameter built-in so that you only have to say the *other* parameter each time you use the new rule. Fill in the missing newword: (newword foo x is fixed as 3) So I'd choose words: 1=let 2=lambda 3=defun 4=curry. What words would a typical man on the street choose instead? The name regex has done major hidden damage to the computing industry I have my own gripe against regular expressions (regex for short). I hate the extremely terse format, with horrible concoctions of escape and anti-escape magic characters, to fit within Unix's 255-character limit on command lines, compared to a nicely s-expression nested notation that would be possible if regex hadn't entrenched itself so solidly. -- http://mail.python.org/mailman/listinfo/python-list
Re: pickle problem
[EMAIL PROTECTED] wrote: I'm wondering if anyone can help with a workaround for a problem I currently have. I'm trying to set up a prefork tcp server. Specifically, I'm setting up a server that forks children and has them listen on pipes created with os.pipe(). The parent process for the group starts an inet:tcp server on a given port. In the parent, after a socket.accept(), I'm trying to pickle the connection object to send over an IPC pipe (as stated previously), but I get the following error: File /usr/lib/python2.4/copy_reg.py, line 76, in _reduce_ex raise TypeError(a class that defines __slots__ without TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled Does anyone know of a workaround for this? Maybe my approach to this is wrong? Any help would be appreciated. The error-message is pretty clear I'd say. You use slots - so you are responsible yourself for implementing the pickling-protocol using __getstate__ and __setstate__. Looking at the pickle-docs should give you an idea. But the really easy solution is: do not use slots. They are intended as memory-consumption optimization technique, *not* as I want to declare my attributes explicitly-mechanism. So - get rid of them and be a happy pickler. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
[EMAIL PROTECTED] wrote: | PLEASE DO NOT |:.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: I don't think Xah is trolling here (contrary to his/her habit) but posing an interesting matter of discussion. Interesting is in the eye of the beholder. After you'd read the same recycled crud from certain posters again and again, it because trollish spam. -- Lew -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
Robert Maas, http://tinyurl.com/uh3t wrote: I have my own gripe against regular expressions (regex for short). I hate the extremely terse format, with horrible concoctions of escape and anti-escape magic characters, to fit within Unix's 255-character limit on command lines, compared to a nicely s-expression nested notation that would be possible if regex hadn't entrenched itself so solidly. This is all very interesting, but not Java. -- Lew -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
On 2008-05-08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? Yes, and all programs that people write typically look like the hello world program. Look at some real-world programs for a comparison, for example the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/ what can i do easily with python which is not easy in c++/java !? - be productive in programming, rather than hassling with declaring all kind of stuff first. - skip compile step. On the other hand, if you typically write hello world programs, don't bother. You won't see the difference. Sincerely, Albert -- http://mail.python.org/mailman/listinfo/python-list
Re: Am I missing something with Python not having interfaces?
On Thu, 2008-05-08 at 09:12 +0200, Daniel Marcel Eichler wrote: Am Mittwoch 07 Mai 2008 21:48:56 schrieben Sie: That's the point. Interfaces garantee that a duck is a duck, an not only a chicken that quack. Which, in spite of your rhetorical flourish, is the exact opposite of duck typing. Duck typing means that if you're looking for quacking behavior, and you find a quacking chicken, it's close enough. I didn't said that interfaces are a kind of duck-typing. In fact it was the exact opposite. Sometimes you need that kind of rigor, and you can get it as easily as And sometimes you need more. So what? More rigor than Zope's interfaces offer? That's new information to me. Perhaps you should stop being argumentative for a moment, and explain exactly what it is you're looking for and why Zope interfaces don't fit the bill. -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP + TinyButStrong Python replacement
-On [20080507 15:06], Mike Driscoll ([EMAIL PROTECTED]) wrote: http://genshi.edgewall.org/ http://www.kid-templating.org/ http://www.cheetahtemplate.org/ http://turbogears.org/ Add the following to that list: http://jinja.pocoo.org/ http://www.makotemplates.org/ I think Jinja and Mako are currently two of the fastest around. -- Jeroen Ruigrok van der Werven asmodai(-at-)in-nomine.org / asmodai イェルーン ラウフロック ヴァン デル ウェルヴェン http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B If Winter comes, can Spring be far behind..? -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
On May 8, 5:25 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy in c++/java !? Are you a newbie to Python, or to programming in general? I'll assume you are a newbie to programming in general because of that last question you asked. Things in Python are easier than in almost any other programming language. Here are three Hello World programs: --C++- #include iostream.h main() { cout Hello World!; return 0; } -- -Java- class HW { public static void main(String args[]) { System.out.println(Hello World!); } } -- Python print Hello World! -- --C#-- I have no idea! -- I think you can clearly see which one is easiest. Of course, that doesn't mean that the easiest language is always the best language, although it is a strong point. But ease of use is just a one- in-a-million characteristic of Python. If you're a total beginner, I'd recommend you learning the one that attracts you the most. -- http://mail.python.org/mailman/listinfo/python-list
Urgent opening for Engineer (Open Source Technologies)
Hi,This is regarding an opening for software Engineer(Open Source Technologies) The opening is with our client for their Noida branch.They are working on various platforms like Microsoft,Open Source Technology. The designation will be of software engineer/senior software engineer. Skillset Required will be Plone,experience in development implementation of applications using Python open source technologies. Experience : 2-3 years Qualification : BE/B.Tech/MCA/PGDCA or equivalent. If you are interested you can forward your CV on this mail id [EMAIL PROTECTED] as early as possible. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
[EMAIL PROTECTED] ha scritto: Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? well, it's similar in the sense that it is a programming language. So you can say that assembly is similar to BASIC, but that both are different from finnish, but from a programmer's point of view, they're all rather different languages. what can i do easily with python which is not easy in c++/java !? generally speaking python is said to be easier to pick up for a pletora of reasons. technically speaking, it is not, for example, strongly typed, nor it forces you to use a programming paradigm like object oriented programming. This means that if you just want to see your name printed on the screen you can simply write: print raxit and get the work done. to understand it you just have to understand some basics like what is a string and what is a statement. in java, for example, it would look like: public class HelloWorld { public static void main(String[] args) { System.out.println(raxit); } } in short, to obtain the same result (limited to this case) you have to write 650% more code and you're forced to know what is a class, what namespace means, what is a function (and arguments) and what are methods and the dot notation and an array. not that you won't encounter all of them learning python, but you're presented with all of them, all at once, in the moment where you just want to write the simplest program. that's why a typical java beginner's guide starts with ditto examples and adds: ignore everything for the moment. i hate when i have to ignore things of a code that i'm writing! the same applies to C# and, to a certain extend, C++ that is a much older language and present different learning problems. Now, what can you do with python? Virtually everything (network programming, game programming, server side scripting). In most cases, it would run slower than it would do with the other languages (even slower than the slow java). You won't do drivers or kernels in python, but you won't even code them in java or C#. the programs you'll write will mostly run on a number of different platform, like java programs. porting a c++ is a bit tougher. at the moment there is project (mono) that is porting the .net platform (where c# runs) to multiple platforms, but basically, if you write a c# program you're programming for windows. hope it helps Tnx, Raxit www.mykavita.com -- http://mail.python.org/mailman/listinfo/python-list
Re: #!/usr/bin/env python vs. #!/usr/bin/python
This is sort of related, but I'm wondering what is different between #!/usr/bin/env python and #!python. Wouldn't the second do the same thing, since an absolute path is not specified, find 'python' from the PATH environment, I don't really know. Brian Vanderburg II -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
Hi Raxit, One of the the tempting features of Python is that it is fun to code in Python. If you are really trying to learn python, you should read Adventures with Neko (http://gnuvision.com/books/pybook/) . It is an introductory book on Python programming for school children by Mr. Pramode CE. It is fun for children (when I tried it, me too liked it) to do programming with Neko, the cat. I am sure that it will be a fun filled learning experience for you. Regards, Maxin B. John pistacchio wrote: [EMAIL PROTECTED] ha scritto: Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? well, it's similar in the sense that it is a programming language. So you can say that assembly is similar to BASIC, but that both are different from finnish, but from a programmer's point of view, they're all rather different languages. what can i do easily with python which is not easy in c++/java !? generally speaking python is said to be easier to pick up for a pletora of reasons. technically speaking, it is not, for example, strongly typed, nor it forces you to use a programming paradigm like object oriented programming. This means that if you just want to see your name printed on the screen you can simply write: print raxit and get the work done. to understand it you just have to understand some basics like what is a string and what is a statement. in java, for example, it would look like: public class HelloWorld { public static void main(String[] args) { System.out.println(raxit); } } in short, to obtain the same result (limited to this case) you have to write 650% more code and you're forced to know what is a class, what namespace means, what is a function (and arguments) and what are methods and the dot notation and an array. not that you won't encounter all of them learning python, but you're presented with all of them, all at once, in the moment where you just want to write the simplest program. that's why a typical java beginner's guide starts with ditto examples and adds: ignore everything for the moment. i hate when i have to ignore things of a code that i'm writing! the same applies to C# and, to a certain extend, C++ that is a much older language and present different learning problems. Now, what can you do with python? Virtually everything (network programming, game programming, server side scripting). In most cases, it would run slower than it would do with the other languages (even slower than the slow java). You won't do drivers or kernels in python, but you won't even code them in java or C#. the programs you'll write will mostly run on a number of different platform, like java programs. porting a c++ is a bit tougher. at the moment there is project (mono) that is porting the .net platform (where c# runs) to multiple platforms, but basically, if you write a c# program you're programming for windows. hope it helps Tnx, Raxit www.mykavita.com -- http://mail.python.org/mailman/listinfo/python-list
Re: #!/usr/bin/env python vs. #!/usr/bin/python
For me, the difference is #!python doesn't work for me. I get a bad interpreter error. On Thu, May 8, 2008 at 6:31 AM, Brian Vanderburg II [EMAIL PROTECTED] wrote: This is sort of related, but I'm wondering what is different between #!/usr/bin/env python and #!python. Wouldn't the second do the same thing, since an absolute path is not specified, find 'python' from the PATH environment, I don't really know. Brian Vanderburg II -- http://mail.python.org/mailman/listinfo/python-list -- | _ | * | _ | | _ | _ | * | | * | * | * | -- http://mail.python.org/mailman/listinfo/python-list
RE: Newbie to python --- why should i learn !
pls dont learn it Move on The world is full enough of 9 to 5 coders Mark From: [EMAIL PROTECTED] Subject: Newbie to python --- why should i learn ! Date: Thu, 8 May 2008 03:25:17 -0700 To: python-list@python.org Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy in c++/java !? Tnx, Raxit www.mykavita.com -- http://mail.python.org/mailman/listinfo/python-list _ Tired of having no room left in your inbox? Windows Live Hotmail now gives you 5GB of FREE storage! Get your free Windows Live Hotmail account here! http://get.live.com/mail/overview-- http://mail.python.org/mailman/listinfo/python-list
Re: Generate labels for a multi-level outline
Castironpi, Do you want send and throw in it too? If its not too much trouble, I would love to see how you add these. formatter.NullFormatter.format_counter formatter.NullFormatter.format_letter formatter.NullFormatter.format_roman I'm not sure what you mean by the above lines ... googling ... are you referencing formatter.py? http://www.koders.com/python/fid4B7C6E1C20384FC7521414F46DF9DAA33DF2CA11.aspx Thanks for your help on this - I'm learning a lot! Malcolm PS: throw( up ) ... very funny! :) -- http://mail.python.org/mailman/listinfo/python-list
framework build question for mac
Hello, I just had to install an older version of python for a particular app. Afterward, I had some necessary clean-up so that my normal work python would work, but I noticed something odd about the installation. Python is installed on the Mac in the directory /Library/Frameworks/Python.framework/Versions where there is (now) a 2.5 and a 2.4 directory, and a link called Current which points to the 2.5 directory. So far, so good. Now, the python binary (as well as idle, and some other python related binaries) are in /usr/local/bin and are links: python@ - ../../../Library/Frameworks/Python.framework/Versions/2.5/ bin/python pydoc@ - ../../../Library/Frameworks/Python.framework/Versions/2.5/ bin/pydoc python2.4@ - ../../../Library/Frameworks/Python.framework/Versions/ 2.4/bin/python2.4 etc... Now, what I find odd is that the generic binaries (python, pydoc, etc...) as opposed to the version-specific binaries (python2.4, python2.5, etc...) do not point to the Current link in the /Library/ Frameworks/Python.framework/Versions/ directory, but instead point to the last python installed. As a result, in addition to re-pointing the Current link, I also had to manually re-point python, pydoc, idle, etc... in /usr/local/bin Is there a reason for this, or is it just a small oversight on the install script? thanks, Brian Blais -- Brian Blais [EMAIL PROTECTED] http://web.bryant.edu/~bblais -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
C# using System; namespace HelloWorld { Class HelloWorld { static void Main(String[] args) { Console.WriteLine(Hello World); } } } -- http://mail.python.org/mailman/listinfo/python-list
python equivalent to perl's inplace edit mechanism
Does python have an equivalent to Perl's inplace-edit variable $^I? For example, the following perl code below changes mike to dave in a file that is passed as an argument. #!/usr/bin/env perl #chgit script $^I = ''; while() { s/mike/dave/g; print; } The script would be used as below: chgit somefile Afterward, all instances of mike are changed to dave. Thanks. Mike -- | _ | * | _ | | _ | _ | * | | * | * | * | -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
hello, I have programmed co insidentally in all the 3 languages. so out of my experience of 10 + years, I got my personal share of reasons to prefer python over the other 2 namely c++ and java. firstly as every one has already explained, python is easy, fun to learn and can do many things much productively for programmers compared to c++ and java. and c# is no better in that. besides, now a days python has become much much faster in some cases faster than java. compare pygtk vs java swing. python has huge amount of libraries/ modules which are as easy to use as the language itself. the syntax difference mentioned in the first email on this thread makes a huge difference when the code becomes complex and the number of lines increase. so there are a lot of reasons to prefer python over java. for the question what can I do in python easier than other languages is not a question to be answered because it all depends on how one associates the problem space with the language space in which the programmer wishes to express the solution. there will be people who will say java is much better choice for large scale programmes but people like myself will always question that. happy hacking. Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list
Re: Idea for P3K
M�ta-MCI (MVP) wrote: Hi! I don't often feel like using this word Look at languages like OCAML or F # The point being? Yes, shockingly enough other languages have other syntax semantics. Diez -- http://mail.python.org/mailman/listinfo/python-list
POP connection timeout.
Hi All I have written an application that queries a POP mailbox and downloads messages. When the application tries to connect to the mail server, but takes too long (eg. longer than 60 seconds) I want to have it time out. Something like try: pop = poplib.POP3(POPHOST, POPPORT) except someerror, err: print Connecting to mail box has timed out:\n, err I know that in python 2.5 I could pass an additional timeout parameter to the above statement ( ie: pop = poplib.POP3(POPHOST, POPPORT, TIMEOUTINSECONDS), but I am using python 2.4. Can anyone help me implement this timeout functionality. Regards Nicol -- The three things to remember about Llamas: 1) They are harmless 2) They are deadly 3) They are made of lava, and thus nice to cuddle. -- The three things to remember about Llamas: 1) They are harmless 2) They are deadly 3) They are made of lava, and thus nice to cuddle. -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing elapsed time as a string
En Fri, 02 May 2008 16:13:41 -0300, Simon Pickles [EMAIL PROTECTED] escribió: I'm sorry if this has been asked a thousand (million) times. Is there a nifty pythonesque way to produce a string representing an elapsed time period, in terms of years, months, days, hours, mins, seconds? I am storing times in a MySQL db, and would love to be able to write the time elapsed between accesses of certain data. These are in seconds since the epoch, as produced by time.time() Two options: a) You can construct a datetime object with that info, using datetime.datetime.fromtimestamp() (note that the MySQLdb module already returns datetime objects for timestamp columns in MySQL). If you substract two datetime objects, you get a timedelta object, which stores info as whole days, seconds (fraction of day) and microseconds (fraction of second). If you can live with years having exactly 365 days and months having exactly 30 days (or up to 35!): def timedelta_str(td): def plural(n): if n1: return 's' return '' out = [] y, d = divmod(td.days, 365) if y: out.append('%d year' % y + plural(y)) m, d = divmod(d, 30) if m: out.append('%d month' % m + plural(m)) if d: out.append('%d day' % d + plural(d)) h, s = divmod(td.seconds, 60*60) if h: out.append('%d hour' % h + + plural(h)) m, s = divmod(s, 60) if m: out.append('%d min' % m + plural(m)) if s: out.append('%d sec' % s + plural(s)) return ' '.join(out) py from datetime import datetime py d1 = datetime(1992, 5, 11, 8, 23, 8, 612) py d2 = datetime.now() py print d1 1992-05-11 08:23:08.000612 py print d2 2008-05-08 09:21:53.592000 py print timedelta_str(d2-d1) 16 years 1 day 58 mins 45 secs or b) Use the dateutil package http://labix.org/python-dateutil It is probable right in front of me in the docs but I am spinning off into outer space (mentally!) Nope... showing time intervals as years,months,days... isn't trivial, because there are many special cases, and sometimes legal issues too. It's impossible to make everyone happy in this topic. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: #!/usr/bin/env python vs. #!/usr/bin/python
On Thu, 08 May 2008 07:31:17 -0400 Brian Vanderburg II [EMAIL PROTECTED] wrote: This is sort of related, but I'm wondering what is different between #!/usr/bin/env python and #!python. Wouldn't the second do the same thing, since an absolute path is not specified, find 'python' from the PATH environment, I don't really know. Well, I know what happened when I tried it. What happened when you tried it? -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent to perl's inplace edit mechanism
#!/usr/bin/env perl #chgit script $^I = ''; while() { s/mike/dave/g; print; } #!/usr/bin/python import sys lines = open(sys.argv[1]).readlines() open(sys.argv[1], 'w').writelines([line.replace('mike', 'dave') for line in lines]) -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent to perl's inplace edit mechanism
En Thu, 08 May 2008 09:11:56 -0300, Michael Mabin [EMAIL PROTECTED] escribió: Does python have an equivalent to Perl's inplace-edit variable $^I? For example, the following perl code below changes mike to dave in a file that is passed as an argument. #!/usr/bin/env perl #chgit script $^I = ''; while() { s/mike/dave/g; print; } The script would be used as below: chgit somefile Afterward, all instances of mike are changed to dave. Like this? code import sys,fileinput for line in fileinput.input(inplace=True): sys.stdout.write(line.replace('mike','dave')) /code Sample session: C:\TEMPtype foo.txt this line tells about mike and john this second line says nothing goodbye mike! C:\TEMPpython chgit.py foo.txt C:\TEMPtype foo.txt this line tells about dave and john this second line says nothing goodbye dave! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: slicing lists
Yves Dorfsman wrote: So would it be a worthy addition to python, to add it right in the core of the language, and hopefully in an efficient manner ? Note that the s[0,2:6] syntax is currently allowed because of the distinct semantics that the Numeric module and its successors numarray and numpy had for it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with os.walk
Hrvoje Niksic wrote: [EMAIL PROTECTED] writes: (dirpath, dirnames, filenames) = os.walk(scriptPath) You're supposed to loop over values in different directories, like this: for dirpath, dirnames, filenames in os.walk(scriptPath): ... handle dirpath with dirnames and filenames ... The loop will be executed for each subdirectory (direct and indirect) of scriptPath. And if you are simply hand-experimenting, try somthing like: generator = os.walk(scriptPath) dirpath, dirnames, filenames = generator.next() ... dirpath, dirnames, filenames = generator.next() ... --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent to perl's inplace edit mechanism
On Thu, May 8, 2008 at 2:11 PM, Michael Mabin [EMAIL PROTECTED] wrote: Does python have an equivalent to Perl's inplace-edit variable $^I? I misread your question. No, Python eschews magic characters and symbols. They make code ugly and harder to read and maintain. The first 3 lines of the Zen of Python: Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. You might find a variable like that in Ruby, which has strong Perl influences. David. -- http://mail.python.org/mailman/listinfo/python-list
Re: POP connection timeout.
Aspersieman wrote: I have written an application that queries a POP mailbox and ... I want to have it time out I know that in python 2.5 I could pass an additional timeout parameter to the above statement ( ie: pop = poplib.POP3(POPHOST, POPPORT, TIMEOUTINSECONDS), but I am using python 2.4. Can anyone help me implement this timeout functionality. Obviously, get a copy of 2.5 and back-port the poplib code as poplib25 or some such. If you want more help than that, hire someone to do it. --Scott David Daniels -- http://mail.python.org/mailman/listinfo/python-list
Re: POP connection timeout.
En Thu, 08 May 2008 09:24:37 -0300, Aspersieman [EMAIL PROTECTED] escribió: I have written an application that queries a POP mailbox and downloads messages. When the application tries to connect to the mail server, but takes too long (eg. longer than 60 seconds) I want to have it time out. Something like try: pop = poplib.POP3(POPHOST, POPPORT) except someerror, err: print Connecting to mail box has timed out:\n, err I know that in python 2.5 I could pass an additional timeout parameter to the above statement ( ie: pop = poplib.POP3(POPHOST, POPPORT, TIMEOUTINSECONDS), but I am using python 2.4. Use socket.setdefaulttimeout(timeout_in_seconds) before you create the POP3 object; this value will be used by the initial connect. Once it is connected, you can set a different timeout for retrieving mail using pop.sock.settimeout(...) Note that setdefaulttimeout applies to ALL subsequent socket operations, not only using poplib. http://docs.python.org/lib/socket-objects.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: #!/usr/bin/env python vs. #!/usr/bin/python
D'Arcy J.M. Cain wrote: On Thu, 08 May 2008 07:31:17 -0400 Brian Vanderburg II [EMAIL PROTECTED] wrote: This is sort of related, but I'm wondering what is different between #!/usr/bin/env python and #!python. Wouldn't the second do the same thing, since an absolute path is not specified, find 'python' from the PATH environment, I don't really know. Well, I know what happened when I tried it. What happened when you tried it? I haven't tried it but I've seen some files like written that in the past with just a name and no path for some other interpreter (perl or sh probably) and didn't know what the different was or if it was even valid. I at a windows system now so I can't try it yet. Brian Vanderburg II -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
On Thu, May 8, 2008 at 7:25 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy in c++/java !? Programming in a pure duck typing style http://en.wikipedia.org/wiki/Duck_typing Tnx, Raxit www.mykavita.com -- http://mail.python.org/mailman/listinfo/python-list -- Eduardo de Oliveira Padoan http://www.advogato.org/person/eopadoan/ http://twitter.com/edcrypt Bookmarks: http://del.icio.us/edcrypt -- http://mail.python.org/mailman/listinfo/python-list
Parsing Email 'References' header.
Hi I have a python script that parses email headers to extract information from them. I need to get the _last_ messageid in the 'References' field (http://cr.yp.to/immhf/thread.html) to create a threaded view of these emails (these messageid's are stored in a database). Now, I can easily access the 'References' field using the python 'email' module, but I need a regular expression to get the last messageid in the 'References' field. Here's what I have so far: code rx_lastmesgid = re.compile(r(.+$)) lastmesgid = .join( filter( rx_lastmesgid.match, parentid ) ) # parentid's value is eg:[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] lastmesgid = .join( filter( rx_lastmesgid.match, parentid ) ) /code I need it to return [EMAIL PROTECTED] Can anyone help? Thanks Nicol -- The three things to remember about Llamas: 1) They are harmless 2) They are deadly 3) They are made of lava, and thus nice to cuddle. -- http://mail.python.org/mailman/listinfo/python-list
PCBuild.sin - Attempt to compile Python using Visual Studio 2008
The readme.txt has: All you need to do is open the workspace pcbuild.sln in Visual Studio, select the desired combination of configuration and platform and eventually build the solution. Unless you are going to debug a problem in the core or you are going to create an optimized build you want to select Release as configuration. Unfortunately, the Express Edition (Free) doesn't handle solution files. Installed Edition: VC Express Microsoft Visual C++ 2008 91909-152-052-60812 Microsoft Visual C++ 2008 Does anyone have any advice for a person who has limited C++ experience and none with the Visual C++ please? Colin W. -- http://mail.python.org/mailman/listinfo/python-list
listen on TCP port
Hello, is it possibble listening on TCP port by python and how? I am trying chilkat but poorly :(. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: POP connection timeout.
Gabriel Genellina wrote: Use socket.setdefaulttimeout(timeout_in_seconds) before you create the POP3 object; this value will be used by the initial connect. Once it is connected, you can set a different timeout for retrieving mail using pop.sock.settimeout(...) Note that setdefaulttimeout applies to ALL subsequent socket operations, not only using poplib. http://docs.python.org/lib/socket-objects.html Fantastic! This works thanks. Nicol -- The three things to remember about Llamas: 1) They are harmless 2) They are deadly 3) They are made of lava, and thus nice to cuddle. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing Email 'References' header.
On Thu, May 8, 2008 at 2:53 PM, Aspersieman [EMAIL PROTECTED] wrote: Hi I have a python script that parses email headers to extract information from them. I need to get the _last_ messageid in the 'References' field (http://cr.yp.to/immhf/thread.html) to create a threaded view of these emails (these messageid's are stored in a database). Now, I can easily access the 'References' field using the python 'email' module, but I need a regular expression to get the last messageid in the 'References' field. Here's what I have so far: code rx_lastmesgid = re.compile(r(.+$)) lastmesgid = .join( filter( rx_lastmesgid.match, parentid ) ) # parentid's value is eg:[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] lastmesgid = .join( filter( rx_lastmesgid.match, parentid ) ) /code I need it to return [EMAIL PROTECTED] Can anyone help? .*(.*?) -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
On Thu, 08 May 2008 04:17:01 -0700, s0suk3 wrote: Are you a newbie to Python, or to programming in general? I'll assume you are a newbie to programming in general because of that last question you asked. Things in Python are easier than in almost any other programming language. Here are three Hello World programs: Counterexamples for quite short greetings in other programming languages: (Free)BASIC:: Print Hello World! OCaml:: print_string Hello World! ;; Io:: Hello World! linePrint Haskell:: main = putStrLn Hello World! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: web client in Python Q
On Wed, May 7, 2008 at 11:22 PM, Jive Dadson [EMAIL PROTECTED] wrote: I wonder why it does not work with http://stockcharts.com/webcgi/wb.exe?Data.web+SLW It looks like that is a subscription site. That makes things more complicated, because it means you'll need to figure out how to log in, then probably store cookies related to your session and offer them back up to the web server on subsequent requests. Python has modules that help with these things (mostly in the urllib2 module if i recall correctly), but it's not quite as straightforward as just fetching a URL. I don't have time to dig up an example at the moment, but if you're still having trouble with it, I can try to pull something together this weekend. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re-launch of The Gadgets Forum
Re-launch of The Gadgets Forum Re-launch of The Gadgets Forum - gadgets.pk with new and stunning categories, now you can find latest news and reviews about the following: 1) Audio/Video Gadgets = MP3 Players, iPods, Speakers, Audio/Video Systems, Digital Cameras etc. 2) Automobile Gadgets 3) Cell Phones Accessories 4) Laptops, Desktops Accessories 5) Clocks Watches 6) Gaming Gadgets 7) Geek Toys 8) GPS Satellites 9) Home Office Gadgets 10) Kitchen Gadgets 11) Solar Powered Gadgets 12) Travel Power Gadgets JOIN NOW http://www.gadgets.pk -- http://mail.python.org/mailman/listinfo/python-list
Re: PCBuild.sin - Attempt to compile Python using Visual Studio 2008
En Thu, 08 May 2008 09:55:36 -0300, Colin J. Williams [EMAIL PROTECTED] escribió: The readme.txt has: All you need to do is open the workspace pcbuild.sln in Visual Studio, select the desired combination of configuration and platform and eventually build the solution. Unless you are going to debug a problem in the core or you are going to create an optimized build you want to select Release as configuration. Unfortunately, the Express Edition (Free) doesn't handle solution files. Yes, it does. You get a warning saying that solution *folders* aren't supported; that just means that you won't see those 26 projects nicely grouped, only as a long list, that's all... Python builds fine with Visual C++ Express Edition. Select Release, Win32 from the dropdown lists, press F7, and wait for compilation to complete... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing Email 'References' header.
.*(.*?) Doesn't work if there is only one e-mail address: Here's another one: [^]+$ -- http://mail.python.org/mailman/listinfo/python-list
Re: PCBuild.sin - Attempt to compile Python using Visual Studio 2008
Colin J. Williams wrote: The readme.txt has: All you need to do is open the workspace pcbuild.sln in Visual Studio, select the desired combination of configuration and platform and eventually build the solution. Unless you are going to debug a problem in the core or you are going to create an optimized build you want to select Release as configuration. Unfortunately, the Express Edition (Free) doesn't handle solution files. Installed Edition: VC Express Microsoft Visual C++ 2008 91909-152-052-60812 Microsoft Visual C++ 2008 Does anyone have any advice for a person who has limited C++ experience and none with the Visual C++ please? Colin W. Please ignore the request above. In spite of the above message the program appears to build and execute OK for 2.6a2 Now I have to find where the executable has been placed. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing Email 'References' header.
On Thu, 2008-05-08 at 14:53 +0200, Aspersieman wrote: Hi I have a python script that parses email headers to extract information from them. I need to get the _last_ messageid in the 'References' field (http://cr.yp.to/immhf/thread.html) to create a threaded view of these emails (these messageid's are stored in a database). Now, I can easily access the 'References' field using the python 'email' module, but I need a regular expression to get the last messageid in the 'References' field. Here's what I have so far: code rx_lastmesgid = re.compile(r(.+$)) lastmesgid = .join( filter( rx_lastmesgid.match, parentid ) ) # parentid's value is eg:[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] lastmesgid = .join( filter( rx_lastmesgid.match, parentid ) ) /code I need it to return [EMAIL PROTECTED] Can anyone help? Thanks Nicol Forget regular expressions. py lastmesgid = '' + parentid.split('')[-1] -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
Marc 'BlackJack' Rintsch ha scritto: On Thu, 08 May 2008 04:17:01 -0700, s0suk3 wrote: Are you a newbie to Python, or to programming in general? I'll assume you are a newbie to programming in general because of that last question you asked. Things in Python are easier than in almost any other programming language. Here are three Hello World programs: Counterexamples for quite short greetings in other programming languages: (Free)BASIC:: Print Hello World! freebasic is another language i'd point out to a newbie, even if it is not as multiplatform as python if. it has a decent community and a large amount of libraries. it doesn't let you explore functional or, worse, object oriented programming nor you can write server side programs with it. The others are examples of easy hello world languages, but, passed that, i think they don't have the same capabilities of python on terms of support, kind of programs you can write and even overall complexity (haskell forces you to functional programming, io is really a minor language, ocalm forces you to di OOP and, if writing hello world is simple, on the other hand ir may have lines of code that read like: | [] - [] and that negatively compesate the easy way you can write hello world OCaml:: print_string Hello World! ;; Io:: Hello World! linePrint Haskell:: main = putStrLn Hello World! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
prove
Hello, How could I prove to someone that python accepts this syntax using the documentation (I couldn't find it anywhere): classname.functionname(objectname) -- http://mail.python.org/mailman/listinfo/python-list
Re: listen on TCP port
On Thu, 2008-05-08 at 05:56 -0700, [EMAIL PROTECTED] wrote: Hello, is it possibble listening on TCP port by python and how? I am trying chilkat but poorly :(. Thanks -- http://mail.python.org/mailman/listinfo/python-list You just asked this exact same question yesterday, and got a few responses, none of which are addressed in the post above. Do neither twisted nor the socket module work for you? -- http://mail.python.org/mailman/listinfo/python-list
Re: The del statement
On May 8, 2:58 am, Arnaud Delobelle [EMAIL PROTECTED] wrote: George Sakkis wrote: One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]: Equivalent to x.__delitem__(i) (3) del x.a: Equivalent to x.__delattr__('a') (or delattr(x,'a')) Note that the 'X = Y' construct has the corresponding three meanings: (1) x = 4 # Bind x to 4 in the 'current namespace' (2) x[i] = 4 # equivalent to x.__setitem__(i, 4) (3) x.a = 4 # Equivalent to x.__setattr__('a', 4) What conclusion should we draw from that? I think you're trying to imply that it is consistent with setting a value (same with getting). I guess what bugs me about del is that it's a keyword and not some universally well-known punctuation. Do you you feel that Python misses a pop keyword and respective expressions ? (1) pop x: Remove x from the current namespace and return it. (2) pop x[i]: Instead of x.pop(i) (3) pop x.a: Equivalent to _y=x.a; del x.a; return y George -- http://mail.python.org/mailman/listinfo/python-list
Re: PCBuild.sin - Attempt to compile Python using Visual Studio 2008
Gabriel Genellina wrote: En Thu, 08 May 2008 09:55:36 -0300, Colin J. Williams [EMAIL PROTECTED] escribió: The readme.txt has: All you need to do is open the workspace pcbuild.sln in Visual Studio, select the desired combination of configuration and platform and eventually build the solution. Unless you are going to debug a problem in the core or you are going to create an optimized build you want to select Release as configuration. Unfortunately, the Express Edition (Free) doesn't handle solution files. Python builds fine with Visual C++ Express Edition. Select Release, Win32 from the dropdown lists, press F7, and wait for compilation to complete... Or, if you prefer not to have the long startup time for Visual Studio, simple start a command prompt in python\pcbuild, call the env cmd script and then the build script: screendump C:\tempcd \work_in_progress C:\work_in_progresscd python C:\work_in_progress\pythoncd PCbuild C:\work_in_progress\python\PCbuildenv Build environments: x86, ia64, amd64, x86_amd64, x86_ia64 Setting environment for using Microsoft Visual Studio 2008 x86 tools. C:\work_in_progress\python\PCbuildbuild vcbuild /useenv pcbuild.sln Release|Win32 Microsoft (R) Visual C++ Project Builder - Command Line Version 9.00.21022 Copyright (C) Microsoft Corporation. All rights reserved. Build started: Project: make_versioninfo, Configuration: Release|Win32 Compiling... /screendump TJG -- http://mail.python.org/mailman/listinfo/python-list
Troubles with 'self'
I'm somewhat new to Python... and programming in general. I know enough to be dangerous for sure. I have a feeling the solution to this is simple. I'm having trouble getting 'self' to initialize or work in a class application. I keep getting the message: LogFile = self.BasicSummary ( ) NameError: name 'self' is not defined Code looks like this: from data_decode import * class DataAnalysis: def PainInTheArse ( self , i , InvI ): This is a filter I made to overcome some problems I was having with sine wave analysis TemporaryData = [ ] for a in range ( int ( InvI [ i ] ) , len ( InvI ) ): if a 0: a = 0 b = a + 1 try: TemporaryData.append ( InvI [ a + i ] ) if ( InvI [ b + i ] 0 and InvI [ b + i + 1 ] 0 ): TemporaryData.append ( InvI [ a + i + 1 ] ) break except IndexError: continue return TemporaryData def GetTheInvIData ( self , InvI ): Function determines zero-crossing, and then calculates the +/- peaks to get an average CurrentMaxList = [ ] CurrentMinList = [ ] for i in range ( 0 , len ( InvI ) ): try: if ( InvI [ i ] = 0 and InvI [ i + 1 ] 0 ): TemporaryData = self. PainInTheArse ( i , InvI ) BetterData = self.FilterTheBS ( TemporaryData ) CurrentMaxList.append ( max ( BetterData ) ) CurrentMinList.append ( min ( BetterData ) ) except IndexError: continue MeanCurrentMax = sum ( CurrentMaxList ) / len ( CurrentMaxList ) MeanCurrentMin = sum ( CurrentMinList ) / len ( CurrentMinList ) InvIPeakToPeak = MeanCurrentMax - MeanCurrentMin EstPeak = InvIPeakToPeak / 2 return EstPeak def FilterTheBS ( self , TemporaryData ): This is another filter I made to overcome some problems I was having with sine wave analysis BetterData = [ ] UselessData = [ ] for i in range ( 0 , len ( TemporaryData ) ): try: if TemporaryData [ i ] == TemporaryData [ i + 1 ]: UselessData.append ( TemporaryData [ i ] ) else: BetterData.append ( TemporaryData [ i ] ) except IndexError: BetterData.append ( TemporaryData [ i ] ) continue return BetterData def BasicSummary ( self ): DDC = DecodeData( ) try: MeanCurrent_A = float ( ( self.GetTheInvIData ( DDC.InvIa ) ) ) MeanCurrent_B = float ( ( self.GetTheInvIData ( DDC.InvIb ) ) ) MeanCurrent_C = float ( ( self.GetTheInvIData ( DDC.InvIc ) ) ) except ValueError: print'KaFlewie!' LogFile = [] LogFile.append ('DEVICE CURRENT SUMMARY:\n') LogFile.append ( '\tPHASE A: AVG Current = +/- %.2f A' % ( MeanCurrent_A ) ) LogFile.append ( '\tPHASE A: AVG Current = +/- %.2f A' % ( MeanCurrent_B ) ) return LogFile LogFile = self.BasicSummary ( ) for a in LogFile: print a any and all advice is welcome Rick -- http://mail.python.org/mailman/listinfo/python-list
Best technology for agent/web server architecture
Hi, I would be interested in your opinion about what technology you considear the ideal technology for implementing in Python an agent that should comunicate information to a web server. I have read about SOAP but I'm now sure if this will be the right one. The aim of the agent is gather inventory information and the web application (I'm programming it in Django) will receive this information and will store it in the database and will show it in tables. -- http://mail.python.org/mailman/listinfo/python-list
ANN: Assembly Line 0.5
I've uploaded a new version of my PyWeek 6 game, Assembly Line. http://media.pyweek.org/dl/6/gregpw6/AssemblyLine-0.5.zip As a potential Pyggy entry, I'm keen to get some testing and feedback on it. This version is greatly expanded. Some of the new features include: * More machine types and enhanced machine functionality * Simulation of a market that's buying your products * Multiple factories * Extensive reports showing what's going on with sales and finances * Sales and profit targets to aim for, and salary raises to seek after Note that not all the products and machines are available at once now. The new machines will become available as the game progresses (about one every two months of game time) and you need to spend money to research new products. I still haven't done much playtesting or balancing -- I've verified that the Phunky Phrisbee, Mojo Mallet and Supa Slice can be manufactured and sold at a profit, but I don't know about the others yet. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: prove
classname.functionname(objectname) Do you mean something like this? class myclass: @staticmethod def myfunction(myobject): pass myobject = None myclass.myfunction(myobject) If so, then you want to check the staticmethod decorator, described here: http://docs.python.org/lib/built-in-funcs.html David. -- http://mail.python.org/mailman/listinfo/python-list
Re: PCBuild.sin - Attempt to compile Python using Visual Studio 2008
Gabriel Genellina wrote: En Thu, 08 May 2008 09:55:36 -0300, Colin J. Williams [EMAIL PROTECTED] escribió: The readme.txt has: All you need to do is open the workspace pcbuild.sln in Visual Studio, select the desired combination of configuration and platform and eventually build the solution. Unless you are going to debug a problem in the core or you are going to create an optimized build you want to select Release as configuration. Unfortunately, the Express Edition (Free) doesn't handle solution files. Yes, it does. You get a warning saying that solution *folders* aren't supported; that just means that you won't see those 26 projects nicely grouped, only as a long list, that's all... Python builds fine with Visual C++ Express Edition. Select Release, Win32 from the dropdown lists, press F7, and wait for compilation to complete... Many thanks. Yes, you are right. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: prove
Lucas Prado Melo wrote: How could I prove to someone that python accepts this syntax using the documentation (I couldn't find it anywhere): classname.functionname(objectname) TUtorial 9.3.4, method objects What exactly happens when a method is called? You may have noticed that x.f() was called without an argument above, even though the function definition for f specified an argument. What happened to the argument? Surely Python raises an exception when a function that requires an argument is called without any -- even if the argument isn't actually used... Actually, you may have guessed the answer: the special thing about methods is that the object is passed as the first argument of the function. In our example, the call x.f() is exactly equivalent to MyClass.f(x). In general, calling a method with a list of n arguments is equivalent to calling the corresponding function with an argument list that is created by inserting the method's object before the first argument. -- http://mail.python.org/mailman/listinfo/python-list
Re: python equivalent to perl's inplace edit mechanism
I miswrote my question. But I still completely understand. What I really wanted to know was whether there was something equivalent to how perl can perform inplace edits of a file with something like the magic $^I variable. I see from Gabriel that you can use the fileinput module to achieve this. Very cool. And yeah, I think ruby is very perl-like, in that like perl, which looks like someone duct-taped shell, sed, awk and c into a scripting language, ruby duct-taped perl, Smalltalk and Python together. On Thu, May 8, 2008 at 7:49 AM, David [EMAIL PROTECTED] wrote: On Thu, May 8, 2008 at 2:11 PM, Michael Mabin [EMAIL PROTECTED] wrote: Does python have an equivalent to Perl's inplace-edit variable $^I? I misread your question. No, Python eschews magic characters and symbols. They make code ugly and harder to read and maintain. The first 3 lines of the Zen of Python: Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. You might find a variable like that in Ruby, which has strong Perl influences. David. -- | _ | * | _ | | _ | _ | * | | * | * | * | -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
On Thu, 08 May 2008 15:49:01 +0200, pistacchio wrote: Marc 'BlackJack' Rintsch ha scritto: On Thu, 08 May 2008 04:17:01 -0700, s0suk3 wrote: Are you a newbie to Python, or to programming in general? I'll assume you are a newbie to programming in general because of that last question you asked. Things in Python are easier than in almost any other programming language. Here are three Hello World programs: Counterexamples for quite short greetings in other programming languages: (Free)BASIC:: Print Hello World! freebasic is another language i'd point out to a newbie, even if it is not as multiplatform as python if. it has a decent community and a large amount of libraries. it doesn't let you explore functional or, worse, object oriented programming nor you can write server side programs with it. OOP support is under development and why can't you write server side programs in it? CGI is possible. The others are examples of easy hello world languages, but, passed that, i think they don't have the same capabilities of python on terms of support, kind of programs you can write and even overall complexity (haskell forces you to functional programming, io is really a minor language, ocalm forces you to di OOP and, if writing hello world is simple, on the other hand ir may have lines of code that read like: | [] - [] Okay, Haskell's pure functional approach feels somewhat weird. Io is a minor language but a quite nice one IMHO. Simple syntax and relatively simple semantics but very powerful. OCaml doesn't enforce OOP. It's some kind of mirror of Python. Python is an OOP language with support for functional programming, and OCaml is a functional language with support for OOP. The biggest pro for Python among the easy and clear syntax languages is the standard library and the amount of third party modules. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
observer pattern question #1 (reference to subject)
I have two questions about the observer pattern in Python. This is question #1. (I'll put the other is a separate post.) Here is a standard example of the observer pattern in Python: http://en.wikipedia.org/wiki/Observer_pattern Contrast with this rather standard discussion: http://www.dofactory.com/Patterns/PatternObserver.aspx#_self1 The difference I am focusing on is that in the latter, the observer (investor) maintains a reference to the subject (stock). (Many questions can be raised of course: see the discussion at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/131499). Is anything lost by not maintaining this reference (other than error checking ...)? If I feel the observer needs access to the subject, what is wrong with just having the subject pass itself as part of the notification? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
source beautifier
Is there a program (free, payware, whatever) like polystyle for linux/python? http://www.polystyle.com/features/python-beautifier.jsp I've never used it, but the example is quite clear. I just need it for python -- but it should not force me to use PEP8. -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate labels for a multi-level outline (THANK-YOU!)
Dennis, I was a touch bored in the last hour at work today so... Thank you!! Malcolm -- http://mail.python.org/mailman/listinfo/python-list
observer pattern question #2 (notification chain)
I have two questions about the observer pattern in Python. This is question #2. (I'll put the other is a separate post.) Consider this standard example of the observer pattern in Python: URL:http://en.wikipedia.org/wiki/Observer_pattern Now suppose I have a variant. (I am not a programmer, so this may be a separate related pattern.) To make it a little concrete and relate it to the discussion at URL:http://www.dofactory.com/Patterns/PatternObserver.aspx#_self1, suppose there are stocks, mutual funds, and investors. Let us say that funds are observers for stocks, and investors are observers for funds. Once a month I want all stocks to notify their observing funds of their end-of-month price, and *then* all fund to notify their observing investors of their end-of-month investment value. I see a couple differences from the standard pattern referenced above, and one problem. Differences: - observer/subject linked hierarchy (funds are both observers and subjects) - many-many relation (a fund is an observer of many stocks) I think (?) these differences are inessential, but the second does create the following problem: if I do not want a fund to notify an its investors until all stocks have reported, what is the best way to determine the last report in event? Here is one way: create a ``reportreceived`` dict that maps stocks to True or False, and after each stock notification change False to True and check ``all(reportreceived.values())`` to determine whether it is ok to notify investors. When it is ok, then notify investors and reset all the ``reportreceived`` values. This is meant to be a general description so please do not focus on the real world aspects, which are only for illustration. Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: observer pattern question #1 (reference to subject)
Alan Isaac [EMAIL PROTECTED] writes: Is anything lost by not maintaining this reference (other than error checking ...)? If I feel the observer needs access to the subject, what is wrong with just having the subject pass itself as part of the notification? It reduces the number of places the observer can be called from, because now the event source is part of the function signature. If you omit the event source in the signature, you gain looser coupling - it's the observer business to create the dependency. Also, consider the situation where you want all investors to refresh their idea about stock prices (because of, short network failure). It's easy to run through a list of them and call update() for everybody, while it's not so easy to find out what stock the investor is observing (that's the investors business!) and pass that object to the investor in the call. Are these school questions btw? ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
[EMAIL PROTECTED] writes: | PLEASE DO NOT | :.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: I don't think Xah is trolling here (contrary to his/her habit) but posing an interesting matter of discussion. It might be interesting in the abstract, but any such discussion, when cross-posted to multiple language groups on usenet, will inevitably devolve into a flamewar as proponents of the various languages argue about which language better expresses the ideas being talked about. It's like a law of usenet or something. If Xah wanted an interesting discussion, he could have posted this to one language-neutral group such as comp.programming. He doesn't want that - he wants the multi-group flamefest. sherm-- -- My blog: http://shermspace.blogspot.com Cocoa programming in Perl: http://camelbones.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie to python --- why should i learn !
[EMAIL PROTECTED] wrote: Hi, i was reading/learning some hello world program in python. I think its very simillar to Java/C++/C#. What's different (except syntax) ? what can i do easily with python which is not easy in c++/java !? With Python, you can program with a smile on your face. (Truly, when I found Python, programming became fun again.) Gary Herron Tnx, Raxit www.mykavita.com -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
How to kill Python interpreter from the command line?
Hello. I am running Fedora Linux and KDE, using the Konsole command line. When coding Python, I regularly make a bug causing my program to not terminate. But how do I kill the non-terminating Python interpreter without killing the entire Konsole? The default way of killing the current process on the command line is Ctrl+C, but that doesn't work with Python. Neither do the terminate task, suspend task or interrupt task commands (available from right-click in Konsole). So, can someone please help? How do I kill Python without having to restart Konsole? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Custom Classes?
Okay, trying this again with everything working and no ValueError or any other errors, here we go: Load this code. Unless you use a similar login() script, you will want to edit your own values into the user, passwd, db and host: #!/usr/bin/python import MySQLdb import sys,os sys.path.append(os.getcwd()) from login import login user, passwd, db, host = login() pic = pic1 w = 20 x = 0 d = 6 y = 1 getpic = getpic + str(w) + .py try: os.remove(getpic) except: pass code = #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi import sys,os sys.path.append(os.getcwd()) from login import login user, passwd, db, host = login() form = cgi.FieldStorage() picid = int(form[id].value) x = int(form[x].value) pics = {1:'pic1',2:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\ 9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'} pic = pics[x] db = MySQLdb.connect(host, user, passwd, db) cursor= db.cursor() sql = select %s from products where id='%s'; % (pic, str(picid)) cursor.execute(sql) content = cursor.fetchall()[0][0].tostring() cursor.close() print 'Content-Type: image/jpeg' print print content script = open(getpic, w) script.write(code) script.close() and then surf to: http://whatever.url/getpic20.py?id=6x=1 Also, please re-send the link on how to post good questions to the list. I cannot find it. TIA, Victor -- http://mail.python.org/mailman/listinfo/python-list
Re: How to kill Python interpreter from the command line?
On Thu, 8 May 2008 08:29:33 -0700 (PDT), [EMAIL PROTECTED] wrote: Hello. I am running Fedora Linux and KDE, using the Konsole command line. When coding Python, I regularly make a bug causing my program to not terminate. But how do I kill the non-terminating Python interpreter without killing the entire Konsole? The default way of killing the current process on the command line is Ctrl+C, but that doesn't work with Python. Neither do the terminate task, suspend task or interrupt task commands (available from right-click in Konsole). Ctrl+C often works with Python, but as with any language, it's possible to write a program which will not respond to it. You can use Ctrl+\ instead (Ctrl+C sends SIGINT which can be masked or otherwise ignored, Ctrl+\ sends SIGQUIT which typically isn't) or you can use the kill command. You can either use it in another terminal or you can suspend the Python process (Ctrl+Z which sends SIGSTOP and _cannot_ be masked or otherwise ignored) and then use kill in that terminal. You need to know the PID or jobspec in order to use kill. In bash (and probably elsewhere), jobspecs are easy. When you hit Ctrl+Z, the jobspec will be written to your terminal in the form [N]+ Stopped python. N is the jobspec and you can kill it with kill %N. You may need to use SIGKILL to end the process, in which case use kill -KILL %N. You can then resume the Python process with the fg command, it will immediately end since it has be killed. This is more a Linux/bash/etc question than a Python question, so followups might be directed to a more appropriate forum (eg, the man page for your shell, or a bash user group, etc). Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list