Re: [Tutor] What Editori?

2010-02-23 Thread Christian Witts

Giorgio wrote:

Hi All,

what text-editor do you use for python?

I've always used kate/nano on Linux and Notepad++/PSPad on Win. Today 
i've installed portablepython to my pendrive, and found pyscripter in 
that. It's nice!


Do you think it's a good editor? Do you know other names?

Giorgio

--
--
AnotherNetFellow
Email: anothernetfel...@gmail.com 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
  
I use Spyder mainly, also have Geany, SciTe, and Emacs setup but I like 
Spyder for pyLint right there, console inside, the ability to run 
applications in seperate threads and many more useful features.


--
Kind Regards,
Christian Witts


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using Python with a Mac

2010-02-23 Thread Zack Jarrett
Even though it's written for kids "Snake Wrangling for Kids" is a good resource 
to get you started with writing Python code.  Don't be put off by the title or 
the target audience; seriously.  This book will have you writing and executing 
Python scripts by page 8.

You can get it from:
http://code.google.com/p/swfk/downloads/list

Make sure to pull down one of the Mac versions.  The latest revision uses 
Python 3.x syntax.

Good luck!
Zack


On Feb 21, 2010, at 10:06 AM, Marco Rompré wrote:

> Could someone help me please please

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ask

2010-02-23 Thread Benno Lang
On 24 February 2010 12:58, Shurui Liu (Aaron Liu)  wrote:
> This time is not my assignment, I promise.
>
> In python, when we want to list numbers, we use the command "range", like,
> if we want to list integer from 0 to 9, we can write: range(10); if we want
> to list integer from 10 to 29, we can write: range(10,30). I was going to
> show a list of number from 1.0 to 1.9, and I did this in the same way as
> integer: range(1.0,2.0,0.1), but it doesn't work. Can you help me? Thank
> you!

Remember to include your error messages instead of saying "it doesn't work".
It appears that range only supports integers. I did a quick search for
"python float range" and the first link was the following:
http://code.activestate.com/recipes/66472/

HTH,
benno
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] ask

2010-02-23 Thread Shurui Liu (Aaron Liu)
This time is not my assignment, I promise.

In python, when we want to list numbers, we use the command "range", like,
if we want to list integer from 0 to 9, we can write: range(10); if we want
to list integer from 10 to 29, we can write: range(10,30). I was going to
show a list of number from 1.0 to 1.9, and I did this in the same way as
integer: range(1.0,2.0,0.1), but it doesn't work. Can you help me? Thank
you!

-- 
Shurui Liu (Aaron Liu)
Computer Science & Engineering Technology
University of Toledo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Strange list behaviour in classes

2010-02-23 Thread James Reynolds
This thread inspired me to start learning object oriented as well, but it
seems I must be missing something fundamental. If I could get
an explanation of why I am raising the following exception, I would
greatly appreciate it.

I'm getting:

Traceback (most recent call last):
  File "C:\Python31\Lib\COI\Project\test.py", line 8, in 
median = Statistics.stats.median(*a)
  File "C:\Python31\Lib\COI\Project\Statistics.py", line 23, in median
n = (self.value[m] + self.value[m+1]) / 2
IndexError: tuple index out of range

Module 1:

import Statistics

a = [1,2,3,4,5,6,7,8,9,10]

mean = Statistics.stats.mean(a)
median = Statistics.stats.median(*a)
stdev = Statistics.stats.stdev(*a)
z = Statistics.stats.zscore(5, *a)
print(mean, median, stdev, z)
print()

Module 2:

#!/usr/bin/python
# Filename: Statistics.py

import math
value_list = []
class Statistics:
def __init__(self, *value_list):
self.value = value_list
#self.average = mean(*value_list)
self.square_list= []
 def mean(self, *value_list):
ave = sum(self.value) #/ len(value_list)
return ave

def median(self, *value_list):
if len(self.value) % 2 == 1:
m = (len(self.value) - 1)/2
n = self.value[m+1]
else:
m = len(self.value) / 2
m = int(m)
n = (self.value[m] + self.value[m+1]) / 2
return n
 def variance(self, *value_list):
average = self.mean(*value_list)
for n in range(len(value_list)):
square = (self.value[n] - average)**2
self.square_list.append(square)
var = sum(self.square_list) / len(self.square_list)
return var

stats = Statistics(*value_list)













On Tue, Feb 23, 2010 at 10:27 PM, Lie Ryan  wrote:

> On 02/24/10 10:27, C M Caine wrote:
> > Thanks all (again). I've read the classes tutorial in its entirety
> > now, the problem I had didn't seem to have been mentioned at any point
> > explicitly. I'm still a fairly inexperienced programmer, however, so
> > maybe I missed something in there or maybe this is a standard
> > procedure in other OO programming languages.
>
> Not exactly, staticcally-typed languages typically uses keywords (like
> "static") to declare an variable as a class variable; but since in
> python, you don't need to do variable declaration the chosen design is
> to define class variable in the class itself and instance variable
> inside __init__() [actually this is not a precise description of what's
> actually happening, but it'll suffice for newbies]
>
> class MyClass(object):
>classvariable = 'classvar'
>def __init__(self):
>self.instancevariable = 'instvar'
>
> if you want to access class attribute from inside a method, you prefix
> the attribute's name with the class' name, and if you want to access
> instance attribute from inside a method, prefix with self:
>
> class MyClass(object):
>classvariable = 'classvar'
>def __init__(self):
>self.instancevariable = 'instvar'
>def method(self):
>print MyClass.classvariable
>print self.instancevariable
>
>
> But due to attribute name resolution rule, you can also access a class
> variable from self:
>
> class MyClass(object):
>classvariable = 'classvar'
>def __init__(self):
>self.instancevariable = 'instvar'
>def method(self):
>print self.classvariable
>
>
> as long as the class variable isn't shadowed by an instance variable
>
> class MyClass(object):
>var = 'classvar'
>def method(self):
>print self.var#'classvar'
>self.var = 'instvar'
>print self.var#'instvar'
>del self.var
>print self.var#'classvar'
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Strange list behaviour in classes

2010-02-23 Thread Lie Ryan
On 02/24/10 10:27, C M Caine wrote:
> Thanks all (again). I've read the classes tutorial in its entirety
> now, the problem I had didn't seem to have been mentioned at any point
> explicitly. I'm still a fairly inexperienced programmer, however, so
> maybe I missed something in there or maybe this is a standard
> procedure in other OO programming languages.

Not exactly, staticcally-typed languages typically uses keywords (like
"static") to declare an variable as a class variable; but since in
python, you don't need to do variable declaration the chosen design is
to define class variable in the class itself and instance variable
inside __init__() [actually this is not a precise description of what's
actually happening, but it'll suffice for newbies]

class MyClass(object):
classvariable = 'classvar'
def __init__(self):
self.instancevariable = 'instvar'

if you want to access class attribute from inside a method, you prefix
the attribute's name with the class' name, and if you want to access
instance attribute from inside a method, prefix with self:

class MyClass(object):
classvariable = 'classvar'
def __init__(self):
self.instancevariable = 'instvar'
def method(self):
print MyClass.classvariable
print self.instancevariable


But due to attribute name resolution rule, you can also access a class
variable from self:

class MyClass(object):
classvariable = 'classvar'
def __init__(self):
self.instancevariable = 'instvar'
def method(self):
print self.classvariable


as long as the class variable isn't shadowed by an instance variable

class MyClass(object):
var = 'classvar'
def method(self):
print self.var#'classvar'
self.var = 'instvar'
print self.var#'instvar'
del self.var
print self.var#'classvar'


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] webmail client for pop3 in python

2010-02-23 Thread Lie Ryan
On 02/24/10 13:53, Kirk Bailey wrote:
> Anyone knoow of a good python Webmail client in python for my windows
> notebook?

what do you mean by "python webmail client"? Could you elaborate?

If you want to send email programmatically, use the smtplib module if
the server supports SMTP.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] webmail client for pop3 in python

