Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
"Wayne Watson" wrote I'm not familiar with the Image and ImageDraw modules but what I think is happening is... import Image, ImageDraw from Tkinter import * By doing this you have hidden Image because Tkinter has its own Image class. im = Image.open("wagon.tif") This is calling open() on Tkinter.Image You need to either import Image as an alias or use import Tkinter instead of from Tkinter. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] clipboard questions
"Che M" wrote I'm curious about how to interact with the contents of the clipboard effectively and have a couple of questions... 1) Is there one cross-platform way to read the clipboard, In a generic sense no. But if the cut n paste is within a single application then yes, you can use a cross platform GUI framework. That will work across OS versions. Where it gets messy is if you want to paste from the generic OS clipboard into your application and different frameworks vary in how well they handle that. 2) I would like to be able to copy formatting (bold, italics, bullets, hyperlinks, etc.) into the clipboard and then have Python have access to the text content and its formatting Thats even more tricky because not all clipboards will capture formatting codes in their original form. Some require special commands/events. It may also depend on the application that you are copying from. For example consider a MacOS web browser. Do you want to copy the underlying HTML formatting tags? Or the display PDF codes which are used by the Aqua graphics system used by the browser to actually display the output? In other words your display mechanism will need to be able to display whatever the clipboard passes. And your applucatin will need to be able to extract the data from it (eg parse PDF or RTF etc) Cut n paste between apps is non trivial even on a single OS and within a single framework. But if you have mixed environments it can get really messy in my experience! If it's all within a single framework then its not so bad. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] clipboard questions
Le Mon, 26 Jan 2009 02:23:05 -0500, Che M a écrit : > > I'm curious about how to interact with the contents of the clipboard > effectively and have a couple of questions... > > 1) Is there one cross-platform way to read the clipboard, or does one > have to have a different way to do it for Win, Mac, and Linux? (I have > seen some ways with the win32clipboard module, and so thought maybe one > has to do a similar thing for each platform). > > 2) I would like to be able to copy formatting (bold, italics, bullets, > hyperlinks, etc.) into the clipboard and then have Python have access > to the text content and its formatting in such a way that it could be > pasted somewhere within a Python app with formatting preserved. How > can that be done? The way content text will actually be rendered is specified by additional information. There are tons of dedicated languages for that, usually "markup" languages. Some are plain text (and usually open), some binary (and usually proprietary). When you copy a snippet of text from formatted document, depending on the kind of format, on the source application, and even on the copying program, you may or may not copy the formatting together with the content. This will work e.g. for plain text formatting copied from a plain text editor, such as a wikitext copied from its edition frame. Now, this will not give you a styled text. The text will show properly rendered only if the target application (say, your own program) is able to parse, interpret and process the formatting information supplied together with the content. Meaning it must 'know' the markup language. Or, you must use a translation tool from the source markup to another that is known by the target application. Also note that most markup languages such as the various wikilang dialects & the various versions of x/html do not (or rather should not) actually describe the *aspect* of the rendered text, instead they specify the kind, class, meaning of portions of text, such as "this is title" or "this is an important note", "this a book reference". Then, at rendering time, the engine will look for a description of each of these text style classes, which is most often specified in separate style sheets, e.g. CSS files. There are several relevant reasons for that. Denis > Thanks for any suggestions or thoughts. > Che -- la vida e estranya ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] import confusion
On Mon, Jan 26, 2009 at 12:31 AM, Marc Tompkins wrote: > Someone will no doubt phrase this better, but let's take a shot... > > 2) "import django" makes the entire django package and all sub-modules > available. You could then refer to django.forms.DecimalField and > django.contrib.auth.ImproperlyConfigured (for example) in your program, no > further imports needed. No; in general, import x does not make module x.y available for use, you have to explicitly import x.y In [1]: import django In [2]: django.forms --- AttributeErrorTraceback (most recent call last) /Users/kent/ in () AttributeError: 'module' object has no attribute 'forms' There are some exceptions that confuse the issue, for example you can import os and then use os.path.whatever. Other than that you are correct. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Sort of database & "family tree" question
Hello, I'm writing an application that stores people with some info. I'm doing this with ConfigParser and it works, but currently (for testing), there are only 10 persons in it. What if I add, let's say, about 500-600 or even more? Is this still a good choice? So my entry's look like this (more or less ;)): [person1] firstName = foo lastName = bar father = person2 mother = person3 Now, I want to make a family tree out of this, something that looks like the following scheme (hope the formating will be kept): For person "foo bar", on his father-side, and mother-side the same. | father | father--< | | mother person2--< | | father | mother--< | mother Greets, Timo ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sort of database & "family tree" question
Timo wrote: Hello, I'm writing an application that stores people with some info. I'm doing this with ConfigParser and it works, but currently (for testing), there are only 10 persons in it. What if I add, let's say, about 500-600 or even more? Is this still a good choice? Last week, I created a 31MB ConfigParser file with 1 section and 7 or 8 key/value pairs (the values were a bit long-ish). Constructing it and writing it to disk took about 50 seconds. I don't expect that 600 people will give you that much data. Before you start optimizing the data format, I'd suggest you first check whether you have a problem in the first place. Generate 1000 or 2000 (or 5000 or more!) entries with a small program, try loading the file, and see what happens. So my entry's look like this (more or less ;)): [person1] firstName = foo lastName = bar father = person2 mother = person3 Imho the BIG advantage of ConfigParser over just about any other format is that it is simple, human-readable, and human-editable. That makes it an ideal format for development. If the relations you want to express in the data fit in the format, then I'd stick with ConfigParser format until I encounter serious problems. If you do encounter serious problems somewhere in the future, you can decide at that moment what to do (you'd make a better informed choice at that time too), and convert your data to a better format then. Sincerely, Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sort of database & "family tree" question
Le Mon, 26 Jan 2009 14:58:43 +0100, Timo a écrit : > Hello, > > I'm writing an application that stores people with some info. I'm doing > this with ConfigParser and it works, but currently (for testing), there > are only 10 persons in it. What if I add, let's say, about 500-600 or > even more? Is this still a good choice? > > So my entry's look like this (more or less ;)): > [person1] > firstName = foo > lastName = bar > father = person2 > mother = person3 > > > Now, I want to make a family tree out of this, something that looks like > the following scheme (hope the formating will be kept): > > For person "foo bar", on his father-side, and mother-side the same. > > | father > | father--< > | | mother > person2--< > | | father > | mother--< > | mother > > Greets, > Timo > You may build a custom type with 2 attributes 'father' & 'mother', plus a name. The list of objects of this type would be directly populated from your data file. "Terminal" persons (the tree's leaves) could have a special value (e.g. None) for their parent attributes, or you could add a special 'leaf' logical attribute to identify them. This type can also implement a proper output using __str__ or __repr__ Not tested: class Person(object): def __init__(self, name, father=None, mother=None): self.name = name self,father,self.mother = father,mother if mother and father: self.is_leaf = True else: self.is_leaf = False def __str__(self): if self.is_leaf: return self.name return "\t\t%s\n%s %s" % (self.name,self.father.name,self.mother.name) [As the "family" structure is recursive, you can also easily define a recursive "treeView" method that recursively calls parent's own treeView.] Denis -- la vida e estranya ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sort of database & "family tree" question
"Timo" wrote I'm writing an application that stores people with some info. I'm doing this with ConfigParser and it works, but currently (for testing), there are only 10 persons in it. What if I add, let's say, about 500-600 or even more? Is this still a good choice? I'd be happy with this for up to say 1000 people(arbitrary choice) but for more than that I'd go with shelve. So my entry's look like this (more or less ;)): [person1] firstName = foo lastName = bar father = person2 mother = person3 And I assume you are reading these into a Person class and storing these classes in a persons dictionary? Then to access a father becomes: x = 'Person5' print Persons[x].father.firstName Now, I want to make a family tree out of this, something that looks like the following scheme (hope the formating will be kept): For person "foo bar", on his father-side, and mother-side the same. | father | father--< | | mother person2--< | | father | mother--< | mother You don't necessarily need to store the tree if you only want to display it. Using the Persons dictionary approach you can easily write a function to traverse the tree by following the links to the top of the tree. (Note this means some people will have to have None as father/mother!) Similarly you can write a function to find everyone whose father or mother is X and so on. For small scale data this is probably easier than building a full tree structure from your config file. Although that's always an option too and for larger datasets would be more performant. But then I'd move to pickle or shelve because you could load/save the whole tree in one go. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
Title: Signature.html Its own image class. Interesting. ImageTk, apparently. Looking for more on the web finds: From a NM Tech PIL pdf: This module is for use with the graphical user interface functions of the Tkinter package. For more information about the Tkinter widget set, see the local Tkinter page. Going there was of no help. Lundh doesn't mention it in his Intro to Tkinter. Tkinter Handbook doesn't seem to mention it. I see a PhotoImageand bit class in a Pythonware doc. ImageTk appears to be a module. Ah, the NM Tech PIL doc has some words about it. It doesn't discuss it in much detail though. Maybe it has the same methods as PIL Image? new, composite, ... Ran into another problem by changing to import Tkinter. This gets me to: draw.line((0,0),(20,100), fill=128) TypeError: line() got multiple values for keyword argument 'fill' (Interesting that the tuples here are not the way they were entered.) Alan Gauld wrote: "Wayne Watson" wrote I'm not familiar with the Image and ImageDraw modules but what I think is happening is... import Image, ImageDraw from Tkinter import * By doing this you have hidden Image because Tkinter has its own Image class. im = Image.open("wagon.tif") This is calling open() on Tkinter.Image You need to either import Image as an alias or use import Tkinter instead of from Tkinter. HTH, -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) Copper and its alloys have been found effective in hospital sinks, hand rails, beds, ... in significantly reducing bacteria. Estimates are 1/20 people admitted to a hospital become infected, and 1/20 die from the infection. -- NPR Science Friday, 01/16/2009 Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
"Wayne Watson" wrote lIts own image class. Interesting. ImageTk, apparently. No just image. imageTk wouldn't hide your Image. from Tkinter import * Image help(Image) Help on class Image in module Tkinter: class Image | Base class for images. | | Methods defined here: | | __del__(self) | | __getitem__(self, key) | | __init__(self, imgtype, name=None, cnf={}, master=None, **kw) | | __setitem__(self, key, value) | | __str__(self) | | config = configure(self, **kw) | | configure(self, **kw) | Configure the image. | | height(self) | Return the height of the image. | | type(self) | Return the type of the imgage, e.g. "photo" or "bitmap". | | width(self) | Return the width of the image. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Program: Newton's Method
Welcome - this seems to be your first encounter with Python Tutor. It is essential when asking questions like this that you state explicitly what problem you are having. If the program runs and gives unexpected results, tell us that, and show some input, the expected results and the actual results. If the program raises an exception, post the entire traceback. If something else, explain that. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
(Ah, if I could only learn to press Reply All! ) Glad you jogged my memory on the interactive facility. BTW, how do I clear the keyboard imports? Using >>> from Image import * >>> Image >>> help(Image) Help on class Image in module Image: class Image | Methods defined here: | | __getattr__(self, name) | | __init__(self) | | convert(self, mode=None, data="" dither=None, palette=0, colors=256) | Convert to other pixel format | | copy(self) | Copy raster data | | crop(self, box=None) | Crop region from image | | draft(self, mode, size) | Configure image decoder | | filter(self, filter) | Apply environment filter to image | | fromstring(self, data, decoder_name='raw', *args) | Load data to image from binary string | ... This is definitely different than the Tkimage help you showed. I just followed the above entries for those you used below, and the Help(Image) reverts to the base class. So what's happening? How do I use the two Image classes to navigate between an image that uses PIL methods and one than uses Tkinter? Or another way of putting it, how do I use, say, arc in each class to work on their particular objects? Moreover, how do I attach the PIL image to the Tkinter canvas widget, where I'd like to work on it? Alan Gauld wrote: "Wayne Watson" wrote lIts own image class. Interesting. ImageTk, apparently. No just image. imageTk wouldn't hide your Image. from Tkinter import * Image help(Image) Help on class Image in module Tkinter: class Image | Base class for images. | | Methods defined here: | | __del__(self) | | __getitem__(self, key) | | __init__(self, imgtype, name=None, cnf={}, master=None, **kw) | | __setitem__(self, key, value) | | __str__(self) | | config = configure(self, **kw) | | configure(self, **kw) | Configure the image. | | height(self) | Return the height of the image. | | type(self) | Return the type of the imgage, e.g. "photo" or "bitmap". | | width(self) | Return the width of the image. HTH, -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) Copper and its alloys have been found effective in hospital sinks, hand rails, beds, ... in significantly reducing bacteria. Estimates are 1/20 people admitted to a hospital become infected, and 1/20 die from the infection. -- NPR Science Friday, 01/16/2009 Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
"Wayne Watson" wrote Image help(Image) Help on class Image in module Image: ... This is definitely different than the Tkimage help you showed. So what's happening? You import your Image module as Image. Then you import all; the names from Tkinter which includes the name Image. Thus the Tkinter Imahe hides the original imported Image. You need to either import Image as im# or some other alias or not use from Tkinter, ie use import Tkinter as T Then use T.Image to refer to the Tkinter Image and im to refer to the imported Image module Its all about controlling namespaces. It is exactly because of these kinds of problems that the from X import * style is considered a bad idea. (In Tkinter it usually works because the names are pretty GUI specific but if, as you are doing, you mix GUI and graphics you get overlaps. How do I use the two Image classes to navigate between an image that uses PIL methods and one than uses Tkinter? Just use the appropriate module prefix (or an alias) See the namespaces topic in my tutor for a refresher on namespaces! :-) -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
> how do I clear the keyboard imports? I'm not sure what you mean by keyboard imports? Do you mean how to restore an interactive session? If so, then in IDLE you can use: Shell->Restart shell. I don't know how to do that in any of the other IDEs... You can of course del() any name, including modules... Alan G.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] What Centroid Algorithm Is This?
I'm looking at a GUI program that handles meteor images. They leave a trail across the sky. Each video frame (30 fps) provides data on the track, and a centroid is found around each track point. 'm not familiar with the algorithm that does this, but part of it is in the three def stmts below. Maybe someone can hazard a guess? It looks like someone had fun doing this. def MakeSelectsAndWeights( self ): global SELECT1, SELECT2 global WEIGHT1, WEIGHT2 a1 = indices((640,))[0] a2 = a1 + a1 * (701.0-640.0)/702.0 a3 = floor(a2) SELECT1 = a3.astype( intc ) SELECT2 = SELECT1 + 1 WEIGHT2 = a2 - a3 WEIGHT1 = 1.0 - WEIGHT2 One more def Centroid( self, ref, curr, mask ): slopes = indices((488,722),int32) nada = zeros((488,722),uint8) result = where(curr > ref, curr-ref, nada) result = where(result > mask, result-mask, nada) xresult = result * slopes[1] yresult = result * slopes[0] total = sum(ravel(asarray(result,int32))) count = sum(ravel(result > 0)) if total == 0: return 360,240,0,0 xpos = sum(ravel(xresult))/total ypos = sum(ravel(yresult))/total return xpos,ypos,total,count Another def Central( self, ref, curr, mask ): slopes = indices((488,722),int32) nada = zeros((488,722),uint8) result = where(curr > ref, curr-ref, nada) result = where(result > mask, result-mask, nada) total = sum(ravel(asarray(result,int32))) count = sum(ravel(result > 0)) if total == 0: print "Count: %d Total: %d" % (count,total) return 361,244,0,0 blur = result[0:-2, 0:-2] blur += result[0:-2, 1:-1] blur += result[0:-2, 2: ] blur += result[1:-1, 0:-2] blur += result[1:-1, 1:-1] blur += result[1:-1, 2: ] blur += result[2: , 0:-2] blur += result[2: , 1:-1] blur += result[2: , 2: ] index = argmax(ravel(blur)) ypos, xpos = divmod(index, 720) xpos += 1 ypos += 1 return xpos,ypos,total,count -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) Copper and its alloys have been found effective in hospital sinks, hand rails, beds, ... in significantly reducing bacteria. Estimates are 1/20 people admitted to a hospital become infected, and 1/20 die from the infection. -- NPR Science Friday, 01/16/2009 Web Page: ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] clipboard questions
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Mon, 26 Jan 2009 10:13:15 + > Subject: Re: [Tutor] clipboard questions > > > "Che M" wrote > >> I'm curious about how to interact with the contents of the clipboard >> effectively and have a couple of questions... >> >> 1) Is there one cross-platform way to read the clipboard, > > In a generic sense no. But if the cut n paste is within a single > application then yes, you can use a cross platform GUI framework. > That will work across OS versions. Where it gets messy is if you > want to paste from the generic OS clipboard into your application > and different frameworks vary in how well they handle that. Ahh, yes, that's a problem, because I am interested in using the clipboard for cross-application cut/copy/paste, in fact from/to my apps to any apps on any platform. (One to all; all to one). >> 2) I would like to be able to copy formatting (bold, italics, >> bullets, >> hyperlinks, etc.) into the clipboard and then have Python have >> access >> to the text content and its formatting > > Thats even more tricky because not all clipboards will capture > formatting codes in their original form. Some require special > commands/events. It may also depend on the application that > you are copying from. For example consider a MacOS web > browser. Do you want to copy the underlying HTML formatting > tags? Or the display PDF codes which are used by the Aqua > graphics system used by the browser to actually display the > output? I would like to copy whatever makes the most sense for that context, similarly to how Word can accept a lot of different formatting one could copy from, say, the web, and have it show up in a similar way in the document. Bold, italics, colors, underline, paragraph breaks, bullets, fonts, font-size, alignment, etc., such that it looks the same in both windows. Ideally, images, too. >> In other words your display mechanism will need to be able > to display whatever the clipboard passes. And your applucatin > will need to be able to extract the data from it (eg parse PDF > or RTF etc) Right. OK. > Cut n paste between apps is non trivial even on a single OS > and within a single framework. But if you have mixed environments > it can get really messy in my experience! If it's all within a single > framework then its not so bad. I thought that was probably the reality, and I find that too bad. Easy inter-app communication is a great thing, and I can't help but wish there was some built-in module in Python to help with this (I know, I know, I'm being greedy, there are already so many great modules!) in this most complete way that I am hoping for. There is, e.g., a very nice rich text control in wxPython, but for a few years now it has been bereft of rich text input/output, including cut/copy/paste or open/save, and so it sort of isolates the widget from inter-use with Word or OpenOffice.org, AbiWord, etc., though it can save as HTML. I don't know C++, so I feel I cannot be helpful on adding this (wanted) functionality to the wxWidget itself, but was wondering if, while the actual widget was still waiting for that enhancement (which may or may not ever come, it depends on if someone takes it on), I could maybe take a misguided scratch at making some kind of pure Python go-between that could read out the clipboard and paste it into the richtextctrl and tell the control how to handle the formatting, and then vice-versa. Maybe there is a way to start to do this with HTML at least; Phillip Piper made this code for that purpose, here: http://code.activestate.com/recipes/474121/ Although I don't understand this statement by him, "It would be nice to have this as a data object in wxPython, but that doesn't support the necessary clipboard system calls (RegisterClipboardFormat is essential)." What does he mean by necessary clipboard system calls? Note, this will not of course copy Word formatting codes, so there is no Word --> Python pasting, though he claims there is Python --> Word pasting (of HTML I guess). All this makes me think this is probably beyond what I can reasonably accomplish at this point in my understanding. Thanks for the insight. Che > Alan G > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _ Windows Live™: E-mail. Chat. Share. Get more ways to connect. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_012009 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] import imports
Hello, Here are some ideas around import. I wish to receive comments and to learn whether they fit python. As I am not a highly experimented programmer, there may be some features or practices I do know know or do not know well. The following ideas are not dependant of each other, but as they all concern the import topic, I thought they could be grouped in a single message anyway. === import transmission === The module attribute __all__ allows defining names to be exported. I always use it for my own modules, and also sometimes define it in external modules, when absent, or adapt it to my needs. Then I'm happy with a secure "import *". I find nevertheless an issue in the common case of import "transmission" from module to module, where all imported names usually have to repeated to export. This is not only ugly, imo, but also unpracticle when a single change in an name export list has to be corrected anywhere else; there can easily be a whole chain or even a 'tree' of imports. I have found a way to deal with that, illustrated in below in a case where module M0 imports M1 and M2, which itself imports M3: *** M3 *** M3_names = [actual list of relevant names] __all__ = ["M3_names"] + M3_names *** M2 *** from M3 import * M2_names = [actual list of relevant /local/ names] + M3_names __all__ = ["M2_names"] + M2_names *** M1 *** M1_names = [actual list of relevant names] __all__ = ["M1_names"] + M1_names *** M0 *** from M1 import * from M2 import * M0_names = [actual list of relevant /local/ names] + M1_names + M2_names __all__ = ["M0_names"] + M0_names This has the advantage to avoid repetition, and allow a change in a name export list with no need of "chain correction". Still, it is only a personal trick. I wonder whether such a practice could be officialised with a kind of __imported_names__ module attribute, then understood and usable by all: from Mx import * __all__ = __imported_names__ + [actual list of relevant /local/ names] === semantics of "import *" === "import *" is not recommanded for good reasons, as a blind and risky practice. Now, when this is done consciously, kwowing that the imported module defines __all__, then the meaning is totally different, if not opposite. As a consequence, I am not happy at all with the present ambiguity. My proposal would be: * Either a slightly different syntactic form, meaning "import all names defined for export". [I would like "import **", for '*' and '**' are associated in other cases and this is all about named things. But this point is no issue.] As an additional advantage, imo important, trying this kind of import from a module that does not define __all__ would raise an exception; for instance: ImportError("Module does not define any name list for export.") * Or change the semantics of "import *" to require __all__ to be defined in the pointed module. Obviously, this raises compatibility issues that may or may not be adressed using warnings (and/or "from __future__ import import" ;-}) in a change path. === package module lookup === There is a similar issue at the package/application level: I do not know of any practice or feature that simply allows changing a filename, a directory name, or the organisation of the package's directory tree, without having then to correct all dependance information inside the concerned modules. I would love a kind of import lookup to be based on the following assumption: "The main/startup module resides in the package's root dir." Then any import lookup would automatically explore local, relative, sub directories. E basta! This would also encourage the good practice of never writing absolute imports -- which is a plague. There are probably many good ways to implement that feature clearly and efficiently. Here is proposed an example that only aims at clarifying the feature's meaning & usefulness; but does not pretend to be good. The purpose is python to know not only which modules exist, or which modules are intended to be imported, but also where actually they are -- or should be. This does not only address import from client code but also intra-module dependances. A file called __init__.py is used to identify a package as package and provide information about it. I propose to add a __dir__ attribute to a package, defined inside its __init__.py, that would hold a module directory (in the sense of 'index'). This could be implemented as a python dict holding a set of name:path bindings -- while actually it is pure information. It would be either a complement, or an alternative, to a package's __all__ attribute that lists the module names: __all__ = ["main", "compute", "userinput"] __dir__ = ["main":"/", "compute":"/tools", "userinput":"/interface/dialogs"] Note that the pathes are *relative*. The main point is that __dir__'s value would be set by python itself when it is absent from __init__.py or when it needs beeing updated after any change in the package's tree
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
Title: Signature.html Thanks. Very good. That'll give me something to think about. Where is your namespace tutorial? Alan Gauld wrote: "Wayne Watson" wrote Image help(Image) Help on class Image in module Image: ... This is definitely different than the Tkimage help you showed. So what's happening? You import your Image module as Image. Then you import all; the names from Tkinter which includes the name Image. Thus the Tkinter Imahe hides the original imported Image. You need to either import Image as im # or some other alias or not use from Tkinter, ie use import Tkinter as T Then use T.Image to refer to the Tkinter Image and im to refer to the imported Image module Its all about controlling namespaces. It is exactly because of these kinds of problems that the from X import * style is considered a bad idea. (In Tkinter it usually works because the names are pretty GUI specific but if, as you are doing, you mix GUI and graphics you get overlaps. How do I use the two Image classes to navigate between an image that uses PIL methods and one than uses Tkinter? Just use the appropriate module prefix (or an alias) See the namespaces topic in my tutor for a refresher on namespaces! :-) -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) Copper and its alloys have been found effective in hospital sinks, hand rails, beds, ... in significantly reducing bacteria. Estimates are 1/20 people admitted to a hospital become infected, and 1/20 die from the infection. -- NPR Science Friday, 01/16/2009 Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
I'm using pythonWin. Yes, basically, restore the interactive session. I had done several imports, and wanted the clear them to see what would happen with others I planned on entering without having them affected by earlier ones. Keyboard imports. Just entering "import Tkinter" at the >>> prompt. ALAN GAULD wrote: > how do I clear the keyboard imports? I'm not sure what you mean by keyboard imports? Do you mean how to restore an interactive session? If so, then in IDLE you can use: Shell->Restart shell. I don't know how to do that in any of the other IDEs... You can of course del() any name, including modules... Alan G. -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) Copper and its alloys have been found effective in hospital sinks, hand rails, beds, ... in significantly reducing bacteria. Estimates are 1/20 people admitted to a hospital become infected, and 1/20 die from the infection. -- NPR Science Friday, 01/16/2009 Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What Centroid Algorithm Is This?
On Monday 26 January 2009, Wayne Watson wrote: > the three def stmts below. Maybe someone can hazard a guess? It > looks like someone had fun doing this. First bookmark this webpage. It explains every important function in Numpy: http://www.scipy.org/Numpy_Example_List_With_Doc > def Centroid( self, ref, curr, mask ): ref is maybe dark frame > slopes = indices((488,722),int32) > nada = zeros((488,722),uint8) > Do discrimination; areas that are not covered by the meteor are 0 > result = where(curr > ref, curr-ref, nada) > result = where(result > mask, result-mask, nada) > Compute center of mass http://en.wikipedia.org/wiki/Center_of_mass#Definition Look at first formula - result is m - slopes[1] is x-component of r - slopes[0] is y-component of r > xresult = result * slopes[1] > yresult = result * slopes[0] > total = sum(ravel(asarray(result,int32))) > count = sum(ravel(result > 0)) > if total == 0: > return 360,240,0,0 > > xpos = sum(ravel(xresult))/total > ypos = sum(ravel(yresult))/total > > return xpos,ypos,total,count Example algorithm done in Ipython invoked with ipython --pylab In [20]:weights = array([0,0,1,1,1],'d') #These are three weights of mass 1. #They are located at the positions 2, 3, 4. #The center of gravity is therefore at position 3. In [21]:distances = indices(weights.shape) In [22]:distances Out[22]:array([[0, 1, 2, 3, 4]]) In [23]:moments = weights * distances In [24]:moments Out[24]:array([[ 0., 0., 2., 3., 4.]]) In [25]:tot_weight = sum(weights) In [26]:tot_moment = sum(moments) In [27]:center = tot_moment/tot_weight In [28]:center Out[28]:3.0 #Yay, this is the correct result! Kind regards, Eike. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tk+Ipython unexpected behavior
Hi all, I'm going through "An Introduction to Tkinter" by Fredrik Lundh and came across (what seems to be) some slightly unexpected behavior. I'm editing the python file with my favorite text editor, and using the %run magic function in Ipython to test my program(s). On the second example(pg 4 of the PDF), the frame.quit method is bound to a quit button. When I double click the .py file to run it, it closes when the quit button is pressed. But with Ipython, when the quit button is pressed, it unblocks the Ipython input but doesn't actually quit the window. A call to root.quit() will not close the window, only a call to root.destroy(). I'm not terribly worried about it, but I'm curious if it should be considered a bug or simply "unexpected behavior". -Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] using a for loop with feedparser
Hello, I am trying to parse a feed and insert some feed elements into a Django project database. I believe I should be able to use for loop to iterate over the list elements. I am using the Universal Feed parser (http://www.feedparser.org/). I am able to extract items one by one and insert them into a database (code below). As my first try at this, I would like to print the titles of all the feed entries. I tried this import feedparser d = feedparser.parse('http://feeds.delicious.com/v2/rss/utools') for item in d.entries: print item This prints all the feed entries and their values. Any thoughts on how I could just print the titles? Thank you, Tonu Code to save a single feed item into the database: #!/usr/local/bin/python import feedparser import os.path import sys, os import django.contrib.auth sys.path.append ('/home/dmc/projects/django_bookmarks') os.environ['DJANGO_SETTINGS_MODULE']='settings' from django.contrib.auth.models import User from bookmarks.models import * d = feedparser.parse('http://feeds.delicious.com/v2/rss/utools') link1 = Link(url=d.entries[0].link) link1.save() user = User.objects.get(id=1) link = Link.objects.get(id=1) bookmark = Bookmark ( title = d.entries[0].title, desc = d.entries[0].description, link = link, user = user, ) bookmark.save() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] using a for loop with feedparser
Tonu Mikk wrote: Hello, I am trying to parse a feed and insert some feed elements into a Django project database. I believe I should be able to use for loop to iterate over the list elements. I am using the Universal Feed parser (http://www.feedparser.org/). I am able to extract items one by one and insert them into a database (code below). As my first try at this, I would like to print the titles of all the feed entries. I tried this import feedparser d = feedparser.parse('http://feeds.delicious.com/v2/rss/utools') for item in d.entries: print item This prints all the feed entries and their values. Any thoughts on how I could just print the titles? I found out the answer after trying some more. To print the title only, I need to do this: for item in d.entries: print item.title Code to save a single feed item into the database: #!/usr/local/bin/python import feedparser import os.path import sys, os import django.contrib.auth sys.path.append ('/home/dmc/projects/django_bookmarks') os.environ['DJANGO_SETTINGS_MODULE']='settings' from django.contrib.auth.models import User from bookmarks.models import * d = feedparser.parse('http://feeds.delicious.com/v2/rss/utools') link1 = Link(url=d.entries[0].link) link1.save() user = User.objects.get(id=1) link = Link.objects.get(id=1) bookmark = Bookmark ( title = d.entries[0].title, desc = d.entries[0].description, link = link, user = user, ) bookmark.save() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Tonu Mikk Educational Technology Consultant Digital Media Center - dmc.umn.edu tm...@umn.edu 612 625-9221 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What Centroid Algorithm Is This?
Title: Signature.html Thanks for the annotations and references. I see a fair number of functions in Numpy, but none called centroid. Is there a name for this particular algorithm? I suspect there are many such methods. It looks like there many be several concepts at play here that fit together into a whole. I may have to get out my really old Num Recipies book. :-) Eike Welk wrote: On Monday 26 January 2009, Wayne Watson wrote: the three def stmts below. Maybe someone can hazard a guess? It looks like someone had fun doing this. First bookmark this webpage. It explains every important function in Numpy: http://www.scipy.org/Numpy_Example_List_With_Doc def Centroid( self, ref, curr, mask ): ref is maybe dark frame slopes = indices((488,722),int32) nada = zeros((488,722),uint8) Do discrimination; areas that are not covered by the meteor are 0 result = where(curr > ref, curr-ref, nada) result = where(result > mask, result-mask, nada) Compute center of mass http://en.wikipedia.org/wiki/Center_of_mass#Definition Look at first formula - result is m - slopes[1] is x-component of r - slopes[0] is y-component of r xresult = result * slopes[1] yresult = result * slopes[0] total = sum(ravel(asarray(result,int32))) count = sum(ravel(result > 0)) if total == 0: return 360,240,0,0 xpos = sum(ravel(xresult))/total ypos = sum(ravel(yresult))/total return xpos,ypos,total,count Example algorithm done in Ipython invoked with ipython --pylab In [20]:weights = array([0,0,1,1,1],'d') #These are three weights of mass 1. #They are located at the positions 2, 3, 4. #The center of gravity is therefore at position 3. In [21]:distances = indices(weights.shape) In [22]:distances Out[22]:array([[0, 1, 2, 3, 4]]) In [23]:moments = weights * distances In [24]:moments Out[24]:array([[ 0., 0., 2., 3., 4.]]) In [25]:tot_weight = sum(weights) In [26]:tot_moment = sum(moments) In [27]:center = tot_moment/tot_weight In [28]:center Out[28]:3.0 #Yay, this is the correct result! Kind regards, Eike. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) Copper and its alloys have been found effective in hospital sinks, hand rails, beds, ... in significantly reducing bacteria. Estimates are 1/20 people admitted to a hospital become infected, and 1/20 die from the infection. -- NPR Science Friday, 01/16/2009 Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] using a for loop with feedparser
I now have a new question related to the same project. I currently have a code snippet like this: 1.for item in d.entries: 2.link = Link(url=item.link) 3.link.save() 4.user = User.objects.get(id=1) 5.link = Link.objects.get(id=1) 6.bookmark = Bookmark ( 7.title = item.title, 8.desc = item.description, 9.link = link, 10. user = user, 11. ) 12. bookmark.save() I need to increment the link id (line 5) for each item in the d.entries. I tried "link = Link.objects.get(id=id+1)" and "link = Link.objects.get((id=1)+1)", but both of them generated errors. I am not quite sure where to go from here. Thank you, Tonu Tonu Mikk wrote: Tonu Mikk wrote: Hello, I am trying to parse a feed and insert some feed elements into a Django project database. I believe I should be able to use for loop to iterate over the list elements. I am using the Universal Feed parser (http://www.feedparser.org/). I am able to extract items one by one and insert them into a database (code below). As my first try at this, I would like to print the titles of all the feed entries. I tried this import feedparser d = feedparser.parse('http://feeds.delicious.com/v2/rss/utools') for item in d.entries: print item This prints all the feed entries and their values. Any thoughts on how I could just print the titles? I found out the answer after trying some more. To print the title only, I need to do this: for item in d.entries: print item.title Code to save a single feed item into the database: #!/usr/local/bin/python import feedparser import os.path import sys, os import django.contrib.auth sys.path.append ('/home/dmc/projects/django_bookmarks') os.environ['DJANGO_SETTINGS_MODULE']='settings' from django.contrib.auth.models import User from bookmarks.models import * d = feedparser.parse('http://feeds.delicious.com/v2/rss/utools') link1 = Link(url=d.entries[0].link) link1.save() user = User.objects.get(id=1) link = Link.objects.get(id=1) bookmark = Bookmark ( title = d.entries[0].title, desc = d.entries[0].description, link = link, user = user, ) bookmark.save() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
"Wayne Watson" wrote Where is your namespace tutorial? Check my .sig... :-) -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] import imports
"spir" wrote Here are some ideas around import. I wish to receive comments The module attribute __all__ allows defining names to be exported. I always use it for my own modules, and also sometimes define it in external modules, when absent, or adapt it to my needs. I've never defined it in any of my modules. It encourages people to use from X import * which is nearly always a bad idea. Then I'm happy with a secure "import *". I'm not sure what you mean by a secure import *. The only danger is that of name collisions and limiting the exported names only helps by a tiny amount. There is still a good chance that another module will have the same name exported. ...unpracticle when a single change in an name export list has to be corrected anywhere else; there can easily be a whole chain or even a 'tree' of imports. Exactly, thats why its a bad idea IMHO. You can never predict what other modules your module might be used with and to start customising other peoples modules to your own envirohnment leads to madness in my view! "import *" is not recommanded for good reasons, as a blind and risky practice. Now, when this is done consciously, knowing that the imported module defines __all__, then the meaning is totally different, if not opposite. Not at all. Two modules could still have conflicting names. I don;t see how you can avoid it. Thats why using import foo is better. import foo also has the advantage of forcing code to explicitly flag where imported functions and classes are found. This makes debugging and maintence far easier. import * is a "bad idea" for all sorts of reasons. Namespaces are powerful tools - lets use them. === package module lookup === There is a similar issue at the package/application level: I do not know of any practice or feature that simply allows changing a filename, a directory name, or the organisation of the package's directory tree, without having then to correct all dependance information inside the concerned modules. This is a more valid issue although if you always import both package and subpackages directly and especially if you use aliases to protect your code references from change import foo as f means even if foo changes name you only need to change the import statement not all the references to f.x I would love a kind of import lookup to be based on the following assumption: "The main/startup module resides in the package's root dir." But most packages don;t have a startup or main module. They are libraries that the application writer uses. Thus the app writer provides the main or startup module not the package writer. This would also encourage the good practice of never writing absolute imports -- which is a plague. I'm not sure what you mean by absolute imports. If you mean giving the physical path to the file then You cannot really do that in Python. I don't understand the comment? The purpose is python to know not only which modules exist, or which modules are intended to be imported, but also where actually they are -- or should be. I thought it did that already? It looks in sys.path for modules and when it finds them it sets the __file__ attribute if appropriate.. I got lost around here. I assume you are having problems with modules that I've never encountered? -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tk+Ipython unexpected behavior
"W W" wrote the frame.quit method is bound to a quit button. When I double click the .py file to run it, it closes when the quit button is pressed. But with Ipython, when the quit button is pressed, it unblocks the Ipython input but doesn't actually quit the window. I don't know what framework IPython uses but Tkinter is renowned for running in irregular ways from inside IDEs - even ones not written in Tkinter!. My recommendation for testing Tkinter (or indeed any GUI) programs is to always run them from an OS prompt. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] using a for loop with feedparser
On Mon, Jan 26, 2009 at 4:53 PM, Tonu Mikk wrote: > I now have a new question related to the same project. I currently have a > code snippet like this: > > 1.for item in d.entries: > 2.link = Link(url=item.link) > 3.link.save() > 4.user = User.objects.get(id=1) > 5.link = Link.objects.get(id=1) > 6.bookmark = Bookmark ( > 7.title = item.title, > 8.desc = item.description, > 9.link = link, > 10. user = user, > 11. ) > 12. bookmark.save() > > I need to increment the link id (line 5) for each item in the d.entries. I > tried "link = Link.objects.get(id=id+1)" and "link = > Link.objects.get((id=1)+1)", but both of them generated errors. I am not > quite sure where to go from here. Are you trying to retrieve the Link you just saved in line 3? Why not just use the link variable you already have? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tk+Ipython unexpected behavior
On Mon, Jan 26, 2009 at 5:41 PM, Alan Gauld wrote: > I don't know what framework IPython uses None, it is an enhanced Python interactive shell, you should check it out! Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] datetime year problem, default year available?
Hello Tutors, I have some questions on setting the year in a datetime object via strptime. The issues is that in my date string I only have a day and a month ('11/27' for example). Now when I use datetime.strptime('11/27', ''%m/%d) I get a datetime object but the year is 1900. This makes sense as I did not provide one. Then I saw that a datetime object has a replace function so now I could replace a 1900 by 2008 (we can assume the year is 2008). Then we can do datetime.strptime('11/27', '%m/%d').replace(year=2008) and it works but... Is there a way to set a default year when none is provide to strptime? Or is there another way to handle this? Many thanks, Sander ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tk+Ipython unexpected behavior
"Kent Johnson" wrote I don't know what framework IPython uses None, it is an enhanced Python interactive shell, you should check it out! I've looked a couple of times at the web site but never bothered downloading it. I got the impression it was a GUI shell window like PyCrust but from your comment I assume I'm wrong in that idea and it runs in a normal console window? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tk+Ipython unexpected behavior
On Mon, Jan 26, 2009 at 8:17 PM, Alan Gauld wrote: > > "Kent Johnson" wrote > >>> I don't know what framework IPython uses >> >> None, it is an enhanced Python interactive shell, you should check it out! > > I've looked a couple of times at the web site but never bothered > downloading it. I got the impression it was a GUI shell window > like PyCrust but from your comment I assume I'm wrong in that > idea and it runs in a normal console window? Yes, it is a text app that runs in a console window. It has many features; my favorites are listed here: http://personalpages.tds.net/~kent37/kk/00011.html Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tk+Ipython unexpected behavior
* Kent Johnson [090127 03:39]: > Yes, it is a text app that runs in a console window. It has many > features; my favorites are listed here: > http://personalpages.tds.net/~kent37/kk/00011.html The links on your page are broken: See: http://ipython.scipy.org/doc/manual/html/ In fact Ipython is so feature rich, some people even use it as login shell. Short demo: % ipython Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32) Type "copyright", "credits" or "license" for more information. IPython 0.8.4 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [2]: %magic IPython's 'magic' functions === The magic function system provides a series of functions which allow you to control the behavior of IPython itself, plus a lot of system-type features. All these functions are prefixed with a % character, [ snip ] In [8]: ls -a .zshrc .zshrc* In [9]: _i Out[9]: u'_ip.system("ls -F -a .zshrc")\n' In [12]: s = !ls -altr .zshrc In [13]: s Out[13]: SList (.p, .n, .l, .s, .grep(), .fields() available). Value: 0: -rw--- 1 joe joe 12753 2009-01-02 01:32 .zshrc In [14]: for i in s: : print i : : -rw--- 1 joe joe 12753 2009-01-02 01:32 .zshrc In [18]: store s Stored 's' (SList) In [19]: store Stored variables and their in-db values: s -> ['-rw--- 1 joe joe 12753 2009-01-02 01:32 .zsh In [20]: a="/tmp" In [21]: ls $a jRs.tmp lost+found/ In [22]: %edit # opens Editor etc... -- Freedom, Freedom, Freedom, Oi! -- Zoidberg NUR NOCH BIS 31.01.! GMX FreeDSL - Telefonanschluss + DSL für nur 16,37 EURO/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] import site failed (WinXP)
Hello, Since yesterday I've been having problems running Python. I've been getting the error "import site failed; use -v for traceback". IDLE won't start either. The traceback seems to sugget that Python "cannot import name aliases". I've tried uninstalling and reinstalling Python and also installing a newer version of Python, but the problem persists even if I try installing Python 2.6 instead of Python 2.5.2 which I had installed till yesterday. I'm on Windows XP SP3. Here's the traceback: C:\Documents and Settings\Alexei>c:\python25\python.exe -v # installing zipimport hook import zipimport # builtin # installed zipimport hook # c:\python25\lib\site.pyc matches c:\python25\lib\site.py import site # precompiled from c:\python25\lib\site.pyc # c:\python25\lib\os.pyc matches c:\python25\lib\os.py import os # precompiled from c:\python25\lib\os.pyc import errno # builtin import nt # builtin # c:\python25\lib\ntpath.pyc matches c:\python25\lib\ntpath.py import ntpath # precompiled from c:\python25\lib\ntpath.pyc # c:\python25\lib\stat.pyc matches c:\python25\lib\stat.py import stat # precompiled from c:\python25\lib\stat.pyc # c:\python25\lib\UserDict.pyc matches c:\python25\lib\UserDict.py import UserDict # precompiled from c:\python25\lib\UserDict.pyc # c:\python25\lib\copy_reg.pyc matches c:\python25\lib\copy_reg.py import copy_reg # precompiled from c:\python25\lib\copy_reg.pyc # c:\python25\lib\types.pyc matches c:\python25\lib\types.py import types # precompiled from c:\python25\lib\types.pyc import _types # builtin # c:\python25\lib\locale.pyc matches c:\python25\lib\locale.py import locale # precompiled from c:\python25\lib\locale.pyc import encodings # directory c:\python25\lib\encodings # c:\python25\lib\encodings\__init__.pyc matches c:\python25\lib\encodings\__ini t__.py import encodings # precompiled from c:\python25\lib\encodings\__init__.pyc # c:\python25\lib\codecs.pyc matches c:\python25\lib\codecs.py import codecs # precompiled from c:\python25\lib\codecs.pyc import _codecs # builtin 'import site' failed; traceback: Traceback (most recent call last): File "C:\Python25\lib\site.py", line 415, in main() File "C:\Python25\lib\site.py", line 406, in main aliasmbcs() File "C:\Python25\lib\site.py", line 356, in aliasmbcs import locale, codecs File "C:\Python25\lib\locale.py", line 14, in import sys, encodings, encodings.aliases File "C:\Python25\lib\encodings\__init__.py", line 32, in from encodings import aliases ImportError: cannot import name aliases # c:\python25\lib\warnings.pyc matches c:\python25\lib\warnings.py import warnings # precompiled from c:\python25\lib\warnings.pyc # c:\python25\lib\linecache.pyc matches c:\python25\lib\linecache.py import linecache # precompiled from c:\python25\lib\linecache.pyc Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> -- Alexei Vinidiktov ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How Do I Put an Image on a Canvas and Display it?
I'm missing it. Author of the Learn to Program web site http://www.alan-g.me.uk/ ?? I don't see anything about namespaces there. Alan Gauld wrote: "Wayne Watson" wrote Where is your namespace tutorial? Check my .sig... :-) -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) Copper and its alloys have been found effective in hospital sinks, hand rails, beds, ... in significantly reducing bacteria. Estimates are 1/20 people admitted to a hospital become infected, and 1/20 die from the infection. -- NPR Science Friday, 01/16/2009 Web Page:___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor