Re: mirroring files and data via http

2008-07-07 Thread Matt Nordhoff
Steve Potter wrote: > On Jul 6, 8:19 pm, Matt Nordhoff <[EMAIL PROTECTED]> wrote: >> Steve Potter wrote: >>> I'm working on a project to create a central administration interface >>> for several websites located on different physical servers. >>&g

Re: Confused yet again: Very Newbie Question

2008-07-07 Thread Matt Nordhoff
mcl wrote: > Why can I not the change the value of a variable in another class, > when I have passed it via a parameter list. > > I am sure I am being stupid, but I thought passed objects were Read/ > Write In Python, there are names which are bound to objects. Doing "foo = bar" and then "foo = s

Re: Confused yet again: Very Newbie Question

2008-07-07 Thread Matt Nordhoff
mcl wrote: > On 7 Jul, 13:09, Jeff <[EMAIL PROTECTED]> wrote: >> When you call c3.createJoe(c1.fred), you are passing a copy of the >> value stored in c1.fred to your function. Python passes function >> parameters by value. The function will not destructively modify its >> arguments; you must exp

Re: I am looking for svn library(module)

2008-07-07 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Hi, > > I am looking fo svn library(module) which is used in the svn- > mailer(http://opensource.perlig.de/svnmailer/) project. Does anybody > know where can I find it(download url)? This is information which I > received from python error: > > from svn import core as s

Re: Confused yet again: Very Newbie Question

2008-07-07 Thread Matt Nordhoff
Jerry Hill wrote: > On Mon, Jul 7, 2008 at 7:30 AM, mcl <[EMAIL PROTECTED]> wrote: >> I did not think you had to make the distinction between 'byvar' and >> 'byref' as in Basic. > > Python does not use "call by value" or "call by reference" semantics. > Instead, python's model is "call by object".

Re: redirecting output of process to a file using subprocess.Popen()

2008-07-10 Thread Matt Nordhoff
skeept wrote: > On Jul 9, 7:32 pm, [EMAIL PROTECTED] wrote: >> I am trying to redirect stderr of a process to a temporary file and >> then read back the contents of the file, all in the same python >> script. As a simple exercise, I launched /bin/ls but this doesn't >> work: >> >> #!/usr/bin/python

Re: SimpleJson is slow .... is there any C Compiled version ?

2008-07-25 Thread Matt Nordhoff
sanket wrote: > Hello All, > > I have created an API which fetches some data from the database. > I am using simplejson to encode it and return it back. > > Now the problem is that, this API is being called for millions of > times in a sequence. > I ran a profiler and saw that most of the time is

Re: How easy is it to install python as non-root user?

2008-04-03 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Does python install fairly easily for a non-root user? > > I have an ssh login account onto a Linux system that currently > provides Python 2.4.3 and I'd really like to use some of the > improvements in Python 2.5.x. > > So, if I download the Python-2.5.2.tgz file is it

Re: Help replacing os.system call with subprocess call

2008-04-07 Thread Matt Nordhoff
David Pratt wrote: > Hi. I am trying to replace a system call with a subprocess call. I have > tried subprocess.Popen and subprocess.call with but have not been > successful. The command line would be: > > svnadmin dump /my/repository > svndump.db > > This is what I am using currently: > > os.

Re: Help replacing os.system call with subprocess call

2008-04-07 Thread Matt Nordhoff
Matt Nordhoff wrote: > David Pratt wrote: >> Hi. I am trying to replace a system call with a subprocess call. I have >> tried subprocess.Popen and subprocess.call with but have not been >> successful. The command line would be: >> >> svnadmin dump /my/repository

Re: Help replacing os.system call with subprocess call

2008-04-07 Thread Matt Nordhoff
David Pratt wrote: > Hi David and Matt. I appreciate your help which has got me moving > forward again so many thanks for your reply. I have been using > subprocess.Popen a fair bit but this was the first time I had to use > subprocess to capture large file output. The trouble I was having was > wi

Re: Newbie: How to pass a dictionary to a function?

2008-04-07 Thread Matt Nordhoff
BonusOnus wrote: > How do I pass a dictionary to a function as an argument? > > > # Say I have a function foo... > def foo (arg=[]): > x = arg['name'] > y = arg['len'] > > s = len (x) > > t = s + y > > return (s, t) I assume you actually indented the body of the function? > # The dictionary:

Re: Destructor?

2008-04-08 Thread Matt Nordhoff
Gabriel Rossetti wrote: > Hello everyone, > > we are writing an application that needs some cleanup to be done if the > application is quit, normally (normal termination) or by a signal like > SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm > mistaken there is no guaran

Re: Destructor?

2008-04-08 Thread Matt Nordhoff
Matt Nordhoff wrote: > Gabriel Rossetti wrote: >> Hello everyone, >> >> we are writing an application that needs some cleanup to be done if the >> application is quit, normally (normal termination) or by a signal like >> SIGINT or SIGTERM. I know that the __de

Re: import statement convention

2008-04-08 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > By convention, I've read, your module begins with its import > statements. Is this always sensible? > > I put imports that are needed for testing in the test code at the end > of the module. If only a bit of the module has a visual interface, why > pollute the global nam

Re: Lists: why is this behavior different for index and slice assignments?

2008-04-22 Thread Matt Nordhoff
John Salerno wrote: >> replaces the elements in the slice by assigned elements. > > > I don't understand the second part of that sentence. I'm assuming "it" > refers to the list being assigned, "replaces the elements" is > self-evident, but what does "by assigned elements" refer to? It seems > wh

Re: library to do easy shell scripting in Python

2008-04-23 Thread Matt Nordhoff
Wow, this message turned out to be *LONG*. And it also took a long time to write. But I had fun with it, so ok. :-) Michael Torrie wrote: > Recently a post that mentioned a recipe that extended subprocess to > allow killable processes caused me to do some thinking. Some of my > larger bash script

