Re: guess file type in python

2007-11-19 Thread Matt Nordhoff
Japan Shah wrote: > > > > > > mimetypes module? -- -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting a list of list

2007-11-21 Thread Matt Nordhoff
Tim Chase wrote: >> are there available library or pythonic algorithm for sorting a list >> of list depending on the index of the list inside the list of my >> choice? > > The built-in sorted() function and the sort() method on various > collections take an optional "key=function" keyword paramate

Re: new is missing in module hmac SHA-based encryption function in Python

2007-11-21 Thread Matt Nordhoff
Hailong Wang wrote: > Matt, > > Thanks for response, I changed my script to hw_hmac.py, but still does > not work. > > Traceback (most recent call last): > File "C:/Python25/hw_script/my_hmac.py", line 1, in > import hmac > File "C:\Python25\hw_script\hmac.py", line 4, in > myhmac =

Re: new is missing in module hmac SHA-based encryption function in Python

2007-11-21 Thread Matt Nordhoff
Hailong Wang wrote: > I have small hmac encryption programm by python, but always complain > that hmac module does not have attribute new, do I need to install > anything additinal in my laptop? I am using python 2.5.1 > > import hmac > import md5 > import sha > myhmac = hmac.new("test") > > > T

Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Matt Nordhoff
Tim Chase wrote: > (You'd think this was the Lisp ML, not Python... ) Atsp? :-) -- -- http://mail.python.org/mailman/listinfo/python-list

Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Python is a good programming language, but "Python" is not a good > name. > > First, python also means snake, Monty Python. If we search "python" in > google, emule, many results are not programming resource. If we search > PHP, all results are programming resource. >

Re: Timezones in python

2007-12-05 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Is there any build in solution in python to handle timezones? My > problem is I have to convert +4 time to +0. In the worst case i can > just add +4 to the houer but I'm not very happy about that. Another > problem is the summer/winter timechange which happen with one wee

Re: File to dict

2007-12-07 Thread Matt Nordhoff
Chris wrote: > Ta Matt, wasn't paying attention to what I typed. :) > And didn't know that about .get() and not having to declare the > global. > Thanks for my mandatory new thing for the day ;) :-) -- -- http://mail.python.org/mailman/listinfo/python-list

Re: File to dict

2007-12-07 Thread Matt Nordhoff
Duncan Booth wrote: > Just some minor points without changing the basis of what you have done > here: > > Don't bother with 'readlines', file objects are directly iterable. > Why are you calling both lstrip and rstrip? The strip method strips > whitespace from both ends for you. > > It is usual

Re: File to dict

2007-12-07 Thread Matt Nordhoff
Chris wrote: > For the first one you are parsing the entire file everytime you want > to lookup just one domain. If it is something reused several times > during your code execute you could think of rather storing it so it's > just a simple lookup away, for eg. > > _domain_dict = dict() > def gen

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.

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 > PROTECTED]&xUDysvTbzZZOaymjQ2oYIx2AvMdJ1WQfjP02wIBBQBb1EVZAqmmGunxrcyGx1AcfegWUUYtaZfRW434O5Qn6InSMUZXgF5e3KzJbCntBGOj7pv31zab&action=login-run&passkey=e84239c9da59dbeb61d4d45db2cc5

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 scri

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.

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 archive

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 e

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' : 'Moz

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/?categoryi

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

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 > } Heheheh.. -- -- 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

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Matt Nordhoff
Raymond Hettinger wrote: > I'm considering deprecating these two functions and would like some > feedback from the community or from people who have a background in > functional programming. > > * I'm concerned that use cases for the two functions are uncommon and > can obscure code rather than cl

Re: problem with global var

2008-01-03 Thread Matt Nordhoff
Bruno Ferreira wrote: > Hi, > > I wrote a very simple python program to generate a sorted list of > lines from a squid access log file. > > Here is a simplified version: > > ## > 1 logfile = open ("squid_access.log", "r") > 2 topsquid = [["0", "0", "0", "0", "0"

Re: Delete lines containing a specific word

2008-01-06 Thread Matt Nordhoff
Francesco Pietra wrote: > Please, how to adapt the following script (to delete blank lines) to delete > lines containing a specific word, or words? > > f=open("output.pdb", "r") > for line in f: > line=line.rstrip() > if line: > print line > f.close() > > If python in Li

Re: problem of converting a list to dict

2008-01-09 Thread Matt Nordhoff
bsneddon wrote: > This seemed to work for me if you are using 2.4 or greater and > like list comprehension. dict([ tuple(a.split("=")) for a in mylist[1:-1]]) > {'mike': 'manager', 'paul': 'employee', 'tom': 'boss'} > > should be faster than looping That's what he's doing (well, a generator

Re: Elementary string-formatting

2008-01-13 Thread Matt Nordhoff
Odysseus wrote: > Hello, group: I've just begun some introductory tutorials in Python. > Taking off from the "word play" exercise at > > > > I've written a mini-program to tabulate the number of characters in each > word in a fi

Re: ucs2 or ucs4?

2008-01-14 Thread Matt Nordhoff
Neal Becker wrote: > How do I tell if my python-2.5 is build with ucs2 or ucs4? You can also check sys.maxunicode. >>> import sys >>> sys.maxunicode If it's 1114111, you're UCS-4. If it's something much lower, you're UCS-2. -- -- http://mail.python.org/mailman/listinfo/python-list

Re: Is str/unicode.encode supposed to work? with replace/ignore

2008-01-15 Thread Matt Nordhoff
BerlinBrown wrote: > With this code, ignore/replace still generate an error > > # Encode to simple ascii format. > field.full_content = field.full_content.encode('ascii', > 'replace') > > Error: > > [0/1] 'ascii' codec can't decode byte 0xe2 in positi

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 >

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 mo

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. Havi

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. -- -- http://mail.python.org/mailman/l

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 "+" in

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

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 s

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

[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 shut

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 mi

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 fast

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 y

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 developer

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,

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,

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

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

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

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

  1   2   >