Re: Getting around immutable default arguments for recursion

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 9:27 AM, dpapathanasiou denis.papathanas...@gmail.com wrote: Without the if priors: line just above the first return statement (a typo perhaps?), then yes, it would do what I want. Yes sorry it was :) a) a global should and need not be used. Passing the entire

Re: executing multiple functions in background simultaneously

2009-01-14 Thread James Mills
Speaking of Threading .. http://codepad.org/dvxwAphE Just a really interesting way of doing this :) cheers James -- -- Problems are solved by method -- http://mail.python.org/mailman/listinfo/python-list

process/thread instances and attributes

2009-01-14 Thread James Mills
Hey all, I have this concept I'm working on and here is the code... Problem is if you run this it doesn't terminate. I believe you can terminate it in the main process by calling a.stop() But I can't find a way for it to self terminate, ie: self.stop() As indicated by the code...

Re: Python 3 isinstance

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 1:03 PM, Lambert, David W (ST) lamber...@corning.com wrote: Overly terse. I do mean that this is illegal: isinstance(s, {str, bytes}) tuples have order, immutability, and the possibility of repeat items. A set is most reasonable in a mathematical sense. What's

Re: Does Python really follow its philosophy of Readability counts?

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 2:50 PM, Russ P. russ.paie...@gmail.com wrote: (..) One feature of Ada that I always thought was a good idea is the distinction between functions and procedures, where functions are guaranteed to not have side effects. But I don't think Ada allows advanced functional

Re: Does Python really follow its philosophy of Readability counts?

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 3:59 PM, Michele Simionato michele.simion...@gmail.com wrote: (...) It could just be an issue of practicality. Python is an industrial strength language with libraries for everything and you can use it for your daily work. There are nice little languages out there that

Re: 2to3 Help?

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 4:01 PM, marco.m.peter...@gmail.com wrote: I have Python 3.0. I tried to use the 2to3 program included with the interpreter to convert some scripts for Python 2.5 to Python 3.0 ones. When I try to start it form the Python command line, it says it is a syntax error.

Re: 2to3 Help?

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 4:17 PM, marco.m.peter...@gmail.com wrote: $ 2to3.py testscript.py File stdin, line 1 $ 2to3.py testscript.py ^ Syntax Error: Invalid Syntax Oh i see... You need to do 2 things: 1) Run 2to3 on the shell not the python interpreter. 2) Learn some basic UNIX.

Re: Does Python really follow its philosophy of Readability counts?

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 4:20 PM, Michele Simionato michele.simion...@gmail.com wrote: (...) I would be fine having something like pylint built-in in the language and running at every change of the source code (unless disabled with a command line switch). I think this is the only reasonable

Re: Does Python really follow its philosophy of Readability counts?

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 4:34 PM, Michele Simionato michele.simion...@gmail.com wrote: (...) There are lots of Python developers (and most of the core developers) that think the OO community is wrong about enforced encapsulation. Personally, I think in a few years everybody will realize the

Re: 2to3 Help?

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 4:32 PM, marco.m.peter...@gmail.com wrote: I tried to run it on the command prompt (I use Windows XP) but it doesn't work either. I did not realize you were using WIndows :) Normally most shells in the UNIX/Linux world start with a '$'. I opened the command prompt:

Re: why o/p is different ???

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 4:34 PM, asit lipu...@gmail.com wrote: I recently faced a peculiar o/p. My objective is to remove the command name(my script name) from sys.argv[0]. I coded like this If you _really_ want to remove your script_name from sys.argv, then do this: del sys.argv[0] If

Re: Standard IPC for Python?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 2:25 AM, Laszlo Nagy gand...@shopzeus.com wrote: The question is: what is the standard way to implement fast and portable IPC with Python? Are there tools in the standard lib that can do this? Certainly not standard by any means, but I use circuits (1). Two or more

