[ANN]: circuits-1.3.1

2011-01-31 Thread James Mills
Hi,

I'm pleased to announce circuits-1.3.1 a minor bug-fix release of
the circuits framework/library.

What is circuits ?
==

circuits is a Lightweight Event driven and Asynchronous Application
Framework for the Python Programming Language with a strong
Component Architecture. circuits also includes a lightweight,
high performance and scalable HTTP/WSGI web server
(with some similar features to CherryPy) as well as various I/O
and Networking components.

Get it from PyPi: http://pypi.python.org/pypi/circuits/1.3.1
Read the documentation: http://packages.python.org/circuits
See the examples: https://bitbucket.org/prologic/circuits/src/1.3.1/examples/

Please give us feedback on the circuits-users groups
http://groups.google.com/group/circuits-users or on the
#circuits IRC Channel on the FreeNode IRC Network.

cheers
James

-- 
-- James Mills
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[ANN]: sahriswiki 0.8

2011-01-31 Thread James Mills
Hello,

I'm pleased to announce the first public release of sahriswiki-0.8

What is sahriswiki ?
===

sahriswiki is a simple wiki engine written in a couple of weeks
atop the circuits web framework (circuits.web).

You can see a live demo of it running here:

http://sahriswiki.org/

Get it from PyPi: http://pypi.python.org/pypi/sahriswiki/0.8
Following it's development at:
https://bitbucket.org/prologic/sahriswiki/overview

cheers
James

-- 
-- James Mills
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[RELEASED] Python 3.2 rc 2

2011-01-31 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of the Python development team, I'm quite happy to announce
the second release candidate of Python 3.2.

Python 3.2 is a continuation of the efforts to improve and stabilize the
Python 3.x line.  Since the final release of Python 2.7, the 2.x line
will only receive bugfixes, and new features are developed for 3.x only.

Since PEP 3003, the Moratorium on Language Changes, is in effect, there
are no changes in Python's syntax and built-in types in Python 3.2.
Development efforts concentrated on the standard library and support for
porting code to Python 3.  Highlights are:

* numerous improvements to the unittest module
* PEP 3147, support for .pyc repository directories
* PEP 3149, support for version tagged dynamic libraries
* PEP 3148, a new futures library for concurrent programming
* PEP 384, a stable ABI for extension modules
* PEP 391, dictionary-based logging configuration
* an overhauled GIL implementation that reduces contention
* an extended email package that handles bytes messages
* a much improved ssl module with support for SSL contexts and certificate
  hostname matching
* a sysconfig module to access configuration information
* additions to the shutil module, among them archive file support
* many enhancements to configparser, among them mapping protocol support
* improvements to pdb, the Python debugger
* countless fixes regarding bytes/string issues; among them full support
  for a bytes environment (filenames, environment variables)
* many consistency and behavior fixes for numeric operations

For a more extensive list of changes in 3.2, see

http://docs.python.org/3.2/whatsnew/3.2.html

To download Python 3.2 visit:

http://www.python.org/download/releases/3.2/

Please consider trying Python 3.2 with your code and reporting any bugs
you may notice to:

http://bugs.python.org/


Enjoy!

- -- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.2's contributors)

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk1Gj6IACgkQN9GcIYhpnLC53wCfcZhc6bxbc+fsmi+PAJxM6npr
Hh4An3QRdeyKHm+L3CqVk+EX02PxNx2r
=sTu6
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Option in Management careers.

2011-01-31 Thread gaurav
Rush for career in computer and government jobs potential revenue.
http://rojgars1.webs.com/gov.htmhttp://rojgars.webs.com/bankingjobs.htm

Huge chance in Management careers. Management careers for you.
http://managementjobs.webs.com/pm.htm 
http://topcareer.webs.com/humanresourcemgmt.htm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple values for keyword argument

2011-01-31 Thread Simon Brunning
On 29 January 2011 18:39,  pa...@cruzio.com wrote:
 I, myself, use the spanish word 'yo' instead (less keystrokes, I hate
 'self', and it amuses me); if I'm working with my numerical experiments
 I'll use 'n' or 'x'... although, when posting sample code to c.l.py I do
 try to use 'self' to avoid possible confusion.  :)

 I am glad you said this.  I have been avoiding understanding this 'self',
 just accepting it :}  For the time being, since my programs I am creating
 are for my own use, I think I will make my own names up, that are
 descriptive to me as the programmer, it's all going to be interpreted
 anyway.  And the other email equating to C's argv, etc. - now I get it.

It's perfectly legal to use a name other than self. It's alo perfectly
legal never to wash - and you won't make any friends that way either.

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.2 rc 2

2011-01-31 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of the Python development team, I'm quite happy to announce
the second release candidate of Python 3.2.

Python 3.2 is a continuation of the efforts to improve and stabilize the
Python 3.x line.  Since the final release of Python 2.7, the 2.x line
will only receive bugfixes, and new features are developed for 3.x only.

Since PEP 3003, the Moratorium on Language Changes, is in effect, there
are no changes in Python's syntax and built-in types in Python 3.2.
Development efforts concentrated on the standard library and support for
porting code to Python 3.  Highlights are:

* numerous improvements to the unittest module
* PEP 3147, support for .pyc repository directories
* PEP 3149, support for version tagged dynamic libraries
* PEP 3148, a new futures library for concurrent programming
* PEP 384, a stable ABI for extension modules
* PEP 391, dictionary-based logging configuration
* an overhauled GIL implementation that reduces contention
* an extended email package that handles bytes messages
* a much improved ssl module with support for SSL contexts and certificate
  hostname matching
* a sysconfig module to access configuration information
* additions to the shutil module, among them archive file support
* many enhancements to configparser, among them mapping protocol support
* improvements to pdb, the Python debugger
* countless fixes regarding bytes/string issues; among them full support
  for a bytes environment (filenames, environment variables)
* many consistency and behavior fixes for numeric operations

For a more extensive list of changes in 3.2, see

http://docs.python.org/3.2/whatsnew/3.2.html

To download Python 3.2 visit:

http://www.python.org/download/releases/3.2/

Please consider trying Python 3.2 with your code and reporting any bugs
you may notice to:

http://bugs.python.org/


Enjoy!

- -- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.2's contributors)

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk1Gj6IACgkQN9GcIYhpnLC53wCfcZhc6bxbc+fsmi+PAJxM6npr
Hh4An3QRdeyKHm+L3CqVk+EX02PxNx2r
=sTu6
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Style question: Nicknames for deeply nested objects

2011-01-31 Thread Jean-Michel Pichavant

Gerald Britton wrote:

Hi all,

Today I was thinking about a problem I often encounter.  
[snip]


1. You need to call this thing many times with different arguments, so
you wind up with:

   x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1)
   y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2)
   z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3)
[snip]
--
Gerald Britton
  

This is not solved by style but by design.
You simply don't use too much nested objects. That's a sign of something 
wrong in your overall object model.


Since I do not encounter this problem as often as you are, I guess it is 
a matter of habbits.


however, considering what

import a.module.that.is.quite.nested as myModule

is doing, I guess using a local variable to store your nested method is 
just fine.


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


Re: Understanding def foo(*args)

2011-01-31 Thread Jean-Michel Pichavant

sl33k_ wrote:

Hi,

I am struggling to grasp this concept about def foo(*args). Also, what
is def bar(*args, *kwargs)?

Isnt it like self must be the first parameter to the method/function?
If not what are the exceptions?

Also, can the terms method and function be used interchangeably?

TIA
  

python *args **kwargs in google.

1st hit.

JM


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


Re: Pickling/Unpickling python Exceptions

2011-01-31 Thread Sergey Lukin
Is anybody there to help me out ?

On Thu, Jan 27, 2011 at 4:49 PM, Sergey Lukin lukin@gmail.com wrote:

 Hi all,

 I'm migrating code from python 2.4 to python 2.6 and I've got into troubles
 with pickling/unpickling  python Exceptions.
 The following code works fine in 2.4 but not in 2.6.
 See Exception1 example

 I have found on python mail list similar problem
 http://mail.python.org/pipermail/python-list/2009-December/1228773.html
 They recommend to use __reduce__. But this does not help as I'm getting
 different Exception class after pickle
 See Exception_with_reduce example

 I also have found possible solution to this problem here
 http://bugs.python.org/issue1692335
 As a workaround they propose to pass Exception arguments into base class
 See Exception2 example
 But there is another problem. Constructor is called 2 times which is not
 acceptable to me.

 Could you please advice on the solution?

 --
 test program
 --
 import cPickle

 class Exception1(Exception):
 def __init__(self,arg1):
 print constructor called
 Exception.__init__(self)

 class Exception2(Exception):
 def __init__(self,arg1):
 print constructor called
 Exception.__init__(self,arg1)

 class Exception_with_reduce(Exception):
 def __reduce__(self):
 try:
 getnewargs = self.__getnewargs__
 except AttributeError:
 newargs = (self.__class__,)
 else:
 newargs = (self.__class__,) + getnewargs()

 try:
 getstate = self.__getstate__
 except AttributeError:
 state = self.__dict__
 else:
 state = getstate()
 return (Exception, newargs, state)

 def __init__(self,arg1):
 print constructor called
 Exception.__init__(self,arg1)

 def test(E,args):
 try:
 print ,E.__name__
 e = E(*args)
 print - pickling
 s = cPickle.dumps(e)
 print - unpickling
 e = cPickle.loads(s)

 if E != e.__class__:
 print ! failed: expected %s, got
 %s%(E.__name__,e.__class__.__name__)
 except Exception, e:
 print ! failed:,e

 print \ finished
 print


 import os
 if os.path.isfile(/home/ast1/blabla):
 try:
 s = open(/home/ast1/blabla,r).read()
 e = cPickle.loads(s)
 print e.__class__
 except Exception, e:
 print error:,e

 test(Exception1,[1])
 test(Exception2,[1])
 test(Exception_with_reduce,[1])
 --


 --
 run results on python 2.6:
 --

 constructor called
 class '__main__.Exception2'
  Exception1
 constructor called
 - pickling
 - unpickling
 ! failed: ('__init__() takes exactly 2 arguments (1 given)', class
 '__main__.Exception1', ())
 \ finished

  Exception2
 constructor called
 - pickling
 - unpickling
 constructor called
 \ finished

  Exception_with_reduce
 constructor called
 - pickling
 - unpickling
 ! failed: expected Exception_with_reduce, got Exception
 \ finished

 --
 run results on python 2.4:
 --

 __main__.Exception2
  Exception1
 constructor called
 - pickling
 - unpickling
 \ finished

  Exception2
 constructor called
 - pickling
 - unpickling
 \ finished

  Exception_with_reduce
 constructor called
 - pickling
 - unpickling
 \ finished







-- 
Media Center for TomTom - a unique video player from MobilNova.com
Be the first to watch !
http://www.MobilNova.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


XML to dict(d)

2011-01-31 Thread Daniel Stender
Hi guys,

we are trying to convert a Sanskrit dictionary which is in a homegrown XML 
format into dict(d),
the input file goes like this:

cut
H2hhc3200/hc3key1akAlikam/key1hc12/hc1key2a-kAlikam/key2/hbody
lexind./lex cimmediately/c lsMBh./ls /bodytailmul/ 
MW000173/MW pc2,2/pc
L266/L/tail/H2
H2hhc3110/hc3key1akAlya/key1hc12/hc1key2a-kAlya/key2/hbody
 lexmfn./lex
cunseasonable./c /bodytailmul/ MW000174/MW pc2,2/pc 
L267/L/tail/H2
H1hhc3110/hc3key1akAsAra/key1hc11/hc1key2a-kAsAra/key2/hbody
 lexm./lex
cN._of_a_teacher/c lsBhP./ls /bodytailmul/ MW000175/MW 
pc2,2/pc
L268/L/tail/H1
H1hhc3110/hc3key1akiYcana/key1hc11/hc1key2a-kiYcana/key2/hbody
lexmfn./lex cwithout_anything_,_utterly_destitute/c 
/bodytailpc2,2/pc
L269/L/tail/H1
H1Ahhc3100/hc3key1akiYcana/key1hc11/hc1key2a-kiYcana/key2/hbody
 lex
