ANN: cssutils 0.9.6b3

2009-08-02 Thread Christof Hoeke

what is it
--
A Python package to parse and build CSS Cascading Style Sheets. (Not a 
renderer though!)


about this release
--
0.9.6b3 adds a few features and fixes quite a few bugs.

main changes

+ **FEATURE**: Added parsing support and new profile for details 
defined in module Fonts http://www.w3.org/TR/css3-fonts/


+ **FEATURE**: Added ``cssutils.parseStyle(cssText, 
encoding='utf-8')`` convienience function


+ **FEATURE** (experimental, request from issue #27): Added 
``css.CSSStyleDeclaration.children()`` which is a generator yielding any 
known children of a declaration including *all* properties, comments or 
CSSUnknownRules.


+ FEATURE: ``CSSStyleDeclaration.insertRule`` also accepts a 
``CSSRuleList`` now (same as ``CSSStyleSheet`` which does this for some 
time now).


+ FEATURE: Added ``CSSStyleDeclaration.keys()`` method which 
analoguous to standard dict returns property names which are set in the 
declaration.


- **API CHANGE**: Replaced attribute ``css.Property.parentStyle`` 
with ``css.Property.parent`` (``parentStyle`` is DEPRECATED now).


+ **BUGFIX**: Improved child and parent node referencing.

+ **BUGFIX**: Parsing of CSSValues with unknown function names with 
a specific length of 4 or 7 chars were resulting in a SyntaxErr. Also 
parsing of comma separated list of CSS FUNCTION values works now.


+ BUGFIX: Fixed validation problems:
- ``font-family: a   b`` (values with spaces in names without 
being quoted) are parsed now without emitting an ERROR. These are indeed 
valid but discouraged and you should use quotes (more than one space is 
compacted to a single space anyway so rather complicated without quotes)
- negative lengths for the ``font-size`` property are now 
properly reported as ERRORs


- IMPROVEMENT (minor): cssutils sets the HTTP header ``User-Agent`` 
now when fetching sheets over HTTP (with e.g. ``cssutils.parseUrl``).


- *FEATURE* (experimental): Added support to at least parse sheets 
with Microsoft only property values for ``filter`` which start with 
``progid:DXImageTransform.Microsoft.[...](``. To enable these you need 
to set::


 from cssutils import settings
 settings.set('DXImageTransform.Microsoft', True)
 cssutils.ser.prefs.useMinified()
 text = 'a {filter: 
progid:DXImageTransform.Microsoft.BasicImage( rotation = 90 )}'

 print cssutils.parseString(text).cssText

a{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=90)}


  This currently is a **major hack** but if you like to minimize 
sheets in the wild which use this kind of CSS cssutils at least can 
parse and reserialize them.


license
---
cssutils is published under the LGPL version 3 or later, see 
http://cthedot.de/cssutils/


If you have other licensing needs please let me know.

download

For download options see http://cthedot.de/cssutils/

cssutils needs Python 2.4 or higher (tested with Python 2.6.2, 2.5.2, 
2.4.4 and Jython 2.5 on Vista only)



Bug reports (via Google code), comments, etc are very much appreciated! 
Thanks.


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

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


ANN: Pyspread 0.0.12

2009-08-02 Thread Martin Manns


Pyspread 0.0.12 released


I am pleased to announce the new release 0.0.12 of pyspread.

 
About: 
--
 
Pyspread is a cross-platform Python spreadsheet application. It is
based on and written in the programming language Python.

Instead of spreadsheet formulas, Python expressions are entered into
the spreadsheet cells. Each expression returns a Python object that can
be accessed from other cells. These objects can represent anything
including lists or matrices.

Pyspread runs on Linux, Windows and *nix platforms with GTK support. I
have reports that it works with MacOS X as well.

Homepage:
-

http://pyspread.sf.net


New features in 0.0.12:
---

* ODF file support
* Detachable tool bars
* Cells now support attributes such as fonts, borders, colors
* Cells can now be painted on from inside a macro function
* Major speed-up and memory reduction
* Dependency to networkx removed
* Frozen cells that are not updated introduced
* Style toolbar added
* Find toolbar added
* Regular expression search added
* Zoom functionality added
* Default text color changed to system default (for black themes)
* Ok and Cancel buttons swapped in New sheet dialog


Bugfixes:
-

* Strange arange reference behaviour fixed (BUG 2760121)
* stt = sum(S[16:18,Y,0]) raises TypeError fixed (BUG 2579698)
* On Windows, some dialogs have to be closed twice. (fixed)
* Recursion detection dows not work on nested structures, i.e. when
  S[2,2,2] is referred to from inside a container object, pyspread will
  not realize a cycle. Therefore, a Maximum recursion depth error is
  reported (fixed)


Known issues:
-

* ODF documents with many columns and rows can freeze pyspread on
  loading (use the old pys format instead)
* Horizontal cell alignment missing
* Some fonts throw an error message when scrolling (but work
  nonetheless)
* Fonts are not included in ODF files
* Cell attributes are not copied or deleted with cell content


Martin

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

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


cgi script

2009-08-02 Thread golu
Hi,
i started learning cgi few days ago in python and everything went
fine  until i started getting the follwing error

The server encountered an internal error and was unable to complete
your request. Either the server is overloaded or there was an error in
a CGI script.

If you think this is a server error, please contact the webmaster. 
  i am using apache on xampp. plz help
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python processors? : WAS Re: Does python have the capability for driver development ?

2009-08-02 Thread Steven D'Aprano
On Sun, 02 Aug 2009 14:19:45 +1200, greg wrote:

 That's what killed things like the Lisp machine. Their developers
 couldn't keep up with the huge resources that people like Intel and
 Motorola had to throw at CPU development, so eventually a
 general-purpose CPU could run Lisp faster than a Lisp machine.

When you say eventually, I think you mean decades ago. I recall a 
collaboration between Apple and Texas Instruments to build a Macintosh 
with a Lisp Machine in the late 1980s. From the one box, you could run 
two computers simultaneously, with two operating systems, one running the 
Motorola 68020 and the other a Lisp Machine processor.

I don't think it sold very well -- by memory, benchmarks showed that for 
half (or less) of the price, you could run Lisp in software on a vanilla 
Mac and the software would be faster than running it on the Lisp Machine.

TI also had at least one Nubus card for the Mac running a Lisp Machine:
http://en.wikipedia.org/wiki/TI_Explorer

On a similar note, there were Forth machines also available for the Apple 
Macintosh. Unlike Lisp, I think they suffered from the general lack of 
popularity of Forth rather than lack of speed.



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


Re: Get Cliet IP Address

2009-08-02 Thread eliasf

Fred Atkinson wrote:

What is the function to obtain the client browser's IP
address?


Do you mean the external public IP to the Internet? When I wanted to log the 
dynamic IP that my ADSL connection gets, I used whatismyip.com like this:


   import urllib2

   QUERY_URL = 'http://www.whatismyip.com/automation/n09230945.asp'

   def query():
   Get IP as a string.

   As per the whatismyip.com automation rules, this function should not
   be called more ofter than every 5 minutes.
   
   return urllib2.urlopen(QUERY_URL).read()

There's probably a better way, but I'm not very good with networking.  :o) 


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


Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Michael M Mason


Dave Angel da...@ieee.org wrote in message 
news:mailman.4120.1249172970.8015.python-l...@python.org...

Michael M Mason wrote:
div class=moz-text-flowed style=font-family: -moz-fixedI'm running 
Python 3.1 on Vista and I can't figure out how to add my own directory to 
sys.path.


Thanks to Jon, Piet, David and Dave for the responses.


sys.path gets its values from several places.


Ah, I'd misunderstood the docs: I thought it came from just one place (which 
I couldn't find).


Anyway, I'd suggest adding it to PythonPath, and if it's empty, just 
create it with the directory you need.


Thanks--that worked!

I'm hoping you know you can also add to sys.path directly during script 
initialization.  It's just a list, and is writeable.


Yes, but I'm mainly playing in IDLE and I was getting a bit fed up of 
repeatedly typing

 import sys
 sys.path.append('C:/Users/Michael/Code/Python')
 import mystuff

--
Michael


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


Re: cgi script

2009-08-02 Thread Carl Banks
On Aug 1, 11:11 pm, golu bhardwajjaye...@gmail.com wrote:
 Hi,
 i started learning cgi few days ago in python and everything went
 fine  until i started getting the follwing error
 
 The server encountered an internal error and was unable to complete
 your request. Either the server is overloaded or there was an error in
 a CGI script.


Your script has a syntax error.  (You forgot a colon or something like
that.)

If you can, try to run the file directly from a Python interpreter to
see where the error is.


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


Re: Custom namespaces

2009-08-02 Thread Steven D'Aprano
On Sat, 01 Aug 2009 21:46:35 -0700, Chris Rebert wrote:

 Is there any way to install a custom type as a namespace?
 
 For classes/objects, yes, using metaclasses. See the __prepare__()
 method in PEP 3115: http://www.python.org/dev/peps/pep-3115/

Looks good, but that's Python 3 only, yes?

At least, I can't get the metaclass to change the __dict__ in Python 2.6. 
There's obviously no __prepare__ before 3.0, but I tried the following, 
and still __dict__ ends up as a regular dict. Am I missing something?


class VerboseDict(dict):
def __getitem__(self, item):
print (Looking up key '%s'... % item)
return super(VerboseDict, self).__getitem__(item)

class Meta(type):
def __new__(cls, name, bases, namespace):
namespace = VerboseDict(namespace)
obj = super(Meta, cls).__new__(cls, name, bases, namespace)
return obj

MyClass = Meta('MyClass', (object,), dict(x=1, y=2))





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


Re: Custom namespaces

2009-08-02 Thread Chris Rebert
On Sun, Aug 2, 2009 at 12:18 AM, Steven
D'Apranost...@remove-this-cybersource.com.au wrote:
 On Sat, 01 Aug 2009 21:46:35 -0700, Chris Rebert wrote:

 Is there any way to install a custom type as a namespace?

 For classes/objects, yes, using metaclasses. See the __prepare__()
 method in PEP 3115: http://www.python.org/dev/peps/pep-3115/

 Looks good, but that's Python 3 only, yes?

Correct.

 At least, I can't get the metaclass to change the __dict__ in Python 2.6.
 There's obviously no __prepare__ before 3.0, but I tried the following,
 and still __dict__ ends up as a regular dict. Am I missing something?


 class VerboseDict(dict):
    def __getitem__(self, item):
        print (Looking up key '%s'... % item)
        return super(VerboseDict, self).__getitem__(item)

 class Meta(type):
    def __new__(cls, name, bases, namespace):
        namespace = VerboseDict(namespace)
        obj = super(Meta, cls).__new__(cls, name, bases, namespace)
        return obj

I would /guess/ that type.__new__() is internally doing the equivalent
of dict(namespace). Hence why the addition of __prepare__() was
necessary; it's probably impossible to accomplish what you want in
earlier Python versions.

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


Generate a new object each time a name is imported

2009-08-02 Thread Steven D'Aprano
I would like to generate a new object each time I import a name from a 
module, rather than getting the same object each time. For example, 
currently I might do something like this:

# Module
count = 0
def factory():
# Generate a unique object each time this is called
global count
count += 1
return Object #%d % count


