How to: Setuptools
I would like to use easy_install, but can't figure out how to install it. I have 64-bit Python 2.7.5 on Windows 7. Following the instructions on https://pypi.python.org/pypi/setuptools, it says: Download ez_setup.py and run it; it will download the appropriate .egg file and install it for you. (Currently, the provided .exe installer does not support 64-bit versions of Python for Windows, due to a distutils installer compatibility issue Being new to Python, I don't know what it means to "run it". I am not sure what I am looking at when I open it as the first line is "#!python". Looking down into the content of ez_setup.py, I find: 'setuptools-0.6c10-py2.6.egg': but there is no entry 'setuptools-0.6c10-py2.7.egg': Searching for it, I found a version at: https://pypi.python.org/packages/2.7/s/setuptools/ This appeared to be a linux version, the first line is: #!/bin/sh and the content seems to be encoded. There is an exe at https://pypi.python.org/pypi/setuptools, but the instructions on the page state the .exe won't work for 64-bit installs. Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How to: Setuptools
On May 28, 7:26 am, Mark Lawrence wrote: > On 28/05/2013 13:03, rusi wrote: > > > > > > > On May 28, 6:32 am, ray wrote: > >> I would like to use easy_install, but can't figure out how to install it. > > >> I have 64-bit Python 2.7.5 on Windows 7. > > >> Following the instructions onhttps://pypi.python.org/pypi/setuptools, it > >> says: > >> Download ez_setup.py and run it; it will download the appropriate .egg > >> file and install it for you. (Currently, the provided .exe installer does > >> not support 64-bit versions of Python for Windows, due to a distutils > >> installer compatibility issue > > >> Being new to Python, I don't know what it means to "run it". I am not > >> sure what I am looking at when I open it as the first line is "#!python". > > >> Looking down into the content of ez_setup.py, I find: > >> 'setuptools-0.6c10-py2.6.egg': > >> but there is no entry > >> 'setuptools-0.6c10-py2.7.egg': > > >> Searching for it, I found a version > >> at:https://pypi.python.org/packages/2.7/s/setuptools/ > > >> This appeared to be a linux version, the first line is: > >> #!/bin/sh > >> and the content seems to be encoded. > > >> There is an exe athttps://pypi.python.org/pypi/setuptools, but the > >> instructions on the page state the .exe won't work for 64-bit installs. > > >> Ray > > > Since there seems to be no response to this, let me try (even though I > > am not on windows) > > Just point your browser at the link > >http://peak.telecommunity.com/dist/ez_setup.py > > And save the file ez_setup.py > > > The more windows-y way of running this is to right-click this and edit > > the run-with in some way that I dont have at my finger-tips. > > Do this, something goes wrong, no output to see. > > > > > The more old-fashioned way is to start a dos-box (run cmd.exe) > > navigate to the directory where the ez_setup.py is saved > > from there run the command: > > python ez_setup.py > > Do this, something goes wrong, output in front of you. > > > > > Do that and report back on what happened > > -- > If you're using GoogleCrap� please read > thishttp://wiki.python.org/moin/GoogleGroupsPython. > > Mark Lawrence > > The installation fails. The report stated it could not find the file. Per: Looking down into the content of ez_setup.py, I find: 'setuptools-0.6c10-py2.6.egg': but there is no entry 'setuptools-0.6c10-py2.7.egg': Since I am trying to install this for Python 2.7, it fails. Any suggestions? Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How to: Setuptools
On Monday, May 27, 2013 8:32:43 PM UTC-5, ray wrote: > I would like to use easy_install, but can't figure out how to install it. > > > > I have 64-bit Python 2.7.5 on Windows 7. > > > > Following the instructions on https://pypi.python.org/pypi/setuptools, it > says: > > Download ez_setup.py and run it; it will download the appropriate .egg file > and install it for you. (Currently, the provided .exe installer does not > support 64-bit versions of Python for Windows, due to a distutils installer > compatibility issue > > > > Being new to Python, I don't know what it means to "run it". I am not sure > what I am looking at when I open it as the first line is "#!python". > > > > Looking down into the content of ez_setup.py, I find: > > 'setuptools-0.6c10-py2.6.egg': > > but there is no entry > > 'setuptools-0.6c10-py2.7.egg': > > > > Searching for it, I found a version at: > > https://pypi.python.org/packages/2.7/s/setuptools/ > > > > This appeared to be a linux version, the first line is: > > #!/bin/sh > > and the content seems to be encoded. > > > > There is an exe at https://pypi.python.org/pypi/setuptools, but the > > instructions on the page state the .exe won't work for 64-bit installs. > > > > Ray I looked through distutils-sig/ . There were many finding the problem. There is a solution using Setuptools 2.7 bdist_wininst - http://groups.google.com/group/distutils-sig/browse_thread/thread/6107d5c9044c3f37/4d1a53f9e8fb7d20?hl=en&lnk=gst&q=Setuptools+2.7+bdist_wininst> It wasn't clear on where to run things from nor did it address the missing 2.7 reference. The reference - http://www.lfd.uci.edu/~gohlke/pythonlibs/ has a 64 bit installer - distribute-0.6.43.win-amd64-py2.7.exe. It ran without error reports. This all was to install netwokx. That installed without error. Ray -- http://mail.python.org/mailman/listinfo/python-list
Wondering in the Python Forrest
I am new to Python and am learning for engineering and scientific use. For some reason, which I don’t remember, I went to Scipy.org downloaded the module. I am sure it had explained things but that was a couple weeks ago and it’s all a blur. So now I am working in Pythonxy. One of my activities is to work with data from Excel. I found the cvs reader and started researching its use. I found that structured data could be presented in Python using a module in wxPython. Where am I? I do not know the relationships between the Pythons. I feel that I am missing something. I started with Python as it has so much functionality and a huge user group of very helpful individuals and sites. Now that I have delved deeper, it seems I need different Pythons. I would like to understand how to use all this functionality, logistically. If I have a series of tasks to perform, do I open a session in one, read in data from a source, manipulate it, write it out, open another Python type, read in the manipulated data, perform other actions, write it out, close that and then open another to display? Is there a more coherent way to do this? I would appreciate any help in better understanding how to use all these tools. Thanks, Ray -- http://mail.python.org/mailman/listinfo/python-list
Remote Connection
I wonder if there is a solution to provide remote connections between two computers similar to Remote Desktop. The difference I am looking for is to be able to deliver speech/audio from the local machine to the remote machine which will process the audio via Dragon Naturally Speaking. As an additional point, I would like to be able to deliver speech to that remote computer from a cell phone. I would appreciate all considerations. The current remote machine is an XP Pro SP2, the local machine is . . . right now an XP Pro but will change to a Windows 7 Pro. I do not have a cell for this; I am waiting to see if any solution may dictate the cell details. ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Remote Connection
On Apr 19, 8:23 pm, Chris Rebert wrote: > On Tue, Apr 19, 2011 at 6:04 PM, ray wrote: > > I wonder if there is a solution to provide remote connections between > > two computers similar to Remote Desktop. The difference I am looking > > for is to be able to deliver speech/audio from the local machine to > > the remote machine which will process the audio via Dragon Naturally > > Speaking. > > > As an additional point, I would like to be able to deliver speech to > > that remote computer from a cell phone. > > > I would appreciate all considerations. > > > The current remote machine is an XP Pro SP2, the local machine > > is . . . right now an XP Pro but will change to a Windows 7 Pro. I do > > not have a cell for this; I am waiting to see if any solution may > > dictate the cell details. > > How does this specifically involve Python at all, pray tell? > > Regards, > Chris- Hide quoted text - > > - Show quoted text - Chris, The speech commands will scripted in Python. Dragonfly is the Python project to coordinate this but does not address connectivity. So I am wondering if there have been any Python projects to address the connectivity. ray -- http://mail.python.org/mailman/listinfo/python-list
How to Use Setuptools, Alternatives?
I have Python 2.7 on Win7 Pro on a tightly locked down desktop. I would like to install Networkx from an egg. From what I have read, Setuptools can be used for this. I don't know how to install Setuptools. The exe will not work. On execution, it reports that the Python version is not included in the registry. Further, I can not input the version and location on the subsequent installation screen, the fields will not accept focus so I can not input the values. Since the exe will not install, I considered using the Setuptools egg. But it requires Setuptools. It appears to be a circle. What are some suggestions for installing this? Thanks, ray -- http://mail.python.org/mailman/listinfo/python-list
Alternatives to PythonPath
I am using Win7 on a tightly locked down desktop. Is there an alternative to using PythonPath? What are the trade-offs? Thanks, ray -- http://mail.python.org/mailman/listinfo/python-list
Ruby on Rails Job Site -- Is there a Python equivalent?
I just found a job listing site for Ruby on Rails. http://jobs.rubynow.com/ I wonder if there's an equivalent one for Django? For some reason a lot of people seem to know about RoR, but when I ask them about Django, they go like, "huh?" -- http://mail.python.org/mailman/listinfo/python-list
Re: Ruby on Rails Job Site -- Is there a Python equivalent?
Adrian Holovaty wrote: > Here ya go: > > http://code.djangoproject.com/wiki/DevelopersForHire > > See the "Django-powered jobs" section. We could definitely advertise > this page more, as it's a bit hidden at the moment on the Django wiki. > > There are three Django jobs on that page now, and I know of at least > two others. See > http://www.djangoproject.com/weblog/2005/nov/27/weekinreview/ . > > Hope this helps! Thanks Adrian! BTW I hope Django will surpass or at least equal RoR popularity. I just love Python too much :) > > Adrian > > -- > Adrian Holovaty > holovaty.com | djangoproject.com | chicagocrime.org -- http://mail.python.org/mailman/listinfo/python-list
How do these Java concepts translate to Python?
Hello, I've been learning Python in my sparetime. I'm a Java/C++ programmer by trade. So I've been reading about Python OO, and I have a few questions that I haven't found the answers for :) 1. Where are the access specifiers? (public, protected, private) 2. How does Python know whether a class is new style or old style? E.g.: class A: pass How does it know whether the class is new style or old style? Or this decision only happens when I've added something that belongs to new style? How do I tell Python which one I want to use? 3. In Java we have static (class) method and instance members. But this difference seems to blur in Python. I mean, when you bind a member variable in Python, is it static, or instance? It seems that everything is static (in the Java sense) in Python. Am I correct? Thanks in advance, Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How do these Java concepts translate to Python?
Fausto Arinos Barbuto wrote: > Ray wrote: > > > 1. Where are the access specifiers? (public, protected, private) > > AFAIK, there is not such a thing in Python. So everything is public? I know that you can prefix a member with underscores to make something private, but how about protected, for example? > > ---Fausto -- http://mail.python.org/mailman/listinfo/python-list
Re: How do these Java concepts translate to Python?
Devan L wrote: > Fausto Arinos Barbuto wrote: > > Ray wrote: > > > > > 1. Where are the access specifiers? (public, protected, private) > > > > AFAIK, there is not such a thing in Python. > > > > ---Fausto > > Well, technically you can use _attribute to mangle it, but technically > speaking, there are no public, protected, or private things. OK, thanks. How about static members and instance members? Seems that in Python everything is class-wide? Thanks Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How do these Java concepts translate to Python?
Thanks guys! Your explanations have cleared up things significantly. My transition from C++ to Java to C# was quite painless because they were so similar, but Python is particularly challenging because the concepts are quite different. (I always have this paranoid feeling: "Am I using Python to write Java, or using Python to write Python?") Regards, Ray Ray wrote: -- http://mail.python.org/mailman/listinfo/python-list
Re: How do these Java concepts translate to Python?
bruno modulix wrote: > And BTW, don't bother making all your attributes "protected" or > "private" then writing getters and setters, Python has a good support > for computed attributes, so you can change the implementation without > problem (which is the original reason for not-public attributes): Thanks Bruno! This is good stuff. This is exactly what I want to avoid: writing Java in Python. Cheers, Ray > > # first version: > class Foo(object): > def __init__(self): > self.baaz = 42 # public attribute > > # later we discover that we want Foo.baaz to be computed: > class Foo(object): > def __init__(self): > self.baaz = 42 > > def _set_baaz(self, value): > if value < 21 or value > 84: > raise ValueError, "baaz value must be in range 21..84" > self._baaz = value > > def _get_baaz(self): > return self._baaz * 2 > > baaz = property(fget=_get_baaz, fset=_set_baaz) > > Easy as pie, uh ?-) > > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Python's Exception, and Capitalization
Hello guys, OK, I've been reading some more about Python. There are some things about Python exception that I haven't been able to grasp: 1. This is a small thing, but why is object spelled "object", and the mother of all exception "Exception" (with capital E)? Why is not object spelled "Object" then? Especially since Exception's descendants are named with the first letter of each word capitalized? I mean, in Java, it's Object. Whereas in C++, they're quite consistent, standard stuff are usually all lowercaps (basic_string, iostream, etc.). Python seems to have a mix of both. Am I right in assuming that object is object (with lower case 'o') because it is built-in, and Exception is not? So when we write our own classes, exceptions, etc., we should capitalize it like in Java or C#? By the way, what's the convention for functions? It's a bit confusing because when I see Python builtins, it seems that they follow C++ style (e.g.: has_key, readline). So... does it mean that when I write my own function, customarily I'd say myFunction() (or MyFunction()?) 2. I'm quite baffled that you either have try/except, or try/finally. In Java, it is quite common to do this: try { // something } catch(AException e) { // handle } catch(BException e) { // handle } catch(CException e) { // handle } finally { // whatever happens, execute this } It seems that since except and finally are mutually exclusive I can't do this. So... what's the usual idiom for this? Thanks! Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How do these Java concepts translate to Python?
Roy Smith wrote: > Quick answer; there are none, all attributes are public. > > Slightly longer answer; if you name an attribute with two leading > underscores (i.e. "__myPrivateData"), there is some name mangling that goes > on which effectively makes the attribute private. There are ways around > it, but you have to know what you're doing and deliberately be trying to > spoof the system (but, then again, exactly the same can be said for C++'s > private data). Well yeah... if you really want it, in Java you can do that too via reflection. Just that I'm not used to it yet so I feel a bit jittery with so much power on my hands! > Soapbox answer; private data is, in some ways, a useful tool, but it is not > part and parcel of object oriented programming. I've had people (mostly > C++/Java weenies) that Python is not an OOPL because it does not enforce > data hiding. "Feh", I say to them. Feh... those weenies don't know what they're talkin about. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's Exception, and Capitalization
D H wrote: > Yeah, the python standard library has been built by lots of different > people. It wasn't designed by one entity using one standard like the > java standard library or .NET/Mono class library. Um, OK, so is it customary in modern Python programs to follow Java convention? then methods/functions should be written someMethod() or myFunction()? > > 2. I'm quite baffled that you either have try/except, or try/finally. > > Apparently that will be fixed sometime: > http://python.miscellaneousmirror.org/peps/pep-0341.html Ah, okay. I'm quite surprised to see the date--it was _that_ recent! :) But currently, how have you--Python guys who code for a living--been handling this case? I know that you can put another try inside a try, but obviously the need for that is not common enough in idiomatic Python program (or else this would have been a PEP in, say, 2000). Cheers Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How do these Java concepts translate to Python?
bruno modulix wrote: > Then wait until you discover what one can do with __magic_methods__, > functions-as-objects, closures, callable objects, descriptors > (properties on steroids), decorators, generators, and metaclasses... > *Then* you'll know what power means !-) > > And more is to come... ... I've got a feeling that this Pythonic journey will expand my brain so much ;) > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: How do these Java concepts translate to Python?
gene tani wrote: > I think you'll like python. > > http://naeblis.cx/rtomayko/2004/12/15/the-static-method-thing > http://dirtsimple.org/2004/12/java-is-not-python-either.html > > (and python-is-not-java) Thanks gene, these are exactly the stuff I wanna know more about. Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's Exception, and Capitalization
Steve M wrote: > You might find the Python Style Guide to be helpful: > > http://www.python.org/doc/essays/styleguide.html Nice! Thanks Steve. Ray -- http://mail.python.org/mailman/listinfo/python-list
A PIL Question
Hello, I'm using latest PIL version with Python 2.4.1. (for solving a level in Python Challenge actually...). Anyway, I'm trying to draw a picture. My question is, why is it that putdata() won't work? Even this won't run: import Image im = Image.open("something.jpg") seq = im.getdata() image = Image.Image() image.putdata(seq) image.show() I always get: Traceback (most recent call last): File "Script1.py", line 31, in ? image.putdata(seq) File "D:\Development\Python24\Lib\site-packages\PIL\Image.py", line 1120, in putdata self.im.putdata(data, scale, offset) AttributeError: 'NoneType' object has no attribute 'putdata' Anybody has any idea why this is the case? Thanks, Ray -- http://mail.python.org/mailman/listinfo/python-list
Please Criticize My Code
Hello, I just wrote a short script that generates look and say sequence. What do you Python guys think of it? Too "Java-ish"? I can't shake off the feeling that somebody may have done this with 2-3 lines of Python magic. Heh. # generator for sequence def lookAndSaySequence(firstTerm, n): term = str(firstTerm) for i in xrange(n): yield term term = lookAndSay(term) # the method that looks, and says def lookAndSay(number): look_at_this = str(number) say_this = ['0', look_at_this[0]] for digit in look_at_this: if say_this[-1] != digit: say_this.extend(('1', digit)) else: say_this[-2] = str(int(say_this[-2]) + 1) return "".join(say_this) # run it! print [x for x in lookAndSaySequence(1, 30)] Thanks, Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Please Criticize My Code
Damn, those are cool, man. Thanks! This Python thing keeps expanding and expanding my brain... Ray [EMAIL PROTECTED] wrote: -- http://mail.python.org/mailman/listinfo/python-list
Re: Please Criticize My Code
Michael Hoffman wrote: > Ray wrote: > > > I just wrote a short script that generates look and say sequence. What > > do you Python guys think of it? Too "Java-ish"? > > Yes, but that's beside the point. :) Well... I'm always paranoid that I'm, you know, writing Java in Python :) Thanks for the examples! That last one took me a while to understand. I like the way you approach it though (e.g.: going after clarity first instead of shortness). Cheers Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Please Criticize My Code
Christoph Rackwitz wrote: > Why not? Because the regex isn't compiled? > Don't tell me not to do something, tell me why i should'nt do it. No it's not the regex, it's because you just spoiled the challenge for everybody who hasn't solved level 10 yet... -- http://mail.python.org/mailman/listinfo/python-list
Why is map() preferable in this case?
Hello, I'm just reading the latest edition of Python Cookbook, where it says in Recipe 4.2: "when the op you wanna perform on each item is to call a function on the item and use the function's result, use L1 = map(f, L), rather than L1 = (f(x) for x in L)" What is wrong with the generator expression (or maybe it is list comprehension, I cannot remember now whether they used [] or () in the book)? Is it for clarity? I'm a newbie, and to me, the generator/comprehension looks _way_ more clearer than map(f, L). Are there any performance/memory requirements I'm not aware of? Why would one want to use map() when there's already an expression that is so clear and easy to understand? Thanks! Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is map() preferable in this case?
Delaney, Timothy (Tim) wrote: > map() will be faster if the function you are calling from map() is > *also* in coded in C. If it's coded in python, then the generator > expression will probably be faster. > > Use whatever reads better to you. Look at optimising when you need to, > and not before. Well, I can understand why some people prefer map(). It's shorter to type, and after I'm used to it, it's kinda OK actually. I wonder if BDFL is going to remove it for real in Python 3000... > > Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list
Suggestions for a Java programmer
Hello there, I've been programming in Java for about 8 years now, but lately I've been hearing a lot about Python and I'm really interested in learning more about it. I've read the tutorial, and some books (core python programming is one), but there's one thing that's still missing: how to use Python the "Python" way. I found learning C# was a breeze for me because the language shares a lot of concepts and notions with Java--I can always say: "I do X this way in Java, I should be able to do X this way too in C#", and usually I'm not far off the mark. But Python is different enough that, even though some basic concepts do translate easily, idioms and effective usage of it don't come easy. I can't help thinking that when I'm writing Python, I'm actually writing Java in Python. Not Python in Python. Can you point me to "Python for Java Programmers" resources? I found one blog, but that only touched the tip of the iceberg, I feel. I know that as I use Python more and read more books and read how experienced Python programmers code, eventually I'll find it out. But I'd like to expedite that process if possible. What are your suggestions? Thank you! Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestions for a Java programmer
Hi Christos, Christos TZOTZIOY Georgiou wrote: > On 24 Mar 2005 00:22:09 -0800, rumours say that "Ray" > <[EMAIL PROTECTED]> might have written: > > Searching google for "python for java programmers" (without the quotes) > produces: > > Python for Java programmers - Irmen's Python wiki Yes, I feel that this wiki touches more on how Java compares to Python (as opposed to how to *think* in Python). Maybe I should get the Python Cookbook to absorb more of the Python way of thinking, you think? > Python & Java: Side by Side Comparison This also compares Java & Python, the differences of which I am already aware of. > Jython Home Page (which you might like a lot) Thanks, I've used it before, but I feel that I was using it to "write Java in Python" > dirtSimple.org: Python Is Not Java (some useful pointers) This is the one I was referring to. I'm looking for something like this (how some common idioms in Java is not the best way to do it in Python, and how to do things the Python way). Thanks! Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestions for a Java programmer
bruno modulix wrote: > These two books should help you to get a grasp of Pythonic idioms: > > http://www.mindview.net/Books/TIPython Will read this later. > http://diveintopython.org/ I just downloaded this one and am reading it now. Thanks bruno! > > > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestions for a Java programmer
Ville Vainio wrote: > Regarding a Java programmer moving to Python, a lot of the mindset > change is about the abundant use of built in data types of Python. So > a Java programmer, when confronted with a problem, should think "how > can I solve this using lists, dicts and tuples?" (and perhaps also my > new favourite, sets). Class-based solution should be chosen only after > seeing that the problem can't be trivially solved with built-in types. Hmmm, but isn't it the same as a Java programmer who's familiar with the Collection Framework? (Which has list, dict (map), and set)? -- http://mail.python.org/mailman/listinfo/python-list
tcp networking question (CLOSE_WAIT)
hi, I'm new to python networking. I am waiting TCP server/client app by using python built-in SocketServer. My problem is if client get killed, then the tcp port will never get released, in CLOSE_WAIT maybe I didn't do the handler right? or anyway I can catch the client get killed? I wrote following simple code to explain the issue I have, server listen on 127.0.0.1:1234 client need to send multi-messages (I am sending 2 in this test) if client get killed (I just do kill client_pid) then if I check lsof, I will see the new allocated tcp do not get released server.py #!/usr/bin/python import threading import SocketServer import time class TCPServerRequestHandler(SocketServer.BaseRequestHandler): def handle(self): while True: data=self.request.recv(1024) if not data: time.sleep(0.1) continue print data self.request.send(data) if data=='end': break def main(): server = TCPServer(('127.0.0.1', 1234), TCPServerRequestHandler) ip, port = server.server_address server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() time.sleep(600) server.shutdown() server.server_close() if __name__=='__main__': main() client.py import socket import time def client(): sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(('127.0.0.1', 1234)) sock.sendall('hello') response=sock.recv(1024) print "Received:", response time.sleep(60) sock.sendall('end') response=sock.recv(1024) print "Received:", response sock.close() if __name__=='__main__': client() when I run it, client has 60 seconds sleep, so I just kill the process from OS kill 93948 then I'm running lsof to find my TCP/UDP lsof -n -p $(ps -ef|grep serve[r]|awk '{print $2}')|egrep '(TCP|UDP)'|awk '{print $NF}' TCP 127.0.0.1:search-agent (LISTEN) TCP 127.0.0.1:search-agent->127.0.0.1:59411 (CLOSE_WAIT) I will see the CLOSE_WAIT, this is where the client get killed. any help would be great! Thanks a lot! -- https://mail.python.org/mailman/listinfo/python-list
Re: tcp networking question (CLOSE_WAIT)
On Thursday, February 25, 2016 at 1:18:05 PM UTC-5, Martin A. Brown wrote: > >I'm new to python networking. I am waiting TCP server/client app by > >using python built-in SocketServer. My problem is if client get > >killed, then the tcp port will never get released, in CLOSE_WAIT > > I did not thoroughly review your code (other than to see that you > are not using SO_REUSEADDR). This is the most likely problem. > > Suggestion: > > man 7 socket > > Look for SO_REUSEADDR. Then, apply what you have learned to your > code. > > -Martin > > -- > Martin A. Brown > http://linux-ip.net/ it's not I can't bind the address, my problem is: server is long run. if client die without "disconnect" then server will leak one socket. by using the built-in thread socket server. the extra tcp port are opened by built-in class itself. if the handler() is finish correctly (the line with break) then this socket will get cleaned up. but if client dies, then I am never get out from that True loop. so the socket will keep in close_wait -- https://mail.python.org/mailman/listinfo/python-list
Re: tcp networking question (CLOSE_WAIT)
On Thursday, February 25, 2016 at 12:56:10 PM UTC-5, Ray wrote: > hi, > > I'm new to python networking. I am waiting TCP server/client app by using > python built-in SocketServer. My problem is if client get killed, then the > tcp port will never get released, in CLOSE_WAIT > > maybe I didn't do the handler right? or anyway I can catch the client get > killed? > > I wrote following simple code to explain the issue I have, server listen on > 127.0.0.1:1234 > client need to send multi-messages (I am sending 2 in this test) if client > get killed (I just do kill client_pid) then if I check lsof, I will see the > new allocated tcp do not get released > > server.py > > #!/usr/bin/python > import threading > import SocketServer > import time > > class TCPServerRequestHandler(SocketServer.BaseRequestHandler): > > def handle(self): > while True: > data=self.request.recv(1024) > if not data: > time.sleep(0.1) > continue > print data > self.request.send(data) > if data=='end': > break > > def main(): > server = TCPServer(('127.0.0.1', 1234), TCPServerRequestHandler) > ip, port = server.server_address > server_thread = threading.Thread(target=server.serve_forever) > server_thread.daemon = True > server_thread.start() > time.sleep(600) > server.shutdown() > server.server_close() > if __name__=='__main__': > main() > > client.py > import socket > import time > > def client(): > sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM) > sock.connect(('127.0.0.1', 1234)) > sock.sendall('hello') > response=sock.recv(1024) > print "Received:", response > time.sleep(60) > sock.sendall('end') > response=sock.recv(1024) > print "Received:", response > sock.close() > > if __name__=='__main__': > client() > > > when I run it, client has 60 seconds sleep, so I just kill the process from OS > kill 93948 > > then I'm running lsof to find my TCP/UDP > lsof -n -p $(ps -ef|grep serve[r]|awk '{print $2}')|egrep '(TCP|UDP)'|awk > '{print $NF}' > > TCP 127.0.0.1:search-agent (LISTEN) > TCP 127.0.0.1:search-agent->127.0.0.1:59411 (CLOSE_WAIT) > > I will see the CLOSE_WAIT, this is where the client get killed. > > > any help would be great! > > Thanks a lot! I fond the issue. it's my own stupid issue. i did "continue" if no data received. just break from it then it will be fine -- https://mail.python.org/mailman/listinfo/python-list
Re: tcp networking question (CLOSE_WAIT)
On Thursday, February 25, 2016 at 1:56:21 PM UTC-5, Martin A. Brown wrote: > Hello again Ray, > > >> >I'm new to python networking. I am waiting TCP server/client app by > >> >using python built-in SocketServer. My problem is if client get > >> >killed, then the tcp port will never get released, in CLOSE_WAIT > >> > >> I did not thoroughly review your code (other than to see that you > >> are not using SO_REUSEADDR). This is the most likely problem. > >> > >> Suggestion: > >> > >> man 7 socket > >> > >> Look for SO_REUSEADDR. Then, apply what you have learned to your > >> code. > > > >it's not I can't bind the address, my problem is: server is long > >run. if client die without "disconnect" then server will leak one > >socket. > > Sorry for my trigger-happy, and incorrect reply. > > After so many years, I should know better than to reply without > completely processing questions. Apologies. > > >by using the built-in thread socket server. the extra tcp port are > >opened by built-in class itself. if the handler() is finish > >correctly (the line with break) then this socket will get cleaned > >up. but if client dies, then I am never get out from that True > >loop. so the socket will keep in close_wait > > > >I fond the issue. it's my own stupid issue. > >i did "continue" if no data received. > >just break from it then it will be fine > > Well, I'm glad you found the issue. > > Best of luck, > > -Martin > > -- > Martin A. Brown > http://linux-ip.net/ Thank you very much for reply and help. -- https://mail.python.org/mailman/listinfo/python-list
matplotlib question: OverflowError: Allocated too many blocks
hi, i'm using matplotlib to generate chart from audio wave file, and I had a problem with it. test code as: from scipy.io import wavfile import matplotlib.pyplot as plt rate, x = wavfile.read('test2.wav') plt.plot(x) plt.savefig('test2.png') the len of x= 19531840 (as len(x) ) matplotlib give exception: OverflowError: Allocated too many blocks if I display it by: plt.draw() plt.show() everything works fine. it seems I just can't save the output to a file. I know if I reduce the figsize would make it work. [aka plt.subplots(figsize=(5,2)) ] but this is not what I need. I need to generate the large chart. (depends on size of input file) anyone know if there's another way to "save" big output file? -- https://mail.python.org/mailman/listinfo/python-list
How to design:Use One TCPIP Client connection to Server and work concurrently
Hi all, The system use ONE tcpip client and connection to server. A large batch transactions send to server.I want to send to server concurrently. any idea ? In my thinking, A.Devide large batch transactions to small batch transactions. B.Create multi-thread or multiprocessing to process small transactions. C.No idea at how to control multithread using ONE client concurrently? Each small transactions do not need to wait others Thank for your suggestions. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to design:Use One TCPIP Client connection to Server and work concurrently
Hi all, Because the server only can accept ONE connect from client. If the client establish connection with the server,the server can not accept other client. One large batch transaction file come from user. client divide the large file to several smaller files. In my thinking: client have many seats.Each smaller files is thread. client manage which seat was avaiable,handle send to/recv from server. Any idea or suggestion? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to design:Use One TCPIP Client connection to Server and work concurrently
In some enviroment,Client connect with Server(Always connect). It is a little like pipe.Many requester use the pipe send request and receive reponse.In client side,it dispatch requests and handle/match response. -- https://mail.python.org/mailman/listinfo/python-list
Installing 2.6 on Win 7
I have not found binaries for this install. The page http://www.python.org/download/windows/ takes me to http://www.python.org/download/releases/ which goes to http://www.python.org/download/releases/2.6.7/ Here are Gzip and Bzip tar balls. The readme files describe linux builds and the content seems to match. Are there win binaries or source files? ray -- http://mail.python.org/mailman/listinfo/python-list
RE: Installing 2.6 on Win 7
Brian, Thank you, that was great. Ray Joseph, PE832 586-5854r...@aarden.us Original Message Subject: Re: Installing 2.6 on Win 7From: Brian Curtin <brian.cur...@gmail.com>Date: Fri, September 09, 2011 3:14 pmTo: ray <r...@aarden.us>Cc: python-list@python.orgOn Fri, Sep 9, 2011 at 15:04, ray <r...@aarden.us> wrote:>> I have not found binaries for this install. The page> http://www.python.org/download/windows/> takes me to> http://www.python.org/download/releases/> which goes to> http://www.python.org/download/releases/2.6.7/> Here are Gzip and Bzip tar balls. The readme files describe linux> builds and the content seems to match.>> Are there win binaries or source files?As stated at the top of that page..."""Python 2.6.7 is a security-fix only source release for Python2.6.6, fixing several reported security issues. Python 2.6.7 wasreleased on June 3, 2011."""If you work backwards, http://www.python.org/download/releases/2.6.6/is the last version binaries were created for. -- http://mail.python.org/mailman/listinfo/python-list
Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7
On Friday, November 18, 2011 12:55 AM, W. eWatson wrote: Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I uninstalled and installed. Same problem. If one right-clicks on a py file, IDLE is not shown in the menu as Edit with IDLE. After playing with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same results. If I look at a 2.4 install on my laptop, I get the desired reference to Edit with IDLE. My guess is that Win 7 is behind this. If so, it's good-bye Python. Comments? Why not good-bye Windows ? Actually you may want to try Vim, or gVim in Windows. I think the people who use IDLE is with really good patient. -- http://mail.python.org/mailman/listinfo/python-list
How to: Coordinate DictReader and Reader for CSV
I am trying to get the data from a CSV file into variables. I have used DictReader to get the field names and I can report them. When I attempt to look at the data, every row shows the combination of fieldname:data. How do I get the data out? linelist=open( "C:/Users/rjoseph/Documents/Projects/Bootstrap Plan Design Tool/Sandbox/line_list_r0a.csv", "rb" ) csvDictReader=csv.DictReader( linelist, dialect='excel' ) for data in csvReader: print data[0] print data[1] print data[2] print data[3] linelist.close() Thanks, ray -- http://mail.python.org/mailman/listinfo/python-list
How to Get Data from DictReader for CSV Files
I don't see how to get my data from the output. I can see the data in the rows but it is mixed in with the field names. That is, the data I get comes out as: fieldname1 : data1 , fieldname2 : data2 , etc. import csv linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) csvReader= csv.DictReader( linelist, dialect='excel' ) for data in csvReader: print data linelist.close() I want to pass this data as arrays or lists to another module such as: myfunction(data1, data2, data3) How do I get the data I want out of the pair fieldname1 : data1? Thanks, ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How to: Coordinate DictReader and Reader for CSV
On Nov 21, 7:59 am, Neil Cerutti wrote: > On 2011-11-21, ray wrote: > > > I am trying to get the data from a CSV file into variables. I have > > used DictReader to get the field names and I can report them. When I > > attempt to look at the data, every row shows the combination of > > fieldname:data. How do I get the data out? > > linelist=open( "C:/Users/thisuser/Documents/Projects/Bootstrap Plan > > Design Tool/Sandbox/line_list_r0a.csv", "rb" ) > > csvDictReader=csv.DictReader( linelist, dialect='excel' ) > > for data in csvReader: > > print data[0] > > print data[1] > > print data[2] > > print data[3] > > linelist.close() > > The elements yielded by a DictReader iterator are dictionaries, > and the keys are the headings of the csv file. So replace those > integers with strings representing the headings of your file. > > If the headings are actually those numbers, you want: > > [...] > print data['0'] > print data['1'] > print data['2'] > print data['3'] > print data['4'] > [...] > > -- > Neil Cerutti > "This room is an illusion and is a trap devisut by Satan. Go > ahead and dauntlessly! Make rapid progres!" > --Ghosts 'n Goblins Neil, Thank you for your efforts. When I use the 0, 1, etc. in the data[x] slot, I get some data. When I put a string in, I get an error stating: TypeError: list indices must be integers, not str But your suggestion has helped my better understand my problem. The output is first a list of the keys and then the associated data. The difficulty is that I want to pass the data to another function will I am in the 'for' loop. But the first data out is keys and that is not the data I want to send to the other function. Is there a way to capture the keys outside of the for loop so when the for loop is entered, only data is extracted? Thanks, ray -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Get Data from DictReader for CSV Files
On Nov 21, 10:29 am, GZ wrote: > Hi, > > On Nov 21, 7:42 am, ray wrote: > > > > > > > I don't see how to get my data from the output. I can see the data in > > the rows but it is mixed in with the field names. That is, the data I > > get comes out as: > > fieldname1 : data1 , fieldname2 : data2 , etc. > > > import csv > > linelist=open( "C:/Users/me/line_list_r0.csv", "rb" ) > > csvReader= csv.DictReader( linelist, dialect='excel' ) > > for data in csvReader: > > print data > > linelist.close() > > > I want to pass this data as arrays or lists to another module such as: > > myfunction(data1, data2, data3) > > > How do I get the data I want out of the pair fieldname1 : data1? > > > Thanks, > > ray > > It returns a dict(). You can reference the fields with > data['fieldname1'], etc.- Hide quoted text - > > - Show quoted text - GZ, That works great. Thanks, ray -- http://mail.python.org/mailman/listinfo/python-list
Please enlighten me about PyPy
Hello! I've been reading about PyPy, but there are some things that I don't understand about it. I hope I can get some enlightenment in this newsgroup :) First, the intro: "The PyPy project aims at producing a flexible and fast Python implementation. The guiding idea is to translate a Python-level description of the Python language itself to lower level languages." So the basic idea is that PyPy is an implementation of Python in Python (i.e.: writing Python's interpreter in Python), and then translate that into another language such as C or Java? How is it different from CPython or Jython then? Also, what does "translation" here mean? Translation as in, say, "Use Jython to translate PyPy to Java classes"? Or "Use Psyco to translate PyPy to native exec"? "Rumors have it that the secret goal is being faster-than-C which is nonsense, isn't it?" Why is this supposed to be nonsense if it's been translated to C? I mean, C version of PyPy vs. CPython, both are in C, then why is this supposed to be nonsense? It seems that I'm missing a lot of nuances in the word "translation" here. Also, this one: We have written a Python interpreter in Python, without many references to low-level details. (Because of the nature of Python, this is already a complicated task, although not as much as writing it in - say - C.) Then we use this as a "language specification" and manipulate it to produce the more traditional interpreters that we want. In the above sense, we are generating the concrete "mappings" of Python into lower-level target platforms. So the "language specification" in this paragraph _is_ the Python implementation in Python, a.k.a.: PyPy? Then what does "manipulate it to produce the more traditional interpreters" mean? I mean, it seems from what I read that PyPy is more about a translator that translates Python code into something else rather than implementing Python in Python. In that case, it could have been any other project, right? As in implementing X in Python, and then translate to another language? Thanks for any pointers! -- http://mail.python.org/mailman/listinfo/python-list
Re: Please enlighten me about PyPy
Hi Luis! Thanks for your reply :) Some further questions below... > So its author decided that having a python implementation written in > python would laid a much better basis for implementing psyco-like > techniques. OK, so far I get it... I think. So it's implementing the Python interpreter in a Python subset called RPython, makes it more amenable to translation with psyco-like techniques. But how is this superior compared to CPython? Is it because Psyco is a specializer, which generate potentially different code for different sets of data? So the assumption is that the interpreter deals with a very specific set of data that Psyco will be able to make use to generate very efficient machine code? I still don't get how this can be superior to the hand-coded C version though? Also, this sounds like it involves implementing the Python's libraries that are currently implemented in C, in Python, so that they can be translated. Did I get that correctly? > This implementation requires a minimal core, writen in a restricted > subset of python called "rpython". This subset avoids many of the most > dynamic aspects of python, making it easier to authomatically translate > it to C through a tool that uses top-notch type inference techniques. OK, now I understand this bit about RPython, thanks. > This translated version of the rpython interpreter (which got already > auto-translated to c), is the basis of Pypy. Now I'm confused again--psyco translates Python into machine code--so how does this tie in with the fact that the interpreter written in Python is translated into another language (in this case C?) > However, I still doubt that I really understood it... > I'm still not sure if the type inference techniques will be used to > improve the performance of programs running on pypy, or if these > techniques were only intended for getting the rpython interpreter > translated to c. > > As far as I know, pypy is currently about 10/20 times slower than > cpython, although many optimizations remain to be done. > And I 'm not sure, but I think that its developers rely on the > psyco-like techniques to achieve the big speed boost their looking for. This is another one I don't get--this approach seems to imply that when PyPy is reasonably complete, it is expected that it'll be faster than CPython. I mean, I don't get how something that's translated into C can be faster than the handcoded C version? Thanks, Ray > > Luis -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido at Google
EP wrote: > Congrats, Guido. Thanks for Python and may your future at Google be bright. Congrats to BDFL too--may the future of his and his creation be bright indeed! Ray > > > EP -- http://mail.python.org/mailman/listinfo/python-list
Re: Please enlighten me about PyPy
Luis M. González wrote: > Well, first and foremost, when I said that I leave the door open for > further explanations, I meant explanations by other people more > knowlegeable than me :-) Thanks for clearing up some of my confusion with PyPy, Luis! Cheers, Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Please enlighten me about PyPy
Carl Friedrich Bolz wrote: > Hi! > > some more pointers in addition to the good stuff that Luis wrote... Thanks Carl! That solidified my mental picture of PyPy a lot more :) Warm regards, Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft IronPython?
Hi Luis, IronPython as it is now is already slightly different from CPython isn't it? Because it has to capture features of CLR languages that are not in Python (such as using generic containers). I wonder how this will branch further in the future--will CPython expand to follow IP, or will they keep diverging further and further. Still I'm very excited about IP--it's the best thing to happen in a long while, especially with Jython moving so slow these days... Ray Luis M. González wrote: > Ironpython has been in development from awhile, and now it's in beta > version 1.0. > Is it good to have Python running on every existing platform out there? > Of course it is. > Luis -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft IronPython?
Luis M. González wrote: > > IronPython as it is now is already slightly different from CPython > > isn't it? Because it has to capture features of CLR languages that are > > not in Python (such as using generic containers). > > Hmm... I'm not sure what you mean by "capture features of CLR". > I think Ironpython is a faithful implementation of python but, of > course, it's aimed at allowing programmers to take advantage of the > framework, it's classes and components. > If not, there would be no reason to port Python to .Net. > Don't you think? Oh, yeah, that's undoubtedly true. What I was referring to were things such as using [] for generic, that doesn't exist in current CPython does it? Regardless, I think it doesn't matter much because once you use .NET libraries you are kinda tied to IronPython anyway--but if Python as a language can be picked up by a broader audience due to IP I'm very happy :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft IronPython?
Kay Schluehr wrote: > At least for Jython we already know from the Jython homepage that it is > the great hope of the Java platform to survive in future and far > beyond. Yeah except that it's coming on so slow... we were doing some scripting for our Java app and Groovy won because Jython has been in alpha for YEARS :( -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft IronPython?
Kent Johnson wrote: > That's a hoot! Of course you can choose what language you like, but to > choose Groovy over Jython because it is more developed is mind-boggling! > > Jython 2.1 has been released, stable and suitable for production use for > many years. The Groovy community was still working on the *language > definition* in November 2005 and has yet to deliver a stable final release. Yeah, I know, I know... but I'm not the only voice in the team, mind. If it were up to me it'd be Jython for sure... Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft IronPython?
Luis M. González wrote: > I'm not en expert on the subject, but I guess that any language > implementation running on .Net should be able to at least "understand" > generics or any other feature available on this framework, because > languages are supposed to interact and use all kinds of classes and > assemblies regardless of the language they were written in. > As for using generics, I think this is not very important in python, I > guess, because it is dyamic and you don't declare types. > So writing x =List[str](), for example, doesn't buy you anything. > You're better off using a regular list: x = []. Yes, in this List example I agree with you. I think it is better to use the regular one. But, say, since C# has generic now, somebody may write a generic class, so you have to have a way to use it (unless it's like Java when you can still do raw types--correct me if I'm wrong). But then again, once you start using .NET class you're tied to .NET anyway so this is not a big problem, I think--although the more perfectionist among us might like to isolate parts of Python code that are .NET/IP specific to make porting easier if it ever comes to that... > > Someone more knowledgeable please kindly correct me... > > Luis -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft IronPython?
Max M wrote: > First of they would need to make Python a strategic platform for > corporations, so that it was used practically everywhere on Windows. Actually, if Python gets used everywhere on Windows, I'll be happy, pure Python or no pure Python :) Visual Python 2010 anyone? -- http://mail.python.org/mailman/listinfo/python-list
Help me in this please--is Python the answer?
Hello, I've got the chance to determine the technology to use in creating a product similar to this: http://www.atomicisland.com/ Now the thing is that I need to sell this to the guy with the money. I've developed for years with C++ and Java, last 7 years J2EE, and I'm kinda sick of the "bloated" feeling that the whole J2EE/appserver business carries into the picture. Python is the language that I use at home, so I've been thinking of using this to implement the product mentioned above. I've personally experienced the pleasure of programming in it, and as such, I hope that this will translate to advantage over our competitors (a la Paul Graham's argument for Lisp). That said, my experience with Python is limited to toy programs, that I write myself for my own use. As such, I have several concerns: 1. How scalable is Python? In J2EE, when the load gets really big, we can resort to clustering. Same goes about availability. Is there anything that will help here in Python? (Mind, my Python experience is usually with scripts and console). 2. If there is, what is the transition like from being lightweight to heavyweight? E.g.: in J2EE we can use Tomcat at first as a lightweight web container, and scale as necessary using a more powerful appserver. Is this possible in Python? 3. Have any of you done this before? As in you come from a heavy J2EE background, and then switch to doing something equally serious in Python? In your experience, in the end, did you find Python suitable at all for this domain or you think you should have stuck to J2EE? What are the pros and cons you discovered? (I'd love to develop in Python and get paid for it finally, but at the same time I do want to give the money guy the best value for his money...) Thanks much, Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Hi Ed, Ed Singleton wrote: > Personally I have found that if you need to sell a technology on, > saying it's written in Java is an advantage generally (because "it's a > standard"). If it's written in Python you may get asked why it has > been written in a "scripting language" if they've heard of it at all. Yes, I agree. Especially with those cover-my-ass types in big institutions who'd only go for things that have the word "Enterprise" on it :) > exactly the same tools as them, so you have to choose better tools. > Almost by definition, the tools that the majority are using are NOT > the best tools for the job. If I were you I'd definitely choose > Python, if only because everyone else is not using it yet. Yes, that was what I was thinking. Fast development cycle and ability to embrace change is crucial here. I do feel the way Java is getting in the way of my coding even after using Python for small personal projects. But then on the other hand, there is a manpower problem--it's damn easy to find a Java programmer (although the quality that you get is a different matter). Python programmers are more difficult. > If I were you I'd concentrate on creating a website that actually > works. Your chances of creating a website that needs to scale to be > 'heavyweight' are very slim. If you manage to get to that point then > you can start worrying about how to cope with all the money that's > rolling in ;) You know what, this is a very good point :)) > AFAIAA Python scales better than Java as any performance critical > parts can be easily rewritten in C. To spend too much time worrying > over it is premature optimisation though. Yes, but this is more of a web application though--something that I've never developed in Python before, so... I'll be evaluating Django shortly--let me see how it compares to Tomcat. > > (I'd love to develop in Python and get paid for it finally, but at the > > same time I do want to give the money guy the best value for his > > money...) > > The only thing you really need to be happy is to find something you > enjoy doing and to do it. Money is definitely secondary to that. If > you have a chance to be paid for working in Python, then go for it; > even if you fail, you will have spent your days in a happy state. Yeah, I have the chance to do that if I manage to get this through, but at the same time I do want to give the guy who funds us the best value possible for his money. (If--If--it means I have to use J2EE, I will do it.) Thanks, Ray > > Ed -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Tim N. van der Leeuw wrote: > Hi Ray, Hi Tim! > I'm in a bit of the same boat as you only I don't get to choose my > implementation language ;-) > > Some of the concerns should be: > - Do you have to interface with things like messaging-systems (a la JMS > specs), distributed transaction managers? If so, the only way to go > Python is Jython: Python for the JVM. Because AFAIK, there are no > interfaces for Python to the likes of IBM's MQSeries or for any > distributed transaction managers. Hmmm, at this level I think not. But yes, this is a good point, I'll keep this in mind. If it's gonna be Jython, I think I might as well go with J2EE--since it is yet another layer on top of a platform. > - Is your application purely a web-based application? Or is there a > large amount of application logic which is not tied to the web in any > way? Yes, it is purely a web-based application... well, it has a "administration" page, that the back office stuff, but that can be web-based as well. > - Python has a number of frameworks for developing server applications, > like Twisted, Zope and Django. > I don't know Twisted; I know a little bit about Zope. Zope has several > enterprise-level features and provides scalability/clustering. > However, I've found the learning-curve for Zope to be a bit steep so > far; too steep to master it in what little bits of spare time I have. > (If I would have more time I'd be able to get the hang of it but I > don't have enough time) Ah, yes... all respect to Zope, but I hope this is something that can be done in Django. I suspect the implementation time will be very, very short... as typical of the nature of these projects, and with the seeming intricacies of Zope, the impression of which I get from reading about it, I don't think we have the spare time/effort... > I've started to toy a bit with Django and it seems to get rather easy > to get started with developing a Web application using Django; however > I also get the feeling that installation is a bit more involved than > with Zope and that it will be not as easy to package up an application > and transport it to another machine, as it is with Zope. Thanks, this is a useful info. I'm about to evaluate Django deeper myself, how have you found it? Does it cover the whole "web" part of the J2EE stack, at least? (i.e.: it can replace Tomcat)? How has your experience been when you need to go further? (i.e.: beyond mapping data in DB to webpages)? > So for development of Web-applications, I would certainly consider > either Zope or Django. > Both offer ways to store your data in a transactional database; Django > has some object-relation mapper tools but I'm not sure how exactly Zope > stores data in a SQL database (it comes with it's own powerful > object-database, the ZODB but I don't know if OR mapping tools exist > for Zope). Hmm, I've never got the time to look at Zope proper, but my understanding is that Django is analogous to Tomcat, and Zope is analogous to a full blown appserver a la WebLogic, right? > So what are your requirements for 'J2EE' applications? And which Python > framework would best fit the bill? Hmmm, it's purely web-based, and I don't foresee message queueing and stuff at this point. I'll take a better look at Django. Thanks! Ray > > > cheers, > > --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Very useful input, Adrian. Thanks a lot! These are facts that I can use to convince people that Python is a legit choice for the app I'm developing. Warm regards, Ray Adrian Holovaty wrote: > Ray wrote: > > Yes, but this is more of a web application though--something that I've > > never developed in Python before, so... I'll be evaluating Django > > shortly--let me see how it compares to Tomcat. > > Performance is one of the key features of Django. For example, I'm > using Django at washingtonpost.com for the U.S. Congress Votes > Database, which has more than 4 million records and is linked-to from > the washingtonpost.com home page whenever there's a key congressional > vote. (http://projects.washingtonpost.com/congress/) > > The server doesn't break a sweat, thanks to Django's > very-convenient-and-powerful cache system: > http://www.djangoproject.com/documentation/cache/ > > Also, the developers at grono.net, a Polish social networking site with > more than half a million users, have converted various bits of their > Java code to Python/Django. They've found that Django is not only much > quicker (and more fun) to develop in, it's also *faster* than Java and > requires less hardware. E-mail me personally if you want their contact > information for direct testimonials; we'll be publishing some more > testimonials publically as we get closer to Django 1.0. > > I would never use TurboGears or Ruby on Rails over Django for any > performance-intensive Web app. In my opinion, both frameworks make some > poor design decisions regarding the importance of performance. > > Adrian > -- > Adrian Holovaty > holovaty.com | chicagocrime.org | djangoproject.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
bruno at modulix wrote: > Possibly - but if a programmer is not able to pick on Python in a matter > of days, then it's a bad programmer that won't be of any help whatever > the language. So in fact, choosing Python may help you get better > programmers !-) You have a point there! :) > You may also want to have a look at turbogears (roughly similar to > Django, but probably much more flexible) Hmm--much more flexible in what sense, Bruno? Thanks much! Ray > > My 2 cents > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me in this please--is Python the answer?
Fredrik Lundh wrote: > I hope you're aware that this sounds a lot like late 90's anti-dynamic- > language propaganda... > > "I would never use Perl or Python over C++ for any performance- > "intensive Web app. In my opinion, both languages make some > poor design decisions regarding the importance of performance." > > (you all know all the counter-arguments) Does the comparison between dynamic and static language carry over to comparison between Django and Turbogear too? Is this what is meant by "Turbogear is much more flexible than Django"? Thanks, Ray > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python code from Java?
fortepianissimo wrote: > > Waiting for jython2.3 might be an option, too - things are pretty much > > on the move right now. > > Any idea how soon that will be? If you just want to use Java to call Python, you can use Jython 2.1 too. Jython 2.2 is in (active) development right now, and hopefully a beta will come out soon. > > Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Need a compelling argument to use Django instead of Rails
I just moved to another company that's mainly a Java/.NET shop. I was happy to find out that there's a movement from the grassroot to try to convince the boss to use a dynamic language for our development! Two of the senior developers, however, are already rooting for Ruby on Rails--although they haven't tried RoR themselves. When I suggested Django, they went like, "what's that?". I said, "It's like the Python counterpart of RoR". "Nah, we're not interested in Python." I think they are already predisposed to RoR simply because of RoR's visibility (i.e.: at my workplace everybody knows RoR but nobody knows about Django unless they've used Python as well). So far the arguments I can think of: 1. The investment of learning Python will be a good investment because it transfer to platforms that we've already supported, i.e.: JVM and .NET CLR (using Jython and IronPython). Ruby's availability on this platform is not as mature--JRuby is still at 0.9 and I don't think IronRuby is coming out anytime soon :) 2. Python is a much more mature language than Ruby--it's been around since ages ago and as such has a lot more tools, articles, and other resources than Ruby. It is also the language being used by high-visibility company like Google, with the creator of the language himself working there. 3. Python emphasizes readability instead of cleverness/conciseness. 4. What else? I haven't tried RoR so I can't argue meaningfully on whether using Django will put us at an advantage. Can you help me with my argument? Meanwhile I think I'll give RoR a try as well. Thank you, Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Steve Holden wrote: > I wouldn't waste your time. "A man convinced against his will is of the > same opinion still", and they already know they aren't interested in > Python. There are probably many other matters about which they are > uninformed and equally determined. Well the thing is that I have to admit I have some stake in this. If we're using Rails then everybody's starting from 0. Whereas if we're using Python I already know it so I'll have an easier time :) Also, those are just two developers. Convincing the big guy, the decision maker, is a separate matter isn't it? Do you know of any other arguments, or you do think that for somebody who really, really doesn't care about which language, either RoR/Ruby or Django/Python will do just fine? Cheers Ray > >http://sethgodin.typepad.com/seths_blog/2005/08/i_changed_my_mi.html > > regards > Steve > -- > Steve Holden +44 150 684 7255 +1 800 494 3119 > Holden Web LLC/Ltd http://www.holdenweb.com > Skype: holdenweb http://holdenweb.blogspot.com > Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
BTW the link below is good reading! Thanks Steve! Steve Holden wrote: >http://sethgodin.typepad.com/seths_blog/2005/08/i_changed_my_mi.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Tim Heaney wrote: > "Ray" <[EMAIL PROTECTED]> writes: > > > > Can you help me with my argument? > > Well, there is this study suggesting Django outperforms Ruby on Rails > > http://wiki.rubyonrails.com/rails/pages/Framework+Performance > > > Meanwhile I think I'll give RoR a try as well. > > Good idea. I think Ruby on Rails is terrific. Perhaps you'll think so > too. If not, at least you'll have a better idea of why you don't. Thanks Tim!! Cheers Ray > > Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Thanks Sybren for the reply! Regarding this point: > The form handling is also excellent. Is it excellent in a way that's "better" than RoR in certain ways? Regards, Ray Sybren Stuvel wrote: > Ray enlightened us with: > > Two of the senior developers, however, are already rooting for Ruby on > > Rails--although they haven't tried RoR themselves. When I suggested > > Django, they went like, "what's that?". > > > > I said, "It's like the Python counterpart of RoR". > > Bad answer. Now they think they'll get the same thing they already > have with RoR, but that they'll have to put more effort into it. > > > "Nah, we're not interested in Python." > > Ask them why. > > > I think they are already predisposed to RoR simply because of RoR's > > visibility (i.e.: at my workplace everybody knows RoR but nobody > > knows about Django unless they've used Python as well). > > Which means most of the people saying "we're not interested in Python" > do so without proper reason, since they don't know the language. > > > 1. The investment of learning Python will be a good investment > > because it transfer to platforms that we've already supported, i.e.: > > JVM and .NET CLR (using Jython and IronPython). Ruby's availability > > on this platform is not as mature--JRuby is still at 0.9 and I don't > > think IronRuby is coming out anytime soon :) > > Jython isn't up to par with current Python versions either. > > > 2. Python is a much more mature language than Ruby--it's been around > > since ages ago and as such has a lot more tools, articles, and other > > resources than Ruby. It is also the language being used by > > high-visibility company like Google, with the creator of the > > language himself working there. > > That is _definitely_ true. The behaviour of Ruby hasn't even properly > been defined. > > > 4. What else? I haven't tried RoR so I can't argue meaningfully on > > whether using Django will put us at an advantage. > > Check out the admin you get for free with Django. Add/edit/delete > controls are easily done with RoR, but Django comes with a mature, > easy to use, on-the-fly generated, customizable admin. The form > handling is also excellent. > > Sybren > -- > The problem with the world is stupidity. Not saying there should be a > capital punishment for stupidity, but why don't we just take the > safety labels off of everything and let the problem solve itself? > Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Steve Holden wrote: > Well, my view is that both are frameworks, and so you will inevitably > "run out of steam" at some point if your implementation plans become too > ambitious. The impression I get is that Rails is relatively inflexible > on database schemas, and once you get "off the beaten track" it gets > difficult to cope with complex existing databases. Hi Steve, Thanks for the reply! Regarding "running out of steam", well... we've been using Struts + Spring + Hibernate on the Java side, so yeah, we're quite used to molding our code to fit frameworks :) Cheers Ray > > regards > Steve > -- > Steve Holden +44 150 684 7255 +1 800 494 3119 > Holden Web LLC/Ltd http://www.holdenweb.com > Skype: holdenweb http://holdenweb.blogspot.com > Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
David Cook wrote: > On 2006-07-24, Sybren Stuvel <[EMAIL PROTECTED]> wrote: > > > Jython isn't up to par with current Python versions either. > > But the last release is up to the level of C-Python 2.2 or so. I don't > really feel like I'm missing that much with it. You mean the alpha? They're rushing for a beta now that'll bring Jython to 2.2, I hope it'll come out soon. But yeah, compared to IronPython (2.4 compliant, halfway to 2.5 even), it's pretty behind. But things are changing the development seems to be picking up speed again! Cheers Ray > > Dave Cook -- http://mail.python.org/mailman/listinfo/python-list
When is Django going to...
support Oracle and MS SQL Server? I just realized that's gonna be a big blow for my case against RoR because we use both databases almost exclusively, we don't use any of Django supported database actually. I did a search and found that there was an Oracle support committed--but is it going to make it into any release any time soon? Thanks Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: When is Django going to...
Bruno Desthuilliers wrote: > Ray wrote: > > support Oracle and MS SQL Server? I just realized that's gonna be a big > > blow for my case against RoR because we use both databases almost > > exclusively, we don't use any of Django supported database actually. > > > > I did a search and found that there was an Oracle support > > committed--but is it going to make it into any release any time soon? > > > > You'd probably get better answers on Django's mailing-list ? Er, yes. That was silly of me. Thanks Bruno! Sorry everyone, Ray > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Kay Schluehr wrote: > Aren't they "rushing" for years? The last update of the Jython news > page is from march 2005. This is not very encouraging even if there is > a secret life of Jython. Yeah I know... but I've been subscribing to jython-dev for quite sometime, and the activity there is surely picking up compared to, say, early 2006. Jython has new committers on board as well so that's encouraging. > But maybe we shouldn't worry because we can > still read: > > "Jython, lest you do not know of it, is the most compelling weapon the > Java platform has for its survival into the 21st century:-)" :( > > But yeah, compared to IronPython > > (2.4 compliant, halfway to 2.5 even), it's pretty behind. But things > > are changing the development seems to be picking up speed again! > > But you can't compile a Python module into a dotNet library that is > used from C# which is the very essence of the CLR. IronPython is not > more usefull than PythonNet. At least for my case I will use IronPython for higher level task, and perhaps calls libraries written in C# instead of the other way around, plus you can leave your module as scripts anyway. If what you want from C# is accessing Python's power then you can always host the IronPython engine can't you? -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Damjan wrote: > BTW I'd choose TurboGears for it's flexibility, but I guess Django could be > nice when more rapid results are needed (and the problem doesn't fall too > far from the Django sweet spot). Well actually I was thinking of exaclty the same thing, because our apps are mostly CRUD apps anyway. However I just learned of one very big killer--lack of support for Oracle and MS SQL Server. That pretty much shoots Django down from the list, and with it Python. > >> "Nah, we're not interested in Python." > > This is a hard attitude, but I have the same feeling about Ruby, I like > Python and just don't see a reason to invest any time in Ruby (Rails or > not).. and from that little I've seen from it.. I didn't like it. > OTOH Ruby surelly is not that bad either. Yeah, I know... in fact I have the same attitude towards Ruby too. People have been telling me it's cool left and right and I go to see some Ruby code, I go "UGH!", and refuse to continue. Maybe because Perl is #1 on my Most Hated Language list. *shrugs* Just that it's a big, huge, humongous pity to see Python keeps missing the big thing over and over again. Last time when biotechnology was hot, which language became The Language? Perl. Now simple web app is hot? It's Ruby. Of course Python is used by Google and it's something, but I guess a lot of people do not know that, even those making a living in the IT industry. OTOH everybody knows about Rails and and everybody raves about it, even those who haven't touched it! > -- > damjan -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
John J. Lee wrote: > I get that overall impression of Django too (as being more tightly > coupled to itself, hence less flexible, when compared with TurboGears > in particular). I haven't done much with it yet, though (and > presumably the 'magic-removal' branch landing did some good). > > What do you make of the rest of Django (aside from the DB stuff)? > > It's a shame TurboGears doesn't yet have a solid "out of the box" CRUD > admin interface as Django. And it's a shame that: Python doesn't have The Anointed Web Framework. Things may have been different if there can be only one, who knows. The lack of support for Oracle and SQL Server by Django is also a killer that'll prevent Django from being picked up by a LOT of companies (sadly, including mine :( ). > > > John -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Jaroslaw Zabiello wrote: > >> Ruby > >> has nice security system (private, protected, public scopes for methods and > >> attributes, > > > > This is not "security", this is data-hiding. > > No. Data hiding are in Python. Ruby uses security similiar to Java. If the > class has method marked as private it cannot be used in children classes. Why are you calling this "security"? The enforcement of "private" is not "security" in Java by a long shot. Trust me I know, been doing Java since near its inception. By your definition of "security" C++ has "security" too. But no, Java (real) security is very different from C++ and Ruby enforcement of private. It's a much bigger subject in its own right. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Hey Steve, Yes, I agree with you. The lack of checking can get confusing fast. It's not about typing without errors. Regardless of how you train as long as you're human you WILL make typos. Also having to check whether a name has already existed can be a major pain in the butt with Python. With Java you always know when a name has already existed, and what type is bound to the name. I consider this to be a Good Thing (tm). Regarding the lack of privacy, I actually like the C++ way of doing it. Privacy is there, but you have the choice to break it (using "friend") if you want/need to. C++ doesn't make it easy for you to do it inadvertently, like you described in the example. The argument against this is that since development with Python is so rapid, you're supposed to always equip your code with extensive unit tests. I like Python but I've never really bought that argument--I guess I've been doing Java too long :) Cheers Ray Steve Jobless wrote: > Sybren Stuvel wrote: > > > > Steve Jobless enlightened us with: > > > The first case can be just a typo, like: > > > > > > x.valeu = 5 > > > > > > I make typos all the time. Without a spell checker, this message > > > would be unreadable :). > > > > Then learn to read what you type, as you type it. Typing without > > errors can be trained. > > I'd rather let a machine to do that. Wasn't computer created for tasks > like this? (No, not really. But...) > > > > > > The second case can be like: > > > > > > x.next = y > > > y.next = None > > > > > > to create a linked list by piggybacking "next" to the class. It will > > > overwrite the iterater for the class if defined. > > > > You shouldn't simply pick a name and assign something to it without > > checking the current use of that name. It's pretty much true for > > everything in life. > > Well, the choice of "next" was not a good example. Sure, no one with > decent Python knowledge would do that. > But what about adding a method to the class? Am I supposed to ask "Is > anyone using name xxx?" The class may be used by developers I don't > even know and some of them may be on the other side of the planet... > > > > > > If I was working on a large project with many engineers, I'd assume > > > someone will do things like this sooner or later. I've seen many > > > horrendous code in my life and I have no control over who I work > > > with. > > > > Long live a versioning system. With that, you can find the person > > writing the horrible code, and slap them on the back of the head. > > People, like all animals, can be trained into doing the right thing. > > I'd like to. But often those people are long gone for one reason or > another. Sometimes, it happens to be my boss... > > > Maybe I should ask the question in a different way: > > What are the benefits from this? There must be something really good > (and hopefully safe) you can do with it only from the outside. I don't > have much problem over-riding functions from the inside of the class. > But from the outside, I fail to see why anyone needs to add attributes > or over-ride functions. > > SJ -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Sybren Stuvel wrote: > Ray enlightened us with: > > Also having to check whether a name has already existed can be a > > major pain in the butt with Python. With Java you always know when a > > name has already existed, and what type is bound to the name. I > > consider this to be a Good Thing (tm). > > I don't buy that. With long functions and variable declarations all > over the place, you can easily miss a few. If you then also forget to > declare a variable (people make mistakes) you can easily re-use a name > without knowing. Huh? No. The compiler will always tell you. Have you ever tried Java before? > > Sybren > -- > The problem with the world is stupidity. Not saying there should be a > capital punishment for stupidity, but why don't we just take the > safety labels off of everything and let the problem solve itself? > Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Sybren Stuvel wrote: > Ray enlightened us with: > > Huh? No. The compiler will always tell you. Have you ever tried Java > > before? > > I know what I'm talking about, I've got a degree in Computer Science > from the University of Amsterdam. Then how come you didn't know that the Java compiler will always tell you? :) > > Sybren > -- > The problem with the world is stupidity. Not saying there should be a > capital punishment for stupidity, but why don't we just take the > safety labels off of everything and let the problem solve itself? > Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
John Machin wrote: > Ray wrote: > > > The argument against this is that since development with Python is so > > rapid, you're supposed to always equip your code with extensive unit > > tests. I like Python but I've never really bought that argument--I > > guess I've been doing Java too long :) > > > > In Java, if you don't always equip your code with extensive unit tests, > what sort of testing do you do? In Java of course we do unit testing as well. It's just that things like what the OP was asking about has already been caught by the compiler at this time. > When do you pick up typo errors that the compiler may not detect, like > blahblah*12.365 instead of blahblah*12/365 ? Yeah, I know what you mean. This is not what the OP was referring to, though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Bruno Desthuilliers wrote: > Ray wrote: > Ray, please, don't top-post Um, top-post? I'm using Google News and it looks like it is placed correctly in the thread... or you're referring to a different thing? Ray -- http://mail.python.org/mailman/listinfo/python-list
Re: Re:[OT] Newbie Q: Class Privacy (or lack of)
Bruno Desthuilliers wrote: > Ray wrote: > > Bruno Desthuilliers wrote: > > > >>Ray wrote: > >>Ray, please, don't top-post > > > > > > Um, top-post? I'm using Google News and it looks like it is placed > > correctly in the thread... or you're referring to a different thing? > > http://en.wikipedia.org/wiki/Top-posting Gotcha ;-) > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Why XP can not run Python after being setting the PATH?
By any chance the command window hasn't been restarted after you've changed the PATH? Strange that looks OK. If you do echo %PATH% what does it tell you, is Python there? Cheers Ray Daniel Mark wrote: > Hello all: > > I have set the PATH for Python as follows: > > My Computer->Properties->Advanced->Environment Variables->System > Variables->Path > > ...; C:\Program Files\Python24; > > Then I try to run python under command line > > C:\>python > > C:\>python.exe > > I got nothing:) > > It works iff I run as follows: > > C:\>"Program Files\Python24\python.exe" > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] > on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> > > My question is how I can set the path so that the XP can run python > without the full path? > > > Thank you very much > -Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Bruno Desthuilliers wrote: > > I'd rather let a machine to do that. Wasn't computer created for tasks > > like this? (No, not really. But...) > > There's obviously a trade-off between 'security' and flexibility. As I > said, I do make lots of typo too, but OTOH the edit/test cycle in Python > is usually so short that such errors are not a problem for me - they're > caught almost immediatly. Actually Bruno, don't you think that the notion of flexibility in Python comes at the expense of "security" is simply due to the fact that the syntax of "screw up" is exactly the same as the syntax of "I mean it this way and I do want it"? Perhaps if we use a different syntax when we want to say "I really want this", it'll be better (so Python can differentiate between a typo and a conscious decision). So going back to the original example, you won't be able to say: x.func = 789 and destroy the function func--Python will raise an error. Instead you have to type a different syntax to tell Python that yes, I do want to overwrite a function with 789. Dunno, just throwing out ideas here :) Cheers Ray > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Ben Sizer wrote: > Ray wrote: > > Actually Bruno, don't you think that the notion of flexibility in > > Python comes at the expense of "security" is simply due to the fact > > that the syntax of "screw up" is exactly the same as the syntax of "I > > mean it this way and I do want it"? > > > > Perhaps if we use a different syntax when we want to say "I really want > > this", it'll be better (so Python can differentiate between a typo and > > a conscious decision). > > Surely the very nature of a typo is that you don't know at the time of > typing that you've done the wrong thing. Therefore it's impossible to > signal to Python that you don't want what you've actually typed! Exactly! So what I'm saying is that if the syntax of rebinding a method *has* to be different then assignment, maybe it'll catch typos more often. (Of course if you STILL make a typo error while using a different syntax...) > The only way statically-typed languages prevent these errors is > typically by prohibiting the operation entirely. Since Python doesn't > want to do that, you can't effectively prevent this type of error. > Luckily, I find that they don't actually arise in practice, and I've > spent orders of magnitude more time in C++ having to coerce objects > from one type to another to comply with the static typing than I > probably ever will spend debugging Python programs where a typo caused > an error of this type. Yeah, I fully agree. Even Java is heaven compared to C++. > > -- > Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Bruno Desthuilliers wrote: > Ray wrote: > > Bruno Desthuilliers wrote: > > Actually Bruno, don't you think that the notion of flexibility in > > Python comes at the expense of "security" is simply due to the fact > > that the syntax of "screw up" is exactly the same as the syntax of "I > > mean it this way and I do want it"? > > (patient) Doctor, it hurts when I do this... > (doctor) Then don't do it. > > !-) Yeah, I know... but the thing is that it's easy to "do it". Say in C++, you can rebind the method of a class to another function if you want to, you can muck around with the vtable and stuff, but you've gotta do something different than, say, a normal assignment. > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Q: Class Privacy (or lack of)
Ben Sizer wrote: > Ray wrote: > But remember, at no point did they think to make that stuff > deliberately hard so that it would give you safety. It's hard because > the implementation is relatively complex. The flipside of that is > writing function objects in C++, which are an ugly hack to get around > the fact that you can't just assign functions or define them in-place > in that language. Python makes it trivial by comparison. And as another > example, if you use the STL in C++ regularly, you will be familiar with > the hoops you have to jump through in order to use generic functions. > eg. try to call a polymorphic member function on each pointer in an > std::map, while passing a fixed parameter to that function... this sort > of thing is trivial in Python as a side-effect of the fact that the > attributes are looked up at run-time. Yeah, I know what you mean. Perhaps that wasn't a good example, but what I meant was simply that it's different. It doesn't even have to be complicated like in the C++ case, just different, so say the interpreter would be able to tell: "oh, this guy wants to rebind the method", and "oh, that is an error". Right now it can't tell because both look the same. I really did like C++ btw. Now I had to force myself really hard just to get through one chapter off a good book like Effective STL, because all the time something at the back of my head was telling me like that that was basically a book about jumping through hoops :) > > -- > Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Ben Sizer wrote: > Roman Susi wrote: > > Ben Sizer wrote: > > > The problem is that Python is the 2nd best language for everything. ;) > > > > Is it a bad thing? > > I don't know. I suppose that depends on how you define 'bad'! For me, > it is often inconvenient, because I'd prefer to use Python but > generally find that I have to choose something else if I want to do the > best possible for any particular project. Exactly. It's bad because Python is the language you'd love to use at work but can't :) Don't tell me to look for a job in a Python shop, there's none. OTOH, there IS at least one RoR shop that I know of and they're doing pretty well! > In my case, multimedia and game support is patchy, and web development > support is still oriented towards the Java/enterprise user - if CGI > doesn't suffice, that is. In the original poster's case, it's seemingly > because specific database support seems to be lacking. Improving the > libraries in these areas would hopefully increase the diversity of > Python's potential applications rather than diminish it. Yep, (support in Django, specifically, not Python). > > -- > Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a compelling argument to use Django instead of Rails
Ben Sizer wrote: > a minimal layer over the C interface anyway. DirectX support only > appeared this year unless you used IronPython, and it doesn't seem very > popular. IronPython is not released yet, I do hope it will become popular though. It's in RC1 now and should be released soon. I'm really looking forward to it! > > Certainly, some Web frameworks have some element of Java flavouring, > > but there's also considerable diversity at least at certain levels. > > Pretty much every Python web offering revolves around you having your > own server with the luxury of running your own long-running processes > on it. Great for business apps, not much use for the hobbyist or > independent site. There are probably some hosts that will provide > shared hosting for your Django or Turbogears app, but they are not > exactly numerous. The barrier to entry here is much higher than with > PHP or ASP, for example. And even with the full framework approach, the > field has been so fragmented until recently that in terms of community > support, you'd be better off opting for another language. I appreciate > there's a diversity vs. standardisation argument there which may never > be settled, so I accept this is just a personal opinion, but I do think > a critical mass of users is important with any technology. Diversity can be a pain in the ass sometimes. Instead of ending up with something really good you end up with a lot of mediocre stuff (Note: I'm not saying anything about Django or Turbogears here, mind!). Reminds me of the time when I was installing Linux for the first time and finding out that there were tons of text editor included in the distro. I only need vi so that wasn't a problem, but I could imagine someone from a strictly Windows world would wish that there was only one text editor :) > I'm in a similar situation to the original poster; I'd like to use > Turbogears for an app I want to write, but will probably end up doing > it in PHP instead, because I can't get dedicated hardware or a local > host for Turbogears. (Never mind the lack of documentation.) Yep. And my case now is pretty much shot with no Oracle/SQL Server support. > > Otherwise, no amount of complaining will put the > > two technologies together. > > It's a fair point, but on the other hand, saying "if you want it doing, > do it yourself" doesn't objectively improve the status quo. If > something doesn't exist, it doesn't exist, and it's valid to comment > upon that fact. Couldn't agree more. A lot of would-be users, upon being told that, would simply turn to another framework/language/platform/whatever that does provide the feature in question. This is especially true for companies with fast moving projects like the one I'm working for at the moment. Of course, then we can always say, "sur, go ahead, your loss blah blah blah" Well maybe. But how does it help ourselves really? > > -- > Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: first book about python
wesley chun wrote: > if you only know shell scripting, you should still be able to pick up > much of the material in Core Python, esp. if you have done looping > and/or conditionals in the shell language. it is a large book and is > pretty comprehensive though, so if you're looking for a lighter intro, > the books gene's suggested should work -- i would also add Dive into > Python to that group. if possible, try to find sample chapters from > any book you're interested in before buying to make sure that it will > suit your needs. Hi Wesley, which edition of Python will your latest Core Python cover? Will it cover 2.5? Thanks Ray -- http://mail.python.org/mailman/listinfo/python-list
Installed correctly
I've just installed Python 2.4.3 on windows 2000. On the download page it says that if python is installed the version number will be displayed if you enter "python" in a command line window, but that does not happen - it just says "unrecognized command". Rebooting does not help. So is it correctly installed? I installed it under "program files/python" instead of the default location C:\python, since I don-t like to have the root of C: cluttered with stuff, are there any problems with this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
How did you compile the C++ executable? I assume that it is Release mode? Then are the optimization switches enabled? Is it compiled as Native Win32 or Managed application? I suspect that other than what other posters have suggested about your code, the difference in speed is due to the way you build your C++ executable... HTH, Ray Licheng Fang wrote: > Hi, I'm learning STL and I wrote some simple code to compare the > efficiency of python and STL. > > //C++ > #include > #include > #include > #include > #include > using namespace std; > > int main(){ > vector a; > for (long int i=0; i<1 ; ++i){ > a.push_back("What do you know?"); > a.push_back("so long..."); > a.push_back("chicken crosses road"); > a.push_back("fool"); > } > set b(a.begin(), a.end()); > unique_copy(b.begin(), b.end(), ostream_iterator(cout, "\n")); > } > > #python > def f(): > a = [] > for i in range(1): > a.append('What do you know') > a.append('so long...') > a.append('chicken crosses road') > a.append('fool') > b = set(a) > for s in b: > print s > > I was using VC++.net and IDLE, respectively. I had expected C++ to be > way faster. However, while the python code gave the result almost > instantly, the C++ code took several seconds to run! Can somebody > explain this to me? Or is there something wrong with my code? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
Fredrik Lundh wrote: > in the Python example, the four strings in your example are shared, so > you're basically copying 4 pointers to the list. > > in the C++ example, you're creating 4 string objects. > > In which case, Licheng, you should try using the /GF switch. This will tell Microsoft C++ compiler to pool identical string literals together. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
Fredrik Lundh wrote: > Ray wrote: > > >> in the C++ example, you're creating 4 string objects. > > > > In which case, Licheng, you should try using the /GF switch. This will > > tell Microsoft C++ compiler to pool identical string literals together. > > in what way does that change the implementation of C++'s string type ? Ah, yes what was I thinking? The fact that it stores std::string objects escaped my mind somehow. /GF just pools the string literals. Thanks for the correction. > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
Tim N. van der Leeuw wrote: > > In which case, Licheng, you should try using the /GF switch. This will > > tell Microsoft C++ compiler to pool identical string literals together. > > > > > > :) > > The code still creates a new string - instance each time it tries to > append a const char* to the vector ... Yeah, you're right... I've been programming Java too long :) > You should instead create the string-objects ahead of time, outside of > the loop. > > Regards, > > --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
Tim N. van der Leeuw wrote: > Incidentally, I also have a version compiled with VC++ 6 now... (not > yet w/VC++ 7) .. Compiled with release-flags and maximum optimization > for speed, here's the result of VC++ 6: OK, now I'm getting obsessed with this too ;-) I'm using VC++ Express, I didn't care to tweak the optimizations, I merely chose the "Release" configuration for the executable. It's blazing fast, taking only 30+ ms each run. Here's the code: int main(){ DWORD begin = ::GetTickCount(); vector a; string c = "What do you know?"; string d = "so long..."; string e = "chicken crosses road"; string f = "fool"; for (long int i=0; i<1 ; ++i){ a.push_back(c); a.push_back(d); a.push_back(e); a.push_back(f); } set b(a.begin(), a.end()); unique_copy(b.begin(), b.end(), ostream_iterator(cout, "\n")); DWORD end = ::GetTickCount(); cout << "Ends in " << (end - begin) << " ms."; } And here's the result: \TestSTL\release>TestSTL.exe What do you know? chicken crosses road fool so long... Ends in 31 ms. I tried the original version: int main(){ DWORD begin = ::GetTickCount(); vector a; for (long int i=0; i<1 ; ++i){ a.push_back("What do you know?"); a.push_back("so long..."); a.push_back("chicken crosses road"); a.push_back("fool"); } set b(a.begin(), a.end()); unique_copy(b.begin(), b.end(), ostream_iterator(cout, "\n")); DWORD end = ::GetTickCount(); cout << "Ends in " << (end - begin) << " ms."; } And the result is only 50% slower: \TestSTL\release>TestSTL.exe What do you know? chicken crosses road fool so long... Ends in 47 ms. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
[EMAIL PROTECTED] wrote: > That's to say, > python is still much faster? Not really, see my test, in my other post in the same thread. I'm using VC++ Express 2005. If we're comparing with Python 2.5 I think it's just fair that for C++ we're using the latest as well. > I am a c++ newbie but I think c++ should be faster here. Same here, although that said Python's implementation of those data structure must already be as optimal as mortals can do it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and STL efficiency
Mc Osten wrote: > Ray <[EMAIL PROTECTED]> wrote: > > > I'm using VC++ Express, I didn't care to tweak the optimizations, I > > merely chose the "Release" configuration for the executable. It's > > blazing fast, taking only 30+ ms each run. > > Of course it is faster. We are looping 100 times, you just 1. Certainly--I was not comparing 100 against 1. Referring to the OP's statement: "However, while the python code gave the result almost instantly, the C++ code took several seconds to run!" 30ms sounds like a definite improvement over several seconds! I'll try to tweak it later at home and report here. I'll try out the 100 too. Cheers Ray > > -- > blog: http://www.akropolix.net/rik0/blogs | Uccidete i filosofi, > site: http://www.akropolix.net/rik0/ | tenetevi riso e > forum: http://www.akropolix.net/forum/ | bacchette per voi. -- http://mail.python.org/mailman/listinfo/python-list