Re: [Tutor] The Disappearing Program (py2exe)

2010-02-20 Thread Alan Gauld
"Wayne Watson" wrote File "matplotlib\__init__.pyc", line 478, in _get_data_path RuntimeError: Could not find the matplotlib data files <---What is this? C:\Users\Wayne\Sandia_Meteors\Sentinel_Development\Learn_Python\Py2exe_Test\dist> == I G

Re: [Tutor] ask

2010-02-20 Thread Alan Gauld
"Shurui Liu (Aaron Liu)" wrote How to describe a math formula: sphere=(4/3)*PI*R**3? I'm not sure what you are asking? Shurui Liu (Aaron Liu) Computer Science & Engineering Technology University of Toledo I assume from this that you have a basic knowledge of math so you understand about

Re: [Tutor] The Disappearing Program (py2exe)

2010-02-20 Thread Wayne Watson
Yes, I sent a message there last night. No responses yet. Strangely I don't see it posted yet. That was six hours ago. Well, I finish off my night's sleep in about 4 hours maybe it will have made it.py2exe seems a little less traveled subject than most. On 2/20/2010 1:36 AM, Alan Gauld wrote:

Re: [Tutor] pyMVPA and OSError

2010-02-20 Thread Yaroslav Halchenko
Hi Juli, why not to ask at our mailing list? ;) http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa usually we don't bite too hard ;) so, in your case, would you get similar crash when you simply import pylab ? try to upgrade your pylab installation, or otherwise disable it for

[Tutor] Python 3.0

2010-02-20 Thread Paul Whittaker
Using the following script, the (Windows 7) PC echoes the key presses but doesn't quit (ever!) import msvcrt print('Press SPACE to stop...') while True: k = msvcrt.getch() # Strangely, this echoes to the IDLE window if k == ' ': # Not recognized break _

[Tutor] List append method: St Petersburg Game

2010-02-20 Thread AG
Hi Pythonistas I am having difficulty with applying the list.append(x) method to produce a list that will contain outputs which will become coordinates for a later call to Matplotlib. Perhaps someone here can help me figure this out? The basic program is below: # St Petersburg Game: v. 2:

Re: [Tutor] Python 3.0

2010-02-20 Thread bob gailer
On 2/20/2010 5:52 AM, Paul Whittaker wrote: Using the following script, the (Windows 7) PC echoes the key presses but doesn't quit (ever!) import msvcrt print('Press SPACE to stop...') while True: k = msvcrt.getch() # Strangely, this echoes to the IDLE window if k == ' ':

Re: [Tutor] List append method: St Petersburg Game

2010-02-20 Thread bob gailer
On 2/20/2010 7:43 AM, AG wrote: Hi Pythonistas I am having difficulty with applying the list.append(x) method to produce a list that will contain outputs which will become coordinates for a later call to Matplotlib. Perhaps someone here can help me figure this out? Please let me know how

Re: [Tutor] List append method: St Petersburg Game

2010-02-20 Thread AG
bob gailer wrote: On 2/20/2010 7:43 AM, AG wrote: Please let me know how I can clarify my question 1 - You are giving way too much information. We do not need to know the rules of the game or all the code. Our time to read email is limited. The less you tell us that is not relevant the be

[Tutor] Network Socket question

2010-02-20 Thread Tom Green
Hello group, First, I love this forum as I find it to be a wealth of info on Python and programming in general. I have a general question about sockets, which is what I primarily use Python for. My environment is Windows and I am using Python 2.5. My sockets are working great but now I am runni

Re: [Tutor] The Disappearing Program (py2exe)

2010-02-20 Thread Wayne Watson
This apparently not quite as easy as the py2exe suggests when MPL is involved. See . It looks like I have some reading and work to do. On 2/20/2010 3:21 AM, Wayne Watson wrote: Yes, I sent a message there last night. No responses yet. Strangely I don

Re: [Tutor] The Disappearing Program (py2exe)

2010-02-20 Thread Wayne Watson
(This might be slightly readable. Missed two words.) This apparently is not quite as easy as the py2exe tutorial suggests when MPL is involved. See . It looks like I have some reading and work to do. The link came from my post to the MPL list. I hadn

Re: [Tutor] Python 3.0

2010-02-20 Thread Alan Gauld
"Paul Whittaker" wrote Using the following script, the (Windows 7) PC echoes the key presses but doesn't quit (ever!) import msvcrt print('Press SPACE to stop...') while True: k = msvcrt.getch() # Strangely, this echoes to the IDLE window You will need to run it in an OS command wind

Re: [Tutor] Python 3.0

