RE: attribute is accessed from Nonetype

2012-08-03 Thread Prasad, Ramit
> Also, please use the names correctly and consistently.  The None object
> (yes, there is only one) is not the same as a none object.  And there is
> no standard type called Nonetype.

To be fair, this is not very clear to a beginner. 

>>> len(None) # Python 2.6
TypeError: object of type 'NoneType' has no len()


Ramit
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dbf.py API question

2012-08-03 Thread Peter Otten
Ethan Furman wrote:

> SQLite has a neat feature where if you give it a the file-name of
> ':memory:' the resulting table is in memory and not on disk.  I thought
> it was a cool feature, but expanded it slightly: any name surrounded by
> colons results in an in-memory table.
> 
> I'm looking at the same type of situation with indices, but now I'm
> wondering if the :name: method is not pythonic and I should use a flag
> (in_memory=True) when memory storage instead of disk storage is desired.
 
For SQLite it seems OK because you make the decision once per database. For 
dbase it'd be once per table, so I would prefer the flag.

Random

> Thoughts?

- Do you really want your users to work with multiple dbf files? I think I'd 
rather convert to SQLite, perform the desired operations using sql, then 
convert back.

- Are names required to manipulate the table? If not you could just omit 
them to make the table "in-memory".

- How about a connection object that may either correspond to a directory or 
RAM:

db = dbf.connect(":memory:")
table = db.Table("foo", ...)

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


Re: Is Python a commercial proposition ?

2012-08-03 Thread Stefan Behnel
Prasad, Ramit, 03.08.2012 08:51:
>> I'm in stuck record mode here, but one of the things I really enjoy
>> about reading here is the way things do go off topic.  IMHO makes for a
>> far more interesting experience.  YMMV.
> 
> +1 
> 
> Ramit
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of
> securities, accuracy and completeness of information, viruses,
> confidentiality, legal privilege, and legal entity disclaimers,
> available at http://www.jpmorgan.com/pages/disclosures/email.  

Huh? Who's still trying to sell viruses these days? I thought they came for
free?

Stefan


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


Eclipse and the Python plugin

2012-08-03 Thread lipska the kat
A while ago someone asked me what I thought of the Eclipse plugin for 
python, well I just downloaded and installed the latest version of 
Eclipse for Java (Juno) followed by the Python plugin. After a while 
messing about with it I can only say ... phew, what a relief. The plugin 
looks like it automates a whole bunch of tasks such as packaging and you 
can configure it to use Jython, Iron Python (neither of which I have 
used) and some other stuff I have never heard of


I installed all this on Ubuntu Linux 12.04 with no problems whatsoever.

There's a debugger (which I haven't tried), code completion, error 
highlighting and much more.


Installing the plugin is documented here
http://www.rose-hulman.edu/class/csse/resources/Eclipse/eclipse-python-configuration.htm

And the most amazing thing of all is it's all completely free.

I can now create, debug and test a simple IRC server written in Java
and an IRC Bot that I am attempting to build in Python side by side in 
the same IDE simply by switching profiles (click one button). Astonishing.


You might like to try it

Just FYI so please don't tell me off (again).

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Calling Values

2012-08-03 Thread Subhabrata
Dear Group,

I am trying to call the values of one function in the another function in the 
following way:
def func1():
num1=10
num2=20
print "The Second Number is:",num2
return

def func2():
num3=num1+num2
num4=num3+num1
print "New Number One is:",num3
print "New Number Two is:",num4
return

I am preferring not to use argument passing or using class? Is there any 
alternate way?

Thanking in Advance,
Regards,
Subhabrata. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling Values

2012-08-03 Thread Mark Lawrence

On 03/08/2012 12:49, Subhabrata wrote:

Dear Group,

I am trying to call the values of one function in the another function in the 
following way:
def func1():
num1=10
num2=20
print "The Second Number is:",num2
return

def func2():
num3=num1+num2
num4=num3+num1
print "New Number One is:",num3
print "New Number Two is:",num4
return

I am preferring not to use argument passing or using class? Is there any 
alternate way?

Thanking in Advance,
Regards,
Subhabrata.



I think you've got the wrong group, but I don't know the best one for 
psychiatrists :)  Seriously I can't see what you're trying to achieve 
with this approach.  Can you explain it and I'm certain that we'll come 
up with a decent solution to your problem, whatever that may be.


--
Cheers.

Mark Lawrence.

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


Re: Eclipse and the Python plugin

2012-08-03 Thread Mark Lawrence

On 03/08/2012 12:34, lipska the kat wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python, well I just downloaded and installed the latest version of
Eclipse for Java (Juno) followed by the Python plugin. After a while
messing about with it I can only say ... phew, what a relief. The plugin
looks like it automates a whole bunch of tasks such as packaging and you
can configure it to use Jython, Iron Python (neither of which I have
used) and some other stuff I have never heard of

I installed all this on Ubuntu Linux 12.04 with no problems whatsoever.

There's a debugger (which I haven't tried), code completion, error
highlighting and much more.

Installing the plugin is documented here
http://www.rose-hulman.edu/class/csse/resources/Eclipse/eclipse-python-configuration.htm


And the most amazing thing of all is it's all completely free.

I can now create, debug and test a simple IRC server written in Java
and an IRC Bot that I am attempting to build in Python side by side in
the same IDE simply by switching profiles (click one button). Astonishing.

You might like to try it

Just FYI so please don't tell me off (again).

lipska



My opinion of Eclipse is unchanged by your words, it's like trying to 
run a legless carthorse in the Grand National or the Derby.


--
Cheers.

Mark Lawrence.

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


Re: ANN: dbf.py 0.94

2012-08-03 Thread Mark Lawrence

On 21/07/2012 00:59, Ethan Furman wrote:

Getting closer to a stable release.

Latest version has a simpler, cleaner API, and works on PyPy (and
hopefully the other implementations as well ;), as well as CPython.

Get your copy at http://python.org/pypi/dbf.

Bug reports, comments, and kudos welcome!  ;)

~Ethan~


Will this work with Recital software on VMS? :)

--
Cheers.

Mark Lawrence.

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


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 13:10, Mark Lawrence wrote:

On 03/08/2012 12:34, lipska the kat wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python,


snip





My opinion of Eclipse is unchanged by your words, it's like trying to
run a legless carthorse in the Grand National or the Derby.


:-)) There's this image in my mind ... jeez, get a grip.

I'm sorry to hear that, what would you recommend.

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread Mark Lawrence

On 03/08/2012 13:23, lipska the kat wrote:

On 03/08/12 13:10, Mark Lawrence wrote:

On 03/08/2012 12:34, lipska the kat wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python,


snip





My opinion of Eclipse is unchanged by your words, it's like trying to
run a legless carthorse in the Grand National or the Derby.


:-)) There's this image in my mind ... jeez, get a grip.

I'm sorry to hear that, what would you recommend.

lipska



Sorry I can't recommend anything as I use Python for small personal 
projects, so I find a combination of Notepad++ and PythonWin totally 
adequate for my needs.  Eclipse is also popular, so simply because I 
don't like it speed wise doesn't mean that it's not for you.  Picking an 
IDE often gets down to your own preferences and perhaps budget.


--
Cheers.

Mark Lawrence.

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


Re: Calling Values

2012-08-03 Thread Nobody
On Fri, 03 Aug 2012 04:49:46 -0700, Subhabrata wrote:

> I am trying to call the values of one function in the another function
> in the following way:
> def func1():
>   num1=10
>   num2=20
>   print "The Second Number is:",num2
>   return
> 
> def func2():
>   num3=num1+num2
>   num4=num3+num1