type=inhmfn./lex cdisinterested/c /bodytailpc2,2/pc 
L270/L/tail/H1A
H1Bhhc3110/hc3key1akiYcana/key1hc11/hc1key2a-kiYcana/key2/hbody
lexn./lex cthat_which_is_worth_nothing./c /bodytailMW000176/MW 
pc2,2/pc
L271/L/tail/H1B
H3hhc3110/hc3key1akiYcanatA/key1hc13/hc1key2a-kiYcana--tA/key2/hbody
lexf./lex OR/
cvoluntary_poverty_pas_practised_by_as0Jaina/as0as1sjEna/s/as1_ascetics/p./c
/bodytailMW000177/MW pc2,2/pc L272/L/tail/H3
/cut

I've found that there is the library python-dictdlib for concatenating dict 
dictionaries, what would
be the best way to de-XML the source file?

Thanks for any pointers in advance!

Daniel Stender

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


Re: XML to dict(d)

2011-01-31 Thread Neil Cerutti
On 2011-01-31, Daniel Stender dan...@danielstender.com wrote:
 Hi guys,

 we are trying to convert a Sanskrit dictionary which is in a
 homegrown XML format into dict(d), the input file goes like
 this:

xml.etree.ElementTree will parse your file and return it as a
hierarchy of dict-like Element objects.

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


Re: XML to dict(d)

2011-01-31 Thread Stefan Behnel

Daniel Stender, 31.01.2011 13:45:

we are trying to convert a Sanskrit dictionary which is in a homegrown XML 
format into dict(d),
the input file goes like this:

cut
H2hhc3200/hc3key1akAlikam/key1hc12/hc1key2a-kAlikam/key2/hbody
lexind./lex  cimmediately/c  lsMBh./ls  /bodytailmul/  MW000173/MW  
pc2,2/pc
L266/L/tail/H2
H2hhc3110/hc3key1akAlya/key1hc12/hc1key2a-kAlya/key2/hbody  
lexmfn./lex
cunseasonable./c  /bodytailmul/  MW000174/MW  pc2,2/pc  
L267/L/tail/H2
H1hhc3110/hc3key1akAsAra/key1hc11/hc1key2a-kAsAra/key2/hbody  
lexm./lex
cN._of_a_teacher/c  lsBhP./ls  /bodytailmul/  MW000175/MW  
pc2,2/pc
L268/L/tail/H1
H1hhc3110/hc3key1akiYcana/key1hc11/hc1key2a-kiYcana/key2/hbody
lexmfn./lex  cwithout_anything_,_utterly_destitute/c  
/bodytailpc2,2/pc
L269/L/tail/H1
H1Ahhc3100/hc3key1akiYcana/key1hc11/hc1key2a-kiYcana/key2/hbody
  lex
type=inhmfn./lex  cdisinterested/c  /bodytailpc2,2/pc  
L270/L/tail/H1A
H1Bhhc3110/hc3key1akiYcana/key1hc11/hc1key2a-kiYcana/key2/hbody
lexn./lex  cthat_which_is_worth_nothing./c  /bodytailMW000176/MW  
pc2,2/pc
L271/L/tail/H1B
H3hhc3110/hc3key1akiYcanatA/key1hc13/hc1key2a-kiYcana--tA/key2/hbody
lexf./lex  OR/
cvoluntary_poverty_pas_practised_by_as0Jaina/as0as1sjEna/s/as1_ascetics/p./c
/bodytailMW000177/MW  pc2,2/pc  L272/L/tail/H3
/cut

I've found that there is the library python-dictdlib for concatenating dict 
dictionaries, what would
be the best way to de-XML the source file?


How do you want to the dict to look like?

Stefan

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


RE: Understanding def foo(*args)

2011-01-31 Thread Rob Richardson
My thanks both to the original poster and to JM for an excellent answer.
I saw this syntax for the first time recently, and I've been curious
about it too.

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


Re: XML to dict(d)

2011-01-31 Thread Daniel Stender
 I've found that there is the library python-dictdlib for concatenating
 dict dictionaries, what would
 be the best way to de-XML the source file?
 
 How do you want to the dict to look like?
 
 Stefan

What's in key1 should be the search word, the rest altogether belonging to 
that in a single line
(with some minor modifications).

Greetings,
DS

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


Re: XML to dict(d)

2011-01-31 Thread Stefan Behnel

Daniel Stender, 31.01.2011 15:14:

I've found that there is the library python-dictdlib for concatenating
dict dictionaries, what would
be the best way to de-XML the source file?


How do you want to the dict to look like?


What's inkey1  should be the search word, the rest altogether belonging to 
that in a single line
(with some minor modifications).


the rest isn't very precise, but here's an example of what you could do.

from xml.etree.cElementTree import iterparse

words = {}
h_tags = ('H1', 'H2', 'H3')
for _, element in iterparse('thefile.xml'):
 if element.tag in h_tags:
 words[element.findtext('h/key1')] = element

Since you didn't provide enough information, I have no idea what you want 
to make of the h, body and tail tags. But I'm sure you'll figure it out.


Stefan

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


Re: Python critique

2011-01-31 Thread sturlamolden
On 10 Des 2010, 21:02, John Nagle na...@animats.com wrote:

     Probably the biggest practical problem with CPython is
 that C modules have to be closely matched to the version of
 CPython.  There's no well-defined API that doesn't change.

ctypes and DLLs in plain C do not change, and do not depend on CPython
version.


Sturla

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


Re: Python critique

2011-01-31 Thread sturlamolden
On 11 Des 2010, 00:09, Antoine Pitrou solip...@pitrou.net wrote:

      Probably the biggest practical problem with CPython is
  that C modules have to be closely matched to the version of
  CPython.  There's no well-defined API that doesn't change.

 Please stop spreading FUD:http://docs.python.org/c-api/index.html

Even if the API does not change, there is still static linkage with
version dependency. That is avoided with ctypes.

Sturla

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


Would like to add an upload facility to my web site

2011-01-31 Thread Ramon F Herrera

(newbie alert)

This is what I have so far:

http://patriot.net/~ramon/upload_facility.html

The code is shown below. It seems I need that actual script that
performs the file transfer. I would prefer it in Python.

TIA,

-Ramon

---

html
body
br /
form action=upload_file.php method=post enctype=multipart/form-
data
label for=fileName of file to be uploaded:/label
input type=file name=file id=file /
br /
br /
input type=submit name=submit value=Upstream like the
salmons! /
/form
/body
/html

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


Re: Would like to add an upload facility to my web site

2011-01-31 Thread Ramon F Herrera
On Jan 31, 10:49 am, Ramon F Herrera ra...@conexus.net wrote:
 (newbie alert)

 This is what I have so far:

 http://patriot.net/~ramon/upload_facility.html

 The code is shown below. It seems I need that actual script that
 performs the file transfer. I would prefer it in Python.

 TIA,

 -Ramon

 ---

 html
 body
 br /
 form action=upload_file.php method=post enctype=multipart/form-
 data
     label for=fileName of file to be uploaded:/label
     input type=file name=file id=file /
     br /
     br /
     input type=submit name=submit value=Upstream like the
 salmons! /
 /form
 /body
 /html

IMPORTANT Bonus question:

Where should I post this type of question about writing stuff for the
web

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


Re: Would like to add an upload facility to my web site

2011-01-31 Thread Miki
One way is http://pythonwise.blogspot.com/2007/03/pushing-data-easy-way.html :)

This list a good place to ask, you can try StackOverflow as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Cast to a method pointer in ctypes

2011-01-31 Thread Andrew Evans
How can I cast to a method pointer in ctypes. for example this in C

int (*func)();
func = (int (*)()) expl;
(int)(*func)();

How can I do this in ctypes using Python? I couldn't find the info I needed
to be able to do this

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


Re: Would like to add an upload facility to my web site

2011-01-31 Thread Luis M . González
On Jan 31, 1:50 pm, Ramon F Herrera ra...@conexus.net wrote:
 On Jan 31, 10:49 am, Ramon F Herrera ra...@conexus.net wrote:









  (newbie alert)

  This is what I have so far:

 http://patriot.net/~ramon/upload_facility.html

  The code is shown below. It seems I need that actual script that
  performs the file transfer. I would prefer it in Python.

  TIA,

  -Ramon

  ---

  html
  body
  br /
  form action=upload_file.php method=post enctype=multipart/form-
  data
      label for=fileName of file to be uploaded:/label
      input type=file name=file id=file /
      br /
      br /
      input type=submit name=submit value=Upstream like the
  salmons! /
  /form
  /body
  /html

 IMPORTANT Bonus question:

 Where should I post this type of question about writing stuff for the
 web

 -Ramon

I guess this question is framework specific.
Are you using any framework (django, pylons, etc...)?
-- 
http://mail.python.org/mailman/listinfo/python-list


IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rantingrick

IDLE: A cornicopia of mediocrity and obfuscation.
-- by Rick Johnson


IDLE --which is the Python Integrated Development and Learning
Environment-- was once the apple of Guido's eye but has since
degenerated into madness many years ago and remains now as the shining
jewel show piece on the proverbial python wall of shame. A once
mighty dream of programming for everyone that is now nothing more
than an example of how NOT to program.

IDLE contains some of the worst code this community has created. Bad
design patterns, tacked on functionality, blasphemous styling, and
piss poor packaging. There seems to be no guiding goals or game-plan.
And year after year if IDLE *does* get any attention it's just more
haphazard code thrown into the mix by someone who has gone blind from
reading the source. However we cannot blame the current maintainer (if
any such even exists!) because NOBODY can maintains such a spaghetti
mess that this package has become!

If we would have had a proper game plan from day one i believe we
could have avoided this catastrophe. Follows is an outline of the
wrongs with some suggestions to right them...

 * First of all the main two modules PyShell and EditorWindow are
laid out in such a non sequential way that it is virtually impossible
to follow along. We should have had a proper app instance from which
all widgets where combined. The main app should have followed a
common sense sequential mentality of...

 * subclassing the tk.Toplevel
 * initializing instance variables
 * creating the main menu
 * creating the sub widgets
 * declaring internal methods
 * declaring event handlers
 * then interface/generic methods.

 This is the recipe for order AND NOT CHAOS! What we have now is utter
chaos! When we have order we can read source code in a sequential
fashion. When we have order we can comprehend what we read. And when
we have order we can maintain a library/package with ease. However
sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS!

* The underlying sub widgets should have started with their own proper
order of declared initialization. And all events should be handled
in the widget at hand NOT outsourced to some other class!

 * One of the biggest design flaws is the fact that outside modules
manipulate the main editor/pyshells events. This is a terrible way to
code. For example the AutoCompleteWindow takes over the tab event

  #-- Puesdo Code --#
  # in editor window __init__
  self.autocomplete = AutoComplete(blah)
  # in editor window onKeyPress(blah)
  if key == 'Tab' and blah:
  self.autocomplete.show_tip(blah)
  elif key == 'Escape' and acw.is_visibe():
  self.autocomplete.hide()

 This is a bad design! The main editor window should handle all its
own events AND THEN call outside class methods when needed. We don't
want Mommy classes telling the kids what to do, when to eat, when to
sleep, and when to excrete! We should create our objects with the
virtue of self reliance and responsibility!. The Colorizer,
ParenMatch, textView, TreeWidget, CallTips, and many other modules are
guilty of event stealing also. Event functionality must be handled
in the widget itself, NOT stolen and handled in an outside class. When
we split up sequential code we get CHAOS!

 * Another bad choice was creating custom reusable widgets
(Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in
idlelib. These should have been moved into the lib-tk module where
they would be more visible to python programmers AND we could reduce
the cruft in the idlelib! Remember, when we create more files,
folders, and objects we create CHAOS. And nobody can learn from CHAOS!

 * Another blasphemy is the fact that every module should include some
sort of test to display its usage. If the module is a GUI widget then
you MUST show how to use the widget in a window. Sadly like all
everything else, idlelib is devoid of examples and testing. And the
very few tests that DO exists just blow chunks!

 * Last but not least idlelib does not follow PEP8 or ANY convention.
So much so that it seems the developers snubbed their nose at such
conventions! We are missing doc strings and comments. We have built-
ins being re-bound! Just code horror after code horror.

These are just the top of the list. The peak of a huge iceberg that
threatens to sink the community in the arms of chaos never to return.
I am beginning to believe that this community is either made of
amateurs due to this lackluster code in the stdlib. However it could
be that the folks are really professional and refuse to work on such a
horrible code base (which i understand). I am going with the latter.

When are we going to demand that these abominations be rectified? How
much longer must we wait? A year? Ten years?... i don't think Python
will survive another ten years with this attitude of obfuscation, and
mentality of mediocrity.

-- rr: disappointed and annoyed!




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


Re: Would like to add an upload facility to my web site

2011-01-31 Thread Google Poster
On Jan 31, 11:36 am, Luis M. González luis...@gmail.com wrote:
 On Jan 31, 1:50 pm, Ramon F Herrera ra...@conexus.net wrote:



  On Jan 31, 10:49 am, Ramon F Herrera ra...@conexus.net wrote:

   (newbie alert)

   This is what I have so far:

  http://patriot.net/~ramon/upload_facility.html

   The code is shown below. It seems I need that actual script that
   performs the file transfer. I would prefer it in Python.

   TIA,

   -Ramon

   ---

   html
   body
   br /
   form action=upload_file.php method=post enctype=multipart/form-
   data
       label for=fileName of file to be uploaded:/label
       input type=file name=file id=file /
       br /
       br /
       input type=submit name=submit value=Upstream like the
   salmons! /
   /form
   /body
   /html

  IMPORTANT Bonus question:

  Where should I post this type of question about writing stuff for the
  web

  -Ramon


 I guess this question is framework specific.

No.

  Are you using any framework (django, pylons, etc...)?

Luis:

I have a commercial shell account. I can only edit the directory
~ramon/public_html.

I published one file already, I need the other.

Gracias!

-Ramon

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


Re: Would like to add an upload facility to my web site

2011-01-31 Thread Google Poster
On Jan 31, 11:36 am, Luis M. González luis...@gmail.com wrote:
 On Jan 31, 1:50 pm, Ramon F Herrera ra...@conexus.net wrote:



  On Jan 31, 10:49 am, Ramon F Herrera ra...@conexus.net wrote:

   (newbie alert)

   This is what I have so far:

  http://patriot.net/~ramon/upload_facility.html

   The code is shown below. It seems I need that actual script that
   performs the file transfer. I would prefer it in Python.

   TIA,

   -Ramon

   ---

   html
   body
   br /
   form action=upload_file.php method=post enctype=multipart/form-
   data
       label for=fileName of file to be uploaded:/label
       input type=file name=file id=file /
       br /
       br /
       input type=submit name=submit value=Upstream like the
   salmons! /
   /form
   /body
   /html

  IMPORTANT Bonus question:

  Where should I post this type of question about writing stuff for the
  web

  -Ramon

 I guess this question is framework specific.
 Are you using any framework (django, pylons, etc...)?


Luis,

Allow me to make this more clear. I have my own servers, all of them
running Linux. I have been Linux sysadmin for more time than I care to
remember. However, I (on purpose) provided an example hosted at my
commercial shell provider. That was a deliberate decision, because I
am looking for the simplest possible solution.

I guess the question now is: Do I need root access to uploads files??

Gracias,

-Ramon

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rantingrick
On Jan 31, 11:39 am, rantingrick rantingr...@gmail.com wrote:


In my original post i showed this code

#-- Puesdo Code --#
  # in editor window __init__
  self.autocomplete = AutoComplete(blah)
  # in editor window onKeyPress(blah)
  if key == 'Tab' and blah:
  self.autocomplete.show_tip(blah)
  elif key == 'Escape' and acw.is_visibe():
  self.autocomplete.hide()


...is a suggested FIX of the current code NOT a generalization of the
current code. However it may easily be miss-interpreted due to
improper placement in the paragraph.



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


Re: WxPython versus Tkinter.

2011-01-31 Thread sturlamolden
On 23 Jan, 01:07, rantingrick rantingr...@gmail.com wrote:

 It is time to prove once and for all how dated and worthless Tkinter
 is compared to wxPython. Yes, WxPython is not as advanced as i would
 like it to be for a 21st century GUI library.

So use PyQt instead.

 However compared to
 Tkinter, Wx is light years ahead! Wx is our best hope to move Python
 into the 21st century.

I vaguely someone saying that about Borland VCL and C++. Now people
harly remember there was a RAD product called Borland C++ Builder,
with a sane GUI API compared to Microsoft's MFC.

I for one do not like to handcode GUIs. That is why I use
wxFormBuilder, and the availability of a good GUI builder dictates my
choise of API (currently wxPython due to the previously mentioned
product).

Sturla



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


Re: multiple values for keyword argument

2011-01-31 Thread patty
 On 29 January 2011 18:39,  pa...@cruzio.com wrote:
 I, myself, use the spanish word 'yo' instead (less keystrokes, I hate
 'self', and it amuses me); if I'm working with my numerical experiments
 I'll use 'n' or 'x'... although, when posting sample code to c.l.py I
 do
 try to use 'self' to avoid possible confusion.  :)

 I am glad you said this.  I have been avoiding understanding this
 'self',
 just accepting it :}  For the time being, since my programs I am
 creating
 are for my own use, I think I will make my own names up, that are
 descriptive to me as the programmer, it's all going to be interpreted
 anyway.  And the other email equating to C's argv, etc. - now I get it.

 It's perfectly legal to use a name other than self. It's alo perfectly
 legal never to wash - and you won't make any friends that way either.

 --
 Cheers,
 Simon B.



Cute.

Believe me, I am learning to change my evil ways.  This is what happens
when you come from a *long* line of self-employed, entrepreneurial people.

Independently Yours,

Patty



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


Re: Would like to add an upload facility to my web site

2011-01-31 Thread Nitin Pawar
On Mon, Jan 31, 2011 at 11:16 PM, Google Poster gopos...@jonjay.com wrote:

 On Jan 31, 11:36 am, Luis M. González luis...@gmail.com wrote:
  On Jan 31, 1:50 pm, Ramon F Herrera ra...@conexus.net wrote:
 
 
 
   On Jan 31, 10:49 am, Ramon F Herrera ra...@conexus.net wrote:
 
(newbie alert)
 
This is what I have so far:
 
   http://patriot.net/~ramon/upload_facility.html
 
The code is shown below. It seems I need that actual script that
performs the file transfer. I would prefer it in Python.
 
TIA,
 
-Ramon
 
---
 
html
body
br /
form action=upload_file.php method=post enctype=multipart/form-
data
label for=fileName of file to be uploaded:/label
input type=file name=file id=file /
br /
br /
input type=submit name=submit value=Upstream like the
salmons! /
/form
/body
/html
 
   IMPORTANT Bonus question:
 
   Where should I post this type of question about writing stuff for the
   web
 
   -Ramon
 
  I guess this question is framework specific.
  Are you using any framework (django, pylons, etc...)?


 Luis,

 Allow me to make this more clear. I have my own servers, all of them
 running Linux. I have been Linux sysadmin for more time than I care to
 remember. However, I (on purpose) provided an example hosted at my
 commercial shell provider. That was a deliberate decision, because I
 am looking for the simplest possible solution.

 I guess the question now is: Do I need root access to uploads files??

 Gracias,

 -Ramon

 --



You don't need a root access to upload files.
You will just need to create a directory where you want to save the uploaded
files and grant permission to the username by which the web server is
running.
In case the file uploads are small the simple upload feature works fine but
for larger files you may need to write a chunk read/write api


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




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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Littlefield, Tyler

However we cannot blame the current maintainer...

You seem to still not know who -we- is. rewrite your message using I in place 
of we, and you'll be on the right track.

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rantingrick
PLEASE KINDLY IGNORE MY FIRST TWO POSTS:
  Due to some errors i need to repost.
Thank you.



IDLE: A cornicopia of mediocrity and obfuscation.
-- by Rick Johnson


IDLE --which is the Python Integrated Development and Learning
Environment-- was once the apple of Guido's eye but has since
degenerated into madness many years ago and remains now as the shining
jewel show piece on the proverbial python wall of shame. A once
mighty dream of programming for everyone that is now nothing more
than an example of how NOT to program.

IDLE contains some of the worst code this community has created. Bad
design patterns, tacked on functionality, blasphemous styling, and
piss poor packaging. There seems to be no guiding goals or game-plan.
And year after year if IDLE *does* get any attention it's just more
haphazard code thrown into the mix by someone who has gone blind from
reading the source. However we cannot blame the current maintainer --
if any such even exists-- because NOBODY can maintains such a
spaghetti mess that this package has become!

If we would have had a proper game plan from day one i believe we
could have avoided this catastrophe. Follows is an outline of the
wrongs with some suggestions to right them...

 * First of all the main two modules PyShell and EditorWindow are
laid out in such a non sequential way that it is virtually impossible
to follow along. We should have had a proper app instance from which
all widgets where combined. The main app should have followed a
common sense sequential mentality of...

 * subclassing the tk.Toplevel
 * initializing instance variables
 * creating the main menu
 * creating the sub widgets
 * declaring internal methods
 * declaring event handlers
 * interface/generic methods.

... This is the recipe for order AND NOT CHAOS! What we have now is
utter chaos! When we have order we can read source code in a
sequential fashion. When we have order we can comprehend what we read.
And when we have order we can maintain a library/package with ease.
However sadly we DO NOT have order, we have CHAOS, CHAOS, and more
CHAOS!

* The underlying sub widgets should have started with their own proper
order of declared initialization. And all events should be handled
in the widget at hand NOT outsourced to some other class!

 * One of the biggest design flaws is the fact that outside modules
manipulate the main editor/pyshells events. This is a terrible way to
code. For example the AutoCompleteWindow takes over the tab event.
This is a bad design! The main editor window should handle all its own
events AND THEN call outside class methods when needed...

  #-- Puesdo Code --#
  # in editor window __init__
  self.autocomplete = AutoComplete(blah)
  # in editor window onKeyPress(blah)
  if key == 'Tab' and blah:
  self.autocomplete.show_tip(blah)
  elif key == 'Escape' and acw.is_visibe():
  self.autocomplete.hide()

...We don't want Mommy classes telling the kids what to do, when to
eat, when to sleep, and when to excrete! We should create our objects
with the virtue of self reliance and responsibility!. The Colorizer,
ParenMatch, CallTips, and many other modules are guilty of event
stealing also. Event functionality must be handled in the widget
itself, NOT stolen and handled in an outside class. When we split up
sequential code we get CHAOS!

 * Another bad choice was creating custom reusable widgets
(Tabbedpages, FindDialog, ReplaceDialog, textView, TreeWidget, etc...)
and leaving them in idlelib. These should have been moved into the lib-
tk folder where they would be more visible to python programmers AND
we could reduce the cruft in the idlelib! Remember, when we create
more files, folders, and objects we create CHAOS. And nobody can learn
from CHAOS!

 * Another blasphemy is the fact that every module should include some
sort of test/demo to display its usage. If the module is a GUI widget
then you MUST show how to use the widget in a window. Sadly like all
everything else, idlelib is devoid of examples and testing. And the
very few tests that DO exists just blow chunks!

 * Last but not least idlelib does not follow PEP8 or ANY convention.
So much so that it seems the developers snubbed their nose at such
conventions! We are missing doc strings and comments. We have built-
ins being rebound! Just code horror after code horror.

These are just the top of the list. The peak of a huge iceberg that
threatens to sink the community in the arms of chaos never to return.
I am beginning to believe that this community is made of amateurs due
to this lackluster code in the stdlib. However it could be that the
folks are really professional and refuse to work on such a horrible
code base (which i understand). I am going with the latter.

When are we going to demand that these abominations be rectified? How
much longer must we wait? A year? Ten years?... i don't think Python
will survive another ten years with this attitude of obfuscation, and
mentality of mediocrity.

-- rr: 

Re: multiple values for keyword argument

2011-01-31 Thread Jean-Michel Pichavant

pa...@cruzio.com wrote:

  I have been avoiding understanding this 'self',
[snip]
Regards,

Patty
  
What is to be understood ?? self references the instance. Did I miss 
something ?


JM


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Giampaolo Rodolà
So what you're actually telling is that Python won't survive another
10 years because:

- IDLE is it's default editor
- idlelib directory is the first place you should look every time you
need an inspiration on how code should be written
- code in idlelib directory sucks

That's an interesting point and I thank you for pointing that out.
Personally I've never looked into idlelib directory for 7 years in a row at all.
I was probably doing some other things, I don't know, but now I'm
definitively gonna start looking for a new language because it's clear
that any language having a directory called idlelib within such a
horrible source code is not gonna last for long.


Thanks again,


--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/


2011/1/31 rantingrick rantingr...@gmail.com:
 PLEASE KINDLY IGNORE MY FIRST TWO POSTS:
  Due to some errors i need to repost.
 Thank you.



 IDLE: A cornicopia of mediocrity and obfuscation.
 -- by Rick Johnson


 IDLE --which is the Python Integrated Development and Learning
 Environment-- was once the apple of Guido's eye but has since
 degenerated into madness many years ago and remains now as the shining
 jewel show piece on the proverbial python wall of shame. A once
 mighty dream of programming for everyone that is now nothing more
 than an example of how NOT to program.

 IDLE contains some of the worst code this community has created. Bad
 design patterns, tacked on functionality, blasphemous styling, and
 piss poor packaging. There seems to be no guiding goals or game-plan.
 And year after year if IDLE *does* get any attention it's just more
 haphazard code thrown into the mix by someone who has gone blind from
 reading the source. However we cannot blame the current maintainer --
 if any such even exists-- because NOBODY can maintains such a
 spaghetti mess that this package has become!

 If we would have had a proper game plan from day one i believe we
 could have avoided this catastrophe. Follows is an outline of the
 wrongs with some suggestions to right them...

  * First of all the main two modules PyShell and EditorWindow are
 laid out in such a non sequential way that it is virtually impossible
 to follow along. We should have had a proper app instance from which
 all widgets where combined. The main app should have followed a
 common sense sequential mentality of...

  * subclassing the tk.Toplevel
  * initializing instance variables
  * creating the main menu
  * creating the sub widgets
  * declaring internal methods
  * declaring event handlers
  * interface/generic methods.

 ... This is the recipe for order AND NOT CHAOS! What we have now is
 utter chaos! When we have order we can read source code in a
 sequential fashion. When we have order we can comprehend what we read.
 And when we have order we can maintain a library/package with ease.
 However sadly we DO NOT have order, we have CHAOS, CHAOS, and more
 CHAOS!

 * The underlying sub widgets should have started with their own proper
 order of declared initialization. And all events should be handled
 in the widget at hand NOT outsourced to some other class!

  * One of the biggest design flaws is the fact that outside modules
 manipulate the main editor/pyshells events. This is a terrible way to
 code. For example the AutoCompleteWindow takes over the tab event.
 This is a bad design! The main editor window should handle all its own
 events AND THEN call outside class methods when needed...

  #-- Puesdo Code --#
  # in editor window __init__
  self.autocomplete = AutoComplete(blah)
  # in editor window onKeyPress(blah)
  if key == 'Tab' and blah:
      self.autocomplete.show_tip(blah)
  elif key == 'Escape' and acw.is_visibe():
      self.autocomplete.hide()

 ...We don't want Mommy classes telling the kids what to do, when to
 eat, when to sleep, and when to excrete! We should create our objects
 with the virtue of self reliance and responsibility!. The Colorizer,
 ParenMatch, CallTips, and many other modules are guilty of event
 stealing also. Event functionality must be handled in the widget
 itself, NOT stolen and handled in an outside class. When we split up
 sequential code we get CHAOS!

  * Another bad choice was creating custom reusable widgets
 (Tabbedpages, FindDialog, ReplaceDialog, textView, TreeWidget, etc...)
 and leaving them in idlelib. These should have been moved into the lib-
 tk folder where they would be more visible to python programmers AND
 we could reduce the cruft in the idlelib! Remember, when we create
 more files, folders, and objects we create CHAOS. And nobody can learn
 from CHAOS!

  * Another blasphemy is the fact that every module should include some
 sort of test/demo to display its usage. If the module is a GUI widget
 then you MUST show how to use the widget in a window. Sadly like all
 everything else, idlelib is devoid of examples and testing. And the
 very few tests that DO exists just blow chunks!

  * Last but not least 

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rantingrick
On Jan 31, 1:32 pm, Giampaolo Rodolà g.rod...@gmail.com wrote:
 So what you're actually telling is that Python won't survive another
 10 years because:

 - IDLE is it's default editor

Well not solely because IDLE is the default editor. IDLE is very
useful to newcommers and could be made even more useful however the
code base is rotten!

 - idlelib directory is the first place you should look every time you
 need an inspiration on how code should be written

In an ideal world it should be the first place you look when wanting
to learn how to build medium sized GUI projects with the built-in
Tkinter module. However the reality is ANYTHING but ideal. The code is
rotten to the core, full of inconsistencies and just very unpythonic.
Not something i would suggest any aspiring Tkinter n00b look at unless
they want to learn what NOT to do.

 - code in idlelib directory sucks

plainly and simply... YES.

 That's an interesting point and I thank you for pointing that out.
 Personally I've never looked into idlelib directory for 7 years in a row at 
 all.

And i am glad, because had you followed the example of IDLE you would
be spreading mediocrity and obfuscation. Both of which are not virtues
to be admired.

 I was probably doing some other things, I don't know, but now I'm
 definitively gonna start looking for a new language because it's clear
 that any language having a directory called idlelib within such a
 horrible source code is not gonna last for long.

Well not unless we do something about it. It is high time to stop
patching, bolting on, and future extending the suffering of this
horrendous code base. It is time to pull the plug, let it die, and
start fresh. Start from a real python perspective. We can learn from
past mistakes and build something much better. But will we? Do we have
the community spirit to take on this challenge? Do we as a community
have any fire left or have we collectively waxed cold?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use the Source Luke

2011-01-31 Thread Raymond Hettinger
On Jan 30, 6:47 am, Tim Wintle tim.win...@teamrubber.com wrote:
 +1 - I think the source links are very useful (and thanks for pushing
 them).

Happy to do it.

 However I think the biggest changes that have probably happened with
 python itself are:

  (1) More users for whom this is their first language.
  (2) CS courses / training not teaching C (or pointer-based languages).

 (2) is especially important IMO - under half of the python developers I
 have regularly worked with would feel comfortable reading C - so for the
 other half reading C source code probably isn't going to help them
 understand exactly what's going on (although in the long run it might
 help them a lot)

That would explain why fewer people look at the C source code.

However, even the parts of the standard library written in pure Python
don't seem to be getting read anymore, so I'm still inclined to
attribute the issue to 1) inconvenient placement of source code,
2) a largish code base, and 3) possibly a cultural shift.

I'm thinking that all of those can be addressed by efforts
to lower to intellectual investment required to find the
relevant source code.


Raymond

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


Re: Use the Source Luke

2011-01-31 Thread rantingrick
On Jan 30, 10:50 am, rusi rustompm...@gmail.com wrote:

 I note particularly the disclaimer that it was removed from wikipedia
 [Like when your-unfavorite-TV-channel censors stuff you know it
 deserves a second look ;-) ]

Oh you mean that channel that *claims* to provide a specific type of
programming however they really provide *anything* but that specific
type of programming! Yes, thank god for you tube.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python metaclass and UML

2011-01-31 Thread Laszlo Nagy
How should I represent a Python metaclass on an UML class diagram? I 
know how to represent composition, aggregation and inheritance. But not 
sure about metaclasses. What kind of arrow or line should I use between 
a class and its metaclass? Is there a standard for this?


Thanks,

   Laszlo

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


Re: Python metaclass and UML

2011-01-31 Thread Ian Kelly
On Mon, Jan 31, 2011 at 1:04 PM, Laszlo Nagy gand...@shopzeus.com wrote:
 How should I represent a Python metaclass on an UML class diagram? I know
 how to represent composition, aggregation and inheritance. But not sure
 about metaclasses. What kind of arrow or line should I use between a class
 and its metaclass? Is there a standard for this?

http://stackoverflow.com/questions/1483273/how-to-draw-a-classs-metaclass-in-uml
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python metaclass and UML

2011-01-31 Thread James Mills
On Tue, Feb 1, 2011 at 6:04 AM, Laszlo Nagy gand...@shopzeus.com wrote:
 How should I represent a Python metaclass on an UML class diagram? I know
 how to represent composition, aggregation and inheritance. But not sure
 about metaclasses. What kind of arrow or line should I use between a class
 and its metaclass? Is there a standard for this?

IHMO (but others may have other opinions) the same way
you'd represent a decorated function. Metaclasses IHMO
have the same effect as a decorated function - modifying
another classes's behavior.

cheers
Jaes

-- 
-- James Mills
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple values for keyword argument

2011-01-31 Thread Patty


- Original Message - 
From: Jean-Michel Pichavant jeanmic...@sequans.com

To: pa...@cruzio.com
Cc: python-list@python.org
Sent: Monday, January 31, 2011 11:35 AM
Subject: Re: multiple values for keyword argument



pa...@cruzio.com wrote:

  I have been avoiding understanding this 'self',
[snip]
Regards,

Patty
  
What is to be understood ?? self references the instance. Did I miss 
something ?


JM





Yes, there was more.  And it's been fully explained at this point.

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


Re: Understanding def foo(*args)

2011-01-31 Thread Ben Finney
Rob Richardson rob.richard...@rad-con.com writes:

 My thanks both to the original poster and to JM for an excellent answer.
 I saw this syntax for the first time recently, and I've been curious
 about it too.

Would it be correct of me to assume that you have not worked through the
entire Python tutorial URL:http://docs.python.org/tutorial/ to get a
thorough grounding in Python basics like this?