2010-02-20 Thread Alan Gauld
"bob gailer" wrote k = msvcrt.getch() # Strangely, this echoes to the IDLE window if k == ' ': # Not recognized IOW - getch always returns 1 character. You are testing for a 0 length string. Will never happen. No, he is testing for a space character. But he is runnin

Re: [Tutor] pyMVPA and OSError

2010-02-20 Thread Luke Paireepinart
On Thu, Feb 18, 2010 at 10:23 AM, Juli wrote: > Dear All, > > I am very much new to python, therefore I am likely to feel stupid > about asking this. I need pyMPVA module to play around with some fMRI > data. I have installed Python2.6 on Mac OS X Leopard. When I input >>> > import mvpa i get a d

[Tutor] Superclass call problem

2010-02-20 Thread Alan Harris-Reid
Hi, I am having trouble understanding how superclass calls work. Here's some code... class ParentClass(): def __init__(self): do something here class ChildClass(ParentClass): def __init__(self): super().__init__(self) # call parentclass __init__ method

[Tutor] fast sampling with replacement

2010-02-20 Thread Andrew Fithian
Hi tutor, I'm have a statistical bootstrapping script that is bottlenecking on a python function sample_with_replacement(). I wrote this function myself because I couldn't find a similar function in python's random library. This is the fastest version of the function I could come up with (I used c

Re: [Tutor] Superclass call problem

2010-02-20 Thread Luke Paireepinart
Your call to super is wrong. It should be super and you pass the class and instance, then call init. On 2/20/10, Alan Harris-Reid wrote: > Hi, > > I am having trouble understanding how superclass calls work. Here's > some code... > > class ParentClass(): > def __init__(self): > do so

Re: [Tutor] fast sampling with replacement

2010-02-20 Thread Luke Paireepinart
Can you explain what your function is doing and also post some test code to profile it? On Sat, Feb 20, 2010 at 10:22 AM, Andrew Fithian wrote: > Hi tutor, > > I'm have a statistical bootstrapping script that is bottlenecking on a > python function sample_with_replacement(). I wrote this functio

Re: [Tutor] Superclass call problem

2010-02-20 Thread Kent Johnson
On Sat, Feb 20, 2010 at 12:50 PM, Alan Harris-Reid wrote: > Hi, > > I am having trouble understanding how superclass calls work.  Here's some > code... > > class ParentClass(): >   def __init__(self): >       do something here You should inherit object to use super(): class ParentClass(object):

Re: [Tutor] fast sampling with replacement

2010-02-20 Thread Kent Johnson
On Sat, Feb 20, 2010 at 11:22 AM, Andrew Fithian wrote: > can > you help me speed it up even more? > import random > def sample_with_replacement(list): >     l = len(list) # the sample needs to be as long as list >     r = xrange(l) >     _random = random.random >     return [list[int(_random()*l

Re: [Tutor] Superclass call problem

2010-02-20 Thread Alan Harris-Reid
Kent Johnson wrote: On Sat, Feb 20, 2010 at 12:50 PM, Alan Harris-Reid wrote: Hi, I am having trouble understanding how superclass calls work. Here's some code... class ParentClass(): def __init__(self): do something here You should inherit object to use super(): class Pare

Re: [Tutor] fast sampling with replacement

2010-02-20 Thread Luke Paireepinart
On Sat, Feb 20, 2010 at 1:50 PM, Kent Johnson wrote: > On Sat, Feb 20, 2010 at 11:22 AM, Andrew Fithian > wrote: > > can > > you help me speed it up even more? > > import random > > def sample_with_replacement(list): > > l = len(list) # the sample needs to be as long as list > > r = xra

Re: [Tutor] Superclass call problem

2010-02-20 Thread Luke Paireepinart
> > > Hi Kent, thanks for the reply, > > Sorry, left out 'object' from my example. The actual code already reads > class ParentClass(object): > > Did you figure it out from my previous e-mail? ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

[Tutor] Replacing part of a URL

2010-02-20 Thread Lao Mao
Hello, I need to be able to replace the last bit of a bunch of URLs. The urls look like this: www.somesite.com/some/path/to/something.html They may be of varying lengths, but they'll always end with .something_or_other.html I want to take the "something" and replace it with something else. My

Re: [Tutor] Replacing part of a URL

2010-02-20 Thread Shashwat Anand
>>> url = 'http://www.somesite.com/some/path/to/something.html' >>> var = 'anotherthing' >>> i = url.rfind('/') + 1 >>> j = url.rfind('.') >>> if i < j: ... newurl = url[:i] + var + url[j:] ... else: ... newurl = url[:i] + var >>> newurl 'http://www.somesite.com/some/path/to/anotherthing.ht