A function's local variables only exist while that function is being
executed[1]. It's meaningless to try to access them from outside the
function.

[1] There is an exception (closures), but it doesn't have any bearing on
this particular problem.

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


Re: ANN: dbf.py 0.94

2012-08-03 Thread Alex Strickland

On 2012/07/21 11:49 PM, Mark Lawrence wrote:


and PS is spelt p.s. :)


Ahem, the absolutely authoritative reference on the subject:

http://en.wikipedia.org/wiki/Postscript

says PS or P.S.
--
Regards
Alex
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: dbf.py 0.94

2012-08-03 Thread Mark Lawrence

On 03/08/2012 13:50, Alex Strickland wrote:

On 2012/07/21 11:49 PM, Mark Lawrence wrote:


and PS is spelt p.s. :)


Ahem, the absolutely authoritative reference on the subject:

http://en.wikipedia.org/wiki/Postscript

says PS or P.S.


I'm sorry but you can't read my writing[1].

[1] another Python sketch for the uninitiated but on album only possibly?

--
Cheers.

Mark Lawrence.

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


Re: Calling Values

2012-08-03 Thread Ulrich Eckhardt

Am 03.08.2012 13:49, schrieb Subhabrata:

I am trying to call the values of one function in the

> another function in the following way:


def func1():
num1=10
num2=20
print "The Second Number is:",num2
return

def func2():
num3=num1+num2
num4=num3+num1
print "New Number One is:",num3
print "New Number Two is:",num4
return

I am preferring not to use argument passing or using class?


You could make those variables global, see the "global" statement in the 
documentation of the language. However: I don't think that is a good 
idea and it will make your program more confusing to read than 
necessary, but go ahead and make that experience yourself. ;)


If you want, you can post your code here when done so that others might 
give you hints how to do things easier and cleaner, like e.g. putting 
spaces around operators and using four spaces indention (See PEP 8) or 
dropping the implied return from functions that return nothing. Apart 
from that, the above code is too short and with too little info what 
it's supposed to achieve, I can't really give you better advise.


Good luck!

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


Re: dbf.py API question

2012-08-03 Thread Ethan Furman

Peter Otten wrote:

Ethan Furman wrote:


SQLite has a neat feature where if you give it a the file-name of
':memory:' the resulting table is in memory and not on disk.  I thought
it was a cool feature, but expanded it slightly: any name surrounded by
colons results in an in-memory table.

I'm looking at the same type of situation with indices, but now I'm
wondering if the :name: method is not pythonic and I should use a flag
(in_memory=True) when memory storage instead of disk storage is desired.
 
For SQLite it seems OK because you make the decision once per database. For 
dbase it'd be once per table, so I would prefer the flag.


So far all feedback is for the flag, so that's what I'll do.



Random


Thoughts?


- Do you really want your users to work with multiple dbf files? I think I'd 
rather convert to SQLite, perform the desired operations using sql, then 
convert back.


Seems like that would be quite a slow-down (although if a user wants to 
do that, s/he certainly could).


- Are names required to manipulate the table? If not you could just omit 
them to make the table "in-memory".


At one point I had thought to make tables singletons (so only one copy 
of /user/bob/scores.dbf) but that hasn't happened and is rather low 
priority, so at this point the name is not required for anything beside 
initial object creation.


- How about a connection object that may either correspond to a directory or 
RAM:


db = dbf.connect(":memory:")
table = db.Table("foo", ...)


dbf.py does not support the DB-API interface, so no connection objects. 
  Tables are opened directly and dealt with directly.


All interesting thoughts that made me think.  Thank you.

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


Re: ANN: dbf.py 0.94

2012-08-03 Thread Ethan Furman

Mark Lawrence wrote:

On 21/07/2012 00:59, Ethan Furman wrote:

Getting closer to a stable release.

Latest version has a simpler, cleaner API, and works on PyPy (and
hopefully the other implementations as well ;), as well as CPython.

Get your copy at http://python.org/pypi/dbf.

Bug reports, comments, and kudos welcome!  ;)


Will this work with Recital software on VMS? :)


Does Recital use dBase III, Foxbase, Foxpro, or Visual Foxpro compatible 
files?  Does Python run on VMS?  If yes to both of those, then it 
should.  :)


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


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 13:40, Mark Lawrence wrote:

On 03/08/2012 13:23, lipska the kat wrote:

On 03/08/12 13:10, Mark Lawrence wrote:

On 03/08/2012 12:34, lipska the kat wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python,


snip


it's like trying to
run a legless carthorse in the Grand National or the Derby.


:-)) There's this image in my mind ... jeez, get a grip.

I'm sorry to hear that, what would you recommend.


Sorry I can't recommend anything as I use Python for small personal
projects, so I find a combination of Notepad++ and PythonWin totally
adequate for my needs. Eclipse is also popular, so simply because I
don't like it speed wise doesn't mean that it's not for you.


I've been using it for years for Java, I just recently found the Python 
plugin.



Picking an IDE often gets down to your own preferences and perhaps budget.


It's free ... good enough reason for me. I'm Always interested to hear 
of alternatives though.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread rusi
On Aug 3, 4:34 pm, lipska the kat  wrote:
> A while ago someone asked me what I thought of the Eclipse plugin for
> python, well I just downloaded and installed the latest version of
> Eclipse for Java (Juno) followed by the Python plugin.

Thanks Lipska for reporting back.
I personally find the eclipse UI frightening but I am unwilling to
conclude that its eclipse and not me.

By comparison, when I first heard of emacs, (about 20 years ago) the
local guru would come in the morning and start emacs then go out for a
smoke.  When he came back it had finished started up.
So the acronym: Eight Megabytes And Constantly Swapping made a lot of
sense then.  I guess today it would have to be Eight-hundred to make
any sense.

More to the point, it seems to me that eclipse was today what emacs
was then -- seemingly too large but in time I expect it will not seem
so large.

So one more request from me:

Can you try the refactoring support and tell us how it fares?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: xlrd 0.8.0 released!

2012-08-03 Thread pruebauno
On Wednesday, August 1, 2012 11:01:56 AM UTC-4, Chris Withers wrote:
> Hi All,
> 
> 
> 
> I'm pleased to announce the release of xlrd 0.8.0:
> 
> 
> 
> http://pypi.python.org/pypi/xlrd/0.8.0
> 
> 
> 
> This release finally lands the support for both .xls and .xlsx files.
> 
> Many thanks to John Machin for all his work on making this happen.
> 
> Opening of .xlsx files is seamless, just use xlrd as you did before and 
> 
> it all should "just work".
> 
> 
> 
> xlrd 0.8.0 is also the first release that that targets Python 2.6 and 
> 
> 2.7, but no Python 3 just yet. Python 2.5 and below may work but are not 
> 
> supported. If you need to use Python 2.5 or earlier, please stick to 
> 
> xlrd 0.7.x.
> 
> 
> 
> Speaking of xlrd 0.7.x, that's now in "requested maintenance only" mode 
> 
> ;-) That means, if possible, use 0.8.x. If you have a really good reason 
> 
> for sticking with 0.7.x, and you find a bug that you can't work around, 
> 
> then please make this clear on the python-ex...@googlegroups.com and 
> 
> we'll see what we can do.
> 
> 
> 
> If you find any problems, please ask about them on the list, or submit 
> 
> an issue on GitHub:
> 
> 
> 
> https://github.com/python-excel/xlrd/issues
> 
> 
> 
> Full details of all things Python and Excel related can be found here:
> 
> 
> 
> http://www.python-excel.org/
> 
> 
> 
> cheers,
> 
> 
> 
> Chris
> 
> 
> 
> -- 
> 
> Simplistix - Content Management, Batch Processing & Python Consulting
> 
>  - http://www.simplistix.co.uk

