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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: OT: Can;'t find a Mozilla user group

2009-06-03 Thread Matt Nordhoff
Anthra Norell wrote: > I can't run Firefox and Thunderbird without getting these upgrade > ordering windows. I don't touch them, because I have reason to suspect > that they are some (Russian) virus that hijacks my traffic. Occasionally > one of these window pops up the very moment I hit a key and

Re: confused with subprocess.Popen

2009-05-09 Thread Matt Nordhoff
Soumen banerjee wrote: > Hello, > for a certain app, i used to use a command: > os.system("soundwrapper espeak -f line.txt") > now, if i wanted to kill espeak, i would have to run: > os.system("killall espeak") > since the subprocess module allows sending SIGKILL to the process, i > decided to swit

Re: Simple way of handling errors

2009-05-07 Thread Matt Nordhoff
Steven D'Aprano wrote: > On Wed, 06 May 2009 20:21:38 -0700, TomF wrote: > >>> The only reason you would bother going to the time and effort of >>> catching the error, printing your own error message, and then exiting, >>> is if you explicitly want to hide the traceback from the user. >> Well, to

Re: Use of Unicode in Python 2.5 source code literals

2009-05-03 Thread Matt Nordhoff
Uncle Bruce wrote: > I'm working with Python 2.5.4 and the NLTK (Natural Language > Toolkit). I'm an experienced programmer, but new to Python. > > This question arose when I tried to create a literal in my source code > for a Unicode codepoint greater than 255. (I also posted this > question in

Re: print(f) for files .. and is print % going away?

2009-04-30 Thread Matt Nordhoff
Esmail wrote: > Hello all, > > I use the print method with % for formatting my output to > the console since I am quite familiar with printf from my > C days, and I like it quite well. > > I am wondering if there is a way to use print to write > formatted output to files? > > Also, it seems like

Re: JSON and Firefox sessionstore.js

2009-04-24 Thread Matt Nordhoff
Steven D'Aprano wrote: > On Thu, 23 Apr 2009 05:08:35 +0100, I V wrote: > >> For something with at least a vague air of credibility to it, somebody >> who appears to be a Mozilla developer comments on their bug tracker, >> that sessionstore.js isn't "pure JSON" (though he only identifies the >> pa

Re: Scrap Posts

2009-04-09 Thread Matt Nordhoff
Avi wrote: > Hey Folks, > > I love this group and all the awesome and python savvy people who post > here. However I also see some dumb posts like 'shoes' or something > related to sex :( > > What can we do about crap like this? Can we clean it up? Or atleast > flag some for removal. > > Moderat

Re: safe eval of moderately simple math expressions

2009-04-09 Thread Matt Nordhoff
Joel Hedlund wrote: > Hi all! > > I'm writing a program that presents a lot of numbers to the user, and I > want to let the user apply moderately simple arithmentics to these > numbers. One possibility that comes to mind is to use the eval function, > but since that sends up all kinds of warning f

Re: Detecting Binary content in files

2009-03-31 Thread Matt Nordhoff
ritu wrote: > Hi, > > I'm wondering if Python has a utility to detect binary content in > files? Or if anyone has any ideas on how that can be accomplished? I > haven't been able to find any useful information to accomplish this > (my other option is to fire off a perl script from within m python

Re: UnicodeEncodeError - opening encoded URLs

2009-03-27 Thread Matt Nordhoff
D4rko wrote: > Hi! > > I have a problem with urllib2 open() function. My application is > receiving the following request - as I can see in the developement > server console it is properly encoded: > > [27/Mar/2009 22:22:29] "GET /[blahblah]/Europa_%C5%9Arodkowa/5 HTTP/ > 1.1" 500 54572 > > Then

Re: unsubscribe to send daily mails

2009-03-26 Thread Matt Nordhoff
Sudheer Rapolu wrote: > Hello > > Please unsubscribe to send daily mails to me. > > Warm Regards > Sudheer > > > > > -- > http://mail.python.org/mailman/listinfo/python-list See the link in the signature of every message

Re: download x bytes at a time over network

2009-03-17 Thread Matt Nordhoff
Saurabh wrote: > Heres the reason behind wanting to get chunks at a time. > Im actually retrieving data from a list of RSS Feeds and need to > continuously check for latest posts. > But I dont want to depend on Last-Modified header or the pubDate tag > in . Because a lot of feeds just output date('

Re: print - bug or feature - concatenated format strings in a print statement

2009-03-17 Thread Matt Nordhoff
bdb112 wrote: > Thanks for all the replies: > I think I see now - % is a binary operator whose precedence rules are > shared with the modulo operator regardless of the nature of its > arguments, for language consistency. > I understand the arguments behind the format method, but hope that the > sli

Re: Set & Frozenset?

2009-03-09 Thread Matt Nordhoff
Alan G Isaac wrote: >> Hans Larsen schrieb: >>> How could I "take" an elemment from a set or a frozenset > > > On 3/8/2009 2:06 PM Diez B. Roggisch apparently wrote: >> You iterate over them. If you only want one value, use >> iter(the_set).next() > > > I recall a claim that > >

Re: A tale of two execs

2009-02-23 Thread Matt Nordhoff
aha wrote: > Hello All, > I am working on a project where I need to support versions of Python > as old as 2.3. Previously, we distributed Python with our product, but > this seemed a bit silly so we are no longer doing this. The problem > that I am faced with is that we have Python scripts that

Re: Revision Control

2009-02-18 Thread Matt Nordhoff
Tim Chase wrote: >> -Mercurial (this is a big up and coming RCS) > > This is currently my favorite: good branching/merging, fast, written > mostly in Python (one C extension module, IIRC), and a simple interface > >> -Bazaar (written in Python. Also pretty new. I don't know about Windows >> s

Re: time: Daylight savings confusion

2009-02-05 Thread Matt Nordhoff
Tim H wrote: > On Win XP 64bit, Python 2.6.1 64bit > > I am trying to rename files by their creation time. > > It seems the time module is too smart for its own good here. > > time.localtime(os.path.getctime(f)) returns a value one hour off from > what windows reports for files that were created

Re: v = json.loads("{'test':'test'}")

2009-01-25 Thread Matt Nordhoff
Matt Nordhoff wrote: > gert wrote: >> On Jan 25, 11:16 pm, Дамјан Георгиевски wrote: >>>> raise ValueError(errmsg("Expecting property name", s, end)) >>>> http://docs.python.org/library/json.html >>>> What am I doing wrong ? >>> try

Re: v = json.loads("{'test':'test'}")

2009-01-25 Thread Matt Nordhoff
gert wrote: > On Jan 25, 11:16 pm, Дамјан Георгиевски wrote: >>> raise ValueError(errmsg("Expecting property name", s, end)) >>> http://docs.python.org/library/json.html >>> What am I doing wrong ? >> try this >> v = json.loads('{"test":"test"}') >> >> JSON doesn't support single quotes, only doub

Re: using subprocess module in Python CGI

2008-12-23 Thread Matt Nordhoff
ANURAG BAGARIA wrote: > Hello, > > I am a Python Newbie and would like to call a short python script via > browser using a CGI script, but initially I am trying to call the same > python script directly through python command line. The script intends > to perform a few command line in a pipe and I

Re: Free place to host python files?

2008-12-17 Thread Matt Nordhoff
James Mills wrote: > 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

Re: Using the `email' module in a bazaar plugin

2008-12-10 Thread Matt Nordhoff
Julian Smith wrote: > I don't seem to be able to use the `email' module from within a bazaar > plugin. Other modules work ok, e.g. nntplib. > > Here's my plugin, cut-down to show just the email problem: > > import sys > print 'sys.version', sys.version > > import nntplib > n = nntplib.NN

Re: html codes

2008-12-09 Thread Matt Nordhoff
Daniel Fetchinson wrote: > Hi folks, > > I came across a javascript library that returns all sorts of html > codes in the cookies it sets and I need my web framework (written in > python :)) to decode them. I'm aware of htmlentitydefs but > htmlentitydefs.entitydefs.keys( ) are of the form '&#xxx'

Re: generating a liste of characters

2008-12-04 Thread Matt Nordhoff
This is a slightly old post, but oh well... Shane Geiger wrote: > import string > alphabet=list(string.letters[0:26]) > print alphabet Most of the string module's constants are locale-specific. If you want the ASCII alphabet instead of the current language's, you need to use string.ascii_{letters

Re: Need help in understanding a python code

2008-11-16 Thread Matt Nordhoff
Benjamin Kaplan wrote: > If you really believe that, you haven't been following this list long > enough. Every terminology dispute always includes at least 1 Wikipedia > link. > > Also, you might want to look at this study: > http://news.cnet.com/2100-1038_3-5997332.html That study has been dispu

Re: Simple print to stderr

2008-10-27 Thread Matt Nordhoff
RC wrote: > By default the print statement sends to stdout > I want to send to stderr > > Try > > print "my meeage", file=sys.stderr > > I got >> SyntaxError: invalid syntax > > I try > > print "my message", sys.stderr > > But it still sent to stdout. > What is the syntax? > > I wouldn't und

Re: Antigravity module needed.

2008-10-17 Thread Matt Nordhoff
Terry Reedy wrote: > If Python added an antigravity module to the stdlib, > what should it say or do? See > http://xkcd.com/353/ > (and let your mouse hover). It was added 2 days ago. :-P -- -- http://mail.python.org/mailm

Re: Implementing my own Python interpreter

2008-10-13 Thread Matt Nordhoff
Ognjen Bezanov wrote: > Hello All, > > I am a third year computer science student and I'm the process of > selection for my final year project. > > One option that was thought up was the idea of implement my own version > of the python interpreter (I'm referring to CPython here). Either as a > pr

Re: Inefficient summing

2008-10-09 Thread Matt Nordhoff
Chris Rebert wrote: > I personally would probably do: > > from collections import defaultdict > > label2sum = defaultdict(lambda: 0) FWIW, you can just use: label2sum = defaultdict(int) You don't need a lambda. > for r in rec: > for key, value in r.iteritems(): > label2sum[key] +=

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: 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: 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: 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: 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: 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: 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: 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: 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: "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: 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: 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: 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: 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: 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: 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: 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
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: 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: 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: mirroring files and data via http

2008-07-06 Thread Matt Nordhoff
Steve Potter wrote: > I'm working on a project to create a central administration interface > for several websites located on different physical servers. > > You can think of the websites as a blog type application. My > administration application will be used to create new blog posts with > assoc

Re: Are the following supported in scipy.sparse

2008-07-01 Thread Matt Nordhoff
dingo_1980 wrote: > I wanted to know if scipy.sparse support or will support the following > functions which are available in scipy.linalg or scipy or numpy: > > Inverse > Cholesky > SVD > multiply > power > append > eig > concatenate > > Thanks... You should probably ask on a SciPy mailing list

Re: Using just the Mako part of Pylons?

2008-06-30 Thread Matt Nordhoff
John Salerno wrote: > Bruno Desthuilliers wrote: >> John Salerno a écrit : >>> I just installed Pylons onto my hosting server so I could try out >>> templating with Mako, but it seems a little more complicated than that. >> >> Err... Actually, it's certainly a little less complicated than that. >>

Re: Windows OS , Bizarre File Pointer Fact

2008-06-27 Thread Matt Nordhoff
Taygun Kekec wrote: > Code : > #!/usr/bin/python > # -*- coding: utf-8 -*- > import os > > if os.name == 'nt': > OS_Selection = 0 > elif os.name == 'posix': > OS_Selection = 1 > else : > OS_Selection = 1 > > del_cmd_os = ( "del","rm") > filelist = ("ddd.txt","eee.txt","fff.txt") > >

Re: Weird local variables behaviors

2008-06-20 Thread Matt Nordhoff
Sebastjan Trepca wrote: > Hey, > > can someone please explain this behavior: > > The code: > > def test1(value=1): > def inner(): > print value > inner() > > > def test2(value=2): > def inner(): > value = value > inner() > > test1() > test2() > > [EMAIL PROTEC

Re: images on the web

2008-06-19 Thread Matt Nordhoff
Matt Nordhoff wrote: > chris wrote: >> I'm creating a data plot and need to display the image to a web page. >> What's the best way of doing this without having to save the image to >> disk? I already have a mod_python script that outputs the data in >> tabul

Re: images on the web

2008-06-19 Thread Matt Nordhoff
chris wrote: > I'm creating a data plot and need to display the image to a web page. > What's the best way of doing this without having to save the image to > disk? I already have a mod_python script that outputs the data in > tabular format, but I haven't been able to find anything on adding a > g

Re: Simple Class/Variable passing question

2008-06-19 Thread Matt Nordhoff
monkeyboy wrote: > Hello, > > I'm new to python, and PythonCard. In the code below, I'm trying to > create a member variable (self.currValue) of the class, then just pass > it to a simple function (MainOutputRoutine) to increment it. I thought > Python "passed by reference" all variables, but the

Re: python/ruby question..

2008-06-19 Thread Matt Nordhoff
Mensanator wrote: > On Jun 18, 10:33�pm, "bruce" <[EMAIL PROTECTED]> wrote: >> hi... >> >> can someone point me to where/how i would go about calling a ruby app from a >> python app, and having the python app being able to get a returned value >> from the ruby script. >> >> something like >> >> tes

Re: reading from an a gzip file

2008-06-18 Thread Matt Nordhoff
Nader wrote: > Hello, > > I have a gzip file and I try to read from this file withe the next > statements: > > gunziped_file = gzip.GzipFile('gzip-file') > input_file = open(gunziped_file,'r') > > But I get the nezt error message: > > Traceback (most recent call last): > File "read_sfloc_fi

Re: write Python dict (mb with unicode) to a file

2008-06-14 Thread Matt Nordhoff
dmitrey wrote: > hi all, > what's the best way to write Python dictionary to a file? > > (and then read) > > There could be unicode field names and values encountered. > Thank you in advance, D. pickle/cPickle, perhaps, if you're willing to trust the file (since it's basically eval()ed)? Or JSON

Re: Python 3000 vs. Python 2.x

2008-06-13 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > As a new comer to Python I was wondering which is the best to start > learning. I've read that a number of significant features have > changed between the two versions. Yet, the majority of Python > programs out in the world are 2.x and it would be nice to understand >

Re: Does this path exist?

2008-05-28 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > I wanted to ask for ways to test whether a path exists. I usually use > os.path.exists(), which does a stat call on the path and returns True > if it succeeds, or False if it fails (catches os.error). But stat > calls don't fail only when a path doesn't exist. I see that,

Re: module import problem

2008-05-24 Thread Matt Nordhoff
Milos Prudek wrote: > I have a Kubuntu upgrade script that fails to run: > > File "/tmp/kde-root//DistUpgradeFetcherCore.py", > line 34, in > import GnuPGInterface > ImportError > No module named GnuPGInterface > > I got a folder /usr/share/python-support/python-gnupginterface with > a "GnuPGI

Re: Get all the instances of one class

2008-05-18 Thread Matt Nordhoff
Tommy Nordgren wrote: > class MyClass : a_base_class > memberlist=[] > > # Insert object in memberlist when created; > # note: objects won't be garbage collected until removed from memberlist. Just to say, if you wanted to go about it that way, you could avoid the garbage collection probl

Re: python without while and other "explosive" statements

2008-05-11 Thread Matt Nordhoff
ivo talvet wrote: > Hello, > > Is it possible to have a python which not handle the execution of > "while", "for", and other loop statements ? I would like to allow > remote execution of python on a public irc channel, so i'm looking for > techniques which would do so people won't be able to crash

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, 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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. 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: 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: Strange loop behavior

2008-03-26 Thread Matt Nordhoff
Gabriel Rossetti wrote: > Hello, > > I wrote a program that reads data from a file and puts it in a string, > the problem is that it loops infinitely and that's not wanted, here is > the code : > > d = repr(f.read(DEFAULT_BUFFER_SIZE)) > while d != "": > file_str.write(d) >

Re: Problem with PARAGRAPH SEPARATOR

2008-03-20 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Actually that's what I tried to do, for example: > outputString = myString.encode('iso-8859-1','ignore') > > However, I always get such messages (the character, that's causing problems > varies, but its always higher than 127 ofc...) > > 'ascii' codec can't decode byte

Re: Python Generators

2008-03-16 Thread Matt Nordhoff
mpc wrote: > def concatenate(sequences): > for seq in sequences: > for item in seq: > yield item You should check out itertools.chain(). It does this. You call it like "chain(seq1, seq2, ...)" instead of "chain(sequences)" though, which may be a problem for you. The res

Re: Unicode/UTF-8 confusion

2008-03-15 Thread Matt Nordhoff
Tom Stambaugh wrote: > I'm still confused about this, even after days of hacking at it. It's > time I asked for help. I understand that each of you knows more about > Python, Javascript, unicode, and programming than me, and I understand > that each of you has a higher SAT score than me. So please

Re: request for Details about Dictionaries in Python

2008-03-14 Thread Matt Nordhoff
Michael Wieher wrote: > I'm not sure if a well-written file/seek/read algorithm is faster than a > relational database... > sure a database can store relations and triggers and all that, but if > he's just doing a lookup for static data, then I'm thinking disk IO is > faster for him? not sure I w

  1   2   >