Re: [Tutor] Replacing part of a URL

2010-02-20 Thread Shashwat Anand
> > They may be of varying lengths, but they'll always end with > .something_or_other.html > Missed this point. You can use posixpath module too as an option. >>> url = 'http://www.somesite.com/some/path/to/something.html >>> var = 'anotherthing' >>> posixpath.dirname(url) 'http://www.somesite.com

Re: [Tutor] Replacing part of a URL

2010-02-20 Thread Kent Johnson
On Sat, Feb 20, 2010 at 5:34 PM, Lao Mao wrote: > Hello, > I need to be able to replace the last bit of a bunch of URLs. > The urls look like this: > www.somesite.com/some/path/to/something.html > They may be of varying lengths, but they'll always end with > .something_or_other.html > I want to ta

[Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Dayo Adewunmi
Hi all, This script I'm working on, should take all the image files in the current directory and generate an HTML thumbnails. import os import urllib # Generate thumbnail gallery def genThumbs(): # Get current directory name absolutePath = os.getcwd() urlprefix = "http://kili.org/~day

Re: [Tutor] Superclass call problem

2010-02-20 Thread Alan Harris-Reid
Luke Paireepinart wrote: Your call to super is wrong. It should be super and you pass the class and instance, then call init. On 2/20/10, Alan Harris-Reid wrote: Hi, I am having trouble understanding how superclass calls work. Here's some code... class ParentClass(): def __init__(sel

Re: [Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Shashwat Anand
> > for dirname, subdirname, filenames in os.walk(absolutePath): > for filename in filenames: > print "" > %(currentdir,filename,currentdir,filename) > > I see a small typo here. print "" %(currentdir,filename,currentdir,filename) should rather be print "" %(currentdir,filenam

Re: [Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Dayo Adewunmi
Shashwat Anand wrote: for dirname, subdirname, filenames in os.walk(absolutePath): for filename in filenames: print "" %(currentdir,filename,currentdir,filename) I see a small typo here. print "" %(currentdir,filename,currentdir,filename) should rather

Re: [Tutor] Superclass call problem

2010-02-20 Thread Steven D'Aprano
On Sun, 21 Feb 2010 04:50:49 am Alan Harris-Reid wrote: > Hi, > > I am having trouble understanding how superclass calls work. Here's > some code... What version of Python are you using? In Python 2.x, you MUST inherit from object to use super, and you MUST explicitly pass the class and self:

Re: [Tutor] Replacing part of a URL

2010-02-20 Thread Steven D'Aprano
On Sun, 21 Feb 2010 09:34:34 am Lao Mao wrote: > Hello, > > I need to be able to replace the last bit of a bunch of URLs. > > The urls look like this: > > www.somesite.com/some/path/to/something.html > > They may be of varying lengths, but they'll always end with > .something_or_other.html > > I wa

Re: [Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Luke Paireepinart
On Sat, Feb 20, 2010 at 6:11 PM, Dayo Adewunmi wrote: > Shashwat Anand wrote: > >> >> >> >> >> for dirname, subdirname, filenames in os.walk(absolutePath): >> for filename in filenames: >> print "" >>%(currentdir,filename,currentdir,filename) >> >> >> I see a small

Re: [Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Shashwat Anand
> > > > If you're using OS functions you should NOT bank on the slashes being > forward-slashes. This is platform-specific behavior. You should use > os.path.split() to get the elements of your path and do a "/".join() on > them. Otherwise your code will break on Windows because the path will be

Re: [Tutor] Python 3.0

2010-02-20 Thread Mark Tolonen
"bob gailer" wrote in message news:4b7fea0e.6000...@gmail.com... On 2/20/2010 5:52 AM, Paul Whittaker wrote: Using the following script, the (Windows 7) PC echoes the key presses but doesn't quit (ever!) import msvcrt print('Press SPACE to stop...') while True: k = msvcrt.getch()

Re: [Tutor] os.path.basename() issue with path slashes

2010-02-20 Thread Steven D'Aprano
On Sun, 21 Feb 2010 10:49:19 am Dayo Adewunmi wrote: > Hi all, > > This script I'm working on, should take all the image files in the > current directory and generate an HTML thumbnails. > > import os > import urllib You import urllib, but don't appear to use it anywhere. > > # Generate thumbnail

Re: [Tutor] Replacing part of a URL

2010-02-20 Thread spir
On Sun, 21 Feb 2010 11:25:31 +1100 Steven D'Aprano wrote: > "Some people, when confronted with a problem, think 'I know, I'll use > regular expressions.' Now they have two problems." -- Jamie Zawinski ;-) la vita e estrany http://spir.wikidot.com/ ___