Re: When to derive from object?

2009-10-13 Thread Matimus
On Oct 13, 8:02 am, Matimus wrote: > On Oct 13, 7:45 am, Igor Mikushkin wrote: > > > Hello all! > > > I'm a newbie to Python. > > Could you please say me when it is better to derive from "object" and > > when not? > > > Thanks, > &g

Re: When to derive from object?

2009-10-13 Thread Matimus
On Oct 13, 7:45 am, Igor Mikushkin wrote: > Hello all! > > I'm a newbie to Python. > Could you please say me when it is better to derive from "object" and > when not? > > Thanks, > Igor The only reason to derive from 'object' is if there is some sort of weird side effect of using new style classe

Re: Modules/packages by GvR?

2009-08-28 Thread Matimus
On Aug 28, 7:58 am, gb345 wrote: > Are there any Python-only modules or packages in the latest releases > of Python 2.x or Python 3.x that were largely written by Guido van > Rossum?  What's the best way to find this out?  I know that some > modules mention the author(s) in the source code, but th

Re: 2.6 windows install

2009-08-21 Thread Matimus
On Aug 20, 10:21 am, "Tim Arnold" wrote: > Hi, > I installed python2.6 to a netapp device. I can use it from my local windows > machine (XP). But others cannot use it from their pcs. > > They get this response > "The system cannot execute the specified program.". > > If they double click on python

Re: What is the purpose of "struct" and "array" modules

2009-05-28 Thread Matimus
On May 28, 11:17 am, Igor Katson wrote: > I pretty much understand what they do, but what's the case of using > these modules by example? Is it something like pickle, to store the data > efficiently in files? For one it provides a mechanism for reading and writing arbitrary file formats. For exam

Re: Inheritance and Design Question

2009-05-27 Thread Matimus
On May 27, 12:58 pm, imageguy wrote: > I have an object the I would like to use as a base class.  Some of the > methods I would like to override completely, but others I would simply > like to call the base class method and use the return value in the > child method.  The purpose here is to elimin

Re: SQL and CSV

2009-05-05 Thread Matimus
On May 5, 9:25 am, Nick wrote: > On May 5, 5:19 pm, Tim Golden wrote: > > > > > Nick wrote: > > > I have a requirement to read a CSV file. Normally, no problem, just > > > import CSV and slurp the file up. > > > > However, in this case I want to filter out lines that have fields set > > > to part

Re: nested looping

2009-04-08 Thread Matimus
On Apr 8, 2:15 pm, PK wrote: > So I'm trying to see whats the cleanest way to do this: > > I have a > > checklist = [ax, bx, by, cy  ..] (a combination of a,b,c with x and y, > either both on one) > > allist = [a,b,c,] > xlist = [x, y, ..] > > now I wanna loop through alist and xlist and see i

Re: Problem with lists.

2009-02-22 Thread Matimus
On Feb 20, 8:12 am, "ssd" wrote: > Hi, > > In the following code, (in Python 2.5) > I was expecting to get in "b" variable the values  b: [[0, 0], [0, 1],[0, > 2], [0, 3],[0, 4], [1, 0],[1, 1], [1, 2], .] > But I get only the last value [4,4], b: b: [[4, 4], [4, 4], [4, 4], ... ] > > My code:

Re: "import" not working?

2009-02-20 Thread Matimus
On Feb 20, 3:56 pm, Lionel wrote: > On Feb 20, 3:52 pm, Chris Rebert wrote: > > > > > On Fri, Feb 20, 2009 at 3:33 PM, Lionel wrote: > > > Hello all: > > > > I've crafted several classes and exceptions which I've stored in a > > > file called "DataFileType.py". I then invoke them from within oth

Re: Keeping the Console Open with IDLE

2009-02-19 Thread Matimus
On Feb 19, 8:06 pm, "W. eWatson" wrote: > I'm using IDLE for editing, but execute programs directly. If there are > execution or "compile" errors, the console closes before I can see what it > contains. How do I prevent that? > -- >                                 W. eWatson > >               (121

Re: Python knapsack problem

2009-02-13 Thread Matimus
On Feb 13, 8:06 am, "Kurioz" wrote: > Hi, > > I got the assignment to solve the knapsack problem in Python. I have to find > the solution to put items in a sack (I have only one item A, B and C) which > maxWeight can't be larger than 6 kilograms.  Solution of this problem should > be A and C but t

Re: Added-value of frameworks?

2009-02-04 Thread Matimus
On Feb 4, 8:08 am, Gilles Ganault wrote: > Hello > > If I wanted to build some social web site such as Facebook, what do > frameworks like Django or TurboGears provide over writing a site from > scratch using Python? > > Thank you for your feedback. Why not just look at the frameworks themselves

Re: Window (tkinter) with no decoration

2009-02-03 Thread Matimus
On Feb 3, 8:58 am, Djames Suhanko wrote: > Hello, programmers! >  I would like to do a menu bar like kicker or windows menu. is possible? > > -- > Djames Suhanko > LinuxUser 158.760 Maybe you are looking for this? import Tkinter rt = Tkinter.Tk() rt.overrideredirect(True) # do stuff Matt --

Re: optparse question

2009-01-26 Thread Matimus
> I did all the requisite reading and found that I should use optparse > instead of getopt.   I read the documentation and since the words > "simple" and "easy" often appeared in the examples and documentation, I > just knew that it would be a snap to implement. I don't know where you got that. 'g

Re: what's the point of rpython?

2009-01-18 Thread Matimus
The goals are listed here: http://codespeak.net/pypy/dist/pypy/doc/architecture.html Speed is mentioned, but as a secondary concern. The main goal seems to be to create a vehicle into exploring the concept of dynamic languages themselves. If that seems amorphous then it is because it is a researc

Re: optimizing large dictionaries

2009-01-15 Thread Matimus
On Jan 15, 1:39 pm, Per Freem wrote: > hello > > i have an optimization questions about python. i am iterating through > a file and counting the number of repeated elements. the file has on > the order > of tens of millions elements... > > i create a dictionary that maps elements of the file that

Re: the name of a method

2009-01-15 Thread Matimus
On Jan 15, 8:23 am, thomas.steffe...@googlemail.com wrote: > Hello, > > I have a Class: > > class myClass: >     def __init__(self): >         # do something >         print "name of class = " +  self.__class__.__name__ > >     def myMethod(self): >         # do something >         print "name of m

Re: point class help

2009-01-14 Thread Matimus
On Jan 14, 8:50 am, r wrote: > On Jan 14, 10:44 am, Steve Holden wrote: > > > Thous it does seem particularly perverse to have the add method not > > itself return a Point. > > Thanks Steve, > i was going implement exactly this but thought there "might" be a > better way i did not know about. So

Re: Python 3.0 nonlocal statement

2009-01-06 Thread Matimus
On Jan 6, 5:31 am, Casey wrote: > In PEP 3104 the nonlocal statement was proposed and accepted for > implementation in Python 3.0 for access to names in outer scopes.  The > proposed syntax included an optional assignment or augmented > assignment to the outer name, such as: > > nonlocal x += 1 >

Re: How to initialize a class variable once

2008-12-08 Thread Matimus
On Dec 8, 8:08 pm, Roy Smith <[EMAIL PROTECTED]> wrote: > I've got a class with a class variable: > > class Foo: >    _map = {} > > How do I make sure this only gets initialized the *first* time the > module containing the class is imported?  What appears to be happening > as it stands is each time

Re: "as" keyword woes

2008-12-04 Thread Matimus
On Dec 4, 6:08 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 03 Dec 2008 17:15:21 -0800, Matimus wrote: > >> Couldn't we have continued along just fine using a smarter parser > >> without elevating "as" to reserved

Re: "as" keyword woes

2008-12-03 Thread Matimus
> What I want to understand is why this parser change was necessary in > order to enable new 2.6/3.0 features. Was this change potentially > avoidable? Does it really matter? The change occurred and it isn't going to go back. What you should be asking yourself is whether the affect it had on your

Re: performance question: dictionary or list, float or string?

2008-12-02 Thread Matimus
On Dec 2, 3:51 am, [EMAIL PROTECTED] wrote: > I forgot to mention that I did a simple timeit test which doesn't > show > significant runtime difference 3.5 sec for dictionary case and 3.48 > for > list case. > > def read_as_dictionary(): >     fil = open('myDataFile', 'r') >     forces = {} >     f

Re: how to dynamically instantiate an object inheriting from several classes?

2008-11-24 Thread Matimus
On Nov 21, 2:11 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > I have a function that takes a reference to a class, and then   > instantiates that class (and then does several other things with the   > new instance).  This is easy enough: > >     item = cls(self, **itemArgs) > > where "cls" is the cla