Congrats! Being able to read Office 2007 files will be very useful. Looking 
forward to the Python 3 support.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling Values

2012-08-03 Thread subhabangalore
On Friday, August 3, 2012 5:19:46 PM UTC+5:30, Subhabrata wrote:
> Dear Group,
> 
> 
> 
> I am trying to call the values of one function in the another function in the 
> following way:
> 
> def func1():
> 
>   num1=10
> 
>   num2=20
> 
>   print "The Second Number is:",num2
> 
>   return
> 
> 
> 
> def func2():
> 
>   num3=num1+num2
> 
>   num4=num3+num1
> 
>   print "New Number One is:",num3
> 
>   print "New Number Two is:",num4
> 
>   return
> 
> 
> 
> I am preferring not to use argument passing or using class? Is there any 
> alternate way?
> 
> 
> 
> Thanking in Advance,
> 
> Regards,
> 
> Subhabrata.

Dear Group,

def func1():

num1=10

num2=20

print "The Second Number is:",num2

return


def func2():

func1()
num3=num1+num2

num4=num3+num1

print "New Number One is:",num3

print "New Number Two is:",num4


This works. Even you can incoportate some conditionals over func1() in func2() 
and run.
My question can I call its values of func1() too? 
What it is the big deal in experimenting we may come up with some new code or a 
new need?
Indentation slightly differs while you post, I agree. Return I just like too 
use.
Mark you are too concerned for me, thanks.

Regards,
Subhabrata.

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


Demise of Mr. Kenneth Gonsalves

2012-08-03 Thread Anoop Thomas Mathew
With my heartfelt condolence, I'd like to inform you all the unfortunate
demise of Mr.Kenneth Gonsalves (KG - law...@thenilgiris.com), who was a
strong advocate of Python, Django and Free Software in India.
He had served as the President of IPSS(Indian Python Software Society),
which initiated the PyCon India, done a lot of workshops on Python and was
an active member in the Django user group.

Anoop Thomas Mathew
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Demise of Mr. Kenneth Gonsalves

2012-08-03 Thread Marcin Tustin
What happened to him? He was posting on this list in the last week?

On Fri, Aug 3, 2012 at 11:12 AM, Anoop Thomas Mathew wrote:

> With my heartfelt condolence, I'd like to inform you all the unfortunate
> demise of Mr.Kenneth Gonsalves (KG - law...@thenilgiris.com), who was a
> strong advocate of Python, Django and Free Software in India.
> He had served as the President of IPSS(Indian Python Software Society),
> which initiated the PyCon India, done a lot of workshops on Python and was
> an active member in the Django user group.
>
> Anoop Thomas Mathew
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Marcin Tustin
Tel: 07773 787 105
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Demise of Mr. Kenneth Gonsalves

2012-08-03 Thread Anoop Thomas Mathew
Chronic Asthma. He was hospitalized yesterday, and passed away today.




On 3 August 2012 20:45, Marcin Tustin  wrote:

> What happened to him? He was posting on this list in the last week?
>
> On Fri, Aug 3, 2012 at 11:12 AM, Anoop Thomas Mathew wrote:
>
>> With my heartfelt condolence, I'd like to inform you all the unfortunate
>> demise of Mr.Kenneth Gonsalves (KG - law...@thenilgiris.com), who was a
>> strong advocate of Python, Django and Free Software in India.
>> He had served as the President of IPSS(Indian Python Software Society),
>> which initiated the PyCon India, done a lot of workshops on Python and was
>> an active member in the Django user group.
>>
>>
>> Anoop Thomas Mathew
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Marcin Tustin
> Tel: 07773 787 105
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Calling Values

2012-08-03 Thread Prasad, Ramit

> def func1():
> 
>   num1=10
> 
>   num2=20
> 
>   print "The Second Number is:",num2
> 
>   return
> 
> 
> def func2():
> 
> func1()
>   num3=num1+num2
> 
>   num4=num3+num1
> 
>   print "New Number One is:",num3
> 
>   print "New Number Two is:",num4
> 
> 
> This works. Even you can incoportate some conditionals over func1() in func2()
> and run.

This does not work. Python does not get "compiled" in the same manner
as other languages (C, Java etc). Since you never call func2(), there is no
error. Once you try calling func2() you will see it does not work. func1()
does work.

The Second Number is: 20
Traceback (most recent call last):
  File "subha.py", line 24, in 
func2()
  File "subha.py", line 15, in func2
num3=num1+num2
NameError: global name 'num1' is not defined

> My question can I call its values of func1() too?
> What it is the big deal in experimenting we may come up with some new code or
> a new need?

It is not a big deal, that is how you learn. You are just writing code that
neither works nor really shows enough to tell us why or what you are trying 
to do. Not much I can do to guide or help you because I am completely lost
at your goal. The best I can do at the moment is say. func2 will not work.
You could return num1 and num2 from func1() and then it would work.

def func1():
num1=10
num2=20
print "The Second Number is:",num2
return num1, num2


def func2():
   num1, num2 = func1()
num3=num1+num2
num4=num3+num1
print "New Number One is:",num3
print "New Number Two is:",num4


func2()

Ramit
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling Values

2012-08-03 Thread Ethan Furman

subhabangal...@gmail.com wrote:

On Friday, August 3, 2012 5:19:46 PM UTC+5:30, Subhabrata wrote:

Dear Group,



I am trying to call the values of one function in the another function in the 
following way:

def func1():

num1=10

num2=20

print "The Second Number is:",num2

return



def func2():

num3=num1+num2

num4=num3+num1

print "New Number One is:",num3

print "New Number Two is:",num4

return



I am preferring not to use argument passing or using class? Is there any 
alternate way?



Thanking in Advance,

Regards,

Subhabrata.


Dear Group,

def func1():

num1=10

num2=20

print "The Second Number is:",num2

return


def func2():

func1()
num3=num1+num2

num4=num3+num1

print "New Number One is:",num3

print "New Number Two is:",num4


This works. 


No, it doesn't.  If it does work for you then you have code you aren't 
showing us.


~Ethan~

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


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 14:54, rusi wrote:

On Aug 3, 4:34 pm, lipska the kat  wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python, well I just downloaded and installed the latest version of
Eclipse for Java (Juno) followed by the Python plugin.


Thanks Lipska for reporting back.
I personally find the eclipse UI frightening but I am unwilling to
conclude that its eclipse and not me.


snip.

I have no vested interest in Eclipse but I don't believe that you would 
feel the same once you got your head around the basics. I don't pretend 
to be an expert, far from it, but I have taught myself enough to go into 
a contract and hit the ground running, loading the source tree into 
Eclipse is a great way to start to understand the code and the libraries 
it uses. Well it works for me anyway.



More to the point, it seems to me that eclipse was today what emacs
was then -- seemingly too large but in time I expect it will not seem
so large.


It can be bewildering I agree but the basics are not too intimidating.
I remember early versions of IBMs VisualAge for Java ... guaranteed to 
give you brain damage.



So one more request from me:

Can you try the refactoring support and tell us how it fares?


Well, I don't really have enough Python code to refactor anything at the 
moment however I did try something that may or may not prove to be 
informative.


