Re: English-like Python

2009-01-15 Thread James Mills
On Fri, Jan 16, 2009 at 11:02 AM, The Music Guy wrote: > Just out of curiousity, have there been any attempts to make a version > of Python that looks like actual English text? I mean, so much of Python > is already based on the English language that it seems like the next > natural step would be

multiprocessing vs. distributed processing

2009-01-15 Thread James Mills
I've noticed over the past few weeks lots of questions asked about multi-processing (including myself). For those of you new to multi-processing, perhaps this thread may help you. Some things I want to start off with to point out are: "multiprocessing will not always help you get things done fast

Re: [Python-Dev] multiprocessing vs. distributed processing

2009-01-16 Thread James Mills
On Fri, Jan 16, 2009 at 6:30 PM, Matthieu Brucher wrote: > 2009/1/16 James Mills : >> I've noticed over the past few weeks lots of questions >> asked about multi-processing (including myself). > > Funny, I was going to blog about this, but not just for Python. > >

Re: problem in implementing multiprocessing

2009-01-16 Thread James Mills
On Fri, Jan 16, 2009 at 7:16 PM, gopal mishra wrote: > I create two heavy objects sequentially without using multipleProcessing > then creation of the objects takes 2.5 sec.if i create these two objects in > separate process then total time is 6.4 sec. > > i am thinking it is happening due to the

Re: multiprocessing vs. distributed processing

2009-01-16 Thread James Mills
On Fri, Jan 16, 2009 at 10:15 PM, Jesse Noller wrote: > That being said, there is no reason why you could not use it in > conjunction with something like Kamaelia, pyro, $ipc mechanism/etc. And also circuits (1). circuits has full implementations of Thread and Process components. circuits also ha

Re: process/thread instances and attributes

2009-01-16 Thread James Mills
On Fri, Jan 16, 2009 at 10:33 PM, Jesse Noller wrote: (...) > Personally, rather then using a value to indicate whether to run or > not, I would tend to use an event to coordinate start/stop state. The reason I implemented workers.Thread and workers.Process this way is basically so taht long-run

Re: Event Handling and Signal-Slot Mechanism

2009-01-18 Thread James Mills
On Mon, Jan 19, 2009 at 1:10 PM, Steven Woody wrote: > Python has Signal-Slot mechanism, why he still need another mechanism > Event Handling? And, in some cases, it seems only Event Handling > mechanism is available, for example closeEvent(). For what case and > for what reason, the python thin

Re: problem in implementing multiprocessing

2009-01-18 Thread James Mills
On Mon, Jan 19, 2009 at 3:50 PM, gopal mishra wrote: > i know this is not an io - bound problem, i am creating heavy objects in the > process and add these objects in to queue and get that object in my main > program using queue. > you can test the this sample code > import time > from multiproces

Re: Event Handling and Signal-Slot Mechanism

2009-01-19 Thread James Mills
On Mon, Jan 19, 2009 at 5:49 PM, Steven Woody wrote: > I am reading mark summerfield's book Rapid GUI Programming with Python > and Qt, chapter 6. In the example code, it inserted customized > behavior when user selects file->exit by overriding closeEvent() event > handler, but in other context, w

Re: function to find the modification date of the project

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 7:44 AM, Joe Strout wrote: > This isn't a question, but something I thought others may find useful (and > if somebody can spot any errors with it, I'll be grateful). > > We had a case recently where the client was running an older version of our > app, and didn't realize it

Re: function to find the modification date of the project

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 8:39 AM, James Mills wrote: > On Tue, Jan 20, 2009 at 7:44 AM, Joe Strout wrote: >> This isn't a question, but something I thought others may find useful (and >> if somebody can spot any errors with it, I'll be grateful). >> >> We had

Re: function to find the modification date of the project

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 9:19 AM, Joe Strout wrote: > James Mills wrote: > >> You know you could just store a __version__ >> attribute in your main library (__init__.py). :) > > What, and update it manually? I don't trust myself to remember to do that > every time

Re: function to find the modification date of the project

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 9:20 AM, Joe Strout wrote: > Yes, and presumably if some power user did this, then that would be the > intended effect. Not sure why they'd do that, but they must have a good > reason -- who am I to stop them? Actually I'm fairly certain there -could- potentially be tools

