Re: sending bytes to parallel port

2006-07-29 Thread Diez B. Roggisch
 
   fd = open('/dev/ppi0','w')
   fcntl.ioctl(fd.fileno(),'PPISCTRL',1000)
 Traceback (most recent call last):
  File stdin, line 1, in ?
 TypeError: an integer is required
 
 i guess i'm failing to properly define the int i need for the 8byte 
 value ineed to send the port to set pins high /low

Python doesn't know about PPISCTRL - it has no way of knowing all 
secret, OS-specific constants for ioctl-calls.

So, you need to figure out the numeric value of that constant .- look it 
up in the appropriate header-file.

Then, you do have the next problem with passing that 1000 value of 
yours. ioctl expects strings or buffers as parameters which contain a 
byte-representation of the value you want to set. This is an snippet I 
use to read the event device capabilities under linnux:


buf = array.array('c', [' ' for i in xrange(EV_MAX / 8 + 1)])
fcntl.ioctl(self._fd, EVIOCGBIT(0, len(buf)), buf, True)
caps = struct.unpack(I, buf)[0]

HTH,

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


Re: sending bytes to parallel port

2006-07-29 Thread Timothy Smith
Diez B. Roggisch wrote:
   fd = open('/dev/ppi0','w')
   fcntl.ioctl(fd.fileno(),'PPISCTRL',1000)
 Traceback (most recent call last):
  File stdin, line 1, in ?
 TypeError: an integer is required

 i guess i'm failing to properly define the int i need for the 8byte 
 value ineed to send the port to set pins high /low
 

 Python doesn't know about PPISCTRL - it has no way of knowing all 
 secret, OS-specific constants for ioctl-calls.

 So, you need to figure out the numeric value of that constant .- look it 
 up in the appropriate header-file.

 Then, you do have the next problem with passing that 1000 value of 
 yours. ioctl expects strings or buffers as parameters which contain a 
 byte-representation of the value you want to set. This is an snippet I 
 use to read the event device capabilities under linnux:


 buf = array.array('c', [' ' for i in xrange(EV_MAX / 8 + 1)])
 fcntl.ioctl(self._fd, EVIOCGBIT(0, len(buf)), buf, True)
 caps = struct.unpack(I, buf)[0]

 HTH,

 Diez
   
*sigh*
if only pyparallel would install

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


Re: sending bytes to parallel port

2006-07-29 Thread Diez B. Roggisch
 *sigh*
 if only pyparallel would install

*sigh* If only you said _what_ failed we could maybe help you make it 
work... :)

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


Re: How to find difference in years between two dates?

2006-07-29 Thread thebjorn
John Machin wrote:
 I don't understand. The examples that I showed went from the last day
 of a month to the last day of another month. [...]

Q1: is ((date-4days)+4days) == date?
Q2: is (((date-4days)+1month)+4days) == date+1month?

Ok, let's use Python'ish syntax (including numbering the days from 0
upwards, and backwards from -1, the last day of the month), you want
the last day of a month plus a month be the last day of the next
month. Simplistically, something like:

   month[-1] + 1 month == (month+1)[-1]   {last-to-last}

but that's obviously not the entire rule you want, unless 4-30 + 1
month == 5-31? So you would also like to have:

   month[i] + 1 month = (month+1)[i] {lock-step}

we'd like yesterday to be a day ago? So for suitable i:

   month[i] - 1 day == month[i-1]  {yesterday-1}
   month[0] - 1 day == (month-1)[-1]   {yesterday-2}

which leads to a natural definition for when tomorrow is:

   month[i] + 1 day == month[i+1]   {tomorrow-1}
   month[-1] + 1 day == (month+1)[0]{tomorrow-2}

So far so good. Now let's count backwards:

   month[-1] - 1 day == month[-2]  by: yesterday-1
   month[-2] - 1 day == month[-3]  by: yesterday-1
   month[-3] - 1 day == month[-4]  by: yesterday-1
   etc.

In other words, if you insist that the last day of the month is a well
defined concept and you want a day ago to be yesterday then month[-4],
the forth-to-last day of the month, is necessarily also well
defined. Having a well defined month[i], I'll apply your rules for
adding a month:

   month[-4] + 1 month == (month+1)[-4]   by: last-to-last

but you don't like this, because that means that e.g.:

   april[-4] + 1 month == may[-4]
   april[27] + 1 month == may[28]

which in addition to {lock-step}:

   april[27] + 1 month == may[27]

either gives an inconsistent, ill-formed, or FUZZY system (although
I would call it regular ;-)

My approach is simpler since it doesn't define addition, only
subtraction on valid dates, so if I switch to representing dates as
(month, day):

   (a, b) - (c, d) := a - c   iff b  d   {subtract}
 else a - c - 1

{subtract} is irregular but well defined for all valid dates (it will
always give you an answer, and it's always the same answer ;-) :

   (2,29) - (1,31) == 0
   (3,1) - (1,31) == 2

I can add day addition and still be ok:

   (m,d) + 1 day := (m,d+1){tomorrow-1}
   (m,-1) + 1 day := (m+1,0)   {tomorrow-2}
   (m,d) - 1 day := (m,d-1)   {yesterday-1}
   (m,0) - 1 day := (m-1,-1)  {yesterday-2}

Now my system is well-formed and consitent, even though it is
irregular, and it will answer yes to Q1 above. I can't see a way of
adding month addition to this and stay consistent without enumerating
special cases for every month, so Q2 can't even be asked in my system.

  You're entitled to your opinion.

 And you to yours :-)

Ok, I've explained why I hold mine... You care to do the same?

-- bjorn

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


Re: sending bytes to parallel port

2006-07-29 Thread Timothy Smith
Diez B. Roggisch wrote:
 *sigh*
 if only pyparallel would install
 

 *sigh* If only you said _what_ failed we could maybe help you make it 
 work... :)

 Diez
   
titan# python setup.py install
running install
running build
running build_py
Traceback (most recent call last):
  File setup.py, line 19, in ?
package_data = data_files
  File /usr/local/lib/python2.4/distutils/core.py, line 149, in setup
dist.run_commands()
  File /usr/local/lib/python2.4/distutils/dist.py, line 946, in
run_commands
self.run_command(cmd)
  File /usr/local/lib/python2.4/distutils/dist.py, line 966, in
run_command
cmd_obj.run()
  File /usr/local/lib/python2.4/distutils/command/install.py, line
506, in run
self.run_command('build')
  File /usr/local/lib/python2.4/distutils/cmd.py, line 333, in run_command
self.distribution.run_command(command)
  File /usr/local/lib/python2.4/distutils/dist.py, line 966, in
run_command
cmd_obj.run()
  File /usr/local/lib/python2.4/distutils/command/build.py, line 112,
in run
self.run_command(cmd_name)
  File /usr/local/lib/python2.4/distutils/cmd.py, line 333, in run_command
self.distribution.run_command(command)
  File /usr/local/lib/python2.4/distutils/dist.py, line 965, in
run_command
cmd_obj.ensure_finalized()
  File /usr/local/lib/python2.4/distutils/cmd.py, line 117, in
ensure_finalized
self.finalize_options()
  File /usr/local/lib/python2.4/distutils/command/build_py.py, line
60, in finalize_options
self.data_files = self.get_data_files()
  File /usr/local/lib/python2.4/distutils/command/build_py.py, line