Re: Standard IPC for Python?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 3:40 AM, Laszlo Nagy gand...@shopzeus.com wrote: Can anyone tell me if select.select works under OS X? Yes it does. cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: executing multiple functions in background simultaneously

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney catherine.m.moro...@jpl.nasa.gov wrote: I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. Currently I'm doing this by calling them as sub-processes executable from

Re: Programming friction

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:29 AM, killsto kilian...@gmail.com wrote: I'm trying to implement a basic user controlled sliding box with pygame. I have everything worked out, except for two things. Try the pygame mailing list :) cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: executing multiple functions in background simultaneously

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:35 AM, MRAB goo...@mrabarnett.plus.com wrote: The disadvantage of threads in Python (CPython, actually) is that there's the GIL (Global Interpreter Lock), so you won't get any speed advantage if the threads are mostly processor-bound. The OP didn't really say what

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:50 AM, Russ P. russ.paie...@gmail.com wrote: Here's the definition on the Wikipedia page for object oriented programming (and it does *not* sound like Python classes): Encapsulation conceals the functional details of a class from objects that send messages to it.

Re: problem calling method

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:28 AM, pieterprovo...@gmail.com wrote: class MyFrame(wx.Frame): def __init__(self, *args, **kwds): It might be helpful here if you called the parent __init__. Like so: class MyFrame(wx.Frame): def __init__(self, *args, **kwds): super(MyFrame,

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 12:27 PM, Paul Rubin http://phr.cx@nospam.invalid wrote: James Mills prolo...@shortcircuit.net.au writes: You do realize this is a model and not strictly a requirement. Quite a few things in Python are done merely by convention. Don't get caught up. But, if something

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 12:57 PM, Terry Reedy tjre...@udel.edu wrote: public = no leading underscore private = one leading underscore protected = two leading underscores Python uses encapsulation by convention rather than by enforcement. As mentioned previously this is not encapsulation, but

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:18 PM, Russ P. russ.paie...@gmail.com wrote: Yes, but the fact that you can approximate OO programming in a particular language does not make that language object oriented. You can approximate OO programming in C, but that does not mean that C is an OO language.

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:25 PM, Rhodri James rho...@wildebst.demon.co.uk wrote: I wouldn't violently object to having some means of policing class or module privacy, but it does have consequences. When it's a convention, you can break it; when it isn't, you can't, even if you do have good

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:31 PM, r rt8...@gmail.com wrote: public = no leading underscore private = one leading underscore protected = two leading underscores Python uses encapsulation by convention rather than by enforcement. Very well said Terry! I like that python does not force me to

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 1:50 PM, Carl Banks pavlovevide...@gmail.com wrote: 1. Wise people don't believe everything that is written on Wikipedia. 2. The person who wrote that line in Python.org is a wise person. Agreed. You know what? Computer science buzzwords mean jack squat to me. I

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 3:11 PM, Russ P. russ.paie...@gmail.com wrote: (...) Give me one use-case where you strictly require that members of an object be private and their access enforced as such ? You're kidding, right? Think about a ten-million line program being developed by 100

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 3:11 PM, Russ P. russ.paie...@gmail.com wrote: I think you are the one who is confused. Part of the problem here is that the term encapsulation has at least two widely used meanings (in the context of programming). In one sense, it just means grouping data and methods

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 3:35 PM, Russ P. russ.paie...@gmail.com wrote: You know what? The more I think about the kind of nonsense you and others are spouting here, the more annoyed I get. I will gladly agree that encapsulation may be more trouble than it's worth for small applications, maybe

Re: Does Python really follow its philosophy of Readability counts?

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 4:35 PM, Paul Rubin http://phr.cx@nospam.invalid wrote: James Mills prolo...@shortcircuit.net.au writes: Bare in mind also, that enfocing access control / policing as you called it has a performance hit as the machine (the Python vm) has to perform checks each time

Re: pep 8 constants

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 4:49 PM, Brendan Miller catph...@catphive.net wrote: PEP 8 doesn't mention anything about using all caps to indicate a constant. Is all caps meaning don't reassign this var a strong enough convention to not be considered violating good python style? I see a lot of

Re: Object help

2009-01-11 Thread James Mills
On Mon, Jan 12, 2009 at 9:49 AM, killsto kilian...@gmail.com wrote: Thanks. That makes sense. It helps a lot. Although, you spelled color wrong :P. color colour They are both correct depending on what country you come from :) Just curious, is there another way? How would I do this in c++