Re: defining class functions

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 10:08 AM, Astan Chee wrote: > Hi, > I have two classes in python that are in two different files/python scripts. > Class A uses Class B like this: > class B(object): > def function1(self,something): > pass > def function2(self,something): > print "hello one"

Re: ifconfig in python

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 10:28 AM, Nehemiah Dacres wrote: > Is ther an easy way to get the resolved ip address of the machine a script > is running on? socket.gethostbyname(socket.gethostname) has only returned > the ip address of my loop back interface ... not very usefull. That's because your /e

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

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 12:07 PM, Russ P. wrote: >> Russ, I think _you_ are missing the point. >> If the attribute is already public, why does it need properties? Why would a >> programmer go to the trouble of adding them manually, just to get one level >> of >> indirection for an already public

Re: ifconfig in python

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 12:48 PM, Ned Deily wrote: > Also, since the subject is on my brain at the moment, how to find "the > address" is not the right question to ask. These days most systems have > multiple network interfaces (Ethernet, WiFi, dialup, et al) running > multiple protocols, like IP

Re: function to find the modification date of the project

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 1:22 PM, Joe Strout wrote: > Any comments on the functioning and platform-independence of the code? Make it simpler :) cheers James -- http://mail.python.org/mailman/listinfo/python-list

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

2009-01-19 Thread James Mills
On Tue, Jan 20, 2009 at 2:39 PM, Luis Zarrabeitia wrote: > This line would make a lot more sense if you were talking about Java's getters > and setters, or about a language where accessing a property is different than > accessing an attribute (which would make little sense). If properties already

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 1:18 PM, Russ P. wrote: > Since when is no one is allowed to suggest a potential improvement to > a product unless they are willing to implement it themselves? Imagine > what the world would be like if such a rule applied to all products. Maybe nobody wants what you want ?

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 9:11 AM, Russ P. wrote: > Rather than waste more time replying to your post, Let me just refer > you to an excellent post that you may have missed earlier in this > thread by Mr. D'Aprano: > > http://groups.google.com/group/comp.lang.python/msg/d684d43b64a6e35a I'll finish

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 2:50 PM, Russ P. wrote: >> My mistake for using "trivial" instead, I didn't realise it would trip >> up your pedantry. > > Your mistake for being a moron. But it seems to happen regularly, > doesn't it. How much more of my time are you going to waste, loser? I'm sorry Russ

Re: How to write a simple shell loop in python?

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 3:12 PM, Saul Spatz wrote: > Strange. I don't have an explanation, but experiment shows that if you > change print "$ ", to print "$ " (that is, leave out the comma) then the > leading blank is not printed. This behavior doesn't depend on the "print > input" statement's b

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 3:20 PM, Russ P. wrote: (...) > Let me explain, moron. I don't need enforced data hiding for the > prototype I am working on now, because it's only a prototype that will > be converted into another more suitable language for the end product. > I am just interested in the i

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 3:26 PM, Russ P. wrote: > I die? That sounds like a threat. I should report you for that, loser. > Are you going to stalk me now, loser? It's an expression you fool. > Oh, and does your software engineering professor agree with you that > Python is perfectly suitable for

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 3:47 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > James Mills writes: >> I guarantee that this is not the case, only that those that >> actually -do- use python for large scale projects or even mission >> critical or safe

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 3:51 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > James Mills writes: >> Actually - in case you are perfectly unaware - programming >> languages -do not- bare meaning to such systems nor have >> an impact on their suitabi

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 4:08 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "Programming languages -do not- bare meaning to such systems nor have > an impact on their suitability or unsuitability" (I presume you mean > "bear" not "bare") is a far stronger and stupider statement than one >

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 4:32 PM, Russ P. wrote: > But you did make some rather outlandish statements. I had written > this: > >> I suggest you call Boeing and tell them that encapsulation is more >> trouble than it's worth for their 787 flight software. But please >> don't do it if you ever wish t

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 4:49 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "Today, Boeing uses about 500,000 lines of Ada to fly its commercial > 747 400 in subsystem components, critical certification, and human > safety features. Two of the three largest systems on the 747, or 43 > per

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