-- 
 \ “I wish there was a knob on the TV to turn up the intelligence. |
  `\  There's a knob called ‘brightness’ but it doesn't work.” |
_o__) —Eugene P. Gallagher |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use the Source Luke

2011-01-31 Thread Emile van Sebille

On 1/31/2011 12:35 PM Raymond Hettinger said...

That would explain why fewer people look at the C source code.

However, even the parts of the standard library written in pure Python
don't seem to be getting read anymore, so I'm still inclined to
attribute the issue to 1) inconvenient placement of source code,
2) a largish code base, and 3) possibly a cultural shift.



ISTM that around the time the list forked off py-dev fewer people 
remained that were singing 'use the source'. . .


Emile


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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Robert

On 2011-01-31 15:19:44 -0500, rantingrick said:


On Jan 31, 1:32 pm, Giampaolo Rodolà g.rod...@gmail.com wrote:

So what you're actually telling is that Python won't survive another
10 years because:

- IDLE is it's default editor


Well not solely because IDLE is the default editor. IDLE is very
useful to newcommers and could be made even more useful however the
code base is rotten!


Then DO something about it and no excuses. Fork it, make it better, 
submit it as a replacement.


--
Robert


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


Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox

2011-01-31 Thread Sascha
Hello

I am returning specialised website html according to what platform the
user is on. Is there a way to determine if the user is on a Smart
Phone or on IE or on Firefox?

Using python /or examining HTTP packets?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Kevin Walzer

Rick,

I've spent a fair amount of time in the IDLE source tree, putting 
together patches for various Mac-specific bugs and submitting them to 
the Python tracker, and I agree the code is crufty and disorganized. It 
is certainly not an example of current best practices in Tkinter 
development. The code base has accrued over the years, has been touched 
by many, many different hands, and I think its current messy state 
reflects that legacy.


But, as I understand it, the purpose of IDLE is not to provide a 
pedagogical example of Tkinter programming practices, but instead to 
provide a lightweight development environment for those learning Python, 
to interactively explore different aspects of Python. For this it serves 
its purpose well. I use IDLE a good deal for my Python development work, 
and the cruftiness of the code under the hood is not an impediment to me 
getting my work done (unless the work is patching IDLE itself).


Given this, I don't see any huge need to bulldoze IDLE to the ground and 
replace it with something else, or even do massive rewrites of the code, 
unless such a project also significantly improved the user-facing 
portions of IDLE as well. However, there are certainly no impediments 
for you undertaking such a project yourself: similar efforts have been 
undertaken in the past and, as I understand it, have led to some 
significant improvements in IDLE's performance. Here's the one I'm 
thinking of:


http://idlefork.sourceforge.net/

According to this project's details, IDLE was forked, numerous changes 
were made to its code base, the new version of IDLE gained a user base, 
and eventually the changes were merged back in to Python's main line of 
development.


It certainly would be interesting to see a fresh approach to IDLE, and I 
think the scope of such a project would be much easier for a single 
person to manage than would replacing Tkinter in the stdlib with another 
GUI toolkit, such as wxPython, or pyGUI, or something else. I'd 
encourage you to set up a project page somewhere, begin cutting some 
code, and then invite feedback from other users and/or developers. I 
think that approach has a much better chance of getting off the ground 
and making progress than long threads on c.l.py.


Good luck!

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


simplest way to create simple standalone wsgi server without import wsgi_lib.server

2011-01-31 Thread Gelonida
Hi,

Normally I use following code snippet to quickly test a wsgi module
without a web server.

import wsgi_lib.server
wsgi_lib.server.run(application, port=port)


However Now I'd like to test a small wsgi module on a rather old host
( Python 2.4.3 ) where I don't have means to update python.

Is there any quick and easy code snippet / module, performing the same
task as my above mentioned lines?

Thanks in advance for any hints




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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Robert

On 2011-01-31 17:17:06 -0500, Kevin Walzer said:



It certainly would be interesting to see a fresh approach to IDLE, and I
think the scope of such a project would be much easier for a single
person to manage than would replacing Tkinter in the stdlib with another
GUI toolkit, such as wxPython, or pyGUI, or something else. I'd
encourage you to set up a project page somewhere, begin cutting some
code, and then invite feedback from other users and/or developers. I
think that approach has a much better chance of getting off the ground
and making progress than long threads on c.l.py.

Good luck!

--Kevin


I think it would be interesting as well. H, I am about to do the 
O'Reilly series that Steve Holden did for Python. Maybe I will take 
that up as a project when I get through it (or...*nudge* *nudge* *wink* 
*wink* to Rick, help out if someone else does a fork).


--
Robert


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


Re: Use the Source Luke

2011-01-31 Thread Steven D'Aprano
On Mon, 31 Jan 2011 12:35:12 -0800, Raymond Hettinger wrote:

 However, even the parts of the standard library written in pure Python
 don't seem to be getting read anymore, so I'm still inclined to
 attribute the issue to 1) inconvenient placement of source code, 2) a
 largish code base, and 3) possibly a cultural shift.

I'd be inclined to say that #3 is by far the most important. When I 
started programming, the internet wasn't even a distant object on radar. 
(That is to say, it existed, but hardly anyone outside of a few gurus at 
universities had even heard of it.) If you wanted to learn a language, 
you bought a book and read it, if one existed and you could afford it, 
and you read the sample code that came with the software. Often the book 
you bought told you to read the sample code. You couldn't email a mailing 
list to ask for help, or post to a forum, or google the answer. If you 
were lucky, you could go to a Users Group once a month or so. And so old 
timers learned to read the source, because that's almost all there was.

Today's newbies take the internet, web forums, mailing lists, usenet and 
google for granted. This is a *big* cultural shift.

As for #1, in truth I don't believe it is actually a problem. Okay, it 
might be a bit inconvenient to find the Python source code the first few 
times you go looking (I can never remember whether to look in
/usr/lib/python or /usr/local/lib/python), but once you've found it, it 
isn't difficult to create a shortcut for it. And as for #2, yes, there 
may be a lot of code in the standard library, but it's all cut up into 
small, easily swallowed chunks called modules :)

In my experience, the biggest obstacles for people to read the Python 
code in the standard library are:

(1) thinking to do so in the first place; and

(2) the chicken-and-egg problem that as a newbie they often don't 
understand what they're reading.


Your idea of including links to source in the documentation will 
hopefully help with the first.


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


Re: multiple values for keyword argument

2011-01-31 Thread Westley Martínez
http://en.wikipedia.org/wiki/Self_(computer_science)

On Mon, 2011-01-31 at 13:20 -0800, Patty wrote:

 - Original Message - 
 From: Jean-Michel Pichavant jeanmic...@sequans.com
 To: pa...@cruzio.com
 Cc: python-list@python.org
 Sent: Monday, January 31, 2011 11:35 AM
 Subject: Re: multiple values for keyword argument
 
 
  pa...@cruzio.com wrote:
I have been avoiding understanding this 'self',
  [snip]
  Regards,
 
  Patty

  What is to be understood ?? self references the instance. Did I miss 
  something ?
  
  JM
  
  
 
 
 Yes, there was more.  And it's been fully explained at this point.
 
 Patty


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


Re: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox

2011-01-31 Thread Chris Rebert
On Mon, Jan 31, 2011 at 2:16 PM, Sascha samzielkery...@gmail.com wrote:
 Hello

 I am returning specialised website html according to what platform the
 user is on. Is there a way to determine if the user is on a Smart
 Phone or on IE or on Firefox?

Yes, the User-Agent HTTP header:
http://en.wikipedia.org/wiki/User_agent

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Westley Martínez
alias idle='vim'

: D

On Mon, 2011-01-31 at 09:39 -0800, rantingrick wrote:

 IDLE: A cornicopia of mediocrity and obfuscation.
 -- by Rick Johnson
 
 
 IDLE --which is the Python Integrated Development and Learning
 Environment-- was once the apple of Guido's eye but has since
 degenerated into madness many years ago and remains now as the shining
 jewel show piece on the proverbial python wall of shame. A once
 mighty dream of programming for everyone that is now nothing more
 than an example of how NOT to program.
 
 IDLE contains some of the worst code this community has created. Bad
 design patterns, tacked on functionality, blasphemous styling, and
 piss poor packaging. There seems to be no guiding goals or game-plan.
 And year after year if IDLE *does* get any attention it's just more
 haphazard code thrown into the mix by someone who has gone blind from
 reading the source. However we cannot blame the current maintainer (if
 any such even exists!) because NOBODY can maintains such a spaghetti
 mess that this package has become!
 
 If we would have had a proper game plan from day one i believe we
 could have avoided this catastrophe. Follows is an outline of the
 wrongs with some suggestions to right them...
 
  * First of all the main two modules PyShell and EditorWindow are
 laid out in such a non sequential way that it is virtually impossible
 to follow along. We should have had a proper app instance from which
 all widgets where combined. The main app should have followed a
 common sense sequential mentality of...
 
  * subclassing the tk.Toplevel
  * initializing instance variables
  * creating the main menu
  * creating the sub widgets
  * declaring internal methods
  * declaring event handlers
  * then interface/generic methods.
 
  This is the recipe for order AND NOT CHAOS! What we have now is utter
 chaos! When we have order we can read source code in a sequential
 fashion. When we have order we can comprehend what we read. And when
 we have order we can maintain a library/package with ease. However
 sadly we DO NOT have order, we have CHAOS, CHAOS, and more CHAOS!
 
 * The underlying sub widgets should have started with their own proper
 order of declared initialization. And all events should be handled
 in the widget at hand NOT outsourced to some other class!
 
  * One of the biggest design flaws is the fact that outside modules
 manipulate the main editor/pyshells events. This is a terrible way to
 code. For example the AutoCompleteWindow takes over the tab event
 
   #-- Puesdo Code --#
   # in editor window __init__
   self.autocomplete = AutoComplete(blah)
   # in editor window onKeyPress(blah)
   if key == 'Tab' and blah:
   self.autocomplete.show_tip(blah)
   elif key == 'Escape' and acw.is_visibe():
   self.autocomplete.hide()
 
  This is a bad design! The main editor window should handle all its
 own events AND THEN call outside class methods when needed. We don't
 want Mommy classes telling the kids what to do, when to eat, when to
 sleep, and when to excrete! We should create our objects with the
 virtue of self reliance and responsibility!. The Colorizer,
 ParenMatch, textView, TreeWidget, CallTips, and many other modules are
 guilty of event stealing also. Event functionality must be handled
 in the widget itself, NOT stolen and handled in an outside class. When
 we split up sequential code we get CHAOS!
 
  * Another bad choice was creating custom reusable widgets
 (Tabbedpages, FindDialog, ReplaceDialog, etc...) and leaving them in
 idlelib. These should have been moved into the lib-tk module where
 they would be more visible to python programmers AND we could reduce
 the cruft in the idlelib! Remember, when we create more files,
 folders, and objects we create CHAOS. And nobody can learn from CHAOS!
 
  * Another blasphemy is the fact that every module should include some
 sort of test to display its usage. If the module is a GUI widget then
 you MUST show how to use the widget in a window. Sadly like all
 everything else, idlelib is devoid of examples and testing. And the
 very few tests that DO exists just blow chunks!
 
  * Last but not least idlelib does not follow PEP8 or ANY convention.
 So much so that it seems the developers snubbed their nose at such
 conventions! We are missing doc strings and comments. We have built-
 ins being re-bound! Just code horror after code horror.
 
 These are just the top of the list. The peak of a huge iceberg that
 threatens to sink the community in the arms of chaos never to return.
 I am beginning to believe that this community is either made of
 amateurs due to this lackluster code in the stdlib. However it could
 be that the folks are really professional and refuse to work on such a
 horrible code base (which i understand). I am going with the latter.
 
 When are we going to demand that these abominations be rectified? How
 much longer must we wait? A year? Ten years?... i don't think Python
 will survive another 

Re: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox

2011-01-31 Thread James Mills
On Tue, Feb 1, 2011 at 8:16 AM, Sascha samzielkery...@gmail.com wrote:
 I am returning specialised website html according to what platform the
 user is on. Is there a way to determine if the user is on a Smart
 Phone or on IE or on Firefox?

I have an iPad and just wrote a simple demo app to test this:

http://prologic.no-ip.org:8000/

Source: http://codepad.org/zdZJgm1j

Basically if you check for the string iPad in
the User-Agent header. Obviously this only
works for iPads running IOS and the built-in
Safari Web Browser - but I'm sure other tablet/mobile
devices provide similar unique User-Agent strings.

cheers
James

-- 
-- James Mills
--
-- Problems are solved by method
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Stephen Hansen
On 1/31/11 10:12 AM, rantingrick wrote:
 -- rr: disappointed and annoyed!

tl;dr

You did this one before, I swear.

You're running out of material.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox

2011-01-31 Thread Vivek Shrivastava

 its userAgent or UserAgent String. Though its easy to send request with
 any( fake) userAgent but its industry standard to get browser information
 from userAgent only.

 http://www.useragentstring.com/pages/useragentstring.php



 On Mon, Jan 31, 2011 at 2:46 PM, James Mills prolo...@shortcircuit.net.au
  wrote:

 On Tue, Feb 1, 2011 at 8:16 AM, Sascha samzielkery...@gmail.com wrote:
  I am returning specialised website html according to what platform the
  user is on. Is there a way to determine if the user is on a Smart
  Phone or on IE or on Firefox?

 I have an iPad and just wrote a simple demo app to test this:

 http://prologic.no-ip.org:8000/

 Source: http://codepad.org/zdZJgm1j

 Basically if you check for the string iPad in
 the User-Agent header. Obviously this only
 works for iPads running IOS and the built-in
 Safari Web Browser - but I'm sure other tablet/mobile
 devices provide similar unique User-Agent strings.

 cheers
 James

 --
 -- James Mills
 --
 -- Problems are solved by method
 --
 http://mail.python.org/mailman/listinfo/python-list



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


Re: Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox

2011-01-31 Thread Ben Finney
Sascha samzielkery...@gmail.com writes:

 I am returning specialised website html according to what platform the
 user is on. Is there a way to determine if the user is on a Smart
 Phone or on IE or on Firefox?

The HTTP standard defines the “User-Agent” field, to be sent as part of
the request header URL:http://en.wikipedia.org/wiki/User_agent.

Note that this information is often abused by web server operators, and
the response of many users is to mangle or fabricate this field before
it is sent to the server. (My browser, for example, instructs the reader
to stop obsessing about User-Agent and to code for web standards instead
URL:http://linuxmafia.com/faq/Web/user-agent-string.html.)

-- 
 \   “If you do not trust the source do not use this program.” |
  `\—Microsoft Vista security dialogue |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simplest way to create simple standalone wsgi server without import wsgi_lib.server