urllib2 - 403 that _should_ not occur.

2009-01-11 Thread James Mills
Hey all, The following fails for me: from urllib2 import urlopen f = urlopen(http://groups.google.com/group/chromium-announce/feed/rss_v2_0_msgs.xml;) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.6/urllib2.py, line 124, in urlopen return

Re: urllib2 - 403 that _should_ not occur.

2009-01-11 Thread James Mills
On Mon, Jan 12, 2009 at 12:58 PM, Philip Semanchuk phi...@semanchuk.com wrote: On Jan 11, 2009, at 8:59 PM, James Mills wrote: Hey all, The following fails for me: from urllib2 import urlopen f = urlopen(http://groups.google.com/group/chromium-announce/feed/rss_v2_0_msgs.xml

Re: urllib2 - 403 that _should_ not occur.

2009-01-11 Thread James Mills
On Mon, Jan 12, 2009 at 1:25 PM, Philip Semanchuk phi...@semanchuk.com wrote: Oooops, I guess it is my brain that's not working, then! Sorry about that. Nps. I tried your sample and got the 403. This works for me: (...) Some sites ban UAs that look like bots. I know there's a Java-based bot

Re: Object help

2009-01-11 Thread James Mills
On Mon, Jan 12, 2009 at 2:26 PM, killsto kilian...@gmail.com wrote: I was kidding. IMO, we Americans should spell color like everyone else. Heck, use the metric system too while we are at it. Yes well why don't you start up a rally and convince your brand new shiny government to catch up with

Re: Implementing file reading in C/Python

2009-01-09 Thread James Mills
On Fri, Jan 9, 2009 at 7:15 PM, Marc 'BlackJack' Rintsch bj_...@gmx.net wrote: print(Filesize : %d % (filesize)) print(Image size : %dx%d % (width, height)) print(Bytes per Pixel: %d % (blocksize)) Why parentheses around ``print``\s argument? In Python 3 ``print`` is a statement

Re: Implementing file reading in C/Python

2009-01-09 Thread James Mills
On Fri, Jan 9, 2009 at 7:41 PM, Marc 'BlackJack' Rintsch bj_...@gmx.net wrote: Please read again what I wrote. Lol I thought 3 was a smiley! :) Sorry! cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing takes higher execution time

2009-01-08 Thread James Mills
On Thu, Jan 8, 2009 at 7:31 PM, Nick Craig-Wood n...@craig-wood.com wrote: (...) How many projects are you processing at once? And how many MB of zip files is it? As reading zip files does lots of disk IO I would guess it is disk limited rather than anything else, which explains why doing

Re: BadZipfile file is not a zip file

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 11:28 AM, webcomm rya...@gmail.com wrote: Hmm. When I open it in Windows or with 7-Zip, it contains a text file that has the data I would expect it to have. I guess that alone doesn't necessarily prove it's a zip file? datum is something I'm downloading via a web

Re: Implementing file reading in C/Python

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 1:04 PM, Johannes Bauer dfnsonfsdu...@gmx.de wrote: Hello group, Hello. (...) Which takes about 40 seconds. I want the niceness of Python but a little more speed than I'm getting (I'd settle for factor 2 or 3 slower, but factor 30 is just too much). Can anyone point

