newbie question

2006-03-01 Thread orangeDinosaur
Hi,

I'm brand new to using/playing with Python, and I have what is likely a
very simple question but can't seem to figure it out.

I wrote up a script in my preferred text editor.  It contains maybe ten
lines of code.  I want to be able to execute those code lines with a
single command either from the inline mode or from IDLE.  How do I do
this?  I saved the file (myscript.py) in a folder that I've specified
in my PYTHONPATH environment variable, and when I type

>>> import myscript

the script runs.  If, later during the same session, I type

>>> myscript

all I get for output is



Somwhere in the beginning tutorial there's this line:

"The script can be given a executable mode, or permission, using the
chmod command:

$ chmod +x myscript.py"

Which I took to mean that if I enter that I would be able to do what I
wanted.  But no, it just highlights 'myscript' in red and says it's a
syntax error.  

What am I missing?

thanks for your help!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie question

2006-03-02 Thread orangeDinosaur
Thanks!!

This makes sense. And you were right about my misunderstanding.


Michael Tobis wrote:
> I think the answers so far are unnecessarily confusing and off the
> mark.
>
> Here is what I think you think you want to know:
>
> 1) import only works once. If you try import again, it will see the
> module already exists, and will ignore you
>
> 2) the functionality you think you want is reload.
> >>> reload mymodule
> will essentially reimport mymodule after the first time.
>
> However, what you think you want is not what you want, which is why the
> experienced people are giving misleading and overcomplicated answers.
> Normally reload is a fairly advanced feature and beginners don't need
> it.
>
> Usually, an import statement invokes a module containing a bunch of
> definitions (usually functions or classes, but sometimes even
> constants), but it doesn't DO anything unless it is invoked as the main
> program.
>
> So after you satisfy yourself that "reload" does what you want, try to
> think about how you would work things so you don't need it.
>
> For instance, instead of something like
>
> #mystuff.py
>
> print "hello ",
> print "world"
>
> # end of file
>
>
>
> >>> import mystuff
> hello world
> >>> import mystuff
>
> >>>
>
> is
>
>
>
> ### newstuff.py
>
> def newstuff():
>print "hello",
>print " world"
>
> # end of file
>
>
>
> >>> from newstuff import newstuff
> >>> newstuff()
> hello, world
> >>> newstuff()
> hello, world
> 
> 
> hth
> mt

-- 
http://mail.python.org/mailman/listinfo/python-list


string stripping issues

2006-03-02 Thread orangeDinosaur
Hello,

I am encountering a behavior I can think of reason for.  Sometimes,
when I use the .strip module for strings, it takes away more than what
I've specified.  For example:

>>> a = 'Hughes. John\r\n'

>>> a.strip('')

returns:

'ughes. John\r\n'

However, if I take another string, for example:

>>> b = 'Kim, Dong-Hyun\r\n'

>>> b.strip('')

returns:

'Kim, Dong-Hyun\r\n'

I don't understand why in one case it eats up the 'H' but in the next
case it leaves the 'K' alone.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string stripping issues

2006-03-02 Thread orangeDinosaur
thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


what am I missing (syntax error)

2006-03-05 Thread orangeDinosaur
Here's  a section of code:

for x in occupants:
if x not in uniqueUsers and not in staff: 
uniqueUsers.append(x)
elif x in staff and not in uniqueStaff: 
uniqueStaff.append(x)

When I try to import the module with the function definition that
contains this code, I get a syntax error pointing to the 'in' after the
'and not in staff'.  I can't figure out why this is bad syntax.  Both
'uniqueUsers' and 'staff' are lists.  

thanks for your help!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what am I missing (syntax error)

2006-03-05 Thread orangeDinosaur
OK, thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


matplotlib basic question

2007-04-19 Thread orangeDinosaur
Hi,

I am exploring the possibility of using python as a replacement of
MATLAB when I leave school.  So, I've been playing with matplotlib and
have run into some weird behavior after recently installing python
2.5.1 and matplotlib 0.90 on my Windows XP machine. Here's an example
of what I see:

>>>from matplotlib.pylab import *
>>>x=arange(-2*pi,2*pi,pi/24)
>>>y=sin(x)
>>>plot(x,y)
[]
>>> show()


So, first off, what's up with the [] line that shows up after my plot command?  And second,
when I call show(), a new figure pops up with my sin wave -- seems all
right, yes? But I'm not given another >>> prompt in IDLE until or
unless I close the figure that popped up with the show() call.

So, after closing the figure I type this:

>>>show()
>>>plot(x,y)
>>>

and this time another figure pops up with my sine wave again and I get
a prompt as well.  But now, the figure window is completely
unresponsive -- I can't even close it without getting the "your
program is not repsonding" business.  What am I missing?  This
behavior so far seems pretty unintuitive.

Any clarification is appreciated!

trevis

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: matplotlib basic question

2007-04-20 Thread orangeDinosaur
OK, I'll go with the enthought installation.  This seems to be the
path of least resistance.  For those of you who have been in my
position, is there a reason NOT to go with the enthought installation
and do things piecemeal instead?

thanks,
trevis

On Apr 20, 11:36 am, Pete Forman <[EMAIL PROTECTED]> wrote:
> orangeDinosaur <[EMAIL PROTECTED]> writes:
>
>  > [...] But now, the figure window is completely unresponsive -- I
>  > can't even close it without getting the "your program is not
>  > repsonding" business.  What am I missing?  This behavior so far
>  > seems pretty unintuitive.
>
> The best way out of this is to use IPython.  It also needs a backend
> which remains responsive, WxAgg works but Tk did not last time I
> tried.  IPython 0.8.1 is a release candidate which fixes some Windows
> issues in 0.8.0.  If you want a stable package that has all the parts
> present out of the box then look at Enthought.
> --
> Pete Forman-./\.-  Disclaimer: This post is originated
> WesternGeco  -./\.-   by myself and does not represent
> [EMAIL PROTECTED]-./\.-   the opinion of Schlumberger 
> orhttp://petef.port5.com  -./\.-   WesternGeco.


-- 
http://mail.python.org/mailman/listinfo/python-list