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: 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: 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: 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: 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: 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 wa

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

socket.AF_INET

2008-04-19 Thread Matt Herzog
Hi All. I'm trying to write a script that will send me an email message when my IP address changes on a specific NIC. On Linux, the script works. On FreeBSD, it fails with: Traceback (most recent call last): File "./pyifcheck.py", line 22, in if get_ip_address('xl0') == IPADDY: File "./pyifch

replacing text inplace

2008-04-20 Thread Matt Herzog
Hey All. I'm learning some python with the seemingly simple task of updating a firewall config file with the new IP address when my dhcpd server hands one out. Yeah, I know it's dangerous to edit such a file "in place" but this is just an exercise at this point. I would not mind using file han

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: License selection for free software

2008-05-06 Thread Matt Porter
On Tue, 06 May 2008 20:02:21 +0100, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: [EMAIL PROTECTED] (Ville M. Vainio) writes: [EMAIL PROTECTED] (Ville M. Vainio) writes: I don't think BSD/MIT like license really annoys anyone. Think python here ;-) Python's non-GPL license certainly is a

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: Simple questions on use of objects (probably faq)

2006-03-08 Thread Matt Hammond
4: Can I avoid the dummy counter i in the for loop and do something > like: > yz=[y[:-1].x-y[1:].x] yz = [e.x for e in y] yz.reverse() -- | Matt Hammond | R&D Engineer, BBC Research & Development, Tadworth, Surrey, UK. | http://kamaelia.sf.net/ | http://www.bbc.co.uk/rd/ -- http://

Re: Simple questions on use of objects (probably faq)