Re: Searching for Regular Expressions in a string WITH overlap

2008-11-20 Thread Matimus
On Nov 20, 4:31 pm, Ben <[EMAIL PROTECTED]> wrote: > I apologize in advance for the newbie question.  I'm trying to figure > out a way to find all of the occurrences of a regular expression in a > string including the overlapping ones. > > For example, given the string 123456789 > > I'd like to use

Re: special editor support for indentation needed.

2008-11-14 Thread Matimus
On Nov 14, 11:41 am, "Eric S. Johansson" <[EMAIL PROTECTED]> wrote: > in trying to make programming in Python more accessible to disabled > programmers > (specifically mobility impaired speech recognition users), and hitting a bit > of > a wall.  The wall (for today) is indentation.  I need a met

Re: using "private" parameters as static storage?

2008-11-13 Thread Matimus
On Nov 13, 9:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: > One thing I miss as I move from REALbasic to Python is the ability to   > have static storage within a method -- i.e. storage that is persistent   > between calls, but not visible outside the method.  I frequently use   > this for such thi

Re: duck-type-checking?

2008-11-12 Thread Matimus
On Nov 12, 7:06 am, Joe Strout <[EMAIL PROTECTED]> wrote: > Let me preface this by saying that I think I "get" the concept of duck- > typing. > > However, I still want to sprinkle my code with assertions that, for   > example, my parameters are what they're supposed to be -- too often I   > mistake

Re: Extending Logger

2008-11-07 Thread Matimus
> Yes but in the other hand > :http://docs.python.org/library/logging.html#logger-objects > "Note that Loggers are never instantiated directly, but always through > the module-level function logging.getLogger(name)." That is part of the power of the logging module. If you ask for a logger of the

Re: Building loop with some exceptions?

2008-11-04 Thread Matimus
On Nov 4, 11:20 am, Gilles Ganault <[EMAIL PROTECTED]> wrote: > Hello > > I need to call a URL through a loop that starts at 01 and ends at 99, > but some of the steps must be ignored: > > = > url = "http://www.acme.com/list?code="; > p = re.compile("^(\d+)\t(.+)$") > > for i=01 to 99 except 04

Re: brackets content regular expression