120, in get_data_files
filenames = [
  File /usr/local/lib/python2.4/distutils/command/build_py.py, line
128, in find_data_files
globs = (self.package_data.get('', [])
AttributeError: 'NoneType' object has no attribute 'get'
titan#

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


Re: HERE I BUILT A QUICK MATRIX TOOOK 5 MINS

2006-07-29 Thread H J van Rooyen
Grant Edwards [EMAIL PROTECTED] wrote:

| On 2006-07-28, Paul McGuire [EMAIL PROTECTED] wrote:
|  ...USING A INFINITE MAGENTIC
|  FIELD!!!
| 
|  I have a vision of a sweeping magenta fabric rippling through the cosmos.
| 
|  Perhaps a mauvic, cyanic, or even aubergenic field would be more stylish.
|
| depends on what shoes you choose to go with it.
|
| --
| Grant Edwards   grante Yow!  My uncle Murray
|   at   conquered Egypt in 53
|visi.comB.C. And I can prove
|it too!!

I find myself in the unenviable position that I can no longer remember the
colour of magic as expressed in Terry Pratchett's books - was it something like
Octarine?

- Hendrik

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


Re: How to force a thread to stop

2006-07-29 Thread H J van Rooyen
Paul Rubin http://[EMAIL PROTECTED] Writes:



| H J van Rooyen [EMAIL PROTECTED] writes:
|  *grin* - Yes of course - if the WDT was enabled - its something that
|  I have not seen on PC's yet...
|
| They are available for PC's, as plug-in cards, at least for the ISA
| bus in the old days, and almost certainly for the PCI bus today.

That is cool, I was not aware of this - added to a long running server it will
help to make the system more stable - a hardware solution to hard to find bugs
in Software - (or even stuff like soft errors in hardware - speak to the
Avionics boys about Neutrons) do you know who sells them and what they are
called? -

Sorry if this is getting off topic on this thread... ( in a way it is on topic -
because a reset will stop a thread every time...)

- Hendrik

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


Re: How to force a thread to stop

2006-07-29 Thread H J van Rooyen

Dennis Lee Bieber [EMAIL PROTECTED] wrote:

| On Fri, 28 Jul 2006 08:27:18 +0200, H J van Rooyen
| [EMAIL PROTECTED] declaimed the following in comp.lang.python:
|
| 
|  Dennis - did your OS not have a ticker running?
| 
| That ancient machine, while round-robin, multi-priority,
| pre-emptive, seemed still to only deliver signals on deliberate
| blocking calls -- perhaps to prevent potential corruption if the signal
| had been delivered(handled) in the middle of some multi-instruction
| sequence. The OS level would see the ctrl-c, and set the signal bit
| in the task header -- but without the blocking I/O (typically), the code
| to activate a registered signal handler would not be invoked. Operation
| was something like: submit I/O request, AND(signal bits, signal mask) --
| invoke handler if non-zero, block for I/O return [or return directly for
| asynchronous I/O request]

- Hah! - so it *could* have responded - it just chose not to - so it was pre
emptive - but hey - what is different between modern OS's and what you are
describing? - it seems to me that there is just a lot of extra memory control,
as well as control over who is allowed to do what - in an effort to make things
more stable - and all this stuff just eats cycles and slows you down... (or
alternatively, makes the hardware more complex and expensive...)

But to get back to the OP's problem - basically the thread has to see some sort
of variable change, or receive a message (by examining something to see if there
is a message there) and then kill itself, or the OS must be told to stop giving
control back to the thread in question - which option will leave all the loose
ends in the thread loose...

So its either: hey mr nice thread please stop - or hey Mr OS - kill that
thread ... - now from the OS viewpoint - if the application implements some
threading itself - it may not even know that the thread exists - OS threads are
known variously as Tasks or Processes or Running Programmes - so using the
big guns on a thread may not be possible without killing the parent too...

So if you want to use the OS to kill the thread - it has to be a formal OS
thread - something started with a call to the OS, and not something that an
application implements by itself - and I am not familiar enough with Python
threading and dummy threading to pretend to know what is under the hood - but
I haven't seen an additional process appearing on my Linux box when I start a
thread - so its either something that Python does on its own without
registering the new thread with Linux - or I haven't looked closely enough...

So if somebody else can take over here, we might convince the OP that hey mr
nice thread is the way to go, even in the case that the thread in question is
an OS Process - after all - there has to be inter - task communication in any
case - so the cleanest solution is to build the kill in right from scratch...

Why do I think of COBOL:

read master_file_record at end go to end_routine

HTH   - Hendrik


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


Re: sending bytes to parallel port

2006-07-29 Thread H J van Rooyen
Timothy Smith [EMAIL PROTECTED] wrote:


| Grant Edwards wrote:
|  On 2006-07-28, Timothy Smith [EMAIL PROTECTED] wrote:
| 
| 
|  i've been trying to send an 8 byte string to my parallel port
|  under freebsd. the purpose is it to control a relay board. the
|  board simply responds to the output byte coming from the port.
|  eg.  0001 will set pin 1 high and flick the relay open.
|  todate i've attempted this with merely open() on /dev/ppi0 and
|  numpy for the byte array, but i just can't seem to get it
|  working. i know the parallel port works and i know the relay
|  board works (tested it with it's own windows ultility) so it's
|  just my crappy programming keeping me from success.
| 
| 
|  I'm guessing there's an implied request for help there
|  somewhere.  This would be a good start:
| 
|http://www.google.com/search?q=python+parallel+port
| 
|  I'd particularly recommend taking a look at the pyparallel
|  module found here:
| 
|http://pyserial.sourceforge.net/
| 
|  I've not used pyparallel, but based on my experience with
|  pyserial and some of Chris Liechti's other work, I'd bet
|  dollars to doughnuts it's your best option.
| 
| 
| yes, i did try pyparallel however it will not install on freebsd,
| setup.py errors.
|
| and yes i've done quite a bit of googling, i never expected it to be
| this difficult. i've done work with serial ports before. never parallel but.

What is on the other side of the link? - if its a small 8 bit micro - you may
simply be going too fast...

- Hendrik

|

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


Re: War chest for writing web apps in Python?

2006-07-29 Thread Rob Sinclar
On Saturday 29 July 2006 03:43, Nick Vatamaniuc wrote:
 Aptitude, are you still using that? Just use Synaptic on Ubuntu. The
 problem as I wrote in my post before is that for some IDEs you don't
 just download an executable but because they are written for Linux
 first, on  Windows you have to search and install a lot of helper
 libraries that often takes quite a bit of time.

 And why do you want to spend half an hour searching for stuff when you
 can do just spend 1 minute in a nice graphical installer or use apt-get
 install on the command line to  install it.

 I am using Ubuntu primarily because it has the .deb system which I
 found to be much better mentained and which deals with dependecies a
 lot better.

 Nick V.

Synaptic is using aptitude as back-end (this is serious).
I also find deb system being the best. Managed with aptitude, not apt.
Windows is definitely worth the effort.

Best Regards,
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: metaclass : parse all class once before doing anything else ?

2006-07-29 Thread Diez B. Roggisch
Laurent Rahuel schrieb:
 I got a metaclass named Foo


I have the impression that you are not talking about a meta-class, but a 
normal class here.

 Then I got two others classes:
 
 class Bar(Foo):
 pass
 
 class Baz(Foo):
 pass
 
 I know how to add some attrs, methods to Bar and Baz when the module is
 loaded but I need to do something more :
 
 Before adding anything to these classes, 
 1 - I need to parse all defined Foo classes
 2 - sort them 
 3 - parse this sorted list to add attrs and methods.
 
 This seems to be really to clever for me ;-(
 
 Any idea ?

Why do you want to do this? It is in that way not possible - python has 
no preprocessing step that would allow this.

I suggest you explain to us what you are after here, and then we might 
come up with a solution.

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


Re: War chest for writing web apps in Python?

2006-07-29 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Rob Sinclar
wrote:

 Synaptic is using aptitude as back-end (this is serious).

Why can I deinstall aptitude without deinstalling synaptic then!?

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to force a thread to stop

2006-07-29 Thread Paul Rubin
H J van Rooyen [EMAIL PROTECTED] writes:
 That is cool, I was not aware of this - added to a long running server it will
 help to make the system more stable - a hardware solution to hard to find bugs
 in Software - (or even stuff like soft errors in hardware - speak to the
 Avionics boys about Neutrons) do you know who sells them and what they are
 called? -

I usually try froogle.com to find stuff like that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HERE I BUILT A QUICK MATRIX TOOOK 5 MINS

2006-07-29 Thread Diez B. Roggisch
 I find myself in the unenviable position that I can no longer remember the
 colour of magic as expressed in Terry Pratchett's books - was it something 
 like
 Octarine?

AFAIK yes.

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


Re: War chest for writing web apps in Python?

2006-07-29 Thread Diez B. Roggisch
 Synaptic is using aptitude as back-end (this is serious).

No. It uses apt.

 I also find deb system being the best. Managed with aptitude, not apt.
 Windows is definitely worth the effort.

aptitude as well as synaptic both depend transitive upon debconf, which 
depends on apt.

Use

apt-cache dotty synaptic

to explore the dependency-graph.

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


Re: How to force a thread to stop

2006-07-29 Thread Damjan
 | A common recovery mechanism in embedded systems is a watchdog timer,
 | which is a hardware device that must be poked by the software every
 | so often (e.g. by writing to some register).  If too long an interval
 | goes by without a poke, the WDT hard-resets the cpu.  Normally the
 | software would poke the WDT from its normal periodic timing routine.
 | A loop like you describe would stop the timing routine from running,
 | eventually resulting in a reset.
 
 *grin* - Yes of course - if the WDT was enabled - its something that I
 have not seen on PC's yet...

The intel 810 chipset (and all after that) has a builtin watchdog timer -
unfortunetally on some motherboards it's disabled (I guess in the BIOS).

How do I know that?
Once I got Linux installed on a new machine and although the install
went without a problem, after the first boot the machine would reboot on
exactly 2 minutes. 
After a bit of poking around I found that hotplug detected the WDT support
and loaded the driver for it (i8xx_tco), and it seems the WDT chip was set
to start ticking right away after the driver poked it. 



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


Re: metaclass : parse all class once before doing anything else ?

2006-07-29 Thread Paddy

Laurent Rahuel wrote:
 Hi,

 I have a much to smart problem for my brain.

 Here is the deal :

 I got a metaclass named Foo

 Then I got two others classes:

 class Bar(Foo):
 pass

 class Baz(Foo):
 pass

 I know how to add some attrs, methods to Bar and Baz when the module is
 loaded but I need to do something more :

 Before adding anything to these classes,
 1 - I need to parse all defined Foo classes
 2 - sort them
 3 - parse this sorted list to add attrs and methods.

 This seems to be really to clever for me ;-(

 Any idea ?

 Regards,

 Laurent.

I, like Diez am unsure of why you would need what you have asked for,
but maybe this will help.

You can keep  track of all instances of a class by this kind of thing:

 class C1(object):
... inst = []
... def __init__(self):
... self.inst.append(self)
...
 i1 = C1()
 i2 = C1()
 print i1,i2
__main__.C1 object at 0x0128C970 __main__.C1 object at 0x0128CA50
 print C1.inst
[__main__.C1 object at 0x0128C970, __main__.C1 object at
0x0128CA50]


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


testing for data type

2006-07-29 Thread Jonathan Bowlas








Hi Listers,



I have a requirement to test for a data type could someone
tell me if this is possible in python?



Basically I have a ZPT in Zope that users can select checkboxes
in a form which pass arguments for a python function, however if there is only
one checkbox selected it is passed as a string whereas more than one checkbox
is passed as a list. Therefore if my function is required to perform an action
based on each argument passed in the list the function works correctly but if
it is passed as a string nothing happens.



This is my function:

selecteddeptcodes = context.REQUEST.DEPTCODE

currentstatus = context.REQUEST.STATUS



if currentstatus == 'pending':

for dptcd in selecteddeptcodes:

 context.changetolive(DEPTCODE=dptcd)

if currentstatus == 'old':

for dptcd in selecteddeptcodes:

 context.changetopending(DEPTCODE=dptcd)

return context.pub_dept_form(context, context.REQUEST,
message='Updated Status')



The argument in question is selecteddeptcodes.



I tried to make my function conditional based on the length
of the argument passed but if its just one checkbox value passed the
length of the argument is 2 (which is the number of chars passed in the string)
and if there are two checkboxes the length of the argument (which is the number
of items in the list) is also 2. So that doesnt help.



Any assistance would be appreciated.



Jon






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

Partial Classes - Aspects

2006-07-29 Thread Dr. Peer Griebel
I'm currently writing a small toy application to support symbolic
algebra.  Therefore I implemented some classes Term, Var, Number, Sum,
Product, Power.  These classes are tightly coupled.  So it is not
possible to organize them in distinct files. This would result in
cyclic imports.

To manage the complexity I implemented some sort of aspect oriented
programming (perhaps aspect oriented programming is not quite right in
this context...). That is I implemented a mechanism to dynamically add
methods to existing classes.  This is similar to the thread Partial
classes discussed in this list.  Therefore hereby offer some use case
for partial classes.

The aspects I already implemented are amongst others: pretty printing,
differentiation, expansion of terms.  The aspect for expansion looks
like this:


# -*- coding: iso-8859-1 -*-
__aspect__ = Expand

class TermExpand:
def expand(self):
return self

class SumExpand:
def expand(self):
...

def expandSum(term, sum):
# some helper function
...

class ProductExpand:
def expand(self):
...

class PowerExpand:
def expand(self):
...



The code to import an aspect into existing classes accepts as a
parameter the name of a module.  The module will be imported.
Afterwards the code iterates over all elements defined in the module.
If it is a (specially named) class all methods will be copied to the
original class.  If it is a (top level) function it will be copied into
the global namespace.  E.g. the method expand of the class TermExpand
will be copyied to the base class Term.

The difficulty with this approach is that the classes' methods and the
functions do operate in the wrong global namespace.  Since these
functions/methods are located in their own module they get their own
namespace.  To correct this I have to use new.function() to create new
methods/functions with the correct namespace (which is the base
module's namespace).

So my questions boil down to this:

* Do you think this is a sound approach to structure my code?
* I don't like the necessity to modify the functions. Is there a
simpler approach? 

Thanks,
  Peer

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


Re: Comma is not always OK in the argument list?!

2006-07-29 Thread Roman Susi
Nick Vatamaniuc wrote:

True, that is why it behaves the way it does, but which way is the
correct way? i.e. does the code need updating or the documentation?

  

Perhaps, someone can make a bug report... IMHO, docs are wrong.

-Roman

-Nick V.

[EMAIL PROTECTED] wrote:
  

Nick Vatamaniuc wrote:


Roman,

According to the Python call syntax definition
(http://docs.python.org/ref/calls.html) commas should be allowed, so it
seems like a minor bug.  Here are the  lines in question:
-http://docs.python.org/ref/calls.html---
call ::= primary ( [argument_list [,]] )
argument_list::=positional_arguments [, keyword_arguments] [, *
expression] [, ** expression]
 | keyword_arguments [, * expression] [, ** expression]
| * expression [, ** expression]
| ** expression
--
If you notice in the 'call' definition, no matter what the
'argument_list' is, it can be followed by an optional ',' right before
the closing ')'. Your code is a counterexample to this. Here is a more
exhaustive example:

  

Actually, in the real BNF it's not allowed:

http://svn.python.org/view/python/trunk/Grammar/Grammar?rev=46209view=markup

parameters: '(' [varargslist] ')'
varargslist: ((fpdef ['=' test] ',')*
  ('*' NAME [',' '**' NAME] | '**' NAME) |
  fpdef ['=' test] (',' fpdef ['=' test])* [','])
fpdef: NAME | '(' fplist ')'



  


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


Re: Need a compelling argument to use Django instead of Rails

2006-07-29 Thread Vincent Delporte
On Sat, 29 Jul 2006 04:07:12 GMT, Tim Roberts [EMAIL PROTECTED] wrote:
Exactly.  The Python interpreter can take a significant fraction of a
second to start.  For the typical short web request, the overhead can add
up.

On the other hand, unless you're handling dozens of requests per minute,
users are unlikely to notice.

You can also keep session state in memory instead of spilling to disk, and
you can keep database sessions open.

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


Re: War chest for writing web apps in Python?

2006-07-29 Thread Rob Sinclar
  Synaptic is using aptitude as back-end (this is serious).

 Why can I deinstall aptitude without deinstalling synaptic then!?

 Ciao,
   Marc 'BlackJack' Rintsch

Hi,
This is because Aptitude is an independant console application
that is very useful to users working on linux machines without
X server installed.

Synaptic is the interface which leads the underlying application.
Synaptic is often installed with a 
$ aptitude install synaptic

Best Regards,
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: War chest for writing web apps in Python?

2006-07-29 Thread gslindstrom
Sybren Stuvel wrote:
 Vincent Delporte enlightened us with:
  I'm thinking of using Python to build the prototype for a business
  web appplication.

 Why just the prototype?


I don't know about Vincent, but I once worked in a C++ shop where all
other languages were actively discouraged.  I would build my prototypes
in Python to show proof of concept because I could do it quickly.  It
was also nice to show project managers so they could verify it was what
they wanted us to build before we dedicated a full time effort to
development.

I recall once prototype I created in wxWindows; when I showed it to my
boss he exclaimed That's Python!?.  He was amazed because it looked
just like the windows apps we developed!

Having moved on to another company where we develop in Python
full-time, I hear my former shop now has many Python (and Perl and
Java) programmers.

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


Re: War chest for writing web apps in Python?

2006-07-29 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Rob Sinclar
wrote:

  Synaptic is using aptitude as back-end (this is serious).

 Why can I deinstall aptitude without deinstalling synaptic then!?


 This is because Aptitude is an independant console application
 that is very useful to users working on linux machines without
 X server installed.

I know what aptitude is…
 
 Synaptic is the interface which leads the underlying application.

…but I ask why I can deinstall it and still use synaptic if it's using
aptitude as back-end as you seriously claim!?

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Fastest Way To Loop Through Every Pixel

2006-07-29 Thread Chaos

nikie wrote:
 Chaos wrote:

  As my first attempt to loop through every pixel of an image, I used
 
  for thisY in range(0, thisHeight):
  for thisX in range(0, thisWidth):
#Actions here for Pixel thisX, thisY
 
  But it takes 450-1000 milliseconds
 
  I want speeds less than 10 milliseconds

 Milliseconds don't mean much unless we knew how big your images are and
 what hardware you're using.

 Have you considered using NumPy? Assuming you can get the image into a
 numpy array efficiently, the actual algorithm boils down to something
 like this:

 grey = r*0.3 + g*0.59 + b*0.11
 index = grey.argmin()
 x,y = index%step, index/step
 v = grey[x,y]

 where r,g,b and grey are numpy.ndarray objects; The arithmetic
 operators and the argmin-function are implemented in C, so you can
 expect decent performance. (the 4 lines above take about 80 ms for a
 1000x1000 image on my PC)

 If that's not enough, you might want to use some specially optimized C
 library for this purpose. (I'd suggest Intel's IPP, but there are
 others).

Can you give me an example of geting an image into a numpy array?

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


Re: Fastest Way To Loop Through Every Pixel

2006-07-29 Thread Chaos

nikie wrote:
 Chaos wrote:

  As my first attempt to loop through every pixel of an image, I used
 
  for thisY in range(0, thisHeight):
  for thisX in range(0, thisWidth):
#Actions here for Pixel thisX, thisY
 
  But it takes 450-1000 milliseconds
 
  I want speeds less than 10 milliseconds

 Milliseconds don't mean much unless we knew how big your images are and
 what hardware you're using.

 Have you considered using NumPy? Assuming you can get the image into a
 numpy array efficiently, the actual algorithm boils down to something
 like this:

 grey = r*0.3 +

 g*0.59 + b*0.11
 index = grey.argmin()
 x,y = index%step, index/step
 v = grey[x,y]

 where r,g,b and grey are numpy.ndarray objects; The arithmetic
 operators and the argmin-function are implemented in C, so you can
 expect decent performance. (the 4 lines above take about 80 ms for a
 1000x1000 image on my PC)

 If that's not enough, you might want to use some specially optimized C
 library for this purpose. (I'd suggest Intel's IPP, but there are
 others).

I really do not understand the code. Where did you get the varibales r,
g, b and step and what does v produce?

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


Re: non-blocking PIPE read on Windows

2006-07-29 Thread Antonio Valentino
placid [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Hi all,
 
 I have been looking into non-blocking read (readline) operations on
 PIPES on windows XP and there seems to be no way of doing this. Ive
 read that you could use a Thread to read from the pipe, but if you
 still use readline() wouldnt the Thread block too?

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

 What i need to do is, create a process using subprocess.Popen, where
 the subprocess outputs information on one line (but the info
 continuesly changes and its always on the same line) and read this
 information without blocking, so i can retrieve other data from the
 line i read in then put this in a GUI interface.
 
 
 readline() blocks until the newline character is read, but when i use
 read(X) where X is a number of bytes then it doesnt block(expected
 functionality) but i dont know how many bytes the line will be and its
 not constant so i cant use this too.
 
 Any ideas of solving this problem?
 
 
 Cheers

I realized something very similar to what you described in 

http://sourceforge.net/projects/bestgui

- the subprocess2.py module realizes the non blocking I/O
- the outputparser.py module processes the output from the controlled
process and updates the progress-bar, the status-bar and the log
messages in the GUI. Incomplete lines are stored in a buffer and
processed at the next read.

ciao

-- 
Antonio Valentino



-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comma is not always OK in the argument list?!

2006-07-29 Thread Nick Vatamaniuc
Roman,

The way  I see it, it could be either way. In other words if I can
write f(1,2,3) and f(1,2,3,) I should also be able to write
f(1,*[2,3],). It is a really small detail but there sould be some
consistency. Either no extra commas for all kinds of argument types or
extra commas for _all_ of them. It seems though also that if it is
possible to do it with lists, tuples and dictionaries, it should also
be possible to do it with argument lists. In other words if (1,2,3,)
makes sense so should func(1,2,3,) even when written as
func(1,2,*[3],).

Well you are the one who discovered this so you shoud be the one
submitting the bug report! Here is PEP 3 page with the guidelines for
bug reporting:
http://www.python.org/dev/peps/pep-0003/

Just mark it as a very low priority since it is more of a cosmetic bug
than a serious showstopper.

-Nick V


Roman Susi wrote:
 Nick Vatamaniuc wrote:

 True, that is why it behaves the way it does, but which way is the
 correct way? i.e. does the code need updating or the documentation?
 
 
 
 Perhaps, someone can make a bug report... IMHO, docs are wrong.

 -Roman

 -Nick V.
 
 [EMAIL PROTECTED] wrote:
 
 
 Nick Vatamaniuc wrote:
 
 
 Roman,
 
 According to the Python call syntax definition
 (http://docs.python.org/ref/calls.html) commas should be allowed, so it
 seems like a minor bug.  Here are the  lines in question:
 -http://docs.python.org/ref/calls.html---
 call ::= primary ( [argument_list [,]] )
 argument_list::=positional_arguments [, keyword_arguments] [, *
 expression] [, ** expression]
| keyword_arguments [, * expression] [, ** expression]
 | * expression [, ** expression]
 | ** expression
 --
 If you notice in the 'call' definition, no matter what the
 'argument_list' is, it can be followed by an optional ',' right before
 the closing ')'. Your code is a counterexample to this. Here is a more
 exhaustive example:
 
 
 
 Actually, in the real BNF it's not allowed:
 
 http://svn.python.org/view/python/trunk/Grammar/Grammar?rev=46209view=markup
 
 parameters: '(' [varargslist] ')'
 varargslist: ((fpdef ['=' test] ',')*
   ('*' NAME [',' '**' NAME] | '**' NAME) |
   fpdef ['=' test] (',' fpdef ['=' test])* [','])
 fpdef: NAME | '(' fplist ')'
 
 
 
   
 

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


Re: Client/Server Question

2006-07-29 Thread Dennis Benzinger
[EMAIL PROTECTED] wrote:
 Is os.system() going to be deprecated in future ?.I read somewhere.
 [...]

Sometime in the future it will. But that won't happen soon. Read the 
second paragraph of Backwards Compatibility in the subprocess PEP 
http://www.python.org/dev/peps/pep-0324/.


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


system programign

2006-07-29 Thread oqestra
may i use python to read a file and output its content to another file
which is not created yet and i don't want to use  to do this in
linux? how do you do ? oqestra.

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


=?utf-8?Q?Re:_ANN:_4_New_ShowMeDo.com_Videos_=28Wing_IDE, _RUR=2DPLE_=282=29, _PataPata=29?=

2006-07-29 Thread david_wahler
I'll be out of the office until approximately August 20th. If you have any 
questions, please email [EMAIL PROTECTED]

-- David Wahler


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


Re: system programign

2006-07-29 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], oqestra wrote:

 may i use python to read a file and output its content to another file
 which is not created yet and i don't want to use  to do this in
 linux?

Read the documentation about `open()`.  Simple example:

in_file = open('old.txt', 'r')
out_file = open('new.txt', 'w')
for line in in_file:
out_file.write(line)
in_file.close()
out_file.close()

how do you do ?

I'm fine, thanks.  ;-)

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


install python on cdrom

2006-07-29 Thread Fabian Braennstroem
Hi,

I look for an easy way to use the newest scipy, pyvtk, matplotlib,
f2py, numpy, paraview/vtk,... on a entreprise redhat machine
without administration rights.
My first thought was to install the whole new python system
on a cdrom/dvd and mounting it, when I need it. Would that
be the easiest way? I would be glad to read some
hints about the way doing it... 

Greetings!
 Fabian

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


Re: Client/Server Question

2006-07-29 Thread bryanjugglercryptographer

[EMAIL PROTECTED] wrote:
 My server.py looks like this

 -CODE--
 #!/usr/bin/env python
 import socket
 import sys
 import os

 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 host = ''
 port = 2000

 s.bind((host,port))
 s.listen(1)
 conn, addr = s.accept()
 print 'client is at', addr

 while True:
   data = conn.recv(100)
   if (data == 'MaxSim'):
   print 'MaxiSim'
   os.system('notepad')
   elif (data == 'Driving Sim'):
   print 'Driving Sim'
   os.system('explorer')
   elif (data == 'SHUTDOWN'):
   print 'Shutting down...'
   os.system('shutdown -s')
   conn.close()
   break
 ---CODE
 END-

 I am running this above program on a windows machine. My client is a
 Linux box. What I want to achieve is that server.py should follows
 instructions till I send a 'SHUTDOWN' command upon which it should shut
 down.

 When I run this program and suppose send 'MaxSim' to it, it launches
 notepad.exe fine, but then after that it doesn't accept subsequent
 command.

As others noted, that's because os.system() blocks.
You have more bugs than that.

The recv() might return MaxiSimDriving Sim. It could return
MaxiS on one call, and im on the next. If the remote side
closes the connection, recv() will keep returning the empty
string, and your program will be stuck in an infinite loop.

Did you understand Faulkner's suggustion? Anyone who connects to
TCP port 2000 can invoke shutdown -s (which I assume shuts down
your host).


-- 
--Bryan

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


Re: Nested function scope problem

2006-07-29 Thread Antoon Pardon
On 2006-07-29, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On 28 Jul 2006 17:48:03 GMT, Antoon Pardon [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:

 
 That is no reason to say that python has no variables. If someone would
 explain the difference between objects in some other language and
 objects in python I wouldn't accept the statement: python has no
 objects either.

   Python objects can exist without a variable bound to them...
 Though typically such would soon be garbage collected G

Well C++ objects can exist without a variable bound to them.
We just call them memory leaks G

   Traditional languages are the other way around... If a variable
 exists, it may exist with no object/value (ie, it is uninitialized -- a
 big problem in C).

What do you call traditional? Lisp is about as old as Fortran AFAIK.

 Python names can not exist (and be used) without
 being bound to some object (even None is a defined object). Attempting
 to use a name that has not been bound gives you the unbound local type
 problem.

   Yes, some other languages do define special flag values so that they
 can detect the usage of an uninitialized item... But the variable itself
 exists regardless; you can not detach the object from the variable
 (except by assigning something else to the variable).

I'm not so sure Python is that different. The fact that you get
an UnboundLocalError, instead of a NameError, suggests that in
the first case, the 'variable' already exists but is bound to
a Not yet Bound value. Not so long ago I was discussing some
implementation details of CPython and someone then said that
all local variables are entered into the local scope at call
time. This was to prevent the language to find variables
that are shadowed on a more global scope because the local
variable wasn't boud yet.

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


Re: Nested function scope problem

2006-07-29 Thread Antoon Pardon
On 2006-07-28, Gerhard Fiedler [EMAIL PROTECTED] wrote:
 On 2006-07-28 15:20:52, Antoon Pardon wrote:

 Typically, variable implies a data storage location that can take on
 different values. Emphasis on location -- the name is fixed to a
 memory location whose contents can be varied.
 
 That is not true. It may be the case in a number of languages but my
 experience with lisp and smalltalk, though rather limited, says that no
 such memory location is implied with the word variable in those
 languages and AFAIK they don't have a problem with the word variable
 either. 
 
 In Python, the closest would be a mutable object.

 Maybe this gets somewhere. Consider variable != constant. Python names are
 variables in that what they refer to (what is associated with them through
 a dict) can be changed, through various means (most commonly assignment).
 They are also variables in that what they refer to (usually) can be
 changed. Whether an assignment or some other command changes the reference
 association or the referenced object is one of the confusing issues with
 Python. But that doesn't make a variable less variable... :)

I think the important thing to remember is that the assignment in Python
is a alias maker and not a copy maker. In languages like C, Fortran,
pascal, the assignment makes a copy from what is on the righthand and
stores that in the variable on the lefthand. In languages like Lisp,
Smalltalk and Python, the assignment essentially makes the lefthand
an alias for the righthand.

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


Re: Nested function scope problem

2006-07-29 Thread Antoon Pardon
On 2006-07-29, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On 28 Jul 2006 18:20:52 GMT, Antoon Pardon [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:


 That is not true. It may be the case in a number of languages but
 my experience with lisp and smalltalk, though rather limited,
 says that no such memory location is implied with the word variable
 in those languages and AFAIK they don't have a problem with the
 word variable either.

   I have no smalltalk experience, and my lisp goes back to a cassette
 based version on a TRS-80 Model III...

   Since, at that time at least, everything in lisp was a
 tree-branching linked list I had trouble even considering setq to define
 a variable -- it was closer to adding a name to a node of the lists...
G {Yes, that IS a very loose interpretation}

   Does lisp permit one object to have multiple variables attached to
 it -- that is, two or more names on one object (whatever the node
 contains)...

AFAIK, yes

 And if so, what happens if, say, the object had been a
 scalar value 3.14159265436 perhaps and you make an assignment to one
 of the names?

About the same as happens in Python. One name will then be attached to
a new value and the other names will still be attached to 3.14159265436

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


Smaple of recursive directory walker

2006-07-29 Thread Traveler
Hello, 

At work I have a directory of about 50 large text files and i need to
search thru them for 10 separate words and print how many were found
in total.

I am new to python so could somebody please show me some sample code
that would help me get this done and i will work from that.

Thanks.

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


Re: sending bytes to parallel port

2006-07-29 Thread Grant Edwards
On 2006-07-29, Timothy Smith [EMAIL PROTECTED] wrote:

 I'd particularly recommend taking a look at the pyparallel
 module found here:

 yes, i did try pyparallel however it will not install on
 freebsd, setup.py errors.

Ah. I guess freebsd wasn't one of the systems listed on the
pyparallel page -- I should have paid closer attention.

 and yes i've done quite a bit of googling, i never expected it
 to be this difficult. i've done work with serial ports before.
 never parallel but.

Serial ports on PCs are pretty standardized as 16550 UARTs, and
The Unix serial port API was mostly nailed down years ago.

There are at least three different schemes for parallel ports,
and not everybody implements those identically even if they do
claim to be one of the three.  Many motherboard chipsets claim
to do do all three.  On top of that, there doesn't seem to be a
common Unix prallel port API.

-- 
Grant Edwards   grante Yow!  Is this ANYWHERE,
  at   USA?
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: War chest for writing web apps in Python?

2006-07-29 Thread SPE - Stani's Python Editor
Nick Vatamaniuc schreef:

 I found Komodo to
 be too slow on my machine, SPE was also slow, was crashing on me and
 had strange gui issues,

I hope you didn't install SPE from the MOTU repositories with synaptic
or apt-get. I use SPE myself daily on Ubuntu and wrote this howto
install SPE on Ubuntu:
http://www.ubuntuforums.org/showthread.php?t=218001highlight=wxpython

I know that others are running SPE on Ubuntu without problems. The main
point is not to use SPE from the repositories, but from the SPE
website. If the howto is too much just download the -nosetup.zip

Stani
--
http://pythonide.stani.be

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


Re: Nested function scope problem

2006-07-29 Thread Gerhard Fiedler
On 2006-07-29 13:47:37, Antoon Pardon wrote:

 I think the important thing to remember is that the assignment in Python
 is a alias maker and not a copy maker. In languages like C, Fortran,
 pascal, the assignment makes a copy from what is on the righthand and
 stores that in the variable on the lefthand. In languages like Lisp,
 Smalltalk and Python, the assignment essentially makes the lefthand
 an alias for the righthand.

Yes, I think I got it now :) 

It seems that, in essence, Bruno is right in that Python doesn't really
have variables. Everything that seems variable doesn't really change; what
changes is that an element of what seems to change gets rebound. Which in
itself is a rebinding process of a dictionary... I have yet to go there and
see whether anything at all changes :) 

Gerhard

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


Proposal for new option -U extending -u

2006-07-29 Thread James Thiele
Currently -u specifies that stdin, stdout and stderr are all
unbuffered. I propose a that -U make all files unbuffered. It could be
useful for programs that log to files.

Comments solicited.

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


Math package

2006-07-29 Thread diffuser78
I want to write a program which would have a 2 dimensional array of 1
billion by 1 billion. This is for computational purposes and evaluating
a mathematical concept similar to Erdos number.

Which is the best package for such programs (that would be fast
enough). 

Every help is appreciated.

Thanks

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


Re: Smaple of recursive directory walker

2006-07-29 Thread Ant

 At work I have a directory of about 50 large text files and i need to
 search thru them for 10 separate words and print how many were found
 in total.

 I am new to python so could somebody please show me some sample code
 that would help me get this done and i will work from that.

Assuming it's primarily the directory walk you need help with,
something like the following should help:

for root, dirs, files in os.walk('~/mydir'):
for file in [f for f in files if f.endswith(.txt)]:
fh = open(file)
for line in fh:
# Search for words.
fh.close()

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


Re: Smaple of recursive directory walker

2006-07-29 Thread Traveler
yes this is great i will work from that but how can i use say a list
to pass 10 words?

mylist = ['word1','word2','word3','word4']



On 29 Jul 2006 12:01:03 -0700, Ant [EMAIL PROTECTED] wrote:


 At work I have a directory of about 50 large text files and i need to
 search thru them for 10 separate words and print how many were found
 in total.

 I am new to python so could somebody please show me some sample code
 that would help me get this done and i will work from that.

Assuming it's primarily the directory walk you need help with,
something like the following should help:

for root, dirs, files in os.walk('~/mydir'):
for file in [f for f in files if f.endswith(.txt)]:
fh = open(file)
for line in fh:
# Search for words.
fh.close()

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


Re: Math package

2006-07-29 Thread Bas
I think you need one of these:

http://www-03.ibm.com/servers/deepcomputing/bluegene.html

Don't know if it runs python. If that doesn't work try to reformulate
your problem and have a look at

http://scipy.org/

Cheers,
Bas

[EMAIL PROTECTED] wrote:
 I want to write a program which would have a 2 dimensional array of 1
 billion by 1 billion. This is for computational purposes and evaluating
 a mathematical concept similar to Erdos number.

 Which is the best package for such programs (that would be fast
 enough). 
 
 Every help is appreciated.
 
 Thanks

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


Re: Math package

2006-07-29 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], diffuser78
wrote:

 I want to write a program which would have a 2 dimensional array of 1
 billion by 1 billion. This is for computational purposes and evaluating
 a mathematical concept similar to Erdos number.

Lets say you just want a byte at each cell in that array:

You have: (1 billion)^2 bytes
You want: terabyte
* 100
/ 1e-06

Hope you have enough memory.  ;-)

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Math package

2006-07-29 Thread bearophileHUGS
[EMAIL PROTECTED]:
 I want to write a program which would have a 2 dimensional array of 1
 billion by 1 billion. This is for computational purposes and evaluating
 a mathematical concept similar to Erdos number.

Maybe you are talking about the edges of a graph with 1e9 nodes. This
structure is surely quite sparse, so you don't need to store the edges
in a matrix, you can manage is as a sparse structure, and maybe you
don't need a Blue Gene.

If you find ways to clean your data, reduce the vertex and arc count,
and if you have a lot of memory, then maybe Boost Graph for Python may
suffice:
http://www.osl.iu.edu/~dgregor/bgl-python/

Bye,
bearophile

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


Re: Proposal for new option -U extending -u

2006-07-29 Thread Fuzzyman

James Thiele wrote:
 Currently -u specifies that stdin, stdout and stderr are all
 unbuffered. I propose a that -U make all files unbuffered. It could be
 useful for programs that log to files.

 Comments solicited.

'-U' is already taken (for unicode only strings). Other than that I
have no opinion (don't think I'd use it...).

All the best,


Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

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


Re: Math package

2006-07-29 Thread diffuser78
I will write the problem a little more clearer so that you guys can
recommend me better.

In a graphs of size N ( where, N = 1e9), each node has a degree D=1000.
i.e There are overall (D*N)/2 edges in the graph. This graph needs to
be generated randomly using the program.

Now my task is to find the shortest distance from each node to every
other node. And finally I want to find is the average distance from one
node to another node in the graph. This is an average Erdos number or
equivalently what degree of seperation exists in the graph.

I can start with low values of N and D but my ultimate aim is to
simulate this graph on big values of N and D.

Every help is greatly appreciated.

Thanks


[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED]:
  I want to write a program which would have a 2 dimensional array of 1
  billion by 1 billion. This is for computational purposes and evaluating
  a mathematical concept similar to Erdos number.

 Maybe you are talking about the edges of a graph with 1e9 nodes. This
 structure is surely quite sparse, so you don't need to store the edges
 in a matrix, you can manage is as a sparse structure, and maybe you
 don't need a Blue Gene.

 If you find ways to clean your data, reduce the vertex and arc count,
 and if you have a lot of memory, then maybe Boost Graph for Python may
 suffice:
 http://www.osl.iu.edu/~dgregor/bgl-python/
 
 Bye,
 bearophile

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


Re: Fastest Way To Loop Through Every Pixel

2006-07-29 Thread Ron Adam
Chaos wrote:
 As my first attempt to loop through every pixel of an image, I used
 
 for thisY in range(0, thisHeight):
 for thisX in range(0, thisWidth):
   #Actions here for Pixel thisX, thisY
 
 But it takes 450-1000 milliseconds
 
 I want speeds less than 10 milliseconds
 
 I have tried using SWIG, and pypy but they all are unsuccessfull in
 compiling my files.

This probably won't work for you, but it's worth suggesting as it may 
give you other ideas to solve your problem.

If it is a list of lists of pixel objects you can iterate though the 
pixels directly and not use range or xrange at all.  For this to work 
the pixel object needs to be mutable or have an attribute to store it's 
value.  It can't be just an int, in that case you will need to use indexes.



 pixel = [rgb_value]

or

 pixel = [r,g,b]

or

 class Pixel(object):
def __self__(self, rgb_value):
self.value = rgb_value
 pixel = Pixel(rgb_value)

Or some other variation that is mutable.


These may not be suitable and may cause additional overhead elsewhere as 
the image may need to be converted to some other form in order to 
display or save it.



What Actions are you performing on the pixels?

You may be able to increase the speed by creating lookup tables in 
dictionaries and then use the pixel value for the key.


Just a rough example...

action1 = dict()
# fill dict with precomputed pixel key value pairs.
# ...

image = getimage()
for row in image:
   for pixel in row:
  # one of the following or something similar
  pixel[0] = action1[pixel]
  pixel.value = action1[pixel.value]
  pixel[:] = action[pixel]


The pixels need to be objects so they are mutable.  If they aren't, then 
you will need to use index's as you did above.

Precomputing the pixel value tables may use up too much memory or take a 
very long time if your image has a large amount of possible colors.  If 
precomputing the pixels take too long but you are not concerned by the 
memory usage, you may be able to store (pickle) the precomputed tables 
then unpickle it before it is used.

This work best if the number of colors (the depth) is limited.

If these suggestions aren't applicable, then you most likely need to 
look at an image library that uses compiled C (or assembly) code to do 
the brute force work.  It may also be possible to access your platforms 
directX or opengl library routines directly to do it.

Cheers,
Ron












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


Re: simple dbus python problem ... please help

2006-07-29 Thread alisonken1

bob wrote:

snip

 bus = dbus.Bus (dbus.Bus.TYPE_SYSTEM)
 hal_service = bus.get_service ('org.freedesktop.Hal')
 hal_manager = hal_service.get_object ('/org/freedesktop/Hal/Manager',
   'org.freedesktop.Hal.Manager')

snip

It appears that bus.get_service() has been deprecated and deleted.

Not sure about the changes, so anyone else who can help please jump in.

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


Re: Newbie..Needs Help

2006-07-29 Thread Anthra Norell

- Original Message -
From: Graham Feeley [EMAIL PROTECTED]
Newsgroups: comp.lang.python
To: python-list@python.org
Sent: Friday, July 28, 2006 5:11 PM
Subject: Re: Newbie..Needs Help


 Thanks Nick for the reply
 Of course my first post was a general posting to see if someone would be
 able to help
 here is the website which holds the data I require
 http://www.aapracingandsports.com.au/racing/raceresultsonly.asp?storydate=27/07/2006meetings=bdgo

 The fields required are as follows
  NSW Tab
 #  Win  Place
  2$4.60   $2.40
  5$2.70
  1$1.30
  Quin$23.00
  Tri  $120.70
 Field names are
 Date   ( not important )
 Track= Bendigo
 RaceNoon web page
 Res1st...2
 Res2nd..5
 Res3rd..1
 Div1..$4.60
 DivPlc...$2.40
 Div2..$2.70
 Div3..$1.30
 DivQuin.$23.00
 DivTrif...$120.70
 As you can see there are a total of 6 meetings involved and I would need to
 put in this parameter ( =bdgo) or (=gosf) these are the meeting tracks

 Hope this more enlightening
 Regards
 graham


Graham,

Only a few days ago I gave someone a push who had a very similar problem. I 
handed him code ready to run. I am doing it again for
you.
  The site you use is much harder to interpret than the other one was and 
so I took the opportunity to experimentally stretch
the envelope of a new brain child of mine: a stream editor called SE. It is new 
and so I also take the opportunity to demo it.
  One correspondent in the previous exchange was Paul McGuire, the author 
of 'pyparse'. He made a good case for using 'pyparse'
in situations like yours. Unlike a stream editor, a parser reads structure in 
addition to data and can relate the data to its
context.
  Anlayzing the tables I noticed that they are poorly structured: The first 
column contains both data and ids. Some records are
shorter than others, so column ids have to be guessed and hard coded. Missing 
data sometimes is a dash, sometimes nothing. The
inconsistencies seem to be consistent, though, down the eight tables of the 
page. So they can be formalized with some confidence
that they are systematic. If Paul could spend some time on this, I'd be much 
interested to see how he would handle the relative
disorder.
  Another thought: The time one invests in developing a program should not 
exceed the time it can save overall (not talking
about recreational programming). Web pages justify an extra measure of caution, 
because they may change any time and when they do
they impose an unscheduled priority every time the reader stops working and 
requires a revision.

So, here is your program. I write it so you can copy the whole thing to a file. 
Next copy SE from the Cheese Shop. Unzip it and put
both SE.PY and SEL.PY where your Python progams are. Then 'execfile' the code 
in an IDLE window, call 'display_horse_race_data
('Bendigo', '27/07/2006') and see what happens. You'll have to wait ten seconds 
or so.

Regards

Frederic

##

TRACKS = { 'New Zealand' : '',
   'Bendigo' : 'bdgo',
   'Gosford' : 'gosf',
   'Northam' : 'nthm',
   'Port Augusta': 'pta',
   'Townsville'  : 'town',
 }


# This function does it all once all functions are loaded. If nothing shows, the
# page has not data.

def display_horse_race_data (track, date, clip_summary = 100):

   
  tracks: e.g. 'Bendigo' or 'bdgo'
  date: e.g. '27/07/2006'
  clip_summary: each table has a long summary header.
the argument says hjow much of it to show.
   

   if track [0].isupper ():
  if TRACKS.has_key (track):
 track = TRACKS [track]
  else:
 print 'No such track %s' % track
 return
   open ()
   header, records = get_horse_race_data (track, date)
   show_records (header, records, clip_summary)



##


import SE, urllib

_is_open = 0

def open ():

   global _is_open

   if not _is_open:   # Skip repeat calls

  global Data_Filter, Null_Data_Marker, Tag_Stripper, Space_Deflator, 
CSV_Maker

  # Making the following Editors is a step-by-step process, adding one 
element at a time and
  # looking at what it does and what should be done next.
  # Get pertinent data segments
  header= ' ~(?i)Today\'s Results - .+?div 
style=padding-top:5px;~==*END*OF*HEADER* '
  race_summary  = ' ~(?i)Race [1-9].*?/fontbr~== '
  data_segment  = ' ~(?i)table border=0 width=100% cellpadding=0 
cellspacing=0(.|\n)*?/table~==*END*OF*SEGMENT* '
  Data_Filter = SE.SE (' EAT ' + header + race_summary + data_segment)

  # Some data items are empty. Fill them with a dash.
  mark_null_data = ' 

Pygame Help

2006-07-29 Thread Blaze Bresko
Hi,

I am trying to make a game using either livewires or pygame. The game
is tetris. Right now I have gotten the program to a point where
everything works (as in user input, score, lines, etc), except I can't
get more than one block to work. Right now I have the user playing a
game where a single block falls at a time instead of one of the seven
different patterns. I was curious how you would program the seperate
images to fall together and not break apart, because pygame and
livewires uses images as collision detection, so therefore you can't
make most of the shapes a single image because they will have
transparent spaces as part of the image, which will make floating
shapes and such.

--Thanks
--Andrew

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


Re: Pygame Help

2006-07-29 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Blaze Bresko
wrote:

 [Tetris] I was curious how you would program the seperate  images to
 fall together and not break apart, because pygame and livewires uses
 images as collision detection, so therefore you can't make most of the
 shapes a single image because they will have transparent spaces as part
 of the image, which will make floating shapes and such.

I wouldn't rely on the graphics library at all but create a model of the
game that's completely independent from the graphics.  I think a two
dimensional structure with lists of lists is the simplest solution.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pygame Help

2006-07-29 Thread Lee Harr
 I was curious how you would program the seperate
 images to fall together and not break apart, because pygame and
 livewires uses images as collision detection, so therefore you can't
 make most of the shapes a single image because they will have
 transparent spaces as part of the image, which will make floating
 shapes and such.


The way I did it was to compose the shapes out of squares.
The implementation is available in the pygsear-games
distribution. You'd need pygsear also, to play the game.

http://www.nongnu.org/pygsear/

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


Re: Math package

2006-07-29 Thread Robert Kern
[EMAIL PROTECTED] wrote:
 I will write the problem a little more clearer so that you guys can
 recommend me better.
 
 In a graphs of size N ( where, N = 1e9), each node has a degree D=1000.
 i.e There are overall (D*N)/2 edges in the graph. This graph needs to
 be generated randomly using the program.

You will need to specify your desired random generation algorithm a bit better. 
There are lots of ways to do that, and different choices will affect your 
results substantially. They will also affect your *ability* to get results.

 Now my task is to find the shortest distance from each node to every
 other node. And finally I want to find is the average distance from one
 node to another node in the graph. This is an average Erdos number or
 equivalently what degree of seperation exists in the graph.
 
 I can start with low values of N and D but my ultimate aim is to
 simulate this graph on big values of N and D.

You probably won't be able to get up to N=1e9 and D=1000. The memory 
requirements are just too large even with a better data structure than an 
adjacency matrix (possibly the worst one you could use for problems this size).

However, for smaller graphs, you will probably want to look at the Boost Graph 
Library, as someone else has already mentioned, and LANL's NetworkX package. It 
was written for the statistical study of large networks (though not as large as 
you want).

   https://networkx.lanl.gov/

If you have a large cluster available, you might be able to parallelize your 
algorithms using the Parallel Boost Graph Library. I don't believe that Python 
bindings are available though. Your ability to solve your problem will also 
depend on the structure of the graph that you generated. Some networks 
parallelize better than others. Look at the Performance link on the site 
below.

   http://osl.iu.edu/research/pbgl/

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth.
   -- Umberto Eco

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


Re: Comma is not always OK in the argument list?!

2006-07-29 Thread Nick Vatamaniuc
Dennis,

You make a good point, that is what I though first. Semantically I
thought a comma after **kw as in ..., **kw,) doesn't make sense because
there is nothing that could follow **kw except the ')'. But then trying
some other cases (see the previous posts for my examples) I noticed
that commas aren't allowed after *pos_args also. For example if ,
*pos_args,) would be an error BUT stuff could follow *pos_args and that
could be **kw as in ..., *pos_args,**kw).

In other words the behavior is not consistent. So it seems that 3
things could happen with this:

1) Not allow commas after **kw only. Allow them in any other case,
because semantically 'stuff' could possibly follow.

2) Don't allow extra commas for all the argument lists. In other words
f(1,2,) or f(a=1,b=2,) would be an error.  But then do we want argument
lists to be consistent with tuples as far as syntax goes?

3) Allow trailing commas after all kinds of arguments in the argument
lists. This is what the documentation describes at the moment. I think
this is more sensible. I understand that argument lists and tuples are
not the same, but it would be nice to have a _syntactic_ consistency,
as opposed to 'a surprise'. As in t=(1,2,3,)  f(1,2,3,)  f(1,*[2,3],)
and f(1,*[2],**{'c':3},) should all be 'OK'.