2011-01-31 Thread Jean-Paul Calderone
On Jan 31, 5:28 pm, Gelonida gelon...@gmail.com wrote:
 Hi,

 Normally I use following code snippet to quickly test a wsgi module
 without a web server.

 import wsgi_lib.server
 wsgi_lib.server.run(application, port=port)

 However Now I'd like to test a small wsgi module on a rather old host
 ( Python 2.4.3 ) where I don't have means to update python.

 Is there any quick and easy code snippet / module, performing the same
 task as my above mentioned lines?

 Thanks in advance for any hints

You didn't mention why you can't update Python, or if that means you
can't install new libraries either.  However, if you have Twisted 8.2
or newer, you can replace your snippet with this shell command:

twistd -n web --port port --wsgi application

application is the fully-qualified Python name of your application
object.  So, for example if you have a module named foo that defines
an application name, you would pass foo.application.

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


Re: multiple values for keyword argument

2011-01-31 Thread Patty
  - Original Message - 
  From: Westley Martínez 
  To: python-list@python.org 
  Sent: Monday, January 31, 2011 3:27 PM
  Subject: Re: multiple values for keyword argument


  http://en.wikipedia.org/wiki/Self_(computer_science)

  Hello Westley:

  Thank you for the reference.  I saw something in it that I think is what 
tripped me up in my understanding of 'self'.  I printed out the page to absorb 
more later.  It helps me to learn when the concept is introduced to me in terms 
of comparison to other languages so I like this page.  Here are the two lines 
from the wiki page, I was probably going to try and 'assign to self' and 
expecting that I was modifying the original object like it says.  In turn, that 
is what was leading me to want to name 'self' anything I want, to jog my memory 
as to 'where it came from' because '*I* am assigning it'.  [I know I should be 
documenting my code clearly and my memory shouldn't need to be jogged :} ].  
  Some languages, such as Objective-C, allow assignment to this, although it 
is deprecated. Doing so can be very misleading to maintenance programmers, 
because the assignment does not modify the original object, only changing which 
object that the rest of the code in the method refers to, and can end with 
undefined behavior

  Regards - 

  Patty


  On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: 
- Original Message - 
From: Jean-Michel Pichavant jeanmic...@sequans.com
To: pa...@cruzio.com
Cc: python-list@python.org
Sent: Monday, January 31, 2011 11:35 AM
Subject: Re: multiple values for keyword argument


 pa...@cruzio.com wrote:
   I have been avoiding understanding this 'self',
 [snip]
 Regards,

 Patty
   
 What is to be understood ?? self references the instance. Did I miss 
 something ?
 
 JM
 
 


Yes, there was more.  And it's been fully explained at this point.

Patty




--


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


Re: multiple values for keyword argument

2011-01-31 Thread Westley Martínez
In Python, self is simply the standard name used. You can use any name.
Consider this:
 class Spam:
... def __init__(self):
... print(self)
... self = 'eggs'
... print(self)
... 
 spam = Spam()
__main__.Spam object at 0xb7224b4c
eggs

When we have an instance method, here __init__, we always pass the
instance as the first argument. This is assigned as regular old
variable. It doesn't have any special restrictions. So when we refer
self to a string, self simply stops pointing to the object and points to
the string instead, but remember that each self is only contained in its
method, so all the other selfs in the class will still point to the
object.

On Mon, 2011-01-31 at 18:18 -0800, Patty wrote:

  
 
 - Original Message - 
 From: Westley Martínez 
 To: python-list@python.org 
 Sent: Monday, January 31, 2011 3:27 PM
 Subject: Re: multiple values for keyword argument
 
 
 http://en.wikipedia.org/wiki/Self_(computer_science)
  
 Hello Westley:
  
 Thank you for the reference.  I saw something in it that I
 think is what tripped me up in my understanding of 'self'.  I
 printed out the page to absorb more later.  It helps me to
 learn when the concept is introduced to me in terms of
 comparison to other languages so I like this page.  Here are
 the two lines from the wiki page, I was probably going to try
 and 'assign to self' and expecting that I was modifying the
 original object like it says.  In turn, that is what was
 leading me to want to name 'self' anything I want, to jog my
 memory as to 'where it came from' because '*I* am assigning
 it'.  [I know I should be documenting my code clearly and my
 memory shouldn't need to be jogged :} ].  
 Some languages, such as Objective-C, allow assignment to
 this, although it is deprecated. Doing so can be very
 misleading to maintenance programmers, because the assignment
 does not modify the original object, only changing which
 object that the rest of the code in the method refers to, and
 can end with undefined behavior
  
 Regards - 
  
 Patty
 
 
 On Mon, 2011-01-31 at 13:20 -0800, Patty wrote: 
  
  - Original Message - 
  From: Jean-Michel Pichavant jeanmic...@sequans.com
  To: pa...@cruzio.com
  Cc: python-list@python.org
  Sent: Monday, January 31, 2011 11:35 AM
  Subject: Re: multiple values for keyword argument
  
  
   pa...@cruzio.com wrote:
 I have been avoiding understanding this 'self',
   [snip]
   Regards,
  
   Patty
 
   What is to be understood ?? self references the instance. Did I 
 miss 
   something ?
   
   JM
   
   
  
  
  Yes, there was more.  And it's been fully explained at this point.
  
  Patty
 
 
 
 
 
 __
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list


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


Running python scripts from the command line.

2011-01-31 Thread Nanderson
I've recently started to program. Python is my first language, so I'm
a complete beginner. I've been trying to call python scripts from the
command line by entering this command into it:

python test.py

But it gives me this error message:

python test.py
  File stdin, line 1
python test.py
   ^
SyntaxError: invalid syntax

I know that test.py exists, and the script is correct (here is is
anyways):

a = 1
if a:
print 'Value of a is', a

I am using python 2.7.1 installed on Windows 7. This seems like
something that should be easy, so I'm sure I'm just missing a very
small problem. Any help is greatly appreciated.

Thanks,
Anderson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running python scripts from the command line.

2011-01-31 Thread Benjamin Kaplan
On Mon, Jan 31, 2011 at 9:43 PM, Nanderson
mandersonrandersonander...@gmail.com wrote:
 I've recently started to program. Python is my first language, so I'm
 a complete beginner. I've been trying to call python scripts from the
 command line by entering this command into it:

python test.py

 But it gives me this error message:

python test.py
  File stdin, line 1
    python test.py
                   ^
 SyntaxError: invalid syntax

 I know that test.py exists, and the script is correct (here is is
 anyways):

 a = 1
 if a:
    print 'Value of a is', a

 I am using python 2.7.1 installed on Windows 7. This seems like
 something that should be easy, so I'm sure I'm just missing a very
 small problem. Any help is greatly appreciated.

 Thanks,
 Anderson

You're already in Python when you type that. If you want to run a
script, you need to call Python from your normal shell, not from
inside the Python interpreter.

$ python
Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15)
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type help, copyright, credits or license for more information.
 python
Traceback (most recent call last):
  File stdin, line 1, in module
NameError: name 'python' is not defined
 exit()
$  python test.py
Value of a is 1


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

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


Re: Running python scripts from the command line.

2011-01-31 Thread Nanderson
On Jan 31, 6:54 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote:
 On Mon, Jan 31, 2011 at 9:43 PM, Nanderson









 mandersonrandersonander...@gmail.com wrote:
  I've recently started to program. Python is my first language, so I'm
  a complete beginner. I've been trying to call python scripts from the
  command line by entering this command into it:

 python test.py

  But it gives me this error message:

 python test.py
   File stdin, line 1
     python test.py
                    ^
  SyntaxError: invalid syntax

  I know that test.py exists, and the script is correct (here is is
  anyways):

  a = 1
  if a:
     print 'Value of a is', a

  I am using python 2.7.1 installed on Windows 7. This seems like
  something that should be easy, so I'm sure I'm just missing a very
  small problem. Any help is greatly appreciated.

  Thanks,
  Anderson

 You're already in Python when you type that. If you want to run a
 script, you need to call Python from your normal shell, not from
 inside the Python interpreter.

 $ python
 Python 2.6.6 (r266:84292, Jan 10 2011, 20:14:15)
 [GCC 4.2.1 (Apple Inc. build 5659)] on darwin
 Type help, copyright, credits or license for more information. 
 python

 Traceback (most recent call last):
   File stdin, line 1, in module
 NameError: name 'python' is not defined exit()

 $  python test.py
 Value of a is 1







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

Wow, thank you very much for your help. This worked absolutely great.
I feel like a huge n00b after that though; it was just so obvious!
Anyways, like I said before, thank you very much for your help.

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Giampaolo Rodolà
2011/1/31 rantingrick rantingr...@gmail.com:
 In an ideal world it should be the first place you look when wanting
 to learn how to build medium sized GUI projects with the built-in
 Tkinter module.

I wouldn't do that, and thankfully in the *real* world what is
considered more important usually gets more attention.
If instead of ranting nonsense all day long you would spend a little
bit of your time by taking a look at how crowded the python bug
tracker already is, you would discover an interesting thing which goes
under the name of priority.
High priority bugs get fixed first. IDLE source code is clearly not a
high priority issue, hence it doesn't get fixed: end of story.
Actually I don't even understand how can IDLE source code quality have
anything to do with python success or future adoption, as you implied
in your statements.
And why do you care so much anyway? You have spent the past 5 days
blabbing about how bad Tkinter is, how ugly and useless it is
nowadays, and now you suddenly care about IDLE source code quality?
Do you have any idea how ridiculous this looks from the outside?

 However the reality is ANYTHING but ideal. The code is
 rotten to the core, full of inconsistencies and just very unpythonic.

99% of the times the right answer to this statement is go file a bug
and possibly provide a patch but not in your case since it's clear
that you have absolutely no interest in resolving *anything*, let
alone actually write some code, assuming you're able to do so in the
first place.

 Personally I've never looked into idlelib directory for 7 years in a row at 
 all.
 I was probably doing some other things, I don't know, but now I'm
 definitively gonna start looking for a new language because it's clear
 that any language having a directory called idlelib within such a
 horrible source code is not gonna last for long.

 Well not unless we do something about it. It is high time to stop
 patching, bolting on, and future extending the suffering of this
 horrendous code base. It is time to pull the plug, let it die, and
 start fresh. Start from a real python perspective. We can learn from
 past mistakes and build something much better. But will we? Do we have
 the community spirit to take on this challenge? Do we as a community
 have any fire left or have we collectively waxed cold?

How can you possibly not understand that I was being sarcastic?


--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to read the last line of a huge file???

2011-01-31 Thread Alan Meyer

On 01/26/2011 04:22 PM, MRAB wrote:

On 26/01/2011 10:59, Xavier Heruacles wrote:

I have do some log processing which is usually huge. The length of each
line is variable. How can I get the last line?? Don't tell me to use
readlines or something like linecache...


Seek to somewhere near the end and then read use readlines(). If you
get fewer than 2 lines then you can't be sure that you have the entire
last line, so seek a little farther from the end and try again.


I think this has got to be the most efficient solution.

You might get the source code for the open source UNIX utility tail 
and see how they do it.  It seems to work with equal speed no matter how 
large the file is and I suspect it uses MRAB's solution, but because 
it's written in C, it probably examines each character directly rather 
than calling a library routine like readlines.


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


Re: Looking for Remote Python Project

2011-01-31 Thread Alan Meyer

On 01/29/2011 04:19 PM, joy99 wrote:

Dear Room,

I am a Python Programmer from India(New Delhi Region), and I worked
for quite a long time in Bangalore. I have been working in Python for
the last 4 years or so. I have successfully built around 15 projects
in Python. I am looking for some remote Python Projects, which can be
done from home.

If any one knows of anything, I may be helpful enough.

Best Regards,
Subhabrata.


Subharata,

Would you be willing to tell us what a programmer with your level of 
experience typically charges per hour for his services?


I'm not in a position to hire anyone, I'm just a programmer myself.  But 
I'm curious about rates in India vs. the U.S., where I live and work.


Thanks and good luck with your efforts to get work.

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


Converting getCSS Count Code from java to python

2011-01-31 Thread SMERSH009
Hi, I'd love some help converting this code to the python equivalent:

private int getCSSCount(String aCSSLocator){
String jsScript = var cssMatches = eval_css(\%s\,
window.document);cssMatches.length;;
return Integer.parseInt(selenium.getEval(String.format(jsScript,
aCSSLocator)));
}

http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/

Thanks for the help
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to read the last line of a huge file???

2011-01-31 Thread Kushal Kumaran
On Tue, Feb 1, 2011 at 9:12 AM, Alan Meyer amey...@yahoo.com wrote:
 On 01/26/2011 04:22 PM, MRAB wrote:

 On 26/01/2011 10:59, Xavier Heruacles wrote:

 I have do some log processing which is usually huge. The length of each
 line is variable. How can I get the last line?? Don't tell me to use
 readlines or something like linecache...

 Seek to somewhere near the end and then read use readlines(). If you
 get fewer than 2 lines then you can't be sure that you have the entire
 last line, so seek a little farther from the end and try again.

 I think this has got to be the most efficient solution.

 You might get the source code for the open source UNIX utility tail and
 see how they do it.  It seems to work with equal speed no matter how large
 the file is and I suspect it uses MRAB's solution, but because it's written
 in C, it probably examines each character directly rather than calling a
 library routine like readlines.


How about mmapping the file and using rfind?

def mapper(filename):
with open(filename) as f:
mapping = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ)
endIdx = mapping.rfind('\n')
startIdx = mapping.rfind('\n', 0, endIdx)
return mapping[startIdx + 1:endIdx]

def seeker(filename):
offset = -10
with open(filename, 'rb') as f:
while True:
f.seek(offset, os.SEEK_END)
lines = f.readlines()
if len(lines) = 2:
return lines[-1][:-1]
offset *= 2

In [1]: import timeit

In [2]: timeit.timeit('finders.seeker(the-file)', 'import finders')
Out[2]: 32.216405868530273

In [3]: timeit.timeit('finders.mapper(the-file)', 'import finders')
Out[3]: 16.805877208709717

the-file is a 120M file with ~500k lines.  Both functions assume the
last line has a trailing newline.  It's easy to correct if that's not
the case.  I think mmap works similarly on Windows, but I've never
tried there.

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rantingrick
On Jan 31, 4:17 pm, Kevin Walzer k...@codebykevin.com wrote:
 Rick,

 I've spent a fair amount of time in the IDLE source tree, putting
 together patches for various Mac-specific bugs and submitting them to
 the Python tracker, and I agree the code is crufty and disorganized. It
 is certainly not an example of current best practices in Tkinter
 development. The code base has accrued over the years, has been touched
 by many, many different hands, and I think its current messy state
 reflects that legacy.

Thanks for admitting this. Some people refuse to see the truth!

 But, as I understand it, the purpose of IDLE is not to provide a
 pedagogical example of Tkinter programming practices, but instead to
 provide a lightweight development environment for those learning Python,
 to interactively explore different aspects of Python. For this it serves
 its purpose well. I use IDLE a good deal for my Python development work,
 and the cruftiness of the code under the hood is not an impediment to me
 getting my work done (unless the work is patching IDLE itself).

Yes. IDLE is first and foremost a tool to get work done. However we
should not ignore the fact that IDLE could also be a great learning
resource for Tkinter GUI's and other subjects. Why not clean up the
code base? We could start small. First, move the custom widgets like
textView, Tabbedpages, FindDialog, ReplaceDialog, and TreeWidget into
the lib-tk for others to use more freely. Then we can modify the
event robbers CallTips, ParenMatch, and ColorDelegator. Just small
steps Kevin. It all starts with babysteps. At least we would be doing
something. Currently we are sitting around waiting for a miracle to
happen, and problems are solved by methods, not miracles!


 Given this, I don't see any huge need to bulldoze IDLE to the ground and
 replace it with something else, or even do massive rewrites of the code,
 unless such a project also significantly improved the user-facing
 portions of IDLE as well.

Well some changes and improvements can be made to the UI as well.

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


Re: how to modify axis tick values exponential value location in matplotlib

2011-01-31 Thread Rajendra prasad Gottipati
not able to change the location of exponent/offset label in the axis, in
case of multiple y axis exponent/offset label of one axis is overwriting
other axis value, how to control the location of this lable(like 1e8).Can
anybody help me solving this issue.


On Sun, Jan 30, 2011 at 9:55 AM, Rajendra prasad Gottipati 
rajendra4li...@gmail.com wrote:

 it seems relevant to my issue.


 http://stackoverflow.com/questions/3677368/matplotlib-format-axis-offset-values-to-whole-numbers-or-specific-number


 On Sun, Jan 30, 2011 at 9:45 AM, Rajendra prasad Gottipati 
 rajendra4li...@gmail.com wrote:

 Hi,

 I am plotting the graph for long values like(267838484) so that its
 printing the tick lables on axes as 2.6 , 2.8 and at the top its having a
 text like e07 something like this, I want to move the display location of
 this exponent (e07) as i am having trouble in having multiple y-axis as they
 are getting mixed in text. like (e07 is written on top of e08 of other axis)

 Can any one help me in getting this done? also i am having issue in
 getting tick lables of x-axis while plotting with pylab.plot_date.


 Regards
 Raja



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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rantingrick
On Jan 31, 4:38 pm, Robert sigz...@gmail.com wrote:

 I think it would be interesting as well. H, I am about to do the
 O'Reilly series that Steve Holden did for Python.

Did you see the video Steve Holden did with Trish Gray? Just for fun
fast forward to 0:03:30. Just as Trish comments about Python diversity
Steve gets all shook up... man you could cut the tension with a
knife!!!

http://www.oreillyschool.com/courses/python1/

Oh, and Trish, if you are out there and you would like a personal
introduction to Python programming i would be very happy to give you
some very, very, private lessons using my python...
.
.
.
.
.
interpretor. *wink*

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rantingrick
On Jan 31, 9:24 pm, Giampaolo Rodolà g.rod...@gmail.com wrote:

 Actually I don't even understand how can IDLE source code quality have
 anything to do with python success or future adoption, as you implied
 in your statements.

Well thats because you are not looking at this from the correct
perspective. Every piece of code, every module, every documentation,
every community grudge reflects on us in positive and negative ways.
And the IDLE library is reflecting pretty badly on us. The IDLE
library is making us look like a bunch of two bit script kiddies who
cannot even follow our own philosophies.

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread Stephen Hansen
On 1/31/11 9:26 PM, rantingrick wrote:
 Oh, and Trish, if you are out there and you would like a personal
 introduction to Python programming i would be very happy to give you
 some very, very, private lessons using my python...
 .
 .
 .
 .
 .
 interpretor. *wink*
 
 ;-)

You are disgusting.

If Trish Gray were here, I'd offer a sincere apology on behalf of the
community for you.

Which is ironic, considering how one of my major complaints about you is
your audacity to claim to speak for We, The Community. But I have to
hope we're better then this.

Disgusting.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rusi
On Feb 1, 1:35 am, Raymond Hettinger pyt...@rcn.com wrote:
 However, even the parts of the standard library written in pure Python
 don't seem to be getting read anymore, so I'm still inclined to
 attribute the issue to 1) inconvenient placement of source code,
 2) a largish code base, and 3) possibly a cultural shift.


There is another thread running where this was said (by a python
developer?)

 Actually I don't even understand how can IDLE source code quality have
 anything to do with python success or future adoption, as you implied
 in your statements.
 High priority bugs get fixed first. IDLE source code is clearly not a
 high priority issue, hence it doesn't get fixed: end of story.

Now if we can put aside for a moment the fact that the person to whom
this was said specializes in the art of raising others' blood
pressures and making them say what they may not otherwise have said,
it should be clear that this priority is at cross purposes with
Raymond's.

In short (at the risk of belonging to the equivalence class of others
whose names start with R) I would suggest a 4th point: Code cruft

Please note: I am thankful to all python devs for giving me python.
Its just that when functionality becomes as large as it is for python
and the target is fast moving, keeping code spic and span will
generally be perceived to be a priority that has crossed the point of
diminishing returns.  Consequence: noobs have a higher barrier to
entry than earlier
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-01-31 Thread rusi
On Feb 1, 11:14 am, rusi rustompm...@gmail.com wrote:
 On Feb 1, 1:35 am, Raymond Hettinger pyt...@rcn.com wrote:

snipped

O O wrong thread... sorry!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use the Source Luke

2011-01-31 Thread rusi
The following, meant for this thread, went to another my mistake :-)
--

On Feb 1, 1:35 am, Raymond Hettinger pyt...@rcn.com wrote:
 However, even the parts of the standard library written in pure Python
 don't seem to be getting read anymore, so I'm still inclined to
 attribute the issue to 1) inconvenient placement of source code,
 2) a largish code base, and 3) possibly a cultural shift.


There is another thread running where this was said (by a python
developer?)

 Actually I don't even understand how can IDLE source code quality have
 anything to do with python success or future adoption, as you implied
 in your statements.
 High priority bugs get fixed first. IDLE source code is clearly not a
 high priority issue, hence it doesn't get fixed: end of story.

Now if we can put aside for a moment the fact that the person to whom
this was said specializes in the art of raising others' blood
pressures and making them say what they may not otherwise have said,
it should be clear that this priority is at cross purposes with
Raymond's.

In short (at the risk of belonging to the equivalence class of others
whose names start with R) I would suggest a 4th point: Code cruft

Please note: I am thankful to all python devs for giving me python.
Its just that when functionality becomes as large as it is for python
and the target is fast moving, keeping code spic and span will
generally be perceived to be a priority that has crossed the point of
diminishing returns.  Consequence: noobs will have a higher barrier to
entry than earlier
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use the Source Luke

2011-01-31 Thread rantingrick
On Feb 1, 12:25 am, rusi rustompm...@gmail.com wrote:

 In short (at the risk of belonging to the equivalence class of others
 whose names start with R) I would suggest a 4th point: Code cruft

Oh rusi, just come out of the closet already we accept you! :-)

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


Re: Use the Source Luke

2011-01-31 Thread Stephen Hansen
On 1/31/11 10:38 PM, rantingrick wrote:
 On Feb 1, 12:25 am, rusi rustompm...@gmail.com wrote:
 In short (at the risk of belonging to the equivalence class of others
 whose names start with R) I would suggest a 4th point: Code cruft
 Oh rusi, just come out of the closet already we accept you! :-)

First tonight, you find sexism funny; now you find bigotry funny.

Disgusting.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue11073] threading.Thread documentation can be improved

2011-01-31 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I still don't understand.  I haven't used threading much, but I don't believe 
I've ever used a static method with it.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11073
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11076] Iterable argparse Namespace

2011-01-31 Thread Virgil Dupras

New submission from Virgil Dupras hs...@hardcoded.net:

Currently, there is no (documented) way to easily extract arguments in an 
argparse Namespace as a dictionary. This way, it would me easy to interface a 
function taking a lot of kwargs like this:

 args = parser.parse_args()
 my_function(**dict(args))

There's _get_kwargs() but it's a private undocumented method. I guess that 
making it public would be problematic because of the namespace pollution that 
would occur. That's why I'm proposing to make it iterable.

If it isn't rejected, I'd gladly work on the required patch.

--
components: Library (Lib)
keywords: easy
messages: 127582
nosy: vdupras
priority: normal
severity: normal
status: open
title: Iterable argparse Namespace
type: feature request
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11076
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11073] threading.Thread documentation can be improved

2011-01-31 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Roy, it's not clear what you're after.  What is it that you think is special 
about the way the target is called?

--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11073
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11061] Verify command option before parsing config file

2011-01-31 Thread Sebastien Douche

Sebastien Douche sdou...@gmail.com added the comment:

Oups sorry Eric. I created the report very quickly after a discussion with 
Tarek. If you type a wrong command like python -m distutils2:run wrong, 
disutils2 still parses the setup.cfg. How resolve this? Don't know, maybe a 
migration to optparse.

Anyway, close the bug if you think it's irrevelant.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11061
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11075] Turtle crash with IDLE on Mac OS X 10.6

2011-01-31 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