2010-02-23 Thread Kirk Bailey
Anyone knoow of a good python Webmail client in python for my windows 
notebook?


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Eric Dorsey
On any platform, I use (gui) vim (gvim on Win/Linux, mvim/macvim on OSX)
with this plugin:

http://www.vim.org/scripts/script.php?script_id=30



On Tue, Feb 23, 2010 at 5:40 PM, Benno Lang wrote:

> On 24 February 2010 01:24, Giorgio  wrote:
> > what text-editor do you use for python?
>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using Python with a Mac

2010-02-23 Thread Eric Dorsey
Not sure if this is what you're asking, but you can invoke the Python
interpreter from the command line (Terminal)

Open a new terminal, and at the $ prompt just type "python"..

$ python
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print "now in the python interpreter"
now in the python interpreter

To run a python program from the command line (assuming its in the same
directory), just type:

$ python myprogram.py



On Sun, Feb 21, 2010 at 10:06 AM, Marco Rompré wrote:

> Hi everyone, I would like to know how to use python with a mac.
>
> For now, I go to spotlight, open terminal then type IDLE and a window pops
> up but its like the window that opens when you run your programs already
> saved and I'm not able to open another window to write a script from
> scratch.
>
> Could someone help me please please
>
> I have the latest Macbook Pro so 2,88ghz 15 inches screen.
>
> Thank you in advance
>
> Marchoes
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Dave Angel


Wayne Watson wrote:
A few days ago I posted a message titled ""Two" Card Monty. The 
problem I mentioned looks legitimate, and remains puzzling. I've 
probed this in a newsgroup, and no one has an explanation that fits.


My claim is that if one creates a program in a folder that reads a 
file in the folder it and then copies it to another folder, it will 
read  the data file in the first folder, and not a changed file in the 
new folder. I'd appreciate it if some w7 users could try the program 
below, and let me know what they find.  I'm using IDLE in Win7 with Py 
2.5.


My experience is that if one checks the properties of the copied file, 
it will point to the original py file and execute it and not the copy. 
If win7 is the culprit, I would think this is a somewhat  serious 
problem. It may be the sample program is not representative of the 
larger program that has me stuck. If necessary I can provide it. It 
uses common modules. (Could this be something like the namespace usage 
of variables that share a common value?)


# Test program. Examine strange link in Python under Win7
# when copying py file to another folder.
# Call the program vefifywin7.py
# To verify my situation use IDLE, save and run this program there.
# Put this program into a folder along with a data file
# called verify.txt. Create a single text line with a few characters 
in it

# Run this program and note the output
# Copy the program and txt file to another folder
# Change the contents of the txt file
# Run it again, and see if the output is the same as in the other folder
track_file = open("verify.txt")
aline = track_file.readline();
print aline
track_file.close()

I find your English is very confusing.  Instead of using so many 
pronouns with confusing antecedents, try being explicit.


>My claim is that if one creates a program in a folder that reads a 
file in the folder


Why not say that you created a program and a data file in the same 
folder, and had the program read the data file?


>...in the folder it and then copies it to another folder

That first 'it' makes no sense, and the second 'it' probably is meant to 
be "them".  And who is it that does this copying?  And using what method?


> ... it will read  the data file in the first folder

Who will read the data file?  The first program, the second, or maybe 
the operator?


About now, I have to give up.  I'm guessing that the last four lines of 
your message were intended to be the entire program, and that that same 
program is stored in two different folders, along with data files having 
the same name but different first lines.  When you run one of these 
programs it prints the wrong version of the line.


You have lots of variables here, Python version, program contents, Idle, 
Windows version.  Windows 7 doesn't do any mysterious "linking," so I'd 
stop making that your working hypothesis.  Your problem is most likely 
the value of current directory ( os.getcwd() ).  And that's set 
according to at least three different rules, depending on what program 
launches Python.  If you insist on using Idle to launch it, then you'll 
have to convince someone who uses Idle to tell you its quirks.   Most 
likely it has a separate menu for the starting directory than for the 
script name & location.  But if you're willing to use the command line, 
then I could probably help, once you get a clear statement of the 
problem.  By default, CMD.EXE uses the current directory as part of its 
prompt, and that's the current directory Python will start in.


But the first things to do are probably to print out the value of  
os.getcwd(), and to add a slightly different print in each version of 
the program so you know which one is running.


Incidentally, I'd avoid ever opening a data file in "the current 
directory."  If I felt it important to use the current directory as an 
implied parameter to the program, I'd save it in a string, and build the 
full path to the desired file using  os.path.join() or equivalent.


DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Strange list behaviour in classes

2010-02-23 Thread C M Caine
On 22 February 2010 23:28, Wayne Werner  wrote:
> On Mon, Feb 22, 2010 at 4:10 PM, C M Caine  wrote:
>>
>> Or possibly strange list of object behaviour
>>
>> IDLE 2.6.2
>> >>> class Player():
>>        hand = []
>>
>>
>> >>> Colin = Player()
>> >>> Alex = Player()
>> >>>
>> >>> Players = [Colin, Alex]
>> >>>
>> >>> def hands():
>>        for player in Players:
>>                player.hand.append("A")
>>
>> >>> hands()
>> >>>
>> >>> Colin.hand
>> ['A', 'A']
>> >>> Alex.hand
>> ['A', 'A']
>>
>> I would have expected hand for each object to be simply ['A']. Why
>> does this not occur and how would I implement the behaviour I
>> expected/want?
>>
>> Thanks in advance for your help,
>> Colin Caine
>
> This comes from the nature of the list object. Python lists are pass/shared
> as reference objects. In your case, both Colin and Alex are pointing to the
> Player object's copy of hands - they both get a reference to the same
> object.
> If you want to create different hand lists you could do something like this:
> class Player:
>     def __init__(self, hand=None):
>         if isinstance(hand, list):
>              self.hand = hand
>         else:
>              print "Player needs a list object for its hand!"
>
> ex:
> In [11]: Alan = Player()
> Player needs a list object for its hand!
> In [12]: Alan = Player([])
> In [13]: Jim = Player([])
> In [14]: Alan.hand.append(3)
> In [15]: Jim.hand
> Out[15]: []
> HTH,
> Wayne
>

Thanks all (again). I've read the classes tutorial in its entirety
now, the problem I had didn't seem to have been mentioned at any point
explicitly. I'm still a fairly inexperienced programmer, however, so
maybe I missed something in there or maybe this is a standard
procedure in other OO programming languages.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Benno Lang
On 24 February 2010 01:24, Giorgio  wrote:
> what text-editor do you use for python?