Perhaps more Python core developers would comment...

Nick Vatamaniuc


Dennis Lee Bieber wrote:
 On 29 Jul 2006 07:26:57 -0700, Nick Vatamaniuc [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:

  Roman,
 
  The way  I see it, it could be either way. In other words if I can
  write f(1,2,3) and f(1,2,3,) I should also be able to write
  f(1,*[2,3],). It is a really small detail but there sould be some
  consistency. Either no extra commas for all kinds of argument types or

   Part of the problem may be that the * notation implies that the
 associated argument is supposed to fill ALL other supplied positional
 arguments -- so what is that empty argument after the , supposed to be
 associated with? A positional argument /after/ all positional arguments?
 --
   WulfraedDennis Lee Bieber   KD6MOG
   [EMAIL PROTECTED]   [EMAIL PROTECTED]
   HTTP://wlfraed.home.netcom.com/
   (Bestiaria Support Staff:   [EMAIL PROTECTED])
   HTTP://www.bestiaria.com/

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


Re: War chest for writing web apps in Python?

2006-07-29 Thread Nick Vatamaniuc
Stani,

Thanks. I'll definetly give SPE another try.
You have a great editor with features that others don't have.
I'll try it with the latest wxPython.

I never really thought SPE was the problem, it seemed like a lot of
issues I saw were from wxWidgets...

Nick V.



SPE - Stani's Python Editor wrote:
 Nick Vatamaniuc schreef:

  I found Komodo to
  be too slow on my machine, SPE was also slow, was crashing on me and
  had strange gui issues,

 I hope you didn't install SPE from the MOTU repositories with synaptic
 or apt-get. I use SPE myself daily on Ubuntu and wrote this howto
 install SPE on Ubuntu:
 http://www.ubuntuforums.org/showthread.php?t=218001highlight=wxpython

 I know that others are running SPE on Ubuntu without problems. The main
 point is not to use SPE from the repositories, but from the SPE
 website. If the howto is too much just download the -nosetup.zip
 
 Stani
 --
 http://pythonide.stani.be

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


Re: Fastest Way To Loop Through Every Pixel

2006-07-29 Thread Paul McGuire
Paul McGuire [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Chaos [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
  myCol = (0.3 * image.GetRed(thisX, thisY)) + (0.59 *
  image.GetGreen(thisX, thisY)) + (0.11 * image.GetBlue(thisX, thisY))
  if myCol  darkestCol:
 darkestCol = myCol
 possX = thisX
 possY = thisY
 

 Psyco may be of some help to you, especially if you extract out your myCol
 expression into its own function, something like:

 def darkness(img,x,y):
 return  (0.3 * img.GetRed(x,y)) + (0.59 * img.GetGreen(x,y)) + (0.11 *
 img.GetBlue(x,y))

snip

Even better than my other suggestions might be to write this function, and
then wrap it in a memoizing decorator
(http://wiki.python.org/moin/PythonDecoratorLibrary#head-11870a08b0fa59a8622
201abfac735ea47ffade5) - surely there must be some repeated colors in your
image.

-- Paul



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


making pseudo random number with spam ad convert text to binary

2006-07-29 Thread bussiere maillist
here is a little project to make a more or less good pseudo random generator by using spam :http://euryale.googlecode.com/it's almost quite finished but i've got a last problem i didn't manage to convert text to binary :
hazard = binascii.a2b_qp(attachment) + binascii.a2b_qp(body) + binascii.a2b_qp(addr) + binascii.a2b_qp(sujet) print binascii.b2a_qp(hazard)it still print me ascii charactersregardsBussiere

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

python and JMS

2006-07-29 Thread tksri2000
I am looking to use python to talk to JMS. Can some please point me to
such resources if this is possible.

Sri

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


Re: Proposal for new option -U extending -u

2006-07-29 Thread Carl Banks
James Thiele wrote:
 Currently -u specifies that stdin, stdout and stderr are all
 unbuffered. I propose a that -U make all files unbuffered. It could be
 useful for programs that log to files.

 Comments solicited.

Unnecessary.  You can control the buffering of any file object you
create yourself, e.g. open(somefile,buffering=0) to create an
unbuffered file object.  The reason you need a switch for stdin,
stdout, stderr is you don't create those objects yourself.

Carl Banks

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


Re: Newbie..Needs Help

2006-07-29 Thread Graham Feeley
Well Well Well, Anthra you are a clever person, Are
nt you
I nearly fell over when i read your post.
Would it help if we used another web site to gather data
As you stated the tables are not all that well structured.
well I will give thisone  a go first and if there is anything I can do for 
you just ask and I will try my best.
I really appreciate what you have done.
Of course I will try to follow your code to see if any will fall on 
meLOL
Regards
Graham

Anthra Norell [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 - Original Message -
 From: Graham Feeley [EMAIL PROTECTED]
 Newsgroups: comp.lang.python
 To: python-list@python.org
 Sent: Friday, July 28, 2006 5:11 PM
 Subject: Re: Newbie..Needs Help


 Thanks Nick for the reply
 Of course my first post was a general posting to see if someone would be
 able to help
 here is the website which holds the data I require
 http://www.aapracingandsports.com.au/racing/raceresultsonly.asp?storydate=27/07/2006meetings=bdgo

 The fields required are as follows
  NSW Tab
 #  Win  Place
  2$4.60   $2.40
  5$2.70
  1$1.30
  Quin$23.00
  Tri  $120.70
 Field names are
 Date   ( not important )
 Track= Bendigo
 RaceNoon web page
 Res1st...2
 Res2nd..5
 Res3rd..1
 Div1..$4.60
 DivPlc...$2.40
 Div2..$2.70
 Div3..$1.30
 DivQuin.$23.00
 DivTrif...$120.70
 As you can see there are a total of 6 meetings involved and I would need 
 to
 put in this parameter ( =bdgo) or (=gosf) these are the meeting tracks

 Hope this more enlightening
 Regards
 graham


 Graham,

 Only a few days ago I gave someone a push who had a very similar problem. 
 I handed him code ready to run. I am doing it again for
 you.
  The site you use is much harder to interpret than the other one was 
 and so I took the opportunity to experimentally stretch
 the envelope of a new brain child of mine: a stream editor called SE. It 
 is new and so I also take the opportunity to demo it.
  One correspondent in the previous exchange was Paul McGuire, the 
 author of 'pyparse'. He made a good case for using 'pyparse'
 in situations like yours. Unlike a stream editor, a parser reads structure 
 in addition to data and can relate the data to its
 context.
  Anlayzing the tables I noticed that they are poorly structured: The 
 first column contains both data and ids. Some records are
 shorter than others, so column ids have to be guessed and hard coded. 
 Missing data sometimes is a dash, sometimes nothing. The
 inconsistencies seem to be consistent, though, down the eight tables of 
 the page. So they can be formalized with some confidence
 that they are systematic. If Paul could spend some time on this, I'd be 
 much interested to see how he would handle the relative
 disorder.
  Another thought: The time one invests in developing a program should 
 not exceed the time it can save overall (not talking
 about recreational programming). Web pages justify an extra measure of 
 caution, because they may change any time and when they do
 they impose an unscheduled priority every time the reader stops working 
 and requires a revision.

 So, here is your program. I write it so you can copy the whole thing to a 
 file. Next copy SE from the Cheese Shop. Unzip it and put
 both SE.PY and SEL.PY where your Python progams are. Then 'execfile' the 
 code in an IDLE window, call 'display_horse_race_data
 ('Bendigo', '27/07/2006') and see what happens. You'll have to wait ten 
 seconds or so.

 Regards

 Frederic

 ##

 TRACKS = { 'New Zealand' : '',
   'Bendigo' : 'bdgo',
   'Gosford' : 'gosf',
   'Northam' : 'nthm',
   'Port Augusta': 'pta',
   'Townsville'  : 'town',
 }


 # This function does it all once all functions are loaded. If nothing 
 shows, the
 # page has not data.

 def display_horse_race_data (track, date, clip_summary = 100):

   
  tracks: e.g. 'Bendigo' or 'bdgo'
  date: e.g. '27/07/2006'
  clip_summary: each table has a long summary header.
the argument says hjow much of it to show.
   

   if track [0].isupper ():
  if TRACKS.has_key (track):
 track = TRACKS [track]
  else:
 print 'No such track %s' % track
 return
   open ()
   header, records = get_horse_race_data (track, date)
   show_records (header, records, clip_summary)



 ##


 import SE, urllib

 _is_open = 0

 def open ():

   global _is_open

   if not _is_open:   # Skip repeat calls

  global Data_Filter, Null_Data_Marker, Tag_Stripper, Space_Deflator, 
 CSV_Maker

  # Making the following Editors is a step-by-step process, 

PIL on MacOS

2006-07-29 Thread kernel1983
I was trying to build PIL and pygame from the source on the MacOS.

But when I typed 'sudo python setup.py install',
it gives error msg :

gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd
-fno-common -dynamic -DNDEBUG -g -DHAVE_LIBZ -DWORDS_BIGENDIAN
-I/System/Library/Frameworks/Tcl.framework/Headers
-I/System/Library/Frameworks/Tk.framework/Headers
-I/usr/local/include/freetype2 -IlibImaging
-I/Library/Frameworks/Python.framework/Versions/2.4/include
-I/usr/local/include -I/usr/include
-I/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4
-c _imaging.c -o build/temp.macosx-10.4-fat-2.4/_imaging.o
gcc: cannot specify -o with -c or -S and multiple compilations
error: command 'gcc' failed with exit status 1

Is there any one who did this before?how can i solve it?
Thanks

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


[ python-Bugs-1112549 ] cgi.FieldStorage memory usage can spike in line-oriented ops

2006-07-29 Thread SourceForge.net
Bugs item #1112549, was opened at 2005-01-30 13:40
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1112549group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 8
Submitted By: Chris McDonough (chrism)
Assigned to: Nobody/Anonymous (nobody)
Summary: cgi.FieldStorage memory usage can spike in line-oriented ops

Initial Comment:
Various parts of cgi.FieldStorage call its
read_lines_to_outerboundary, read_lines and
skip_lines methods.These methods use the
readline method of the file object that represents an
input stream.  The input stream is typically data
supplied by an untrusted source (such as a user
uploading a file from a web browser).  The input data
is not required by the RFC 822/1521/1522/1867
specifications to contain any newline characters.  For
example, it is within the bounds of the specification
to supply a a multipart/form-data input stream with a
file-data part that consists of a 2GB string composed
entirely of x characters (which happens to be
something I did that led me to noticing this bug).

The simplest fix is to make use of the size argument
of the readline method of the file object where it is
used within all parts of FieldStorage that make use of
it.  A patch against the Python 2.3.4 cgi.py module
that does this is attached.

--

Comment By: Chris McDonough (chrism)
Date: 2006-07-27 21:42

Message:
Logged In: YES 
user_id=32974

The files I've just uploaded are revisions to the cgi and test_cgi modules for 
the 
current state of the SVN trunk.  If someone could apply these, it would be 
appreciated, or give me access and I'll be happy to.

FTR, this is a bug which exposes systems which use the cgi.FieldStorage class 
(most Python web frameworks do) to a denial of service potential.

--

Comment By: Chris McDonough (chrism)
Date: 2005-04-03 04:00

Message:
Logged In: YES 
user_id=32974

FYI, I'd be happy to do the merging here if you wanted to
give me checkin access.

--

Comment By: Chris McDonough (chrism)
Date: 2005-04-03 03:42

Message:
Logged In: YES 
user_id=32974

An updated test_cgi.py is attached.  I test both the
readline behavior and add a test for basic multipart parsing. 

--

Comment By: Guido van Rossum (gvanrossum)
Date: 2005-04-01 04:48

Message:
Logged In: YES 
user_id=6380

Can I tweak you into uploading a unit test?

--

Comment By: Chris McDonough (chrism)
Date: 2005-04-01 02:56

Message:
Logged In: YES 
user_id=32974

Re: parse_multipart..  yes, it looks like there's no use
fixing that as it just turns around and puts the line into a
list.. it is vulnerable but just by virtue of its non-use of
a tempfile, it appears doomed anyway for large requests.  I
don't know of anything that uses it.
 
Good catch wrt boundary recognition bug, I'm uploading
another patch.

--

Comment By: Guido van Rossum (gvanrossum)
Date: 2005-03-31 22:13

Message:
Logged In: YES 
user_id=6380

Methinks that the fix isn't quite right: it would
incorrectly recognize as a boundary a very long line
starting with -- followed by the appropriate random string
at offset 2**16. This could probably be taken care of by
adding a flag that is true initially and after that keeps
track of whether the previous line ended in \n.

Also, there's a call to fp.readline() in parse_multipart()
that you didn't patch -- it wouldn't help because that code
is saving the lines in a list anyway, but isn't that code
vulnerable as well? Or is it not used?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1112549group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1441397 ] compiler module loses docstrings

2006-07-29 Thread SourceForge.net
Bugs item #1441397, was opened at 2006-03-02 00:52
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1441397group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: None
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Nobody/Anonymous (nobody)
Summary: compiler module loses docstrings

Initial Comment:
this is svn head:

 import compiler
 compiler.transformer.parse('doc')
Module(None, Stmt([Discard(Const('doc'))]))

this is 2.4:

 import compiler
 compiler.transformer.parse('doc')
Module('doc', Stmt([]))

I think the problem may be rooted in the parser module rather than the 
compiler module itself.

--

Comment By: Georg Brandl (gbrandl)
Date: 2006-07-29 09:34

Message:
Logged In: YES 
user_id=849994

The bug was transformer._doc_nodes missing or_test.
Fixed in rev. 50924, including test.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1441397group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1014230 ] optparse: parser.remove_option(-h) inconsistency

2006-07-29 Thread SourceForge.net
Bugs item #1014230, was opened at 2004-08-23 10:04
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1014230group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: strop (strop)
Assigned to: Greg Ward (gward)
Summary: optparse: parser.remove_option(-h) inconsistency

Initial Comment:
remove_option(-h) method of OptionParser has a strange 
behaviour : it can't be removed from 2 different OptionParser 
objects. 
It may be due to the fact that the help option seems to be a 
unique object. 
Even if this can be solved by addind add_help_option=0 to 
OptionParser constructor parameters, it seems to be an 
inconsistency wrt remove_option method 
 

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1014230group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1519571 ] turtle.py Docs still incomplete

2006-07-29 Thread SourceForge.net
Bugs item #1519571, was opened at 2006-07-09 10:49
Message generated for change (Settings changed) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1519571group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Lingl (gregorlingl)
Assigned to: A.M. Kuchling (akuchling)
Summary: turtle.py Docs still incomplete

Initial Comment:
There are three functions in turtle.py (which do not
occur as methods of Pen), which are still not
documented:

setup()
title()
done()

Regards,
Gregor

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1519571group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1519571 ] turtle.py Docs still incomplete