Re: problem with unicode

2008-04-25 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Hi everybody, > > I'm using the win32 console and have the following short program > excerpt > > # media is a binary string (mysql escaped zipped file) > >>> print media > xワユロ[ヨ... > (works) > >>> print unicode(media) > UnicodeDecodeError: 'ascii' codec can't decode

Re: Is 2006 too old for a book on Python?

2008-04-25 Thread Matt Nordhoff
jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > t

Re: removing extension

2008-04-27 Thread Matt Nordhoff
Arnaud Delobelle wrote: > More simply, use the rsplit() method of strings: > path = r'C:\myimages\imageone.jpg' path.rsplit('.', 1) > ['C:\\myimages\\imageone', 'jpg'] > > path = r"C:\blahblah.blah\images.20.jpg" path.rsplit('.', 1) > ['C:\\blahblah.blah\\images.20', 'jpg'] >

Re: Am I missing something with Python not having interfaces?

2008-05-06 Thread Matt Nordhoff
Mike Driscoll wrote: > On May 6, 8:44 am, jmDesktop <[EMAIL PROTECTED]> wrote: >> Studying OOP and noticed that Python does not have Interfaces. Is >> that correct? Is my schooling for nought on these OOP concepts if I >> use Python. Am I losing something if I don't use the "typical" oop >> cons

Re: Simple question

2008-05-10 Thread Matt Nordhoff
Gandalf wrote: > my server is my computer and all i did way to install python on it. But what web server program are you using? Apache? IIS? Lighttpd? -- -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, are you ill?

2008-05-10 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > You > can't get out of the code block with pressing the Enter key; you have > to press Ctrl+Z (if you're in Linux) in order to get out of that code > block, which then throws you back to the Linux command line, but > before that it prints this line > > [1]+ Stopped

Re: Is using range() in for loops really Pythonic?

2008-05-10 Thread Matt Nordhoff
John Salerno wrote: > I know it's popular and very handy, but I'm curious if there are purists > out there who think that using something like: > > for x in range(10): > #do something 10 times > > is unPythonic. The reason I ask is because the structure of the for loop > seems to be for itera

Re: Python multimap

2008-08-27 Thread Matt Nordhoff
brad wrote: > Recently had a need to us a multimap container in C++. I now need to > write equivalent Python code. How does Python handle this? > > k['1'] = 'Tom' > k['1'] = 'Bob' > k['1'] = 'Joe' > ... > > Same key, but different values. No overwrites either They all must > be inserted into

Re: Process "Killed"

2008-08-28 Thread Matt Nordhoff
dieter wrote: > Hi, > > Overview > === > > I'm doing some simple file manipulation work and the process gets > "Killed" everytime I run it. No traceback, no segfault... just the > word "Killed" in the bash shell and the process ends. The first few > batch runs would only succeed with one or t