2008-10-31 Thread Matimus
rst " b < Ó > d " and then " e < f  > g " but not " > b < Ó > d > here starts a new group:  < e < f  > g " > On 31 ÏËÔ, 20:53, Matimus <[EMAIL PROTECTED]> wrote: > > > On Oct 31, 10:25šam, netimen <[EMAIL PROTECTE

Re: brackets content regular expression

2008-10-31 Thread Matimus
On Oct 31, 10:25 am, netimen <[EMAIL PROTECTED]> wrote: > I have a text containing brackets (or what is the correct term for > '>'?). I'd like to match text in the uppermost level of brackets. > > So, I have sth like: ' 123 < 1 aaa < t bbb < a ff > > 2 > > b'. How to match text between the

Re: Printing with interspersed element

2008-10-30 Thread Matimus
On Oct 30, 2:10 pm, "Paulo J. Matos" <[EMAIL PROTECTED]> wrote: > On Thu, Oct 30, 2008 at 8:42 PM, Arnaud Delobelle > > > > <[EMAIL PROTECTED]> wrote: > > On Oct 30, 8:07 pm, "Paulo J. Matos" <[EMAIL PROTECTED]> wrote: > >> Hi all, > > >> I guess this is a recurring issue for someone who doesn't re

Re: Limit between 0 and 100

2008-10-27 Thread Matimus
On Oct 25, 1:42 pm, [EMAIL PROTECTED] wrote: > Hi. I'm very new to Python, and so this is probably a pretty basic > question, but I'm lost. I am looking to limit a float value to a > number between 0 and 100 (the input is a percentage). > > I currently have: > > integer = int() > running = True > >

Re: Global dictionary or class variables

2008-10-24 Thread Matimus
On Oct 24, 1:44 pm, Mr.SpOOn <[EMAIL PROTECTED]> wrote: > Hi, > in an application I have to use some variables with fixed valuse. > > For example, I'm working with musical notes, so I have a global > dictionary like this: > > natural_notes = {'C': 0, 'D': 2, 'E': 4 } > > This actually works fin

Re: logging module

2008-10-23 Thread Matimus
On Oct 23, 7:58 am, "Werner F. Bruhin" <[EMAIL PROTECTED]> wrote: > I am starting to use the logging module. > > Simple log to file and/or console work very nicely. > > Even managed to get TimedRotatingFileHandler to work. > > The problem I am trying to solve. > > 1. I would like to have a "log vie

Re: ImportError in python 2.5 in C API DLL

2008-10-16 Thread Matimus
On Oct 16, 10:58 am, Henrik <[EMAIL PROTECTED]> wrote: > Hi, > > We are upgrading from Python 2.3 to verion 2.5 and when we recompile > we get ImportError. > > To test we took the spam example from the web documentation and > compiled it with Py23 and it imports without a problem. Changing the > li

Re: Making class attributes non-case-sensitive?

2008-10-14 Thread Matimus
> So is iterating through dir() to force both the members of dir(), and > the requested attribute name, to lower case for a comparison, really > the easiest way? > > Thanks again for sticking with me. I hope I didn't add to the > confusion. What I learn I will of course pass on. > > - Rafe It stil

Re: Upgrading from 2.5 to 2.6

2008-10-13 Thread Matimus
> Python 2.5 and 2.6 can coexist, so there isn't any need for some > kind of upgrade procedure. Installing 2.6 will not affect your > 2.5 installation. That isn't entirely true. In Windows, python files bound to a particular version of python in the registry. So, for example, if you double click o

Re: Making class attributes non-case-sensitive?

2008-10-13 Thread Matimus
On Oct 13, 4:08 am, Rafe <[EMAIL PROTECTED]> wrote: > Just so I don't hijack my own thread, the issue is 'how to wrap an > object which is not case sensitive'. > > The reason I am stuck dealing with this?... The application's API is > accessed through COM, so I don't know if I can do anything but r

Re: Get "code object" of class

2008-10-10 Thread Matimus
On Oct 10, 5:50 am, Okko Willeboordse <[EMAIL PROTECTED]> wrote: > To get the "code object" c of my_class I can do; > > c = compile(inspect.getsource(my_class), "

Re: Quality control in open source development

2008-10-08 Thread Matimus
On Oct 8, 8:43 am, Dave <[EMAIL PROTECTED]> wrote: > With the open source licenses that allow redistribution of modified > code, how do you keep someone unaffiliated with the Python community > from creating his or her own version of python, and declaring it to be > Python 2.6, or maybe Python 2.7

Re: Inheritance but only partly?

2008-10-02 Thread Matimus
On Oct 2, 1:16 pm, process <[EMAIL PROTECTED]> wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? I think the noral way of doing that is to split the ori

Re: Wait or not?

2008-09-30 Thread Matimus
On Sep 30, 4:20 pm, Eric <[EMAIL PROTECTED]> wrote: > I've been wanting to learn Python for a while now but I can't decide > on whether to wait for Python 3's final release and learn it or just > go ahead and learn 2.x. Would it be hard to make the transition being > a noob? It shouldn't be a hard

Re: One class per file?

2008-09-29 Thread Matimus
> The book "Code Complete" recommends that you put only one class in a > source file, which seems a bit extreme for me. It seems that many > classes are small, so that putting several of them in a file seems > reasonable. I noticed that the decimal.py module in the standard > library has several c

Re: ConfigParser subclass problem

2008-09-26 Thread Matimus
On Sep 26, 12:56 pm, Strato <[EMAIL PROTECTED]> wrote: > Hi folks, > > I think I do something wrong, but I don't see why it doesn't work, so I > will explain: > > I've searched in the list archive and found this thread, that explain > exactly what I want to have: the options strings returned by > C

Re: a short-cut command for globals().clear() ??

2008-09-22 Thread Matimus
On Sep 22, 2:31 pm, [EMAIL PROTECTED] wrote: > hi all, > > forgive me , but the RTFM and Google search approaches are not > yielding an answer on this question.  I need to know if there's a top > level python interpreter command that clears all user variables (not > built-ins) from the global names

Re: What do you call a class not intended to be instantiated

2008-09-22 Thread Matimus
On Sep 21, 3:39 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > I have a class which is not intended to be instantiated. Instead of using > the class to creating an instance and then operate on it, I use the class > directly, with classmethods. Essentially, the class is used as

Re: optparse

2008-09-16 Thread Matimus
I'm assuming you read at least some of the docs. This page makes it pretty clear: http://docs.python.org/lib/optparse-default-values.html Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: Persuading ConfigParser to give me the section elements in the same order as the file

2008-09-10 Thread Matimus
On Sep 10, 1:52 pm, geoffbache <[EMAIL PROTECTED]> wrote: > Hi all, > > I recently needed to parse a file that was perfect for ConfigParser > apart from one thing: the elements in the sections, although > definitions, could in some cases clash with each other and therefore > it was important to be

Re: Test if list contains another list

2008-09-08 Thread Matimus
On Sep 8, 12:32 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > mathieu a écrit : > > > Hi there, > > >   I am trying to write something very simple to test if a list > > contains another one: > > > a = [1,2,3] > > > b = [3,2,1,4] > > > but 'a in b' returns False. > > Indeed. Lists are not set

Re: creating a similar object from an derived class

2008-09-03 Thread Matimus
On Sep 3, 12:09 pm, Scott <[EMAIL PROTECTED]> wrote: > Let's say I have an object: > > class foo(): >    def create_another() >        return foo() > >    def blah(): >        x = self.create_another() >        ... do something with X > > Now I create a inherited class of this object: > > class bar

Re: eval() == evil? --- How to use it safely?

2008-08-28 Thread Matimus
On Aug 28, 3:09 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > On Thu, Aug 28, 2008 at 6:51 PM, Fett <[EMAIL PROTECTED]> wrote: > > I am creating a program that requires some data that must be kept up > > to date. What I plan is to put this data up on a web-site then have > > the program periodi

Re: Python in a Nutshell -- Book vs Web

2008-08-28 Thread Matimus
On Aug 28, 3:05 pm, "W. eWatson" <[EMAIL PROTECTED]> wrote: > I read an Amazon of Python in a Nutshell. The first edition is supposedly > much like the web site. What web site? The second edition apparently adds > more to the book than the web site. O'Reilly seems to just read all of the available

Re: Python one-liner??

2008-08-22 Thread Matimus
> Do we have python one-liner like perl one-liner 'perl -e'?? The answer is python -c... but python -h is useful too. Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing exceptions in PEP 3107

2008-08-11 Thread Matimus
> Maybe the following syntax would be even more intuitive: > > def foo(a: "a info", b: "b info") return "ret info" raise "exc info": >         return "hello world" > > I don't know how determined the "->" syntax is already. That seems much more intuitive and extensible. The "->" syntax has always

Re: Missing exceptions in PEP 3107

2008-08-09 Thread Matimus
On Aug 9, 9:08 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > I'm just reading PEP 3107 (function annotations) and wonder why > exceptions are not mentioned there. I think it would be helpful if one > could specify which exceptions can be raised by a function, similarly to > how it is possibl

Re: Function editing with Vim throws IndentError

2008-07-25 Thread Matimus
On Jul 24, 9:32 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message > <[EMAIL PROTECTED]>, Matimus > wrote: > > > On Jul 24, 2:54 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] > > central.gen.new_zeala

Re: Function editing with Vim throws IndentError

2008-07-24 Thread Matimus
On Jul 24, 2:54 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message > <[EMAIL PROTECTED]>, > > Matimus wrote: > > That isn't the standard. With that setup tabs will show up as 4 > > spaces, and still confuse you. >

Re: Function editing with Vim throws IndentError

2008-07-23 Thread Matimus
On Jul 22, 2:02 pm, ptn <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I have a weird problem.  Say I have a .py file with some functions in > it, like this: > >     # (...) >     def foo(): >         print("bar") > > When I open it and add a line to one of the functions, > >     # (...) >     def

Re: How do I compare files?

2008-07-22 Thread Matimus
On Jul 22, 4:27 pm, Clay Hobbs <[EMAIL PROTECTED]> wrote: > I am making a program that (with urllib) that downloads two jpeg files > and, if they are different, displays the new one.  I need to find a way > to compare two files in Python.  How is this done? > > -- Ratfink Do you just want to check

Re: Question about inheritence

2008-07-22 Thread Matimus
On Jul 22, 9:26 am, Catherine Heathcote <[EMAIL PROTECTED]> wrote: > If I create a new class inherited from another with a constructor, what > happens with the new class's constructer? > Thanks for your time. Nothing, unless you call it in your constructor. class Base(object): def __init__(self)

Re: Is this a valid use of 'import'?

2008-07-22 Thread Matimus
On Jul 22, 8:12 am, Frank Millman <[EMAIL PROTECTED]> wrote: > Hi all > > I am familiar enough with the normal use of 'import'. However, I have > found a use for it which seems effective, but I have not seen it used > like this before, so I am not sure if there are any downsides. > > I know that wh

Re: One step up from str.split()

2008-07-16 Thread Matimus
On Jul 15, 4:28 pm, "Joel Koltner" <[EMAIL PROTECTED]> wrote: > "Sion Arrowsmith" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > What's wrong with sys.argv ? > > Mainly that it doesn't exist.  :-)  The example was slightly contrived -- I'm > really dealing with commands inter