2006-07-29 Thread SourceForge.net
Bugs item #1519571, was opened at 2006-07-09 10:49
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1519571group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Lingl (gregorlingl)
Assigned to: A.M. Kuchling (akuchling)
Summary: turtle.py Docs still incomplete

Initial Comment:
There are three functions in turtle.py (which do not
occur as methods of Pen), which are still not
documented:

setup()
title()
done()

Regards,
Gregor

--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-07-29 10:46

Message:
Logged In: YES 
user_id=11375

I've added documentation for these methods in rev. 50932. 
Thanks for pointing out the omission!


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1519571group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1414697 ] inconsistency in help(set)

2006-07-29 Thread SourceForge.net
Bugs item #1414697, was opened at 2006-01-25 10:43
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1414697group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Gregory Petrosyan (gregory_p)
Assigned to: Raymond Hettinger (rhettinger)
Summary: inconsistency in help(set)

Initial Comment:
 help(set)

Help on class set in module __builtin__:

class set(object)
 |  set(iterable) -- set object
 |
 |  Build an unordered collection.
 |
 |  Methods defined here:
 |  ...


It would be better for docstring to be Build an
unordered collection with no duplicate elements. 
instead of Build an unordered collection.

--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-07-29 11:12

Message:
Logged In: YES 
user_id=11375