2009-01-20 Thread James Mills
On Wed, Jan 21, 2009 at 4:55 PM, Russ P. wrote: > On Jan 20, 10:24 pm, alex23 wrote: >> This is pretty much what I had in mind when I said before that I >> believed such concerns could be addressed externally of the >> interpreter. Thankfully I thought to check Activestate before knocking >> up m

Re: list subsetting

2009-01-21 Thread James Mills
On Thu, Jan 22, 2009 at 11:35 AM, blueiur wrote: > i think it's best way > lst = [0, 1, 3.14, 20, 8, 8, 3.14] > len( filter(lambda x: x > 3.13 and x < 3.15, lst) ) > 2 I prefer this way (cleaner): >>> lst = [0, 1, 3.14, 20, 8, 8, 3.14] >>> len([x for x in lst if 3.13 < x < 3.15]) 2 >>> cheers J

Re: Formal specification and proof (was : Does Python really follow its philosophy of "Readability counts"?)

2009-01-22 Thread James Mills
On Thu, Jan 22, 2009 at 8:42 PM, Ricardo Aráoz wrote: (...) > What I've seen engineers do when they need extra safety is to put in place > independently developed and operated redundant systems, at least three, and > the system will do whatever two of the independent systems agree on. So I > gues

Re: Adding a field to a 'foreign' object from the outside

2009-01-22 Thread James Mills
On Fri, Jan 23, 2009 at 1:19 PM, atleta wrote: > I'm working with a callback API (a DBus one) and I'd need to store > some state between the calls somewhere. I know that it's possible to > extend an object with fields after creation, so I could just store my > data in the session object that is pa

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

2009-01-22 Thread James Mills
On Fri, Jan 23, 2009 at 3:22 PM, Russ P. wrote: (...) > My understanding is that the vast majority of Python software is > provided as open source. Hence, I am a bit confused by all the talk > about the need for freedom and openness in Python. If data hiding were > enforced, and you need access t

Re: optparse question

2009-01-26 Thread James Mills
On Tue, Jan 27, 2009 at 11:02 AM, Pat wrote: (...) > What does it take to pass single parameter to a program? > http://docs.python.org/library/optparse.html stated that programs always > have options. Is that so? What about "dir /s"? Sample code: #!/us

Re: Method returning an Iterable Object

2009-01-26 Thread James Mills
On Tue, Jan 27, 2009 at 1:16 PM, Anjanesh Lekshminarayanan wrote: > But how come a raise StopIteration in the next() method doesnt need to > be caught ? It works without breaking. Because this exception is specially dealt with when iterating over an iterator. The "raise StopIteration" is what cau

Re: shutil module (directory input)

2009-01-26 Thread James Mills
On Tue, Jan 27, 2009 at 1:48 PM, klia wrote: > i am trying to tweak the current codes so that later when i call it from the > terminal i can provide sourcefile and the destination file rather being > fixed in the code.becuase now i have to specify the sourcefile and the > destinationfile in codes

Re: optparse with numpy.array?

2009-01-26 Thread James Mills
On Tue, Jan 27, 2009 at 3:45 PM, Johan Ekh wrote: > Thank you Robert, > but what if I just want to create an array interactively, e.g. like m = > array([1.0, 2.0, 3.0]), and pass it > to my program? I tried extending optparse with a new type as explained in > the link you gave me > but I was not

Re: optparse with numpy.array?

2009-01-26 Thread James Mills
On Tue, Jan 27, 2009 at 4:01 PM, Johan Ekh wrote: > Thank you James, > but I just can't optparse to accept an array, only integers, floats ans > strings. > > My code looks like this > > from optparse import OptionParser > parser = OptionParser() > parser.add_option('-t', '--dt', action='store', ty

Re: Why doesn't eval of generator expression work with locals?

2009-01-27 Thread James Mills
On Wed, Jan 28, 2009 at 9:31 AM, Fabio Zadrozny wrote: > Anyone knows why the code below gives an error? > > global_vars = {} > local_vars = {'ar':["foo", "bar"], 'y':"bar"} > print eval('all((x == y for x in ar))', global_vars, local_vars) y is undefined in your generator expression. Why are yo

Re: Recommendation for a small web framework like Perl's CGI::Application to run as CGI?