Re: 'if name is not None:' v. 'if name:'

2008-07-15 Thread Matimus
On Jul 15, 12:44 pm, "Victor Noagbodji" <[EMAIL PROTECTED]> wrote: > >>what's the difference between these two statement? > >one checks if the given object is not None, the other checks if it's a true > >value: > >http://docs.python.org/ref/Booleans.html#Booleans > >>And which one should one use?

Re: One step up from str.split()

2008-07-14 Thread Matimus
On Jul 14, 6:33 pm, "Joel Koltner" <[EMAIL PROTECTED]> wrote: > I normally use str.split() for simple splitting of command line arguments, but > I would like to support, e.g., long file names which-- under windows -- are > typically provided as simple quoted string. E.g., > > myapp --dosomething -

Bug when using with_statement with exec

2008-07-14 Thread Matimus
I think I'm going to create a new issue in Pythons issue database, but I wanted to run it by the news group first. See if I can get any useful feed back. The following session demonstrates the issue: Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help"

Re: screencapture with PIL question

2008-07-14 Thread Matimus
On Jul 14, 8:11 am, greg <[EMAIL PROTECTED]> wrote: > Is there any way to capture the entire window?  specifically > the scrolled portion of a window that is _not_visible_on_the_screen_. I don't think there is. That is why it is called a _screen_ capture. Matt -- http://mail.python.org/mailman/