Thanks for your suggestion; I've added 'unordered collection
of unique elements' in rev. 50934.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1414697group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1530382 ] ssl object documentation lacks a couple of methods

2006-07-29 Thread SourceForge.net
Bugs item #1530382, was opened at 2006-07-28 09:20
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1530382group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Lawrence Oluyede (rhymes)
Assigned to: A.M. Kuchling (akuchling)
Summary: ssl object documentation lacks a couple of methods

Initial Comment:
According to
http://docs.python.org/dev/lib/ssl-objects.html the SSL
Objects expose only write() and read() but they also
expose issuer() and server() methods.

See Modueles/_ssl.c from line 557 to 565

--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-07-29 11:35

Message:
Logged In: YES 
user_id=11375

I've documented these methods in rev. 50935.  Thanks for
pointing out this omission!



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1530382group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1465014 ] CSV regression in 2.5a1: multi-line cells

2006-07-29 Thread SourceForge.net
Bugs item #1465014, was opened at 2006-04-05 11:14
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1465014group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Open
Resolution: Rejected
Priority: 5
Submitted By: David Goodger (goodger)
Assigned to: Skip Montanaro (montanaro)
Summary: CSV regression in 2.5a1: multi-line cells

Initial Comment:
Running the attached csv_test.py under Python 2.4.2
(Windows XP SP1) produces:

c:\apps\python24\python.exe ./csv_test.py
['one', '2', 'three (line 1)\n(line 2)']

Note that the third item in the row contains a newline
between (line 1) and (line 2).

With Python 2.5a1, I get:

c:\apps\python25\python.exe ./csv_test.py
['one', '2', 'three (line 1)(line 2)']

Notice the missing newline, which is significant.  The
CSV module under 2.5a1 seems to lose data.


--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-07-29 13:24

Message:
Logged In: YES 
user_id=11375

I looked at this bug report, but I have no idea of exactly
what behaviour has changed or what needs to be described.


--

Comment By: Andrew McNamara (andrewmcnamara)
Date: 2006-06-22 23:34

Message:
Logged In: YES 
user_id=698599

Yep, your point about adding a comment to the documentation 
is fair. Skip, do you want to take my words and massage 
them into a form suitable for the docs?

--

Comment By: David Goodger (goodger)
Date: 2006-06-22 23:13

Message:
Logged In: YES 
user_id=7733

I didn't realize that the previous behavior was buggy; I
thought that the current behavior was a side-effect.  The
2.5 behavior did cause a small problem in Docutils, but it's
already been fixed.  I just wanted to ensure that no
regression was creeping in to 2.5.

Thanks for the explanation!  Perhaps it could be added to
the docs in some form?