If I create a Java class and right click in the code window and select 
refactor from the context menu there is a HUGE list of things I can do. 
Why I might want to do some of them I have no idea, but there they are. 
In contrast if I create a Python class and select refactor I get a 
significantly smaller list of things I can do. Inline local variable, 
Extract local variable, Extract method, Rename, Generate constructors, 
Generate properties and Override/Implement methods. I think this may be 
a result of Pythons different (from Java) grammar rules. I can write a 
Python class and call it Foo and save it in a file called Bar and it's 
no big deal (at least Eclipse doesn't get excited) If I try that in Java 
the sky falls in. Of course I'm about as far away from being a Python 
expert as it's possible to be.


Anyway, if and when I find out more I'll let you know. It will be a 
while though.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Calling Values

2012-08-03 Thread Steven D'Aprano
On Fri, 03 Aug 2012 04:49:46 -0700, Subhabrata wrote:

> I am preferring not to use argument passing

It's not 1964 any more and you're not programming in BASIC.

What you have just told us is that you prefer not to write good quality 
programs, and that you prefer to write buggy, hard to maintain code.

Of course that is your right to make such a foolish choice, but you 
shouldn't expect people to help you. There is enough terrible code in the 
world without encouraging people to write more.

If you would like to learn good coding techniques, please stay around 
here and pay attention to modern practices for writing good quality code. 
If you would rather stick to worst-practices from the 1960s, don't expect 
any encouragement.



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


avlhqw avlhqeavlhqino ovfqalmw avlhqei avlhqeaivscunqw

2012-08-03 Thread Martin Michael Musatov
Thanks to technology, a memorandum of understanding (thanks from Tel
Aviva / s, F `u / n (I [I TO rotate HM), and try to think, nature is"
E | .. (no offense to kiloton preparation. .. has C, E (Visor / s
Chest on Tuesday Kin \ 2 I "auto. Hi Lasso, Wilson vest / Na` martin /
NH MW `. brought / \ n VIEW goals WT /" NH, RAN, not (I all, or [that
load / Samoa ...) I think the WT DR 3 Μάη | . gown or some [even
in auto Cayman S (j eventual auto Arabia will not bar / threw / a) "L"
4 Oh, BAG, Gen auto, n (oil. raj Anatole’s auto / threw HM / s (Tao,
she vest (EDA Kai May that | Hall and hold LEIA ovum .. \ 5] 505 A
thru / |? auto / ton, John (avlhqw / DVDs eggs MAY Tues | H, the pH of
WAIT May / U / Eyelet) EN May two | gown or some [aunt EN his / | even
\ "LO 6` EN aunt BAG / | .. I over Ni (Kama’s evoke / NO perinea, U
(and auto [Peripatetic To /) 7 Adelaide (n ovum Ventolin.n akin
graphite, F I '/ S (all Ventolin.n Palau an (10] not PULL arch / s \
"from" H vesting Vent Olin not clear, Greek] is Zhukov PULL arch / d)
eight times a year, Lin Ventolin.n akin No Thanks, I `F u / n (or
[vesting avlhqe.j EN aunt / | .. (EDA Mr. Kai N / A \ [paragraph` t
Scottie (oil. F / 500 .. for avlhqino NH, N DH SIP) Get 9 or "50", BAG
EN WT / ... | wit Chennai is = (oil. ton Adolfo.n auto / miss / s (EN
and / | Scottie |. vest to [WK with RS) agape or 10 "/ n ton Adolfo
auto n / EDA (VA / |. wit I (EDA Yolanda aunt Kai Ski / | ovum
resist ...) The 11-misw / s ton Adolfo.n auto / (EN and / |. of
Scottie | vest (EN and Kai / |. Scottie, |. reputation / (1000 = ovum
want and / u-PA Gay (or [`t Scottie in veto, flues you’d goalmouth
auto / s) 12 degrees , F U "/ (technical., 1 (or [I AVE, entail I` u /
n Martin, all comments. what auto .. N / A 13 °), F U "I / O (open, RE
( or [cover even. PULL arch n / graphite), F MIL `U / N (, SK spin (or
[enrich coverage ton poncho, B) from 14 degrees, F" u / n (payment (or
[I even , violation of ton, CA), Ms. Gray MIL / V (e, RE (or [even.
PULL arch n / d) and covering gray / 500 (rotation of the earth (or [I
chiaroscuro, vest (Okay., May Beautiful / U / u `EN MIL / n, the game
will cover (.. Kai does not enrich poncho n .. n), BR 15 agape / O.
MADE EN dispute a / VA |. SEW PM | ) Eva agape / | ton difference
(ovum times are eggs, the pH can parent / EN aunt J / |. \ 16 or [/ n,
EN VA / |. KB, SEW | (MK pique / and Nark. CK (b pique-Kai, has / the
ovfqalmw N / S (H Kai emblazon "organic unity / straight (and keep ..
ovum EVE, May / June protection. all SAP or requests vest Additional
Protocol to the Agreement), I 17 "He was not, smog parameters, Get
(oil. pique` H, E and auto / \ O `poi / s .. May LAMA / U / read evil
ton avid / N) 18 (escape, O [ RA vest (oil. Kama’s Zhukov, and sat
down, or [O `ante, God. retail (Shoat. / ante there, students Ego
Crista, however, and \ or R [N and gown or some [escape you [PR vest,
n), '19 VEX MW / n vex / lion (San all ovum VEX H = H ', w / w \ AV
garb San VEX = "b, w / w (moment, An Keenan me B MW / n \ all I [/ Na
fawner or sin [e-IT ovum ease net VEX-In. MW / N) 20, I / cry / of
ADM. whales ... digestive ALPO Director / ovum `, (O Kai, gave
permission, s) and -21 000 Gray `u / n (or [O ovum given than all,
wean (all or O [which aunt, N (or Kai. [PA-IT / Tao n / EVE and
avlhqei M / d, and AGE tablespoons ovum). March 22 vesting of Tao, she
(IV US memo avenue # in Visor [u / ovum, hold, or God, or S *, where
he was the Messiah ante vesting (avenue, memo ton GS, I think. HO N)
23 AP / avenue onion. memo is ovule. ton food and energy \ 'O' or
'swimming mellow / s. No, I think. ton food, and RA, ICE) 24 "B / ovum
J] Zhukov, PULL is arch / s or EN / N, I, you) even miles EN` u / n,
New Hampshire | no] PULL arch / d Zhukov ('You / I EN WT / | .. HO
`w / |. EN Kai WT / | .. Heritage Manor / h) 25, I think [Stevie. NH
Evangelic P.D., Ah] and' I. hip hungers auto barn / (no, a thousand
degrees avid help when. N) 26 t / h is the salary my gray / WT / n
plan, known Sat K / day) I think 27 - true / cry / or MA] VELA , Beta
PULL ... auto / EN mail `u / n, we have (CRED VIEW and, and ... [the
color of nature, SH |. children` s / \ Tao salary / M (BRED `Kai caw.
I . C `Q Dale all auto MA / color is finally Skein /, known (oil.
avlhqe, vest (Kai ovum and cry / day (Tourism / DR aunt / |.) 28, I
think now / is not (technically, ( EDA that Nate aunt / |. \ I [or
Narcotics Anonymous [Only fawner / | E Miscellaneous / parish space
(oil. aivscunqw / male PULL auto / (EN and / |. Peruse, | auto /) 29
even avid or and / [u, Kayo, vest (gown, Barker, or [AP / 50 poi / s
than Dionysus, NAN (VEX. auto / Gage, Naphtali)  M a r t i n  M u s a
t o v  8 1 8 4 3 0 4 5 8 6 S M S  m u s a t o v  a t  a t t  d o t  n
e t
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: unable to get simple html file up

2012-08-03 Thread Smaran Harihar
guys i m still waiting for a reply

-- Forwarded message --
From: Smaran Harihar 
Date: Thu, Aug 2, 2012 at 12:26 PM
Subject: unable to get simple html file up
To: python-list@python.org


Hi,

I am following this
tutorial
and
i am not able to get the link.py  up and running.
I should be looking at Html file with link directing to the cgi script.

But strangely i can't even see the page itself. Any idea why it is like
this? I have made link.py executable. Here is the
server.py
.

-- 
Thanks & Regards
Smaran Harihar




-- 
Thanks & Regards
Smaran Harihar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread Steven D'Aprano
On Fri, 03 Aug 2012 16:51:26 +0100, lipska the kat wrote:

> I can write a
> Python class and call it Foo and save it in a file called Bar and it's
> no big deal (at least Eclipse doesn't get excited) If I try that in Java
> the sky falls in.

:)

Correct. Python does not require, or even encourage, the one-class-per-
file rule of Java. You are encouraged to encapsulate related code into 
related units, for whatever is appropriate according to the situation. 
Whether than means one class in a module or ten will depend on the 
classes in question.

And although it was quite prevalent in the past, these days the 
convention is avoid having the module and class name to be identical, as 
in time.time, unless you really have to. Preferred is something like 
decimal.Decimal.

What I consider close to the extreme of what is comfortable in Python is 
the decimal module, which includes 19 classes and 21 module-level 
functions. It's not quite as scary as it seems -- many of those classes 
and functions are only a few lines each, and most of those are 
documentation. *Short* lines at that, this isn't Perl. The bulk of the 
module is only two classes, Decimal and Context.

Mind you, both of those are seriously large, Decimal has 117 methods and 
Context around 70-80 (I stopped counting). So as I said, that's about the 
upper limit for what I consider reasonable in a single module.



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


Re: unable to get simple html file up

2012-08-03 Thread Rod Person
On Fri, 3 Aug 2012 09:40:44 -0700
Smaran Harihar  wrote:

> guys i m still waiting for a reply
> 
> -- Forwarded message --
> From: Smaran Harihar 
> Date: Thu, Aug 2, 2012 at 12:26 PM
> Subject: unable to get simple html file up
> To: python-list@python.org
> 
> 
> Hi,
> 
> I am following this
> tutorial
> and
> i am not able to get the link.py  up and
> running. I should be looking at Html file with link directing to the
> cgi script.
> 
> But strangely i can't even see the page itself. Any idea why it is
> like this? I have made link.py executable. Here is the
> server.py
> .
> 

looks like the closing """ are missing from link.py

-- 

Rod Person  http://www.rodperson.com  rodper...@rodperson.com


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


Re: unable to get simple html file up

2012-08-03 Thread Chris Angelico
On Sat, Aug 4, 2012 at 2:40 AM, Smaran Harihar  wrote:
> guys i m still waiting for a reply

You may get more helpful results if you add more information to your
question. Also, be aware that you're asking volunteers to donate their
time to you; according to the timestamps, it's less than a day since
your original post. Granted, python-list IS a heavily-trafficked and
fast-responding list (unlike several others I'm on, on which a week's
delay is entirely possible), but even so, prodding should probably be
left off until it's been rather longer. On the other hand, if your
follow-up is adding a pile of additional (useful!) information, it
won't look like a ping, and it actually will improve your chances of a
reply.

Here's a helpful resource on asking questions on these sorts of lists:

http://www.catb.org/~esr/faqs/smart-questions.html

Keep in mind that nobody's paid to help you, so you have to make us
_want_ to respond. One of the best ways to do that is to make it easy
for us to help you.

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


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 17:40, Steven D'Aprano wrote:

On Fri, 03 Aug 2012 16:51:26 +0100, lipska the kat wrote:


I can write a
Python class and call it Foo and save it in a file called Bar and it's
no big deal (at least Eclipse doesn't get excited) If I try that in Java
the sky falls in.


:)

Correct. Python does not require, or even encourage, the one-class-per-
file rule of Java.


snip

Well it's actually one public class per file, you can have as many 
package visible classes as you like not to mention inner classes and 
anonymous classes, but I know what you mean.


I used to know a developer who though that any file (class) that 
contained more lines of code than could fit on an A4 sheet of paper at 
10 points was too large ... a little extreme perhaps.



Mind you, both of those are seriously large, Decimal has 117 methods and
Context around 70-80 (I stopped counting). So as I said, that's about the
upper limit for what I consider reasonable in a single module.


117 methods seems a lot doesn't it. I'm still trying to get my head 
around Python packages, I think Eclipse will help me with this and the 
whole module mix of functions and classes is taking a while to get used 
to. The standard included libraries are pretty impressive though and it 
is certainly easier to write quick throwaway prototypes in Python. I 
guess this will become even quicker once I understand the language better.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Demise of Mr. Kenneth Gonsalves

2012-08-03 Thread Javier Guerra Giraldez
On Fri, Aug 3, 2012 at 10:12 AM, Anoop Thomas Mathew  wrote:
> With my heartfelt condolence, I'd like to inform you all the unfortunate
> demise of Mr.Kenneth Gonsalves (KG - law...@thenilgiris.com), who was a
> strong advocate of Python, Django and Free Software in India.

certainly sad news. i'm bad at remembering who did what; but i
don't have to check the list to remember him as a very positive
presence.

thanks for sharing.

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


Re: Calling Values

2012-08-03 Thread subhabangalore
On Friday, August 3, 2012 10:50:52 PM UTC+5:30, Dennis Lee Bieber wrote:
> On Fri, 3 Aug 2012 04:49:46 -0700 (PDT), Subhabrata
> 
>  declaimed the following in
> 
> gmane.comp.python.general:
> 
> 
> 
> > Dear Group,
> 
> > 
> 
> > I am trying to call the values of one function in the another function in 
> > the following way:
> 
> 
> 
>   Technically, "the values of one function" are whatever it RETURNS;
> 
> 
> 
> > def func1():
> 
> > num1=10
> 
> > num2=20
> 
> > print "The Second Number is:",num2
> 
> > return
> 
> >
> 
>   This function returns None.
> 
> 
> 
>   Recommended software design practices are that any thing inside the
> 
> function should be local to just that function -- a function should be a
> 
> black box -- you call it with some data, and you obtain some results
> 
> when it returns; what it does internally should be "invisible" and have
> 
> no effect on any other code.
> 
> 
> 
>   Read:
> 
> http://en.wikipedia.org/wiki/Coupling_%28computer_programming%29
> 
> (what you are attempting falls into "content coupling" if you change the
> 
> use of "module" to "function")
> 
> 
> 
>   However, Python lets you declare names to be global (to the
> 
> module/file). This is primarily meant to be used when a function must
> 
> rebind a module level entity. (This would be "common coupling")
> 
> 
> 
> def func1():
> 
>   global num1, num2
> 
>   ...
> 
> 
> 
> But, as mentioned, that now makes num1 and num2 names that are known
> 
> outside the functions.
> 
>  
> 
> > def func2():
> 
> > num3=num1+num2
> 
> > num4=num3+num1
> 
> > print "New Number One is:",num3
> 
> > print "New Number Two is:",num4
> 
> > return
> 
> > 
> 
>   Misleading print statements, as you are NOT changing "number one" or
> 
> "number two"; you've just created two NEW names (num3, num4).
> 
> 
> 
> > I am preferring not to use argument passing or using class? Is there any 
> > alternate way?
> 
> >
> 
> 
> 
>   Well, if you end func1 with
> 
> 
> 
>   return num1, num2
> 
> 
> 
> you can change func2 into:
> 
> 
> 
> def func2():
> 
>   n1, n2 = func1()
> 
>   num3 = n1 + n2
> 
>   num4 = num3 + n1
> 
> ...
> 
> -- 
> 
>   Wulfraed Dennis Lee Bieber AF6VN
> 
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

Dear Group,
Absolutely brilliant, Ramit.  Dennis also came with almost same answer.  Using 
global may not give clean results everytime. 

I wanted to say, 
>>> def func1():
num1=10
num2=20
print "The Second Number is:",num2


>>> def func2():
func1()
num3=50
print "The New Number is:",num3

>>> func2()
The Second Number is: 20
The New Number is: 50
The post went slightly wrong sorry. 
No, I experiment myself on idle evenings to experiment with coding etc so I 
think of problems, practice on them and try to see if any better code evolves. 
Nothing else. I posted and Steve did not comment perhaps never happens. He 
rebukes me so much from my early days here, I just enjoy it.

Regards and best wishes,
Subhabrata. 


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


Re: Eclipse and the Python plugin

2012-08-03 Thread Temia Eszteri
On Fri, 3 Aug 2012 06:54:04 -0700 (PDT), rusi 
wrote:

>On Aug 3, 4:34 pm, lipska the kat  wrote:
>> A while ago someone asked me what I thought of the Eclipse plugin for
>> python, well I just downloaded and installed the latest version of
>> Eclipse for Java (Juno) followed by the Python plugin.
>
>Thanks Lipska for reporting back.
>I personally find the eclipse UI frightening but I am unwilling to
>conclude that its eclipse and not me.
>
>By comparison, when I first heard of emacs, (about 20 years ago) the
>local guru would come in the morning and start emacs then go out for a
>smoke.  When he came back it had finished started up.
>So the acronym: Eight Megabytes And Constantly Swapping made a lot of
>sense then.  I guess today it would have to be Eight-hundred to make
>any sense.
>
>More to the point, it seems to me that eclipse was today what emacs
>was then -- seemingly too large but in time I expect it will not seem
>so large.
>
>So one more request from me:
>
>Can you try the refactoring support and tell us how it fares?

Having used PyDev for Eclipse for a while, I can honestly say its
memory consumption, while definitely rather large for the task, isn't
so large as to cause any trouble for most modern systems. I'm able to
keep it in the background with no notable performance impact, and if I
do have to reopen it for whatever reason, it only takes about ten
seconds.

A small price to pay for easy code completion, docstrings in tooltips,
and a more user-friendly debugger (though some things like weakref
containers will happily fool it and make debugging a little more
difficult).

~Temia
-- 
Invective! Verb your expletive nouns!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simplified Python parsing question

2012-08-03 Thread BartC
"Eric S. Johansson"  wrote in message 
news:mailman.2752.1343700723.4697.python-l...@python.org...

On 7/30/2012 9:54 PM, Steven D'Aprano wrote:


It would please me greatly if you would be willing to try an experiment. 
live my life for a while. Sit in a chair and tell somebody what to type 
and where to move the mouse without moving your hands. keep your hands 
gripping the arms or the sides of the chair. The rule is you can't touch 
the keyboard you can't touch the mice, you can't point at the screen. I 
suspect you would have a hard time surviving half a day with these 
limitations. no embarrassment in that, most people wouldn't make it as far 
as a half a day.


Just using speech? Probably more people than you might think have had such 
experiences: anyone who's done software support over the telephone for a 
start! And in that scenario, they are effectively 'blind' too.


--
Bartc 


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


Re: Demise of Mr. Kenneth Gonsalves

2012-08-03 Thread Daniel Roseman
On Friday, 3 August 2012 16:12:35 UTC+1, atm wrote:
>
> With my heartfelt condolence, I'd like to inform you all the unfortunate 
> demise of Mr.Kenneth Gonsalves (KG - law...@thenilgiris.com), who was a 
> strong advocate of Python, Django and Free Software in India.
> He had served as the President of IPSS(Indian Python Software Society), 
> which initiated the PyCon India, done a lot of workshops on Python and was 
> an active member in the Django user group.
>
> Anoop Thomas Mathew
>


That's a shock. He was a valued contributor to this list and to the Django 
community in general. Please pass on condolences to his family and friends.
--
Daniel.
-- 
http://mail.python.org/mailman/listinfo/python-list


Deciding inheritance at instantiation?

2012-08-03 Thread Tobiah

I have a bunch of classes from another library (the html helpers
from web2py).  There are certain methods that I'd like to add to
every one of them.  So I'd like to put those methods in a class,
and pass the parent at the time of instantiation.  Web2py has
a FORM class for instance.  I'd like to go:

my_element = html_factory(FORM)

Then my_element would be an instance of my class, and also
a child of FORM.

I started messing with decorators, but it became difficult
for me to visualise how to do this.

Thanks!

Toby
  
--

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


Re: Deciding inheritance at instantiation?

2012-08-03 Thread Terry Reedy

On 8/3/2012 4:48 PM, Tobiah wrote:

I have a bunch of classes from another library (the html helpers
from web2py).  There are certain methods that I'd like to add to
every one of them.  So I'd like to put those methods in a class,
and pass the parent at the time of instantiation.  Web2py has
a FORM class for instance.  I'd like to go:

 my_element = html_factory(FORM)

Then my_element would be an instance of my class, and also
a child of FORM.

I started messing with decorators, but it became difficult
for me to visualise how to do this.


Use type(name, bases, content) for dynamic class creation.

--
Terry Jan Reedy

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


Re: attribute is accessed from Nonetype

2012-08-03 Thread Dave Angel
On 08/03/2012 03:01 AM, Prasad, Ramit wrote:
>> Also, please use the names correctly and consistently.  The None object
>> (yes, there is only one) is not the same as a none object.  And there is
>> no standard type called Nonetype.
> To be fair, this is not very clear to a beginner. 
>
 len(None) # Python 2.6
> TypeError: object of type 'NoneType' has no len()
>

I'm sorry, what's not clear?  Nonetype is not the same as NoneType. 
Python is case sensitive.


-- 

DaveA

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


Re: attribute is accessed from Nonetype

2012-08-03 Thread Chris Angelico
On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel  wrote:
> I'm sorry, what's not clear?  Nonetype is not the same as NoneType.
> Python is case sensitive.

There isn't a NoneType either. I get a NameError.

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


Re: attribute is accessed from Nonetype

2012-08-03 Thread Dave Angel
On 08/03/2012 06:41 PM, Chris Angelico wrote:
> On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel  wrote:
>> I'm sorry, what's not clear?  Nonetype is not the same as NoneType.
>> Python is case sensitive.
> There isn't a NoneType either. I get a NameError.
>
> ChrisA

NoneType isn't in the builtin namespace.  It's in the types module.

import types
a = types.Nonetype

It's still special, because None is a singleton.  In any case there are
a number of places where the string "NoneType" is produced,

>>> type(None)



>>> None + 3
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

>>> None[3]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not subscriptable

etc.

and it's in the docs, at least on page:
http://docs.python.org/library/constants.html

-- 

DaveA

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


Re: Eclipse and the Python plugin

2012-08-03 Thread Cousin Stanley
lipska the kat wrote:

> 
> I can now create, debug and test a simple IRC server 
> written in Java and an IRC Bot that I am attempting 
> to build in Python 
> 

  For a bit of inspiration python-irc-bot-wise
  you might look at supybot  

  It's currently available in debian wheezy
  so probably also available in ubuntu 

# apt-cache show supybot

  A few years back I ran it 24/7 for several months
  on a very low spec debian box and was impressed
  with its performance, configurability, and 
  plugin usage  

  However, I haven't looked at or used
  recent versions 
  

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Deciding inheritance at instantiation?

2012-08-03 Thread Nobody
On Fri, 03 Aug 2012 13:48:08 -0700, Tobiah wrote:

> I have a bunch of classes from another library (the html helpers
> from web2py).  There are certain methods that I'd like to add to
> every one of them.  So I'd like to put those methods in a class,
> and pass the parent at the time of instantiation.  Web2py has
> a FORM class for instance.  I'd like to go:
> 
>   my_element = html_factory(FORM)
> 
> Then my_element would be an instance of my class, and also
> a child of FORM.

You can use type() to create classes dynamically. E.g.:

class my_base_class(object):
# extra methods

subclasses = {}

def html_factory(cls, *args, **kwargs):
name = "my_" + cls.__name__
if name not in subclasses:
subclasses[name] = type(name, (cls, my_base_class), {})
return subclasses[name](*args, **kwargs)

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


Re: attribute is accessed from Nonetype

2012-08-03 Thread Steven D'Aprano
On Sat, 04 Aug 2012 08:41:20 +1000, Chris Angelico wrote:

> On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel  wrote:
>> I'm sorry, what's not clear?  Nonetype is not the same as NoneType.
>> Python is case sensitive.
> 
> There isn't a NoneType either. I get a NameError.

Shame on you :-P 

Ramit Prasad showed exactly how you can see NoneType in action in the 
part of the post you snipped from your reply.

py> len(None)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: object of type 'NoneType' has no len()


NoneType *is* a standard type. It's just not bound to a publicly 
accessible name in the built-ins. But you can easily get access to the 
class using either:

type(None)
None.__class__

or in Python 2.6 at least, 

import types
types.NoneType

(although it has been removed from Python 3.2 for some reason).



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


Re: Deciding inheritance at instantiation?

2012-08-03 Thread Steven D'Aprano
On Fri, 03 Aug 2012 13:48:08 -0700, Tobiah wrote:

> I have a bunch of classes from another library (the html helpers from
> web2py).  There are certain methods that I'd like to add to every one of
> them.  So I'd like to put those methods in a class, and pass the parent
> at the time of instantiation.  Web2py has a FORM class for instance. 
> I'd like to go:
> 
>   my_element = html_factory(FORM)
> 
> Then my_element would be an instance of my class, and also a child of
> FORM.

I cannot understand what you are actually trying to do here because you 
aren't giving enough information and the description you give is 
misleading. But from what little I can grasp, I think it sounds like an 
unclean, confusing design and you would be better off with either mixins, 
composition, or code injection.

What is html_factory? By the name, it should return some HTML. But you're 
assigning the output to something called "my_element", which suggests it 
is returning only a single element of HTML. To me, I would expect that to 
be a string. Consequently, it isn't clear to me what you actually want, 
and I'm forced to make some wild guesses, and I can see a number of 
different alternative approaches.


=== Mixins ===

You state:

There are certain methods that I'd like to add to every 
one of [my classes].  So I'd like to put those methods 
in a class, and pass the parent at the time of instantiation

Don't pass the utility class at instantiation time. Use it as a mixin 
class.

class UtilityMixin:
# add "those methods" to this class
pass


class MyClassA(MyParentClass, UtilityMixin):
pass

class MyClassB(AnotherClass, UtilityMixin):
pass

class MyClassC(MyClassB):  # already inherits from UtilityMixin
pass


=== Composition ===


This frankly sounds like an abuse of inheritance. Inheritance is for 
modelling "is-a" relationships, not just for sticking arbitrary lumps of 
unrelated code together. If I can understand what you are trying to do, 
then you need to model a "has-a" relationship. For example:

The Contact Us page is not a html form, it HAS a html form;

therefore the instance which creates the Contact Us page is not a html 
form either, and should not inherit from FormClass;

but it should have a FormClass instance it can delegate the creation of 
the form to.


Something like this, perhaps:

contact_page_designer = PageDesigner()
contact_page_designer.form_designer = FormClass()


This can be wrapped inside the __init__ method, of course. The FormClass 
instance can be passed as a generic argument.

Then, your PageDesigner methods which need to create a form simply 
delegate the work to the form_designer attribute. Instead of this:

self.make_form()

which depends on self having ten different methods to do with making 
forms, you do this:

self.form_designer.make_form()

and all the form-related methods are encapsulated in one place, out of 
the way. This general technique is known as composition, or delegation, 
and you use it every time you do something like this:

result = self.name.upper()  # delegating upper method to the string name

And yet, somehow people forget it in favour of inheritance once they move 
beyond the primitive built-in types.


=== Code injection ===

You talk about deciding inheritance at instantiation time, which implies 
that each instance will get different methods. If so, then so long as you 
aren't changing dunder methods (double leading and trailing underscore 
special methods like __init__ and friends), you can inject methods 
directly onto an instance, either to add new functionality or override 
existing functionality on a per-instance basis.


py> class Parrot:
... def speak(self):
... print "Polly wants a cracker!"
...
py> class KillBot:
... def speak(self):
... print "Crush! Kill! Destroy!"
...
py> p = Parrot()
py> p.speak()
Polly wants a cracker!
py> p.speak = KillBot().speak
py> p.speak()
Crush! Kill! Destroy!


=== Dynamic class creation ===

Forget about using type(), there's an easier way.


def factory(name, parent_class):
   class MyClass(parent_class):
   def method(self):
   print "Called method"
   return 42
MyClass.__name__ = name
return MyClass


Much easier than the equivalent using type.


def method(self):
print "Called method"
return 42

type(name, (parent_class,), {'method': method})



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


Re: attribute is accessed from Nonetype

2012-08-03 Thread Steven D'Aprano
On Fri, 03 Aug 2012 19:03:20 -0400, Dave Angel wrote:

> On 08/03/2012 06:41 PM, Chris Angelico wrote:
>> On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel  wrote:
>>> I'm sorry, what's not clear?  Nonetype is not the same as NoneType.
>>> Python is case sensitive.
>> There isn't a NoneType either. I get a NameError.
>>
>> ChrisA
> 
> NoneType isn't in the builtin namespace.  It's in the types module.
> 
> import types
> a = types.Nonetype


Oh the irony. After criticising a beginner for getting the case wrong, 
you have done exactly the same thing.

A form of Muphry's Law (the Iron Law of Nitpicking) perhaps?

http://en.wikipedia.org/wiki/Muphry%27s_law



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


Re: attribute is accessed from Nonetype

2012-08-03 Thread Dave Angel
On 08/03/2012 09:35 PM, Steven D'Aprano wrote:
> On Fri, 03 Aug 2012 19:03:20 -0400, Dave Angel wrote:
>
>> On 08/03/2012 06:41 PM, Chris Angelico wrote:
>>> On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel  wrote:
 I'm sorry, what's not clear?  Nonetype is not the same as NoneType.
 Python is case sensitive.
>>> There isn't a NoneType either. I get a NameError.
>>>
>>> ChrisA
>> NoneType isn't in the builtin namespace.  It's in the types module.
>>
>> import types
>> a = types.Nonetype
> 
>
> Oh the irony. After criticising a beginner for getting the case wrong, 
> you have done exactly the same thing.
>
> A form of Muphry's Law (the Iron Law of Nitpicking) perhaps?
>
> http://en.wikipedia.org/wiki/Muphry%27s_law
>
You are, of course right;  I blew it.  Thanks for pointing it out with
humor.


-- 

DaveA

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


Re: dbf.py API question

2012-08-03 Thread Tim Chase
On 08/03/12 08:11, Ethan Furman wrote:
> So far all feedback is for the flag, so that's what I'll do.

I agree with the flag, though would also be reasonably content with
using None for the filename to indicate in-memory rather than
on-disk storage.

-tkc




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


Re: Deciding inheritance at instantiation?

2012-08-03 Thread Steven W. Orr

On 8/3/2012 4:48 PM, Tobiah wrote:

I have a bunch of classes from another library (the html helpers
from web2py). There are certain methods that I'd like to add to
every one of them. So I'd like to put those methods in a class,
and pass the parent at the time of instantiation. Web2py has
a FORM class for instance. I'd like to go:

my_element = html_factory(FORM)

Then my_element would be an instance of my class, and also
a child of FORM.

I started messing with decorators, but it became difficult
for me to visualise how to do this.

Thanks!

Toby


Your class inherits from whatever is in the class statement.

class Foo(object):
pass

Here, Foo inherits from object, but you can replace object with any tuple of 
classes which can be redefined before instantiation.


class Base1(object):
pass

class Base2(object):
pass

Now we can define Foo2 to inherit from something that better be a tuple of 
classes at instantiation time.


class Foo2(bases):
pass

bases = (Base1,)

foo2 = Foo2() # foo2 is a Foo2 which inherits from Base1.

bases = (Base1, Bace2)

foob1b2 = Foo2() # foob1b2 is a Foo2 which inherits from Base1 and Base2.

Who was it who said: "Give a man a shovel and he'll dig himself one helluva 
hole"?

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
--
http://mail.python.org/mailman/listinfo/python-list


trouble with pyplot in os x

2012-08-03 Thread Eric
I'm just starting to futz around with matplotlib and I tried to run this
example from the matplotlib doc page (it's the imshow() example):

import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

delta = 0.025
x = y = np.arange(-3.0, 3.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = Z2-Z1  # difference of Gaussians

im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
origin='lower', extent=[-3,3,-3,3])

plt.show()



I get the following error: 

Exception in Tkinter callback
Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py",
 line 1410, in __call__
return self.func(*args)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py",
 line 248, in resize
self.show()
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py",
 line 252, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py",
 line 19, in blit
tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, 
id(bbox_array))
TclError



I'm using Python 2.7.3 on OS X 10.6.8 and I'm invoking python by doing
"arch -i386 python" because matplotlib doesn't do 64-bit.  Has anyone
else seen this?  Does anyone know why this is happening?  It looks
like a problem with tkinter but beyond that I haven't a clue.  And,
finally, any ideas as to how to make it behave?

TIA,
eric
-- 
http://mail.python.org/mailman/listinfo/python-list


test

2012-08-03 Thread sistema
test
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread rusi
On Aug 3, 10:04 pm, lipska the kat  wrote:
>
> 117 methods seems a lot doesn't it. I'm still trying to get my head
> around Python packages, I think Eclipse will help me with this and the
> whole module mix of functions and classes is taking a while to get used
> to. The standard included libraries are pretty impressive though and it
> is certainly easier to write quick throwaway prototypes in Python.

Good that you get this early.  The python libraries are well crafted
and well documented.
They are also not over engineered so that you can get to what you want
without a lng:
org.dada.lang.servlet.dada... (Which is also why 117 can be ok)

The thing about python that experienced C++ and Java programmers are
most likely to miss is a mode of playful working in which trying out
small pieces in the interpreter is a key part of the development
process.  (and which is why functions are ok, not just classes)

If eclipse supports this well I'd be interested to know.
If not you need to supplement eclipse with (something like)
- python inside shell
- ipython inside shell
- python inside python-mode inside emacs

[The first turns out to be a pain because import wont work more than
once, reload wont work the first time, and if you do import * nothing
will work after the first time]
-- 
http://mail.python.org/mailman/listinfo/python-list


On-topic: alternate Python implementations

2012-08-03 Thread Steven D'Aprano
Most people are aware, if only vaguely, of the big Four Python 
implementations:

CPython, or just Python, the reference implementation written in C.
IronPython, written in .NET.
Jython, written in Java.
PyPy, the optimizing implementation written in Python (actually, it's 
written in a subset of Python, RPython).

But the Python ecosystem is a lot bigger than just those four. Here are 
just a few other implementations that you might be interested in:


Stackless - the "forgetten Python", Stackless is, I believe, the oldest 
implementation behind only CPython itself. It's a fork of CPython with 
the calling stack removed and fast and lightweight microthreads, and is 
used extensively in EVE Online.

http://www.stackless.com/


Nuitka - optimising Python compiler written in C++, supports Python 2.6 
and 2.7, claims to be up to twice as fast as CPython.

http://nuitka.net/pages/overview.html


WPython - another optimizing version of Python with wordcodes instead of 
bytecodes.

http://code.google.com/p/wpython/


CLPython, an implementation of Python written in Common Lisp.

http://common-lisp.net/project/clpython/


CapPython is an experimental restricted version of Python with 
capabilities.

http://plash.beasts.org/wiki/CapPython
http://en.wikipedia.org/wiki/Object-capability_model


Berp - a compiler which works by translating Python to Haskell and 
compiling that.

https://github.com/bjpop/berp/wiki



Give them some love!



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


Re: On-topic: alternate Python implementations

2012-08-03 Thread Chris Angelico
On Sat, Aug 4, 2012 at 4:15 PM, Steven D'Aprano
 wrote:
> CLPython, an implementation of Python written in Common Lisp.
>
> Berp - a compiler which works by translating Python to Haskell and
> compiling that.

Okay. WHY? CLPython gives some reason, but how often do you need to
bridge that particular pair of languages? And why compile Python via
Haskell, when C is available as a "high level assembly language"?

The mind boggles...

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


Re: On-topic: alternate Python implementations

2012-08-03 Thread Stefan Behnel
Steven D'Aprano, 04.08.2012 08:15:
> Most people are aware, if only vaguely, of the big Four Python 
> implementations:
> 
> CPython, or just Python, the reference implementation written in C.
> IronPython, written in .NET.
> Jython, written in Java.
> PyPy, the optimizing implementation written in Python (actually, it's 
> written in a subset of Python, RPython).
> 
> But the Python ecosystem is a lot bigger than just those four. Here are 
> just a few other implementations that you might be interested in:
> 
> 
> Stackless - the "forgetten Python", Stackless is, I believe, the oldest 
> implementation behind only CPython itself. It's a fork of CPython with 
> the calling stack removed and fast and lightweight microthreads, and is 
> used extensively in EVE Online.
> 
> http://www.stackless.com/
> 
> 
> Nuitka - optimising Python compiler written in C++, supports Python 2.6 
> and 2.7, claims to be up to twice as fast as CPython.
> 
> http://nuitka.net/pages/overview.html
> 
> 
> WPython - another optimizing version of Python with wordcodes instead of 
> bytecodes.
> 
> http://code.google.com/p/wpython/
> 
> 
> CLPython, an implementation of Python written in Common Lisp.
> 
> http://common-lisp.net/project/clpython/
> 
> 
> CapPython is an experimental restricted version of Python with 
> capabilities.
> 
> http://plash.beasts.org/wiki/CapPython
> http://en.wikipedia.org/wiki/Object-capability_model
> 
> 
> Berp - a compiler which works by translating Python to Haskell and 
> compiling that.
> 
> https://github.com/bjpop/berp/wiki

And not to forget Cython, which is the only static Python compiler that is
widely used. Compiles and optimises Python to C code that uses the CPython
runtime and allows for easy manual optimisations to get C-like performance
out of it.

http://cython.org/

Stefan


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