Re: How to make python scripts .py executable, not bring up editor

2008-07-08 Thread Matimus
On Jul 7, 2:56 pm, korean_dave <[EMAIL PROTECTED]> wrote: > From command Prompt, i type in a script,  "tryme.py". > > This, instead, brings up PythonWin editor and Interactive Window. > > Path variable is "C:\Python24". (I need Python 2.4 installed, not 2.5) > > How do I make it so that the script

Re: Please check my understanding...

2008-07-01 Thread Matimus
On Jul 1, 12:35 pm, Tobiah <[EMAIL PROTECTED]> wrote: > list.append([1,2]) will add the two element list as the next > element of the list. > > list.extend([1,2]) is equivalent to list = list + [1, 2] > and the result is that each element of the added list > becomes it's own new element in the orig

Re: raw_input into Tkinter ?

2008-06-30 Thread Matimus
On Jun 30, 9:55 am, [EMAIL PROTECTED] wrote: > Is there any way to type into a Tkinter frame window? > I want to use raw_input() within a Tkinter frame. `raw_input(prompt)` just calls `sys.stdout.write(prompt)` and returns `sys.stdin.readline()`. So, you can just create file-like objects to replac

Re: How to "rebind" py2.5.1 to run from comprompt after uninstalling py3.0?

2008-06-27 Thread Matimus
On Jun 26, 8:13 pm, defn noob <[EMAIL PROTECTED]> wrote: > I installed python30 and so command prompt runs all pythonprograms > through that which i didnt want so i uninstalled it. > > now i cant start any pythonprograms through the commandprompt. > > how do I "rebind" python25 to luanch when clali

Re: embedding and extending python C API registering callback handler objects

2008-06-27 Thread Matimus
On Jun 27, 8:22 am, Tim Spens <[EMAIL PROTECTED]> wrote: > Hello all, > > I've been trying to get an example found > herehttp://codeidol.com/python/python3/Embedding-Python/Registering-Callb... > to work.  Every thing works fine except when I try to trigger an event from c > that will call a pyth

Re: ConfigParser: Can I read(ConfigParser.get()) a configuration file and use it to call a funciton?

2008-06-26 Thread Matimus
On Jun 26, 7:41 am, [EMAIL PROTECTED] wrote: > Hello. I am a novice programmer and have a question > > I have a configuration file(configuration.cfg) > I read this from reading.py using ConfigParser > When I use ConfigParser.get() function, it returns a string. > I want to call a function that has