2006-03-08 Thread Matt Hammond
On Wed, 08 Mar 2006 11:29:29 -, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 08 Mar 2006 11:00:09 +, Matt Hammond wrote: > >>> 4: Can I avoid the dummy counter i in the for loop and do something >>> like: >>> yz=[y[:-1].x-y[1:].

Re: Any python HTML generator libs?

2006-03-10 Thread Matt Goodall
', 'color': 'blue'} > > print """\ > Section %(secnum)s > Elements of type %(type)s should be coloured %(color)s > """ % results Don't forget that you may need to escape the application's data for inclusion in HTML:

Re: Linear regression in NumPy

2006-03-18 Thread Matt Crema
the answer with shorter, more readable code. A one-liner! Is there a 'canned' routine to do it in numpy? btw, I am not advocating that one should not understand the concepts behind a 'canned' routine. If you do not understand this concept you should take 's advice and dive into a linear algebra book. It's not very difficult, and it is essential that a scientific programmer understand it. -Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: Linear regression in NumPy

2006-03-18 Thread Matt Crema
Matt Crema wrote: > Robert Kern wrote: > >> nikie wrote: >> >>> I still don't get it... >>> My data looks like this: >>> x = [0,1,2,3] >>> y = [1,3,5,7] >>> The expected output would be something like (2, 1), as y[i] = x[i]*2

Re: Linear regression in NumPy

2006-03-18 Thread Matt Crema
7;polyval'. Then: "help polyval" and this problem would have been solved in under 5 minutes. To sum up a wordy post, "What do experienced users find is the most efficient way to navigate the numpy docs? (assuming one has already read the FAQs and tutorials)" Thanks. -Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: why isn't Unicode the default encoding?

2006-03-20 Thread Matt Goodall
.txt") >>> stream = codecs.getreader('utf-8')(f) >>> c = stream.read(1) The 'stream' works on unicode characters so 'c' is a unicode instance, i.e. a whole textual character. - Matt -- __ / \__ Matt Goodall, Pollenation Internet

Re: News-retrieval client-news.google

2006-04-14 Thread Matt H
[EMAIL PROTECTED] wrote: > Hi All, > I'm trying to write a news retrieval client in python. > I'm going to get the news from google's news service. > However, when I run the following code, google gives me a 403 error. Knowing google, they're blocking the user agent supplied by urllib2. -- http:/

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: switch

2009-12-09 Thread Matt McCredie
f def switch(self, option): getattr(self, 'do_' + str(option), self.default)() d = MyCommandDispatcher() d.switch('a') d.switch(5) This isn't _much_ more coding than using the dictionary method, and is pretty readable. This is also a common pattern in python. Mat

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

unittest inconsistent

2010-01-06 Thread Matt Haggard
Can anyone tell me why this test fails? http://pastebin.com/f20039b17 This is a minimal example of a much more complex thing I'm trying to do. I'm trying to hijack a function and inspect the args passed to it by another function. The reason the 'Tester' object has no attribute 'arg1' is because

Re: getopt not raising exception

2010-01-10 Thread Matt Nordhoff
sys, getopt > > try: > opts, args = getopt.getopt(sys.argv, "h:", ["help"]) > except getopt.GetoptError: > print "error" > sys.exit(2) > > If no args are passed when the script is run there is no exception > raised.

Re: Arrrrgh! Another module broken

2010-01-17 Thread Matt Newville
Once I get everything to work under 2.6, I am using it > forever or until new releases no longer break working > code, whichever comes first. Hey, good luck with that forever plan. --Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: How to control I/O buffering besides -u?

2009-09-26 Thread Matt Joiner
You can try flushing, or reopening with no buffering sys.stdout.flush() sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) On Sun, Sep 27, 2009 at 2:20 AM, Dave Angel wrote: > kj wrote: >> >> Is there any way to specify unbuffered I/O from *within* the code >> (rather than via the command-line

Re: unexplainable python

2009-09-27 Thread Matt Joiner
Yes the needless use of classes further supports that theory. On Sun, Sep 27, 2009 at 4:31 PM, John Nagle wrote: > dads wrote: >> >> Sorry forgot to mention I'm using python 2.6 > >   This looks like a homework assignment. > >                                John Nagle > -- > http://mail.python.or

Python resident memory retention & Evan Jones' improvements

2009-10-02 Thread Matt Ernst
My apologies in advance if this has been addressed before. Google does not presently seem to return search results for this group from more than a couple of months ago. I have some long-running Python processes that slowly increase in resident memory size, and whose resident size goes down only wh

Re: Python resident memory retention & Evan Jones' improvements

2009-10-03 Thread Matt Ernst
agmentation. Thank you for the explanation. Since my real application uses many small objects, it makes sense that memory cannot be reclaimed in the absence of compaction. Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: Documentation of 2.x indicating what will be gone in 3.x?

2009-10-12 Thread Matt Bowcock
On Oct 12, 8:21 pm, Peng Yu wrote: > Hi, > > I'm wondering if there is a document for 2.x indicating what will be > gone in 3.x. For example, I heard that __cmp__ be not available in > Python 3. But I don't see it > inhttp://docs.python.org/reference/datamodel.html. > > Regards, > Peng 'Dive int

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: Windows file paths, again

2009-10-22 Thread Matt McCredie
st fine to me. There is a difference between a python string literal written inside of a python script and a string read from a file. When reading from a file (or the registry) what you see is what you get. There is no need to do so much work. Matt McCredie -- http://mail.python.org/mailman/listinfo/python-list

Re: Read any function in runtime

2009-10-23 Thread Matt McCredie
': statement = raw_input("Complete the function f(x)=") exec "f = lambda x:"+statement in {} print f(2) print f(4) print f(6) Matt McCredie -- http://mail.python.org/mailman/listinfo/python-list

Re: Read any function in runtime

2009-10-26 Thread Matt McCredie
Rhodri James wildebst.demon.co.uk> writes: > > On Fri, 23 Oct 2009 17:39:40 +0100, Matt McCredie gmail.com> > wrote: > > > joao abrantes gmail.com> writes: > > > >> > >> Hey. I want to make a program like this:print "Complete the fu

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: import from a string

2009-11-03 Thread Matt McCredie
code. You might also look at the __import__ funciton, which can import by python path. You might also look at the imp module. Matt -- http://mail.python.org/mailman/listinfo/python-list

tkFileDialog question

2009-11-13 Thread Matt Mitchell
prevent the empty tk window from popping up? Here's the code: import tkFileDialog answer = tkFileDialog.askdirectory() if answer is not '': #do stuff Thanks! Matt -- http://mail.python.org/mailman/listinfo/python-list

RE: tkFileDialog question

2009-11-13 Thread Matt Mitchell
-6300 or by electronic mail immediately. Thank you. -Original Message- From: python-list-bounces+mmitchell=transparent@python.org [mailto:python-list-bounces+mmitchell=transparent@python.org] On Behalf Of Matt Mitchell Sent: Friday, November 13, 2009 9:33 AM To: python-list

RE: tkFileDialog question

2009-11-16 Thread Matt Mitchell
Subject: Re: tkFileDialog question Matt, There is also a nice thing you need to know about Python if you already do not know. That is the fact that all empty collections bool to False. This makes Truth testing easier. >>> bool([]) False >>> bool('') False >>> bool(

RE: XML root node attributes

2009-11-17 Thread Matt Mitchell
--- The information contained in this electronic message and any attached document(s) is intended only for the personal and confidential use of the designated recipients named above. This message may be confidential. If the reader of this message is not the i

RE: Gray Hat Python: Python Programming for Hackers Soft copy

2009-11-20 Thread Matt Mitchell
You mean like: http://nostarch.com/ghpython.htm From: python-list-bounces+mmitchell=transparent@python.org [mailto:python-list-bounces+mmitchell=transparent@python.org] On Behalf Of Elf Scripter Sent: Friday, November 20, 2009 3:31 PM To: python-list@python.org Subject: Gray Hat Python

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: Traversing through variable-sized lists

2010-02-17 Thread Matt McCredie
me, value in izip(frames, stretch(values, frames_per_value)): frame.func(value) Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: string to list when the contents is a list

2010-02-17 Thread Matt McCredie
provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None. """ node = parse(text, mode='eval').body if not isinstance(node, List): raise ValueError('malformed string') def _convert(node): if isinstance(node, Str): return node.s raise ValueError('malformed string') return list(map(_convert, node.elts)) Matt McCredie -- http://mail.python.org/mailman/listinfo/python-list

Re: netcdf4-python

2010-02-20 Thread Matt Newville
responding (in windows cmd). > > I'm not sure what is wrong so if anyone as any ideas I would gladly > send you the netcdf file to try. Thanks. If the file is really of NetCDF3 format, scipy.io.netcdf should work. Replace netCDF4.Dataset(filename,'r',format='NETCDF3_CLASSIC') with scipy.io.netcdf.netcdf_open(filename,'r') --Matt Newville -- 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

Is there a better way to do this?

2010-03-01 Thread Matt Mitchell
quot;Not the right capitalization." # do the rest of the stuff I need to do. This works, but to me it seems like there has to be a better way of doing it. Any feedback or suggestions would be appreciated. Thanks, Matt -- http://mail.python.org/mailman/listinfo/python-list

RE: Call Signtool using python

2010-03-02 Thread Matt Mitchell
I think you need to use the /p switch to pass signtool.exe a password when using the /f switch. Check out http://msdn.microsoft.com/en-us/library/8s9b9yaz%28VS.80%29.aspx for more info. --- The information contained in this electronic message and any attached d

Multiprocessing problem

2010-03-02 Thread Matt Chaput
hough I have no idea what it does, etc.) but keep having the problem. Am I just using multiprocessing wrong? Is this a bug? Any advice? Thanks, Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing problem

2010-03-02 Thread Matt Chaput
On 3/2/2010 3:59 PM, Matt Chaput wrote: > I'm trying to use a simple pattern where a supervisor object starts a > bunch of worker processes, instantiating them with two queues (a job > queue for tasks to complete and an results queue for the results). The > supervisor puts al

Re: Multiprocessing problem

2010-03-02 Thread Matt Chaput
ormation back while they run, they just write to a temporary file which the supervisor can read, which avoids the issue. But if anyone can tell me what I was doing wrong for future reference, I'd greatly appreciate it. Thanks, Matt -- 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

using python ftp

2010-12-22 Thread Matt Funk
3) get listing 4) match the file pattern i want to the listing 5) check if file already exists 6) download file if matched and doesn't exist Can anyone offer any advice whether this already done somewhere? thanks matt -- http://mail.python.org/mailman/listinfo/python-list

Re: using python ftp

2010-12-23 Thread Matt Funk
en match it via regular pattern. Not sure if this is the best/most elegant way. But it should work. thanks matt On 12/23/2010 1:46 AM, Octavian Rasnita wrote: > Can this lib also work with ftps? > > Thanks. > > Octavian > > - Original Message - > From: "Anurag

numpy/matlab compatibility

2011-01-25 Thread Matt Funk
ode) thanks matt -- http://mail.python.org/mailman/listinfo/python-list

Re: numpy/matlab compatibility

2011-01-25 Thread Matt Funk
numpy. Andrea: you are right about the value 100. It should have been 0.5. The original code has a different vector which is tested against 100. I tried to simply reproduce the functionality with a random vector. Thus the confusion. Again, thanks for the input. matt On 1/25/2011 2:36 PM, Andrea

Editor/IDE with Python coverage support?

2011-02-16 Thread Matt Chaput
Are there any editors/IDEs with good support for line-coloring from Python test coverage results? (I normally use Eclipse + PyDev but PyDev's current coverage support isn't much better than nothing.) Thanks, Matt -- http://mail.python.org/mailman/listinfo/python-list

Unit testing multiprocessing code on Windows

2011-02-17 Thread Matt Chaput
ut if the command line is "nosetests", it's a one way ticket to an infinite explosion of processes. Any thoughts? Thanks, Matt -- http://mail.python.org/mailman/listinfo/python-list

Unit testing multiprocessing code on Windows

2011-02-17 Thread Matt Chaput
The test runner in PyDev works properly. Maybe multiprocessing is starting new Windows processes by copying the command line of the current process, but if the command line is "nosetests", it's a one way ticket to an infinite explosion of processes. Any thoughts? Thanks, Ma

Re: Unit testing multiprocessing code on Windows

2011-02-18 Thread Matt Chaput
On 18/02/2011 2:54 AM, Terry Reedy wrote: On 2/17/2011 6:31 PM, Matt Chaput wrote: Does anyone know the "right" way to write a unit test for code that uses multiprocessing on Windows? I would start with Lib/test/test_multiprocessing. Good idea, but on the one hand it doesn&#x

Re: Unit testing multiprocessing code on Windows

2011-02-18 Thread Matt Chaput
On 17/02/2011 8:22 PM, phi...@semanchuk.com wrote: Hi Matt, I assume you're aware of this documentation, especially the item entitled "Safe importing of main module"? http://docs.python.org/release/2.6.6/library/multiprocessing.html#windows Yes, but the thing is my code isn

<    2   3   4   5   6   7   8   >