Marking the bug report closed.

--

Comment By: Andrew McNamara (andrewmcnamara)
Date: 2006-06-22 20:27

Message:
Logged In: YES 
user_id=698599

The previous behaviour caused considerable problems, 
particularly on platforms that did not use the unix line-
ending conventions, or with files that originated on those 
platforms - users were finding mysterious newlines where 
they didn't expect them.

Quoted fields exist to allow characters that would otherwise 
be considered part of the syntax to appear within the field. 
 So yes, quoted fields are a special case, and necessarily 
so.

The current behaviour puts the control back in the hands of 
the user of the module: if literal newlines are important 
within a field, they need to read their file in a way that 
preserves the newlines. The old behaviour would introduce 
spurious characters into quoted fields, with no way for the 
user to control that behaviour.

I'm sorry that the change causes you problems. With a format 
that's as loosely defined as CSV, it's an unfortunate fact 
of life that there are going to be conflicting requirements. 

--

Comment By: David Goodger (goodger)
Date: 2006-06-22 14:17

Message:
Logged In: YES 
user_id=7733

I see what you're saying, but I disagree.  In Python 2.4,
csv.reader did not require newlines, but in Python 2.5 it
does.  That's a significant behavioral change.  In the
stdlib csv Module Contents docs for csv.reader, it says:
csvfile can be any object which supports the iterator
protocol and returns a string each time its next method is
called.  It doesn't mention newline-terminated strings.

In any case, the behavior is inconsistent: newlines are not
required to terminate row-ending strings, but only strings
which end inside cells split across rows.  Why the discrepancy?

--

Comment By: Andrew McNamara (andrewmcnamara)
Date: 2006-06-20 19:17

Message:
Logged In: YES 
user_id=698599

I think your problem is with str.splitlines(), rather than 
the csv.reader: splitlines ate the newline. If you pass it 
True as an argument, it will retain the end-of-line 
character in the resulting strings.

--

Comment By: David Goodger (goodger)
Date: 2006-05-02 17:04

Message:
Logged In: YES 
user_id=7733

Assigned to Andrew McNamara, since his change appears to
have caused this regression (revision 38290 on
Modules/_csv.c).

--

Comment By: David Goodger (goodger)
Date: 2006-05-02 16:58

Message:
Logged 

[ python-Bugs-1429053 ] set documentation deficiencies

2006-07-29 Thread SourceForge.net
Bugs item #1429053, was opened at 2006-02-10 07:07
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1429053group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Keith Briggs (kbriggs)
Assigned to: A.M. Kuchling (akuchling)
Summary: set documentation deficiencies

Initial Comment:
http://www.python.org/doc/current/lib/types-set.html
has a dead link: Module sets.

Also, there does not seem to be any documentation on
how to construct a set.   Does set()==set([])?   What
is allowed  as an argument to set()?  Any iterable?

--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-07-29 13:27

Message:
Logged In: YES 
user_id=11375

This bug seems to be fixed; closing.


--

Comment By: Georg Brandl (birkenfeld)
Date: 2006-02-13 14:29

Message:
Logged In: YES 
user_id=1188172

The new location of the devel docs is
http://docs.python.org/dev.

--

Comment By: Keith Briggs (kbriggs)
Date: 2006-02-13 07:12

Message:
Logged In: YES 
user_id=888261

Where is it fixed?  I see all the same problems at
http://www.python.org/dev/doc/devel/lib/types-set.html.

--

Comment By: Georg Brandl (birkenfeld)
Date: 2006-02-10 11:21

Message:
Logged In: YES 
user_id=1188172

This is all already corrected, except for the empty set thing.

--

Comment By: Keith Briggs (kbriggs)
Date: 2006-02-10 10:53

Message:
Logged In: YES 
user_id=888261

Furthermore, the operations update etc. are mutations of s,
so wouldn't the definitions

s.update(t) s |= t  return set s with elements added from t
s.intersection_update(t)s = t  return set s keeping only
elements also found in t
s.difference_update(t)  s -= t  return set s after removing
elements found in t
s.symmetric_difference_update(t)s ^= t  return set s with
elements from s or t but not both

be better as 

s.update(t) s |= t  add elements from t to s

etc.?
I'm not sure what the word return is doing here.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1429053group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1530959 ] distutils doesn't notice --with-pydebug

2006-07-29 Thread SourceForge.net
Bugs item #1530959, was opened at 2006-07-29 13:45
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1530959group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Collin Winter (collinwinter)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils doesn't notice --with-pydebug

Initial Comment:
As it stands (as of r50921), building a C extension
module first with a debug build of Python (built with
--with-pydebug), then with a regular Python build
(without --with-pydebug) does not cause distutils to
recompile the extension module as it should. This leads
to undefined symbol errors at runtime when the module
is loaded.

The attached patch against
Lib/distutils/command/build.py causes
distutils.command.build to append '-pydebug' to the
platform-specific directory name  (e.g.,
'linux-i686-2.5') if Python was compiled with
--with-pydebug.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1530959group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1465014 ] CSV regression in 2.5a1: multi-line cells

2006-07-29 Thread SourceForge.net
Bugs item #1465014, was opened at 2006-04-05 10:14
Message generated for change (Comment added) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1465014group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Pending
Resolution: Fixed
Priority: 5
Submitted By: David Goodger (goodger)
Assigned to: Skip Montanaro (montanaro)
Summary: CSV regression in 2.5a1: multi-line cells

Initial Comment:
Running the attached csv_test.py under Python 2.4.2
(Windows XP SP1) produces:

c:\apps\python24\python.exe ./csv_test.py
['one', '2', 'three (line 1)\n(line 2)']

Note that the third item in the row contains a newline
between (line 1) and (line 2).

With Python 2.5a1, I get:

c:\apps\python25\python.exe ./csv_test.py
['one', '2', 'three (line 1)(line 2)']

Notice the missing newline, which is significant.  The
CSV module under 2.5a1 seems to lose data.


--

Comment By: Skip Montanaro (montanaro)
Date: 2006-07-29 15:07

Message:
Logged In: YES 
user_id=44345

I checked in a change to libcsv.tex (revision 50953).  It adds a versionchanged 
bit to the reader doc that explains why the behavior changed in 2.5.  Andrew  
Andrew, please check my work.  Sorry for the delay taking care of this.

Skip


--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-07-29 12:24

Message:
Logged In: YES 
user_id=11375

I looked at this bug report, but I have no idea of exactly
what behaviour has changed or what needs to be described.


--

Comment By: Andrew McNamara (andrewmcnamara)
Date: 2006-06-22 22:34

Message:
Logged In: YES 
user_id=698599

Yep, your point about adding a comment to the documentation 
is fair. Skip, do you want to take my words and massage 
them into a form suitable for the docs?

--

Comment By: David Goodger (goodger)
Date: 2006-06-22 22:13

Message:
Logged In: YES 
user_id=7733

I didn't realize that the previous behavior was buggy; I
thought that the current behavior was a side-effect.  The
2.5 behavior did cause a small problem in Docutils, but it's
already been fixed.  I just wanted to ensure that no
regression was creeping in to 2.5.

Thanks for the explanation!  Perhaps it could be added to
the docs in some form?

Marking the bug report closed.

--

Comment By: Andrew McNamara (andrewmcnamara)
Date: 2006-06-22 19:27

Message:
Logged In: YES 
user_id=698599

The previous behaviour caused considerable problems, 
particularly on platforms that did not use the unix line-
ending conventions, or with files that originated on those 
platforms - users were finding mysterious newlines where 
they didn't expect them.

Quoted fields exist to allow characters that would otherwise 
be considered part of the syntax to appear within the field. 
 So yes, quoted fields are a special case, and necessarily 
so.

The current behaviour puts the control back in the hands of 
the user of the module: if literal newlines are important 
within a field, they need to read their file in a way that 
preserves the newlines. The old behaviour would introduce 
spurious characters into quoted fields, with no way for the 
user to control that behaviour.

I'm sorry that the change causes you problems. With a format 
that's as loosely defined as CSV, it's an unfortunate fact 
of life that there are going to be conflicting requirements. 

--

Comment By: David Goodger (goodger)
Date: 2006-06-22 13:17

Message:
Logged In: YES 
user_id=7733

I see what you're saying, but I disagree.  In Python 2.4,
csv.reader did not require newlines, but in Python 2.5 it
does.  That's a significant behavioral change.  In the
stdlib csv Module Contents docs for csv.reader, it says:
csvfile can be any object which supports the iterator
protocol and returns a string each time its next method is
called.  It doesn't mention newline-terminated strings.

In any case, the behavior is inconsistent: newlines are not
required to terminate row-ending strings, but only strings
which end inside cells split across rows.  Why the discrepancy?

--

Comment By: Andrew McNamara (andrewmcnamara)
Date: 2006-06-20 18:17

Message:
Logged In: YES 
user_id=698599

I think your problem is with str.splitlines(), rather than 
the csv.reader: splitlines ate the newline. If you pass it 
True as an argument, it will retain the end-of-line 
character in the resulting strings.


[ python-Bugs-960860 ] botched html for index subheadings

2006-07-29 Thread SourceForge.net
Bugs item #960860, was opened at 2004-05-26 10:17
Message generated for change (Comment added) made by fdrake
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=960860group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jim Jewett (jimjjewett)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: botched html for index subheadings

Initial Comment:
In the index, if a topic has subtopics, it should be listed 
as 
dttopic
dddldtsubtopic1
 dtsubtopic2
   /dl


In some cases (such as the reference manual entries for 
module, or object(continued)), it is correct.  In other 
cases (such as the entries for name, or the first column 
of object), the dddl.../dl wrapper is left out, so 
that the subentries appear to be normal entries that just 
happen to be out of alphabetical order.


--

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2006-07-29 16:15

Message:
Logged In: YES 
user_id=3066

This appears to be fine in the 2.4.3 and development
versions of the documentation.  If I'm missing something,
please be specific about what you think is wrong.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=960860group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1531016 ] Comman not allowed at the end of argument list for **argumen

2006-07-29 Thread SourceForge.net
Bugs item #1531016, was opened at 2006-07-29 20:21
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531016group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Roman Suzi (rnd0110)
Assigned to: Nobody/Anonymous (nobody)
Summary: Comman not allowed at the end of argument list for **argumen

Initial Comment:
This tells it all:

 str('sdfd', **a,)
  File stdin, line 1
str('sdfd', **a,)
   ^
SyntaxError: invalid syntax

 str('sdfd', *a,)
  File stdin, line 1
str('sdfd', *a,)
   ^
SyntaxError: invalid syntax

While the docs tell otherwise:

http://docs.python.org/ref/calls.html

While having arguments after ** doesn't make sense,
comma after ANY kinds of arguments seem to be more
consistent.




--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531016group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1531016 ] Comma not allowed at the end of argument list for **argument

2006-07-29 Thread SourceForge.net
Bugs item #1531016, was opened at 2006-07-29 20:21
Message generated for change (Settings changed) made by rnd0110
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531016group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.4
Status: Open
Resolution: None
Priority: 2
Submitted By: Roman Suzi (rnd0110)
Assigned to: Nobody/Anonymous (nobody)
Summary: Comma not allowed at the end of argument list for **argument

Initial Comment:
This tells it all:

 str('sdfd', **a,)
  File stdin, line 1
str('sdfd', **a,)
   ^
SyntaxError: invalid syntax

 str('sdfd', *a,)
  File stdin, line 1
str('sdfd', *a,)
   ^
SyntaxError: invalid syntax

While the docs tell otherwise:

http://docs.python.org/ref/calls.html

While having arguments after ** doesn't make sense,
comma after ANY kinds of arguments seem to be more
consistent.




--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531016group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1163367 ] correct/clarify documentation for super

2006-07-29 Thread SourceForge.net
Bugs item #1163367, was opened at 2005-03-14 18:39
Message generated for change (Comment added) made by fdrake
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1163367group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Steven Bethard (bediviere)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: correct/clarify documentation for super

Initial Comment:
The current documentation for super is confusing.  For
instance, it says that it returns the superclass of
type which is incorrect; it actually returns the next
type in type's MRO.  Well, to be truthful, it doesn't
even do that; it returns a proxy object which makes
that type's attributes available, but that's just
another reason to fix the documentation.

I suggest changing the wording to something like:

super(type[, object-or-type])

Return an object that exposes the attributes available
through the type's superclasses, without exposing the
attributes of the type itself.  Attributes will be
looked up using the normal resolution order, omitting
the first class in the MRO (that is, the type itself).

If the second argument is present, it should either be
an instance of object, in which case
isinstance(object-or-type, type) must be true, or it
should be an instance of type, in which case
issubclass(object-or-type, type) must be true.  The
typical use for this form of super is to call a
cooperative superclass method:

class C(B):
def meth(self, arg):
super(C, self).meth(arg)

If the second argument to super is omitted, the super
object returned will not expose any attributes
directly.  However,  attributes will be accessible
whenever the descriptor machinery is invoked, e.g.
though explicit invocation of __get__.

Note that super is undefined for implicit lookups using
statements or operators such as super(C, self)[name].
 These must be spelled out with their explicit lookup,
e.g. super(C, self).__getitem__(name). New in version
2.2. 


It's not perfect and I welcome suggestions for
re-wording, but I think it's substantially more
accurate about what super actually does.  It also moves
the second argument omitted situation to the end,
since this is a vastly more uncommon use case.

--

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2006-07-29 16:40

Message:
Logged In: YES 
user_id=3066

I'm not sure what the paragraph following the \end{verbatim}
means.  Can someone clarify?

--

Comment By: Georg Brandl (birkenfeld)
Date: 2006-01-20 12:06

Message:
Logged In: YES 
user_id=1188172

See also Bug #973579 (which I closed as duplicate) for
alternative wording.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1163367group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-960860 ] botched html for index subheadings

2006-07-29 Thread SourceForge.net
Bugs item #960860, was opened at 2004-05-26 14:17
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=960860group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: None
Status: Pending
Resolution: None
Priority: 5
Submitted By: Jim Jewett (jimjjewett)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: botched html for index subheadings

Initial Comment:
In the index, if a topic has subtopics, it should be listed 
as 
dttopic
dddldtsubtopic1
 dtsubtopic2
   /dl


In some cases (such as the reference manual entries for 
module, or object(continued)), it is correct.  In other 
cases (such as the entries for name, or the first column 
of object), the dddl.../dl wrapper is left out, so 
that the subentries appear to be normal entries that just 
happen to be out of alphabetical order.


--

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2006-07-29 20:15

Message:
Logged In: YES 
user_id=3066

This appears to be fine in the 2.4.3 and development
versions of the documentation.  If I'm missing something,
please be specific about what you think is wrong.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=960860group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1495229 ] W3C - Python DOM type mapping docs need updating

2006-07-29 Thread SourceForge.net
Bugs item #1495229, was opened at 2006-05-25 19:33
Message generated for change (Comment added) made by fdrake
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1495229group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Brown (mike_j_brown)
Assigned to: Martin v. Löwis (loewis)
Summary: W3C - Python DOM type mapping docs need updating

Initial Comment:
I believe the information at
http://docs.python.org/lib/dom-type-mapping.html is
outdated; most if not all boolean return values, at
least in minidom, are handled as BooleanType, not
IntegerType. This should be standard.

Sorry, I don't have a patch to submit for this. Should
be an easy fix though.

--

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2006-07-30 00:56

Message:
Logged In: YES 
user_id=3066

My position on this is that:

1) The docs are not wrong.

2) The docs should be updated to indicate that bool values
are returned where appropriate.

3) It is reasonable that Python developers know the
relationship between bool and int.  That is not something
that can reasonably change in Python 2.x.  It seems unlikely
to change for Python 3000.

4) The strict application of the IDL mapping really hasn't
helped in creating a good DOM-like interface for Python.

Dealing with the last item isn't within scope for handling
this issue.


--

Comment By: Mike Brown (mike_j_brown)
Date: 2006-06-03 17:01

Message:
Logged In: YES 
user_id=371366

If answer #1 is chosen and the others rejected, then the
docs remain misleading, since the average reader just wants
to know what types to expect from an implementation (or
should code into their implementation), and shouldn't be
expected to know the relationship between Booleans and
integers. Is it even reasonable to expect that this
relationship will always be true? In any case, I'd rather
see it made explicit as to why minidom doesn't seem, at
first, to respect the type mapping, at least in current
implementations. It could be as simple as adding Andrew's
comment, phrased as This DOM mapping is derived from the
IDL mapping for Python, which predates the introduction of
BooleanType, which is currently a subtype of IntegerType.
Implementations may use either type. or some such.

--

Comment By: A.M. Kuchling (akuchling)
Date: 2006-06-03 16:42

Message:
Logged In: YES 
user_id=11375

Martin, you probably need to make a pronouncement on this.  The DOM 
mapping is supposed to be derived from the IDL mapping for Python, which 
predates Booleans, but methods such as hasChildNodes() return True/False.
I can see at least three answers:

1) Booleans are subtypes of integers, so the docs are not wrong.

2) The docs are wrong and should say Boolean.

3) The methods should be returning regular 0 and 1, not True and False, and 
should be changed.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1495229group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com