Re: Newbie question about tuples and list comprehensions

2008-06-25 Thread Matimus
On Jun 25, 2:37 pm, idiolect <[EMAIL PROTECTED]> wrote: > Hi all - Sorry to plague you with another newbie question from a > lurker.  Hopefully, this will be simple. > > I have a list full of RGB pixel values read from an image.  I want to > test each RGB band value per pixel, and set it to somethi

Re: python -regular expression - list element

2008-06-25 Thread Matimus
On Jun 25, 2:55 am, antar2 <[EMAIL PROTECTED]> wrote: > Hello, > > I am a beginner in Python and am not able to use a list element for > regular expression, substitutions. > > list1 = [ 'a', 'o' ] > list2 = ['star',  'day', 'work', 'hello'] > > Suppose that I want to substitute the vowels from list

Re: Sequence iterators with __index__

2008-06-25 Thread Matimus
On Jun 24, 4:19 pm, schickb <[EMAIL PROTECTED]> wrote: > On Jun 24, 3:45 pm, Matimus <[EMAIL PROTECTED]> wrote: > > > > > > I think it would be useful if iterators on sequences had the __index__ > > > method so that they could be used to slice sequences.

Re: logging module's documentation lies?

2008-06-24 Thread Matimus
On Jun 24, 2:35 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Quote from the docs: > >     FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s" >     logging.basicConfig(format=FORMAT) >     d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} >     logging.warning("Protocol problem:

Re: Sequence iterators with __index__

2008-06-24 Thread Matimus
On Jun 24, 3:29 pm, schickb <[EMAIL PROTECTED]> wrote: > I think it would be useful if iterators on sequences had the __index__ > method so that they could be used to slice sequences. I was writing a > class and wanted to return a list iterator to callers.  I then wanted > to let callers slice from

Re: percent string replacement with index