# Calling module
from Module import factory
a = factory()  # a == Object #1
b = factory()  # b == Object #2
del factory


I'm looking for a way to hide the generation of objects from the caller, 
so I could do something like this:

from Module import factory() as a  # a == Object #1
from Module import factory() as b  # b == Object #2

except of course that syntax is illegal.



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


Re: Generate a new object each time a name is imported

2009-08-02 Thread Jonathan Gardner
On Aug 2, 12:35 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:

 I'm looking for a way to hide the generation of objects from the caller,
 so I could do something like this:

 from Module import factory() as a  # a == Object #1
 from Module import factory() as b  # b == Object #2


Explicit is better than implicit. In other words, I don't see why you
need to hide this. Just import the factory function and call it.

from Module import factory
a = factory()
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Run pyc file without specifying python path ?

2009-08-02 Thread Barak, Ron


 -Original Message-
 From: Dave Angel [mailto:da...@dejaviewphoto.com]
 Sent: Thursday, July 30, 2009 20:08
 To: Barak, Ron
 Cc: 'python-list@python.org'
 Subject: Re: Run pyc file without specifying python path ?

 Barak, Ron wrote:
  Hi Dave,
 
  On second thoughts, I may have a problem implementing the
 wrapper solution, because my actual test_pyc.pyc, needs to
 parse its command line.
  Namely, the actual call to test_pyc.pyc looks something like this:
 
  $ python  test_pyc.py -U dave -PpasswoRD -C CreateMcGroupOnVolume
  --SVMs_IPs '10.1.1.1 , 10.1.1.2' -n host1,host2 -g gn -j
 jn -s svn
  -t tvn -p pool1 -l -c
 
  And I don't know of a way to add these parameters to the import
  test_pyc in wrapper
 
  Is there a way to pass information to an imported module ?
 (Sorry if there's an obvious answer, I just cannot figure it out).
 
  Bye,
  Ron.
 
 
  -Original Message-
  From: Dave Angel [mailto:da...@dejaviewphoto.com]
  Sent: Thursday, July 30, 2009 16:03
  To: Barak, Ron
  Cc: 'Dave Angel'; 'python-list@python.org'
  Subject: RE: Run pyc file without specifying python path ?
 
  Barak, Ron wrote:
 
  -Original Message-
  From: Dave Angel [mailto:da...@ieee.org]
  Sent: Wednesday, July 29, 2009 21:05
  To: Barak, Ron
  Cc: 'python-list@python.org'
  Subject: Re: Run pyc file without specifying python path ?
 
  Barak, Ron wrote:
 
 
  Hi,
 
  I wanted to make a python byte-code file executable,
 
 
  expecting to be able to run it without specifying
 python on the
  (Linux bash) command line.
 
 
  So, I wrote the following:
 
  [r...@vmlinux1 python]# cat test_pyc.py #!/usr/bin/env python
 
  print hello
  [r...@vmlinux1 python]#
 
  and made its pyc file executable:
 
  [r...@vmlinux1 python]# ls -ls test_pyc.pyc
  4 -rwxr-xr-x  1 root root 106 Jul 29 14:22 test_pyc.pyc
  [r...@vmlinux1 python]#
 
  So, I see:
 
  [r...@vmlinux1 python]# file test_pyc.py*
  test_pyc.py:  a python script text executable
  test_pyc.pyc: python 2.3 byte-compiled
  [r...@vmlinux1 python]#
 
  If I try to do the following, no problem:
 
  [r...@vmlinux1 python]# python test_pyc.pyc hello
  [r...@vmlinux1 python]#
 
  However, the following fails:
 
  [r...@vmlinux1 python]# ./test_pyc.pyc
  -bash: ./test_pyc.pyc: cannot execute binary file
  [r...@vmlinux1 python]#
 
  Is there a way to run a pyc file without specifying the
 
 
  python path ?
 
 
  Bye,
  Ron.
 
 
 
 
  I don't currently run Unix, but I think I know the problem.
 
  In a text file, the shell examines the first line, and if
 
  it begins
 
  #!
  it's assumed to point to the executable of an
 interpreter for that
  text file.  Presumably the same trick doesn't work for a
 .pyc file.
 
  Why not write a trivial wrapper.py file, don't compile
 it, and let
  that invoke the main code in the .pyc file?
 
  Then make wrapper.py executable, and you're ready to go.
 
  DaveA
 
 
 
 
  Hi Dave,
  Your solution sort of defeats my intended purpose (sorry
 
  for not divulging my 'hidden agenda').
 
  I wanted my application to hide the fact that it's a
 
  python script, and look as much as possible like it's a compiled
  program.
 
  The reason I don't just give my user a py file, is that I
 
  don't want a cleaver user to change the innards of the script.
 
  On the other hand, I don't want to make a compiled
 
  (freezed?) version of the application, because it'll grow the
  resulting file significantly, and I don't have the
 experience to know
  how it will run on different Linuxes.
 
  Bye,
  Ron.
 
 
  Most of the other answers basically paraphrased my suggestion of
  making a wrapper file, not compiling it, and making it
 executable.
  With that
  approach, the user just types   wrapper.py on his command line.
 
  And wrapper.py only needs two lines, a shebang, and an
 import, no big
  deal if the user modifies it.  The rest of your code can be .pyc
  files.
 
  Steven makes some good points.  You have to define what level of
  clever you're protecting from.  A determined hacker will get in no
  matter what you do, unless you want to ship the program in a
  proprietary embedded system, encased in epoxy.
  Further, if you have an extension of .py or .pyc, a knowledgeable
  hacker will know it's probably python.
 
  You imply you want it to run unmodifed on multiple unknown Linux
  versions.  I think that lets out binfmt solutions.
  That means you need to test and support not only multiple Linux
  implementations, but multiple Python versions, because who
 knows what
  the user may have installed.  I think you need to rethink your
  support strategy.  And maybe concentrate on being able to detect
  change, rather than prevent it.
 
  DaveA
 
 
 
 
 (Please don't top-post.  It puts responses out of order)

 You don't have to do anything special.  Any module can import
 sys, and parse sys.argv, as long as it wasn't yet modified.

 DaveA


Hi Dave,

It seems like I don't understand your solution.
I use the (appatched) soapAPI.py as 

Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Mark Lawrence

Michael M Mason wrote:


Dave Angel da...@ieee.org wrote in message 
news:mailman.4120.1249172970.8015.python-l...@python.org...

Michael M Mason wrote:
div class=moz-text-flowed style=font-family: -moz-fixedI'm 
running Python 3.1 on Vista and I can't figure out how to add my own 
directory to sys.path.


Thanks to Jon, Piet, David and Dave for the responses.


sys.path gets its values from several places.


Ah, I'd misunderstood the docs: I thought it came from just one place 
(which I couldn't find).


Anyway, I'd suggest adding it to PythonPath, and if it's empty, just 
create it with the directory you need.


Thanks--that worked!
Be careful, I'm screwed things up on several occasions by placing a file 
on PYTHONPATH that overrides a file in the standard library, test.py 
being my favourite!


I'm hoping you know you can also add to sys.path directly during 
script initialization.  It's just a list, and is writeable.


Yes, but I'm mainly playing in IDLE and I was getting a bit fed up of 
repeatedly typing

 import sys
 sys.path.append('C:/Users/Michael/Code/Python')
 import mystuff


--
Kindest regards.

Mark Lawrence.

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


Re: Generate a new object each time a name is imported

2009-08-02 Thread Hrvoje Niksic
Steven D'Aprano st...@remove-this-cybersource.com.au writes:

 I'm looking for a way to hide the generation of objects from the caller, 
 so I could do something like this:

 from Module import factory() as a  # a == Object #1
 from Module import factory() as b  # b == Object #2

 except of course that syntax is illegal.

That sounds reasonable (zen quotes aside), but it's just not possible in
current Python.  It would require for any use of a in subsequent code
to not only refer to an object, but also to automagically call it.  I
know of no mechanism to do that.  While Python allows intricate
customization of access to objects, simply referring to a name remains
fixed in meaning, probably intentionally.

(The cell mechanism used to implement closures sounds like it could
help, but a cell only stores a single value, not a factory, and it
doesn't apply to global variables anyway.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Michael M Mason
Mark Lawrence breamore...@yahoo.co.uk wrote in message 
news:mailman.4130.1249203322.8015.python-l...@python.org...
Be careful, I'm screwed things up on several occasions by placing a file 
on PYTHONPATH that overrides a file in the standard library, test.py being 
my favourite!


Thanks.  Sure enough, I've already got my own test.py but I hadn't 
discovered it was a problem yet...


--
Michael 


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


Re: Run pyc file without specifying python path ?

2009-08-02 Thread Dave Angel

Barak, Ron wrote:

Hi Dave,

It seems like I don't understand your solution.
I use the (appatched) soapAPI.py as the wrapper to parsing.pyc.
However, if I do (for instance):

$ python -u parsing.pyc -U aaa

The last line of the output is (as expected):

return_code: 12 ; params: {'username': 'aaa'}

But, if I try the following:

$ soapAPI.py -U aaa

I don't get this line. Only the output to stderr gets printed to the screen.

Bye,
Ron.

  

Hi Ron,

To make it easier for anybody following this thread, let me post the 
minimum equivalent source files, inline.


parsing.py:
--
#!/usr/bin/env python

import sys

def main():
   print  sys.stderr, This is stderr output
   return  5, sys.argv

if __name__ == __main__:
   return_code, params = main()
   print return_code:,return_code,; params:,params
   sys.exit(return_code)
---
soapapi.py:
---
#!/usr/bin/env python

import sys
import parsing

parsing.main()
--


When I run soapapi.;py, it indeed prints only the stderr output.

The solution is to move (most or all) of the top-level code of 
parsing.py into a main() function.  Since you already have a main(), 
I'll rename that, and make a new one that calls it.


new   parsing.py:
---
#!/usr/bin/env python

import sys

def innermain():
   print  sys.stderr, This is stderr output
   return  5, sys.argv

def main():
   return_code, params = innermain()
   print return_code:,return_code,; params:,params
   sys.exit(return_code)

if __name__ == __main__:
   main()
---

The output is now two lines, one from innermain(), and one from main().  
And it's the same whether the user runs  parsing.py  or   soapAPI.py


To clarify what happened, realize that when the user invokes  
parsing.py, the module is considered a script, and gets a pseudo-name of 
__main__When that same module is imported by another one, it is 
considered a library module, and gets its own name parsing


So any logic that explicitly checks for __main__ has to change,  
because we want identical behavior in the two cases.


DaveA

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


Re: Newbie Question regarding __init__()

2009-08-02 Thread Dave Angel

Simon wrote:

Okay I will fix my code and include self and see what happens.  I
know I tried that before and got another error which I suspect was
another newbie error.

The idea behind the init_Pre is that I can put custom code here to
customize the __init__ instead of creating a new subclass.  This kind
of hook pattern allows you to flatten your inheritance hierarchy.  I
can choose in the init_Pre method to execute code before the init_exec
(which contains the default __init__ code) and still execute the
init_Exec method or I can completely customize the entire __init__ by
returning False from init_Pre and prevent the init_Exec from being
called.  I use this type of pattern with almost all my methods.  In
this way I can create a less complicated inheritance chain but still
have have custom code when needed without sub-classing.

I am use to Visual FoxPro which where you can do

=is.init_Pre().And.This.init_Exec() and the result is discarded so
that is why it looks the way it does.  In this form init_Exec has to
return a value.  However, If self.init_Pre(): self.init_Exec() would
work the same and then I could avoid returning a value.

Thanks,
Simon


On Aug 1, 5:52 am, Dave Angel da...@ieee.org wrote:
  

Nat Williams wrote:


As MRAB described, ALL instance methods need to accept 'self' as a first
parameter, as that will be passed to them implicitly when they are called.
This includes __init__.  The name 'self' is just a commonly accepted
convention for the name of the instance object passed to methods.  You don't
have to call it that, but you really should.
  
Take a look athttp://docs.python.org/tutorial/classes.html#class-objects

It might help shed some light on how methods and instances work.
  
One other thing.  I'm a little confused by the first line of

dcObject.__init__:
  
self.init_Pre() and self.init_Exec()
  
I suspect this does not do what you think it does.  init_Pre and init_Exec

will both be called by this expression (unless init_Pre throws an exception,
of course).  You're not getting anything here that you wouldn't by just
calling each method on a separate line, except just making it harder to
read.
  

Read the doc-string for init_Pre() and for init_Exec().  The final
version of init_Pre() will return False in some circumstances, and in
those circumstances Simon doesn't want init_Exec() to be called.  He's
deliberately using the short-circuit evaluation of  'and'  to accomplish
that.









On Fri, Jul 31, 2009 at 8:53 PM, Simon dciphercomput...@gmail.com wrote:
  

Hi

So should the dcObject class include the self as well since I have

not defined an __init__ method in dcCursor?

Simon

--

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


Every one of those methods in both of those classes need a self first
argument.  As others have said, all instance methods need a 'self.'



  
(Please don't top-post.  You should put new responses at the end of 
quoted text, or sometimes inline if that's clearer.)


I don't understand your comparison to Foxpro.  read on.

As your code was last posted, you don't need a return value from 
init_Exec()  Every function that doesn't have an explicit return will 
return None.  And None is interpreted as False in an and expression.  
If you had an if around the whole thing, then you'd care.


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


Re: Help understanding the decisions *behind* python?

2009-08-02 Thread Dave Angel



sturlamolden wrote:

On 20 Jul, 18:27, Phillip B Oldham phillip.old...@gmail.com wrote:

  

We're not looking to start any arguments or religious wars and we're
not asking that python be changed into something its not. We'd simply
like to understand the decision behind the lists and tuple structures.
We feel that in not getting the difference between the two types we
may be missing out on using these data structures to their full
potential.



A crude simplification would be:

- A Python programmer will use a tuple where a C programmer will use a
struct.

- Python and C programmers use lists and arrays similarly.

Tuples are used for passing arguments to and from a function. Common
use of tuples include multiple return values and optional arguments
(*args).

It has already been mentioned that tuples are immutable and can be
used as dictionary keys.


  
I think collections.namedtuple, introduced in Python 2.6, might help 
bridge the gap between a traditional tuple and a C struct.



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


Re: Generate a new object each time a name is imported

2009-08-02 Thread Peter Otten
Steven D'Aprano wrote:

 I would like to generate a new object each time I import a name from a
 module, rather than getting the same object each time. For example,
 currently I might do something like this:
 
 # Module
 count = 0
 def factory():
 # Generate a unique object each time this is called
 global count
 count += 1
 return Object #%d % count
 
 
 # Calling module
 from Module import factory
 a = factory()  # a == Object #1
 b = factory()  # b == Object #2
 del factory
 
 
 I'm looking for a way to hide the generation of objects from the caller,
 so I could do something like this:
 
 from Module import factory() as a  # a == Object #1
 from Module import factory() as b  # b == Object #2
 
 except of course that syntax is illegal.

How about

 class A(object):
... def __init__(self):
... self._n = 0
... @property
... def a(self):
... try:
... return self._n
... finally:
... self._n += 1
...
 import sys
 sys.modules[yadda] = A()
 from yadda import a
 from yadda import a as b
 a, b
(0, 1)

Peter

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


Re: Generate a new object each time a name is imported

2009-08-02 Thread Steven D'Aprano
On Sun, 02 Aug 2009 12:33:03 +0200, Peter Otten wrote:

 How about
[snip]
 import sys
 sys.modules[yadda] = A()

Perfect! That's exactly the sort of thing I'm looking for.

Thanks for everyone who answered.




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


Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Mark Lawrence

Michael M Mason wrote:
Mark Lawrence breamore...@yahoo.co.uk wrote in message 
news:mailman.4130.1249203322.8015.python-l...@python.org...
Be careful, I'm screwed things up on several occasions by placing a 
file on PYTHONPATH that overrides a file in the standard library, 
test.py being my favourite!


Thanks.  Sure enough, I've already got my own test.py but I hadn't 
discovered it was a problem yet...


Typical, tried to reproduce it and can't!  Still at least you've been 
warned.


--
Kindest regards.

Mark Lawrence.

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


Re: Generate a new object each time a name is imported

2009-08-02 Thread Paul Rubin
Peter Otten __pete...@web.de writes:
  import sys
  sys.modules[yadda] = A()

OMG wow.  I bow to you.  But I'm not sure whether that's bowing in
awe or in terror.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help understanding the decisions *behind* python?

2009-08-02 Thread Marcus Wanner

On 8/1/2009 9:31 PM, sturlamolden wrote:

- Python and C programmers use lists and arrays similarly.


I'm guessing that's because of the brackets...

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


Re: Generate a new object each time a name is imported

2009-08-02 Thread Peter Otten
 wrote:

KNode cannot parse your From-string correctly. Strange.

 Peter Otten __pete...@web.de writes:
  import sys
  sys.modules[yadda] = A()
 
 OMG wow.  I bow to you.  But I'm not sure whether that's bowing in
 awe or in terror.

I don't know who invented it, but it's an old trick. It even made it into 
the standard library (email.LazyImporter).

For the record: I don't recommend it.

Peter

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


Skipping a superclass

2009-08-02 Thread Steven D'Aprano
I have a series of subclasses like this:

class A(object):
def method(self, *args):
print Lots of work gets done here in the base class

class B(A):
def method(self, *args):
print A little bit of work gets done in B
super(B, self).method(*args)

class C(B):
def method(self, *args):
print A little bit of work gets done in C
super(C, self).method(*args)


However, the work done in C.method() makes the work done in B.method() 
obsolete: I want one to run, or the other, but not both. C does need to 
inherit from B, for the sake of the other methods, so I want C.method() 
*only* to skip B while still inheriting from A. (All other methods have 
to inherit from B as normal.)

So what I have done is change the call to super in C to super(B, self) 
instead of super(C, self). It seems to work, but is this safe to do? Or 
are there strange side-effects I haven't seen yet?



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


Seeding the rand() Generator

2009-08-02 Thread Fred Atkinson
How does one seed the rand() generator when retrieving random
recordings in MySQL?  

Regards, 



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


Re: Skipping a superclass

2009-08-02 Thread Chris Rebert
On Sun, Aug 2, 2009 at 5:36 AM, Steven
D'Apranost...@remove-this-cybersource.com.au wrote:
 I have a series of subclasses like this:

 class A(object):
    def method(self, *args):
        print Lots of work gets done here in the base class

 class B(A):
    def method(self, *args):
        print A little bit of work gets done in B
        super(B, self).method(*args)

 class C(B):
    def method(self, *args):
        print A little bit of work gets done in C
        super(C, self).method(*args)


 However, the work done in C.method() makes the work done in B.method()
 obsolete: I want one to run, or the other, but not both. C does need to
 inherit from B, for the sake of the other methods, so I want C.method()
 *only* to skip B while still inheriting from A. (All other methods have
 to inherit from B as normal.)

 So what I have done is change the call to super in C to super(B, self)
 instead of super(C, self). It seems to work, but is this safe to do? Or
 are there strange side-effects I haven't seen yet?

Barring some true weirdness in super(), I don't /think/ so. It
obviously works fine in the single-inheritance case, and (after some
brute-force testing) the only permitted multiple inheritances
involving C and (A or B) always have C ahead of B in the MRO (method
resolution order).

The fact that you're wanting to bypass a superclass method might
suggest however, that your hierarchy could be structured better. Have
you considered moving B.method() into another, new class (e.g. newB)
which subclasses B? Then C can inherit from B without inheriting the
unwanted method, while B's functionality still exists, just under a
new name (newB).

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


Re: Newbie thwarted by sys.path on Vista

2009-08-02 Thread Christian Heimes

Michael M Mason wrote:
I'm running Python 3.1 on Vista and I can't figure out how to add my own 
directory to  sys.path.


The docs suggest that I can either add it to the PYTHONPATH environment 
variable or to the PythonPath key in the registry.  However, PYTHONPATH 
doesn't exist, and updating the registry key has no effect (and in any case 
the contents aren't the same as sys.path).


So where does sys.path get its value from, and how do I change it?


You can use my PEP 370 (http://python.org/dev/peps/pep-0370/) and a .pth 
file to extend the search path for modules.


 import os
 import site
 site.USER_SITE
'/home/heimes/.local/lib/python2.6/site-packages'
 if not os.path.isdir(site.USER_SITE):
... os.makedirs(site.USER_SITE)
...
 pth = open(os.path.join(site.USER_SITE, michal.pth), w)
 pth.write(C:/Users/Michael/Code/Python\n)
 pth.close()

Restart Python, your custom search path should be in sys.path.

Christian

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


Re: A Bug By Any Other Name ...

2009-08-02 Thread Albert van der Horst
In article mailman.3309.1247861321.8015.python-l...@python.org,
J. Cliff Dyer j...@sdf.lonestar.org wrote:
On Fri, 2009-07-17 at 20:53 +, Albert van der Horst wrote:
 Because unlike in algol 68 in python whitespace is relevant,
 we could get by with requiring whitespace:
 x= -q   # okay
 ab and -ac and -b  -d# okay
 8 ** -2 # okay

This is actually quite thoroughly untrue.  In python, *indentation* is
significant.  Whitespace (internal to a line) is not.  You can even call
methods like this if you want:

You totally don't get it. You describe how python is now.
I propose a change to be made to python. Small wonder that that is
different from what it is now.


 s = 'abc'
 s. upper()
ABC

You prove nothing by giving examples.
You can disprove by giving one counter example,
here it goes.

Whitespace (internal to a line) is significant.
In Python you cannot change
  xleftgoing = 12300
to
x left going = 123 000 000

(You can in Algol68)

Obviously, that's A Bad Idea(tm), but python's parser won't stop you.

What is a bad idea?
Apparently you are not talking about my idea of changing the parser.
(Pythons parser won't stop you from changing the parser doesn't
make sense.)

The ++ operator gotcha is so minor that I can't remember anyone actually
asking about it on the list (who was actually facing it as a
problem--this thread was started by idle speculation).  Can we not
change the language syntax to address non-issues?

As other languages have an Eleventh Commandment against concatenating
operators, the larger issue is hardly futile.


Practicality beats purity, a.k.a. don't you have something better to do?

I'm having a great time, thank you!

Cheers,
Cliff

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
alb...@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: Colour of output text

2009-08-02 Thread Albert van der Horst
In article mailman.3163.1247670223.8015.python-l...@python.org,
Jean-Michel Pichavant  jeanmic...@sequans.com wrote:
Nobody wrote:
 On Fri, 10 Jul 2009 09:23:54 +, garabik-news-2005-05 wrote:


 I would like to learn a way of changing the colour of a particular
 part of the output text. I've tried the following

 On Unix operating systems this would be done through the curses interface:

 http://docs.python.org/library/curses.html

 Or using ANSI colour codes:

 colours = {
 'none'   :,
 'default':\033[0m,
 'bold'   :\033[1m,


 [snip]


 # non-standard attributes, supported by some terminals


 This comment should have appeared immediately after none ;)

 Hard-coding control/escape sequences is just lame. Use the curses modules
 to obtain the correct sequences for the terminal.


As the OP I'm really interested in doing so. I currently have all my
colors hard-coded.
Now It may be lame but as soon as I call curses.initscr(), it's just
messing up with my terminal, moreover I didn't figure out how to print
'hello' using curses color codes.
Anyone has an example ? I'm pretty sure it may fit in one line.

In general initscr() ought to work. It fails if it has no/a wrong
idea of what your terminal is.

In the same shell as you run run your program type

set | grep -i term

Now some entry should show up, e.g.
TERM=xterm

infocmp $TERM

should fetch information about your terminal, from the same source
as curses does.

Possible problems are:
- your operating system/configurations lies to curses about the terminal
  or your terminal is not specified at all
- curses has not been properly installed and cannot find the database

Groetjes Albert



JM




--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
alb...@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


IFL 2009: Call for Papers and Participation

2009-08-02 Thread IFL 2009
Call for Papers and ParticipationIFL 2009Seton Hall UniversitySOUTH ORANGE, NJ, USAhttp://tltc.shu.edu/blogs/projects/IFL2009/Register at: http://tltc.shu.edu/blogs/projects/IFL2009/registration.html* NEW *Registration and talk submission extended to August 23, 2009! ***The 21st International Symposium on Implementation and Application of Functional Languages, IFL 2009, will be held for the first time in the USA. The hosting institution is Seton Hall University in South Orange, NJ, USA and the symposium dates are September 23-25, 2009. It is our goal to make IFL a regular event held in the USA and in Europe. The goal of the IFL symposia is to bring together researchers actively engaged in the implementation and application of functional and function-based programming languages. IFL 2009 will be a venue for researchers to present and discuss new ideas and concepts, work in progress, and publication-ripe results related to the implementation and application of functional languages and function-based programming.Following the IFL tradition, IFL 2009 will use a post-symposium review process to produce a formal proceedings which will be published by Springer in the Lecture Notes in Computer Science series. All participants in IFL 2009 are invited to submit either a draft paper or an extended abstract describing work to be presented at the symposium. These submissions will be screened by the program committee chair to make sure they are within the scope of IFL and will appear in the draft proceedings distributed at the symposium. Submissions appearing in the draft proceedings are not peer-reviewed publications. After the symposium, authors will be given the opportunity to incorporate the feedback from discussions at the symposium and will be invited to submit a revised full arcticle for the formal review process. These revised submissions will be reviewed by the program committee using prevailing academic standards to select the best articles that will appear in the formal proceedings.Invited Speaker: Benjamin C. Pierce University of Pennsylvania Talk Title: How To Build Your Own Bidirectional Programming LanguageTOPICSIFL welcomes submissions describing practical and theoretical work as well as submissions describing applications and tools. If you are not sure if your work is appropriate for IFL 2009, please contact the PC chair at ifl2...@shu.edu. Topics of interest include, but are not limited to:language concepts type checking contractscompilation techniques staged compilationruntime function specializationruntime code generation partial evaluation (abstract) interpretation generic programming techniques automatic program generation array processing concurrent/parallel programming concurrent/parallel program execution functional programming and embedded systems functional programming and web applications functional programming and security novel memory management techniques runtime profiling and performance measurements debugging and tracing virtual/abstract machine architectures validation and verification of functional programs tools and programming techniques FP in EducationPAPER SUBMISSIONSProspective authors are encouraged to submit papers or extended abstracts to be published in the draft proceedings and to present them at the symposium. All contributions must be written in English, conform to the Springer-Verlag LNCS series format and not exceed 16 pages. The draft proceedings will appear as a technical report of the Department of Mathematics and Computer Science of Seton Hall University.IMPORTANT DATESRegistration deadline August 15, 2009Presentation submission deadline August 15, 2009IFL 2009 Symposium September 23-25, 2009Submission for review process deadline November 1, 2009Notification Accept/Reject December 22, 2009Camera ready version February 1, 2010PROGRAM COMMITTEEPeter Achten University of Nijmegen, The NetherlandsJost Berthold Philipps-Universität Marburg, GermanyAndrew Butterfield University of Dublin, IrelandRobby Findler Northwestern University, USAKathleen Fisher ATT Research, USACormac Flanagan University of California at Santa Cruz, USAMatthew Flatt University of Utah, USAMatthew Fluet Toyota Technological Institute at Chicago, USADaniel Friedman Indiana University, USAAndy Gill University of Kansas, USAClemens Grelck University of Amsterdam/Hertfordshire, The Netherlands/UKJurriaan Hage Utrecht University, The NetherlandsRalf Hinze Oxford University, UKPaul Hudak Yale University, USAJohn Hughes Chalmers University of Technology, SwedenPatricia Johann University of Strathclyde, UKYukiyoshi Kameyama University of Tsukuba, JapanMarco T. Morazán (Chair) Seton Hall University, USARex Page University of Oklahoma, USAFernando Rubio Universidad Complutense de Madrid, SpainSven-Bodo Scholz University of Hertfordshire, UKManuel Serrano INRIA Sophia-Antipolis, FranceChung-chieh Shan Rutgers University, USADavid Walker Princeton University, USAViktória Zsók Eötvös Loránd 

Is python buffer overflow proof?

2009-08-02 Thread Jizzai

Is a _pure_ python program buffer overflow proof?

For example in C++ you can declare a char[9] to hold user input.
If the user inputs 10+ chars a buffer overflow occurs.

In python, I cannot seem to find a way to define/restrict a string length.
This is probably by design and raises the topic in question.

Am curious to see the opinions of people who know.

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


PAK WEB PAK WEB TV PAK WEBSITES PAK WEB DIRECTORY PAK WEB HOSTING PAK WEB HOST PAK WEB HOSTING PAK WEB PAK WEB PAK WEB PAK WEB PAK WEB PAK WEB PAK WEB on www.pak-web-page

2009-08-02 Thread Kamal Kamal
PAK WEB

www.pak-web-pages.blogspot.com


PAK WEB TV

www.pak-web-pages.blogspot.com

 PAK WEBSITES

www.pak-web-pages.blogspot.com

 PAK WEB DIRECTORY

www.pak-web-pages.blogspot.com

 PAK WEB HOSTING

www.pak-web-pages.blogspot.com

 PAK WEB HOST

www.pak-web-pages.blogspot.com

 PAK WEB HOSTING

www.pak-web-pages.blogspot.com

 PAK WEB

www.pak-web-pages.blogspot.com

PAK WEB



www.pak-web-pages.blogspot.com

PAK WEB PAK WEB PAK WEB


www.pak-web-pages.blogspot.com


 PAK WEB

www.pak-web-pages.blogspot.com


PAK WEB on www.pak-web-pages.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python buffer overflow proof?

2009-08-02 Thread Marcus Wanner

On 8/2/2009 9:50 AM, Jizzai wrote:

Is a _pure_ python program buffer overflow proof?

For example in C++ you can declare a char[9] to hold user input.
If the user inputs 10+ chars a buffer overflow occurs.

In python, I cannot seem to find a way to define/restrict a string length.
This is probably by design and raises the topic in question.

Am curious to see the opinions of people who know.

TIA.
I believe that python is buffer overflow proof. In fact, I think that 
even ctypes is overflow proof...


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


Re: Seeding the rand() Generator

2009-08-02 Thread Marcus Wanner

On 8/2/2009 9:42 AM, Fred Atkinson wrote:

How does one seed the rand() generator when retrieving random
recordings in MySQL?  

	Regards, 




		Fred 

something like:

import random, time
random.seed(time.time())
#not actual record access code:
sqlite3.recordaccessfuction(recordid = random.rand())

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


Re: Is python buffer overflow proof?

2009-08-02 Thread Christian Heimes

Marcus Wanner wrote:
I believe that python is buffer overflow proof. In fact, I think that 
even ctypes is overflow proof...


No, ctypes isn't buffer overflow proof. ctypes can break and crash a 
Python interpreter easily.


Christian

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


Re: Processes not exiting

2009-08-02 Thread ma3mju
On 31 July, 11:27, Piet van Oostrum p...@cs.uu.nl wrote:
  ma3mju matt.u...@googlemail.com (m) wrote:
 m Hi all,
 m I'm having trouble with multiprocessing I'm using it to speed up some
 m simulations, I find for large queues when the process reaches the
 m poison pill it does not exit whereas for smaller queues it works
 m without any problems. Has anyone else had this trouble? Can anyone
 m tell me a way around it? The code is in two files below.

 How do you know it doesn't exit. You haven't shown any of your output.

 I did discover a problem in your code, but it should cause an exception:

 m #set off some of the easy workers on the hard work (maybe double
 m number of hard)
 m for i in range(0,num_hard_workers):
 m     hard_work_queue.put(None)
 m     hard_workers.append(multiprocessing.Process
 m (target=GP.RandomWalkGeneralizationErrorParallel,args=
 m (hard_work_queue,result_queue,)))
 m #wait for all hard workers to finish
 m for worker in hard_workers:
 m     worker.join()

 Here you create new hard workers, but you never start them. The join
 should then give an exception when it reaches these.
 --
 Piet van Oostrum p...@cs.uu.nl
 URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
 Private email: p...@vanoostrum.org

Ok thanks I'll change that In a sec, It never reaches that bit of code
because the easy_workers don't exit so it never gets past the join().

As far as running it goes I get the datapt and number of points
printed to the list for everything in both queues. When it reaches the
end of either queue I get Poison on the screen then here for each
process but I don't get worker joined and as expected don't get
this should not appear. If I have a look at the processes running
after all queues are supposed to have finished I see all of them
running taking little or no resources. This is running on Ubuntu
Jaunty at home and the same happens on the Debian machine at uni.

The weird thing is that if I run them with less points the processes
do manage to exit.

Thanks

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


Re: Processes not exiting

2009-08-02 Thread ma3mju
On 31 July, 11:34, MRAB pyt...@mrabarnett.plus.com wrote:
 ma3mju wrote:
  Hi all,

  I'm having trouble with multiprocessing I'm using it to speed up some
  simulations, I find for large queues when the process reaches the
  poison pill it does not exit whereas for smaller queues it works
  without any problems. Has anyone else had this trouble? Can anyone
  tell me a way around it? The code is in two files below.

 [snip]

  #get number of cores and set the number on concurrent processes
  num_hard_workers = 2
  num_workers = multiprocessing.cpu_count()*1.5
  easy_workers = []
  hard_workers = []
  #add poison pill for each worker and create the worker
  for i in range(0,num_workers-num_hard_workers):
      easy_work_queue.put(None)
      easy_workers.append(multiprocessing.Process
  (target=GP.RandomWalkGeneralizationErrorParallel,args=
  (easy_work_queue,result_queue,)))
  for i in range(0,num_hard_workers):
      hard_work_queue.put(None)
      hard_workers.append(multiprocessing.Process
  (target=GP.RandomWalkGeneralizationErrorParallel,args=
  (hard_work_queue,result_queue,)))

 You have 2 hard workers and ceil(CPU_count * 1.5) - 2 easy workers.
 What if the number of CPUs was 1? That would give 2 hard and 0 easy!

 Also, I recommend that you put only 1 'poison pill' in each queue and
 have the workers put it back when they see it.

I'll give that a go in a sec and see if it helps. The processes quit
out for smaller queues though so it should in theory be alright. I'm
not too fussed about the CPU's it's only there because I change
between a uni PC and home one with a different number of cores in each
but both greater than one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Predefined Variables

2009-08-02 Thread Scott David Daniels

Piet van Oostrum wrote:

Scott David Daniels scott.dani...@acm.org (SDD) wrote:

SDD Stephen Cuppett (should have written in this order):

Fred Atkinson fatkin...@mishmash.com wrote ...

Is there a pre-defined variable that returns the GET line...

os.environment('QUERY_STRING')

SDD Maybe you mean:
SDD os.environ['USER']

Let's take the best of both:
os.environ['QUERY_STRING']


Sorry about that.  I was testing expression before posting, and I don't
do that much cgi stuff.  I forgot to restore the variable name.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is python buffer overflow proof?

2009-08-02 Thread Steven D'Aprano
On Sun, 02 Aug 2009 13:50:14 +, Jizzai wrote:

 Is a _pure_ python program buffer overflow proof?

It's supposed to be.
 
 For example in C++ you can declare a char[9] to hold user input. If the
 user inputs 10+ chars a buffer overflow occurs.

 In python, I cannot seem to find a way to define/restrict a string
 length. This is probably by design and raises the topic in question.

That's a separate issue from being buffer overflow proof. You can't 
specify that a string have a maximum of N characters except by slicing 
the string after it's formed:

s = x*1  # Make a big string.
s = s[:100]  # Limit it to 100 characters.

But Python won't overflow any buffers even if you try to create a truly 
huge string:

s = x*(1024**4)  # Try to create a 1 TB string.

Your PC will run slow while Python and the OS tries to allocate 1TB of 
memory, then it will safely raise MemoryError. Pure Python should never 
dump core.



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


Re: Seeding the rand() Generator

2009-08-02 Thread Scott David Daniels

Fred Atkinson wrote:

How does one seed the rand() generator when retrieving random
recordings in MySQL?  


It is not entirely clear what you are asking.  If you are talking about
MySQL's random number generator, you are talking in the wrong newsgroup.
If you are talking about Python's, does this work?
import random
random.seed(123542552)
I'm not quite sure how you came to believe that Python controls MySQL,
as opposed to using its services.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Processes not exiting

2009-08-02 Thread ma3mju
On 2 Aug, 15:48, ma3mju matt.u...@googlemail.com wrote:
 On 31 July, 11:34, MRAB pyt...@mrabarnett.plus.com wrote:



  ma3mju wrote:
   Hi all,

   I'm having trouble with multiprocessing I'm using it to speed up some
   simulations, I find for large queues when the process reaches the
   poison pill it does not exit whereas for smaller queues it works
   without any problems. Has anyone else had this trouble? Can anyone
   tell me a way around it? The code is in two files below.

  [snip]

   #get number of cores and set the number on concurrent processes
   num_hard_workers = 2
   num_workers = multiprocessing.cpu_count()*1.5
   easy_workers = []
   hard_workers = []
   #add poison pill for each worker and create the worker
   for i in range(0,num_workers-num_hard_workers):
       easy_work_queue.put(None)
       easy_workers.append(multiprocessing.Process
   (target=GP.RandomWalkGeneralizationErrorParallel,args=
   (easy_work_queue,result_queue,)))
   for i in range(0,num_hard_workers):
       hard_work_queue.put(None)
       hard_workers.append(multiprocessing.Process
   (target=GP.RandomWalkGeneralizationErrorParallel,args=
   (hard_work_queue,result_queue,)))

  You have 2 hard workers and ceil(CPU_count * 1.5) - 2 easy workers.
  What if the number of CPUs was 1? That would give 2 hard and 0 easy!

  Also, I recommend that you put only 1 'poison pill' in each queue and
  have the workers put it back when they see it.

 I'll give that a go in a sec and see if it helps. The processes quit
 out for smaller queues though so it should in theory be alright. I'm
 not too fussed about the CPU's it's only there because I change
 between a uni PC and home one with a different number of cores in each
 but both greater than one.

Just tried changing the poison pill part to no avail sadly
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generate a new object each time a name is imported

2009-08-02 Thread Terry Reedy

Peter Otten wrote:

Steven D'Aprano wrote:



I'm looking for a way to hide the generation of objects from the caller,
so I could do something like this:

from Module import factory() as a  # a == Object #1
from Module import factory() as b  # b == Object #2

except of course that syntax is illegal.


How about


For newbies who do not get how the following works, but would like to 
know, I am adding some explanation.



class A(object):

... def __init__(self):
... self._n = 0
... @property
... def a(self):
... try:
... return self._n
... finally:
... self._n += 1


The @property decorator turns the 'a' function into the hidden getter 
function for what looks to the outside world like a simple instance 
attribute named 'a'.



import sys
sys.modules[yadda] = A()


sys.modules is a system namespace that normally associates names with 
modules. It is used by import statements to find existing modules. 
However, there is no requirement that the associated object actually be 
a module. A module is simply a collection of objects accessed as 
attributes. One can get and set attributes of a module, and but hardly 
anyhing else. Other attribute collection objects will do as well as far 
as imports are concerned. 'If it quack like a duck (module in this case)...'


The above sets the 'module' to an *instance* of class A.


from yadda import a


This looks for the 'module' named 'yadda'. It finds one - the instance 
of A. It then requests attribute 'a' (of that instance). That request is 
routed to the getter function.


This import statement could be in any module, not just the one that set 
A() as a module surrogate.



from yadda import a as b
a, b

(0, 1)


As Peter mentioned in his followup, module surrogates were intended for 
lazy imports of expensive-to-compute attributes that might never be 
needed, so their creation could be delayed to whenever needed, if ever.


Tricks like the above are not recommended for normal usage, but do 
illstrate some aspects of the language.


Terry Jan Reedy

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


Re: How to read webpage

2009-08-02 Thread catafest
Maybe your python2.5 not working good!?
But, I use python 2.6 , and i use this for your problem:
import urllib
html = urllib.urlopen(http://www.rediff.com/;).read()
print html

If you want use authenticate then...
You make working urllib2 and use this
auth = urllib2.Request(auth_uri, authreq_data)

On Aug 1, 4:52 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 tarun wrote:
  Dear All,
  I want to read a webpage and copy the contents of it in word file. I
  tried to write following code:

  import urllib2
  urllib2.urlopen(http://www.rediff.com/;)

  *Error:-*

      urllib2.urlopen(http://www.icicibank.com/;)
    File C:\Python25\lib\urllib2.py, line 121, in urlopen
      return _opener.open(url, data)
    File C:\Python25\lib\urllib2.py, line 374, in open
      response = self._open(req, data)
    File C:\Python25\lib\urllib2.py, line 392, in _open
      '_open', req)
    File C:\Python25\lib\urllib2.py, line 353, in _call_chain
      result = func(*args)
    File C:\Python25\lib\urllib2.py, line 1100, in http_open
      return self.do_open(httplib.HTTPConnection, req)
    File C:\Python25\lib\urllib2.py, line 1075, in do_open
      raise URLError(err)
  urllib2.URLError: urlopen error (11001, 'getaddrinfo failed')

 I've just tried it. I didn't get an exception, so your problem must be
 elsewhere.

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


Re: Processes not exiting

2009-08-02 Thread MRAB

ma3mju wrote:

On 2 Aug, 15:48, ma3mju matt.u...@googlemail.com wrote:

On 31 July, 11:34, MRAB pyt...@mrabarnett.plus.com wrote:




ma3mju wrote:

Hi all,
I'm having trouble with multiprocessing I'm using it to speed up some
simulations, I find for large queues when the process reaches the
poison pill it does not exit whereas for smaller queues it works
without any problems. Has anyone else had this trouble? Can anyone
tell me a way around it? The code is in two files below.

[snip]

#get number of cores and set the number on concurrent processes
num_hard_workers = 2
num_workers = multiprocessing.cpu_count()*1.5
easy_workers = []
hard_workers = []
#add poison pill for each worker and create the worker
for i in range(0,num_workers-num_hard_workers):
easy_work_queue.put(None)
easy_workers.append(multiprocessing.Process
(target=GP.RandomWalkGeneralizationErrorParallel,args=
(easy_work_queue,result_queue,)))
for i in range(0,num_hard_workers):
hard_work_queue.put(None)
hard_workers.append(multiprocessing.Process
(target=GP.RandomWalkGeneralizationErrorParallel,args=
(hard_work_queue,result_queue,)))

You have 2 hard workers and ceil(CPU_count * 1.5) - 2 easy workers.
What if the number of CPUs was 1? That would give 2 hard and 0 easy!
Also, I recommend that you put only 1 'poison pill' in each queue and
have the workers put it back when they see it.

I'll give that a go in a sec and see if it helps. The processes quit
out for smaller queues though so it should in theory be alright. I'm
not too fussed about the CPU's it's only there because I change
between a uni PC and home one with a different number of cores in each
but both greater than one.


Just tried changing the poison pill part to no avail sadly


I wonder whether one of the workers is raising an exception, perhaps due
to lack of memory, when there are large number of jobs to process.

Another question: why are you distinguishing between easy and hard jobs?
Do you actually get a measurable improvement in performance from doing
it this way instead of having just a single queue of jobs and a single
pool of workers?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Get Cliet IP Address

2009-08-02 Thread Piet van Oostrum
 Fred Atkinson fatkin...@mishmash.com (FA) wrote:

FAWhat is the function to obtain the client browser's IP
FA address?   

You mean in a web server?

The following should work (and was posted by me not long ago):

from os import getenv

ip = (getenv(HTTP_CLIENT_IP) or
  getenv(HTTP_X_FORWARDED_FOR) or
  getenv(HTTP_X_FORWARDED_FOR) or
  getenv(REMOTE_ADDR) or
  UNKNOWN)

I use getenv() rather than environ[] to avoid exceptions.
-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cgi script

2009-08-02 Thread Piet van Oostrum
 golu bhardwajjaye...@gmail.com (g) wrote:

g Hi,
g i started learning cgi few days ago in python and everything went
g fine  until i started getting the follwing error
g 
g The server encountered an internal error and was unable to complete
g your request. Either the server is overloaded or there was an error in
g a CGI script.

g If you think this is a server error, please contact the webmaster. 
g   i am using apache on xampp. plz help

Putting the following in your script might help as it will show the
exception trace in your browser (if it gets that far, that is).


import cgitb
cgitb.enable()

-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Building / making an application

2009-08-02 Thread Peter Chant
What is a good way to do this?  There are instructions on making modules at:

http://docs.python.org/distutils/setupscript.html

however, what do you do if you don't want a module?  I'm thinking of where
I'd like to split the code into several files and have a build / setup
script put it together and install it somewhere such as /usr/local/bin. 
I'm interested in what the standard way of doing this is.

Thanks,

Pete



-- 
http://www.petezilla.co.uk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket policy flash help

2009-08-02 Thread Piet van Oostrum
 NighterNet darkne...@gmail.com (N) wrote:

N Here the full code.
N flashpolicy.xml
N [[[
N ?xml version=1.0?
N cross-domain-policy
Nallow-access-from domain=* to-ports=* /
N /cross-domain-policy
N ]]]

N flashpolicytest_server3x.py
N [[[

N #!/usr/local/bin/python
N '''
N Still under testing...
N python version 3.x.x
N '''
N import socket
N import threading
N import sys
N import os

N file_name = 'flashpolicy.xml'
N fh = open(file_name, r)
N policy = fh.read(10001)

You never use that variable.

N host = ''; #out side network
N port = ;

N print (#  - Init... -  #);
N class ClientThread (threading.Thread):
N global policy;
N allClients = [];
N vlock = threading.Lock();
N id = 0 # next available thread number
N def __init__(self,clientSocket):
N threading.Thread.__init__(self)
N self.sockfd = clientSocket; #socket client
N self.name = '';
N ClientThread.id += 1
N self.id = ClientThread.id
N self.nickName = '';
N self.allClients.append(self.sockfd);
N def sendAll(self,buff):
N for index,clientSock in enumerate(self.allClients):
N try:
N clientSock.send(buff);

There is no guarantee that send will indeed transmit all of buff. It is
better to use clientSock.sendall(buff). Or you should check the return
value of send and check if it is equal to the length of buff. And repeat
if not. (But sendall is easier). 

Also don't use ; at the end of the statement. It's not pythonic.

N except (socket.error):
N print ('error socket %s\n',index,| clean);
N clientSock.close()
N del self.allClients[index]
N def run(self):
N while True:
N buff = self.sockfd.recv(1028);

There is no guarantee that recv will get the whole message. It may even
get as little as 1 byte. So you should check the return value of recv.
The official way is to keep reading until you have enough input or until
you hit end of file.

N if not buff:
N print (connect close...(client side));
N self.sockfd.close();
N break #incase it loop infinite
N if str(buff) == str(b\'policy-file-request/\\x00\'):

What you check here is whether buff contains the byte sequence that starts with 
a
b, then a ' ... and ending with the 5 bytes \ x 0 0 ' which is wrong.

Actually it should be:

if buff == b\'policy-file-request/\x00':
or
if buff == b\'policy-file-request/\0':


N print ('policy FOUND  sending...')
N print(buff)
N b = b'?xml 
version=\1.0\?cross-domain-policyallow-access-
N from domain=\*\ to-ports=\*\ //cross-domain-policy'
N print (b)
N self.sockfd.send(b);
N self.sockfd.sendall(b);

Only self.sockfd.sendall; delete the line with self.sockfd.send(b). And
remove the semicolons for esthetical reasons.

N Some odd reason I can't send flash policy from python to flash socket
N to agrees with the connection.

-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building / making an application

2009-08-02 Thread Krishnakant
On Sun, 2009-08-02 at 20:21 +0100, Peter Chant wrote:
 What is a good way to do this?  There are instructions on making modules at:
 
 http://docs.python.org/distutils/setupscript.html
 
 however, what do you do if you don't want a module?  I'm thinking of where
 I'd like to split the code into several files and have a build / setup
 script put it together and install it somewhere such as /usr/local/bin. 
 I'm interested in what the standard way of doing this is.
 
Have you considered creating a deb or rpm package for your application?
Most of the documentation for deb or rpm will talk about make files.
But even a distutil based python package (with a setup.py) can be made
into a deb package.
Then the your requirement will be satisfied at least for most gnu/linux
based distros.

happy hacking.
Krishnakant.



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


Re: Building / making an application

2009-08-02 Thread Peter Chant
Krishnakant wrote:


 Have you considered creating a deb or rpm package for your application?
 Most of the documentation for deb or rpm will talk about make files.
 But even a distutil based python package (with a setup.py) can be made
 into a deb package.
 Then the your requirement will be satisfied at least for most gnu/linux
 based distros.

I'm a slacker, so what I would do would be to make a slack build, the
slackbuild would take the source and build that.  The stage I am at is
the how to build the source stage.  Don't really intend to get as far as
distribution specific packages.

What I could do is create a script in the source root directory (that sounds
a bit overblown) that simply concatenates together all the python files in
the right order and perhaps copies the result to /usr/local/bin or /usr/bin
as appropriate.  Is that the right way to go?  It looks like distutils is
appropriate only for modules.  

OTOH it might be appropriate to put the bulk of an application in a module
and have a function calling it the only part of the main script.

Pete

-- 
http://www.petezilla.co.uk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building / making an application

2009-08-02 Thread Diez B. Roggisch

Peter Chant schrieb:

Krishnakant wrote:



Have you considered creating a deb or rpm package for your application?
Most of the documentation for deb or rpm will talk about make files.
But even a distutil based python package (with a setup.py) can be made
into a deb package.
Then the your requirement will be satisfied at least for most gnu/linux
based distros.


I'm a slacker, so what I would do would be to make a slack build, the
slackbuild would take the source and build that.  The stage I am at is
the how to build the source stage.  Don't really intend to get as far as
distribution specific packages.

What I could do is create a script in the source root directory (that sounds
a bit overblown) that simply concatenates together all the python files in
the right order and perhaps copies the result to /usr/local/bin or /usr/bin
as appropriate.  Is that the right way to go?  It looks like distutils is
appropriate only for modules.  


OTOH it might be appropriate to put the bulk of an application in a module
and have a function calling it the only part of the main script.


You should consider using setuptools. Then you get an egg that people 
can install, and you can define console_scripts-entry-points which 
will be installed into /usr/local/bin or similar locations.


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


Re: Help with Regex for domain names

2009-08-02 Thread Aahz
In article mailman.3998.1248989346.8015.python-l...@python.org,
MRAB  pyt...@mrabarnett.plus.com wrote:
Nobody wrote:
 On Thu, 30 Jul 2009 10:29:09 -0700, rurpy wrote:
 
 regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)')
 You might also want to consider that some country
 codes such as co for Columbia might match more than
 you want, for example:

   re.match(r'[\w\-\.]+\.(?:us|au|de|co)', 'foo.boo.com')

 will match.
 
 ... so put \b at the end, i.e.:
 
 regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)\b')
 
It would still match www.bbc.co.uk, so you might need:

regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)\b(?!\.\b)')

If it's a string containing just the candidate domain, you can do

regex = re.compile(r'[\w\-\.]+\.(?:us|au|de)$')
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important. --Henry Spencer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seeding the rand() Generator

2009-08-02 Thread Fred Atkinson
On Sun, 02 Aug 2009 08:53:50 -0700, Scott David Daniels
scott.dani...@acm.org wrote:

Fred Atkinson wrote:
  How does one seed the rand() generator when retrieving random
 recordings in MySQL?  

It is not entirely clear what you are asking.  If you are talking about
MySQL's random number generator, you are talking in the wrong newsgroup.
If you are talking about Python's, does this work?
 import random
 random.seed(123542552)
I'm not quite sure how you came to believe that Python controls MySQL,
as opposed to using its services.

--Scott David Daniels
scott.dani...@acm.org

I am coding in Python.  

I am accessing a MySQL database.  

I have a string to instruct the MySQL database to use the
'rand()' function to randomly choose one of the records in the
database.  

I know how to seed it in PHP.  Does anyone know how to see it
from with Python?  

Regards, 




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


Re: Predefined Variables

2009-08-02 Thread Fred Atkinson
On Sun, 02 Aug 2009 08:11:22 -0700, Scott David Daniels
scott.dani...@acm.org wrote:

Piet van Oostrum wrote:
 Scott David Daniels scott.dani...@acm.org (SDD) wrote:
 SDD Stephen Cuppett (should have written in this order):
 Fred Atkinson fatkin...@mishmash.com wrote ...
 Is there a pre-defined variable that returns the GET line...
 os.environment('QUERY_STRING')
 SDD Maybe you mean:
 SDD os.environ['USER']
 Let's take the best of both:
 os.environ['QUERY_STRING']

Sorry about that.  I was testing expression before posting, and I don't
do that much cgi stuff.  I forgot to restore the variable name.

--Scott David Daniels
scott.dani...@acm.org

I finally got it to work with x =getenv('QUERY_STRING')

Regards, 



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


Re: Processes not exiting

2009-08-02 Thread Piet van Oostrum
 MRAB pyt...@mrabarnett.plus.com (M) wrote:

M I wonder whether one of the workers is raising an exception, perhaps due
M to lack of memory, when there are large number of jobs to process.

But that wouldn't prevent the join. And you would probably get an
exception traceback printed.

I wonder if something fishy is happening in the multiprocessing
infrastructure. Or maybe the Fortran code goes wrong because it has no
protection against buffer overruns and similar problems, I think.
-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Get Cliet IP Address

2009-08-02 Thread Fred Atkinson
What is the function to obtain the client browser's IP
address?   




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


Re: Python docs disappointing

2009-08-02 Thread kj
In 09bf4f17-40a5-4bad-81d3-1950545b7...@g6g2000vbr.googlegroups.com
Carl Banks pavlovevide...@gmail.com writes:

snip

Thanks.  Your remarks at least confirm that my impression was not
simply due to my noob ignorance: the keyboard-accessible docs are
indeed as poor as they look.

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


RE Question

2009-08-02 Thread Victor Subervi
Hi;
How do I search and replace something like this:
aLine = re.sub('[]?[p]?[]?font size=h' + str(x) + '[
a-zA-Z0-9\'=:]*[]?[b]?[]?', 'h' + str(x) + '', aLine)
where RE *only* looks for the possibility of p at the beginning of the
string; that is, not the individual components as I have it coded above, but
the entire 3-character block?
TIA,
Victor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python buffer overflow proof?

2009-08-02 Thread Marcus Wanner

On 8/2/2009 10:43 AM, Christian Heimes wrote:

Marcus Wanner wrote:
I believe that python is buffer overflow proof. In fact, I think that 
even ctypes is overflow proof...


No, ctypes isn't buffer overflow proof. ctypes can break and crash a 
Python interpreter easily.


Christian

I see. I thought that it said invalid array index when you try to 
read/write outside of an array's bounds, though...


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


Re: Building / making an application

2009-08-02 Thread Peter Chant
Diez B. Roggisch wrote:


 You should consider using setuptools. Then you get an egg that people
 can install, and you can define console_scripts-entry-points which
 will be installed into /usr/local/bin or similar locations.

Interesting, I think I need to have a play with that.  The cross platform
bit could be useful as well.

Pete

-- 
http://www.petezilla.co.uk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python docs disappointing

2009-08-02 Thread Mohan Parthasarathy
I am a newbie and about a month old with Python. There is a wealth of
material about Python and I am really enjoying learning Python.

One thing that could have helped Python documentation is that instead of the
very raw doc string, it could have used something like PythonDoc (java doc
style) so that the functions/classes are documented better. At least I am
planning to use PythonDoc for the code that I am going to write. Let me know
if there is a better one..

-mohan

On Fri, Jul 31, 2009 at 1:10 PM, kj no.em...@please.post wrote:




 I'm pretty new to Python, and I like a lot overall, but I find the
 documentation for Python rather poor, overall.

 I'm sure that Python experts don't have this problem: they have
 internalized some good ways to access the documentation, are
 productive with it, and therefore have lost the ability to see why
 the Python documentations is deficient for beginners.  This explains
 why a suboptimal situation can persist like this: those who are
 most able fix it are also the least able to perceive it.

 I've heard similar complaints from other experienced programmers
 who are trying out Python for the first time: poor documentation.

 Here is an *entirely typical* example: on some Unix, try

 % pydoc urllib

 The displayed documentation mention the optional parameter data
 in practically every function listed (a few dozen of them).  This
 parameter is not documented *anywhere* on that page.  All that we
 are told is that its default value is always None.

 I'm sure that I can find a full description of this parameter if
 I fire up Google, and search online.  In fact, more likely than
 not, I'll find far more documentation than I want.  But my point
 is that a programmer should not need to do this.  The full
 documentation should be readily accessible directly through a few
 keystrokes.

 I would love to know how experienced Python programmers quickly
 zero in on the Python documentation they need.

 TIA!

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

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


Re: Python docs disappointing

2009-08-02 Thread Chris Rebert
 On Fri, Jul 31, 2009 at 1:10 PM, kj no.em...@please.post wrote:
 I'm pretty new to Python, and I like a lot overall, but I find the
 documentation for Python rather poor, overall.

 I'm sure that Python experts don't have this problem: they have
 internalized some good ways to access the documentation, are
 productive with it, and therefore have lost the ability to see why
 the Python documentations is deficient for beginners.  This explains
 why a suboptimal situation can persist like this: those who are
 most able fix it are also the least able to perceive it.

 I've heard similar complaints from other experienced programmers
 who are trying out Python for the first time: poor documentation.

 Here is an *entirely typical* example: on some Unix, try

 % pydoc urllib

 The displayed documentation mention the optional parameter data
 in practically every function listed (a few dozen of them).  This
 parameter is not documented *anywhere* on that page.  All that we
 are told is that its default value is always None.

 I'm sure that I can find a full description of this parameter if
 I fire up Google, and search online.  In fact, more likely than
 not, I'll find far more documentation than I want.  But my point
 is that a programmer should not need to do this.  The full
 documentation should be readily accessible directly through a few
 keystrokes.

 I would love to know how experienced Python programmers quickly
 zero in on the Python documentation they need.
On Sun, Aug 2, 2009 at 4:22 PM, Mohan Parthasarathysurut...@gmail.com wrote:
 I am a newbie and about a month old with Python. There is a wealth of
 material about Python and I am really enjoying learning Python.

 One thing that could have helped Python documentation is that instead of the
 very raw doc string, it could have used something like PythonDoc (java doc
 style) so that the functions/classes are documented better. At least I am
 planning to use PythonDoc for the code that I am going to write. Let me know
 if there is a better one..

If you use reStructuredText (http://docutils.sf.net/rst.html), you can
leverage Sphinx (http://sphinx.pocoo.org/), which generates the
superb-looking official Python docs.

Cheers,
Chris

P.S. Please don't top-post (http://en.wikipedia.org/wiki/Top-post) in
the future.
-- 
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seeding the rand() Generator

2009-08-02 Thread Carl Banks
On Aug 2, 2:18 pm, Fred Atkinson fatkin...@mishmash.com wrote:
 On Sun, 02 Aug 2009 08:53:50 -0700, Scott David Daniels

 scott.dani...@acm.org wrote:
 Fred Atkinson wrote:
         How does one seed the rand() generator when retrieving random
  recordings in MySQL?  

 It is not entirely clear what you are asking.  If you are talking about
 MySQL's random number generator, you are talking in the wrong newsgroup.
 If you are talking about Python's, does this work?
      import random
      random.seed(123542552)
 I'm not quite sure how you came to believe that Python controls MySQL,
 as opposed to using its services.

 --Scott David Daniels
 scott.dani...@acm.org

         I am coding in Python.  

         I am accessing a MySQL database.  

         I have a string to instruct the MySQL database to use the
 'rand()' function to randomly choose one of the records in the
 database.  

         I know how to seed it in PHP.  Does anyone know how to see it
 from with Python?  

It sounds like you are using MySQL's rand() function, which means that
whatever SQL command you used to seed it in PHP is the same command
you would use to seed it in Python.

You'll have to give us more information if you want a better answer
than that.


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


Re: Python docs disappointing

2009-08-02 Thread Christian Heimes

Mohan Parthasarathy schrieb:

I am a newbie and about a month old with Python. There is a wealth of
material about Python and I am really enjoying learning Python.

One thing that could have helped Python documentation is that instead of the
very raw doc string, it could have used something like PythonDoc (java doc
style) so that the functions/classes are documented better. At least I am
planning to use PythonDoc for the code that I am going to write. Let me know
if there is a better one..


Several projects are trying to improve the doc strings with an extended 
syntax. Personally I prefer the epytext syntax from epydoc [1]. It's a 
JavaDoc like markup language that extends the raw doc strings with 
useful information.


Christian

[1] http://epydoc.sourceforge.net/manual-epytext.html

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


Registation is open for the 9th PyWeek game programming challenge!

2009-08-02 Thread Richard Jones

The ninth PyWeek challenge will run between:

 Sunday 30th August to Sunday 6th September (00:00UTC to 00:00UTC)

The PyWeek challenge invites entrants to write a game in one week from
scratch either as an individual or in a team. Entries must be developed
in Python, during the challenge, and must incorporate some theme chosen
at the start of the challenge.


REGISTRATION IS NOW OPEN --

Visit the challenge website to sign up, join discussions in the  
message board or read the timetable and rules:


  http://www.pyweek.org/9/


PLANNING FOR THE CHALLENGE --

Make sure you have working versions of the libraries you're going to  
use.

The rules page has a list of libraries and other resources.

Make sure you can build packages to submit as your final submission (if
you're going to use py2exe, make sure you know how to use it and that it
works).

If you don't have access to Linux, Windows or a Mac to test on, contact
friends, family or other competitors to find someone who is able to test
for you.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Skipping a superclass

2009-08-02 Thread Miles Kaufmann

On Aug 2, 2009, at 5:36 AM, Steven D'Aprano wrote:

I have a series of subclasses like this:

class A(object):
   def method(self, *args):
   print Lots of work gets done here in the base class

class B(A):
   def method(self, *args):
   print A little bit of work gets done in B
   super(B, self).method(*args)

class C(B):
   def method(self, *args):
   print A little bit of work gets done in C
   super(C, self).method(*args)


However, the work done in C.method() makes the work done in B.method()
obsolete: I want one to run, or the other, but not both. C does need  
to
inherit from B, for the sake of the other methods, so I want  
C.method()
*only* to skip B while still inheriting from A. (All other methods  
have

to inherit from B as normal.)


This might not be applicable to the larger problem you're trying to  
solve, but for this sample, I would write it as:


class A(object):
def method(self, *args):
self._method(*args)
print Lots of work gets done here in the base class
def _method(self, *args):
pass # or perhaps raise NotImplemented

class B(A):
def _method(self, *args):
print A little bit of work gets done in B

class C(B):
def _method(self, *args):
print A little bit of work gets done in C


So what I have done is change the call to super in C to super(B, self)
instead of super(C, self). It seems to work, but is this safe to do?  
Or

are there strange side-effects I haven't seen yet?


In a diamond-inheritance situation, you may end up skipping methods  
besides just B.method().


-Miles

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


Re: Generate a new object each time a name is imported

2009-08-02 Thread alex23
On Aug 3, 4:07 am, Terry Reedy tjre...@udel.edu wrote:
 Peter Otten wrote:
  Steven D'Aprano wrote:
[...]

Fantastic question, answer  explanation, guys. Well done.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue6595] Make Decimal constructor accept all unicode decimal digits in input.

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Committed to py3k in r74279, release31-maint in r74280.  Leaving open for 
backport to 2.x.

--

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



[issue6595] Make Decimal constructor accept all unicode decimal digits in input.

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Backported to trunk and release26-maint in r74281 and r74282.

--
resolution:  - fixed
status: open - closed

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



[issue6625] UnicodeEncodeError on pydoc's CLI

2009-08-02 Thread Christoph Burgmer

New submission from Christoph Burgmer cburg...@ira.uka.de:

pydoc fails with a UnicodeEncodeError for properly specified Unicode
docstrings (u...) on the command line interface.

See attached patch that encodes the output with the system's encoding.

--
components: Extension Modules
files: unicode.patch
keywords: patch
messages: 91182
nosy: christoph
severity: normal
status: open
title: UnicodeEncodeError on pydoc's CLI
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file14626/unicode.patch

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



[issue2053] IDLE - standardize dialogs

2009-08-02 Thread Guilherme Polo

Guilherme Polo ggp...@gmail.com added the comment:

I have reviewed the latest patch now, it is nice in general but I
dislike the idea of increasing even more EditorWindow. I would really
prefer to put this somewhere else, like.. idlelib/dialogs.py. Also, I'm
inclined to remove this master/parent hiding and continue making it
explicit.

--

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



[issue6619] Remove duplicated function in Lib/inspect.py

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks for the report!  Fixed in r74285 (trunk), r74286 (release26-maint), 
r74287 (py3k) and r74288 (release31-maint).

--
nosy: +marketdickinson
resolution:  - fixed
status: open - closed

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



[issue6604] test_distutils subtest test_get_exe_bytes fails depending on execution order

2009-08-02 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

This was fixed in r71759 and backported in the 2.6 branch in r71765,

thanks for the feedback!

--
resolution:  - wont fix
status: open - closed

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



[issue6620] Variable may be used before first being assigned to in Lib/locale.py

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

So this can happen only if grouping is [0] (or an equivalent iterable).  
Since this is an invalid grouping, I think the appropriate response would 
be for _grouping_intervals([0]) to raise an exception (which is what it 
currently does as soon as you iterate over the result, though this is 
possibly not by design. :)

Vincent, does the attached patch (_grouping_intervals.patch, against py3k) 
silence the pylint warning?

--
nosy: +marketdickinson
Added file: http://bugs.python.org/file14627/_grouping_intervals.patch

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



[issue2698] Extension module build fails for MinGW: missing vcvarsall.bat

2009-08-02 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

The vcvarsall.bat eror is unrelated to the error James and Eric are
mentioned, which is another error fixed in the revision Hagen points.

Lenard, could you re-run it under the latest 2.6 version with the global
option --verbose please ?

--

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



[issue6555] distutils config file should have the same name on both platforms and all scopes

2009-08-02 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

The mac/win difference is with the starting dot because it's impossible
under windows to name a file under the directory browser UI that starts
with a .. You have to be a power-user to do so. (pydistutils.cfg
versus .pydistutils.cfg)

Now for pydistutils.cfg  vs distutils.cfg I don't know why it's like
that. It should be distutils.cfg everywhere imho. Even if the global
and local one are eventually merged. I'll launch a thread about it on
distutils-sig.

Next, setup.cfg is for the current directory because this how you
operate with packages that have setup.py+setup.cfg files : you chdir in
the directory then run a distutils command.

Last, under windows, it should use os.path.expanduser('~') instead of
looking for a HOME variable. this will be fix in any case.

--
nosy: +exarkun
priority:  - normal
resolution:  - accepted
type:  - behavior
versions: +Python 2.7, Python 3.2

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



[issue6622] [RFC] wrong variable used in Lib/poplib.py

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Comparing with trunk, I agree that it seems very likely that 'password' is 
intended here.

It's unfortunate that the test-suite doesn't expose this bug;  it would be 
good to come up with a test that covers this.

--
nosy: +marketdickinson
stage:  - test needed
type:  - behavior
versions: +Python 3.1

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



[issue6621] [RFC] Remove leftover use of Carbon module from Lib/binhex.py

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

As far as I can tell, it looks safe to just remove these two blocks.  
There's a third block that should be removed as well (the second if 
os.name == 'mac': ... in the hexbin function.

--
nosy: +marketdickinson

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



[issue6621] [RFC] Remove leftover use of Carbon module from Lib/binhex.py

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

This should be fixed in the 3.1 maintenance branch as well.

--
versions: +Python 3.1

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



[issue6621] [RFC] Remove leftover use of Carbon module from Lib/binhex.py

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

See also issue 2715.

--

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



[issue2715] Remove carbon-specific code from binhex

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

This came up again recently in issue 6621.

What's the current status of the binhex module in py3k?  It looks as 
though the Carbon-specific code has been *partially* but not completely 
removed.  In particular, there are references to FSSpec remaining, but 
no FSSpec is imported anywhere.

The references to FSSpec are all inside if os.name == 'mac': ...  
blocks.  On my 10.5/Intel and 10.4/PPC systems os.name gives 'posix', so 
these blocks never get executed.

Is it safe to simply remove these blocks?

--
nosy: +marketdickinson

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



[issue6621] [RFC] Remove leftover use of Carbon module from Lib/binhex.py

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Closing as a duplicate of issue 2715.

--
resolution:  - duplicate
status: open - closed
superseder:  - Remove carbon-specific code from binhex

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



[issue2715] Remove carbon-specific code from binhex

2009-08-02 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

From my understanding the mac platform is OS 9, so that code in those 'if' 
blocks can go.

--

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



[issue6626] show Python mimetypes module some love

2009-08-02 Thread Jacob Rus

New submission from Jacob Rus jacobo...@gmail.com:

See discussion started right at the end of the month at
http://mail.python.org/pipermail/python-dev/2009-July/090928.html

And continued at
http://mail.python.org/pipermail/python-dev/2009-August/thread.html

Basically, the mimetypes module is fragile and very confusing code, 
built up over years of feature creep without refactoring or careful 
overall design. I'd like to cut it down to a more manageable code size, 
fix some bugs, update the included list of mime types, and use some nice 
Python features of versions 2.2+. Ideally someone reading the module 
once through would be able to understand what it does.

Patches to be attached shortly.

--
components: Library (Lib)
messages: 91196
nosy: jrus
severity: normal
status: open
title: show Python mimetypes module some love
type: behavior
versions: Python 2.7, Python 3.2

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



[issue2053] IDLE - standardize dialogs

2009-08-02 Thread Tal Einat

Tal Einat talei...@users.sourceforge.net added the comment:

The whole point of this patch is to make the EditorWindow's Text widget
the default master/parent for its dialogs!

IMO this makes sense, since this is a reasonable and intuitive default
for such methods of the EditorWindow object. I understand the explicit
is better than implicit argument, but that doesn't mean that having a
reasonable default value is always wrong. In this case having a default
value both simplifies the code considerably and makes sense, so IMO it
is justified.


Also, please note that the patch actually reduces the size of
EditorWindow.py (both character and line counts) and cleans up the code
in many places. Yes, the definition of the relevant methods is not
trivial, but it is in just one area of the code.

--

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



[issue6627] threading.local() does not work with C-created threads

2009-08-02 Thread Nikolaus Rath

New submission from Nikolaus Rath nikol...@rath.org:

When threads are created by a C extension loaded with ctypes,
threading.local() objects are always empty. If one uses
_threading_local.local() instead of threading.local(), the problem does
not occur. 

More information and example program showing the behaviour:
http://code.google.com/p/fusepy/issues/detail?id=15

--
components: Library (Lib)
messages: 91198
nosy: Nikratio
severity: normal
status: open
title: threading.local() does not work with C-created threads
type: behavior
versions: Python 2.6

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



[issue6608] asctime causing python to crash

2009-08-02 Thread James Abbatiello

James Abbatiello abb...@gmail.com added the comment:

Further investigation shows that MS asctime() doesn't like leap seconds
and causes an assertion when passing (2008, 12, 31, 23, 59, 60, 2, 366,
-1) - 'Wed Dec 31 23:59:60 2008'.

Given that and since asctime() is such a simple function I think it
makes more sense to roll our own.  Attached is a rough patch which does
this.  It pulls the bounds checking used in strftime() out into its own
function so it can be used in both places.  Overriding ctime() is
necessary because Windows decided to use  %02d instead of %3d to
print the day of the month.  Without overriding ctime() the output of
ctime(t) would be different from asctime(localtime(t)) and cause
test_conversion() to fail.  There is a USE_SYSTEM_ASCTIME switch to
decide whether to use the system asctime() or the internal one.

--
keywords: +patch
Added file: http://bugs.python.org/file14628/asctime.patch

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



[issue6626] show Python mimetypes module some love

2009-08-02 Thread Jacob Rus

Jacob Rus jacobo...@gmail.com added the comment:

This diff should leave the semantics of the module essentially unchanged 
(including lazy-loading of default files), and also leave the particular 
MIME types used unchanged, even though these are out of date and should be 
updated; a subsequent suggested version will address that, perhaps after 
some discussion.

--
keywords: +patch
Added file: http://bugs.python.org/file14629/mimetypes-2.diff

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



[issue2715] Remove carbon-specific code from binhex

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks, Brett.  I've removed those blocks in r74289 (py3k) and r74290 
(release31-maint).

--

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



[issue2715] Remove carbon-specific code from binhex

2009-08-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

It looks to me as though this issue can now be closed.  Ronald, any 
comments?

--
status: open - pending

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



[issue6626] show Python mimetypes module some love

2009-08-02 Thread Jacob Rus

Jacob Rus jacobo...@gmail.com added the comment:

Here is a version of the patch which does away with the lazy loading: 
these are a small handful of easy-to-parse ~40k files; if the import takes 
an extra eye-blink, it shouldn't be too big a deal.

--
Added file: http://bugs.python.org/file14630/mimetypes3.diff

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



[issue6626] show Python mimetypes module some love

2009-08-02 Thread Jacob Rus

Jacob Rus jacobo...@gmail.com added the comment:

A fixed version of the patch from msg91200, 2009-08-02 20:08

--
Added file: http://bugs.python.org/file14631/mimetypes2.diff

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



[issue6626] show Python mimetypes module some love

2009-08-02 Thread Jacob Rus

Jacob Rus jacobo...@gmail.com added the comment:

This version (#4) switches to expressing the default types as a list of 
tuples instead of as a dict, so that we can include duplicate rows so that 
reverse type - extension lookups will behave properly, once we start 
changing the actual content of the defaults.

The types_map and common_types dictionaries (aliases to the singleton 
MimeTypes object's types_map property) have been left behaving as before 
for backwards compatibility.

The tests still pass.

--
Added file: http://bugs.python.org/file14632/mimetypes4.diff

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



[issue2053] IDLE - standardize dialogs

2009-08-02 Thread Guilherme Polo

Guilherme Polo ggp...@gmail.com added the comment:

I thought the main point of this issue was to define standard functions,
methods, classes (or something in that sense), in order to make the
creation of tk dialogs uniform across IDLE.

Right now it seems reasonable to keep the parent hidden, but I think it
may not help much for maintaining. I really consider a good idea to
define explicitly who is the parent of a dialog, it wasn't an attempt to
refer to the phrase you cited.

I trust you it reduces the size on that file, I really didn't count how
many lines were removed and how many were added, but these dialogs can
be used anywhere around IDLE so I don't see why keeping them inside
EditorWindow is a good idea. It would reduce even more (some few lines)
EditorWindow's size doing so, and it would make more sense as I see.

--

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



[issue6616] PyList_APPEND (append without incref)

2009-08-02 Thread Raymond Hettinger

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

 I know the API well enough (with manipulating dicts/lists etc) 
 and I still want this function for the sake of convenience.

Given that your level of skill is higher than the average user,
I recommend adding this to your own standard libraries or headers.
No need to muck-up the environment for everyone else.

--
assignee:  - rhettinger
resolution:  - rejected
status: open - closed

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



[issue6626] show Python mimetypes module some love

2009-08-02 Thread Jacob Rus

Jacob Rus jacobo...@gmail.com added the comment:

Here is a list I generated of all the current Apache mime.types:

I would just as soon include this in the python standard library, either 
just the Apache file as is, or even these python object literals (maybe 
in a file outside of mimetypes.py), and then *not* import from Apache 
files by default, to cut down on external dependencies. There are 
several alternate MIME types for various types that should be added to 
this list (in earlier positions so they only are used in the type - 
extension map).

The only issue is that some users may have added to their Apache 
mime.types files for the sake of getting mailman or other python 
programs to do what they want. So I'm not entirely sure to what extent 
we should be 100% backwards compatible in such edge cases. 

My personal opinion is that the 'strict' option is unnecessary and 
should be set to do nothing, because users are more likely to want the 
predictable behavior where an unorthodox type gives back the proper 
extension, than the behavior where their code fails unless they pass a 
flag in: I don't see any reason for a user to want a 'type doesn't 
exist' message back for non-registered types. This isn't a test for 
IANA registration module.

--
Added file: http://bugs.python.org/file14633/apache_mimetypes.py

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



[issue1628205] socket.readline() interface doesn't handle EINTR properly

2009-08-02 Thread Rhett Garber

Rhett Garber rhe...@gmail.com added the comment:

I've hit this issue as well.
Attached is an updated patch to 2.6 branch and a test case.
I wrote up more details here:
http://nullhole.com/2009/08/02/anatomy-of-a-regression-test/

--
nosy: +rhettg
Added file: http://bugs.python.org/file14634/diff

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



[issue6628] IDLE freezes after encountering a syntax error

2009-08-02 Thread brian

New submission from brian omniscient.br...@gmail.com:

Running Python 3.1/ IDLE, which was installed on top of a Python 2.5.4
install, Mac OSX 10.4

This seems like such an obvious bug, but I can't find it in the current
list of issues - so I suspect that it may not be reproducible on other
computers, but it's certainly reproducible on my laptop.

If I run a module with (any?) syntax error (for example,

for i in range(10) #missing semicolon
print i

the interpreter will catch it and send you to fix it. Then, any
subsequent attempts to run that same module will freeze IDLE. The
problem doesn't occur if you run a different module.

--
components: IDLE
messages: 91210
nosy: brian89
severity: normal
status: open
title: IDLE freezes after encountering a syntax error
type: crash
versions: Python 3.1

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