Re: compare unicode to non-unicode strings

2008-08-31 Thread Matt Nordhoff
Asterix wrote: > how could I test that those 2 strings are the same: > > 'séd' (repr is 's\\xc3\\xa9d') > > u'séd' (repr is u's\\xe9d') You may also want to look at unicodedata.normalize(). For example, é can be represented multiple ways: >>> import unicodedata >>> unicodedata.normalize('NFC',

Re: "AttributeError: 'module' object has no attribute 'getdefaultlocale'" on Python start

2008-09-09 Thread Matt Nordhoff
Barak, Ron wrote: > Hi Fellow Pythonians, > > I stated getting the following when starting Python (2.5.2 on Windows XP): > > C:\Documents and Settings\RBARAK>python -v > # installing zipimport hook > import zipimport # builtin > # installed zipimport hook > # D:\Python25\lib\site.pyc matches D:

Re: check if the values are prensent in a list of values

2008-09-09 Thread Matt Nordhoff
Emile van Sebille wrote: > flit wrote: >> Hello All, >> >> I will appreciate the help from the more skillfull pythonistas.. >> >> I have a small app that generates a sequence like >> >> 00341 >> 01741 >> 03254 > > Consider using a dict with sorted tuple keys, eg > > d = {} > > for seq in ['00341

Re: function return

2008-09-11 Thread Matt Nordhoff
Beema Shafreen wrote: > hi all, > > I have a script using functions , I have a problem in returning the > result. My script returns only one line , i donot know where the looping > is giving problem, Can any one suggest, why this is happening and let me > know how to return all the lines > > def

Re: function return

2008-09-11 Thread Matt Nordhoff
Gabriel Genellina wrote: > En Thu, 11 Sep 2008 10:59:10 -0300, Matt Nordhoff > <[EMAIL PROTECTED]> escribió: > >>>result = "%s\t%s\t%s" %(id,gene_symbol,ptms) >> >> This is very trivial, but you could change the above line to: >> &g

Re: manipulating files within 'for'

2008-09-12 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Ben Keshet: >> ...wrong. I thought I should omit the comma and didn't put it. I guess >> that stating the obvious should be the first attempt with beginners like >> me. Thanks for thinking about it (it's running perfect now). > > In CLisp, Scheme etc, lists such comma

Re: Gateway to python-list is generating bounce messages.

2008-09-12 Thread Matt Nordhoff
Steven D'Aprano wrote: > On Thu, 11 Sep 2008 17:27:33 +0200, Sjoerd Mullender wrote: > >> When mail messages bounce, the MTA (Message Transfer Agent--the program >> that handles mail) *should* send the bounce message to whatever is in >> the Sender header, and only if that header does not exist, s

Re: Gateway to python-list is generating bounce messages.

2008-09-12 Thread Matt Nordhoff
Grant Edwards wrote: > On 2008-09-12, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > >> I think you misunderstand. He's referring to the Sender >> header, not the From header. The messages the listbot sends >> out have a Sender header of >> "[EMAIL PR

Re: Schwartzian transform for tuple in list

2008-09-24 Thread Matt Nordhoff
Chris Rebert wrote: > On Wed, Sep 24, 2008 at 2:02 PM, David Di Biase <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I have a rather large list structure with tuples contained in them (it's >> part of a specification I received) looks like so: >> [(x1,y1,r1,d1),(x2,y2,r2,d2)...] >> >> The list can range f

Re: How to parse a string completely into a list

2008-09-24 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > On Sep 24, 9:44 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote: >> On Wed, Sep 24, 2008 at 8:30 PM, <[EMAIL PROTECTED]> wrote: >>> I want to take a long alpha-numeric string with \n and white-space and >>> place ALL elements of the string (even individual parts of a long >

Re: Are spams on comp.lang.python a major nuisance?

2008-09-26 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > I took over spam filter management for the python.org mailing lists a couple > months ago and made a few changes to the way the spam filter is trained. > Things seem to be at a reasonable level as far as I can tell (I see a few > spams leak through each day), though I was

Re: Variables with cross-module usage

2009-11-28 Thread Matt Nordhoff
the module object referred to by the name "one". Since there is only one instance of a given module*, the change is indeed reflected everywhere the "one" module is accessed. The problem is that argFunc does not modify (or replace) one.myList, as MRAB said. * Unless you do something strange like reload() or editing sys.modules or having module available under different names...or something. -- Matt Nordhoff -- http://mail.python.org/mailman/listinfo/python-list

Re: a list/re problem

2009-12-11 Thread Matt Nordhoff
', with the >> '*'s removed. >> >> So in the case above n would be ['nbh', 'jkjsdfjasd'] > > [s[1:-1] for s in l if (s[0] == s[-1] == '*')] s[0] and s[-1] raise an IndexError if l contains an empty string. Better something like: >>> [s[1:-1] for s in l if (s[:1] == s[-1:] == '*')] Or just the slightly more verbose startswith/endswith version. -- Matt Nordhoff -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about dir function

2009-12-19 Thread Matt Nordhoff
name "_builtins_" is not defined, as it says. You were probably looking for "__builtins__", with 2 underscores on each end, not just 1. BTW, "__builtins__" is a CPython implementation detail. If you want to play with built-in objects, you should import the __builtin__

Re: using time.gov to get the current time

2009-12-19 Thread Matt Nordhoff
Rick wrote: > Is there any way to get the current time from time.gov using urllib2 or > something similar? > > Does anyone have any examples of doing this? > > Thanks! > Rick King > Southfield MI Why isn't your local system's clock accurate enough? -- Matt N

Re: using time.gov to get the current time

2009-12-19 Thread Matt Nordhoff
Matt Nordhoff wrote: > Rick wrote: >> Is there any way to get the current time from time.gov using urllib2 or >> something similar? >> >> Does anyone have any examples of doing this? >> >> Thanks! >> Rick King >> Southfield MI > > Why i

Re: Another Sets Problem

2009-12-28 Thread Matt Nordhoff
here were, this is not one of those situations. -- Matt Nordhoff -- http://mail.python.org/mailman/listinfo/python-list

Re: getopt not raising exception

2010-01-10 Thread Matt Nordhoff
27;s not much of an option! You should use a regular argument and check len(args) or somesuch. Or, if you must keep it an "option", do something equivalent for that. BTW: Checked out optparse? It's bigger and sexier! -- Matt Nordhoff -- http://mail.python.org/mailman/listinfo/python-list

Re: for loop: range() result has too many items

2009-10-13 Thread Matt Nordhoff
Andre Engels wrote: [snip] > However, I think that the better Python way would be to use a generator: > > def infinite_numbergenerator(): > n = 0 > while True: > yield n > n += 1 > > for i in infinite_numbergenerator(): > ... That's what itertools.count() is for.

Re: for loop: range() result has too many items

2009-10-13 Thread Matt Nordhoff
Matt Nordhoff wrote: > Andre Engels wrote: > [snip] > >> However, I think that the better Python way would be to use a generator: >> >> def infinite_numbergenerator(): >> n = 0 >> while True: >> yield n >>

Re: problem with read() write()

2009-11-01 Thread Matt Nordhoff
Gertjan Klein wrote: > Alf P. Steinbach wrote: > >> So with 'w+' the only way to get garbage is if 'read' reads beyond the end >> of >> file, or 'open' doesn't conform to the documentation. > > It does read beyond the end of file. This is perhaps the way the > underlying C library works, but it

Re: Imitating "tail -f"

2009-11-21 Thread Matt Nordhoff
non-Linux users, but there it is. Too bad, because > inotify is pretty cool. > > Jason Some other operating systems have similar facilities, e.g. FSEvents on OS X. -- Matt Nordhoff -- http://mail.python.org/mailman/listinfo/python-list

Re: Six Minutes and fourty two seconds

2010-02-26 Thread Matt Nordhoff
Tobiah wrote: > Now that I use python, this is the amount of time > per day that I spend adding forgotten semicolons while > debugging other languages. You can fix that by not using other languages. :> -- Matt Nordhoff -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't define __call__ within __init__?

2010-03-10 Thread Matt Nordhoff
x27;t particularly expensive, it would look nicer to just use self.i and do "self.i == 0" in __call__. Not that it matters, but this is probably faster than your version, too, since it saves a method call. By the way, IIRC Python only looks up double-underscore methods on the class, not the instance. That's why you had to indirect through self.F. -- Matt Nordhoff -- http://mail.python.org/mailman/listinfo/python-list

<    1   2