Re: How to convert simple B/W graphic to the dot matrix for the LED display/sign

2012-03-04 Thread Max Erickson
Petr Jakes wrote: > >> What file format is the graphic in? How big is it? >> >> What file format do you want it to be? >> > > Now, I am able to create the png file with the resolution 432x64 > using PIL (using draw.text method for example). > > I would like to get the 432x64 True/False (Black/

Re: installing 2 and 3 alongside on MS Windows

2012-05-25 Thread Max Erickson
Ulrich Eckhardt wrote: > Hi! > > I'm using Python 2.7 for mostly unit testing here. I'm using > Boost.Python to wrap C++ code into a module, in another place I'm > also embedding Python as interpreter into a test framework. This > is the stuff that must work, it's important for production use. >

Re: wxPython newbie question, creating "mega widgets" , and DnD

2005-11-10 Thread Max Erickson
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > A side question - why is their a EVT_LIST_BEGIN_DRAG but no > EVT_LIST_END_DRAG, unlike tree's which have BEGIN and END? I > need a draggable list box, and would prefer to not handle low > level mouse events. My intuitio

Re: tutorial example

2005-11-11 Thread Max Erickson
>>> import math >>> def distance1(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = math.sqrt(dsquared) print result return result >>> def distance2(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = math.s

Re: tutorial example

2005-11-12 Thread Max Erickson
Not in python. For example, what would you call the following? def rsum(n, m): print n+m return n+m In python a method is callable attached to an object. A function is a callable object constructed with a def statement. max -- http://mail.python.org/mailman/listinfo/python-list

Re: UCALC equivalent

2005-08-12 Thread Max Erickson
Scott David Daniels <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > max wrote: >> Larry Bates <[EMAIL PROTECTED]> wrote in >> news:[EMAIL PROTECTED]: >>>Python has built in eval function and doesn't require a library. >> >> Are you kidding? Read the original post a little more closely. >

Re: A PIL Question

2005-08-14 Thread Max Erickson
"Ray" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > > image = Image.Image() > > Anybody has any idea why this is the case? > Image.Image() isn't the way to get a new image object in PIL. Try Image.new(), which needs at least mode and size arguments. You can get those from your ori

Re: Creating watermark with transparency on jpeg using PIL?

2005-08-20 Thread Max Erickson
You need to pass a mask in when you paste in the watermark. see the documentation for the paste method at http://effbot.org/imagingbook/image.htm for more information This should at least get you started... >>> import Image >>> import ImageDraw >>> import ImageFont >>> import ImageEnhance >>> im

Re: Excel Character object through COM

2005-08-26 Thread Max Erickson
"Krisz" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: A.book.Worksheets(1).Range("a1").Characters(1,1) > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: Characters instance has no __call__ method > > So my question is that am I doing something wrong or

Re: Dynamic image creation for the web...

2005-08-28 Thread Max Erickson
Tompa <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi, > > I would like to create images on the fly as a response to an http > request. I can do this with PIL like this (file create_gif.py): > from PIL import Image, ImageDraw > check out sparklines: http://bitworking.org/projects/sp

Re: is dict.copy() a deep copy or a shallow copy

2005-09-04 Thread Max Erickson
"Alex" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: D={'Python': 'good', 'Basic': 'simple'} E=D.copy() E > {'Python': 'good', 'Basic': 'simple'} D['Basic']='oh my' D > {'Python': 'good', 'Basic': 'oh my'} E > {'Python': 'good', 'Basic': 'simple'} > > Hmm

Re: nested tuples

2005-09-09 Thread Max Erickson
"Luis P. Mendes" <[EMAIL PROTECTED]> wrote in > suppose I'm reading a csv file and want to create a tuple of all > those rows and values, like ((row1value1, row1value2, > row1value3),(row2value1, row2value2, row2value3),..., > (rowNvalue1, rowNvalue2, rowNvalue3)) > > I haven't found the way to d

Re: web scrapping - POST and auto-login

2005-09-19 Thread Max Erickson
"james hal-pc.org" wrote in news:[EMAIL PROTECTED]: > "james hal-pc.org" wrote: >> the entire 26 character string from site A, but [1] how do i >> crop it to 10 characters. > > [1] still at a loss on this one, but i can get to it later, > unless you've got any ideas. strings are slicable: >>

Re: web scrapping - POST and auto-login

2005-09-19 Thread Max Erickson
"james hal-pc.org" wrote in news:[EMAIL PROTECTED]: > Max Erickson wrote: >>>>the entire 26 character string from site A, but [1] how do i >>>>crop it to 10 characters. >> >> strings are slicable: > > The only reason i've gotten this

Re: Replacing an XML element?

2005-09-20 Thread Max Erickson
Nick Vargish <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > I've been trying to figure out how to do something that seems > relatively simple, but it's just not coming together for me. I'm > hoping someone will deign to give me a little insight here. > > The problem: We have XML document

Re: How to use writelines to append new lines to an existing file

2005-09-22 Thread Max Erickson
Nico Grubert <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi there, > > I would like to open an existing file that contains some lines of > text in order to append a new line at the end of the content. > > My first try was: > > >>> f = open('/tmp/myfile', 'w') #create new file for wr

Re: os.walk()

2005-02-17 Thread Max Erickson
os.walk() is a generator. When you iterate over it, like in a for loop, as for r,ds,fs in os.walk(...): r, ds and fs are set to new values at the beginning of each iteration. If you want to end up with a list of files or dirs, rather than processing them in the bodies of the file and dir for loop

Re: Wishful thinking : unix to windows script?

2005-03-04 Thread Max Erickson
you might also want to take a look at http://unxutils.sourceforge.net/ where are the tools are available in a single zip file. max -- http://mail.python.org/mailman/listinfo/python-list

Re: function namespaces

2005-03-08 Thread Max Erickson
Darren Dale wrote: > def myfunction(filename): > execfile(filename) > print testvar > > What am I doing wrong? I'm not familiar enough with execfile or the interactive interpreter to know what you are doing wrong, but something like: def myfunction(filename): ns=dict() execfi

Re: Linux Multimedia System

2005-03-13 Thread Max Erickson
Marek Franke wrote: > Hi there, > > we have started with some people from our LUG (Linux User Group) a 'little' > project, called LMMS (Linux Multimedia System). When it's 'finished' it > shall be a window-manager for use on TV and handle with joysticks/gamepads. > > As the name says, it is for mu

Re: How To Do It Faster?!?

2005-03-31 Thread Max Erickson
I don't quite understand what your program is doing. The user=a[18::20] looks really fragile/specific to a directory to me. Try something like this: >>> a=os.popen("dir /s /q /-c /a-d " + root).read().splitlines() Should give you the dir output split into lines, for every file below root(notice t

Re: Accessing next/prev element while for looping

2005-12-18 Thread Max Erickson
j> is a built-in object used to make complex numbers. Or at least it >was, until you rebound it to the current element from myarray. That's bad >practice, but since using complex numbers is rather unusual, one you will >probably get away with. Is it? >>> j Traceback (most recent call last): Fi

Re: New to Python, WxPython etc, etc

2006-01-03 Thread Max Erickson
"rodmc" <[EMAIL PROTECTED]> wrote in news:1136299565.613252.202670 @g44g2000cwa.googlegroups.com: > import _gaim > import wx > > from wxPython.wx import * > > ID_ABOUT = 101 > ID_EXIT = 102 > > class MyFrame(wxFrame): > def __init__(self, parent, ID, title): I don't have an answer to you

Re: Converting milliseconds to human time

2006-01-06 Thread Max Erickson
the hard way(in that you have to do it yourself): def prntime(ms): s=ms/1000 m,s=divmod(s,60) h,m=divmod(m,60) d,h=divmod(h,24) return d,h,m,s >>> print '%d days %d hours %d minutes %d seconds' % prntime(100) 0 days 0 hours 16 minutes 40 seconds >>> pri

Re: Newbie Question: CSV to XML

2006-01-06 Thread Max Erickson
"ProvoWallis" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi, > > I'm learning more and more about Python all the time but I'm still a > real newbie. I wrote this little script to convert CSV to XML and I was > hoping to get some feedback on it if anyone was willing to comment. > >

Re: Unicode Question

2006-01-09 Thread Max Erickson
The encoding argument to unicode() is used to specify the encoding of the string that you want to translate into unicode. The interpreter stores unicode as unicode, it isn't encoded... >>> unicode('\xbe','cp1252') u'\xbe' >>> unicode('\xbe','cp1252').encode('utf-8') '\xc2\xbe' >>> max -- ht

Re: Recursive tree list from dictionary

2006-01-14 Thread Max Erickson
David Pratt <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi. I am wanting to create a tree list result structure from a > dictionary to categorize results. The dictionary contains elements > that identify its parent. The levels of categorization is not fixed, > so there is a need for t

Re: Decimal ROUND_HALF_EVEN Default

2006-01-16 Thread Max Erickson
"3c273" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hello, > > I'm just curious as to why the default rounding in the decimal module > is ROUND_HALF_EVEN instead of ROUND_HALF_UP. All of the decimal > arithmetic I do is rounded half up and I can't think of why one might > use round hal

Re: OT: excellent book on information theory

2006-01-17 Thread Max Erickson
Steve Holden <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Grant Edwards wrote: >> On 2006-01-16, Tim Peters <[EMAIL PROTECTED]> wrote: >> >> >http://www.inference.phy.cam.ac.uk/mackay/itila/Potter.html >>> >>>[Grant Edwards] >>> That made me smile on a Monday morning (not an i

Re: How to generate graphics dynamically on the web using Python CGI script?

2006-01-20 Thread Max Erickson
Sparklines is a script that does exactly what you are asking using python and PIL: http://bitworking.org/projects/sparklines/ max -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode question

2006-07-28 Thread Max Erickson
"Ben Edwards (lists)" <[EMAIL PROTECTED]> wrote: > I am using python 2.4 on Ubuntu dapper, I am working through Dive > into Python. ... > Any insight? > Ben Did you follow all the instructions, or did you try to call sys.setdefaultencoding interactively? See: http://diveintopython.org/xml_pro

Re: class return another instance

2006-08-08 Thread Max Erickson
"Keith" <[EMAIL PROTECTED]> wrote: > > > Any help would be great. > > > > Cheers, > > Keith > > Do you absolutely need the functionality to be in the __init__ method, or does something like the following work: >>> IDs={} >>> class ID: pass >>> def factory(ident): if ident in

Re: Eval (was Re: Question about the use of python as a scripting language)

2006-08-10 Thread Max Erickson
[EMAIL PROTECTED] wrote: > > Brendon> A shortcut occurs to me; maybe someone can tell me > what's wrong Brendon> with my reasoning here. It seems that > any string that is unsafe Brendon> to pass to eval() must > involve a function call, and thus must Brendon> contain an > ope

Re: MP3 files and Python...

2006-10-10 Thread Max Erickson
Karlo Lozovina <[EMAIL PROTECTED]> wrote: > I'm looking for a Python lib which can read and _write_ ID3v1 and > ID3v2 tags, and as well read as much as possible data from MP3 > file (size, bitrate, samplerate, etc...). > > MP3 reproduction is of no importance... > Try mutagen: http://www.sacre

Re: Attribute error

2006-10-14 Thread Max Erickson
"Teja" <[EMAIL PROTECTED]> wrote: > Hi all, > > What is attribute error? what causes that error, especially with COM > objects? > > To be precise : > > Attribute Error: LCAS.LabcarController.writeLogWindow() > > Here, LCAS is a COM object > > Thanks > Teja.P > LabcarController might be

Re: Ok. This IS homework ...

2006-10-14 Thread Max Erickson
"spawn" <[EMAIL PROTECTED]> wrote: > but I've been struggling with this for far too long and I'm about > to start beating my head against the wall. > -- > > I tried adding an additional "while" statement to capture the > second number, but it didn't seem to solve my proble

Re: problem with the 'math' module in 2.5?

2006-10-14 Thread Max Erickson
"Chris" <[EMAIL PROTECTED]> wrote: from math import * sin(0) > 0.0 sin(pi) > 1.2246063538223773e-016 sin(2*pi) > -2.4492127076447545e-016 cos(0) > 1.0 cos(pi) > -1.0 cos(2*pi) > 1.0 > > The cosine function works fine, but I'm getting weird answers for > sine. Is

Re: problem with the 'math' module in 2.5?

2006-10-14 Thread Max Erickson
Max Erickson <[EMAIL PROTECTED]> wrote: > > Try sin(pi*0.5) to see similar behavior to cos(pi) or cos(pi*2). > Uhh, switch that, cos(pi*0.5)... -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython help wxSashWindow

2006-10-19 Thread Max Erickson
"MatthewWarren" <[EMAIL PROTECTED]> wrote: > > Thanks, is that a newsgroup I can view through google groups? I > tried seraching for it but google says no.. > > And I'll give that list a subscribe. > > I have found a wxPython google group, but only 11 members and a > handfull of posts in a year

Re: advice for web-based image annotation

2006-10-19 Thread Max Erickson
Brian Blais <[EMAIL PROTECTED]> wrote: > Hello, > > I want to set up a system where I can have my family members > write comments about a number of pictures, as part of a family > tree project. Essentially, I want them to be able to log into a > website (I already have the webspace, and the serv

Re: list comprehension (searching for onliners)

2006-10-20 Thread Max Erickson
Gerardo Herzig <[EMAIL PROTECTED]> wrote: > Hi all: I have this list thing as a result of a db.query: (short > version) result = [{'service_id' : 1, 'value': 10}, > {'service_id': 2, 'value': 5}, > {'service_id': 1, 'value': 15}, > {'service_id': 2,

Re: question about True values

2006-10-25 Thread Max Erickson
Steve Holden <[EMAIL PROTECTED]> wrote: > Gabriel Genellina wrote: >> At Wednesday 25/10/2006 22:29, Terry Reedy wrote: >> >>> >> the string class's "nil" value. Each of the builtin types >>> >> has such an "empty" or "nil" value: >>> >> >>> >> string "" >>> >> list

Re: Converting a .dbf file to a CSV file

2006-11-02 Thread Max Erickson
Johanna Pfalz <[EMAIL PROTECTED]> wrote: > Is there a module/method in python to convert a file from .DBF > format to .CSV format? > > Johanna Pfalz > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362715 There is an example provided. max -- http://mail.python.org/mailman/listinfo/

Re: how do I pass values between classes?

2006-11-06 Thread Max Erickson
"kath" <[EMAIL PROTECTED]> wrote: > hi, Larry Bates thanks for the reply... > >> You might consider doing it the same way wx passes things around. >> When you instantiate the subclass pass the parent class' instance >> as first argument to __init__ method. > > Yes thats absolutely right.. >

Re: PIL - Pixel Level Image Manipulation?

2006-11-08 Thread Max Erickson
"Gregory Piñero" <[EMAIL PROTECTED]> wrote: > On 11/8/06, Gregory Piñero <[EMAIL PROTECTED]> wrote: >> I want to be able to randomly change pixels in an image and view >> the results. I can use whatever format of image makes this >> easiest, e.g., gray scale, bit tonal, etc. >> >> Ideally I'd lik

Re: path.py and directory naming: trailing slash automatic?

2006-11-10 Thread Max Erickson
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm a big fan of path.py. One thing that I think is a good idea > is for directories to automatically have a slash appended to them > if it is not automatically added. Eg: > > from path import path > > dir = path('/some/dir') > > x = dir

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Max Erickson
>>> color='orange' >>> if color=='red' or 'blue' or 'green': print "Works?" Works? >>> -- http://mail.python.org/mailman/listinfo/python-list

Re: create a text file

2006-05-30 Thread Max Erickson
"per9000" <[EMAIL PROTECTED]> wrote: > # w is for writing > myfile = open('theoutfile',w) That won't work, the second argument to open needs to be a string: myfile = open('theoutfile', 'w') max -- http://mail.python.org/mailman/listinfo/python-list

Re: create a text file

2006-05-30 Thread Max Erickson
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Max Erickson wrote: > >>> # w is for writing >>> myfile = open('theoutfile',w) >> >> That won't work, the second argument to open needs to be a string: > > w = 'w' > >

Re: Variable name has a typo, but code still works. Why?

2006-05-31 Thread Max Erickson
"mateus" <[EMAIL PROTECTED]> wrote: > print "hello world" > > I have a nested loop where the outer loop iterates over key value > pairs of a dictionary and the inner loop iterates over a list > each list of which is a mapped value from the dictionary > > def showReport(self): > for d

Re: argmax

2006-06-01 Thread Max Erickson
"David Isaac" <[EMAIL PROTECTED]> wrote: > 1. Why is there no argmax built-in? > (This would return the index of the largest element in a > sequence.) > > 2. Is this a good argmax (as long as I know the iterable is > finite)? def argmax(iterable): return max(izip( iterable, count() > ))[1] >

Re: Package

2006-06-02 Thread Max Erickson
I'm no expert, but your post made me curious. It appears that __all__ has the effect of ensuring that from test import * picks up test1, but doesn't go any further than that. from test.test1.test2 import * should cause test3 to be imported. max -- http://mail.python.org/mailman/listinfo/

Re: mapping None values to ''

2006-06-18 Thread Max Erickson
"Roberto Bonvallet" <[EMAIL PROTECTED]> wrote: > You don't need map when using list comprehensions: > > ["" for i in [a, b, c] if i in ("None", None)] > That loses list elements that aren't in the tests: >>> a=7 >>> b="None" >>> c=None >>> ["" for i in [a,b,c] if i in ("None",None)] ['', ''

Re: very strange bug coercing to Unicode: need string or buffer, int found

2006-06-21 Thread Max Erickson
"bussiere maillist" <[EMAIL PROTECTED]> wrote: > --=_Part_118629_1441854.1150895040355 > i truly didn't understand this error : > Traceback (most recent call last): > File "D:\Programmation\FrancePaquet\FrancePaquet.py", line 77, > in ? > cabtri = "zz" + chiffrescabtri + clefc > TypeE

Re: code is data

2006-06-23 Thread Max Erickson
Anton Vredegoor <[EMAIL PROTECTED]> wrote: > > However, I knew of the existence of such languages but I am > mostly interested in standardized code interchange, like for > example with JSONP which fetches some external javascriptcode > from another server using JSON and places the translated

Re: Is it possible to change a picture resolution with Python?

2006-09-20 Thread Max Erickson
"Lad" <[EMAIL PROTECTED]> wrote: > from >> image: >> http://www.pythonware.com/library/pil/handbook/image.htm >> >> This is some example code: >> >> from PIL import Image >> im = Image.open("1.jpg") >> nx, ny = im.size >> im2 = im.resize((int(nx*1.5), int(ny*1.5)), Image.BICUBIC) >> im2.save("2.pn

Re: changing a file's permissions

2006-10-02 Thread Max Erickson
James <[EMAIL PROTECTED]> wrote: > --=_Part_63041_761240.1159752399799 > I'm writing a script in linux to excercise my python skills and > have encountered a minor issue. > > Writing the script and creating an ouput file was simple enough > and didn't take too long. However, I don't have permi

Re: recursive function

2007-01-08 Thread Max Erickson
"cesco" <[EMAIL PROTECTED]> wrote: > Hi, > > I have a dictionary of lists of tuples like in the following > example: dict = {1: [(3, 4), (5, 8)], > 2: [(5, 4), (21, 3), (19, 2)], > 3: [(16, 1), (0, 2), (1, 2), (3, 4)]] > > In this case I have three lists inside the dict but this

Re: How to I write DBASE files without ODBC

2006-02-06 Thread Max Erickson
Durumdara <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Can anybody known about DBASE handler module for Python ? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362715 max -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python a Zen language?

2006-02-25 Thread Max Erickson
Given that python code is often described in terms of being 'pythonic' or not, and that pythonic is a term that is apparently well agreed upon yet seemingly impossible to define for someone who does not already understand the word, python is probably a zen language. max -- http://mail.pytho

Re: Do other Python GUI toolkits require this?

2007-04-20 Thread Max Erickson
Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2007-04-20, Max Erickson <[EMAIL PROTECTED]> wrote: >> >> If we are being pedantic about describing a curve that shows the >> progress of a person in learning a topic, there is no arguing >> with you, a steep cu

Re: Do other Python GUI toolkits require this?

2007-04-20 Thread Max Erickson
Antoon Pardon <[EMAIL PROTECTED]> wrote: >>> Just asserting how something can make a difference withouth >>> arguing how in the particular case it actucally makes a >>> difference is just a divertion tactic without real merrit. >>> >> In the face of a notion that all steep curves determining >> "p

Re: Installation of eyeD3 on Windows (newbie)

2007-05-06 Thread Max Erickson
[EMAIL PROTECTED] wrote: > I would highly appreciate if someone could help me with how to > proceed (step-by-step) to get started and use the eyeD3 library > in Windows? > > Many thanks in advance! > It appears that you need to do as follows: Extract the tar.gz to a temporary directory. rena

Re: Python command line error

2007-05-28 Thread Max Erickson
Mick Duprez <[EMAIL PROTECTED]> wrote: > Hi All, > > I've installed Python 2.5 on a number of machines but on one I'm > having problems with the CLI. > If I fire up the 'cmd' dos box and type 'python' I get a line of > gibberish and it locks up the cli, if I run the 'command' dos box > I get a fe

Re: Alternatives for Extracting EXIF and JPEG Data from Images

2007-03-04 Thread Max Erickson
Roger <[EMAIL PROTECTED]> wrote: > Does anybody have a pointer to a Python library/utility that will > extract the chrominance and luminance quantization tables from > JPG images? > > I have been using the _getexif method from PIL, which works fine, > but doesn't extract the quantization data.

Re: PIL: reading bytes from Image

2007-03-10 Thread Max Erickson
"cyberco" <[EMAIL PROTECTED]> wrote: > I'm using web.py to send an image to the client. This works > (shortened): > > print open(path, "rb").read() > > but this doesn't: > > img = Image.open(path) > img.thumbnail((10,10)) > print img.getdata() > > or > > print img.load() > > > How do I get

Re: PIL: reading bytes from Image

2007-03-11 Thread Max Erickson
"cyberco" <[EMAIL PROTECTED]> wrote: > Thanks, > > I've tried the StringIO option as follows: > > = > img = Image.open('/some/path/img.jpg') > img.thumbnail((640,480)) > file = StringIO, StringIO() Is the above line exactly what you tried? If it is, the comma and

Re: help!! *extra* tricky web page to extract data from...

2007-03-13 Thread Max Erickson
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > How extract the visible numerical data from this Microsoft > financial web site? > > http://tinyurl.com/yw2w4h > > If you simply download the HTML file you'll see the data is *not* > embedded in it but loaded from some other file. > > Surely if I

Re: Idiom for running compiled python scripts?

2007-03-20 Thread Max Erickson
Mark <[EMAIL PROTECTED]> wrote: ... > #!/usr/bin/env python > from myprog import main > if __name__ == "__main__": > main() > > Of course this compiles myprog.py into myprog.pyc on first run as > I am wanting. > > I have one of these stubs for all my python scripts I've created > so far. Is

Re: Join strings - very simple Q.

2007-03-24 Thread Max Erickson
"7stud" <[EMAIL PROTECTED]> wrote: > On Mar 24, 8:30 am, Duncan Booth <[EMAIL PROTECTED]> > wrote: >> In case you are feeling that the ','.join(l) looks a bit >> jarring, be aware that there are alternative ways to write it. >> You can call the method on the class rather than the instance: >> >>

Re: How to find to HTML strings and 'save' them?

2007-03-26 Thread Max Erickson
John Nagle <[EMAIL PROTECTED]> wrote: > htags = soup.findAll({'h2':True, 'H2' : True}) # get all H2 tags, > both cases Have you been bitten by this? When I read this, I was operating under the assumption that BeautifulSoup wasn't case sensitive, and then I tried this: >>> import BeautifulSoup

Re: Python Web Servers and Page Retrievers

2007-04-08 Thread Max Erickson
Subscriber123 <[EMAIL PROTECTED]> wrote: > urllib, or urllib2 for advanced users. For example, you can > easily set your own headers when retrieving and serving pages, > such as the User-Agent header which you cannot set in either > urllib or urllib2. Sure you can. See: http://www.diveintopython

Re: Python Web Servers and Page Retrievers

2007-04-11 Thread Max Erickson
"Collin Stocks" <[EMAIL PROTECTED]> wrote: > --=_Part_19087_21002019.1176329323968 > I tried it, and when checking it using a proxy, saw that it > didn't really work, at least in the version that I have (urllib > v1.17 and urllib2 v2.5). It just added that header onto the end, > therefore maki

Re: setuptools without unexpected downloads

2007-10-03 Thread Max Erickson
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote: ... > This recent blog post contains step-by-step instructions on using > free tools to compile python extensions: > > -- ... The package available here: http://www.develer.com/oss/GccWinB

Re: matching a street address with regular expressions

2007-10-11 Thread Max Erickson
Andy Cheesman <[EMAIL PROTECTED]> wrote: > Check out kodos http://kodos.sourceforge.net/ for an interactive > python regexp tester > > Andy > On systems with tkinter installed(So pretty much all Windows and lots and lots of Linux systems), the redemo.py script in the Tools/Scripts directory o

Re: Universal Feed Parser - How do I keep attributes?

2007-01-11 Thread Max Erickson
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > At Wednesday 10/1/2007 14:38, [EMAIL PROTECTED] wrote: > >> >>> d = >> >>> feedparser.parse('http://weather.yahooapis.com/forecastrss?p= > 94089') >> >>> d.feed.yweather_location >>u'' > > You have to feed it the *contents* of the page, not its URL.

Re: urllib2 and HTTPBasicAuthHandler

2007-01-16 Thread Max Erickson
"m.banaouas" <[EMAIL PROTECTED]> wrote: > Hi all, > I started to use urllib2 library and HTTPBasicAuthHandler class > in order to authenticate with a http server (Zope in this case). > I don't know why but it doesn't work, while authenticating with > direct headers manipulation works fine! > ...

Re: urllib2 and HTTPBasicAuthHandler

2007-01-16 Thread Max Erickson
"m.banaouas" <[EMAIL PROTECTED]> wrote: ... >passman.add_password(None, auth_url, data['user'] , ... The only thing I can come up with is that auth_url can't begin with a protocol, like http:// or whatever. max -- http://mail.python.org/mailman/listinfo/python-list

Re: PyCon blogs?

2007-02-28 Thread Max Erickson
[EMAIL PROTECTED] wrote: > Was anybody blogging about PyCon (talks and/or sprints)? Got any > pointers? > > Thanks, > > Skip In no particular order: http://www.nedbatchelder.com/blog/20070226T075948.html http://www.oreillynet.com/onlamp/blog/2007/02/pycon_day_1_1.html http://wamber.net/PyCon

Re: Converting Excel time-format (hours since 1.1.1901)

2007-12-07 Thread Max Erickson
Dirk Hagemann <[EMAIL PROTECTED]> wrote: >> Dirk > Additional to my last posting: if you want to try this out in > Excel you should replace the command "REST" by the english > command what should be something like "remainder". The equivalent in my (U.S. English, 2000) version of excel is called

Re: Need help removing list elements.

2006-04-29 Thread Max Erickson
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: > But this gives me "IndexError: list out of range You are making the list shorter as you are iterating. By the time your index is at the end of the original list, it isn't that long any more. Creating a new list and appending the elements you

Re: cross platform libraries

2006-05-05 Thread Max Erickson
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: > I went to this webpage > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 > > Isn't it supposed to run on the network and close the connected > machine. That code uses the windows libraries on the machine it is run on to gen

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Max Erickson
Andrew Robert <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi Everyone. > > > I tried the following to get input into optionparser from either > a file or command line. > > > The code below detects the passed file argument and prints the > file contents but the individual swithces d

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Max Erickson
Andrew Robert <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Any ideas? I don't know much about optparse, but since I was bored: >>> help(o.parse_args) Help on method parse_args in module optparse: parse_args(self, args=None, values=None) method of optparse.OptionParser instance p

Re: Which is More Efficient?

2006-05-19 Thread Max Erickson
"Dustan" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > > The task manager says "CPU Usage: 100%" when the program is > running, and only when the program is running. > > Efficiency is a measure of 2 things: CPU usage and time. If you > measure just time, you're not necessarily getting

Re: altering an object as you iterate over it?

2006-05-19 Thread Max Erickson
Bruno Desthuilliers wrote > > It has been, at a time, recommended to use file() instead of > open(). Don't worry, open() is ok - and I guess almost anyone > uses it. http://mail.python.org/pipermail/python-dev/2005-December/059073.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing object parent properties

2006-05-23 Thread Max Erickson
One way: class Boo: def __init__(self, parent): self.parent=parent class Foo: X=1 def __init__(self): self.test=boo(self) -- http://mail.python.org/mailman/listinfo/python-list

Re: regex/lambda black magic

2006-05-25 Thread Max Erickson
Andrew Robert <[EMAIL PROTECTED]> wrote: > ValueError: invalid literal for int(): % > > Does anyone see what I am doing wrong? > Try getting rid of the lamba, it might make things clearer and it simplifies debugging. Something like(this is just a sketch): def callback(match): print match.

Re: regex/lambda black magic

2006-05-25 Thread Max Erickson
Andrew Robert <[EMAIL PROTECTED]> wrote: > import re,base64 > > # Evaluate captured character as hex > def ret_hex(value): > return base64.b16encode(value) > > def ret_ascii(value): > return base64.b16decode(value) > Note that you can just do this: from base64 import b16encode,b16dec

Re: Extracting images from a PDF file

2007-12-27 Thread Max Erickson
Doug Farrell <[EMAIL PROTECTED]> wrote: > Hi all, > > Does anyone know how to extract images from a PDF file? What I'm > looking to do is use pdflib_py to open large PDF files on our > Linux servers, then use PIL to verify image data. I want to do > this in order to find corrupt images in the PDF

Re: a newbie regex question

2008-01-25 Thread Max Erickson
"Dotan Cohen" <[EMAIL PROTECTED]> wrote: > Maybe you mean: > for match in re.finditer(r'\([A-Z].+[a-z])\', contents): > Note the last backslash was in the wrong place. The location of the backslash in the orignal reply is correct, it is there to escape the closing paren, which is a special charac

Re: Hyphenation module PyHyphen-0.3 released

2008-02-23 Thread Max Erickson
thebjorn <[EMAIL PROTECTED]> wrote: > Visual Studio 2003 was not found on this system. If you have > Cygwin > installed, > you can try compiling with MingW32, by passing "-c mingw32" to > setup.py. > -- bjorn You need to convince MingW to use the correct VS runtime. Cribbing from: http://

Re: Mutagen File Problem

2008-03-12 Thread Max Erickson
aiwarrior <[EMAIL PROTECTED]> wrote: > Hi i'm having a IO error saying a file does not exist even though > i perform a isFile() check. Can you help me out figuring what is > wrong? > > Thanks in advance > > from mutagen.easyid3 import EasyID3 > from mutagen.mp3 import MP3 > > for root, dirs, f

Re: A different kind of interface

2009-01-23 Thread Max Erickson
bearophileh...@lycos.com wrote: > Years ago I have found this nice small program, TextCalc: > http://www.atomixbuttons.com/textcalc/ > > Despite being very limited and being not integrated with > everything else, it's so handy that for me in certain situations > it's the right tool to use when I h

Re: Geometry package

2009-03-29 Thread Max Erickson
Justin Pearson wrote: > Hi all, > > I'm looking for a geometry package in Python; something that will > let me define line segments, and can tell me if two line segments > intersect. It would be nice if the lines could be defined in > n-space (rather than be confined to 2 or 3 dimensions), but t

Re: Delicious API and urllib2

2009-04-07 Thread Max Erickson
Bill wrote: > The delicious api requires http authorization (actually https). A > generic delicious api post url is "https:// > username:passw...@api.api.del.icio.us/v1/posts/add?url=http:// > example.com/&description=interesting&tags=whatever". > The simplest way is probably to manually add th

Re: do you fail at FizzBuzz? simple prog test

2008-05-12 Thread Max Erickson
Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On May 12, 1:30 pm, John Machin <[EMAIL PROTECTED]> wrote: >> Duncan Booth wrote: > [...] >> > I think the variant I came up with is a bit clearer: >> >> > for i in range(1,101): >> >    print '%s%s' % ('' if i%3 else 'Fizz', '' if i%5 else >> > 'Buzz'

Re: send yield

2008-05-15 Thread Max Erickson
castironpi <[EMAIL PROTECTED]> wrote: > Why can't I write this? > -- > http://mail.python.org/mailman/listinfo/python-list > > Because you don't know how? max -- http://mail.python.org/mailman/listinfo/python-list

Re: Flash Decoder

2008-05-28 Thread Max Erickson
"Mathieu Prevot" <[EMAIL PROTECTED]> wrote: > 2008/5/28 Diez B. Roggisch <[EMAIL PROTECTED]>: >> Ankit wrote: >> >>> Hi everyone,i wanted to build a flash decoder using python can >>> somebody tell me which library to use and what steps should i >>> follow to make a flash(video) decoder?By a decod

Re: [ANN]: Python-by-Example updates

2008-04-12 Thread Max Erickson
AK <[EMAIL PROTECTED]> wrote: > Python-by-Example is a guide to LibRef, aiming to give examples > for all functions, classes, modules, etc. Right now examples > for functions in some of the most important modules are > included. > > http://pbe.lightbird.net/ > > thanks, > The second set of exa

  1   2   >