Re: multi-Singleton-like using __new__

2008-02-08 Thread Matt Nordhoff
J Peyret wrote: - Same with using try/except KeyError instead of in cls.cache. Has_key might be better if you insist on look-before-you-leap, because 'in cls.cache' probably expends to uri in cls.cache.keys(), which can be rather bad for perfs if the cache is very big. i.e. dict lookups are

Re: multi-Singleton-like using __new__

2008-02-08 Thread Matt Nordhoff
Steven D'Aprano wrote: Except that using has_key() means making an attribute lookup, which takes time. I was going to say that, but doesn't 'in' require an attribute lookup of some sort too, of __contains__ or whatever? has_key is probably now just a wrapper around that, so it would be one

Re: different key, same value in dictionaries

2008-02-09 Thread Matt Nordhoff
Gary Herron wrote: You could use ImmutableSets as indexes. (In fact this is the whole reason for the existence of ImmutableSets.) You could derive your own dictionary type from the builtin dictionary type, and map an index operation d[(x,y)] to d[ImmutableSet(a,b)]. Then all of d[a,b],

Re: Is there a web visitor counter available in Python ...

2008-02-11 Thread Matt Nordhoff
W. Watson wrote: ... that is free for use without advertising that I can use on my web pages? I have no idea is suitable for this. My knowledge of Python is somewhat minimal at this point. Maybe Java is better choice. You can analyze your web logs. That's more accurate than a hit counter,

Re: idiom to ask if you are on 32 or 64 bit linux platform?

2008-02-11 Thread Matt Nordhoff
Jon wrote: Hello everyone, I've got a ctypes wrapper to some code which seems to be different when compiled on 32 bit linux compared to 64 bit linux. For the windows version I can use sys.platform == 'win32' versus 'linux2' to decide whether to get the .dll or .so library to load. Having

Re: How do I execute a command from within python and wait on that command?

2008-02-15 Thread Matt Nordhoff
Rafael Sachetto wrote: os.system(command) or proc = popen2.Popen3(command) proc.wait() I don't know about cleanly terminat[ing] the command shell, but you should use the subprocess module now, not any of the other functions scattered around. -- --

Re: How to overcome the incomplete download with urllib.urlretrieve ?

2008-02-18 Thread Matt Nordhoff
This isn't super-helpful, but... James Yu wrote: This is part of my code that invokes urllib.urlretrieve: for i in link2Visit: localName = i.split('/') i = i.replace(' ', '%20') You should use urllib.quote or urllib.quote_plus (the latter replaces spaces with + instead

Re: global variables: to be or not to be

2008-02-22 Thread Matt Nordhoff
icarus wrote: I've read 'global variables' are bad. The ones that are defined as 'global' inside a function/method. The argument that pops up every now and then is that they are hard to keep track of. I don't know Python well enough to argue with that. Just started learning it a few days

Re: clocking subprocesses

2008-03-03 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: On Mar 3, 12:41 pm, Preston Landers [EMAIL PROTECTED] wrote: Run your command through the time program. You can parse the output format of time, or set a custom output format. This mostly applies to Unix-like systems but there is probably an equivalent somewhere on

Re: os.system with cgi

2008-03-03 Thread Matt Nordhoff
G wrote: Hi, I have the following peace of code def getBook(textid, path): url = geturl(textid) if os.path.isfile(path + textid): f = open(path + textid) else: os.system('wget -c ' + url + ' -O ' path + textid) f = open(path + textid) return