Re: Implementing file reading in C/Python

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 3:13 PM, Johannes Bauer dfnsonfsdu...@gmx.de wrote: Uhh, yes, you're right there... I must admit that I was too lazy to include all the stat headers and to a proper st_size check in the C version (just a quick hack), so it's practically hardcoded. With files of exactly

Re: Best practice in organize classes into modules

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody narkewo...@gmail.com wrote: In C++/Java, people usually put one class into one file. What's the suggestion on this topic in Python? I so much interesting this especially when exception classes also involved. Normally i group related functionality

Re: Implementing file reading in C/Python

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 2:29 PM, James Mills prolo...@shortcircuit.net.au wrote: I shall attempt to optimize this :) I have a funny feeling you might be caught up with some features of Python - one notable one being that some things in Python are immutable. psyco might help here though

Re: Regular Expressions...

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 8:54 AM, Ken D'Ambrosio ken.dambro...@segway.com wrote: Hi, all. As a recovering Perl guy, I have to admit I don't quite get the re module. For example, I'd like to do a few things (I'm going to use phone numbers, 'cause that's what I'm currently dealing with):

Re: An idea of how to identify Israeli owned software companies

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 9:24 AM, Steve Holden st...@holdenweb.com wrote: (...) OK, that's enough non-Python ramblings for this thread. God I wish we could delete threads :) cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expressions...

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 10:03 AM, James Stroud jstr...@mbi.ucla.edu wrote: (...) Indeed it seems you are recovering from an especially bad case. I recommend two doses of the python cookbook per day for one to two months. Report back here after your first cycle and we'll tell you how you are

Re: multiprocessing vs thread performance

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 10:55 AM, Arash Arfaee erex...@gmail.com wrote: Hi All , HI :) Does anybody know any tutorial for python 2.6 multiprocessing? Or bunch of good example for it? I am trying to break a loop to run it over multiple core in a system. And I need to return an integer value as

subclassing multiprocessing.Process

2009-01-07 Thread James Mills
Hey all, Just a quick clarification on multiprocessing' Process object. If I were to subclass this, say: class Foo(Process): def foo(self): ... def run(self): ... Would the parent and child objects be identical ? That is, would the same methods of Foo exist in the child ?

Re: parallel and/or synchronous start/run/stop on multiple boxes

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 3:08 PM, Shane gshanemil...@verizon.net wrote: Consider a network of 3 fully-connected boxes i.e. every box as a TCP- IP connection to every other box. Suppose you start a python program P on box A. Is there a Python mechanism for P to send a copy of itself to box B or

asynchronous events with multithreading and multiprocessing with circuits

2009-01-07 Thread James Mills
Hi folks, For those interested, I have just completed implementing multiprocessing support for circuits (1). It has historically always had multithreading support. These components can be found in circuits.workers and are called: Thread and Process The reason these exist is to perform work, ie:

Re: asynchronous events with multithreading and multiprocessing with circuits

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 3:45 PM, James Mills prolo...@shortcircuit.net.au wrote: For those interested, I have just completed implementing multiprocessing support for circuits (1). (...) PS: circuits can be found on PyPi or here: http://trac.softcircuits.com.au/circuits/ The code/support I

Re: parallel and/or synchronous start/run/stop on multiple boxes

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 3:44 PM, Ned Deily n...@acm.org wrote: The multiprocessing module, new in the 2.6 standard library and available in PyPi as a backport to 2.4 and 2.5, supports managing of processes on both local and remote machines. The 2.6 module documentation has an example/demo of

Re: frontend + backend style application design

2009-01-07 Thread James Mills
On Thu, Jan 8, 2009 at 3:56 PM, Steven Woody narkewo...@gmail.com wrote: I am considering write an application, its core functionalities should be implemented in a command-line application with which a user can interact via its command line interface. This kind of command line interface can

Re: greenlets and how they can be used