2009-01-27 Thread James Mills
On Wed, Jan 28, 2009 at 10:15 AM, excord80 wrote: > Well, let's see. I don't need a templating library, since -- as you > pointed out -- I can just use Python's own. I don't need a db > interface (can just make my own dbapi calls if needed). Don't need url > mapping (can just use mod_rewrite rules

Re: Addition of multiprocessing ill-advised? (was: Python 3.0.1)

2009-01-27 Thread James Mills
On Wed, Jan 28, 2009 at 1:49 PM, Ben Finney wrote: > Steve Holden writes: >> I think that [Python 2.6 was a rushed release]. 2.6 showed it in the >> inclusion (later recognizable as somewhat ill-advised so late in the >> day) of multiprocessing […] Steve: It's just a new package - it used to be

Re: Python Application Server

2009-01-27 Thread James Mills
On Wed, Jan 28, 2009 at 2:23 PM, Adi Eyal wrote: > Could anyone recommend a python application server? My application > consists mainly of long running background processes that need to > communicate with each other. Features on my wishlist include, process > pooling (each process will in general

Re: Python Application Server

2009-01-27 Thread James Mills
On Wed, Jan 28, 2009 at 2:42 PM, James Mills wrote: (...) > Might I recommend circuits (1) as a general purpose > framework that you can build your application on top of. > > circuits will allow you to communicate with long-running > background processes, communicate between proc

Re: Addition of multiprocessing ill-advised? (was: Python 3.0.1)

2009-01-28 Thread James Mills
Jesse: Can I mail you off-list regarding multiprocessing ? cheers James -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list

Re: Function Application is not Currying

2009-01-28 Thread James Mills
On Thu, Jan 29, 2009 at 10:28 AM, alex23 wrote: > On Jan 29, 7:32 am, Xah Lee wrote: >> But he is really a asshole, and >> take every chance to peddle his book. > > As opposed to really being an asshole and peddling one's website at > every opportunity? It would seem that Xah Lee suffers from a

Re: Does the Python community really follow the philospy of "Community Matters?"

2009-01-29 Thread James Mills
On Fri, Jan 30, 2009 at 3:38 PM, r wrote: > This observation leads me to two scientific and common sense synopsis. > Either nobody here gives a rats pa'toote about Python, and/or they are > all just a bunch of gutless worms too afraid to stand up to the 10 or > so Perl/Ruby leeches who's infestati

Re: Python package Management GUI - New Project on Sourceforge

2009-02-01 Thread James Mills
On Mon, Feb 2, 2009 at 2:17 PM, David Lyon wrote: > Hi all, > > I am pleased to announce that we have started a new python > project on sourceforge. > > Python Package Manager > pythonpkgmgr.sourceforge.net > > The goal is to provide a cross platform GUI tool that will > vastly simplify loading

Re: Python package Management GUI - New Project on Sourceforge

2009-02-01 Thread James Mills
On Mon, Feb 2, 2009 at 2:57 PM, David Lyon wrote: >> To be truly cross platform, consider >> using the Tcl/Tk toolkit rather tahn >> wxWindows. Why ? Because Tcl/TK >> is packaged and provided along with >> most Python distributions. > > I agree with your point.. > > The problem is that Tcl/TK is

Re: Is the subprocess module robust enough in 2.4?

2009-02-05 Thread James Mills
On Fri, Feb 6, 2009 at 2:20 AM, wrote: > The subprocess module was added in Python 2.4. I'm running 2.4.5 at work. > I know it's seen many bugfixes since first released. Is the version in 2.4 > robust enough to use in preference to os.popen and friends? "Is xxx rubust enough" is an untangible

Re: global name 'sqrt' is not defined

2009-02-05 Thread James Mills
On Fri, Feb 6, 2009 at 10:48 AM, Nick Matzke wrote: > (PS: Is there a way to force a complete reload of a module, without exiting > ipython? Just doing the import command again doesn't seem to do it.) m = __import__("mymobile") reload(m) cheers James -- http://mail.python.org/mailman/listinfo/p

Re: Using multiprocessing from a Windows service

2009-02-05 Thread James Mills
On Fri, Feb 6, 2009 at 3:21 PM, Volodymyr Orlenko wrote: > In the patch I submitted, I simply check if the name of the supposed module > ends with ".exe". It works fine for my case, but maybe this is too general. > Is there a chance that a Python module would end in ".exe"? If so, maybe we > shoul

Re: Propagating function calls

2009-02-10 Thread James Mills
On Wed, Feb 11, 2009 at 11:02 AM, Noam Aigerman wrote: > Suppose I have a python object X, which holds inside it a python object Y. > How can I propagate each function call to X so the same function call in Y > will be called, i.e: > > X.doThatFunkyFunk() > > Would cause > > Y.doThatFunkyFunk() N

Re: can multi-core improve single funciton?

2009-02-10 Thread James Mills
On Wed, Feb 11, 2009 at 2:21 PM, oyster wrote: > My real purpose is to know "whether multi-core can help to improve the > speed of a common function". But I know definitely that the answer is > NO. As stated by others, and even myself, it is not possible to just "automagically" improve the execut

Re: HELP!...Google SketchUp needs a Python API

2008-12-01 Thread James Mills
This is my first post to this particular topic and my good friend alsex32 will know that I tend to steer away from large pointless conversation topics (for obvious reasons). @OP: Listen ... The best way you can support Python is to use Python. The best way you can promote Python is to encourage o

Re: Running a Python script from crontab

2008-12-02 Thread James Mills
Put your main function in a big try, except. Catch any and all errors and log them. Example: def main(): try: do_something() except Exception, error: log("ERROR: %s" % error) log(format_exc()) Hope this helps. cheers James On Wed, Dec 3, 2008 at 12:35 AM, Astley Le Jaspe

Re: HELP!...Google SketchUp needs a Python API

2008-12-02 Thread James Mills
Pssft r, it's I that needs to get laid :) --JamesMills On Tue, Dec 2, 2008 at 4:07 PM, r <[EMAIL PROTECTED]> wrote: > PS james, > > Since you are alex23's friend, do the world a favor...PLEASE GET ALEX > LAID...before it's too late! > -- > http://mail.python.org/mailman/listinfo/python-list >

Re: How to sort a list of file paths

2008-12-02 Thread James Mills
Hi Eriksson, It's nice to see people actually contribute what they've learned back to the community. Great problem, well thought out solution and congrats on the learning :) I can't say per say that I've actually run into a situation where I need to sort file paths in this way ... But if I do I'l

Re: HELP!...Google SketchUp needs a Python API

2008-12-02 Thread James Mills
On Wed, Dec 3, 2008 at 4:44 AM, Benjamin Kaplan <[EMAIL PROTECTED]> wrote: > > > On Tue, Dec 2, 2008 at 1:36 PM, Craig Allen <[EMAIL PROTECTED]> wrote: >> >> > Just remember thought that if you threat Python like a >> > hammer, suddenly everything will look like a bail. >> > >> >> don't you mean if

Re: HELP!...Google SketchUp needs a Python API

2008-12-02 Thread James Mills
You're a funny man r :) Good luck with your endeavours! I have a hard enough time convincing my work colleagues to use anything other than PHP for everything! Here PHP is the Hammer / Pitchfork! --JamesMills On Wed, Dec 3, 2008 at 8:16 AM, r <[EMAIL PROTECTED]> wrote: > OK...so here are the stat'

Re: generating a liste of characters

2008-12-03 Thread James Mills
On Thu, Dec 4, 2008 at 12:18 AM, Yves Dorfsman <[EMAIL PROTECTED]> wrote: > Is there any built in way to generate a list of characters, something > along the line of range('a'-'z') ? > > Right now I am using: > > chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 > chars += [ chr(l) for l i

Re: Don't you just love writing this sort of thing :)

2008-12-03 Thread James Mills
uggh no! On Thu, Dec 4, 2008 at 11:07 AM, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > for \ >Entry \ >in \ >sorted \ > ( >f for f in os.listdir(PatchesDir) if PatchDatePat.search(f) != None > ) \ > : >Patch = (open, > gzip.GzipFile)[Entry

Re: RELEASED Python 3.0 final

2008-12-03 Thread James Mills
On Thu, Dec 4, 2008 at 11:58 AM, alex23 <[EMAIL PROTECTED]> wrote: > On Dec 4, 11:51 am, Barry Warsaw <[EMAIL PROTECTED]> wrote: >> On behalf of the Python development team and the Python community, I >> am happy to announce the release of Python 3.0 final. > > Thanks to you and everyone involved f

Re: "as" keyword woes

2008-12-04 Thread James Mills
One of the things I'd like to point out here is what we've been learning in new job during Induction Training... That is, it's part of the coding standard and design standards to name variables sensibly. For instance, naming a variable "db" when it's really a "database" object is a no no. Instead

Re: "as" keyword woes

2008-12-04 Thread James Mills
On Thu, Dec 4, 2008 at 9:04 PM, Aaron Brady <[EMAIL PROTECTED]> wrote: [... snip ...] > Does the OP hold the following should be legal? > > if if or or: > and( for ) > if not: > while( def ) I most certainly hope not! :) --JamesMills -- -- -- "Problems are solved by method" -- http://mail.py

Re: pretty strange behavior of "strip"

2008-12-04 Thread James Mills
On Fri, Dec 5, 2008 at 9:35 AM, Guy Doune <[EMAIL PROTECTED]> wrote: test=['03.html', '06.html', 'questions.html', '04.html', 'toc.html', '01.html', '05.html', '07.html', '02.html', '08.html'] test > ['03.html', '06.html', 'questions.html', '04.html', 'toc.html', '01.html', > '05.htm

Re: infering the number of args a function takes at runtime

2008-12-07 Thread James Mills
On Mon, Dec 8, 2008 at 2:45 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > On Sun, Dec 7, 2008 at 8:39 PM, sniffer <[EMAIL PROTECTED]> wrote: >> hi all, >> i am a python newbie, in a project currently doing i need to find out >> the number of arguments that a function takes at runtime.? Is this >> p

Re: A question about reference in Python.

2008-12-07 Thread James Mills
Hi, This is really really really pointless code and a really really pointless exercise, but nonetheless, here is a very very basic and minimal implementation of what you're expecting. This should almost *never* be done in Python! Python is a superior dynamic programming language, but it's NOT C!

Re: A question about reference in Python.

2008-12-07 Thread James Mills
On Mon, Dec 8, 2008 at 4:13 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > The following three lines serve no purpose and can only lead to confusion: >> value = None >> prev = None >> next = None You are absolutely right :) Updated code: #!/home/jmills/bin/python -i class Node(object):

Re: A question about reference in Python.

2008-12-07 Thread James Mills
On Mon, Dec 8, 2008 at 4:25 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > No apology necessary of course, i just didn't want the newbie OP to > pick up any bad Python coding habits. Apologies that I might have > phrased my criticism a bit harshly. No not at all :) I do use class variables in some

Re: Strengths and weaknesses of Pygame vs. pyglet vs. PyOpenGL?

2008-12-08 Thread James Mills
On Mon, Dec 8, 2008 at 6:31 PM, alex23 <[EMAIL PROTECTED]> wrote: > On Dec 8, 2:26 pm, illume <[EMAIL PROTECTED]> wrote: >> pygame is simpler to learn, since it doesn't require you to know how >> to create classes or functions. > > I'm not sure if I'd be quick to tout that as an advantage... :) Ne

Re: A question about reference in Python.

2008-12-08 Thread James Mills
In case the OP is interested here is a more complete implementation (others are welcome to comment): http://codepad.org/drIhqb7Z Enjoy :) cheers James -- -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner trying to understand functions.

2008-12-08 Thread James Mills
On Mon, Dec 8, 2008 at 11:32 PM, simonh <[EMAIL PROTECTED]> wrote: > That works fine. Then I've tried to use functions instead. The first > two work fine, the third fails: [ ... snip ... ] Try this: def getName(): name = input('Please enter your name: ') print('Hello', name) return name

Re: Beginner trying to understand functions.

2008-12-08 Thread James Mills
On Tue, Dec 9, 2008 at 12:24 AM, cadmuxe <[EMAIL PROTECTED]> wrote: > i think we should use raw_input('Please enter your name: ') instead of > input('Please enter your name: ') Good point :) OP: Please take notes :) cheers James -- -- -- "Problems are solved by method" -- http://mail.python.org