[OT] Re: Why , not '''?

2008-03-05 Thread Matt Nordhoff
Steven D'Aprano wrote: Surely it would depend on the type of text: pick up any random English novel containing dialogue, and you're likely to find a couple of dozen pairs of quotation marks per page, against a few apostrophes. That's an idea... Write a novel in Python docstrings. Someone

Re: Internet Explorer 8 beta release

2008-03-06 Thread Matt Nordhoff
Colin J. Williams wrote: Isn't compliance with the W3C standard the best way of achieving multiple browser rendering? Exactly. IE 8 is supposed to be significantly less horrible. It won't catch up completely, but perhaps by IE 9 it will. Or this is all a joke, Microsoft buys Opera and shuts

Re: Distributed App - C++ with Python for Portability?

2008-03-10 Thread Matt Nordhoff
Paddy wrote: After profiling their may be other ways to remove a bottleneck, such as using existing highly-optimised libraries such as Numpy; Psycho, an optimising interpreter that can approach C type speeds for Python code; and you could create your own C++ based libraries. You might

Re: Distributed App - C++ with Python for Portability?

2008-03-10 Thread Matt Nordhoff
Stefan Behnel wrote: And if you really need the efficiency of well-tuned raw C, it's one function call away in your Cython code. What do you mean by that? I know nothing about how Cython compares to C in performance, so I said well-tuned because it must be possible to write C that is faster

Re: is operator

2008-03-10 Thread Matt Nordhoff
Metal Zong wrote: The operator is and is not test for object identity: x is y is true if and only if x and y are the same objects. x = 1 y = 1 x is y True Is this right? Why? Thanks. I believe Python automatically creates and caches int objects for 0-256, so whenever you use them, they

Re: is operator

2008-03-10 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: I believe Python automatically creates and caches int objects for 0-256, so whenever you use them, they refer to the same exact objects. Since ints are immutable, it doesn't matter. One of the biggest hits on start-up time, by the way. ;) Well, the developers

Re: Creating a file with $SIZE

2008-03-12 Thread Matt Nordhoff
Robert Bossy wrote: k.i.n.g. wrote: I think I am not clear with my question, I am sorry. Here goes the exact requirement. We use dd command in Linux to create a file with of required size. In similar way, on windows I would like to use python to take the size of the file( 50MB, 1GB ) as

Re: Update pytz timezone definitions

2008-03-14 Thread Matt Nordhoff
_robby wrote: I am looking at using pytz in a scheduling application which will be used internationally. I would like to be able to update the definition files that pytz uses monthly or bi-monthly. As far as I can tell, pytz seems to be updated (fairly) regularly to the newest tzdata, but I

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 would

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 try

Re: Python Generators

2008-03-16 Thread Matt Nordhoff
mpc wrote: snip 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 rest

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 0xc3

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) d =

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 just

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:

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 svndump.db This is what I am using

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 with

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: dict = {}

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 guarantee

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 __del__ method exists, but unless I'm mistaken

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

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 when you assign

Re: library to do easy shell scripting in Python

2008-04-24 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 scripts

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 byte 0x9c in

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 there

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 = rC:\blahblah.blah\images.20.jpg path.rsplit('.', 1) ['C:\\blahblah.blah\\images.20', 'jpg'] HTH There's

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 constructs found

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 iterating

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 my

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 use

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 for result in

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 slightly

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 channel. Because a lot of feeds just output

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, or the

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 it uses

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

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. Moderators?

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\RBARAKpython -v # installing zipimport hook import zipimport # builtin # installed zipimport hook # D:\Python25\lib\site.pyc matches

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','01741','03254']:

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-12 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: result = \t.join(id, gene_symbol, ptms) So trivial

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 commas aren't

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, should

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 PROTECTED] (supposing the subscriber's email address is [EMAIL

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 from about

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 white-space)

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 wasn't

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] += value

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 process

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://svn.python.org/view/python/trunk/Lib/antigravity.py?view=markup -- --

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 understand Python's

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 problem

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 module import GnuPGInterface ImportError No module named GnuPGInterface I got a folder /usr/share/python-support/python-gnupginterface with a

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, at

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: 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 (use

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_files.py, line

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 test.py �a =

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 member

Re: images on the web

2008-06-20 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

Re: images on the web

2008-06-20 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 tabular format, but I haven't been able to find

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 PROTECTED] ~/dev/tests]$

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) # Creating Files for

Re: Using just the Mako part of Pylons?

2008-07-01 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. First point:

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 associated

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. You can think of the websites as a blog type application. My

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 = spam

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 expliticly

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 svn_core

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. See this

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 import

Re: finding dir of main .py file

2007-12-11 Thread Matt Nordhoff
ron.longo wrote: Nope, maybe I'm not explaining myself well. When I do os.getenv('HOME') I get back None. According to the docs, 'HOME' is the user's home directory on some platforms. Which is not what I want. What I want is the directory in which an application's main .py file

Re: E-Mail Parsing

2007-12-12 Thread Matt Nordhoff
Merrigan wrote: I am writing a script to administer my E-Mail Server. The One thing I'm currently struggling with is kind of Parsing the E-Mail adress that I supply to the script. I need to get the username (The part BEFORE the @ sign) out of the address so that I can use it elsewhere. The

Re: determining bytes read from a file.

2007-12-13 Thread Matt Nordhoff
vineeth wrote: parser.add_option(-b, --bytes, dest=bytes) This is an aside, but if you pass 'type=int' to add_option, optparse will automatically convert it to an int, and (I think), give a more useful error message on failure. -- -- http://mail.python.org/mailman/listinfo/python-list

Re: E-Mail Parsing

2007-12-13 Thread Matt Nordhoff
Merrigan wrote: Hi Matt, Thank you very much for the help. It was exactly what I was looking for, and made my script much safer and easier to use. Blessings! -- Merrigan You're welcome. :-) -- -- http://mail.python.org/mailman/listinfo/python-list

Re: urlparse.urlparse bug - misparses long URL

2007-12-13 Thread Matt Nordhoff
John Nagle wrote: Here's a hostile URL that urlparse.urlparse seems to have mis-parsed. http://[EMAIL

Re: High speed web services

2007-12-14 Thread Matt Nordhoff
herbasher wrote: I'm wondering: I'm really not so much into heavy frameworks like Django, because I need to build a fast, simple python based webservice. That is, a request comes in at a certain URL, and I want to utilize Python to respond to that request. Ideally, I want the script to

Re: opposite of zip()?

2007-12-17 Thread Matt Nordhoff
Rich Harkins wrote: [EMAIL PROTECTED] wrote: Given a bunch of arrays, if I want to create tuples, there is zip(arrays). What if I want to do the opposite: break a tuple up and append the values to given arrays: map(append, arrays, tupl) except there is no unbound append() (List.append()

Re: Question about email-handling modules

2007-12-20 Thread Matt Nordhoff
Robert Latest wrote: Hello, I'm new to Python but have lots of programming experience in C, C++ and Perl. Browsing through the docs, the email handling modules caught my eye because I'd always wanted to write a script to handle my huge, ancient, and partially corrupted email archives.

Re: Local variables in classes and class instantiation

2007-12-23 Thread Matt Nordhoff
A.J. Bonnema wrote: Hi all, I just started using Python. I used to do some Java programming, so I am not completely blank. I have a small question about how classes get instantiated within other classes. I have added the source of a test program to the bottom of this mail, that

Re: Python for web...

2007-12-25 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: Hi everyone, I have to develop a web based enterprise application for my final year project. Since i am interested in open source, i searched the net. Almost 90% of them were PHP and MySQL. Cant we use python for that ? I tried several sites, but there is not enough

Re: save gb-2312 web page in a .html file

2007-12-26 Thread Matt Nordhoff
Peter Pei wrote: I am trying to read a web page and save it in a .html file. The problem is that the web page is GB-2312 encoded, and I want to save it to the file with the same encoding or unicode. I have some code like this: url = 'http://blah/' headers = { 'User-Agent' :

Re: save gb-2312 web page in a .html file

2007-12-26 Thread Matt Nordhoff
Peter Pei wrote: You must be right, since I tried one page and it worked. But there is something wrong with this particular page: http://overseas.btchina.net/?categoryid=-1. When I open the saved file (with IE7), it is all messed up. url = 'http://overseas.btchina.net/?categoryid=-1'

Re: Big-endian binary data to/from Python ints?

2007-12-26 Thread Matt Nordhoff
William McBrine wrote: Here are a couple of functions that I feel stupid for having written. They work, and they're pretty straightforward; it's just that I feel like I must be missing an easier way to do this... def net_to_int(numstring): Convert a big-endian binary number, in the

Re: Optional code segment delimiter?

2007-12-29 Thread Matt Nordhoff
xkenneth wrote: Is it possible to use optional delimiters other than tab and colons? For example: if this==1 { print this } http://timhatch.com/projects/pybraces/ Heheheh.. snip -- -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlobject question...

2007-12-29 Thread Matt Nordhoff
bruce wrote: hi... this continues my investigation of python/sqlobject, as it relates to the need to have an id, which is auto-generated. per various sites/docs on sqlobject, it appears that you can override the id, by doing something similar to the following: def foo(SQLObject):

  1   2   >