2008-06-24 Thread Matimus
On Jun 24, 12:26 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Ulrich Eckhardt wrote: > > What I'm surprised is that this isn't supported: > > >   "%(1)s %(2)s" % ("zero", "one", "two") > > > i.e. specifying the index in a sequence instead of the key into a map (maybe > > I would use [1] instead of

Re: insertion sorts...

2008-06-23 Thread Matimus
On Jun 23, 11:52 am, python_newbie <[EMAIL PROTECTED]> wrote: > I don't know this list is the right place for newbie questions. I try > to implement insertion sort in pyhton. At first code there is no > problem. But the second one ( i code it in the same pattern i think ) > doesn't work. Any ideas

Re: Tkinter canvas drag/drop obstacle

2008-06-20 Thread Matimus
On Jun 20, 11:10 am, Matimus <[EMAIL PROTECTED]> wrote: > On Jun 20, 9:11 am, Peter Pearson <[EMAIL PROTECTED]> wrote: > > > Tkinter makes it very easy to drag jpeg images around on a > > canvas, but I would like to have a "target" change color when > &g

Re: Tkinter canvas drag/drop obstacle

2008-06-20 Thread Matimus
On Jun 20, 9:11 am, Peter Pearson <[EMAIL PROTECTED]> wrote: > Tkinter makes it very easy to drag jpeg images around on a > canvas, but I would like to have a "target" change color when > the cursor dragging an image passes over it.  I seem to be > blocked by the fact that the callbacks that might

Re: Hamming Distance

2008-06-19 Thread Matimus
On Jun 19, 4:27 pm, godavemon <[EMAIL PROTECTED]> wrote: > I need to calculate the Hamming Distance of two integers.  The hamming > distance is the number of bits in two integers that don't match.  I > thought there'd be a function in math or scipy but i haven't been able > to find one.  This is my

Re: python/ruby question..

2008-06-19 Thread Matimus
On Jun 19, 4:00 pm, Matimus <[EMAIL PROTECTED]> wrote: > On Jun 18, 8: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

Re: python/ruby question..

2008-06-19 Thread Matimus
On Jun 18, 8: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 = os.exec(testruby.r

Re: Noob: finding my way around the docs...

2008-06-19 Thread Matimus
On Jun 19, 2:06 pm, kj <[EMAIL PROTECTED]> wrote: > I'm a Python noob, and haven't yet figured out my way around the > Python documentation. > > For example, suppose I learn about some great module foo.bar.baz, > and when I run the python interpreter and type "import foo.bar.baz", > lo and behold,

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-18 Thread Matimus
On Jun 16, 1:37 am, Armin Ronacher <[EMAIL PROTECTED]> wrote: > Abstract > > > This PEP proposes an ordered dictionary as a new data structure for > the ``collections`` module, called "odict" in this PEP for short.  The > proposed API incorporates the experiences gained from working with >

Re: How to split a string containing nested commas-separated substrings

2008-06-18 Thread Matimus
On Jun 18, 10:54 am, Matimus <[EMAIL PROTECTED]> wrote: > On Jun 18, 10:19 am, Robert Dodier <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > I'd like to split a string by commas, but only at the "top level" so > > to speak. An element

Re: How to split a string containing nested commas-separated substrings

2008-06-18 Thread Matimus
On Jun 18, 10:19 am, Robert Dodier <[EMAIL PROTECTED]> wrote: > Hello, > > I'd like to split a string by commas, but only at the "top level" so > to speak. An element can be a comma-less substring, or a > quoted string, or a substring which looks like a function call. > If some element contains com

Re: 2d graphics - drawing a vescica piscis in Python

2008-06-17 Thread Matimus
On Jun 17, 12:45 pm, Terrence Brannon <[EMAIL PROTECTED]> wrote: > Hello, I have written a program to draw a vescica piscis en.wikipedia.org/wiki/Vesica_piscis> > > from turtle import * > > def main(): >     setup(width=400, height=400) > >     r = 50 >     color("black") >     circle(r) >     col

Re: Please explain Python "__whatever__" construct.

2008-06-16 Thread Matimus
When and why would I ever use > "__main__" or the many other "__whatever__" constructs? You don't generally use those names directly, they are 'magic'. The __add__ example is a good one. When you do `"hello " + "world"` behind the scenes python is actually calling "hello ".__add__("world"). There

Re: Subclassing list, what special methods do this?

2008-06-13 Thread Matimus
On Jun 13, 11:38 am, Mike Kent <[EMAIL PROTECTED]> wrote: > For Python 2.5 and new-style classes, what special method is called > for mylist[2:4] = seq and for del mylist[2:4] (given that mylist is a > list, and seq is some sequence)? > > I'm trying to subclass list, and I'm having trouble determin

Re: weird iteration/assignment problem

2008-06-13 Thread Matimus
On Jun 13, 8:07 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > cirfu schrieb: > > > for i in xrange(0, len(texts)): > > texts[i] = "yes" > > > for i in texts: > > i = "no" > > > why is the first one working but not the second. i mean i see why the > > firts one works but i dont udn

Re: Simple and safe evaluator

2008-06-12 Thread Matimus
On Jun 11, 9:16 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jun 11, 8:15 pm, bvdp <[EMAIL PROTECTED]> wrote: > > > > > Matimus wrote: > > > > The solution I posted should work and is safe. It may not seem very > > > readable, but it i

Re: Simple and safe evaluator

2008-06-11 Thread Matimus
On Jun 11, 4:38 pm, bvdp <[EMAIL PROTECTED]> wrote: > I'm finding my quest for a safe eval() quite frustrating :) > > Any comments on this: Just forget about getting python to do this and, > instead, grab my set of values (from a user supplied text file) and call > an external program like 'bc' to

Re: Simple and safe evaluator

2008-06-11 Thread Matimus
On Jun 11, 1:25 pm, bvdp <[EMAIL PROTECTED]> wrote: > Is there a simple/safe expression evaluator I can use in a python > program. I just want to pass along a string in the form "1 + 44 / 3" or > perhaps "1 + (-4.3*5)" and get a numeric result. > > I can do this with eval() but I really don't want

Re: can't assign to literal

2008-06-10 Thread Matimus
On Jun 10, 12:53 pm, maehhheeyy <[EMAIL PROTECTED]> wrote: > this is stopping my program from running properly. is there something > wrong in my code when that happens? yes Post your code, or at least the full error message if you want more details. Matt -- http://mail.python.org/mailman/listinf

Re: Question by someone coming from C...

2008-06-09 Thread Matimus
On Jun 9, 2:00 pm, Skye <[EMAIL PROTECTED]> wrote: > Writing this app in Python, not sure what the "best practice" would > be. > > I want a bitfield global logging level that allows me to turn specific > debugging modules on and off. If I was doing this in C, I'd just use > some globals like: > >

  1   2   3   >