2009-01-05 Thread James Mills
On Tue, Jan 6, 2009 at 4:39 AM, Benjamin Walkenhorst kry...@gmx.net wrote: James Mills wrote: On Sun, Jan 4, 2009 at 4:52 AM, Benjamin Walkenhorst kry...@gmx.net wrote: POE was one of the nicest software frameworks I have ever used, and I've been continuously frustrated by the lack

Re: Measuring bytes of packet sent from python application

2009-01-05 Thread James Mills
On Tue, Jan 6, 2009 at 8:26 AM, Kangkook Jee aixe...@gmail.com wrote: I'd like to measure number of bytes sent(or recv'd) from my python application. Does anyone have any idea how can I achieve this? I tried to do this by tracing some socket calls (send, sendto, sendAll) using 'metaclass'

Re: socket send help

2009-01-05 Thread James Mills
On Tue, Jan 6, 2009 at 10:49 AM, Bryan Olson fakeaddr...@nowhere.org wrote: I thought a firewall would block an attempt to bind to any routeable address, but not to localhost. So using INADDR_ANY would be rejected. No. My understanding is that firewalls block network traffic, not system

Re: socket send help

2009-01-05 Thread James Mills
On Wed, Dec 24, 2008 at 3:59 PM, greyw...@gmail.com greyw...@gmail.com wrote: (snip) If I run testserver.py via the cmd prompt in Windows XP and then the testclient.py program, I get the following error: Traceback (most recent call last): File C:\Python30\testclient.py, line 12, in module

Re: Is there a best linux distro for a python hobbyist?

2009-01-05 Thread James Mills
On Tue, Jan 6, 2009 at 11:11 AM, alex goretoy aleksandr.gore...@gmail.com wrote: +1 for ubuntu +1 for Ubuntu also (for the novice and ex-windows user(s)) +2 for CRUX (1) cheers James 1. http://crux.nu/ -- http://mail.python.org/mailman/listinfo/python-list

Re: greenlets and how they can be used

2009-01-04 Thread James Mills
On Sun, Jan 4, 2009 at 4:52 AM, Benjamin Walkenhorst kry...@gmx.net wrote: Back when I was still using Perl, there was - and still is, I guess - a really nice framework called POE, that allowed you to write event-driven state machines in a really easy and pleasant way. Under POE, EVERYTHING

Re: structuring a package?

2009-01-04 Thread James Mills
On Mon, Jan 5, 2009 at 10:17 AM, Torsten Mohr tm...@s.netic.de wrote: It looks natural to me to write in a code that uses the package: import graphic import graphic.square import graphic.circle That way i'd have to structure the code like this: graphic/ __init__,py (GraphicObject)

Re: Code coverage to Python code

2009-01-04 Thread James Mills
On Sun, Jan 4, 2009 at 9:35 PM, Hussein B hubaghd...@gmail.com wrote: What is the best code coverage tool available for Python? I like ot use nose with it's coverage plugin. easy_install nose easy_install co And I use the following in my top-level Makefile tests: @nosetests \

Re: Noob question: Is all this typecasting normal?

2009-01-04 Thread James Mills
On Mon, Jan 5, 2009 at 1:47 PM, sprad jsp...@gmail.com wrote: On Jan 3, 6:41 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: The OP comes from a Perl background, which AFAIK allows you to concat numbers to strings and add strings to numbers. That's probably the (mis) feature

Re: greenlets and how they can be used

2008-12-31 Thread James Mills
On Thu, Jan 1, 2009 at 9:24 AM, Aaron Brady castiro...@gmail.com wrote: (snip) I had a dream for a while that in a GUI framework, every event would spawn a unique thread. The GUI would remain responsive even while executing minor tasks. Of course, shaving a second off running time isn't

Re: get method

2008-12-30 Thread James Mills
On Tue, Dec 30, 2008 at 7:10 PM, Roel Schroeven rschroev_nospam...@fastmail.fm wrote: Hm, you just changed an O(n) algorithm to an O(n**2) algorithm. No big deal for short strings, but try your solution on a string with length 1 and see the difference. On my computer the O(n) version takes

Re: multiprocessing vs thread performance

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 12:29 AM, Aaron Brady castiro...@gmail.com wrote: James, Hi. I'm glad you asked; I never know how out there my comments are (but surmise that feedback is always a good thing). What I was thinking was, I didn't know Virtual Synchrony, and I've never used Erlang, but

[ANN]: circuits-1.0b1 released!

2008-12-30 Thread James Mills
Hi all, I'm pleased to announce the release of circuits-1.0b1 Overview == circuits is an event-driven framework with a focus on Component Software Architectures where System Functionality is defined in Components. Components communicate with one another by propagating events throughout the

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 9:15 AM, MRAB goo...@mrabarnett.plus.com wrote: (snip) A while back I posted a Python implementation of 'bag' (also called a multiset). The code would then become something like: What complexity is this ? cheers James --

Re: [ANN]: circuits-1.0b1 released!

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 10:00 AM, John Krukoff jkruk...@ltgc.com wrote: I'm curious, you've a number of comparisons to Twisted on your site FAQ section, but this sounds like a much closer project to Kamaelia (http://www.kamaelia.org/Home). Are these actually similar or am I missing something

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 10:22 AM, John Machin sjmac...@lexicon.net wrote: (snip) The crawl through the shrubbery looking for evidence approach stumbles on the actual code: Yes I found his implementation soon after :) Not bad actually... I wonder why bag() isn't shipped with the std lib -

Re: multiprocessing vs thread performance

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 8:42 AM, James Mills prolo...@shortcircuit.net.au wrote: (snip) As I continue to develop circuits and improve it's core design as well as building it's ever growing set of Components, I try to keep it as general as possible - my main aim though is distributed

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 10:49 AM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: What set module? Sorry I must have meant the collections module :) Adding a multi-set or bag class to the collections module would be a good idea though. Perhaps you should put in a feature request?

Re: get method

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 10:54 AM, MRAB goo...@mrabarnett.plus.com wrote: Occasionally someone posts here wanting to count items and solutions involving dict or defaultdict are suggested, and I think that a 'bag' class would be useful. The 'set' class was introduced first in a module, but it

greenlets and how they can be used

2008-12-30 Thread James Mills
Hey all, The greenlet from http://codespeak.net/py/dist/greenlet.html is a rather interesting way of handling flow of control. I can't seem to find anything else on the subject except for the above link and the most recent version 0.2 and it's tests. What can greenlet's be used for ? What

Re: How to get back a list object from its string representation?

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 2:46 PM, Harish Vishwanath harish.shas...@gmail.com wrote: Hello, Consider : li = [1,2,3] repr(li) '[1, 2, 3]' Is there a standard way to get back li, from repr(li) ? Normally you would use eval(..) however this is considered by many to be evil and bad practise

Re: MemoryError when list append... plz help

2008-12-30 Thread James Mills
(Sorry for top posting): You are mad! Why on God's earth would you want to create a list containing 60 MILLION elements ? What is the use case ? What are you solving ? You may have 4G of ram, but I very seriously doubt you have 4G of ram available to Python. I have no idea how many bytes of

Re: MemoryError when list append... plz help

2008-12-30 Thread James Mills
On Wed, Dec 31, 2008 at 4:17 PM, James Mills prolo...@shortcircuit.net.au wrote: I have no idea how many bytes of memory storing each element of a list consumes let alone each float object, but I assure you it's not going to be anywhere near that of 60494500 4-bytes spaces (do floats in C

Re: multiprocessing vs thread performance

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 12:52 AM, mk mrk...@gmail.com wrote: Hello everyone, After reading http://www.python.org/dev/peps/pep-0371/ I was under impression that performance of multiprocessing package is similar to that of thread / threading. However, to familiarize myself with both packages I

Re: get method