Re: Beginner trying to understand functions.

2008-12-08 Thread James Mills
On Tue, Dec 9, 2008 at 12:46 AM, Peter Otten <[EMAIL PROTECTED]> wrote: > I think the OP is using Python 3.0. What used to cause trouble Well of course he/she/it is! I'm too blind to have noticed that! :) --JamesMills -- -- -- "Problems are solved by method" -- http://mail.python.org/mailman/l

Re: List Problem

2008-12-09 Thread James Mills
On Wed, Dec 10, 2008 at 3:40 PM, dongzhi <[EMAIL PROTECTED]> wrote: > If I execute part[1], I have got 'a'. If I execute part[2], I have > got ' '. But, if I execute part[1::2], I have got ['a', '', '']. I > don't know why. Please tell me why. Perhaps you meant: part[1:2] pydoc list This will

Re: cx_Oracle issues

2008-12-10 Thread James Mills
On Thu, Dec 11, 2008 at 2:48 AM, huw_at1 <[EMAIL PROTECTED]> wrote: > Any tips - i have never seen this error before but am guessing that > the value being returned is too big for the buffer size set for the > cursor. the procedure fetches data from a LOB. > > Any suggestions/confirmations? Could

Re: Python is slow

2008-12-10 Thread James Mills
@em_gui: You are outrightly wrong. Why ? Python's VM is not slow! In fact it's quite fast. What does tend to be slow is sloppy poorly designed code. Django/Turbogears (sorry for any devs reading this) are large frameworks with a lot of complexity - and yes they tend to be a little cumbersome and s