I use jEdit, and without a GUI I guess I'd use nano - I'm not the sort
who likes reading manuals in order to use a text editor.
Many years ago when I was on Windows I used to use TextPad. Then I
started using jEdit because it was easy to get going on Windows, Mac,
and Linux. I used to switch between operating systems a lot.

> I've always used kate/nano on Linux and Notepad++/PSPad on Win. Today i've
> installed portablepython to my pendrive, and found pyscripter in that. It's
> nice!
> Do you think it's a good editor? Do you know other names?

Use whatever works for you.

Cheers,
benno
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Luke Paireepinart
On Tue, Feb 23, 2010 at 3:08 PM, Giorgio  wrote:

> O_O.
>
> I've downloaded some python examples from my debian server. Then, have
> edited one of them with pyscript. The IDLE (the real idle alan :D) was
> giving out a "unexpected indent" error, so i've checked again and again the
> code -it was ok-.
>
> Then, i've opened it in the IDLE. And there, ONLY there i see a double
> indentation for the line that was giving the error.
>
> I think it's because the script has been written on linux and i'm modifying
> it from windows, any idea or solution?
>
> Are you sure you're not mixing spaces and tabs?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running PIL.Image on .svg file

2010-02-23 Thread Dayo Adewunmi

Eduardo Vieira wrote:

On Tue, Feb 23, 2010 at 7:27 AM, Dayo Adewunmi  wrote:
  

Hi all

When i use PIL.Image in this script:http://dpaste.com/163588/  on an .svg
file, I get this error:http://dpaste.com/163584/
How do i process .svg files in python?
Thanks

Dayo

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor




Hi, svg is not an image (like a bitmap), it's a vector format file, an
xml file to be more precise.

  

Ahhh, I see. Ok thanks.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 3 Statistics?

2010-02-23 Thread Steven D'Aprano
On Wed, 24 Feb 2010 07:43:28 am James Reynolds wrote:

> For me to progress further though, I need to do some statistics work
> in Python. Does anyone know of a python module in Python 3.1 which
> will allow me to do statistics work? Otherwise I will have to go back
> to Python 2.5? to get numpy and scipy?

If you need to go back to the 2.x series, you should use 2.6 not 2.5.

The Windows installer for numpy only supports 2.5, but the source 
install should work with any recent Python 2.x version.



-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Giorgio
O_O.

I've downloaded some python examples from my debian server. Then, have
edited one of them with pyscript. The IDLE (the real idle alan :D) was
giving out a "unexpected indent" error, so i've checked again and again the
code -it was ok-.

Then, i've opened it in the IDLE. And there, ONLY there i see a double
indentation for the line that was giving the error.

I think it's because the script has been written on linux and i'm modifying
it from windows, any idea or solution?

2010/2/23 Alan Gauld 

>
> "Wayne Werner"  wrote
>
>
>  I use vim - for me it's the hands-down best editor. I usually have two
>> terminals (I run linux) open - one for ipython, and one for vim. I usually
>> have vim split into several buffers for each of the files I'm editing, and
>> I
>> have some nice scripts and plugins that help me edit/modify python code.
>>
>> But then again I've never worked on any huge (read: 1000+ lines,
>> unquantifiable "many" files).
>>
>
> I have, same setup except I use a third terminal for actually running
> the program for testing.
>
> And of course I use ctags for navigating around from file to file from vim.
> If you haven't played with ctags and vim start reading man ctags now! :-)
>
>
> Alan G
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python 3 Statistics?

2010-02-23 Thread James Reynolds
Hi All,

I am brand new to python and programing in general. I've been writing a
program that will eventually run a monte carlo simulation of some mortality
events and I've been making decent progress so far.

I decided to use Python 3, as a long term decision, but getting access to
modules seems to be tricky.

For me to progress further though, I need to do some statistics work in
Python. Does anyone know of a python module in Python 3.1 which will allow
me to do statistics work? Otherwise I will have to go back to Python 2.5? to
get numpy and scipy?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Alan Gauld


"Wayne Werner"  wrote


I use vim - for me it's the hands-down best editor. I usually have two
terminals (I run linux) open - one for ipython, and one for vim. I 
usually
have vim split into several buffers for each of the files I'm editing, 
and I

have some nice scripts and plugins that help me edit/modify python code.

But then again I've never worked on any huge (read: 1000+ lines,
unquantifiable "many" files).


I have, same setup except I use a third terminal for actually running
the program for testing.

And of course I use ctags for navigating around from file to file from vim.
If you haven't played with ctags and vim start reading man ctags now! :-)

Alan G


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Giorgio
Yes sorry Alan i've only used the wrong word :D

I know the difference :)

Giorgio

2010/2/23 Alan Gauld 

>
> "Giorgio"  wrote
>
>  Definitely i just use pyscripter because it has the py idle integrated in
>> the window.
>>
>
> PyScripter is an alternative to IDLE but it doesn't have IDLE embedded
> within it. I think you are getting confused between IDLE and the Python
> interactive prompt which is available in several tools.
>
> The only snag I found with Pyscripter is that its shell  is hard coded to
> a Python release as far as I could tell. But thats not unusual, IDLE is
> too,
> as is Pythonwin.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Alan Gauld


"spir"  wrote 
...and has the absolutely necessary duplicate feature ;-) (*). 
(*) Does anyone know another editor that has it?


OK, I'll bite. What is the duplicate feature? :-)

Alan G

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Alan Gauld


"Giorgio"  wrote


Definitely i just use pyscripter because it has the py idle integrated in
the window.


PyScripter is an alternative to IDLE but it doesn't have IDLE embedded
within it. I think you are getting confused between IDLE and the Python
interactive prompt which is available in several tools.

The only snag I found with Pyscripter is that its shell  is hard coded to
a Python release as far as I could tell. But thats not unusual, IDLE is 
too,

as is Pythonwin.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Alan Gauld


"Steve Willoughby"  wrote 


Actually, I suppose even ed and TECO qualify for some work
models ;)


I even use edlin occasionally - usually in batch files...

But Teco is the only editor that I've given up on as being 
just to hard to use! And that's out of more than a 
couple of dozen editors on 9 different OSs!


Alan G.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running PIL.Image on .svg file

2010-02-23 Thread Eduardo Vieira
On Tue, Feb 23, 2010 at 7:27 AM, Dayo Adewunmi  wrote:
> Hi all
>
> When i use PIL.Image in this script:http://dpaste.com/163588/  on an .svg
> file, I get this error:            http://dpaste.com/163584/
> How do i process .svg files in python?
> Thanks
>
> Dayo
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Hi, svg is not an image (like a bitmap), it's a vector format file, an
xml file to be more precise.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread wesley chun
> what text-editor do you use for python?

as an FYI Guido himself uses both emacs and vi/m... he mentioned this
during his PyCon 2010 keynote last week, to which someone tweeted:

http://twitter.com/bradallen137/status/9337630806

i primarily use vi/m and emacs as necessary,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Kent Johnson
On Tue, Feb 23, 2010 at 1:55 PM, Giorgio
> And, please let me ask a question: Kent told that nested_namespace(s) are
> default in python 2.6. And i found a line confirming this in py2.6 library.
> But, what about python 2.5 that as you know is the default on linux?

