Re: python coding contest
gmail.com> writes: > > Currently I'm on 149 characters in one line - 128 without > spaces/newlines. (it'd be three characters shorter if it didn't have > to end with a "\n") > > -T. "unclean... unclean..." > are you importing zlib or bz2 ? -- http://mail.python.org/mailman/listinfo/python-list
Newbie question
I have exp with C/C++ (and a few other langs). I want to use Python to start doing the ff: 1). Data Munging (text processing) 2). Automating my build process 3). (Possibly) some web data retrieval jobs Can anyone point me to resurces/possibly scripts that can get me up to speed (to do these 3 things) ASAP, without having to learn the basics of programming? -- http://mail.python.org/mailman/listinfo/python-list
Python question (PyNoob)
I have exp with C/C++ (and a few other langs). I want to use Python to start doing the ff: 1). Data Munging (text processing) - instead of Perl 2). Automating my build process 3). (Possibly) some web data retrieval jobs Can anyone point me to resurces/possibly scripts that can get me up to speed (to do these 3 things) ASAP, without having to learn the basics of programming? -- http://mail.python.org/mailman/listinfo/python-list
Building VTK-5.0.3-1 with Python bindings (VS 8.0)
I am having problems with CMake. I currently have the ff errors (paths not set - and I am not sure what to set them to): TK_INCLUDE_PATH TK_INTERNAL_PATH TK_XLIB_PATH (I don't know why this is reqd, since I'm running W2k) Has anyone done this before or now how to fix these errors ? -- http://mail.python.org/mailman/listinfo/python-list
interfacing Python interpreter with a VB6 frontend
I am trying something which appears (so far), that many other people have not yet tried before - since I can't find any useful related material despite several days of searching various sites/blogs etc. I want to use VB6 as a front end for building a small GUI console that accepts python commands at the command line and executes them, returning any results to the VB6 window. This requires several steps, but the one I am having most problem finding info on is the ff: 1. using/interacting the Python interpreter from VB6 Any pointers/demos etc are very welcome - and if this has already been done, please let me know, so I can learn from what someone else has done -- http://mail.python.org/mailman/listinfo/python-list
Re: interfacing Python interpreter with a VB6 frontend
Ryan Ginstrom wrote: >>On Behalf Of Anonymous >>This requires several steps, but the one I am having most >>problem finding info on is the ff: >> >>1. using/interacting the Python interpreter from VB6 > > > One way to do this might be by creating a COM server with Python, and having > VB feed it lines of text and then collect results of execution for display. > > win32com has demos of COM servers. > > -- > Regards, > Ryan Ginstrom > Hi Ryan, do you have a link to the resources you mentioned?. I did a search for win32com - and found this : http://python.net/crew/mhammond/win32/FAQ.html (most of the links were either dead, or refrerred to using COM from within Python - i.e. the OTHER way round). -- http://mail.python.org/mailman/listinfo/python-list
Re: piping into a python script
I'm not sure I understane the question but my contribution is : import sys names = sys.argv[1:] line = 'x' while line: line = sys.stdin.readline().strip() if line: names.append (line) print "names=", names Called using: ls | stdtest.py arg1 arg2 arg3 Does this help? Andy -- http://mail.python.org/mailman/listinfo/python-list
Re: python book for non technical absolute beginner
Yes, there is an excellent book for absolute beginners call Python Programming, for the absolute beginner (second edition by Michael Dawson. Here are the reasons why it is excellent for a beginner. It doesn't go beyong basic math as do most other computer books when giving examples, exercises or programs illustrating any language including Python. It teaches the basic phython in 9 chapters and the goes on to teach some basic graphics using Python. But for me and many others the first 9 chapters are perfect and awesome to work through. Most books attempting to teach any subject start off with a few easy basic chapters and then jumpt into complex explanations and examples. Not so with this book. It gives consistent easy to understand examples/code often in the form of a simple game which fun. No book I have seen, read or own on Python teaches the very basic principles of writing code as easily understood as this book. There are many excellent web sites around the world in many languages that teach basic Python with free texts and examples, but for somone with little or no programming experience or a first timer at programming with modest math skills, it is perfect. News123 wrote: > > Hi, > > One of my 'non technical' friends complained about knowing nothing at > all about programming (though using computers regularly for mails / web > browsing / googling and downloading / cropping photos ) > > He wants to play a little with programming to stimulate parts of his > otehrwise idle brain cells. ;-) Normally it's more the social science / > linguistic parts being exercised, > > I thought python might be a nice language for this > > No my question does anybody know a nice beginners book (or a learning CD > or on line tutorial)? Ideally it shouldn't be too serious and have a lot > of small nice mini-examples > > thanks in advance for any suggestions hints > > bye > > N -- http://mail.python.org/mailman/listinfo/python-list
Python beginner, unicode encode/decode Q
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for example: answer_str = raw_input(' Enter answer > ') Herr Üü [ I keyboard in the following characters Herr Üü ] print answer_str Output on screen is > Herr Üü 3 history 1 and 2 code run interactively under Debian Linux Python 2.4 and interactively under windows98, first edition IDLE, Python 2.3.5 and it works. 4 history 3 and 4 code run from within a .py file produce different output from example in book. 5 want to operate under Debian Linux but because the program failed under Linux when I tried to run the code from a file in Linux Python, I thougt I should fire up the win98 Idle/python program and try it to see if ran there but it failed, too from within a file. 6 The sample code is from page 108-109 of: "Python for Dummies" It says in the book: "Python's file objects and StringIO objects don't support raw Unicode; the usual workaround is to encode Unicode as UTF-8 before saving it to a file or stringIO object. The sample code from the book is French as indicate here but trying German produces the same result. 7 I have searched the net under all the keywords but this is as close as I get to accomplishing my task. I suspect I may not be understanding: StringIO objects don't support raw Unicode, but I don't know. #_*_ coding: utf-8 _*_ # code run under linux debian interactively from a terminal and works print " u'Libert\u00e9' " # y = raw_input('Enter >') commented out y = u'Lbert\u00e9' y.encode('utf-8') q = y.encode('utf-8') q.decode('utf-8') print q.decode('utf-8') history 1 works and here is the screen copy of interactive >>> y = raw_input ('>') >Libert\xc3\xa9 >>> q = 'Libert\xc3\xa9' >>> q.decode('utf-8') u'Libert\xe9' >>> print q Liberté >>> [ screen output is next line ] Lberté history 2 # code run under win98, first edition, within IDLE interactively and succeeded in produce correct results. # y = raw_input('Enter >') commented out y = u'Lbert\u00e9' y.encode('utf-8') q = y.encode('utf-8') q.decode('utf-8') print q.decode('utf-8') history 1 works and here is the screen copy of interactive >>> y = raw_input ('>') >Libert\xc3\xa9 >>> q = 'Libert\xc3\xa9' >>> q.decode('utf-8') u'Libert\xe9' >>> print q Liberté >>> [ screen output is next line ] Lberté # history 3 # this code is run from within idle on win98 and inside a python file. # The code DOES NOT produce the proper outout. #_*_ coding: utf-8 _*_ # print "u'Libert\u00e9'" printed to screen y = raw_input('Enter >') # y = u'Lbert\u00e9' commented out y.encode('utf-8') q = y.encode('utf-8') q.decode('utf-8') print q.decode('utf-8') # output is on the lines below was produced on the screen after run enter u'Libert\u00e9' on screen to copy into into y string Enter >u'Libert\u00e9' u'Libert\u00e9' The code DOES NOT produce Liberté but instead produce u'Libert\u00e9' # history 4 # this code is run from within terminal on Debian linux inside a python file. # The code does not produce proper outout but produces the same output as run on # windows. #_*_ coding: utf-8 _*_ print "u'Libert\u00e9'" printed to screen y = raw_input('Enter >') # y = u'Lbert\u00e9' commented out y.encode('utf-8') q = y.encode('utf-8') q.decode('utf-8') print q.decode('utf-8') # output is on the lines below was produced on the screen after run enter u'Libert\u00e9' on screen to copy into into y string Enter >u'Libert\u00e9' u'Libert\u00e9' The code DID NOT produce Liberté but instead produce u'Libert\u00e9' -- http://mail.python.org/mailman/listinfo/python-list
RE: print() and unicode strings (python 3.1)
Have you considered including an encoding line at the top of your file, as described in PEP 0263: http://www.python.org/dev/peps/pep-0263/ I just ran into a similar error, but it went away when I included # coding: utf-8 as the first line in my file. -- http://mail.python.org/mailman/listinfo/python-list
Re: Books?
On Aug 21, 7:04 pm, Chris Angelico wrote: > On Wed, Aug 22, 2012 at 11:39 AM, Roy Smith wrote: > > In article > > <5203ee16-5a80-4cd9-9434-ee2efb645...@kg10g2000pbc.googlegroups.com>, > > Anonymous Group wrote: > > >> What books do you recomend for learning python? Preferably free and/or > >> online. > > > I would start withhttp://docs.python.org/tutorial/ > > Agreed. And for anything beyond that, I would recommend the anonymous > OP offer some more information, such as current programming skill > level and languages known. > > But the tutorial is a good start regardless. > > ChrisA Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: A Moronicity of Guido van Rossum
[EMAIL PROTECTED] wrote: > In comp.lang.perl.misc Kalle Anke <[EMAIL PROTECTED]> wrote: > >>On Thu, 29 Sep 2005 19:44:28 +0200, Matt wrote >>(in article <[EMAIL PROTECTED]>): > > > >>>OK... your post seems to indicate a belief that everyone else is >>>somehow incompetent. Sounds a bit like the "I am sane, it is everyone >>>else who is crazy" concept. Can you suggest a technology or >>>technologist who, in your expert opinion, has gotten it right? > > > >>He has posted similar posts about other things to at least one other mailing >>list, the tone and arguments of these post were exactly the same. > > > I wonder if his postings are related to the phases of the moon? It > might explain a lot. > > Axel Or forgetting to take his medication. -- http://mail.python.org/mailman/listinfo/python-list
finding the difference between the two version of the python program...
is there a tool which, given two version of programs, finds the difference like set of classes added, deleted and modified? assuming the python program is written in oops way. -- http://mail.python.org/mailman/listinfo/python-list
a small doubt
i wrote this code -- class Person(object): instancesCount = 0 def __init__(self, title=""): Person.instancesCount += 1 self.id = "tempst" def testprint(self): print "blah blah" def __getattribute__(self, name): print "in get attribute" a = Person() a.testprint() print a.id - but i am getting this error in get attribute Traceback (most recent call last): File "trapmethodcall1.py", line 15, in a.testprint() TypeError: 'NoneType' object is not callable -- why is it so? __getattribute__ is called whenever an attribute or method is called, rt? or if i set __getattribute__ , i cannot have methods in class? actually my aim is to trap all method calls and keep a counter which is update whenever method called or returned. how should i go about it? -- http://mail.python.org/mailman/listinfo/python-list
trapping all method calls in a class...
hi, i need to trap all method calls in a class in order to update a counter which is increased whenever a method is called and decreased whenever method returns. in order to that i am trying to write a decorator for all the methods. see the code here with error. --- http://codepad.org/2w7JVvDB any suggestions? any other better way of doing it? -- http://mail.python.org/mailman/listinfo/python-list
sending executable data over network..
hi, i wish to change the way the function definition at run time in a running server. new function code which is to be executed is provided by a client at different location. i am getting it by reading a file and sending it using makefile() with server/client connected using sockets. how can make the lines received in a string array as new function definition? or should i receive it in a different way? is there any better way to do the entire thing? -- http://mail.python.org/mailman/listinfo/python-list
Re: sending executable data over network..
any idea or pointer how i could link it to running code in server? for example, i get a new method definition for a method and i wish to change it. client sent new definition, i compile it in server. how can i link it to old code? if it will running in same environment, i would write objectA.getdata()=getdatanew() here? On Tue, Jun 24, 2008 at 4:15 PM, Cédric Lucantis <[EMAIL PROTECTED]> wrote: > Le Tuesday 24 June 2008 08:59:40 Piyush Anonymous, vous avez écrit : > > hi, > > i wish to change the way the function definition at run time in a running > > server. new function code which is to be executed is provided by a client > > at different location. > > i am getting it by reading a file and sending it using makefile() with > > server/client connected using sockets. > > > > how can make the lines received in a string array as new function > > definition? or should i receive it in a different way? > > > > is there any better way to do the entire thing? > > One way is to transmit the code as a string and compile it on server-side > with > the 'compile' builtin function. Another is to compile it on client-side and > transmit the resulting code object with the marshal module but there are > many > restrictions on it (specially the fact that the client and server will have > to run the same python version) so carefully read the docs first. I'd > choose > the first solution, eventually using the pickle module to avoid encoding > problems. > > -- > Cédric Lucantis > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: sending executable data over network..
assuming security is not of concern at the moment, how can i add in update capability? please help me out or show some pointers to look into. i wish to change the way the method definition of a class at run time in a running server (actually i m planning to support many changes at run time). new code which is to be executed is provided by a client at different location. i am receiving the code as a string and compile it on server-side with the 'compile' builtin function or get compiled code using marshal. however i cannot link it to the running code in server? for example, i get a new method definition for a method in class and i wish to change it. client sent new definition, i compile it in server, getting a code object. how can i link it to old code? if it will running in same environment, i could simply write A.getdata=getdatanew # A is a class how should i do it here? should i change the way i am receiving the code? thanks for help -piyush On Wed, Jun 25, 2008 at 12:22 AM, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > Piyush Anonymous wrote: > >> any idea or pointer how i could link it to running code in server? >> for example, i get a new method definition for a method and i wish to >> change it. >> client sent new definition, i compile it in server. how can i link it to >> old code? >> > > Code to be hot-updated (while running) must have update capability builtin. > But please consider security. If a remote system can log in and *push* > code, an attacker can potentially do the same. Notice that self-updating > programs and systems generally log out to a hardwired location, ask if there > are updates, and *pull* the new code. > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Suggestion: Python global scope
I've been tossing this idea in my mind for some time now: In Python, declaring a variable using the global statement automatically makes it available in all subsequent scopes. But to me, it makes more sense to use the global statement to 'import' a variable from the global scope into the current scope. For instance: [code] global X X = 1 def P(): X = 2 print X global X print X print X P() print X [code] Currently, this will print 1, 2, 2 and 2. But if global would be limited to current scope, it would print 1, 2, 1, 1. 'X = 2' would work on the local version of X, 'global X' will 'import' the global X into the local scope, so any actions on X would reference the global X, rather than previous X. -- http://mail.python.org/mailman/listinfo/python-list
Dynamically adding methods to a class...
class MyObject: def __init__(self, name): self.name = name def do_this_default(self): print "default do_this implementation for %s" % self.name def custom_do_this(): #method to be added print "custom do_this implementation for %s" % self.name def funcToMethod(func,clas,method_name=None): """Adds func to class so it is an accessible method; use method_name to specify the name to be used for calling the method. The new method is accessible to any instance immediately.""" import new method = new.instancemethod(func,None,clas) print method if not method_name: method_name=func.__name__ clas.__dict__[method_name]=func myobj = MyObject('myobj1') funcToMethod(custom_do_this,MyObject) #trying 2 add method to class not instance print myobj.custom_do_this() --- Error I am getting; TypeError: custom_do_this() takes no arguments (1 given) Why am I getting it? Also how can I do this in new style class (inherited from 'object')? -- http://mail.python.org/mailman/listinfo/python-list
Re: Mathematica 7 compares to other languages
On Dec 1, 2:23 am, Xah Lee <[EMAIL PROTECTED]> wrote: > On Nov 30, 7:30 pm, Xah Lee <[EMAIL PROTECTED]> wrote: > >>some stuff Are you a bot? I think you failed the Turing test after the 8th time you posted the exact same thing... I'm completely serious. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mathematica 7 compares to other languages
On Nov 30, 10:30 pm, Xah Lee <[EMAIL PROTECTED]> wrote: > some stuff You are a bot? I think you failed the Turing test when you posted the same thing 20 times. A rational human would realize that not too many people peruse this newsgroup, and that most of them have already seen the wall of text post that you generate every time. Just a thought, but whoever owns this thing might want to rework the AI. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mathematica 7 compares to other languages
On Dec 1, 8:29 pm, Lew <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > A rational human would realize that not too many people peruse this > > newsgroup, > > and that most of them have already seen the wall of text post that you > > generate every time. > > Just out of curiosity, what do you consider "this" newsgroup, given its wide > crossposting? > > -- > Lew Ah, didn't realize the cross-posted nature. comp.lang.lisp Hadn't realized he had branched out to cross-posting across five comp.langs Apologies for the double post, thought the internet had wigged out when i sent it first time. -- http://mail.python.org/mailman/listinfo/python-list
Re: Lisp mentality vs. Python mentality
On Apr 25, 2:06 am, Carl Banks wrote: > In answering the recent question by Mark Tarver, I think I finally hit > on why Lisp programmers are the way they are (in particular, why they > are often so hostile to the "There should only be one obvious way to > do it" Zen). > > Say you put this task to a Lisp and a Python programmer: Come up with > a good, generic, reusable way to compare two lists. What are their > respective trains of thought? > > Lisp programmer: > > Well, there is a standard function called mismatch that does it, but I > can't recommend it. First of all, you don't know where that > function's been. Anyone and their mother could have worked on it, did > they have good, sound programming practice in mind when they wrote > it? Of course not. Let's be real here, we have to implement this by > hand. > > (defun lists-are-equal (a b) > (or (and (not a) (not b)) > (and (= (car a) (car b)) (lists-are-equal (cdr a) (cdr b > > There, much better than the standard function, and better yet, it's in > the *absolute minimal form possible*. There is no way to express list > comparison in a more reduced form. It's almost erotic how awesome it > is. I'm---whoa, ok, I'm getting a little excited now, settle down. > Well, come to think of it, that's really not that good. First of all > it's a function. I mean, it just sits there and does nothing till you > call it. How boring is that? It can't react to the current > situation. Plus it compares all lists the same way, and that is > really inefficient. Every list compare is a new problem. Different > lists need different comparative strategies. This function simply > won't do. I need a macro that can intelligently compile the right > list compare methodology in. For instance, if we want to compare two > lists that are known at compile time, we don't want to waste time > comparing them at runtime. No, the macro must detect constant > arguments and special case them. Good start. Now, we have to > consider the conditions this comparison is being done under. If the > user is passing the result of a sort to this macro, it's almost > certain that they are trying to see whether the lists have the same > elements. We can do that a lot more efficiently with a countset. So > let's have the macro check to see if the forms passed to it are all > sort calls. Better yet, let's check for my own powerful sort macro. > Hmm. Wait... I think my 4600-line sort macro already checks its > calling context to see if its results are being fed to a list > comparison. I'll have to refactor that together with this macro. Ok, > good, now I am sure other users will eventually want to customize list > comparison for their own use, after all every list comparison is > different and I can't possibly anticipate all of them. A user needs > to be able to adapt to the situation, so it's vitally important to > create a plug-in infrastructure to give them that flexibility. Now, > what about exceptions, there's a millions ways to deal with that... > > ...and so on until eyelids can no longer stay open > > Python programmer: > > a == b. Next question. > > Carl Banks, who might be exaggerating > > ...a little. (equal a b) or (equalp a b) Next question?? I understand where you are going with the analogy, but I think a lot of what you describe as 'over-thinking' of the problem in lisp comes from people having an honest desire to answer the /right/ question. Lisp gives you a bit of granularity with regard to certain things (like comparison), that in many languages amount to a single '==' operator. I /believe/ that this is because of its origins in symbolic programming. You don't compare numeric functions in Perl and C, and then say 'Oh those silly C programmers over-thinking things, they must have 10 different types of numbers!' -- http://mail.python.org/mailman/listinfo/python-list