Since IDLE and the turtle modules both use Tkinter and thus are both Tcl/Tk 
applications, it wouldn't be surprising if you had problems trying to run a 
program using the IDLE module from within IDLE.  However, I find I can 
successfully run at least one of the supplied Turtle demos from IDLE 2.7.1 and 
IDLE 2.6:

  cd /Applications/Python 2.7/Extras/Demo/turtle
  idle2.7 tdemo_paint.py # or idle2.6

and with either of the two IDLE variants (32-bit - Tk 8.4, 64-/32-bit - Tk 
8.5).  Can you supply a simple script to demonstrate the problem you see?

Keep in mind that, at the moment, neither of the standard python.org 2.7.1 
installers support using ActiveState Tk 8.5.9.  The 32-bit-only installer will 
use ActiveState Tk 8.4, if installed, otherwise use the Apple-supplied Tk 
8.4.19(?) in 10.6.  Python 2.7.1 was released before a 64-bit capable version 
of ActiveState Tk 8.5 was available so, as released, it will only link to the 
Apple-supplied Cocoa Tk 8.5.7 in 10.6 and that version has proven to be very 
unreliable when used with IDLE.  You should be able to build from source a 
Python 2.7.1 that will link to ActiveState 8.5.9 if it is present during the 
build but beware that there are a number of issues both major and minor that 
have been recently fixed in Python (and are in the current release-2.7 
maintenance branch that should appear as a 2.7.2 release in the future) as well 
as a few issues in Cocoa Tk itself which should be fixed in an upcoming release 
of ActiveState Tk 8.5.

--
assignee: ronaldoussoren - ned.deily
nosy: +ned.deily

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11075
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11075] Turtle crash with IDLE on Mac OS X 10.6

2011-01-31 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

er, trying to run a program using the turtle module from within IDLE

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11075
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Do yourself a favor and don't become a PEP 8 nut ;-)

The primary purpose of the example in whatsnew is to teach, demonstrate, and 
explain.  Any PEP 8 considerations take a back seat to that purpose (even PEP 8 
itself admonishes the reader with the famous foolish consistency quotation).

The purpose behind the usual space conventions for keyword arguments is to 
allow them to be visually grouped when more than one is used on a line.  In the 
case of the argparse example, the important parameters are being listed one per 
line along with an explanatory comment.  In my judgement, the example is more 
readable with the spacing as it allows the eye to easily pick-out the argument 
list.  

Am sorry, but it is not really open for debate.  Whatsnew is a single-author 
document reflecting an enormous amount of my time culling changes, crafting 
expository text, and creating strong examples.  As such, it is going to very 
much reflect my style and judgement.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11076] Iterable argparse Namespace

2011-01-31 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

+1 for making the object readily convertible to a dictionary.  That would also 
serve to make it more introspectable without losing the simplicity of the 
current design.

--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11076
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10891] Tweak sorting howto to eliminate redundancy

2011-01-31 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

You can put in the backslashes before the two periods, but not the other 
changes.  I want the method names to continue to be spelled-out in full so that 
it is more clear what they are referring to.  Even in spoken English, I 
typically say list sort or sort method of the builtin list type.  This 
helps distinguish it from the sorted() builtin.

--
assignee: rhettinger - eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10891
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

I agree with Raymond: whoever puts in 95% of work for a single document should 
have artistic license over the style.

I also don't complain if people use a different indentation style in module 
docs they write (but I reserve the right to use mine if I edit these docs).

It is very nice having standards, but well, I hope you know about the hobgoblin 
:)

And particularly about keyword arg spacing, I found that it very much depends 
on the manner of arguments you're dealing with.  For dict()-style functions 
with lots of kwargs, it can really be much easier on the eyes to use space 
around the '=', or even use this style:

foo = dict(
some_key= some_value,
some_longer_key = some_other_value,
)

even if PEP 8 doesn't approve of that either.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3080] Full unicode import system

2011-01-31 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

As explained in issue #10828: Python 3.2 doesn't support non-ASCII module names 
on Windows because module names are encoded to UTF-8 instead of the filesystem 
encoding (the ANSI code page).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3080
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11016] Add S_ISDOOR to the stat module

2011-01-31 Thread Jesús Cea Avión

Jesús Cea Avión j...@jcea.es added the comment:

Martin, I guess stat deprecation could require a few years and it would be an 
extra incompatibility burden between 2.7 and 3.x.

Beside the symbolic constants, why would you see stat deprecated?.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11016
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8973] Inconsistent docstrings in struct module

2011-01-31 Thread SilentGhost

SilentGhost ghost@gmail.com added the comment:

r81947 introduced this issue:

 from struct import *
 pack_into
Traceback (most recent call last):
  File pyshell#1, line 1, in module
pack_into
NameError: name 'pack_into' is not defined

struct.__all__ has a duplicate entry and misses pack_into.

Patch is attached, test passes. Seems quite innocent to me, could it make into 
3.2, George?

--
nosy: +SilentGhost, georg.brandl
status: closed - open
Added file: http://bugs.python.org/file20625/struct.py.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8973
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Python’s import mechanism can now load modules installed in directories with 
non-ASCII characters in the path name: import møøse.bites

møøse is not a module *path*, but a module *name*... This example doesn't work 
on Windows: see #3080. Module paths is the sys.path list. An use case is Python 
installed in the user directory with diacritics in the user name (eg. Python 
installed in C:\Users\Amélie\...).

The biggest news for Python 3.2 is that the email package and nntplib modules 
now work correctly with the bytes/text model in Python 3.

You can also include mailbox in this list.

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Should we add imports in all examples? Eg. add import math in:

 repr(math.pi)
'3.141592653589793'
 str(math.pi)
'3.141592653589793'

At least, accumulate should be replaced by itertools.accumulate in the 
following example:

 list(accumulate(8, 2, 50))
[8, 10, 60]

Because it looks like accumulate() is a builtin function.

Some other examples without the module name: tally = Counter(dogs=5, cat=3), 
d = OrderedDict..., d = deque('simsalabim'), all_polls_closed = 
Barrier(len(sites)), ...

I prefer to have the module name in examples because it is easy to test them: 
just copy/paste in an interpreter. It's even more easier if there is the import 
statement :-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

The import in the following example is wrong :

 import datetime
 datetime.now(timezone.utc)
...

It should be replaced by: from datetime import datetime, timezone.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11073] threading.Thread documentation can be improved

2011-01-31 Thread Roy Smith

Roy Smith r...@panix.com added the comment:

Here's the code I ended up writing:

class Foo():
   def __init__(self):
   self.thread = Thread(target=Foo.runner, args=[self])
   self.thread.start()

   @staticmethod
   def runner(self):
  # blah, blah, blah

It was not immediately clear from the documentation if my runner() method 
should be declared static or not.  In retrospect, it must be (since this can be 
used with target functions which are not class methods at all), but it took a 
bit of thought to get from what the documentation said (i.e. 'callable object 
to be invoked by the run() method') to that conclusion.  

It seems to me the documentation could be a bit more explicit that your target 
does not get called as a method of some object.  Changing the text to read, 
static function or other callable object would remove any such confusion.

It could be that some of my confusion is due to my previously working with a 
C++ threading package where the thread runner functions *were* class methods.  
Still, it seems like the potential for other people to be similarly confused 
exists and a little tweaking of the documentation text would help.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11073
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

Nick, thanks for highlighting the logging changes. In addition to what you 
mentioned, there's still more, at least some of which deserves to get into 
what's new :-)

1. QueueHandler and QueueListener classes were added to help with logging in 
multiprocessing applications.
2. Logger got a getChild(suffix) method which returns a child logger with the 
given suffix.
3. An optional stack_info parameter to logging calls provides complete stack 
information (not just the parts unwound during exception handling).
4. Logger got a hasHandlers() method which returns True if any handlers are 
available for the logger (including those in ancestor loggers).
5. The LoggerAdapter implementation was changed to improve its usability, 
during which its public API gained the isEnabledFor(),   getEffectiveLevel(), 
hasHandlers() and setLevel() methods.
6. HTTPHandler gained secure and credentials keyword arguments for use with SSL 
and sites needing authentication.
7. StreamHandler now has a terminator attribute (defaults to '\n' for backward 
compatibility) but can now be set on a per-handler basis.
8. SysLogHandler gained a socktype keyword argument which defaults to 
SOCK_DGRAM but can accept SOCK_STREAM for use with newer syslog daemons which 
can listen using TCP.
9. basicConfig() also takes an optional style argument (default '%', also 
accepts '{' or '$').
10. SMTPHandler takes optional secure kwarg for use with TLS.
11. SysLogHandler now treats Unicode as per RFC 5424.

Er ... that's it for now.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

ABCMeta should be replaced by abc.ABCMeta, or other abc. prefixes should be 
removed.

class Temperature(metaclass=ABCMeta):
@abc.abstractclassmethod
def from_fahrenheit(self, t):
...
@abc.abstractclassmethod
def from_celsius(self, t):
...

I don't know/understand the - syntax:

 print(byte_stream.getvalue())
b'G3805  showroom   Main chassis' -
b'X7899  warehouse  Reserve cog ' -
b'L6988  receiving  Primary sprocket'

If you would like to split record by record, use something like:

 x=byte_stream.getvalue()
 [x[index:index+REC_LEN] for index in range(0,len(x),REC_LEN)]
[b'G3805  showroom   Main chassis', b'X7899  warehouse  Reserve cog ', 
b'L6988  receiving  Primary sprocket']

--

$ ./python 
Python 3.2rc2+ (py3k:88277, Jan 31 2011, 14:24:09) 
 from ast import literalrequest
ImportError: cannot import name literalrequest

--

 import shutil, pprint
...
 f = make_archive(...)

It's shutil.make_archive(), not make_archive() here.

 shutil.register_archive_format(  # register a new archive 
 format
name = 'xz',
function = 'xz.compress',
extra_args = [('level', 8)],
description = 'xz compression'
)

The function have to be callable: a str is not callable.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11073] threading.Thread documentation can be improved

2011-01-31 Thread Brian Curtin

Brian Curtin cur...@acm.org added the comment:

 It was not immediately clear from the documentation if my runner() method 
 should be declared static or not.

The doc doesn't mention static methods at all, and my uses and others that I've 
seen have never used static methods.

--
nosy: +brian.curtin

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11073
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11073] threading.Thread documentation can be improved

2011-01-31 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

You don't have to use any staticmethod here (actually, staticmethod is an 
anti-pattern in Python). Just write:

class Foo():
   def __init__(self):
   self.thread = Thread(target=self.runner)
   self.thread.start()

   def runner(self):
  # blah, blah, blah

--
nosy: +pitrou
resolution:  - works for me
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11073
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Thanks Victor.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11071] What's New review comments

2011-01-31 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

Please consider mentioning that several modules can now be called with -m: 
pickle, pickletools and tkinter.

--
nosy: +belopolsky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11071
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11077] Tkinter is not thread safe. This is a bug.

2011-01-31 Thread Scott M

New submission from Scott M scott.m...@comcast.net:

The more I look at GUI support in Python, the more I realize that the lack of 
basic thread safety in GUI support is simply a bug. I know Java's Swing has the 
same thread limitation, but that doesn't make it right. Xlib is thread safe. 
The Windows SDK is thread safe. Python is supposed to be the language that's 
easy to use, and there is nothing easy about teaching new programmers that they 
have to mess with queues and timers just to get a basic set of displays 
running, just because when threads are in use.

I'm in the position of teaching folk with little-to-no programming experience, 
how to script simple applications in Python. The modules they have to use are 
inherently threaded, and delivery hunks of data from multiple sources to them. 
The most natural instinct is to put up some graphs and other widgits to display 
the data, and all of it is completely trivial right up until I have to explain 
that drawing a line isn't canvas.line(from, to), but becomes an exercise in 
Queue.Queue and theRoot.after(n, myself), before you even get to learn about 
widgits. Threading is supposed to simplify problems, not add to them. Having to 
hack around with special timers and polling, just to get some simple graphs up, 
is plain unpythonic.

Please consider this a bug, a glaring misfeature, in a language that is 
otherwise a very reasonable choice to get technical but non-programmerish 
people into toolmaking self-sufficiency.

--
components: Tkinter
messages: 127604
nosy: PythonInTheGrass
priority: normal
severity: normal
status: open
title: Tkinter is not thread safe. This is a bug.
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11077
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   >