2008-12-29 Thread James Mills
your function now :) ... I want to show you a far simpler way to do this which takes advantage of Python's list comprehensions and mappings (which are really what dictionaries are): s = James Mills and Danielle Van Sprang dict([(k, len([x for x in s if x == k])) for k in s]) {'a': 5, ' ': 5, 'e

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:32 AM, James Mills prolo...@shortcircuit.net.au wrote: Ross, the others have informed you that you are not actually incrementing the count. I'll assume you've fixed your function now :) ... I want to show you a far simpler way to do this which takes advantage

Re: multiprocessing vs thread performance

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:34 AM, Aaron Brady castiro...@gmail.com wrote: The OP may be interested in Erlang, which Wikipedia (end-all, be-all) claims is a 'distribution oriented language'. I would suggest to the OP that he take a look at circuits (1) an event framework with a focus on

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:38 AM, Ross ross.j...@gmail.com wrote: I realize the code isn't counting, but how am I to do this without using an if statement as the problem instructs? I just gave you a hint :) cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: Python in C

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:32 AM, Chris Rebert c...@rebertia.com wrote: On Mon, Dec 29, 2008 at 5:22 PM, thmpsn@gmail.com wrote: snip 2. Have there been any suggestions in the past to rewrite Python's mainstream implementation in C++ (or why wasn't it done this way from the beginning)?

Re: get method

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 11:43 AM, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Dec 30, 2008 at 11:38 AM, Ross ross.j...@gmail.com wrote: I realize the code isn't counting, but how am I to do this without using an if statement as the problem instructs? I just gave you a hint

Re: multiprocessing vs thread performance

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 12:52 PM, Aaron Brady castiro...@gmail.com wrote: On Dec 29, 7:40 pm, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Dec 30, 2008 at 11:34 AM, Aaron Brady castiro...@gmail.com wrote: The OP may be interested in Erlang, which Wikipedia (end-all, be-all

Re: print a vs print '%s' % a vs print '%f' a

2008-12-29 Thread James Mills
On Tue, Dec 30, 2008 at 1:19 PM, David Cournapeau courn...@gmail.com wrote: (... snip ...) print '%f' % a # - print '1.#INF' Would this not be controlled by: 1. float(a) or a.__float__() 2. tp_print cheers James -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2008-12-28 Thread James Mills
On Mon, Dec 29, 2008 at 4:01 PM, scsoce scs...@gmail.com wrote: I have a function return a reference, and want to assign to the reference, simply like this: def f(a) return a b = 0 * f( b ) = 1* but the last line will be refused as can't assign to function call. In my thought ,

Re: How to represent a sequence of raw bytes

2008-12-22 Thread James Mills
On Mon, Dec 22, 2008 at 4:56 PM, Steven Woody narkewo...@gmail.com wrote: I thing \x11\x22\x33 in python is not the {0x11, 0x22, 0x33} in C. Since, a string in python is immutable, I can _not_ do something like: b[1] = \x55. And, how about char buf[200] in my original question? The

Re: Are Django/Turbogears too specific?

2008-12-22 Thread James Mills
On Tue, Dec 23, 2008 at 12:35 AM, Philip Semanchuk phi...@semanchuk.com wrote: On Dec 22, 2008, at 1:52 AM, Tino Wildenhain wrote: Philip Semanchuk wrote: ... I prefer Mako over the other template languages I've seen. From what I can tell Mako is nearly identical to all other template

Re: Event Driven programming - Doubts

2008-12-22 Thread James Mills
On Tue, Dec 23, 2008 at 12:57 AM, Kottiyath n.kottiy...@gmail.com wrote: Hi, I have been looking at Twisted and lately Circuits as examples for event driven programming in Python. Wonderful! :) circuits that is :) Even though I understood how to implement the code in these and what is

Re: Python is slow

2008-12-22 Thread James Mills
On Tue, Dec 23, 2008 at 4:42 AM, cm_gui cmg...@gmail.com wrote: i am referring mainly to Python for web applications. Python is slow. Please just go away. You are making an embarrassment of yourself. --JamesMills -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-12-21 Thread James Mills
On Mon, Dec 22, 2008 at 4:47 AM, r rt8...@gmail.com wrote: Could not have said it better myself Luis, i stay as far away from C as i can. But there are usage cases for it. If you can think of 1 typical common case I'll reward you with praise! :) By the way, by common and typical I mean

Re: Twisted for non-networking applications

2008-12-21 Thread James Mills
On Mon, Dec 22, 2008 at 4:27 AM, Kottiyath n.kottiy...@gmail.com wrote: Hi all, Is it a good idea to use Twisted inside my application, even though it has no networking part in it? Basically, my application needs lots of parallel processing - but I am rather averse to using threads - due

Re: Are python objects thread-safe?

2008-12-21 Thread James Mills
On Mon, Dec 22, 2008 at 4:51 AM, RajNewbie raj.indian...@gmail.com wrote: Say, I have two threads, updating the same dictionary object - but for different parameters: Please find an example below: a = {file1Data : '', file2Data : ''} Now, I send it to two different threads, both of

Re: Threads, forks, multiplexing - oh my

2008-12-21 Thread James Mills
On Mon, Dec 22, 2008 at 11:36 AM, Thomas Raef tr...@ebasedsecurity.com wrote: I now want to run multiple instances of this program on a client, after receiving the command line and args from a broker, dispatcher, whatever you want to call it. You can use the subprocess module. I've read

Re: New Python 3.0 string formatting - really necessary?

2008-12-21 Thread James Mills
On Mon, Dec 22, 2008 at 11:37 AM, alex23 wuwe...@gmail.com wrote: On Dec 21, 10:11 am, r rt8...@gmail.com wrote: Most of the complaints i hear are the redundant use of self. Which I lamented about but have become accustom(brainwashed) to it. I would remove this if it where up to me. It's a

Re: Twisted for non-networking applications

2008-12-21 Thread James Mills
On Mon, Dec 22, 2008 at 3:25 PM, RajNewbie raj.indian...@gmail.com wrote: I was unable to see documentation explaining this - so asking again. Documentation is available here: http://trac.softcircuit.com.au/circuits/wiki/docs And here: pydoc circuits The code itself is heavily documented. I'm

Re: importing csv file into sqlite

2008-12-19 Thread James Mills
On Fri, Dec 19, 2008 at 8:32 PM, Peter Otten __pete...@web.de wrote: James Mills wrote: values = ,.join([\%s\ % x for x in line]) print INSERT INTO %s %s VALUES (%s); % (table, fields, values) http://xkcd.com/327/ It's a tool! Not one meant to be used publicly from untrusted users. Free

Re: importing csv file into sqlite

2008-12-18 Thread James Mills
@klia: You could have had this done hours ago had you taken my suggestion, used my tool and just piped it into sqlite3 on the command line. --JamesMills -- -- Problems are solved by method -- http://mail.python.org/mailman/listinfo/python-list

Re: socket and subprocess problem

2008-12-18 Thread James Mills
On Thu, Dec 18, 2008 at 8:00 PM, Bryan Olson fakeaddr...@nowhere.org wrote: I'd swear James copied my response, except his came first. Even the formatting came out similar. I hadn't seen his response when I wrote mine, and wouldn't have bothered posing the same thing again. Great minds think

Re: Which sparse matrix package?

2008-12-18 Thread James Mills
On Fri, Dec 19, 2008 at 8:18 AM, Martin Manns mma...@gmx.net wrote: Hi: Hi, I am writing a spreadsheet application in Python What's wrong with pyspread ? [ ... snip ... ] The dict that I tried out is of the type: {(1,2,3): 2323, (1,2,545): 2324234, ... } It is too slow for my

<    1   2   3   4   5   6   >