Re: How can I understan the "for" here?

2008-12-11 Thread James Mills
On Fri, Dec 12, 2008 at 12:44 AM, Kermit Mei <[EMAIL PROTECTED]> wrote: > I can't understand the second sentence because of the "for ... in". > I consider that the syntactics of "for" should be: > > for k,v in params.items(): > .. > > But there's no a colon here, why it can work? It's called

Re: Bidirectional Networking

2008-12-11 Thread James Mills
Have a look at circuits. http://trac.softcircuit.com.au/circuits/ It's a general purpose event-driven framework with a focus on Component architectures and has a good set of Networking Components, specifically: circuits.lib.sockets * TCPServer * TCPClient * UDPServer * UDPClient (alias of UDP

Re: Bidirectional Networking

2008-12-12 Thread James Mills
Just as a matter of completeness for my own suggestion, here is my implementation of your code (using circuits): cheers James -- import random from circuits import listener, Event, Manager from circuits.lib.sockets import TCPServer, TCPClient class Server(TCPServer):

Re: XMPP xmpppy - User Authorization

2008-12-14 Thread James Mills
On Sun, Dec 14, 2008 at 3:47 PM, Henson wrote: > In my own bot, using the latest xmpppy, I've been printing everything > going to the message handler to the screen. I've yet to see a > 'subscribe' string. Has this changed? No this hasn't changed. This is the string you need to check for. It doe

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-14 Thread James Mills
On Mon, Dec 15, 2008 at 9:03 AM, Fuzzyman wrote: > It seems to me to be a generally accepted term when an application > stops due to an unhandled error to say that it crashed. it == application Yes. #!/usr/bin/env python from traceback import format_exc def foo(): print