Yes, since 2.2 nested namespaces have been standard.

Kent
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Randy Raymond

I use Editra.  Randy

--
From: "spir" 
Sent: Tuesday, February 23, 2010 11:13 AM
To: 
Subject: Re: [Tutor] What Editori?


On Tue, 23 Feb 2010 17:46:24 +0100
Giorgio  wrote:


Definitely i just use pyscripter because it has the py idle integrated in
the window.

It's very useful!


Most editors have an integreated console that allow typing commands,
launching the interactice interpreter, and running progs all without
quitting the editor.
I use geany which is imo good for every language... and has the absolutely
necessary duplicate feature ;-) (*). Its only drawback is syntax
highlighting must be set by editing config files.

Denis

(*) Does anyone know another editor that has it?


la vita e estrany

http://spir.wikidot.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Wayne Werner
On Tue, Feb 23, 2010 at 10:24 AM, Giorgio wrote:

> Hi All,
>
> what text-editor do you use for python?
>

I use vim - for me it's the hands-down best editor. I usually have two
terminals (I run linux) open - one for ipython, and one for vim. I usually
have vim split into several buffers for each of the files I'm editing, and I
have some nice scripts and plugins that help me edit/modify python code.

But then again I've never worked on any huge (read: 1000+ lines,
unquantifiable "many" files).

For everything I do, my method works excellent.

HTH
-Wayne
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
Ok Hugo,

so, going back to your example:

def nochange(some_list):
   # create shallow copy of list. NOTE: Shallow copies may still bite
you if you change the list members.
   some_list = some_list[:]
   some_list[1] = 2

Here we've created a new list. It's an object in the global "object-space
:)" but i can't access it outside the function because i don't have a name
referring to it in the global namespace.

Right?

And, please let me ask a question: Kent told that nested_namespace(s) are
default in python 2.6. And i found a line confirming this in py2.6 library.
But, what about python 2.5 that as you know is the default on linux?

Thankyou

Giorgio

2010/2/23 Hugo Arts 

> On Tue, Feb 23, 2010 at 2:28 PM, Giorgio 
> wrote:
> > Thankyou Hugo!
> > Ok, so i think the key is of my problem is that when doing X = 0 i'm
> > creating a new object, that only exist in the local namespace. BUT, when
> > using a list as a parameter for a function i'm only giving it a new name,
> > but the object it's referring to it's always the same, and is in the
> global
> > namespace.
> > Right?
>
> Well, mostly, yes. It's important to see that it's not so much the
> objects that live in namespaces, it's the names (otherwise they would
> be called object-spaces, yes?). The objects do not live inside a
> namespace, but are in a conceptually separate place altogether. A name
> lives in a namespace, and can only be referenced inside that space. An
> object can be referenced from anywhere, as long as you have a name
> that points to it.
>
> So, when you're doing x = 0, you're creating a new object, and the
> name x (in the local namespace) points to that object. That doesn't
> mean the object itself is confined to the local namespace. You could
> write 'return x', which allows you to have a name in the global
> namespace point to that same object.
>
> Hugo
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Lowell Tackett
The environment [OS} of choice can do a lot to expand/enhance the capabilities 
of an editor.  I fell upon Vim from the beginning, and stayed with it for its' 
rich palate of features and adaptability (and of course, the often...and 
exhilarating "oh, Vim can do that!").  But beyond that, the Linux platform I 
work within offers its own dimension.

Generally, I will split a [terminal] screen into two (or even 3) virtual 
screens with bash's 'screen' workhorse, and from there I have in front of me 
[perhaps] a; 1) script edit screen, 2) interactive screen, and 3) 
script-launching screen...all on the same physical monitor.

For me, that combination creates an awfully rich & deep working canvas.   The 
whole...is at least as great as the sum of its' parts.

>From the virtual desk of Lowell Tackett  


--- On Tue, 2/23/10, Giorgio  wrote:

From: Giorgio 
Subject: [Tutor] What Editori?
To: tutor@python.org
Date: Tuesday, February 23, 2010, 11:24 AM

Hi All,
what text-editor do you use for python?
I've always used kate/nano on Linux and Notepad++/PSPad on Win. Today i've 
installed portablepython to my pendrive, and found pyscripter in that. It's 
nice!

Do you think it's a good editor? Do you know other names?
Giorgio

-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com




-Inline Attachment Follows-

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] list to numpy record array

2010-02-23 Thread Vincent Davis
@Skipper

Thanks I will post over on the scipy list

  *Vincent Davis
720-301-3003 *
vinc...@vincentdavis.net
 my blog  |
LinkedIn


On Tue, Feb 23, 2010 at 10:55 AM, Skipper Seabold wrote:

> On Mon, Feb 22, 2010 at 11:50 PM, Vincent Davis
>  wrote:
> >
> > I must be missing something simple. I have a list of lists data = "[['
>  0', '  0', '234.0', '24.0', ' 25'], ['  1', '  0', '22428.0', '2378.1', '
> 25'],.." and what to make a record array from it but it gets screwed up
> or I don't get it, maybe both. Notice that at this stage the items are
> strings, not numbers, and there is whitespace not sure this matters.
> > Here is what is happening
> > adata = numpy.array(data,numpy.float64)
> >
> > >>> adata
> > array([[  0.e+00,   0.e+00,   2.3400e+02,
> >   2.4000e+01,   2.5000e+01],
> >...,
> >[  4.7700e+02,   4.7700e+02,   2.0700e+02,
> >   4.5800e+01,   2.5000e+01]])
> >
> > This is what I would expect except it is not a record array.
> > This is not what I expect. I think I have tried every iteration including
> using numpy dtaypes numpy.int32 or bdata = numpy.array(data, dtype = [('x',
> int),('y', int),('mean',float),('stdv',float),('npixcels',int)])
> > What am I missing?
> >
> > bdata = numpy.array(data, [('x', int),('y',
> int),('mean',float),('stdv',float),('npixcels',int)])
> > >>> bdata
> > array([[(3153952, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
> > (206933603122, 0, 0.0, 0.0, 0), (808334386, 0, 0.0, 0.0, 0),
> > (3486240, 0, 0.0, 0.0, 0)],
> >[(3219488, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
> > (1356161439282, 0, 0.0, 0.0, 0),
> > (54074581398322, 0, 0.0, 0.0, 0), (3486240, 0, 0.0, 0.0, 0)],
> >[(3285024, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
> > (206933931058, 0, 0.0, 0.0, 0), (925775666, 0, 0.0, 0.0, 0),
> > (3486240, 0, 0.0, 0.0, 0)],
> >...,
> >[(3487540, 0, 0.0, 0.0, 0), (3618612, 0, 0.0, 0.0, 0),
> > (206933602866, 0, 0.0, 0.0, 0), (908996661, 0, 0.0, 0.0, 0),
> > (3486240, 0, 0.0, 0.0, 0)],
> >[(3553076, 0, 0.0, 0.0, 0), (3618612, 0, 0.0, 0.0, 0),
> > (13561596370041137, 0, 0.0, 0.0, 0),
> > (62870573495603, 0, 0.0, 0.0, 0), (3486240, 0, 0.0, 0.0, 0)],
> >[(3618612, 0, 0.0, 0.0, 0), (3618612, 0, 0.0, 0.0, 0),
> > (206933798962, 0, 0.0, 0.0, 0), (942552372, 0, 0.0, 0.0, 0),
> > (3486240, 0, 0.0, 0.0, 0)]],
> >
> >   dtype=[('x', ' ' >
> >
>
> I neglected to reply to the whole list on my first try.  For posterity's
> sake:
>
> You should ask on the scipy-user list with a self-contained example.
> It is heavily trafficked. http://www.scipy.org/Mailing_Lists
>
> From the example you gave above, I am not sure what's going unless
> it's something in the casting from strings.  Note though that you have
> created a structured array and not a record array.  The subtle
> difference is that the record array allows attribute lookup ie., you
> could do bdata.x instead of bdata['x'].  Structured arrays are usually
> faster as the attribute lookup convenience is implemented in Python
> whereas the structured arrays use C code.
>
> hth,
>
> Skipper
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Searchlight/MVPA/ValueError

2010-02-23 Thread Eike Welk
Hey J!

On Monday February 22 2010 22:48:11 J wrote:
> Dear all,
> I am trying to run a very simple searchlight on fMRI data via PyLab (on Mac
> Leopard).
> 
> My code is as follows:
> 
> from mvpa.suite import *
> import os
> from matplotlib.pyplot import figure, show
> from mvpa.misc.io.base import SampleAttributes
> from mvpa.datasets.nifti import NiftiDataset
 


> ---
> 
> Your input would be greatly appreciated.
> 
> Thanks a lot,
> J

I think you are using a special library for processing tomographic images of 
brains. This one, right?
http://www.pymvpa.org/

Probably no one else on this list is using it, unfortunately. However there is 
a special mailing list for this software:
http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa


HTH, 
Eike.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] list to numpy record array

2010-02-23 Thread Skipper Seabold
On Mon, Feb 22, 2010 at 11:50 PM, Vincent Davis
 wrote:
>
> I must be missing something simple. I have a list of lists data = "[['  0', ' 
>  0', '234.0', '24.0', ' 25'], ['  1', '  0', '22428.0', '2378.1', ' 
> 25'],.." and what to make a record array from it but it gets screwed up 
> or I don't get it, maybe both. Notice that at this stage the items are 
> strings, not numbers, and there is whitespace not sure this matters.
> Here is what is happening
> adata = numpy.array(data,numpy.float64)
>
> >>> adata
> array([[  0.e+00,   0.e+00,   2.3400e+02,
>           2.4000e+01,   2.5000e+01],
>        ...,
>        [  4.7700e+02,   4.7700e+02,   2.0700e+02,
>           4.5800e+01,   2.5000e+01]])
>
> This is what I would expect except it is not a record array.
> This is not what I expect. I think I have tried every iteration including 
> using numpy dtaypes numpy.int32 or bdata = numpy.array(data, dtype = [('x', 
> int),('y', int),('mean',float),('stdv',float),('npixcels',int)])
> What am I missing?
>
> bdata = numpy.array(data, [('x', int),('y', 
> int),('mean',float),('stdv',float),('npixcels',int)])
> >>> bdata
> array([[(3153952, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
>         (206933603122, 0, 0.0, 0.0, 0), (808334386, 0, 0.0, 0.0, 0),
>         (3486240, 0, 0.0, 0.0, 0)],
>        [(3219488, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
>         (1356161439282, 0, 0.0, 0.0, 0),
>         (54074581398322, 0, 0.0, 0.0, 0), (3486240, 0, 0.0, 0.0, 0)],
>        [(3285024, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
>         (206933931058, 0, 0.0, 0.0, 0), (925775666, 0, 0.0, 0.0, 0),
>         (3486240, 0, 0.0, 0.0, 0)],
>        ...,
>        [(3487540, 0, 0.0, 0.0, 0), (3618612, 0, 0.0, 0.0, 0),
>         (206933602866, 0, 0.0, 0.0, 0), (908996661, 0, 0.0, 0.0, 0),
>         (3486240, 0, 0.0, 0.0, 0)],
>        [(3553076, 0, 0.0, 0.0, 0), (3618612, 0, 0.0, 0.0, 0),
>         (13561596370041137, 0, 0.0, 0.0, 0),
>         (62870573495603, 0, 0.0, 0.0, 0), (3486240, 0, 0.0, 0.0, 0)],
>        [(3618612, 0, 0.0, 0.0, 0), (3618612, 0, 0.0, 0.0, 0),
>         (206933798962, 0, 0.0, 0.0, 0), (942552372, 0, 0.0, 0.0, 0),
>         (3486240, 0, 0.0, 0.0, 0)]],
>
>       dtype=[('x', ' ('npixcels', '
>

I neglected to reply to the whole list on my first try.  For posterity's sake:

You should ask on the scipy-user list with a self-contained example.
It is heavily trafficked. http://www.scipy.org/Mailing_Lists

>From the example you gave above, I am not sure what's going unless
it's something in the casting from strings.  Note though that you have
created a structured array and not a record array.  The subtle
difference is that the record array allows attribute lookup ie., you
could do bdata.x instead of bdata['x'].  Structured arrays are usually
faster as the attribute lookup convenience is implemented in Python
whereas the structured arrays use C code.

hth,

Skipper
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] list to numpy record array

2010-02-23 Thread Vincent Davis
@Kent
All I know about RecordArrays is from reading this page:
http://www.scipy.org/RecordArrays
but it looks like you have done the right thing and created a
RecordArray. What is wrong with this result?

The number are completely different, or I have no idea how to read it.
Here are the first row of each
normal array  ['  0', '  0', '234.0', '24.0', ' 25']
Record array  [(3153952, 0, 0.0, 0.0, 0)

*Vincent Davis
720-301-3003 *
vinc...@vincentdavis.net
 my blog  |
LinkedIn


On Tue, Feb 23, 2010 at 6:30 AM, Kent Johnson  wrote:

> On Mon, Feb 22, 2010 at 11:50 PM, Vincent Davis
>  wrote:
> >
> > I must be missing something simple. I have a list of lists data = "[['
>  0', '  0', '234.0', '24.0', ' 25'], ['  1', '  0', '22428.0', '2378.1', '
> 25'],.." and what to make a record array from it but it gets screwed up
> or I don't get it, maybe both.
> >
> > bdata = numpy.array(data, [('x', int),('y',
> int),('mean',float),('stdv',float),('npixcels',int)])
> > >>> bdata
> > array([[(3153952, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
> ...
> > (3486240, 0, 0.0, 0.0, 0)]],
> >
> >   dtype=[('x', ' '
> All I know about RecordArrays is from reading this page:
> http://www.scipy.org/RecordArrays
> but it looks like you have done the right thing and created a
> RecordArray. What is wrong with this result?
>
> Kent
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Steve Willoughby
On Tue, Feb 23, 2010 at 06:13:51PM +0100, spir wrote:
> I use geany which is imo good for every language... and has the absolutely 
> necessary duplicate feature ;-) (*).

Most have a variety of features which could be called by that name.
What specifically are you referring to here?
-- 
Steve Willoughby|  Using billion-dollar satellites
st...@alchemy.com   |  to hunt for Tupperware.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Randy Raymond

I use Editra.  Randy

--
From: "spir" 
Sent: Tuesday, February 23, 2010 11:13 AM
To: 
Subject: Re: [Tutor] What Editori?


On Tue, 23 Feb 2010 17:46:24 +0100
Giorgio  wrote:


Definitely i just use pyscripter because it has the py idle integrated in
the window.

It's very useful!


Most editors have an integreated console that allow typing commands, 
launching the interactice interpreter, and running progs all without 
quitting the editor.
I use geany which is imo good for every language... and has the absolutely 
necessary duplicate feature ;-) (*). Its only drawback is syntax 
highlighting must be set by editing config files.


Denis

(*) Does anyone know another editor that has it?


la vita e estrany

http://spir.wikidot.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread spir
On Tue, 23 Feb 2010 17:46:24 +0100
Giorgio  wrote:

> Definitely i just use pyscripter because it has the py idle integrated in
> the window.
> 
> It's very useful!

Most editors have an integreated console that allow typing commands, launching 
the interactice interpreter, and running progs all without quitting the editor.
I use geany which is imo good for every language... and has the absolutely 
necessary duplicate feature ;-) (*). Its only drawback is syntax highlighting 
must be set by editing config files.

Denis

(*) Does anyone know another editor that has it?


la vita e estrany

http://spir.wikidot.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Giorgio
Definitely i just use pyscripter because it has the py idle integrated in
the window.

It's very useful!



2010/2/23 Steve Willoughby 

> On Tue, Feb 23, 2010 at 05:24:13PM +0100, Giorgio wrote:
> > what text-editor do you use for python?
>
> While the can of worms that particular question tends to
> open is always an issue (for some reason people get very
> emotionally passionate about why their editor is the best)
> I'm not sure you're going to get much of a useful answer
> beyond a few suggestions to try, since this is such a
> personal choice and depends so much on how you want to
> work.
>
> Personally, I find vim (on all platforms) to work well
> for me.  I'm giving Eclipse+pydev a try to see how I like
> that.
>
> > Do you think it's a good editor? Do you know other names?
>
> Whether any particular editor is "good" as long as it does
> the minimum amount necessary for programming, is entirely
> subjective.  Try a few and see how they work for you.
>
> Actually, I suppose even ed and TECO qualify for some work
> models ;)
>
>
> --
> Steve Willoughby|  Using billion-dollar satellites
> st...@alchemy.com   |  to hunt for Tupperware.
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Steve Willoughby
On Tue, Feb 23, 2010 at 05:24:13PM +0100, Giorgio wrote:
> what text-editor do you use for python?

While the can of worms that particular question tends to
open is always an issue (for some reason people get very
emotionally passionate about why their editor is the best)
I'm not sure you're going to get much of a useful answer
beyond a few suggestions to try, since this is such a
personal choice and depends so much on how you want to
work.

Personally, I find vim (on all platforms) to work well
for me.  I'm giving Eclipse+pydev a try to see how I like
that.  
 
> Do you think it's a good editor? Do you know other names?

Whether any particular editor is "good" as long as it does
the minimum amount necessary for programming, is entirely
subjective.  Try a few and see how they work for you.

Actually, I suppose even ed and TECO qualify for some work
models ;)


-- 
Steve Willoughby|  Using billion-dollar satellites
st...@alchemy.com   |  to hunt for Tupperware.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What Editori?

2010-02-23 Thread Giorgio
Hi All,

what text-editor do you use for python?

I've always used kate/nano on Linux and Notepad++/PSPad on Win. Today i've
installed portablepython to my pendrive, and found pyscripter in that. It's
nice!

Do you think it's a good editor? Do you know other names?

Giorgio

-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Wayne Watson
A few days ago I posted a message titled ""Two" Card Monty. The problem 
I mentioned looks legitimate, and remains puzzling. I've probed this in 
a newsgroup, and no one has an explanation that fits.


My claim is that if one creates a program in a folder that reads a file 
in the folder it and then copies it to another folder, it will read  the 
data file in the first folder, and not a changed file in the new folder. 
I'd appreciate it if some w7 users could try the program below, and let 
me know what they find.  I'm using IDLE in Win7 with Py 2.5.


My experience is that if one checks the properties of the copied file, 
it will point to the original py file and execute it and not the copy. 
If win7 is the culprit, I would think this is a somewhat  serious 
problem. It may be the sample program is not representative of the 
larger program that has me stuck. If necessary I can provide it. It uses 
common modules. (Could this be something like the namespace usage of 
variables that share a common value?)


# Test program. Examine strange link in Python under Win7
# when copying py file to another folder.
# Call the program vefifywin7.py
# To verify my situation use IDLE, save and run this program there.
# Put this program into a folder along with a data file
# called verify.txt. Create a single text line with a few characters in it
# Run this program and note the output
# Copy the program and txt file to another folder
# Change the contents of the txt file
# Run it again, and see if the output is the same as in the other folder
track_file = open("verify.txt")
aline = track_file.readline();
print aline
track_file.close()

--
"There is nothing so annoying as to have two people
 talking when you're busy interrupting." -- Mark Twain

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Running PIL.Image on .svg file

2010-02-23 Thread Dayo Adewunmi

Hi all

When i use PIL.Image in this script:http://dpaste.com/163588/  on an 
.svg file, I get this error:http://dpaste.com/163584/

How do i process .svg files in python?
Thanks

Dayo

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Hugo Arts
On Tue, Feb 23, 2010 at 2:28 PM, Giorgio  wrote:
> Thankyou Hugo!
> Ok, so i think the key is of my problem is that when doing X = 0 i'm
> creating a new object, that only exist in the local namespace. BUT, when
> using a list as a parameter for a function i'm only giving it a new name,
> but the object it's referring to it's always the same, and is in the global
> namespace.
> Right?

Well, mostly, yes. It's important to see that it's not so much the
objects that live in namespaces, it's the names (otherwise they would
be called object-spaces, yes?). The objects do not live inside a
namespace, but are in a conceptually separate place altogether. A name
lives in a namespace, and can only be referenced inside that space. An
object can be referenced from anywhere, as long as you have a name
that points to it.

So, when you're doing x = 0, you're creating a new object, and the
name x (in the local namespace) points to that object. That doesn't
mean the object itself is confined to the local namespace. You could
write 'return x', which allows you to have a name in the global
namespace point to that same object.

Hugo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] list to numpy record array

2010-02-23 Thread Kent Johnson
On Mon, Feb 22, 2010 at 11:50 PM, Vincent Davis
 wrote:
>
> I must be missing something simple. I have a list of lists data = "[['  0', ' 
>  0', '234.0', '24.0', ' 25'], ['  1', '  0', '22428.0', '2378.1', ' 
> 25'],.." and what to make a record array from it but it gets screwed up 
> or I don't get it, maybe both.
>
> bdata = numpy.array(data, [('x', int),('y', 
> int),('mean',float),('stdv',float),('npixcels',int)])
> >>> bdata
> array([[(3153952, 0, 0.0, 0.0, 0), (3153952, 0, 0.0, 0.0, 0),
...
>         (3486240, 0, 0.0, 0.0, 0)]],
>
>       dtype=[('x', ' ('npixcels', 'http://www.scipy.org/RecordArrays
but it looks like you have done the right thing and created a
RecordArray. What is wrong with this result?

Kent
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
Thankyou Hugo!

Ok, so i think the key is of my problem is that when doing X = 0 i'm
creating a new object, that only exist in the local namespace. BUT, when
using a list as a parameter for a function i'm only giving it a new name,
but the object it's referring to it's always the same, and is in the global
namespace.

Right?

2010/2/23 Hugo Arts 

> On Tue, Feb 23, 2010 at 1:13 PM, Giorgio 
> wrote:
> > I have an update:
> > I can easily undertand why this example doesn't work:
> > def nochange(x):
> > x = 0
> > y = 1
> > nochange(y)
> > print y # Prints out 1
> > X is a local variable, and only gets modified in the function, that
> doesn't
> > return any value.
> > But it's very difficult for me to understand WHY this works:
> > def change(some_list):
> > some_list[1] = 4
> > x = [1,2,3]
> > change(x)
> > print x # Prints out [1,4,3]
> > some_list is a "local" list, isn't it? Maybe i can't have lists that are
> > only existing in a function?
>
> Here is what happens, as I understand it:
> When you enter the function, a new name (x, in your case) is created
> in the local scope. That name points to the object you supplied when
> you called the function (an integer object, with a value of 1). the x
> = 0 statement creates a new object, and has the name x now pointing to
> this new object. The old integer object still exists, and y still
> points to it. This is why the global y name is not affected by the
> change in x
>
> Now, in the second example, the same thing basically happens. A new
> name is created and pointed at the object you supplied. However, the
> statement some_list[1] = 4 is different from the assignment, in that
> it doesn't create a new object; It modifies the existing one. Since
> the global and local names both point to the same object, the change
> you make is reflected in both.
>
> You can of course create a new list object, so that the original is
> not affected:
>
> def nochange(some_list):
># create shallow copy of list. NOTE: Shallow copies may still bite
> you if you change the list members.
>some_list = some_list[:]
>some_list[1] = 2
>
> >>> x = [1, 2, 3]
> >>> nochange(x)
> >>> x
> [1, 2, 3]
>
> HTH,
> Hugo
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Hugo Arts
On Tue, Feb 23, 2010 at 1:13 PM, Giorgio  wrote:
> I have an update:
> I can easily undertand why this example doesn't work:
> def nochange(x):
>     x = 0
> y = 1
> nochange(y)
> print y # Prints out 1
> X is a local variable, and only gets modified in the function, that doesn't
> return any value.
> But it's very difficult for me to understand WHY this works:
> def change(some_list):
>     some_list[1] = 4
> x = [1,2,3]
> change(x)
> print x # Prints out [1,4,3]
> some_list is a "local" list, isn't it? Maybe i can't have lists that are
> only existing in a function?

Here is what happens, as I understand it:
When you enter the function, a new name (x, in your case) is created
in the local scope. That name points to the object you supplied when
you called the function (an integer object, with a value of 1). the x
= 0 statement creates a new object, and has the name x now pointing to
this new object. The old integer object still exists, and y still
points to it. This is why the global y name is not affected by the
change in x

Now, in the second example, the same thing basically happens. A new
name is created and pointed at the object you supplied. However, the
statement some_list[1] = 4 is different from the assignment, in that
it doesn't create a new object; It modifies the existing one. Since
the global and local names both point to the same object, the change
you make is reflected in both.

You can of course create a new list object, so that the original is
not affected:

def nochange(some_list):
# create shallow copy of list. NOTE: Shallow copies may still bite
you if you change the list members.
some_list = some_list[:]
some_list[1] = 2

>>> x = [1, 2, 3]
>>> nochange(x)
>>> x
[1, 2, 3]

HTH,
Hugo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] nonlocal variables

2010-02-23 Thread Vladislav Vorobyov
2010/2/23 Hugo Arts 

> On Tue, Feb 23, 2010 at 1:38 PM, Vladislav Vorobyov
>  wrote:
> > #!/usr/bin/python
> > def func_outer():
> > x = 2
> > print('x is', x)
> > def func_inner():
> > nonlocal x
> > x = 5
> > func_inner()
> > print('Changed local x to', x)
> >
> > func_outer()
> >
> > Output:
> > File "nonlocal_var.py", line 6
> > nonlocal x
> >  ^
> > SyntaxError: invalid syntax
> > Why? Cannon find in google it.
> >
>
> check your python version. The nonlocal keyword is only supported in python
> 3.x
>
> Hugo
>
O! Thank. I'm reading "Byte of Python". Didn't look about what version of
python is it.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] nonlocal variables

2010-02-23 Thread Hugo Arts
On Tue, Feb 23, 2010 at 1:38 PM, Vladislav Vorobyov
 wrote:
> #!/usr/bin/python
> def func_outer():
>     x = 2
>     print('x is', x)
>     def func_inner():
>     nonlocal x
>     x = 5
>     func_inner()
>     print('Changed local x to', x)
>
> func_outer()
>
> Output:
> File "nonlocal_var.py", line 6
>     nonlocal x
>  ^
> SyntaxError: invalid syntax
> Why? Cannon find in google it.
>

check your python version. The nonlocal keyword is only supported in python 3.x

Hugo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
Thankyou.

It's clear, this definitely helps me with the first question. But still
doesn't explain almost anything about the example i've posted in the last
post, right?

Giorgio

2010/2/23 Christian Witts 

> Giorgio wrote:
>
>> I have an update:
>>
>> I can easily undertand why this example doesn't work:
>>
>> def nochange(x):
>>x = 0
>>
>> y = 1
>> nochange(y)
>> print y # Prints out 1
>>
>> X is a local variable, and only gets modified in the function, that
>> doesn't return any value.
>>
>> But it's very difficult for me to understand WHY this works:
>>
>> def change(some_list):
>>some_list[1] = 4
>>
>> x = [1,2,3]
>> change(x)
>> print x # Prints out [1,4,3]
>>
>> some_list is a "local" list, isn't it? Maybe i can't have lists that are
>> only existing in a function?
>>
>> Thankyou all
>>
>> 2010/2/22 Kent Johnson mailto:ken...@tds.net>>
>>
>>
>>On Mon, Feb 22, 2010 at 9:13 AM, Giorgio
>>mailto:anothernetfel...@gmail.com>>
>>
>>wrote:
>>
>>> And, i have some difficulties understanding the other "strange"
>>example in
>>> that howto. Just scroll down to: "However, the point is that the
>>value
>>> of x is picked up from the environment at the time when the
>>function is
>>> defined. How is this useful? Let’s take an example — a function
>>which
>>> composes two other functions."
>>> He is working on a function that compose other 2 functions. This
>>is the
>>> final solution
>>> def compose(fun1, fun2):
>>> def inner(x, fun1=fun1, fun2=fun2):
>>> return fun1(fun2(x))
>>> return inner
>>> But also tries to explain why this example:
>>> # Wrong version
>>> def compose(fun1, fun2):
>>> def inner(x):
>>> return fun1(fun2(x))
>>> return inner
>>> def fun1(x):
>>> return x + " world!"
>>> def fun2(x):
>>> return "Hello,"
>>> sincos = compose(sin,cos)  # Using the wrong version
>>> x = sincos(3)
>>> Won't work. Now, the problem is that the "inner" function gets
>>fun1 and fun2
>>> from other 2 functions.
>>> My question is: why? inner is a sub-function of compose, where
>>fun1 and fun2
>>> are defined.
>>
>>It does work:
>>In [6]: def compose(fun1, fun2):
>>  ...: def inner(x):
>>  ...: return fun1(fun2(x))
>>  ...: return inner
>>  ...:
>>
>>In [7]: def fun1(x):
>>  ...: return x + " world!"
>>  ...:
>>
>>In [8]: def fun2(x):
>>  ...: return "Hello,"
>>  ...:
>>
>>In [9]: from math import sin, cos
>>
>>In [10]: sincos = compose(sin,cos)  # Using the wrong version
>>
>>In [11]:
>>
>>In [12]: x = sincos(3)
>>
>>In [13]:
>>
>>In [14]: x
>>Out[14]: -0.8360218615377305
>>
>>That is a very old example, from python 2.1 or before where nested
>>scopes were not supported. See the note "A Note About Python 2.1 and
>>Nested Scopes" - that is now the default behaviour.
>>
>>Kent
>>
>>
>>
>>
>> --
>> --
>> AnotherNetFellow
>> Email: anothernetfel...@gmail.com 
>> 
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
> Take a look at the Python gothcha's:
> http://www.ferg.org/projects/python_gotchas.html#contents_item_6
>
> --
> Kind Regards,
> Christian Witts
>
>
>


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] nonlocal variables

2010-02-23 Thread Vladislav Vorobyov
#!/usr/bin/python
def func_outer():
x = 2
print('x is', x)
def func_inner():
nonlocal x
x = 5
func_inner()
print('Changed local x to', x)

func_outer()

Output:
File "nonlocal_var.py", line 6
nonlocal x
 ^
SyntaxError: invalid syntax
Why? Cannon find in google it.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Christian Witts

Giorgio wrote:

I have an update:

I can easily undertand why this example doesn't work:

def nochange(x):
x = 0

y = 1
nochange(y)
print y # Prints out 1

X is a local variable, and only gets modified in the function, that 
doesn't return any value.


But it's very difficult for me to understand WHY this works:

def change(some_list):
some_list[1] = 4

x = [1,2,3]
change(x)
print x # Prints out [1,4,3]

some_list is a "local" list, isn't it? Maybe i can't have lists that 
are only existing in a function?


Thankyou all

2010/2/22 Kent Johnson mailto:ken...@tds.net>>

On Mon, Feb 22, 2010 at 9:13 AM, Giorgio
mailto:anothernetfel...@gmail.com>>
wrote:

> And, i have some difficulties understanding the other "strange"
example in
> that howto. Just scroll down to: "However, the point is that the
value
> of x is picked up from the environment at the time when the
function is
> defined. How is this useful? Let’s take an example — a function
which
> composes two other functions."
> He is working on a function that compose other 2 functions. This
is the
> final solution
> def compose(fun1, fun2):
> def inner(x, fun1=fun1, fun2=fun2):
> return fun1(fun2(x))
> return inner
> But also tries to explain why this example:
> # Wrong version
> def compose(fun1, fun2):
> def inner(x):
> return fun1(fun2(x))
> return inner
> def fun1(x):
> return x + " world!"
> def fun2(x):
> return "Hello,"
> sincos = compose(sin,cos)  # Using the wrong version
> x = sincos(3)
> Won't work. Now, the problem is that the "inner" function gets
fun1 and fun2
> from other 2 functions.
> My question is: why? inner is a sub-function of compose, where
fun1 and fun2
> are defined.

It does work:
In [6]: def compose(fun1, fun2):
  ...: def inner(x):
  ...: return fun1(fun2(x))
  ...: return inner
  ...:

In [7]: def fun1(x):
  ...: return x + " world!"
  ...:

In [8]: def fun2(x):
  ...: return "Hello,"
  ...:

In [9]: from math import sin, cos

In [10]: sincos = compose(sin,cos)  # Using the wrong version

In [11]:

In [12]: x = sincos(3)

In [13]:

In [14]: x
Out[14]: -0.8360218615377305

That is a very old example, from python 2.1 or before where nested
scopes were not supported. See the note "A Note About Python 2.1 and
Nested Scopes" - that is now the default behaviour.

Kent




--
--
AnotherNetFellow
Email: anothernetfel...@gmail.com 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
  

Take a look at the Python gothcha's:
http://www.ferg.org/projects/python_gotchas.html#contents_item_6

--
Kind Regards,
Christian Witts


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
I have an update:

I can easily undertand why this example doesn't work:

def nochange(x):
x = 0

y = 1
nochange(y)
print y # Prints out 1

X is a local variable, and only gets modified in the function, that doesn't
return any value.

But it's very difficult for me to understand WHY this works:

def change(some_list):
some_list[1] = 4

x = [1,2,3]
change(x)
print x # Prints out [1,4,3]

some_list is a "local" list, isn't it? Maybe i can't have lists that are
only existing in a function?

Thankyou all

2010/2/22 Kent Johnson 

> On Mon, Feb 22, 2010 at 9:13 AM, Giorgio 
> wrote:
>
> > And, i have some difficulties understanding the other "strange" example
> in
> > that howto. Just scroll down to: "However, the point is that the value
> > of x is picked up from the environment at the time when the function is
> > defined. How is this useful? Let’s take an example — a function which
> > composes two other functions."
> > He is working on a function that compose other 2 functions. This is the
> > final solution
> > def compose(fun1, fun2):
> > def inner(x, fun1=fun1, fun2=fun2):
> > return fun1(fun2(x))
> > return inner
> > But also tries to explain why this example:
> > # Wrong version
> > def compose(fun1, fun2):
> > def inner(x):
> > return fun1(fun2(x))
> > return inner
> > def fun1(x):
> > return x + " world!"
> > def fun2(x):
> > return "Hello,"
> > sincos = compose(sin,cos)  # Using the wrong version
> > x = sincos(3)
> > Won't work. Now, the problem is that the "inner" function gets fun1 and
> fun2
> > from other 2 functions.
> > My question is: why? inner is a sub-function of compose, where fun1 and
> fun2
> > are defined.
>
> It does work:
> In [6]: def compose(fun1, fun2):
>...: def inner(x):
>   ...: return fun1(fun2(x))
>   ...: return inner
>...:
>
> In [7]: def fun1(x):
>   ...: return x + " world!"
>   ...:
>
> In [8]: def fun2(x):
>   ...: return "Hello,"
>   ...:
>
> In [9]: from math import sin, cos
>
> In [10]: sincos = compose(sin,cos)  # Using the wrong version
>
> In [11]:
>
> In [12]: x = sincos(3)
>
> In [13]:
>
> In [14]: x
> Out[14]: -0.8360218615377305
>
> That is a very old example, from python 2.1 or before where nested
> scopes were not supported. See the note "A Note About Python 2.1 and
> Nested Scopes" - that is now the default behaviour.
>
> Kent
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor