ANN: Python cgkit v2.0.0alpha8
The eigth alpha release of cgkit2 is available at http://cgkit.sourceforge.net What is it? --- The Python Computer Graphics Kit is an Open Source software package containing a collection of Python modules, plugins and utilities that are meant to be useful for any domain where you have to deal with 3D data of any kind, be it for visualization, creating photorealistic images, Virtual Reality or even games. What's new? --- - New module cri that contains a ctypes-based RenderMan binding - New module mayabinary to parse Maya Binary (.mb) files - Various smaller fixes and additions (see the changelog for a full list) For more information, visit: http://cgkit.sourceforge.net - Matthias - -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: along the lines, hash and obj. id.
On Feb 25, 11:30 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Mon, 25 Feb 2008 17:55:18 -0800 (PST), [EMAIL PROTECTED] declaimed the following in comp.lang.python: I'd like to do this: a= list( range( 5 ) ) assert a== [ 0, 1, 2, 3, 4 ] for i in ref( a ): i.ref*= 2 a= deref( a ) assert a== [ 0, 2, 4, 6, 8 ] [snip] Dictionaries, sets, and the primitives all have ways to do this, in particular, to reset them: a= {} is equivalent to a.clear(), except emEXCEPT THAT/em that other references to it corefer before, and in the former, don't after. No, ={} and .clear() are not equivalent. In the case of class instances, class Instance(): pass ... obj= Instance() obj.a= {} d= obj.a obj.a[0]= object() d[0] object object at 0x00A37468 e= obj obj.a= {} d {0: object object at 0x00A37468} e.a {} It works to keep a reference to the object, then access the member again. If your only reference to the object is the member itself, obj.a= {} breaks d, but obj.a.clear() keeps it alive. In the case of immutables, there is no such .clear() equivalent. If obj.a is a tuple, string, or integer (*miss any?), d is always broken when obj.a is changed. The generic solution involves a second level of indirection: tuple* d= obj.a. I can't land a clean solution to it though. -- http://mail.python.org/mailman/listinfo/python-list
executing a python program by specifying only its name in terminal or command line
hi, i wanna run a python program by specifying only its name ex prog with the arguments in the terminal or command line instead of specifying python prog in the terminal to run the program not even specifying the it with .py extension .. for example i want to run the python program named prog by sepcifying $prog -arguments instead of $python prog -arguments or $prog.py -arguments can anyone tell me how to do it -- http://mail.python.org/mailman/listinfo/python-list
Problems Generating HTML With pydoc
Hi, I'm trying to generate HTML docs for a Python package (directory) currently containing an empty __init__.py and a Module.py file with some classes and docstrings. I tried using the command F:\path\to\project\pydoc.py -w myPackage at the Vista command prompt, and I get wrote myPackage.html as output, but when I open the .html in Firefox, I cannot navigate to the doc page of Module although it is displayed as a link on the main page. I get a File Not Found message in the browser for doing so. If I'm at C:\ in the command prompt and try pydoc.py -w F:\path\to\project\myPackage I get no Python documentation found for 'Module'. pydoc -g seems to display the package's doc .htmls with no problems. I can't seem to figure what's wrong here, so any help is appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is crawling the stack bad? Why?
Russell Warren wrote: Thanks Ian... I didn't know about threading.local before but have been experimenting and it will likely come in quite handy in the future. For this particular case it does basically seem like a replacement for the threadID indexed dictionary, though. ie: I'll still need to set up the RpcContainer, custom request handler, and custom server in order to get the info handed around properly. I will likely go with this approach since it lets me customize other aspects at the same time, but for client IP determination alone I still half think that the stack crawler is cleaner. No convincing argument yet on why crawling the stack is considered bad? I kind of hoped to come out of this with a convincing argument that would stick with me... OK, if you crawl the stack I will seek you out and hit you with a big stick. Does that affect your decision-making? Seriously, crawling the stack introduces the potential for disaster in your program, since there is no guarantee that the calling code will provide the same environment i future released. So at best you tie your solution to a particular version of a particular implementation of Python. You might as well not bother passing arguments to functions at all, since the functions could always crawl the stack for the arguments they need.A major problem with this is that it constrains the caller to use particular names for particular function arguments. What happens if two different functions need arguments of the same name? Seriously, forget this craziness. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP Developer highly interested in Python (web development) with some open questions...
about the encryption: is ur product more valuable than the linux kernel? -- http://mail.python.org/mailman/listinfo/python-list
Re: executing a python program by specifying only its name in terminal or command line
bharath venkatesh wrote: hi, i wanna run a python program by specifying only its name ex prog with the arguments in the terminal or command line instead of specifying python prog in the terminal to run the program not even specifying the it with .py extension .. for example i want to run the python program named prog by sepcifying $prog -arguments instead of $python prog -arguments or $prog.py -arguments can anyone tell me how to do it reseach pathext for Windows. For Unix-like systems use the shebang (#!) line, and don't put a .py at the end of the filename. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: executing a python program by specifying only its name in terminal or command line
Steve Holden wrote: bharath venkatesh wrote: hi, i wanna run a python program by specifying only its name ex prog with the arguments in the terminal or command line instead of specifying python prog in the terminal to run the program not even specifying the it with .py extension .. for example i want to run the python program named prog by sepcifying $prog -arguments instead of $python prog -arguments or $prog.py -arguments can anyone tell me how to do it reseach pathext for Windows. For Unix-like systems use the shebang (#!) line, and don't put a .py at the end of the filename. Besides being ugly and a bit unsettling for the user, the final .py won't prevent the execution of your program. Though the file must have the executable attribute set, so you have to chmod +x it. Cheers, RB -- http://mail.python.org/mailman/listinfo/python-list
Re: __getattribute__ meta class?
On Feb 26, 3:43 am, bambam [EMAIL PROTECTED] wrote: I have a class containing a series of classes like this: class Th(Externaldevice): class _Communicate(commandset2.CommandSet_Communicate): def __getattribute__(self,attrname): attr = commandset2.CommandSet_Communicate.__getattribute__(self,attrname) if __call__ in dir(attr): return functools.partial(Th._wrapper_function, self.parent, attr) else: return attr class _System(commandset2.CommandSet_System): def __getattribute__(self,attrname): attr = commandset2.System_Communicate.__getattribute__(self,attrname) if __call__ in dir(attr): return functools.partial(Th._wrapper_function, self.parent, attr) else: return attr That is, a a wrapper function is applied to a bunch of methods in a bunch of classes. The class declarations are simple, but even so, repetitive. Can anyone suggest a more compact representation for the class declarations? Also, because the parent class name is given explicitly in the class declarations, I can't over-ride the _wrapper_function in a child class, except by over-riding each of the class declarations. Is there a way to reference the _wrapper_function just to the containing class? Steve No real idea what you're doing, but surely altering the class at creation-time, rather than on each attribute call, would be a better approach? Here's one idea (sorry if misunderstood your problem): [code python] import inspect def wrapped(func): def wrapper(self, arg): return func(self, self.parent + ': ' + arg) return wrapper class Meta(type): def __new__(cls, name, bases, attrs): for key, val in attrs.iteritems(): if inspect.isfunction(val) and not key.startswith('_'): attrs[key] = wrapped(val) return super(Meta, cls).__new__(cls, name, bases, attrs) class Base(object): __metaclass__ = Meta parent = 'root' def foo(self, s): return s.upper() def bar(self, s): return s.lower() b = Base() print b.foo('apple') print b.bar('PEAR') print b.parent = 'firstchild' print b.foo('apple') print b.bar('PEAR' [/code] ROOT: APPLE root: pear FIRSTCHILD: APPLE firstchild: pear Gerard -- http://mail.python.org/mailman/listinfo/python-list
Re: buliding log files
diljeet kaur wrote: hi im working on pyqt environment i want to know how to take log or how to build log files of the output Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping Please check module logging. http://docs.python.org/lib/module-logging.html It provides facility of system log of UN*X like systems. -- http://mail.python.org/mailman/listinfo/python-list
how to measure memory usage on Mac OSX ?
hi all, i want to measure memory usage of my python process on Mac OSX. i tired resource module, but it doesn't work on OSX. how can i get it ? thnx. -- masayuki takagi -- http://mail.python.org/mailman/listinfo/python-list
RE: Web site for comparing languages syntax
Sebastian Bassi wrote: I know there is one site with wikimedia software installed, that is made for comparing the syntax of several computer languages (Python included). But don't remember the URL. Anyone knows this site? http://99-bottles-of-beer.net/ is one such site, though I don't know about wikimedia. Mel. Maybe http://www.rosettacode.org ? That's a wiki. Cheers, Drea -- http://mail.python.org/mailman/listinfo/python-list
Re: how to measure memory usage on Mac OSX ?
On Feb 26, 3:43 am, masayuki.takagi [EMAIL PROTECTED] wrote: hi all, i want to measure memory usage of my python process on Mac OSX. i tired resource module, but it doesn't work on OSX. how can i get it ? thnx. -- masayuki takagi #mac osx 10.4.7 import resource print resource.getrusage(resource.RUSAGE_SELF) --output:-- (0.009417, 0.020122, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0) -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about PyPI and 'easy_install'
On Feb 24, 10:38 pm, makoto kuwata [EMAIL PROTECTED] wrote: Hi, I have a trouble around PyPI and easy_install. I have developed OSS (Tenjin) and registered it to PyPI.http://pypi.python.org/pypi/Tenjin/0.6.1 But I can't install it by 'easy_install' command. Hi! I`m think this patch is helpful for you ---BEGIN PATCH--- --- setup.py.orig 2007-10-23 03:54:18.0 +0400 +++ setup.py2008-02-26 14:08:44.66000 +0300 @@ -6,12 +6,10 @@ import sys, re -if len(sys.argv) 1 and sys.argv[1] == 'egg_info': -from ez_setup import use_setuptools -use_setuptools() -from distutils.core import setup +from ez_setup import use_setuptools +from setuptools import setup -name = 'pyTenjin' +name = 'Tenjin' version = '0.6.1' author = 'makoto kuwata' email= '[EMAIL PROTECTED]' ---END PATCH--- PS Thank you for excellent job. -- Vsevolod Balashov http://vsevolod.balashov.name -- http://mail.python.org/mailman/listinfo/python-list
Re: network programming: how does s.accept() work?
On Feb 25, 10:00 pm, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], 7stud [EMAIL PROTECTED] wrote: But your claim that the server doesn't change its port flies in the face of every description I've read about TCP connections and accept(). The articles and books I've read all claim that the server port 5053 is a 'listening' port only. Thereafter, when a client sends a request for a connection to the listening port, the accept() call on the server creates a new socket for communication between the client and server, and then the server goes back to listening on the original socket. You're confusing port and socket. A port is an external thing. It exists in the minds and hearts of packets on the network, and in the RFCs which define the TCP protocol (UDP too, but let's keep this simple). A socket is an internal thing. It is a programming abstraction. Sockets can exist that aren't bound to ports, and several different sockets can be bound to the same port. Just like there can be multiple file descriptors which are connected to a given file on disk. The TCP protocol defines a state machine which determines what packets should be sent in response when certain kinds of packets get received. The protocol doesn't say how this state machine should be implemented (or even demands that it be implemented at all). It only requires that a TCP host behave in a way which the state machine defines. In reality, whatever operating system you're running on almost certainly implements in the kernel a state machine as described by TCP. That state machine has two sides. On the outside is the network interface, which receives and transmits packets. On the inside is the socket interface to user-mode applications. The socket is just the API by which a user program interacts with the kernel to get it to do the desired things on the network interface(s). Now, what the articles and books say is that there is a listening SOCKET. And when you accept a connection on that socket (i.e. a TCP three-way handshake is consummated on the network), the way the socket API deals with that is to generate a NEW socket (via the accept system call). There really isn't any physical object that either socket represents. They're both just programming abstractions. Does that help? If two sockets are bound to the same host and port on the server, how does data sent by the client get routed? Can both sockets recv() the data? -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Menu Item Activation
On Fri, 22 Feb 2008 13:30:06 +0100, [EMAIL PROTECTED] wrote: [snip] Sub problems: how to change state of menu item? how to detect changes in Text widget? If you have a reasonably recent tcl/tk version (= 8.4), you should have a edit_modified() method on your Text telling you if it has been modified since you last called edit_modified(False). HTH -- python -c print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-']) -- http://mail.python.org/mailman/listinfo/python-list
download students tutorials,ebooks,softwares here for Free!!!!
download students tutorials,ebooks,softwares here for Free Download Softwares Ebooks Students tutorials Games Ring tones Wallpapers and Lots of fun everything for FREE only at www.studentshangout.com -- http://mail.python.org/mailman/listinfo/python-list
Re: network programming: how does s.accept() work?
On Feb 25, 10:08 pm, Steve Holden [EMAIL PROTECTED] wrote: There can be many TCP connections to a server all using the same endpoint. Take a look at the traffic coming out of any busy web server: everything that comes out of the same server comes from port 80. That doesn't stop it listening for more connections on port 80. --- When you surf the Web, say to http://www.google.com, your Web browser is a client. The program you contact at Google is a server. When a server is run, it sets up business at a certain port, say 80 in the Web case. It then waits for clients to contact it. When a client does so, the server will usually assign a new port, say 56399, specifically for communication with that client, and then resume watching port 80 for new requests. --- http://heather.cs.ucdavis.edu/~matloff/Python/PyNet.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: how to measure memory usage on Mac OSX ?
On 2月26日, 午後8:02, 7stud [EMAIL PROTECTED] wrote: On Feb 26, 3:43 am, masayuki.takagi [EMAIL PROTECTED] wrote: hi all, i want to measure memory usage of my python process on Mac OSX. i tired resource module, but it doesn't work on OSX. how can i get it ? thnx. -- masayuki takagi #mac osx 10.4.7 import resource print resource.getrusage(resource.RUSAGE_SELF) --output:-- (0.009417, 0.020122, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0) hum... for example below, which elment of the output means the memory usage? the list i should use about 16MB. #mac osx 10.4.11 import resource i = range( 0, 100) print resource.getrusage(resource.RUSAGE_SELF) --output:-- (0.0425829996, 0.0645619994, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 103, 0) -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 25, 5:41 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sun, 24 Feb 2008 10:09:37 -0800, Lie wrote: On Feb 25, 12:46 am, Steve Holden [EMAIL PROTECTED] wrote: Lie wrote: On Feb 18, 1:25 pm, Carl Banks [EMAIL PROTECTED] wrote: On Feb 17, 1:45 pm, Lie [EMAIL PROTECTED] wrote: Any iteration with repeated divisions and additions can thus run the denominators up. This sort of calculation is pretty common (examples: compound interest, numerical integration). Wrong. Addition and subtraction would only grow the denominator up to a certain limit I said repeated additions and divisions. Repeated Addition and subtraction can't make fractions grow infinitely, only multiplication and division could. On what basis is this claim made? (n1/d1) + (n2/d2) = ((n1*d2) + (n2*d1)) / (d1*d2) If d1 and d2 are mutually prime (have no common factors) then it is impossible to reduce the resulting fraction further in the general case (where n1 = n2 = 1, for example). Anyways, addition and subtraction can increase the denominator a lot if for some reason you are inputing numbers with many different denominators. Up to a certain limit. After you reached the limit, the fraction would always be simplifyable. Where does this magical limit appear from? If the input numerator and denominator have a defined limit, repeated addition and subtraction to another fraction will also have a defined limit. Well I suppose is you limit the input denominators to n then you have a guarantee that the output denominators won't exceed n!, but that seems like a pretty poor guarantee to me. Am I wrong here? You seem to be putting out unsupportable assertions. Please justify them or stop making them. Well, I do a test on my own fraction class. I found out that if we set a limit to the numerators and denominators, the resulting output fraction would have limit too. I can't grow my fraction any more than this limit no matter how many iteration I do on them. I do the test is by something like this (I don't have the source code with me right now, it's quite long if it includes the fraction class, but I think you could use any fraction class that automatically simplify itself, might post the real code some time later): while True: a = randomly do (a + b) or (a - b) b = random fraction between [0-100]/[0-100] print a And this limit is much lower than n!. I think it's sum(primes(n)), but I've got no proof for this one yet. *jaw drops* Please stop trying to help convince people that rational classes are safe to use. That's the sort of help that we don't need. For the record, it is a perfectly good strategy to *artificially* limit the denominator of fractions to some maximum value. (That's more or less the equivalent of setting your floating point values to a maximum number of decimal places.) But without that artificial limit, repeated addition of fractions risks having the denominator increase without limit. -- Steven No, it is a real limit. This is what I'm talking about. If the input data has a limit, the output data has a real limit, not a defined- limit. If the input data's denominator is unbounded, the output fraction's denominator is also unbounded In a repeated addition and subtraction with input data that have limits -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 25, 5:41 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sun, 24 Feb 2008 10:09:37 -0800, Lie wrote: On Feb 25, 12:46 am, Steve Holden [EMAIL PROTECTED] wrote: Lie wrote: On Feb 18, 1:25 pm, Carl Banks [EMAIL PROTECTED] wrote: On Feb 17, 1:45 pm, Lie [EMAIL PROTECTED] wrote: Any iteration with repeated divisions and additions can thus run the denominators up. This sort of calculation is pretty common (examples: compound interest, numerical integration). Wrong. Addition and subtraction would only grow the denominator up to a certain limit I said repeated additions and divisions. Repeated Addition and subtraction can't make fractions grow infinitely, only multiplication and division could. On what basis is this claim made? (n1/d1) + (n2/d2) = ((n1*d2) + (n2*d1)) / (d1*d2) If d1 and d2 are mutually prime (have no common factors) then it is impossible to reduce the resulting fraction further in the general case (where n1 = n2 = 1, for example). Anyways, addition and subtraction can increase the denominator a lot if for some reason you are inputing numbers with many different denominators. Up to a certain limit. After you reached the limit, the fraction would always be simplifyable. Where does this magical limit appear from? If the input numerator and denominator have a defined limit, repeated addition and subtraction to another fraction will also have a defined limit. Well I suppose is you limit the input denominators to n then you have a guarantee that the output denominators won't exceed n!, but that seems like a pretty poor guarantee to me. Am I wrong here? You seem to be putting out unsupportable assertions. Please justify them or stop making them. Well, I do a test on my own fraction class. I found out that if we set a limit to the numerators and denominators, the resulting output fraction would have limit too. I can't grow my fraction any more than this limit no matter how many iteration I do on them. I do the test is by something like this (I don't have the source code with me right now, it's quite long if it includes the fraction class, but I think you could use any fraction class that automatically simplify itself, might post the real code some time later): while True: a = randomly do (a + b) or (a - b) b = random fraction between [0-100]/[0-100] print a And this limit is much lower than n!. I think it's sum(primes(n)), but I've got no proof for this one yet. *jaw drops* Please stop trying to help convince people that rational classes are safe to use. That's the sort of help that we don't need. For the record, it is a perfectly good strategy to *artificially* limit the denominator of fractions to some maximum value. (That's more or less the equivalent of setting your floating point values to a maximum number of decimal places.) But without that artificial limit, repeated addition of fractions risks having the denominator increase without limit. -- Steven No, it is a real limit. This is what I'm talking about. If the input data has a limit, the output data has a real limit, not a user-defined- limit (FOR ADDITION AND SUBTRACTION). If the input data's denominator is unbounded, the output fraction's denominator is also unbounded -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
On 25 Feb, 19:44, Nicola Musatti [EMAIL PROTECTED] wrote: Witness the kind of libraries/framework that used to and still come with some commercial C+ + implementation, and even some free/open source ones; Boost, ACE and wxWidgets are the first that come to mind. Oh, that's another good reason for C++'s decline: the fragmentation of the development community through a plethora of proprietary products, each one with its advocates and a relatively small common ground (admittedly growing over the years thanks to Free Software and standards) between them all. When Java came along, even though the best GUI offering was AWT, it was better than nothing and it was one of the batteries included. Although Sun's Java was also proprietary, it was easier for people to obtain and redistribute, often without per- seat or per-unit licensing costs. Of course, C++ isn't the only language with this problem. The Lisp scene has also been plagued by an unnecessary deference to commercial interests, which means that the hottest topic on comp.lang.lisp right now is probably Paul Graham's much-anticipated but arguably disappointing Lisp successor, Arc, amongst the usual in-fighting and parade-dampening. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 25, 11:34 am, casevh [EMAIL PROTECTED] wrote: On Feb 24, 7:56 pm, Mensanator [EMAIL PROTECTED] wrote: But that doesn't mean they become less manageable than other unlimited precision usages. Did you see my example of the polynomial finder using Newton's Forward Differences Method? The denominator's certainly don't settle out, neither do they become unmanageable. And that's general mathematics. Since you are expecting to work with unlimited (or at least, very high) precision, then the behavior of rationals is not a surprise. But a naive user may be surprised when the running time for a calculation varies greatly based on the values of the numbers. In contrast, the running time for standard binary floating point operations are fairly constant. If the point was as SDA suggested, where things like 16/16 are possible, I see that point. As gmpy demonstrates thouigh, such concerns are moot as that doesn't happen. There's no reason to suppose a Python native rational type would be implemented stupidly, is there? In the current version of GMP, the running time for the calculation of the greatest common divisor is O(n^2). If you include reduction to lowest terms, the running time for a rational add is now O(n^2) instead of O(n) for a high-precision floating point addition or O(1) for a standard floating point addition. If you need an exact rational answer, then the change in running time is fine. But you can't just use rationals and expect a constant running time. There are trade-offs between IEEE-754 binary, Decimal, and Rational arithmetic. They all have there appropriate problem domains. I very agree with this statement. Fractionals do have its weakness, and so do Decimal and Hardware Floating Point. And they have their own usage, their own scenarios where they're appropriate. If you needed full-speed calculation, it is clear that floating point wins all over the place, OTOH, if you need to manage your precision carefully Fractional and Decimal both have their own plus and mins -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib slow on Leopard
On 24 Feb, 22:14, Stefan Behnel [EMAIL PROTECTED] wrote: It likely tries to load the DTD in the background, which requires network access. http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic This is principally concerned with the standard library XML modules, not urllib/urllib2 specifically. See the bug report in the tracker: http://bugs.python.org/issue2124 I'd imagine that it's more likely to be a DNS problem than anything else. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 25, 1:58 pm, Carl Banks [EMAIL PROTECTED] wrote: What part of repeated additions and divisions don't you understand? What part of additions and subtractions don't you understand? I'm invalidating half of your statement, the division part, but validating another half, the additions part and adding some statements on my own. Try doing numerical integration sometime with rationals, and tell me how that works out. Try calculating compound interest and storing results for 1000 customers every month, and compare the size of your database before and after. Since when have I said that fractional is appropriate for calculating compound interests. Fractionals works best in scenarios where the calculations are mostly addition and subtraction, not percentage division and multiplications like in compounds. -- http://mail.python.org/mailman/listinfo/python-list
Re: network programming: how does s.accept() work?
7stud [EMAIL PROTECTED] writes: When you surf the Web, say to http://www.google.com, your Web browser is a client. The program you contact at Google is a server. When a server is run, it sets up business at a certain port, say 80 in the Web case. It then waits for clients to contact it. When a client does so, the server will usually assign a new port, say 56399, specifically for communication with that client, and then resume watching port 80 for new requests. Actually the client is the one that allocates a new port. All connections to a server remain on the same port, the one it listens on: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('127.0.0.1', 1)) s.listen(1) s.accept() # now, connect to port 1 from elsewhere (socket._socketobject object at 0xb7adf6f4, ('127.0.0.1', 36345)) s1 = _[0] s1 socket._socketobject object at 0xb7adf6f4 s1.getsockname() ('127.0.0.1', 1)# note the same port, not a different one -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 25, 11:18 pm, Carl Banks [EMAIL PROTECTED] wrote: On Feb 25, 9:41 am, Mensanator [EMAIL PROTECTED] wrote: On Feb 25, 12:58�am, Carl Banks [EMAIL PROTECTED] wrote: On Feb 24, 10:56 pm, Mensanator [EMAIL PROTECTED] wrote: But that doesn't mean they become less manageable than other unlimited precision usages. Did you see my example of the polynomial finder using Newton's Forward Differences Method? The denominator's certainly don't settle out, neither do they become unmanageable. And that's general mathematics. No, that's a specific algorithm. �That some random algorithm doesn't blow up the denominators to the point of disk thrashing doesn't mean they won't generally. Try doing numerical integration sometime with rationals, and tell me how that works out. �Try calculating compound interest and storing results for 1000 customers every month, and compare the size of your database before and after. Nobody said rationals were the appropriate solution to _every_ problem, just as floats and integers aren't the appropriate solution to _every_ problem. I was answering your claim that rationals are appropriate for general mathematical uses. Your argument is that I should be forced to use an inappropriate type when rationals _are_ the appropriate solution. I don't know where you got that idea. My argument is that rationals aren't suitable for ordinary uses because they have poor performance and can easily blow up in your face, trash your disk, and crash your program (your whole system if you're on Windows). In other words, 3/4 in Python rightly yields a float and not a rational. And it should, as floats have native CPU support, 3/4 (with __future__ import) should yields 0.75. Fractional is safe for many usage scenario, but obviously it is not appropriate for all cases, just like floats and decimals. I think this mailing list already have enough absolutist, who can go to either side of the camp but doesn't want to be in the middle. In real world, money is probably best described by float or Decimals, as non-computer money calculations are used to do rounding at 1 cents. But the interest rate is probably better described by rationals. In trigonometry, _perhaps_ the world would be better if trigonometric functions returns rational. Perhaps it is better to use rational for pi (ratio of diameter and circumferrence) and phi (golden ratio). But I think angles is better described as floats nevertheless. J Cliff Dyer: I'm in the camp that believes that 3/4 does indeed yield the integer 0, but should be spelled 3//4 when that is the intention. That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. That means most people. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. -- http://mail.python.org/mailman/listinfo/python-list
low price laptop
Compaq Presario Intel Laptop Model No: 1980Tu :-# Intel Pentium Processor Dual-core Processor T2080 1.73 GHz # Intel 965 GM chipset # 512MB DDR-2 RAM # 80 GB SATA Hard disk # 8X Super Multi double layer drive (8 # 5 GB) more cheapest laptops available Please visit -http://www.homeshop18.com/shop/u/y/p-Computers-Q-and-Q- Peripherals-S-Laptops-S-Compaq-Q-Presario-Q-Intel-Q-Laptop-Q-Model-Q- No:-Q-1980Tu/Home_Online-pI_21580-clI_2-cI_920-pCI_909- -- http://mail.python.org/mailman/listinfo/python-list
Re: network programming: how does s.accept() work?
7stud wrote: If two sockets are bound to the same host and port on the server, how does data sent by the client get routed? Can both sockets recv() the data? I have learned a lot of stuff I did not know before from this thread, so I think I can answer that. There must be a layer of software that listens at the port. When it receives a packet, it can tell which client sent the packet (host and port number). It uses that to look up which socket is handling that particular connection, and passes it as input to that socket. Therefore each socket only receives its own input, and is not aware of anything received for any other connection. Not a technical explanation, but I think it describes what happens. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: network programming: how does s.accept() work?
7stud wrote: On Feb 25, 10:00 pm, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], 7stud [EMAIL PROTECTED] wrote: But your claim that the server doesn't change its port flies in the face of every description I've read about TCP connections and accept(). The articles and books I've read all claim that the server port 5053 is a 'listening' port only. Thereafter, when a client sends a request for a connection to the listening port, the accept() call on the server creates a new socket for communication between the client and server, and then the server goes back to listening on the original socket. You're confusing port and socket. A port is an external thing. It exists in the minds and hearts of packets on the network, and in the RFCs which define the TCP protocol (UDP too, but let's keep this simple). A socket is an internal thing. It is a programming abstraction. Sockets can exist that aren't bound to ports, and several different sockets can be bound to the same port. Just like there can be multiple file descriptors which are connected to a given file on disk. The TCP protocol defines a state machine which determines what packets should be sent in response when certain kinds of packets get received. The protocol doesn't say how this state machine should be implemented (or even demands that it be implemented at all). It only requires that a TCP host behave in a way which the state machine defines. In reality, whatever operating system you're running on almost certainly implements in the kernel a state machine as described by TCP. That state machine has two sides. On the outside is the network interface, which receives and transmits packets. On the inside is the socket interface to user-mode applications. The socket is just the API by which a user program interacts with the kernel to get it to do the desired things on the network interface(s). Now, what the articles and books say is that there is a listening SOCKET. And when you accept a connection on that socket (i.e. a TCP three-way handshake is consummated on the network), the way the socket API deals with that is to generate a NEW socket (via the accept system call). There really isn't any physical object that either socket represents. They're both just programming abstractions. Does that help? If two sockets are bound to the same host and port on the server, how does data sent by the client get routed? Can both sockets recv() the data? Routing traditionally means passing hop-by-hop from one IP address to another, but I'll assume that you are actually concerned about delivery of packets from two separate clients - lets call them (addr1, p1) and (addrs, p2) - to two server processes both using the same endpoint address which we will call (addrS, pS). In all cases the first memebr of the tuple is an IP address and the second is a port number. Note that the condition I mentioned earlier (with the caveat added by Roy) ensures that while addr1 and addr2 might be the same, or p1 and p2 might be the same, they can *never* be the same together: if the TCP layer at addr1 allocates port p1 to one client process, when another client process asks for an ephemeral port TCP guarantees that it wonn't be given p1, because that is already logged as in use by another process. So, in Python terms that represents a guarantee that (addr1, p1) != (addr2, p2) and consequently (addr1, p1, addrS, pS) != (addr2, p2, addrS, pS) Now, when a packet arrives at the server system addressed to the server endpoint, the TCP layer (whcih maintains a record of *both* endpoints for each connection) simply looks at the incoming address and port number to determine which process, of the potentially many using (addrS, pS), it needs to be delivered to. If this isn't enough then you should really take this problem to a TCP/IP group. It's pretty basic, and until you understand it you will never make sense of TCP/IP client/server communications. http://holdenweb.com/linuxworld/NetProg.pdf might help, but I don't guarantee it. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
On Feb 26, 12:58 pm, Paul Boddie [EMAIL PROTECTED] wrote: On 25 Feb, 19:44, Nicola Musatti [EMAIL PROTECTED] wrote: Witness the kind of libraries/framework that used to and still come with some commercial C+ + implementation, and even some free/open source ones; Boost, ACE and wxWidgets are the first that come to mind. Oh, that's another good reason for C++'s decline: the fragmentation of the development community through a plethora of proprietary products, each one with its advocates and a relatively small common ground (admittedly growing over the years thanks to Free Software and standards) between them all. When Java came along, even though the best GUI offering was AWT, it was better than nothing and it was one of the batteries included. Although Sun's Java was also proprietary, it was easier for people to obtain and redistribute, often without per- seat or per-unit licensing costs. C++ was born and acquired its popularity in a period when freely available software wasn't as common as it is today and corporation didn't see any kind of advantage in investing in it. By the way, funny you should mention AWT, given how it was soon superceded by Swing, which in turn competes against SWT. And given the state of the Python web framekork scene if I were you I'd start looking for another language ;-) Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: is there enough information?
Create a class which will ensure turn-taking of events, using a get method with and integer index, by waiting for the prior index to complete before starting the next. from thread import start_new_thread as launch from threading import Lock import time from functools import partial class WithObj: def __init__( self, enter, exit ): self.__enter__, self.__exit__= enter, exit class Step: def __init__( self ): self._index= 0 self._locks= {} self._opened= False self._oplock= Lock() def __getitem__( self, index ): with self._oplock: lock= self._locks.get( index, None ) if None is lock: lock= self._locks[ index ]= Lock() if index!= self._index: assert lock.acquire( False ) return WithObj( partial( self.ienter, index ), partial( self.iexit, index ) ) def ienter( self, index ): with self._oplock: if self._opened: return self lock= self._locks.get( index ) assert lock.acquire() with self._oplock: return self def iexit( self, index, *a ): with self._oplock: self._index+= 1 lock= self._locks.get( self._index ) if None is not lock: lock.acquire( False ) lock.release() def complete( self ): with self._oplock: self._index= 0 lock= self._locks.get( 0 ) if None is not lock: lock.acquire( False ) lock.release() def open( self ): with self._oplock: self._opened= True for lock in self._locks.values(): lock.acquire( False ) lock.release() class CustThread: count= 0 def __init__( self ): CustThread.count+= 1 self.id= CustThread.count self.step= Step() self.cont= True self.cmd= None self.ret= None def __repr__( self ): return 'CustThread %i'% self.id def thloop( thd ): while thd.cont: with thd.step[1]: if not thd.cont: break print( 'step 1', end= ' ' ) thd.ret= thd.cmd+ 1 with thd.step[3]: print( 'step 3' ) thd.ret= None thd.step.complete() def op100( thd ): with thd.step[0]: print( 'step 0', end= ' ' ) thd.cmd= 100 with thd.step[2]: print( 'step 2', end= ' ' ) ret1= thd.ret assert ret1== 101 def main( func ): if __name__== '__main__': func() @main def fmain(): class Case: def __init__( self ): self.th1= CustThread() while 1: print( '===' ) class Case1: case= Case() launch( thloop, ( case.th1, ) ) for _ in range( 10 ): case.th1.cmd= None case.th1.ret= None op100( case.th1 ) case.th1.cont= False case.th1.step.open() print( 'case complete' ) while 1: time.sleep( 1 ) ''' Kind of trivial, interesting technique, and general. Enter with thd.step[n]: to indicate step n in a process. with thd.step[m] for m! = n will block until it exits, and step[n+1] gets the go, or step[0] with step.complete(). step.open() grants every step, such as in the case of completion; set termination conditions prior to its call, and check them in any sensitive loops. One way to replace magic sequence numbers with meaning is the Step1 Step2 Step3 style used in namedtuple, but they're only shown bare here. Sequence numbers are looked up in a hash; special applications can use an array, and account for the possibility that with step[10]: may be called before even step[0]. 0- and 1-based options are customizable. Sequence length may be known at creation time; if so, the Step instance can be initialized with it; contraindicating cases may include with step[n] ... with step[n+2], that don't mean the right thing in a separate instance. __getitem__ returns a WithObj, calling __enter__ and __exit__ on which routes to the Step instance, paired with the specified index. You could probably cache those. The example is a 1-SetOp, 2-DoOp, 1-GetReturn triplet. acquire( False ) / release() pairs release a thread, whether it is acquired already or not. _oplock synchronizes _index and lock lookup operations across an instance. Kind of cool. ''' -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
On Feb 24, 5:25 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Jeff Schwab [EMAIL PROTECTED] writes: there's actually a published book specifically about C++ pitfalls. Mercy, a whole book? http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?EAN=97802... Read the title. This is about C Traps and Pitfalls. Although it shows its age, it's still worth reading. Unfortunately from its price you'd think it was handwritten. Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
On Feb 25, 3:59 pm, Sebastian Kaliszewski [EMAIL PROTECTED] wrote: [...] 1. Your generic resource-management infrastructure is not generic to begin with! It does not work for mutually dependant resources. How so? Could you give a concrete example? 2. Your generic infrastructure increases burden on the programmer everywhere any resorce (including trivial one like memory) is used, while GC kills that burden in 95% of the cases. C++ish approach puts the notion of ownership everywhere - both in 95% of cases where it's useless and in remaining 5% where it's actually needed. That's not reduced effort by any means. Like others around here you seem not to be aware of the existence of the standard C++ library. That and local variables usually deal with well over half the cases of memory management in any non trivial application, and boost::shared_ptr can deal with a good portion of the rest. 3. You can't handle clean-up errors in reasonable way in C++ish approach, so anything more complex should not by handled that way anyway. So it's okay for a Python mechanism to deal with 95% of the cases, but not for a C++ one? At least in C++ resource management only becomes more complicated if you need more control. Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
On Feb 26, 6:58 am, Paul Boddie [EMAIL PROTECTED] wrote: The Lisp scene has also been plagued by an unnecessary deference to commercial interests, which means that the hottest topic on comp.lang.lisp right now is probably Paul Graham's much-anticipated but arguably disappointing Lisp successor, Arc, amongst the usual in-fighting and parade-dampening. It looks like his main contribution was to get rid of superfluous parentheses. Which, admittedly, is no small thing for Lisp. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Indentation and optional delimiters
This is the best praise of semantic indentation I have read so far, by Chris Okasaki: http://okasaki.blogspot.com/2008/02/in-praise-of-mandatory-indentation-for.html A quotation: Imagine my surprise when I started teaching this language and found the students picking it up faster than any language I had ever taught before. As fond as I am of the language, I'm certainly under no illusions that it's the ultimate teaching language. After carefully watching the kinds of mistakes the students were and were not making, I gradually realized that the mandatory indentation was the key to why they were doing better. I have appreciated that article, and I have personally seen how fast students learn Python basics compared to other languages, but I think that it's way more than just indentation that makes the Python language so quick to learn [see appendix]. I used to like indentation-based block delimiting years before finding Python, and this article tells me that it may be a good thing for other languages too, despite some disadvantages (but it's little probable such languages will change, like the D language). Some people have actually tried it in other languages: http://people.csail.mit.edu/mikelin/ocaml+twt/ So I may try to write something similar for another language too. One of the most common complaints about it is this written by James on that blog: I prefer explicit delimiters because otherwise the line wrapping of code by various email programs, web mail, mailing list digesters, newsgroup readers, etc., often results in code that no longer works. A possible solution to this problem is optional delimiters. What's the path of less resistance to implement such optional delimiters? Is to use comments. For example: #} or #: or something similar. If you use such pairs of symbols in a systematic way, you have cheap optional delimiters, for example: def insort_right(a, x, lo=0, hi=None): if hi is None: hi = len(a) #} while lo hi: mid = (lo + hi) // 2 if x a[mid]: hi = mid #} else: lo = mid+1 #} #} a.insert(lo, x) #} It looks a bit ugly, but a script is able to take such code even flattened: def insort_right(a, x, lo=0, hi=None): if hi is None: hi = len(a) #} while lo hi: mid = (lo + hi) // 2 if x a[mid]: hi = mid #} else: lo = mid+1 #} #} a.insert(lo, x) #} And build the original Python code (it's possible to do the opposite too, but it requires a bit more complex script). Such #} may even become a standard (a convention. Not something enforced by the compiler. What I'd like to see the Python compiler enforce is to raise a syntax error if a module mixes tabs and spaces) for Python, so then it's easy to find the re-indenter script when you find flattened code in some email/web page, etc. --- Appendix: I believe there can exist languages even faster than Python to learn by novices. Python 3.0 makes Python even more tidy, but Python itself isn't the most semantically clear language possible. I have seen that the widespread reference semantics in Python is one of the things newbies need more time to learn and understand. So it can be invented a language (that may be slower than Python, but many tricks and a JIT may help to reduce this problem) where a = [1, 2, 3] b = a Makes b a copy-on-write copy of a, that is without reference semantics. Other things, like base-10 floating point numbers, and the removal of other complexity allow to create a language more newbie-friendly. And then I think I too can see myself using such simple to use but practically useful language for very quick scripts, where running speed is less important, but where most possible bugs are avoided because the language semantics is rich but very clean. Is some one else interested in such language? Such language may even be a bit fitter than Python for an (uncommon) practice called real time programming where an artist writes code that synthesizes sounds and music on the fly ;-) --- Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Odd behaviour of *.pth files and Apache
On Tue, 26 Feb 2008 03:01:33 -0200 Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 23 Feb 2008 12:52:45 -0200, D'Arcy J.M. Cain [EMAIL PROTECTED] escribió: I have more information now. It seems that it recurses the .pth files it finds in PYTHONPATH but not for directories found in the .pth files in site-packages. Is this expected behaviour? The documentation suggests that it should pick up both. If a .pth file contains a valid directory, it is added to sys.path but it's not searched for additional .pth files. From http://docs.python.org/lib/module-site.html A path configuration file is a file whose name has the form package.pth AND EXISTS IN ONE OF THE FOUR DIRECTORIES MENTIONED ABOVE (emphasis by me) (the four directories being .../lib/python2.5/site-packages, site-python, etc.) (Mmm, what the 2.5 docs say is not exactly the same as the actual code in site.py, and the version in http://docs.python.org/dev/library/site.html is not the same as the svn version of site.py... anyway, directories added by mean of .pth files are not recursively searched for more .pth files) But that is not true. If I add a path by setting PYTHONPATH and there is a .pth in that directory then it is read and recursively searched for more .pth files. It is only when the path is added because it is in site-packages that it doesn't load the .pth files found. In http://www.python.org/doc/inst/search-path.html there is more specific language: The most convenient way is to add a path configuration file to a directory that's already on Python's path, usually to the .../site-packages/ directory. Path configuration files have an extension of .pth, and each line must contain a single path that will be appended to sys.path. (Because the new paths are appended to sys.path, modules in the added directories will not override standard modules. This means you can't use this mechanism for installing fixed versions of standard modules.) Paths can be absolute or relative, in which case they're relative to the directory containing the .pth file. Any directories added to the search path will be scanned in turn for .pth files. See site module documentation for more information. Directories listed in .pth files in site-packages are added to the search path so they should be scanned for more .pth files. This really smells like a bug in either the code or the docs. I hope it is in the code and will eventually be fixed. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
blog
www.bussines-yoga.blogspot.com My Search Funds Ok so this is not tech/gadget related but i had to post about this I have found a great new site and it is earning me £0।03 for every single I make on the net www.bussines-yoga.blogspot.com My search funds have teamed up with ask.com So basically this meens you get paid to search the net , this is not paid to click but paid to search So sign up today I get paid to read I’m such a lazy reader on my own that even though I’ve run up a credit card debt from (too many) Amazon book purchases, I’ve had little time to read them and sometimes just enjoy them as the ornamental objects that they are, slim books lining my makeshift shelves in o ne extraordinary font and color scheme after another. I think that someday, when I buy a real bookcase, I shall read all the books, hopefully in one sitting, and become saturated in a composite world of Chinese architecture, art, and history, and dreams, death, and beautiful sentences. A dream, but a fun one to think about. So to force myself to read these days, especially from cover to cover, and especially to stay in touch with today’s literature, I proofread in addition to my day job. (Oh, right, it’s to earn extra money, too.) I take on mainly adult literary fiction; as my time is divided between writing, my day job, my dog, J, dance class, and mindless TV, I’d rather take on books that will either teach me something about the craft of writing or introduce me to a writer I’d never read on my own but who I’ve always been a little curious about because of the adulation or vilification heaped on him or her (such as John Banville or Maile Meloy). After I’m done with a job, I jot down some notes on what I’d learned from that particular book. For this space, I’d like to share some of these notes,* partly to articulate for myself why I am attracted to or repelled by certain kinds of books and partly to promote those that particularly affected me. Proofreading, never mind writing, is a lonely job, and though in person I try to be tactful about the work I proofread and the work I write, I find myself sometimes so frustrated and puzzled by which books get a huge amount of attention (such as Claire Messud’s The Emperor’s Children) and which don’t (such as Philippe Claudel’s By a Slow River), that I just want to vent. I don’t know that I’m an articulate or smart venter, but I will try hard to be articulate if I can’t be smart. * Note that for the current jobs, I’m not sure how much I can reveal about the book, as I don’t want to violate any tacit agreement between freelancer and contractor (i.e., keep your mouth shut till the book is published), so I’ll just withhold the ID of the title, author, and character names in the post, and then, a few months down the road after the book’s been published, I can feel safe to reveal. I guess you could say that a lot has happened over the last 6 months. My Agloco referrals went up to over 5000 members, I got in the top 0.01% of all Agloco members, but have yet to receive a dime from Agloco. And no one every will. Agloco officially is closing its doors. The reason. There is no money to meet operational costs. Wait a sec...wasn't that always the case? Anywaythis was more of a fun thing for me to do on the side and I haven't been around for months to even see how it was doing. You see, I made an incredible discovery over the last few months that has caused me to not even think about Agloco for months. I discovered that it is possible accurately predict the time that the currency markets (Forex) will hit their daily highs and lows in a given day. If you don't know what Forex is go to www.iforexsignals.com/questions.html and take the online tutorial. Basically it is not uncommon for people to double their investment money in a month or even a couple weeks in the Forex market. That's right! 100% on your money in a month or less! This is almost unheard of in the investment community, but this system does it consistenly...and it shows no signs of stopping. The idea of Forex trading may scare you, but let me tell you, it is so simple, anyone can do it! I had no prior investing experience until a few months ago. I have grown just a few hundred dollars into an amount that allows me to trade for a living. I opened up an account with a Forex Broker with only a few hundred dollars! I get buy/sell signals the night before from the iForexSignals.com members area, which tells me the exact time to enter the trade, and the exact time to exit. I know, it seems strange, that this system could predict the exact time to enter and exit hours before it happens, and actually be right! I can tell you that just over the last few month, this system has worked very well. I wanted to write this post to let a lot of you Agloco folk know about my success as I feel that it might benefit some of you to join this system and experience the same success I am. For those that have limited time and a desire
Re: buliding log files
On Feb 26, 3:58 pm, Thinker [EMAIL PROTECTED] wrote: diljeet kaur wrote: hi im working on pyqt environment i want to know how to take log or how to build log files of the output Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newse... Please check module logging. http://docs.python.org/lib/module-logging.html It provides facility of system log of UN*X like systems. This tutorial will also help: http://www.onlamp.com/pub/a/python/2005/06/02/logging.html regards, Subeen http://love-python.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
What is it with people and double++ posting... If you have a lot to say, say it together and take the time to slow down, re-read it and not just fly it out, line by line, by line, by line... To answer only the following: That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. That means most people. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. Couldn't disagree with you more, the fact they don't specialise in Computer Science shouldn't be a reason to follow their expected outcomes, they should be informed of the standard CS approach. I'm all for punishing people for making well I thought it would always do the following... thought process. The quicker they learn certain methods and expectations are wrong the quicker they get used to the proper thought patterns. -- http://mail.python.org/mailman/listinfo/python-list
dict.get and str.xsplit
When I use dictionaries I find the dict.get() method very handy, and I'd like to use it often, but I think it's quite slow. This is a small benchmark: from random import randrange from timeit import default_timer as clock def main(N, M): keys = list(set(randrange(2*N) for n in xrange(N))) n2 = len(keys) / 2 keys1, keys2 = keys[:n2], keys[n2:] adict = dict.fromkeys(keys1) t = clock() for _ in xrange(M): for k in keys1: r = adict.get(k, None) for k in keys2: r = adict.get(k, None) print round(clock() - t, 2), s t = clock() for _ in xrange(M): for k in keys1: if k in adict: r = adict[k] else: r = None for k in keys2: if k in adict: r = adict[k] else: r = None print round(clock() - t, 2), s main(4, 30) On my old PC the output is: 2.36 s 1.59 s (Your timings may be 4-5 times smaller, so you can tweak N and M to have significant results). And note that the if/then version is faster even if it calls the hash function two times, while get() is supposed to do it once (in this case the hashing function is very simple and fast. If the keys are long strings the results of a similar benchmark may be different, because the computing of the hashing function may become the slowest part of that code). This is a real difference, that has real impact on the programs I write, so I often use the if/else approach, despite the dict.get() method being semantically fitter and shorter. So can the dict.get() method be speed up? And if not, why? -- Another method I'd like to see, is the str.xsplit() I was talking about time ago too. It's like str.split() but it's lazy. It avoids to build a potentially huge list. In real D programs I have seen such string function may speed up heavy-string-processing code (the kind of code you may want to use Python/Perl/Ruby for) up to 2-3 times. Seeing how such kind of processing is common in Python I think this isn't an optimization to ignore. (I am now getting better in writing C code, so in few months I may even become able to submit a xsplit patch myself. I think it's not too much complex to write, it can borrow lot of code from the str.split method). Bye, and thank you for your kind attention, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
On Tue, 26 Feb 2008 06:02:12 -0800, bearophileHUGS wrote: This is a real difference, that has real impact on the programs I write, so I often use the if/else approach, despite the dict.get() method being semantically fitter and shorter. So can the dict.get() method be speed up? And if not, why? I guess it's the method lookup that's the slow part. Factor it out of the loop and measure again:: adict_get = adict.get for _ in xrange(M): for k in keys1: r = adict_get(k, None) for k in keys2: r = adict_get(k, None) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 2008-02-26 at 04:29 -0800, Lie wrote: J Cliff Dyer: I'm in the camp that believes that 3/4 does indeed yield the integer 0, but should be spelled 3//4 when that is the intention. That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. That means most people. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. Of course. That's why I think you ought to spell it 3//4. Nobody gets confused when a strange operator that they've never seen before does something unusual. Average Jo off the street looks at python code and sees 3/4, and immediately thinks aha! .75! Show the same person 3//4, and she'll think, A double slash? I'd better check the documentation--or better yet, play with it a little in the interactive interpreter. -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 26 Feb 2008 08:55:22 -0500 J. Cliff Dyer [EMAIL PROTECTED] wrote: Of course. That's why I think you ought to spell it 3//4. Nobody gets confused when a strange operator that they've never seen before does something unusual. Average Jo off the street looks at python code and sees 3/4, and immediately thinks aha! .75! Show the same person 3//4, Why do we care what A. Jo thinks? I would hope that A. Programmer Jo would see int {OP} int and assume int result. A. Jo isn't going to be debugging anything. If 3/4 ever returned 0.75 in any language I would drop that language. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
On Tue, 26 Feb 2008 05:23:11 -0800, Nicola Musatti wrote: At least in C++ resource management only becomes more complicated if you need more control. I think this is the point where so many people here disagree. I'm coming from a garbage collection background in OOP programming. In C++ resource management becomes instantly more complicated because I have to think about memory management and must actively manage it in *every case*. Writing code in a RAII style and using smart pointer templates is a cost for me. A cost that's quite high, because it feels completely wrong to have to think about it and to write in that value style, because that goes against my expectations/picture of OOP -- a graph of independent/loosely coupled objects communicating with each other. In this sense C++ looks like a quite crippled and fragile OOP language to me. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
Marc 'BlackJack' Rintsch wrote: On Tue, 26 Feb 2008 06:02:12 -0800, bearophileHUGS wrote: This is a real difference, that has real impact on the programs I write, so I often use the if/else approach, despite the dict.get() method being semantically fitter and shorter. So can the dict.get() method be speed up? And if not, why? I guess it's the method lookup that's the slow part. Factor it out of the loop and measure again:: adict_get = adict.get for _ in xrange(M): for k in keys1: r = adict_get(k, None) for k in keys2: r = adict_get(k, None) And think about using the timeit module, since it's been included among the batteries for your convenience, and it removes some common pitfalls with cross-platform timings. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
On Feb 26, 8:14 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Tue, 26 Feb 2008 06:02:12 -0800, bearophileHUGS wrote: This is a real difference, that has real impact on the programs I write, so I often use the if/else approach, despite the dict.get() method being semantically fitter and shorter. So can the dict.get() method be speed up? And if not, why? I guess it's the method lookup that's the slow part. Factor it out of the loop and measure again:: adict_get = adict.get for _ in xrange(M): for k in keys1: r = adict_get(k, None) for k in keys2: r = adict_get(k, None) Ciao, Marc 'BlackJack' Rintsch Can't be. The string 'get' is only hashed once, since it's hard-coded into the script, and looking it up can't be any slower than looking up __getitem__. -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 26 Feb 2008 04:29:18 -0800, Lie wrote: J Cliff Dyer: I'm in the camp that believes that 3/4 does indeed yield the integer 0, but should be spelled 3//4 when that is the intention. That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. That means most people. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. So why is it creepy then!? ``3 // 4`` is for the people knowing about integer division and ``3 / 4`` gives the expected result for those who don't. Those who don't know ``//`` can write ``int(3 / 4)`` to get the same effect. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
On Feb 25, 8:29 am, Nicola Musatti [EMAIL PROTECTED] wrote: And the migration to Python is due in large part because of an additional factor of 3-4x in personal productivity (over Java). Improvements in runtime performance wouldn't hurt, but for many applications that's not an issue. (If optional data typing were offered, Python's penetration in the enterprise space would be even higher, and I suspect there would be performance gains as well.) This I found less hard to believe. Python is more expressive than Java and usually requires less code for the same task. Moreover the availability of libraries is comparable. I tend to cheat when I code in java and pretend I'm writing in Python. But even then the biggest pain comes in when I try to use really advanced data structures and get all knotted up in the verbosity -- and when I try to figure out what I was doing later it's even worse. For example in Python I tend to build things like dictionaries of tuples to lists of dictionaries without thinking about it, but in Java the equivalent of D[ (x,y) ] = [ { a: b } ] is too horrible to be imagined, even if you cheat and use the non-type-safe containers. Of course this is in addition to other Java annoyances like no proper support for multivalued returns or function pointers, and overgeneralized libraries. However, I have found in the corporate environment that managers frequently don't like it when you do in a few days that things that they themselves don't know how to do in less than several months. Especially when it makes the other programmers angry. Sometimes I think programmers should get sociology/psychology/poli.sci degrees and pick up the programming stuff on the job, since most of what counts seems to be politics, really. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=spam+eggs -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
On Tue, 26 Feb 2008 06:33:01 -0800, castironpi wrote: On Feb 26, 8:14 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Tue, 26 Feb 2008 06:02:12 -0800, bearophileHUGS wrote: This is a real difference, that has real impact on the programs I write, so I often use the if/else approach, despite the dict.get() method being semantically fitter and shorter. So can the dict.get() method be speed up? And if not, why? I guess it's the method lookup that's the slow part. Factor it out of the loop and measure again:: adict_get = adict.get for _ in xrange(M): for k in keys1: r = adict_get(k, None) for k in keys2: r = adict_get(k, None) Ciao, Marc 'BlackJack' Rintsch Can't be. The string 'get' is only hashed once, since it's hard-coded into the script, and looking it up can't be any slower than looking up __getitem__. Within functions it is faster. In the original code the `get` attribute is looked up on the `adict` object twice in each loop iteration via hashing. In my code it is looked up once before the loop and within the loop the local name `adict_get` isn't looked up but hardcoded as index into the internal locals array of the function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
Marc 'BlackJack' Rintsch: I guess it's the method lookup that's the slow part. Factor it out of the loop and measure again:: I did know of that optimization, but sometimes I forget about it... The new timings: Output timings, best of 3, unloaded CPU: 2.32 s with adict.get 1.56 s with in + if/then/else 1.78 s with adict_get It's slower still, despite doing the lookup two times half of the times (half keys are present in the test set). The in is an operator, it's faster than a method call, but I don't understand the other details. Now the difference between 1.78 and 1.56 is small enough, so probably now it's not much noticeable in practice in real programs, so my original argument is mostly dead now :-) In the code points where speed matters instead of a single line with a get() I can use two lines to create a local adict_get. Bye and thank you, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 26 Feb 2008 09:29:55 -0500, D'Arcy J.M. Cain wrote: If 3/4 ever returned 0.75 in any language I would drop that language. Then prepare to drop Python from version 3 on: Python 3.0a1 (py3k, Aug 31 2007, 21:20:42) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type help, copyright, credits or license for more information. 3 / 4 0.75 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Indentation and optional delimiters
On Feb 26, 7:36 am, [EMAIL PROTECTED] wrote: This is the best praise of semantic indentation I have read so far, by Chris Okasaki:http://okasaki.blogspot.com/2008/02/in-praise-of-mandatory-indentatio... A quotation: Imagine my surprise when I started teaching this language and found the students picking it up faster than any language I had ever taught before. As fond as I am of the language, I'm certainly under no illusions that it's the ultimate teaching language. After carefully watching the kinds of mistakes the students were and were not making, I gradually realized that the mandatory indentation was the key to why they were doing better. I have appreciated that article, and I have personally seen how fast students learn Python basics compared to other languages, but I think that it's way more than just indentation that makes the Python language so quick to learn [see appendix]. I used to like indentation-based block delimiting years before finding Python, and this article tells me that it may be a good thing for other languages too, despite some disadvantages (but it's little probable such languages will change, like the D language). Some people have actually tried it in other languages:http://people.csail.mit.edu/mikelin/ocaml+twt/ So I may try to write something similar for another language too. One of the most common complaints about it is this written by James on that blog: I prefer explicit delimiters because otherwise the line wrapping of code by various email programs, web mail, mailing list digesters, newsgroup readers, etc., often results in code that no longer works. A possible solution to this problem is optional delimiters. What's the path of less resistance to implement such optional delimiters? Is to use comments. For example: #} or #: or something similar. If you use such pairs of symbols in a systematic way, you have cheap optional delimiters, for example: def insort_right(a, x, lo=0, hi=None): if hi is None: hi = len(a) #} while lo hi: mid = (lo + hi) // 2 if x a[mid]: hi = mid #} else: lo = mid+1 #} #} a.insert(lo, x) #} It looks a bit ugly, but a script is able to take such code even flattened: def insort_right(a, x, lo=0, hi=None): if hi is None: hi = len(a) #} while lo hi: mid = (lo + hi) // 2 if x a[mid]: hi = mid #} else: lo = mid+1 #} #} a.insert(lo, x) #} And build the original Python code (it's possible to do the opposite too, but it requires a bit more complex script). Such #} may even become a standard (a convention. Not something enforced by the compiler. What I'd like to see the Python compiler enforce is to raise a syntax error if a module mixes tabs and spaces) for Python, so then it's easy to find the re-indenter script when you find flattened code in some email/web page, etc. --- Appendix: I believe there can exist languages even faster than Python to learn by novices. Python 3.0 makes Python even more tidy, but Python itself isn't the most semantically clear language possible. I have seen that the widespread reference semantics in Python is one of the things newbies need more time to learn and understand. So it can be invented a language (that may be slower than Python, but many tricks and a JIT may help to reduce this problem) where a = [1, 2, 3] b = a Makes b a copy-on-write copy of a, that is without reference semantics. Why not b = copyonwrite( a )? Other things, like base-10 floating point numbers, and the removal of other complexity allow to create a language more newbie-friendly. And then I think I too can see myself using such simple to use but practically useful language for very quick scripts, where running speed is less important, but where most possible bugs are avoided because the language semantics is rich but very clean. Is some one else interested in such language? Such language may even be a bit fitter than Python for an (uncommon) practice called real time programming where an artist writes code that synthesizes sounds and music on the fly ;-) Subclass the interpreter-- make your own session. -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 26, 9:29 am, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Tue, 26 Feb 2008 08:55:22 -0500 J. Cliff Dyer [EMAIL PROTECTED] wrote: Of course. That's why I think you ought to spell it 3//4. Nobody gets confused when a strange operator that they've never seen before does something unusual. Average Jo off the street looks at python code and sees 3/4, and immediately thinks aha! .75! Show the same person 3//4, Why do we care what A. Jo thinks? I would hope that A. Programmer Jo would see int {OP} int and assume int result. There's no reason why int op int would imply an int result. It's only a convention in some languages, and a bad one. A. Jo isn't going to be debugging anything. If 3/4 ever returned 0.75 in any language I would drop that language. Have fun dropping Python, then, chief. Integer division with / is already deprecated, can be disabled ever since Python 2.4, and will be wholly removed in Python 3.0. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
On Feb 26, 8:40 am, [EMAIL PROTECTED] wrote: Marc 'BlackJack' Rintsch: I guess it's the method lookup that's the slow part. Factor it out of the loop and measure again:: I did know of that optimization, but sometimes I forget about it... The new timings: Output timings, best of 3, unloaded CPU: 2.32 s with adict.get 1.56 s with in + if/then/else 1.78 s with adict_get It's slower still, despite doing the lookup two times half of the times (half keys are present in the test set). The in is an operator, it's faster than a method call, but I don't understand the other details. Now the difference between 1.78 and 1.56 is small enough, so probably now it's not much noticeable in practice in real programs, so my original argument is mostly dead now :-) In the code points where speed matters instead of a single line with a get() I can use two lines to create a local adict_get. Bye and thank you, bearophile Where does adict_getitem fit in? And try: except: KeyError? -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 26, 9:02 pm, [EMAIL PROTECTED] wrote: That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. That means most people. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. Couldn't disagree with you more, the fact they don't specialise in Computer Science shouldn't be a reason to follow their expected outcomes, they should be informed of the standard CS approach. I'm all for punishing people for making well I thought it would always do the following... thought process. The quicker they learn certain methods and expectations are wrong the quicker they get used to the proper thought patterns. The problem lies on which maths is the real maths? In real world, 3/4 is 0.75 is 0.75 and that's an unchangeable fact, so programming languages that do other things is either wrong or have their reason to do that. Python, C, and other programming languages that uses integer division by default choose to do default integer division because CPUs execute integer division faster than floating division, but it doesn't change the fact that 3/4 is equal to 0.75 but is not equal to 0. I think a CS should understand that the choice of default integer division was actually a workaround for the expensive operation, not because 3/4 actually equals 0. As the more educated person, they should still expect 3/4 to be 0.75 but could understand why if the language they're using gives 0. Commoners are the less educated, languages should appeal to as much people as it could, and giving 3/4 == 0 is the best way to confuse some people right away, instead giving 3/4 == 0.75 would just make the more educated CSs search for the regular division operator. It is better to think this way: CSs supposed brain thought: try: print 3 / 4 except IntegerResult: print 'integer division workaround' if wants[floatdivision]: print 'searching for float division operator' elif wants[integerdivision]: print 'that was already correct' Commoner's supposed brain thought: try: print 3 / 4 than this way: CSs supposed brain thought: try: print 3 / 4 except FPointResult: print 'This language is a jerk' Commoner's supposed brain thought: try: print 3 / 4 The first set of brain thought appeal to everyone, everyone is happy with the result. The second set of brain thought kills a CS guy and gives unhandled error to a commoner. DO you still think that default integer division is better? -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
[EMAIL PROTECTED] napisał(a): It's slower still, despite doing the lookup two times half of the times (half keys are present in the test set). The in is an operator, it's faster than a method call, but I don't understand the other details. Now the difference between 1.78 and 1.56 is small enough, so probably now it's not much noticeable in practice in real programs, so my original argument is mostly dead now :-) In the code points where speed matters instead of a single line with a get() I can use two lines to create a local adict_get. AFAIK, method/function call is generally slow in Python (similarly to the dot attribute lookup). As for the original prooblem, why not use defaultdict? I think it's the most idiomatic way to achieve what we want. And also the fastest one, according to my quick-and-dirty tests: from collections import defaultdict def main(N, M): # snip addict = defaultdict(lambda: None, adict) t = clock() for _ in xrange(M): for k in keys1: r = addict[k] for k in keys2: r = addict[k] print round(clock() - t, 2), s adict.get: 3.12 s adict_get: 2.24 s in: 1.62 s defaultdict: 1.05 s -- http://mail.python.org/mailman/listinfo/python-list
Andy Pausch (of Alice fame) -- last lecture
Hi folks. Andy Pausch who headed up the Alice project which aims to teach 3D animation using Python has gained additional fame from his last lecture where he talks about being diagnosed with terminal pancreatic cancer, and comments on life in general. http://www.cs.cmu.edu/~pausch/ You've probably already seen it, but I thought I'd point out the Python angle. It's a good view to help put things in perspective. Its one of those internet phenomena. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=life+instance -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 26 Feb 2008 06:45:45 -0800 (PST) Carl Banks [EMAIL PROTECTED] wrote: On Feb 26, 9:29 am, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: If 3/4 ever returned 0.75 in any language I would drop that language. Have fun dropping Python, then, chief. Integer division with / is already deprecated, can be disabled ever since Python 2.4, and will be wholly removed in Python 3.0. I have not been following Python development that closely lately so I was not aware of that. I guess I won't be going to Python 3 then. It's great that Python wants to attract young, new programmers. Too bad about us old farts I guess. How soon before 2.x is completely deprecated and I have to become a Walmart greeter? -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 26 Feb 2008 06:59:44 -0800 (PST) Lie [EMAIL PROTECTED] wrote: The problem lies on which maths is the real maths? In real world, 3/4 is 0.75 is 0.75 and that's an unchangeable fact, so programming Which real world is that? In my real world 3/4 is 0 with a remainder of 3. What happens to that 3 depends on the context. When I worked with a youth soccer group I was pretty sure that I would be disciplined if I carved up a seven year old player so that I could put 0.75 of a child on a team. Anyway, I'm sure that all these arguments have been made and it is pointless to argue about it now. It sounds like the decision has been made. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web site for comparing languages syntax
Sebastian Bassi schrieb: Hello, I know there is one site with wikimedia software installed, that is made for comparing the syntax of several computer languages (Python included). But don't remember the URL. Anyone knows this site? It does not use wikimedia, but it's good: http://pleac.sourceforge.net/ The Perl Cookbook gets translated to several other languages. -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de -- http://mail.python.org/mailman/listinfo/python-list
Re: Andy Pausch (of Alice fame) -- last lecture
On Feb 26, 10:03 am, Aaron Watters [EMAIL PROTECTED] wrote: Hi folks. Andy Pausch who headed up the Alice project which aims to teach 3D animation using Python ... Oops. It looks like Alice 1.0 was Python; 2.0 is java, but whatever. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=unbirthday -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 26, 10:17 pm, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: Carl Banks [EMAIL PROTECTED] wrote: On Feb 26, 9:29 am, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: If 3/4 ever returned 0.75 in any language I would drop that language. Have fun dropping Python, then, chief. Integer division with / is already deprecated, can be disabled ever since Python 2.4, and will be wholly removed in Python 3.0. I have not been following Python development that closely lately so I was not aware of that. I guess I won't be going to Python 3 then. It's great that Python wants to attract young, new programmers. Too bad about us old farts I guess. Don't worry, Python would still have integer division (// - double slash), if you still prefer integer division. Lie [EMAIL PROTECTED] wrote: The problem lies on which maths is the real maths? In real world, 3/4 is 0.75 is 0.75 and that's an unchangeable fact, so programming Which real world is that? In my real world 3/4 is 0 with a remainder of 3. What happens to that 3 depends on the context. When I worked with a youth soccer group I was pretty sure that I would be disciplined if I carved up a seven year old player so that I could put 0.75 of a child on a team. lol, when counting how much players needed you wouldn't do a division, you count from one to eleven (a.k.a addition by one a.k.a. increment), excepting at the point where number of available players + current count = 11 (+ spares) (or better, you subtract the number of players to the number of players required). Save the float division for the time, 90 minutes / number of players if you wanted each child to play an equal amount of time. Good joke, and a true argument, I don't wish to see anyone chopped off because I said floating point division is better. -- http://mail.python.org/mailman/listinfo/python-list
Break lines?
I have made this string: TITLE = 'Efficiency of set operations: sort model, (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer' But I am not allowed to break the line like that: IndentationError: unexpected indent How do I break a line? -- http://mail.python.org/mailman/listinfo/python-list
Re: Indentation and optional delimiters
[EMAIL PROTECTED]: Why not b = copyonwrite( a )? Subclass the interpreter-- make your own session. Your idea may work, but I am talking about a new language (with some small differences, not a revolution). Making such language efficient enough may require to add some complex tricks, copy-on-write is just one of them, a JIT is probably useful, etc. Thank you, bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 26, 2:45 pm, Carl Banks [EMAIL PROTECTED] wrote: On Feb 26, 9:29 am, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Tue, 26 Feb 2008 08:55:22 -0500 J. Cliff Dyer [EMAIL PROTECTED] wrote: Of course. That's why I think you ought to spell it 3//4. Nobody gets confused when a strange operator that they've never seen before does something unusual. Average Jo off the street looks at python code and sees 3/4, and immediately thinks aha! .75! Show the same person 3//4, Why do we care what A. Jo thinks? I would hope that A. Programmer Jo would see int {OP} int and assume int result. There's no reason why int op int would imply an int result. It's only a convention in some languages, and a bad one. A. Jo isn't going to be debugging anything. If 3/4 ever returned 0.75 in any language I would drop that language. Have fun dropping Python, then, chief. Integer division with / is already deprecated, can be disabled ever since Python 2.4, and will be wholly removed in Python 3.0. Carl Banks And of course A. Jo will love this: Python 3.0a1+ (py3k:59330, Dec 4 2007, 18:44:39) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. 3/5 0.59998 On a more general note, though, I believe that integer division is a more important concept to CS than 'near exact' division. CS deals mainly with discrete objects (and one might say exclusively, given the digital nature of modern computers), and integers are the more natural numerical objects to associate with discrete things. As with the soccer example given by D'Arcy J.M. Cain, many objects can't be chopped in halves or quarters (especially in CS) therefore float division is no meaningless to them. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Web site for comparing languages syntax
There is this site too, I have written many small programs for it: http://www.codecodex.com/wiki/index.php?title=Main_Page Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
[EMAIL PROTECTED]: As for the original prooblem, why not use defaultdict? I think it's the most idiomatic way to achieve what we want. And also the fastest one, according to my quick-and-dirty tests: It adds the new keys, I can't accept that: from collections import defaultdict as dd adict = {1:2, 3:4} addict = dd(lambda: None, adict) r = addict[10] addict defaultdict(function lambda at 0x008E6FB0, {1: 2, 10: None, 3: 4}) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
D'Arcy J.M. Cain [EMAIL PROTECTED] writes: I have not been following Python development that closely lately so I was not aware of that. I guess I won't be going to Python 3 then. It's great that Python wants to attract young, new programmers. Too bad about us old farts I guess. Before deciding to drop Python 3 on the grounds of integer division, I recommend that you at least read PEP 238 (http://www.python.org/dev/peps/pep-0238/) to see arguments *why* the division was changed. Who knows, maybe they persuade you? The Motivation section of the PEP makes a persuasive argument why integer division works well in statically typed languages, but results in many more gotchas in a dynamic language like Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Break lines?
I have made this string: TITLE = 'Efficiency of set operations: sort model, (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer' But I am not allowed to break the line like that: IndentationError: unexpected indent How do I break a line? Depends on what you want. You can embed running strings with newlines using triple-quotes (either single- or double-quotes): TITLE = Efficiency... (cphstl:... Or you can use string concatenation using line-continuations: TITLE = Efficiency... \ (cphstl:... or using parens TITLE = (Efficiency... (cphstl:...) I like the clean'ness of the first version, but sometimes get irked by it including my leading whitespace (there are some workarounds, but all involve more than trivial effort). I tend to use the 2nd in the case you describe, but usually using the 3rd version in all other cases where it's as a parameter to a function call or some other bracketed/braced construct. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Web site for comparing languages syntax
On 2/26/08, Andreas Tawn [EMAIL PROTECTED] wrote: Maybe http://www.rosettacode.org ? That's a wiki. YES!!!. Thank you!! -- Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología. Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6 GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D -- http://mail.python.org/mailman/listinfo/python-list
Re: Break lines?
saneman wrote: I have made this string: TITLE = 'Efficiency of set operations: sort model, (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer' But I am not allowed to break the line like that: IndentationError: unexpected indent How do I break a line? by triple quoting: TITLE = '''Efficiency of set operations: sort model, (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer''' or TITLE = Efficiency of set operations: sort model, (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer -- http://mail.python.org/mailman/listinfo/python-list
Re: Break lines?
Tim Chase wrote: I have made this string: TITLE = 'Efficiency of set operations: sort model, (cphstl::set::insert(p,e)^n cphstl::set::insert(e)), integer' But I am not allowed to break the line like that: IndentationError: unexpected indent How do I break a line? Depends on what you want. You can embed running strings with newlines using triple-quotes (either single- or double-quotes): TITLE = Efficiency... (cphstl:... Or you can use string concatenation using line-continuations: TITLE = Efficiency... \ (cphstl:... or using parens TITLE = (Efficiency... (cphstl:...) I like the clean'ness of the first version, but sometimes get irked by it including my leading whitespace (there are some workarounds, but all involve more than trivial effort). I tend to use the 2nd in the case you describe, but usually using the 3rd version in all other cases where it's as a parameter to a function call or some other bracketed/braced construct. -tkc Ok thanks! Btw why double quotes instead of single ' ? -- http://mail.python.org/mailman/listinfo/python-list
Re: using PIL for PCA analysis
Paul McGuire wrote # following approx fromhttp://www.dfanning.com/ip_tips/color2gray.html grayscale = lambda (R,G,B) : int(0.3*R + 0.59*G + 0.11*B) print [ [ grayscale(rgb) for rgb in row ] for row in sampledata ] Paul in PIL handbook ,they mention a Luma transform on page15, under the im.convert() section.. L = R * 299/1000 + G * 587/1000 + B * 114/1000 is that not similar to what you mentioned?(I am newbie in this area..) if i want to do an array of PIL image data i can use img=Image.open(myimg.jpg) .convert(L) pixelarray=img.getdata() thus i guess i can build a matrix of a set of images is there something wrong in the way i do this above?may be i can use that to find covariance matrix for the set of images? H -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting python docstings
You know that `epydoc` supports reStructuredText as markup language!? *what* exactly *do* you want? Yes, I do... i was wondering if docutils (http:// docutils.sourceforge.net/) could do that as well (get my reStructuredText documentation) Stephane -- http://mail.python.org/mailman/listinfo/python-list
Re: What does this bogus code in urlparse do?
On Mon, Feb 25, 2008 at 11:04 PM, John Nagle [EMAIL PROTECTED] wrote: See http://svn.python.org/view/python/trunk/Lib/urlparse.py?rev=60163view=markup; Look at urljoin. What does the code marked # XXX The stuff below is bogus in various ways... do? I think it's an attempt to remove leading ../ components in URLs, which are generally ignored. But it also does something with commas, and it's not clear why. John Nagle -- You should probably invest in syntax highlighting ;), it doesn't do anything with commas (just '.', '..' , and ''). It appears to be trying to normalize relative URLs into a single absolute one, as the docstring implies. -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 26 Feb 2008 16:49:10 +0100 Hrvoje Niksic [EMAIL PROTECTED] wrote: D'Arcy J.M. Cain [EMAIL PROTECTED] writes: I have not been following Python development that closely lately so I was not aware of that. I guess I won't be going to Python 3 then. It's great that Python wants to attract young, new programmers. Too bad about us old farts I guess. Before deciding to drop Python 3 on the grounds of integer division, I recommend that you at least read PEP 238 (http://www.python.org/dev/peps/pep-0238/) to see arguments *why* the division was changed. Who knows, maybe they persuade you? I have. They don't. I'm not impressed by the fact that the same generation(s) that can't make change when the cash register is broken are surprised by integer division. What can I say? I learned arithmetic with paper and pencil and my head before I was allowed to use a calculator. Integer division means integer result to me in a very real sense. Arguing that integer division should return a float just sounds like proof by vigorous assertion to me. I suppose I will adapt but it really feels wrong. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Break lines?
Ok thanks! Btw why double quotes instead of single ' ? Either one will do...there's not much difference. I try to use double-quotes most of the time, just so when I include an apostrophe in-line (which I do more often than I include a double-quote in-line), I don't have to think. string1a = John's dog string1b = 'John\'s dog' string2a = She said \hello\ string2b = 'She said hello' string3a = 'She said John\'s nice in a letter' string3b = She said \John's nice\ in a letter' string3c = She said John's nice in a letter string3d = '''She said John's nice in a letter''' My usual aim is for clarity, so I tend to go with the versions that have the fewest backslashes in them. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: dict.get and str.xsplit
[EMAIL PROTECTED] napisał(a): [EMAIL PROTECTED]: As for the original prooblem, why not use defaultdict? I think it's the most idiomatic way to achieve what we want. And also the fastest one, according to my quick-and-dirty tests: It adds the new keys, I can't accept that: Right, my fault not noticing that. I experimented further with __missing__ method and with ask forgiveness idiom (try... except KeyError) and they were both noticeably slower. So checking with in may be the most efficient way we have. Regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Indentation and optional delimiters
On Feb 26, 9:45 am, [EMAIL PROTECTED] wrote: [EMAIL PROTECTED]: Why not b = copyonwrite( a )? Subclass the interpreter-- make your own session. Your idea may work, but I am talking about a new language (with some small differences, not a revolution). Making such language efficient enough may require to add some complex tricks, copy-on-write is just one of them, a JIT is probably useful, etc. Thank you, bye, bearophile It's Unpythonic to compile a machine instruction out of a script. But maybe in the right situations, with the right constraints on a function, certain chunks could be native, almost like a mini- compilation. How much machine instruction do you want to support? -- http://mail.python.org/mailman/listinfo/python-list
Re: is there enough information?
On Feb 26, 1:45 am, [EMAIL PROTECTED] wrote: Two options occurred to me, which the first showed up in the earlier extremely skeletal and cryptic post: Perhaps you would be more likely to get the kind of help you seem to want if you refrained from posting cryptic and skeletal messages. The fact that many other people have pointed this out to you as of late would tend to suggest you are trolling, i.e. intentionally trying to foster miscommunication and threads that do nothing to advance anyones understanding. And regarding your other recent post about trying to find a solution to the problem of immutable types... Due to the above reasons you are unlikely to influence the design of the core language with half-baked stream of consciousness ramblings. These belong in your LiveJournal, not in c.l.python. If you have a problem you need help with, please read this entire document about 3 times before posting anything else: http://catb.org/~esr/faqs/smart-questions.html Specifically this: http://catb.org/~esr/faqs/smart-questions.html#beprecise and this: http://catb.org/~esr/faqs/smart-questions.html#goal -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Feb 26, 9:33 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Tue, 26 Feb 2008 04:29:18 -0800, Lie wrote: J Cliff Dyer: I'm in the camp that believes that 3/4 does indeed yield the integer 0, but should be spelled 3//4 when that is the intention. That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. That means most people. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. So why is it creepy then!? ``3 // 4`` is for the people knowing about integer division and ``3 / 4`` gives the expected result for those who don't. Those who don't know ``//`` can write ``int(3 / 4)`` to get the same effect. yep, that's the point. The new division operator isn't that creepy anymore by returning float instead of integer, kudos for whoever made the change. -- http://mail.python.org/mailman/listinfo/python-list
How to turn a list of tuples into a dictionary?
Let's say I've got a list of tuples, like so: ( ('a', '1'), ('b', '2'), ('c', '3') And I want to turn it into a dictionary in which the first value of each tuple is a key and the second value is a value, like so: { 'a' - '1', 'b' - '2', 'c' - '3' } Is there a way to do this with a single line of code? Currently, I'm doing it like this: tuples = ( ('a', '1'), ('b', '2'), ('c', '3') d = {} for option,value in tuples: d[option] = value Thanks, --Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
J. Cliff Dyer wrote: On Tue, 2008-02-26 at 04:29 -0800, Lie wrote: J Cliff Dyer: I'm in the camp that believes that 3/4 does indeed yield the integer 0, but should be spelled 3//4 when that is the intention. That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. That means most people. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. Of course. That's why I think you ought to spell it 3//4. Nobody gets confused when a strange operator that they've never seen before does something unusual. Average Jo off the street looks at python code and sees 3/4, and immediately thinks aha! .75! Show the same person 3//4, and she'll think, A double slash? I'd better check the documentation--or better yet, play with it a little in the interactive interpreter. Or Jo thinks // is a typo, and helpfully fixes it. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to turn a list of tuples into a dictionary?
On Feb 26, 11:00 am, mrstephengross [EMAIL PROTECTED] wrote: Let's say I've got a list of tuples, like so: ( ('a', '1'), ('b', '2'), ('c', '3') And I want to turn it into a dictionary in which the first value of each tuple is a key and the second value is a value, like so: { 'a' - '1', 'b' - '2', 'c' - '3' } Is there a way to do this with a single line of code? Currently, I'm doing it like this: tuples = ( ('a', '1'), ('b', '2'), ('c', '3') d = {} for option,value in tuples: d[option] = value Thanks, --Steve I'd hand-code it manually, by linking a C extension. Or dict( iterable ). http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-21 -- http://mail.python.org/mailman/listinfo/python-list
Python-URL! - weekly Python news and links (Feb 26)
QOTW: I think not enough is made of the fact that Python combines legibility and power better than any other platform. - Michael Tobis http://mail.python.org/pipermail/advocacy/2008-February/000518.html C++ is a compile-time, type-checked language, which means it is totally safer for newbies than Python. Yep, your big company is totally safe with newbie C++ programmers. - Carl Banks Python 2.5.2 final released: http://groups.google.com/group/comp.lang.python/browse_thread/thread/51e4846fd2bbe43b/ An article in CIO.com about Python in the enterprise inspires a long thread which compares Python to other languages: http://groups.google.com/group/comp.lang.python/browse_thread/thread/c1af9a1a8ebab6c6/ The 2007 LinuxQuestions.org Members Choice Awards selects Python as Programming Language of the Year. http://www.linuxquestions.org/questions/2007-linuxquestions.org-members-choice-awards-79/programming-language-of-the-year-610237/ Why double underscores are used internally: http://groups.google.com/group/comp.lang.python/browse_thread/thread/554c125c85820917/ Function overloading (dispatching by argument type): http://groups.google.com/group/comp.lang.python/browse_thread/thread/745fd73f322bb0c4/ Globals vs Singleton: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6a690983694fedf3/ Threads vs. Continuations: http://groups.google.com/group/comp.lang.python/browse_thread/thread/fe6b9e21b965f25c/ Return value of assignment statements, plus the meaning of variable in Python terms: http://groups.google.com/group/comp.lang.python/browse_thread/thread/2563e7efd842cf95/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish the efforts of Python enthusiats: http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to
Re: Article of interest: Python pros/cons for the enterprise
Nicola Musatti [EMAIL PROTECTED] writes: http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?EAN=97802... Read the title. This is about C Traps and Pitfalls. Whoops, I think the same author wrote a similar one about C++. He hangs out here on this newsgroup sometimes. I didn't notice that my keyword search got the wrong one. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to turn a list of tuples into a dictionary?
mrstephengross [EMAIL PROTECTED] writes: ( ('a', '1'), ('b', '2'), ('c', '3') I'm not trying to be snide, but have you tried looking in the manual? See http://python.org/doc/lib and look at the section about built-in types, if you want to know things about tuples or dictionaries. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to turn a list of tuples into a dictionary?
On Tue, 26 Feb 2008 09:00:54 -0800 (PST) mrstephengross [EMAIL PROTECTED] wrote: Let's say I've got a list of tuples, like so: ( ('a', '1'), ('b', '2'), ('c', '3') And I want to turn it into a dictionary in which the first value of each tuple is a key and the second value is a value, like so: { 'a' - '1', 'b' - '2', 'c' - '3' } Is there a way to do this with a single line of code? Currently, I'm doing it like this: tuples = ( ('a', '1'), ('b', '2'), ('c', '3') d = {} for option,value in tuples: d[option] = value How about this? d = dict(tuples) -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
Nicola Musatti wrote: On Feb 24, 5:25 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Jeff Schwab [EMAIL PROTECTED] writes: there's actually a published book specifically about C++ pitfalls. Mercy, a whole book? http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?EAN=97802... Read the title. This is about C Traps and Pitfalls. Although it shows its age, it's still worth reading. Unfortunately from its price you'd think it was handwritten. That is not a book about C++ pitfalls. That is a book about C pitfalls. They really are two very different languages. Don't get me wrong, C++ has pitfalls of its own -- perhaps the worst of which is writing C and thinking it's C++ in anything other than a superficial sense. But there are vanishingly few cases that could lead to out-of-bounds indexes or dangling pointers anymore. -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
D'Arcy J.M. Cain wrote: On Tue, 26 Feb 2008 08:55:22 -0500 J. Cliff Dyer [EMAIL PROTECTED] wrote: Of course. That's why I think you ought to spell it 3//4. Nobody gets confused when a strange operator that they've never seen before does something unusual. Average Jo off the street looks at python code and sees 3/4, and immediately thinks aha! .75! Show the same person 3//4, Why do we care what A. Jo thinks? I would hope that A. Programmer Jo would see int {OP} int and assume int result. A. Jo isn't going to be debugging anything. If 3/4 ever returned 0.75 in any language I would drop that language. Prepare to drop Python then, as this will be the default behavior in 3.x regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On Tue, 26 Feb 2008 09:01:57 -0800 Jeff Schwab [EMAIL PROTECTED] wrote: Or Jo thinks // is a typo, and helpfully fixes it. Exactly. Programmers who use a language without learning it are apt to do anything. -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Article of interest: Python pros/cons for the enterprise
Jeff Schwab wrote: Nicola Musatti wrote: On Feb 24, 5:25 am, Paul Rubin http://[EMAIL PROTECTED] wrote: Jeff Schwab [EMAIL PROTECTED] writes: there's actually a published book specifically about C++ pitfalls. Mercy, a whole book? http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?EAN=97802... Read the title. This is about C Traps and Pitfalls. Although it shows its age, it's still worth reading. Unfortunately from its price you'd think it was handwritten. That is not a book about C++ pitfalls. That is a book about C pitfalls. Whoops! You already pointed that out. My mistake! As you probably know, Andrew Koenig is reportedly the individual who first proposed argument-dependent lookup, a.k.a Koenig lookup, for C++. -- http://mail.python.org/mailman/listinfo/python-list
Re: is there enough information?
On Feb 26, 10:59 am, Preston Landers [EMAIL PROTECTED] wrote: On Feb 26, 1:45 am, [EMAIL PROTECTED] wrote: Two options occurred to me, which the first showed up in the earlier extremely skeletal and cryptic post: Perhaps you would be more likely to get the kind of help you seem to want if you refrained from posting cryptic and skeletal messages. The fact that many other people have pointed this out to you as of late would tend to suggest you are trolling, i.e. intentionally trying to foster miscommunication and threads that do nothing to advance anyones understanding. And regarding your other recent post about trying to find a solution to the problem of immutable types... Due to the above reasons you are unlikely to influence the design of the core language with half-baked stream of consciousness ramblings. These belong in your LiveJournal, not in c.l.python. If you have a problem you need help with, please read this entire document about 3 times before posting anything else: http://catb.org/~esr/faqs/smart-questions.html Specifically this: http://catb.org/~esr/faqs/smart-questions.html#beprecise and this: http://catb.org/~esr/faqs/smart-questions.html#goal Ugh, very well. You call for an explanation. Back home, the original post would be interesting, so I wrote it. Whatever reactions other people have to them is information that is unavailable to me. I don't know you. I'm rather irked by a proportion of posts, but for my part, it's hard to get me to point a finger. I am not a troll. I want a sustainable, healthy, productive, educational, informative relationship with frequenters of c.l.p, the Python community at large, and anyone who has anything non-negative to contribute. If you are wanting to see how I react to hostility, just ask. I'll fake it for you, but only for a second at a time. Now, what help is it that you believe I seem to want? All I asked for was, ideas. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading a keypress
Dennis Lee Bieber wrote: On Mon, 25 Feb 2008 17:48:21 -0800, Jeff Schwab [EMAIL PROTECTED] declaimed the following in comp.lang.python: What about curses? http://docs.python.org/lib/module-curses.html http://adamv.com/dev/python/curses/ I don't consider needing a 3rd party library for Windows, but not for UNIX/Linux a portable method... The Python module docs claim to support DOS without any kind of extension. I don't know how well (or whether) it works with new versions of Windows. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to turn a list of tuples into a dictionary?
How about this? d = dict(tuples) Aha! I hadn't realized it could be so simple. --Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: Indentation and optional delimiters
[EMAIL PROTECTED]: It's Unpythonic to compile a machine instruction out of a script. But maybe in the right situations, with the right constraints on a function, certain chunks could be native, almost like a mini- compilation. How much machine instruction do you want to support? This language is meant for newbies, or for very quick scripts, or for less bug-prone code, so optimizations are just a way to avoid such programs run 5 times slower than Ruby ones ;-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On 2008-02-26, Lie [EMAIL PROTECTED] wrote: I'm in the camp that believes that 3/4 does indeed yield the integer 0, but should be spelled 3//4 when that is the intention. That's creepy for people that are new to programming and doesn't know how CPUs work and are used to general mathematics. I don't know where you went to grade school, but where I went, we learned about integer division long before we learned about floating point. That means most people. I guess it must depend on where you went to shool. As programming language are now more accessible to regular people without specialized Computer Science degree, it is a just natural trend that computer arithmetic must be done in an expectable manner as seen by those general population not by people who holds a CS degree. -- Grant Edwards grante Yow! You were s'posed at to laugh! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How about adding rational fraction to Python?
On 2008-02-26, Steve Holden [EMAIL PROTECTED] wrote: D'Arcy J.M. Cain wrote: On Tue, 26 Feb 2008 08:55:22 -0500 J. Cliff Dyer [EMAIL PROTECTED] wrote: Of course. That's why I think you ought to spell it 3//4. Nobody gets confused when a strange operator that they've never seen before does something unusual. Average Jo off the street looks at python code and sees 3/4, and immediately thinks aha! .75! Show the same person 3//4, Why do we care what A. Jo thinks? I would hope that A. Programmer Jo would see int {OP} int and assume int result. A. Jo isn't going to be debugging anything. If 3/4 ever returned 0.75 in any language I would drop that language. Prepare to drop Python then, as this will be the default behavior in 3.x IIRC, That was the behavior in Pascal. If you wanted integer division you used the div operator. -- Grant Edwards grante Yow! I'm a nuclear at submarine under the visi.compolar ice cap and I need a Kleenex! -- http://mail.python.org/mailman/listinfo/python-list
Re: is there enough information?
On Feb 26, 11:13 am, [EMAIL PROTECTED] wrote: All I asked for was, ideas. Nope, you didn't. You said exactly this: Specify {...} Is it enough? and included a snipped of code that was not standalone, provided no context or explanatory information, and gave us no clue what you might be trying to accomplish. To me this does not qualify as asking for ideas. It's more like posting nonsense with a thin veneer that looks like it's intended to suggest there is some hidden meaning lurking within and that we are expected to play 20 questions with you to tease out whatever it is you might be getting at, presumably some brilliant gem of an insight that will cause everyone to question our basic intellectual assumptions in some profound philosophical epiphany. This has all the hallmarks of being a fun game for you but a waste of time for us. -- http://mail.python.org/mailman/listinfo/python-list