Re: Python is slow

2008-12-14 Thread James Mills
On Mon, Dec 15, 2008 at 2:44 PM, Benjamin Kaplan wrote: > On Sun, Dec 14, 2008 at 11:38 PM, cm_gui wrote: >> >> hahaha, do you know how much money they are spending on hardware to >> make >> youtube.com fast??? > > Obviously not enough to get to the point where it's cheaper to have the > programm

Re: Python is slow

2008-12-14 Thread James Mills
On Mon, Dec 15, 2008 at 2:59 PM, James Mills wrote: > On Mon, Dec 15, 2008 at 2:44 PM, Benjamin Kaplan > wrote: >> On Sun, Dec 14, 2008 at 11:38 PM, cm_gui wrote: >>> >>> hahaha, do you know how much money they are spending on hardware to >>> make >

Re: Python is slow

2008-12-15 Thread James Mills
On Mon, Dec 15, 2008 at 5:26 PM, Andreas Kostyrka wrote: > So to summarize, Python is fast enough for even demanding stuff, and > when done correctly even number crunching or binary parsing huge files > or possible in competitive speeds. But you sometime need a developer > that can wield the tool

Re: Having Issues with CMD and the 'python' command

2008-12-15 Thread James Mills
"cmd" has _nothing_ to do with Python. --JamesMills -- -- "Problems are solved by method" On Mon, Dec 15, 2008 at 10:51 PM, Lamonte Harris wrote: > Every time I start cmd on windows it requires me to "set > path=%path%;C:\python26" why? I'm getting annoyed... > > -- > http://mail.python.org/m

Re: parse C expression?

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 9:48 AM, Torsten Mohr wrote: > Hi, > > i found some examples when googling for the subject but nothing really > matched. > > Is there a standard module available that lets me parse a syntax like "C" > with numbers, operators, braces, variables and function calls? Try pypar

Re: ethical questions about global variables

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 12:45 PM, Giampaolo Rodola' wrote: > Hi, > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > variable named "use_gmt_times" to decide whether the server has to > return times in GMT or localtime but I'm not sure if it is a good idea > because of the "e

Re: Copying files in directory

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 12:49 PM, wrote: > I'm writing a project management system, and I need the ability to > accept a directory name and move its contents to another directory. > Can someone give me a code sample that will handle this? I can't find > any "copying" functions in os or os.path.

Re: socket and subprocess problem

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 3:30 PM, wrote: > Guys thanks to point it out. > Yes, it's a race problem. I tried sleep long enough, then I can > connect to the socket. I should add code to try to connect to the > socket for a given time out. This is where event-driven approaches become really useful :

Re: Python is slow

2008-12-16 Thread James Mills
n Wed, Dec 17, 2008 at 8:24 AM, r wrote: >> What kind of performance problem have you find in python that makes >> you so unhappy? >> What are you going to do with all the extra speed provided by c++ (a >> Hello World! ?)... > > Still no reply from cm_gui, he must have googled "C hello world" :D

Re: Python is slow

2008-12-16 Thread James Mills
On Wed, Dec 17, 2008 at 9:08 AM, r wrote: > What about all the crap you had to go through just to get output? > Python wins Yes I can't say I really enjoy writing C (at all!) _except_ in the case where I may need to optimise some heavy computation. But then again with multi-core CPUs these days a

Re: Free place to host python files?

2008-12-16 Thread James Mills
On Wed, Dec 17, 2008 at 10:25 AM, Chris Rebert wrote: > I'll plug Bitbucket (http://bitbucket.org/). It gives you 150MB of > Mercurial hosting for free, along with a bug tracker and wiki. And I > hear it's implemented using Django. FreeHG (http://freehg.org) is pretty good too :) cheers James --

Re: How to modify a program while it's running?

2008-12-16 Thread James Mills
On Wed, Dec 17, 2008 at 11:26 AM, Steven D'Aprano wrote: >> So I'd like to restructure my app so that it can stay running and stay >> logged in, yet I can still update and reload at least most of the code. >> But I'm not sure what's the best way to do this. Should I move the >> reloadable code in

Re: How to modify a program while it's running?

2008-12-16 Thread James Mills
@Aaron Your code and suggestion is way too complicated. Just register your objects. When you need to reload your module, destroy the existing objects and re-creat them. This works well assuming you have a stable running core that maintains the connection and that code doesn't change much. --Jame

Re: The rule of literal string

2008-12-17 Thread James Mills
On Thu, Dec 18, 2008 at 9:25 AM, Chris Rebert wrote: > As I stated previously, the key rule is: > > eval(repr(something)) == something This rule is only true for basic data types; For example: >>> eval(repr(1)) == 1 True >>> eval(repr([1, 2, 3])) == [1, 2, 3] True >>> eval(repr({"a": 1, "b": 2,

Re: importing csv file into sqlite

2008-12-17 Thread James Mills
27;s the source to my csv2sql.py tool (1): #!/usr/bin/env python # Module: csv2sql # Date: 14th September 2008 # Author: James Mills, prologic at shortcircuit dot net dot au """csv2sql Tool to convert CSV data file

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

<    1   2   3   4   5   6   >