Re: String Format Error.

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 10:19 PM, Paulo Repreza  wrote:
> Hi,
>
> I'm a newbie with python and I recently bought Beginning with Python (Which
> is a book I recommend) but the problem that I'm facing it's the following:
>
> This is the code:
>
> #!/usr/bin/python2.5
> # Filename: str_format.py
>
> age = 25
> name = 'foobar'
>
> print('{0} is {1} years old'.format(name, age))
> print('Why is {0} playing with that python?'.format(name))
>
>
> But when I run the script I receive this error:
>
> Traceback (most recent call last):
>   File "str_format.py", line 7, in 
> print('{0} is {1} years old'.format(name, age))
> AttributeError: 'str' object has no attribute 'format'
>
>
> It is an error because of the version that I'm using ? Python 2.5.2 (Debian
> lenny)

Yes, Python 2.6 or higher is required to use .format() according to
http://docs.python.org/whatsnew/2.6.html

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


String Format Error.

2008-12-22 Thread Paulo Repreza
Hi,

I'm a newbie with python and I recently bought Beginning with Python (Which
is a book I recommend) but the problem that I'm facing it's the following:

*This is the code:
*
#!/usr/bin/python2.5
# Filename: str_format.py

age = 25
name = 'foobar'

print('{0} is {1} years old'.format(name, age))
print('Why is {0} playing with that python?'.format(name))


*But when I run the script I receive this error:

*Traceback (most recent call last):
  File "str_format.py", line 7, in 
print('{0} is {1} years old'.format(name, age))
AttributeError: 'str' object has no attribute 'format'


It is an error because of the version that I'm using ? Python 2.5.2 (Debian
lenny)

Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread ajaksu
On Dec 22, 9:05 pm, Christian Heimes  wrote:
> ajaksu schrieb:
>
> > That said, a "decode to declared HTTP header encoding" version of
> > urlopen could be useful to give some users the output they want (text
> > from network io) or to make it clear why bytes is the safe way.
>
> Yeah, your idea sounds both useful and feasible. A patch is welcome! :)

Would monkeypatching what urlopen returns be good enough or should we
aim at a cleaner implementation?

Glenn, does this sketch work for you?

def urlopen_text(url, data=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
response = urlopen(url, data, timeout)
_readline = response.readline
_readlines = response.readlines
_read = response.read
charset = response.headers.get_charsets()[0]
def readline(limit = -1):
content = _readline()
return str(content, encoding=charset)
response.readline = readline
def readlines(hint = None):
content = _readlines()
return [str(line, encoding=charset) for line in content]
response.readlines = readlines
def read(n = -1):
content = _read()
return str(content, encoding=charset)
response.read = read
return response

Any comments/suggestions are very welcome. I could use some help from
people that know urllib on the best way to get the charset. Maybe
after some sleep I can code it in a less awful way :)

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


Re: using subprocess module in Python CGI

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 2:02 AM, ANURAG BAGARIA
 wrote:
> Hello,
>
> I am a Python Newbie and would like to call a short python script via
> browser using a CGI script, but initially I am trying to call the same
> python script directly through python command line. The script intends to
> perform a few command line in a pipe and I have written the script (a short
> one) as follows.
>
> #!/usr/bin/python
>
> import cgi, string, os, sys, cgitb, commands, subprocess
> import posixpath, macpath
> #file = "x.tar.gz"
> #comd = "tar -xf %s" % (file)
> #os.system(comd)
> #commands.getoutput('tar -xf x.tar.gz | cd demo; cp README ../')
> comd = [\
> "tar -xf x.tar.gz", \
> "cd demo", \
> "cp README ../", \
>   ]
> outFile = os.path.join(os.curdir, "output.log")
> outptr = file(outFile, "w")
> errFile = os.path.join(os.curdir, "error.log")
> errptr = file(errFile, "w")
> retval = subprocess.call(comd, 0, None, None, outptr, errptr)
> errptr.close()
> outptr.close()
> if not retval == 0:
> errptr = file(errFile, "r")
> errData = errptr.read()
> errptr.close()
> raise Exception("Error executing command: " + repr(errData))
>
>
> but after trying to execute this independently, I get the following error
> which I am unable to interpret :
>
> Traceback (most recent call last):
>   File "process.py", line 18, in 
> retval = subprocess.call(comd, 0, None, None, outptr, errptr)
>   File "/usr/lib/python2.5/subprocess.py", line 443, in call
> return Popen(*popenargs, **kwargs).wait()
>   File "/usr/lib/python2.5/subprocess.py", line 593, in __init__
> errread, errwrite)
>   File "/usr/lib/python2.5/subprocess.py", line 1135, in _execute_child
> raise child_exception

There should be at least one more line in this traceback, and that
line is the most important one.
People will need that line to help you with your problem.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterating initalizations

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 7:52 PM, Aaron Stepp  wrote:
>
> On Dec 22, 2008, at 10:43 PM, Chris Rebert wrote:
>
>> On Mon, Dec 22, 2008 at 7:32 PM, Aaron Stepp 
>> wrote:
>> 
>>>
>>> Thanks for the help so far, I think I'm starting to get a hang of the
>>> syntax.
>>>
>>> I think I need to state my goal more clearly.
>>>
>>> Instead of writing a long list of initializations like so:
>>>
>>> A = [ ]
>>> B = [ ]
>>> ...
>>> Y = [ ]
>>> Z = [ ]
>>>
>>> I'd like to save space by more elegantly turning this into a loop.  If I
>>> need to just write it out, I guess that's ok... but it would be much
>>> cleaner.  I'm a composer, not a programmer, so some of this is quite
>>> above
>>> me.
>>>
>>
>> So, are these variables supposed to be module-level, or attributes of
>> class pitchAndRhythm, or what?
>> Also, are you going to use the variables normally or are you going to
>> need "variable variables" (e.g. like $$var in PHP, which gives the
>> value of the variable with the name of the string stored in $var)?
>>
>> Cheers,
>> Chris
>>
>> --
>> Follow the path of the Iguana...
>> http://rebertia.com
>
>
> The're going to only be part of the pitchAndRhythm class.  Simply put, I
> just need enough arrays to hold a list of pitches/rhythms.  Then I'll have
> each list member returned to an instrument defined in another module.
>
> As I'm hacking away at the code, I'm realizing that maybe I can do this with
> just and A = [] and B = [].  But I'm not sure...
>

Do you really need to name them, or are the names arbitrary and you
only really care about having N distinct lists?

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread Rhodri James

On Tue, 23 Dec 2008 04:35:42 -, Grant Edwards  wrote:


IIRC, Python came pre-installed on my IBM Thinkpad.  However,
it wasn't anyplace the average user would stumble across it...


The suggestively named "IBMTOOLS" directory, I believe :-)

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterating initalizations

2008-12-22 Thread Rhodri James
On Tue, 23 Dec 2008 03:52:35 -, Aaron Stepp   
wrote:


Simply put, I just need enough arrays to hold a list of  
pitches/rhythms.  Then I'll have each list member returned to an  
instrument defined in another module.


One "array" can hold a list of pitches/rhythms.  I'm still not terribly
clear as to why you need so many.  Is each list intended for a different
instrument, so you're more looking at:

  violin_1 = [ ...stuff... ]
  violin_2 = [ ...other stuff...]
  viola = [ ...really sweet stuff... ]
  cello = [ ...really boring stuff... ]

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


cgitb and Apache

2008-12-22 Thread Robert Hancock
I have a cgi running in my alpha environment and, of course,
everything works fine.  In beta, when I attempt to access a page via
our proxy, which works perfectly in alpha.  It attempts to call cgitb
but freezes for while and then exits.

The Apache log show:

[Mon Dec 22 23:49:25 2008] [error] [client 172.16.143.75] /usr/local/
python26/lib/python2.6/cgitb.py:173: DeprecationWarning:
BaseException.message has been deprecated as of Python 2.6

[Mon Dec 22 23:49:25 2008] [error] [client 172.16.143.75]   value =
pydoc.html.repr(getattr(evalue, name))

The source for cgitb at 173 is:

 pydoc.html.escape(str(evalue)))]
if isinstance(evalue, BaseException):
for name in dir(evalue):
if name[:1] == '_': continue
  --->  value = pydoc.html.repr(getattr(evalue, name))
exception.append('\n%s%s =\n%s' % (indent, name,
value))

import traceback
return head + ''.join(frames) + ''.join(exception) + '''

Any suggestions on how to deal with this?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Event Driven programming - Doubts

2008-12-22 Thread Bryan Olson

Kottiyath wrote:

[...] I have not yet understood the implementation of
deferred. I went through a lot of tutorials, but I guess most places
they expect that the user already understands how events are
generated. The tutorials mention that there is no more threads once
twisted is used.

My question is as follows:
I have not understood how the callbacks are hit without (a)
blocking the code or (b) having new threads.

The usual example given is that of a program waiting for data coming
through a socket. In the tutorials, it is mentioned that -in an event
driven program, we schedule the code to hit when the remote server
gets back to us - .
Now, my question is - somebody has to still wait on that socket and
check whether the data is received, and once all the data is received,
call the appropriate callbacks.

Is twisted creating a micro-thread which just waits on the socket and
once the data is received, calls callFromThread for it to run on the
main loop?


No. Event-driven frameworks are built upon some system call that waits 
for events from multiple sources at once. The Python standard library 
exposes several such calls, the most portable of which is select(), in 
the module also named "select".


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

So how is something like deferred implemented? When you schedule action 
on your socket, you are telling the framework to include your socket in 
in subsequent calls to select(), until the socket selects as ready.


The framework keeps a single global list of sockets on which clients are 
waiting, and from this list it builds the select() parameters. A single 
call to select() waits on behalf of all the callbacks. The select() call 
returns a list of sockets ready for I/0; the framework iterates over the 
ready list, invoking the corresponding callbacks one by one. After the 
last callback returns, the framework loops back to select() again.


select() is not the only call to do multi-source I/O, and I'm not an 
expert on these frameworks, so take the above as a simplified general 
description.



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


Re: I always wonder ...

2008-12-22 Thread ajaksu
On Dec 22, 9:24 pm, r  wrote:
> You know what i hate more than a troll, a spineless jellyfish who goes
> around rating peoples post with one star. You are the lowest form of
> life. You are the same type of person who would key someones car in
> the parking lot. You do not have the balls to face you enemy.
>
> If who made a rating were visible, then i would have respect for you,
> but since you lurk in the shadows, you are scum. Come out and face me
> if you dare!
>
> I never have rated a post UNLESS i rate it with 5 stars, WHY, you ask,
> Because my balls are so big i walk around bow-legged! F'in  Cowards!

That would be me, for at least a dozen of your posts. Glad to know it
was more effective than telling you to shut up or calm down.

Cnidaria-ly y'rs,
Daniel
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 10:09 pm, Ben Kaplan  wrote:
> That's just because most of us don't say anything unless we have  
> something useful to say. We prefer to let the experts answer the  
> questions, but we read the threads so we can benefit from them.

OK Ben, So you are saying

1.) do not question the gods!
2.) speak only when spoken to!
3.) do not have an opinion!

Somehow this reminds me of some old and brainwashing religions, Not an
OSS project. Just observations Ben.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
The average user thinks python is only a very large snake!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread Grant Edwards
On 2008-12-22, Joe Strout  wrote:
> Alvin ONeal wrote:
>
>> Also worthy of mention:
>> I've seen python pre-installed on consumer HP desktops (I think as
>> part of a backup/restore script, but I'm not sure)
>
> It's pre-installed on every Mac (both desktop and laptop), too.

IIRC, Python came pre-installed on my IBM Thinkpad.  However,
it wasn't anyplace the average user would stumble across it...

-- 
Grant

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


Re: Python's popularity

2008-12-22 Thread Ben Kaplan



On Dec 22, 2008, at 9:51 PM, r  wrote:


On Dec 22, 7:34 pm, Steven D'Aprano
 wrote:

On Mon, 22 Dec 2008 10:01:21 -0800, r wrote:

Walter,
I just look at the stats for comp.lang.python, and i am 9th place  
for

most post this month.


And about 9,000th place for useful information.

--
Steven


I think you missed my point Steven, I was in no way proud of the fact
of my 9th place rating. It just proves my point to the small following
of this group. And frankly makes me feel bad.


That's just because most of us don't say anything unless we have  
something useful to say. We prefer to let the experts answer the  
questions, but we read the threads so we can benefit from them. Steven  
was pointing out that the number of posts you made has nothing to do  
with the overall audience of this list or how much real content you  
are contributing

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


Re: Twisted for non-networking applications

2008-12-22 Thread Bryan Olson

Kottiyath wrote:

   Is it a good idea to use Twisted inside my application, even though
it has no networking part in it?
   Basically, my application needs lots of parallel processing - but I
am rather averse to using threads - 


With or without threads, the Python interpreter does not do parallel 
processing. You could use multiple processes, or a thread could call an 
extension module that releases Python's global interpreter lock, but 
Python itself does not offer parallel processing.



due to myraid issues it can cause.
So, I was hoping to use a reactor pattern to avoid the threads.


The reactor pattern describes event-driven I/0, not parallel processing.


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


Re: iterating initalizations

2008-12-22 Thread Aaron Stepp


On Dec 22, 2008, at 10:43 PM, Chris Rebert wrote:

On Mon, Dec 22, 2008 at 7:32 PM, Aaron Stepp   
wrote:




Thanks for the help so far, I think I'm starting to get a hang of the
syntax.

I think I need to state my goal more clearly.

Instead of writing a long list of initializations like so:

A = [ ]
B = [ ]
...
Y = [ ]
Z = [ ]

I'd like to save space by more elegantly turning this into a loop.   
If I

need to just write it out, I guess that's ok... but it would be much
cleaner.  I'm a composer, not a programmer, so some of this is  
quite above

me.



So, are these variables supposed to be module-level, or attributes of
class pitchAndRhythm, or what?
Also, are you going to use the variables normally or are you going to
need "variable variables" (e.g. like $$var in PHP, which gives the
value of the variable with the name of the string stored in $var)?

Cheers,
Chris

--
Follow the path of the Iguana...
http://rebertia.com



The're going to only be part of the pitchAndRhythm class.  Simply put,  
I just need enough arrays to hold a list of pitches/rhythms.  Then  
I'll have each list member returned to an instrument defined in  
another module.


As I'm hacking away at the code, I'm realizing that maybe I can do  
this with just and A = [] and B = [].  But I'm not sure...


Thanks again.

AS

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


Re: iterating initalizations

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 7:32 PM, Aaron Stepp  wrote:

>
> Thanks for the help so far, I think I'm starting to get a hang of the
> syntax.
>
> I think I need to state my goal more clearly.
>
> Instead of writing a long list of initializations like so:
>
> A = [ ]
> B = [ ]
> ...
> Y = [ ]
> Z = [ ]
>
> I'd like to save space by more elegantly turning this into a loop.  If I
> need to just write it out, I guess that's ok... but it would be much
> cleaner.  I'm a composer, not a programmer, so some of this is quite above
> me.
>

So, are these variables supposed to be module-level, or attributes of
class pitchAndRhythm, or what?
Also, are you going to use the variables normally or are you going to
need "variable variables" (e.g. like $$var in PHP, which gives the
value of the variable with the name of the string stored in $var)?

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Beep

2008-12-22 Thread Jeffrey Barish
Tobias Andersson wrote:

> Jeffrey Barish skrev:
>> Chris Rebert wrote:
>>> Is the 'pcspkr' kernel module built and loaded?
>> 
>> Yes.  And I should have mentioned that I get sound from Ubuntu
>> applications that produce sound.
> 
> Also, is the terminal bell set to "visual"? If so chr(7) only
> produces a brief flash (or similar).

On Ubuntu, it is possible to set visual and audible beeps separately.  When
I set both, I get the visual beep, but not the audible one.  It's not a
Python issue -- so I should take this thread to Ubuntu -- because I observe
this behavior even when I hit backspace at the beginning of a line in a
terminal.
-- 
Jeffrey Barish

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


Re: iterating initalizations

2008-12-22 Thread r
>>> class test():
def __init__(self, name):
self.name = 'My name is %d' %name


>>> l = []
>>> for name in range(10):
l.append(test(name))


>>> l
[<__main__.test instance at 0x02852E18>, <__main__.test instance at
0x02852C38>, <__main__.test instance at 0x028528A0>, <__main__.test
instance at 0x02852E90>, <__main__.test instance at 0x02852EE0>,
<__main__.test instance at 0x02852F30>, <__main__.test instance at
0x02852F80>, <__main__.test instance at 0x02852FD0>, <__main__.test
instance at 0x023AFC60>, <__main__.test instance at 0x02855030>]
>>> l[0].name
'My name is 0'
>>> l[1].name
'My name is 1'
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterating initalizations

2008-12-22 Thread Aaron Stepp


On Dec 22, 2008, at 10:15 PM, r wrote:


I can't check you code because i don't have these modules but here is
the code with proper indention

import random
from rtcmix import *
from chimes_source import *
from rhythmblock import *
from pitchblock import *
indexrand = random.Random()
indexrand.seed(2)
rhythm = rhythmBlock()
pitch = pitchBlock()

class pitchAndRhythm:
   def __init__(self):
   self.__abet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   def listCreate(self, num):
   if num > 25:
   print "Oops.  This won't work"
   else:
   for a in range(num):
   b = indexrand.randint(0, 3)
   c = indexrand.randint(0, 7)
   index = self.__abet[a]
   index = [ ]
   index = index.append(rhythm.rhythmTwist(b, c))

take 2: notice the "(" and ")" around the arg to __init__



Thanks for the help so far, I think I'm starting to get a hang of the  
syntax.


I think I need to state my goal more clearly.

Instead of writing a long list of initializations like so:

A = [ ]
B = [ ]
...
Y = [ ]
Z = [ ]

I'd like to save space by more elegantly turning this into a loop.  If  
I need to just write it out, I guess that's ok... but it would be much  
cleaner.  I'm a composer, not a programmer, so some of this is quite  
above me.


I usually ask as a last resort, but I've been through the tutorial and  
didn't find this.  I've got a couple python books, but I'd like to  
finish this piece sooner than later.


Thanks!

AS

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


Re: iterating initalizations

2008-12-22 Thread r
I can't check you code because i don't have these modules but here is
the code with proper indention

import random
from rtcmix import *
from chimes_source import *
from rhythmblock import *
from pitchblock import *
indexrand = random.Random()
indexrand.seed(2)
rhythm = rhythmBlock()
pitch = pitchBlock()

class pitchAndRhythm:
def __init__(self):
self.__abet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def listCreate(self, num):
if num > 25:
print "Oops.  This won't work"
else:
for a in range(num):
b = indexrand.randint(0, 3)
c = indexrand.randint(0, 7)
index = self.__abet[a]
index = [ ]
index = index.append(rhythm.rhythmTwist(b, c))

take 2: notice the "(" and ")" around the arg to __init__
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread Christian Heimes
Glenn G. Chappell schrieb:
> Okay, so I guess I didn't really *get* the whole unicode/text/binary
> thing. Maybe I still don't, but I think I'm getting closer. Thanks to
> everyone who replied.

The basic principal is easy. On the one hand you have some text as
unicode data, on the other hand you have some binary data that may
contain text in an arbitrary encoding. In order to get the text you have
to decode the byte data into unicode. The other way around is called
encoding.

Everybody in the whole world has to deal with unicode *unless* you are
living in USA and all you have is plain and simple ASCII text. Python
2.x makes no difference between text in ASCII and arbitrary bytes. Both
are stored in the str type. This makes it easy for ASCII country but the
rest of the world suffers the consequences.

Python 3.0 makes a hard break for ASCII people because with 3.0 really
everybody has to deal with encodings. There is no more implicit
conversion between ASCII text and unicode.
http://www.joelonsoftware.com/articles/Unicode.html explains it in great
detail.

> 
> On Dec 22, 1:41 pm, ajaksu  wrote:
>> On Dec 22, 8:25 pm, Christian Heimes  wrote:
>> That said, a "decode to declared HTTP header encoding" version of
>> urlopen could be useful to give some users the output they want (text
>> from network io) or to make it clear why bytes is the safe way.
> 
> Sounds like a great idea. More to the point, it sounds like it's
> pretty much a necessary idea.
> 
> Consider: reading a web page is an easy one-liner. Now, no one is
> going to write that one-liner, and then spend 20 lines trying to get
> the Content-Type and encoding figured out. Instead we're all going to
> do it the short, easy, *wrong* way. So every program in the world that
> uses urlopen gets to have the same bug. Not good. The *right* way
> needs to be the *easy* way.

Python 2.x suffers from the same problem. It just doesn't tell you from
the beginning that you need to deal with the problem. With 2.x you can
read websites fine - until you have to deal with a non English, non
ASCII text. 3.0 forces the developer to think about the issue right from
the beginning. No more excuses :)

I suggest somebody makes a feature request for 3.1. A patch with unit
test increases the changes for the patch by at least one magnitude.

Christian

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


Re: iterating initalizations

2008-12-22 Thread r
I can't check you code because i don't have these modules but here is
the code with proper indention


import random
from rtcmix import *
from chimes_source import *
from rhythmblock import *
from pitchblock import *
indexrand = random.Random()
indexrand.seed(2)
rhythm = rhythmBlock()
pitch = pitchBlock()

class pitchAndRhythm:
def __init__self:
self.__abet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def listCreate(self, num):
if num > 25:
print "Oops.  This won't work"
else:
for a in range(num):
b = indexrand.randint(0, 3)
c = indexrand.randint(0, 7)
index = self.__abet[a]
index = [ ]
index = index.append(rhythm.rhythmTwist(b, c))
--
http://mail.python.org/mailman/listinfo/python-list


Re: noob trouble with IDLE

2008-12-22 Thread r
Yea, if you use Tkinter in concert with IDLE, your script will lock up.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 7:34 pm, Steven D'Aprano
 wrote:
> On Mon, 22 Dec 2008 10:01:21 -0800, r wrote:
> > Walter,
> > I just look at the stats for comp.lang.python, and i am 9th place for
> > most post this month.
>
> And about 9,000th place for useful information.
>
> --
> Steven

I think you missed my point Steven, I was in no way proud of the fact
of my 9th place rating. It just proves my point to the small following
of this group. And frankly makes me feel bad.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread Glenn G. Chappell
Okay, so I guess I didn't really *get* the whole unicode/text/binary
thing. Maybe I still don't, but I think I'm getting closer. Thanks to
everyone who replied.

On Dec 22, 1:41 pm, ajaksu  wrote:
> On Dec 22, 8:25 pm, Christian Heimes  wrote:
> That said, a "decode to declared HTTP header encoding" version of
> urlopen could be useful to give some users the output they want (text
> from network io) or to make it clear why bytes is the safe way.

Sounds like a great idea. More to the point, it sounds like it's
pretty much a necessary idea.

Consider: reading a web page is an easy one-liner. Now, no one is
going to write that one-liner, and then spend 20 lines trying to get
the Content-Type and encoding figured out. Instead we're all going to
do it the short, easy, *wrong* way. So every program in the world that
uses urlopen gets to have the same bug. Not good. The *right* way
needs to be the *easy* way.

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


Re: Python's popularity

2008-12-22 Thread Tommy Grav


On Dec 22, 2008, at 5:16 PM, Joe Strout wrote:


Alvin ONeal wrote:


Also worthy of mention:
I've seen python pre-installed on consumer HP desktops (I think as
part of a backup/restore script, but I'm not sure)


It's pre-installed on every Mac (both desktop and laptop), too.


Mac and a lot of linux distros use python as an integral part of their
OS development, so most of these actually come with some python
pre-installed (and one should not remove it unless you want to screw
up your OS).

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


RE: Python's popularity

2008-12-22 Thread Ellinghaus, Lance

> > Alvin ONeal wrote:
> > > Also worthy of mention:
> > > I've seen python pre-installed on consumer HP desktops (I think as
> > > part of a backup/restore script, but I'm not sure)
> >
> > It's pre-installed on every Mac (both desktop and laptop), too.

> I am using a Vista HP right now that came pre-installed with Python.
> Blew my mind when i found out :). This single reason just reinforced
> my belief in Python. Now if we can get Python on every windows
> platform...

Check out IronPython. Fully supported and FUNDED by Micro$oft!

http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython


Lance Ellinghaus


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


Re: no sign() function ?

2008-12-22 Thread Steven D'Aprano
On Mon, 22 Dec 2008 14:51:32 +0100, Pierre-Alain Dorange wrote:

> I'm new to python and here i discover at least 4 methods, i just make a
> small script for timing those methods (100 000 times each on a set of 10
> values).
> I do not use timeit, i can't make it work easyly as it need a standalone
> env for each test.

But that's just what timeit does: it creates a standalone environment for 
each test.


>  the test script  #!/usr/bin/env python
> 
> from math import atan2
> import time
> 
> 
> def sign_0(x):
> if x==0.0:
> return 0.0
> elif x>0.0:
> return 1.0
> else:
> return -1.0
> 
> def sign_1(x):
> if x > 0 or (x == 0 and atan2(x, -1.) > 0.):
> return 1
> else:
> return -1
> 
> def sign_2(x):
> return cmp(x, 0)
> 
> sign_3 = lambda x:+(x > 0) or -(x < 0)
> 
> def main():
> candidates=[1.1,0.0,-0.0,-1.2,2.4,5.6,-8.2,74.1,-23.4,7945.481]
> 
> startTime = time.clock()

time.clock() is low resolution on non-Windows systems. If you are using 
Windows, this is okay, if you are not, you are shooting yourself in the 
foot.


> for i in range(10):
> for value in candidates:

Horribly inaccurate, because you are including the time to build a range 
of 100,000 integers. In Python 3, that will only be a little bit 
inaccurate, but in Python 2.x that will have a MAJOR effect -- possibly 
swamping the actual function you are calling.


> s=sign_0(value)
> print "sign_0 : ",time.clock() - startTime

You are (possibly) including the time taken to print to std out in your 
time.


> startTime = time.clock()
> for i in range(10):
> for value in candidates:
> s=sign_1(value)
> print "sign_1 : ",time.clock() - startTime

Repeated code is poor coding practice. Write a function that takes a 
function as argument, and call that:

def timer(function, candidates, count=10):
loop = [None]*count
startTime = time.clock()
for i in loop:
for value in candidates:
s = function(value)
return time.clock() - startTime

But this is just duplicating what timeit already does. Trust me, learn to 
use it, you won't be sorry. Here's a trick that took me a long time to 
learn: instead of copying your functions into the setup code of timeit, 
you can just import them.

This is what I would do (untested):


candidates=[1.1,0.0,-0.0,-1.2,2.4,5.6,-8.2,74.1,-23.4,7945.481]
setup = "from __main__ import sign_%d, candidates"
from timeit import Timer
template = "for x in candidates: s = sign_%d(x)"
for i in range(4):
t = min( Timer(template % i, setup % i).repeat() )
print "Testing sign_%d:" % i, t, "seconds"





>  conclusions ---

None of your conclusions are safe until you have re-tested with a better 
timing method. That doesn't mean you are wrong, only that your reasons 
for believing them are weak.



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


Re: Python's popularity

2008-12-22 Thread Steve Holden
r wrote:
> [Jeff]
> but I raise the bar so that any random joker probably won't bother
> (and making the reverse mapping - knowing my real identity and then
> looking for recent net activity - is much more difficult to do)
> [/Jeff]
> 
> You are the epitimy of an internet troll. A troll tries to hide his
> identity. Why are you so concerned about your TRUE identity. Are the
> FEDS after you, maybe it's the Martians i do not know? Did they take
> into their spaceship and do things to you? Do you wear a aluminum foil
> hat. Look out for those cell towers, there mind control devices
> hahaha. Thanks for the good laugh.

Pot, meet kettle. Kettle: pot.
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Python's popularity

2008-12-22 Thread Steven D'Aprano
On Mon, 22 Dec 2008 10:01:21 -0800, r wrote:

> Walter,
> I just look at the stats for comp.lang.python, and i am 9th place for
> most post this month.


And about 9,000th place for useful information.



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


Re: Python's popularity

2008-12-22 Thread Steve Holden
walterbyrd wrote:
[...]>> Fooled by version numbers ?
> 
> No, but I am giving django the benefit of the doubt. The django
> project told people all along that django was not to be considered
> production ready before 1.0. I will accept that some people decided to
> wait until 1.0 came out to do any production development. Maybe django
> is only lagging because 1.0 just came out?
> 
The Django people said no such thing. They maintained the trunk as
stable - they test so well that many people did indeed rely on the trunk
for production systems.

They did, sensibly in my opinion, refuse to promise that the 1.0 release
would be backward-compatible with the development versions. Indeed they
frequently changed the trunk in incompatible ways while they were
working to find the best APIs, and this only affected those brave or
stupid enough to update their Django installation automatically as
checkins were made. Anyone would expect trouble doing that, and yet the
affected sites were usually easily fixed, thanks to the project's
conscientious maintenance of a list of incompatible changes.

>> My actual CTO is a big Ruby/Rails fan, yet he settled on Python/Django
>> for our current 'big' project. Wonder why ?
> 
> Not knowing much about RoR: yes, I wonder why? Is it because python
> has a cleaner syntax? Or what?

It's because he decided that Django was the best tool for the particular
job, making him unusually open-minded for a member of the pointy-haired
species. Unlike some on this list he doesn't let his prejudices blind
him to reality.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: New Python 3.0 string formatting - really necessary?

2008-12-22 Thread Steven D'Aprano
On Mon, 22 Dec 2008 06:58:06 -0800, walterbyrd wrote:

> On Dec 21, 12:28 pm, Bruno Desthuilliers
>  wrote:
>> Strange enough,
>> no one seems to complain about PHP or Ruby's performances...
> 
> A few years back, there was a certain amount of chest thumping, when
> python/django easily beat ror in a benchmark test. Now that ruby is
> faster, I guess speed is no big issue.

Who was doing this chest-thumping? Fanboys like "r"? Why should you tar 
all of us with their immaturity?


> By the same reasoning, python advocates used to sneer at php because php
> constantly broke backward compatibility. Now that python does it,
> breaking backward compatibility is no big deal.

No, breaking backward compatibility IS a big deal. That's why Python is 
doing it slowly and carefully: the minimum amount of breakage necessary, 
and with the Python 2.x series kept going in parallel for at least two 
additional versions.

> I guess unicode support
> was not that important, until python caught up to perl.

Python has had unicode support for a long time. You just needed to write 
u'' instead of ''.


> I guess, the way it works is: you first assume that python is superior,
> then you figure out why.

Just keep on trollin'.



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


Re: Python's popularity

2008-12-22 Thread Steven D'Aprano
On Mon, 22 Dec 2008 07:11:02 -0800, walterbyrd wrote:

> I have read that python is the world's 3rd most popular language

Oh, well if it's written down it must be true.



> But, I can't help but wonder how python's popularity was determined. 

Why don't you ask the people who made the claim?


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


Re: noob trouble with IDLE

2008-12-22 Thread Rhodri James
On Sun, 21 Dec 2008 21:46:16 -, Ronald Rodriguez  
 wrote:


Hi, Im new to python and I've just started using Byte of Python, running  
the

samples etc. Im using IDLE on Xp. Ok, here's the thing.
A sample script makes a call to the os.system() function in order to zip
some files. Everything works fine when running from the command line, but
the same code fails when I try Run --> Run module on IDLE. Im using 7z to
zip the files. Again, everything is OK when running from the command  
line.

Remember, Im new to python and programming. I've done some google search
without results. Maybe its just too simple :-(  . Any help would be
appreciated. Thanks in advance.


When you say "the same code fails" when run via IDLE, what exactly do you
mean?  Does it produce huge amounts of traceback and whinging?  Does it
lock up IDLE entirely?  Does it thumb its nose at you and go off to dance
the night away in Ibiza?

Absent that information, my best guess is that 7z has its own internal
event loop (a quick Google suggests that it's a GUI tool) which fights
for dominance with IDLE's event loop.  This is a fairly common problem,
and a good reason for avoiding using IDLE's "Run Module" for anything
but the most straightforward Python code.

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: I always wonder ...

2008-12-22 Thread John Machin
On Dec 23, 10:24 am, r  wrote:

> Because my balls are so big i walk around bow-legged!

Have you considered that your alleged testicular enormity may in fact
be an illusion caused by a hernia?



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


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 6:18 pm, Aaron Brady  wrote:
> Us small-minded people have hopes and dreams just like anybody else,
> Thurston.

Now thats the kind of friendly banter this group could use. Instead of
people acting as if their bowel-movements smell like bakery fresh
cinnamon rolls!
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to represent a sequence of raw bytes

2008-12-22 Thread Steven Woody
On Tue, Dec 23, 2008 at 5:05 AM, John Machin  wrote:
> On Dec 23, 1:52 am, "Steven Woody"  wrote:
>> On Mon, Dec 22, 2008 at 6:44 PM, Steven D'Aprano
>>
>>  wrote:
>> > On Mon, 22 Dec 2008 14:56:45 +0800, Steven Woody wrote:
>>
>> >> The intension is to allocate 200 undefined bytes in memory.
>>
>> > You *want* undefined bytes? Out of curiosity, what do you intend to do
>> > with them?
>>
>> to receive/send network packets, read raw files, etc.  After read
>> replies of the thread, I think 'array' or 'struct' maybe what I
>> wanted, may a plain list can do, but I am not sure.
>
> [Rhetorical questions] How do you use "undefined bytes" to receive
> network packets?? Do you really want to use "undefined bytes" to
> *send* network packets
>
> Suggestion: Stop trying to replicate C in Python; think about what you
> are trying to accomplish at a higher level, then how to implement that
> in Python.
>
> Cheers,
> John

Good suggestion, thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Re: iterating initalizations

2008-12-22 Thread bearophileHUGS
Chris Rebert:
> It likely goes without saying, but you ought to read the fine tutorial as 
> well.

I also suggest to fix the messed up indentations.

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread Aaron Brady
On Dec 22, 4:07 pm, r  wrote:
> On Dec 22, 3:15 pm, je.s.t...@hehxduhmp.org wrote:
>
> > r  wrote:
> > > We see where you stand. And also see that by removing your comments
> > > from the archive in 5 days, how small your acorns really are.
>
> > Also, it is pretty hard to take such accusations seriously from someone
> > who themselves is using a generic gmail address w/o their real name
> > attached to it.  If I didn't care about using a proper NNTP client, I
> > could quite easily create some dufus account on Gmail and post through
> > that just like you did - I'm sure that'd really increase my credibility!
>
> Would you trust my words more if i used a name like "Thurstan Howell
> III" Come on, don't tell me you are that shallow. To attack my
> credibility solely based on my user name is the sport of small minded
> people. Surely you can bring more thought, and intelligence to this
> thread than that?...

Us small-minded people have hopes and dreams just like anybody else,
Thurston.
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Python 3.0 string formatting - really necessary?

2008-12-22 Thread r
On Dec 22, 5:53 pm, Aaron Brady  wrote:
> On Dec 22, 11:40 am, r  wrote:
>
>
>
> > On Dec 22, 8:58 am, walterbyrd  wrote:
>
> > > On Dec 21, 12:28 pm, Bruno Desthuilliers
>
> > >  wrote:
> > > > Strange enough,
> > > > no one seems to complain about PHP or Ruby's performances...
>
> > > A few years back, there was a certain amount of chest thumping, when
> > > python/django easily beat ror in a benchmark test. Now that ruby is
> > > faster, I guess speed is no big issue.
>
> > > By the same reasoning, python advocates used to sneer at php because
> > > php constantly broke backward compatibility. Now that python does it,
> > > breaking backward compatibility is no big deal. I guess unicode
> > > support was not that important, until python caught up to perl.
>
> > > I guess, the way it works is: you first assume that python is
> > > superior, then you figure out why.
>
> > I think what walter is saying is the loyalty is gone.
>
> > community:
> > """If python makes great, if it doesn't, why should "i" care if it
> > goes down the toilet?  i just move to ruby"""
>
> > Were is your loyalty pyfans?, Has the fight left you???
>
> Point: It is not rational for the crew to go down with the ship, only
> the captain.
>
> Case: Loyalty is a complex emotion, and it's not clear that it's our
> highest priority, or that it's anyone's.
>
> I want to use a good language.  If Python stops being good (that is, a
> good version of Python stops being maintained and supported), then
> I'll stop using it, and that's the rational thing to do.
>
> Just to be fair, though, it's (contraction) not obviously irrational
> for a captain to go down with the ship.  The mentality, commitments,
> and principles that it lets him keep and make may be better on the
> whole in the long run for captains, crews, and ships, only if they
> have that consequence.  That is, captains that will go down with the
> ship are better captains of ships, and captains that have the capacity
> to betray, forge, or abandon principles make worse captains; therefore
> a good captain will go down, and can't change his mind.
>
> However, as critics and fans of Python, our actions don't really have
> the same consequences as the captains.  That is, it is not rational
> for the crew to go down with the ship, only the captain.

What if the crew sabotage the ship, should the captain still go down
with it, even though sabatuers are to blame?

All ships need a good captain, all captains need a good crew, and all
crews need a good ship.(also True in reverse()). Without loyalty
python will fail, so will Ruby, so will C. Sometimes even when loyalty
is scarce, a language will survive solely because it is the only ship
available.

You do not have to fight for python as I do to use it and benefit from
it, that's OK. I don't care either way. But don't piss on me for
trying to keep her a-float, Mate!.
--
http://mail.python.org/mailman/listinfo/python-list


Re: New Python 3.0 string formatting - really necessary?

2008-12-22 Thread Aaron Brady
On Dec 22, 11:40 am, r  wrote:
> On Dec 22, 8:58 am, walterbyrd  wrote:
>
>
>
> > On Dec 21, 12:28 pm, Bruno Desthuilliers
>
> >  wrote:
> > > Strange enough,
> > > no one seems to complain about PHP or Ruby's performances...
>
> > A few years back, there was a certain amount of chest thumping, when
> > python/django easily beat ror in a benchmark test. Now that ruby is
> > faster, I guess speed is no big issue.
>
> > By the same reasoning, python advocates used to sneer at php because
> > php constantly broke backward compatibility. Now that python does it,
> > breaking backward compatibility is no big deal. I guess unicode
> > support was not that important, until python caught up to perl.
>
> > I guess, the way it works is: you first assume that python is
> > superior, then you figure out why.
>
> I think what walter is saying is the loyalty is gone.
>
> community:
> """If python makes great, if it doesn't, why should "i" care if it
> goes down the toilet?  i just move to ruby"""
>
> Were is your loyalty pyfans?, Has the fight left you???

Point: It is not rational for the crew to go down with the ship, only
the captain.

Case: Loyalty is a complex emotion, and it's not clear that it's our
highest priority, or that it's anyone's.

I want to use a good language.  If Python stops being good (that is, a
good version of Python stops being maintained and supported), then
I'll stop using it, and that's the rational thing to do.

Just to be fair, though, it's (contraction) not obviously irrational
for a captain to go down with the ship.  The mentality, commitments,
and principles that it lets him keep and make may be better on the
whole in the long run for captains, crews, and ships, only if they
have that consequence.  That is, captains that will go down with the
ship are better captains of ships, and captains that have the capacity
to betray, forge, or abandon principles make worse captains; therefore
a good captain will go down, and can't change his mind.

However, as critics and fans of Python, our actions don't really have
the same consequences as the captains.  That is, it is not rational
for the crew to go down with the ship, only the captain.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
[Jeff]
but I raise the bar so that any random joker probably won't bother
(and making the reverse mapping - knowing my real identity and then
looking for recent net activity - is much more difficult to do)
[/Jeff]

You are the epitimy of an internet troll. A troll tries to hide his
identity. Why are you so concerned about your TRUE identity. Are the
FEDS after you, maybe it's the Martians i do not know? Did they take
into their spaceship and do things to you? Do you wear a aluminum foil
hat. Look out for those cell towers, there mind control devices
hahaha. Thanks for the good laugh.
--
http://mail.python.org/mailman/listinfo/python-list


Re: 64-bit / 128-bit data element type for array?

2008-12-22 Thread akineko

Robert wrote:
> Ah, good. numpy lets you construct your own data types from the primitives.
> Since you don't actually need uint128 arithmetic, you don't need a uint128
> primitive. You can just use dtype('V16') (meaning "void, 16 bytes long") ...

Impressive.
I installed NumPy and it worked like a charm (I used uint64).

The above feature is quite useful as the bus size inside a microchip
is getting wider and wider (to get higher performance).

Again, thank you for replying to my posting.

Happy Holidays!
Aki Niimura
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are python objects thread-safe?

2008-12-22 Thread Aaron Brady
On Dec 22, 2:59 am, Duncan Booth  wrote:
> RajNewbie  wrote:
> > Say, I have two threads, updating the same dictionary object - but for
> > different parameters:
> > Please find an example below:
> > a = {file1Data : '',
> >        file2Data : ''}
>
> > Now, I send it to two different threads, both of which are looping
> > infinitely:
> > In thread1:
> > a['file1Data'] = open(filename1).read
> >           and
> > in thread2:
> > a['file2Data'] = open(filename2).read
>
> > My question is  - is this object threadsafe? - since we are working on
> > two different parameters in the object. Or should I have to block the
> > whole object?
>
> It depends exactly what you mean by 'threadsafe'. The GIL will guarantee
> that you can't screw up Python's internal data structures: so your
> dictionary always remains a valid dictionary rather than a pile of bits.
>
> However, when you dig a bit deeper, it makes very few guarantees at the
> Python level. Individual bytecode instructions are not guaranteed
> atomic: for example, any assignment (including setting a new value into
> the dictionary) could overwrite an existing value and the value which is
> overwritten may have a destructor written in Python. If that happens you
> can get context switches within the assignment.

Th.1   Th.2
a=X
   a=Y
a=Z

You are saying that if 'a=Z' interrupts 'a=Y' at the wrong time, the
destructor for 'X' or 'Y' might not get called.  Correct?  In serial
flow, the destructor for X is called, then Y.

> Other nasty things can happen if you use dictionaries from multiple
> threads. You cannot add or remove a dictionary key while iterating over
> a dictionary. This isn't normally a big issue, but as soon as you try to
> share the dictionary between threads you'll have to be careful never to
> iterate through it.

These aren't documented, IIRC.  Did you just discover them by trial
and error?

> You will probably find it less error prone in the long run if you get
> your threads to write (key,value) tuples into a queue which the
> consuming thread can read and use to update the dictionary.

Perhaps there's a general data structure which can honor 'fire-and-
forget' method calls in serial.

a= async( {} )
a[0]= X
a[0]= Y

-->
obj_queue[a].put( a.__setitem__, 0, X )
obj_queue[a].put( a.__setitem__, 0, Y )

If you need the return value, you'll need to block.

print a[0]
-->
  res= obj_queue[a].put( a.__getitem__, 0 )
  res.wait()
  return res
print res

Or you can use a Condition object.  But you can also delegate the
print farther down the line of processing:

obj_queue[a].link( print ).link( a.__getitem__, 0 )

(As you can see, the author (I) finds it a more interesting problem to
get required information in the right places at the right times in
execution.  The actual implementation is left to the reader; I'm
merely claiming that there exists a consistent one taking the above
instructions to be sufficient givens.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: I always wonder ...

2008-12-22 Thread r
You know what i hate more than a troll, a spineless jellyfish who goes
around rating peoples post with one star. You are the lowest form of
life. You are the same type of person who would key someones car in
the parking lot. You do not have the balls to face you enemy.

If who made a rating were visible, then i would have respect for you,
but since you lurk in the shadows, you are scum. Come out and face me
if you dare!

I never have rated a post UNLESS i rate it with 5 stars, WHY, you ask,
Because my balls are so big i walk around bow-legged! F'in  Cowards!
--
http://mail.python.org/mailman/listinfo/python-list


Re: 64-bit / 128-bit data element type for array?

2008-12-22 Thread Robert Kern

akineko wrote:

Hello Robert,


Is that actually a 2s-complement 128-bit unsigned integer, or is it just a
128-bit-long chunk of data?


That is a good question.
A 128-bit data can be anything.
A 128-bit data can be an instrution code (VLIW machines use such wide
instruction). A 128-bit can be a packed ascill (16 chrs).
A 128-bit can be a descriptor (a structure of various fields).
It is probably safe to say that only unsigned 128-bit is required.
(I cannot think of any situations where signed 128-bit is necessary)


Ah, good. numpy lets you construct your own data types from the primitives. 
Since you don't actually need uint128 arithmetic, you don't need a uint128 
primitive. You can just use dtype('V16') (meaning "void, 16 bytes long") for the 
"anything" and "instruction codes" and possible as an intermediate format. 
Byteswapping will work just fine. Use can use dtype('S16') for the ASCII. If the 
structure can be described by bytes, then the structured dtypes will work just 
fine. Unfortunately, we don't support bit-fields.


If you need bit-field support, you may want to take a look at Construct. 
Actually, you may want to look at Construct anyways.


  http://construct.wikispaces.com/

--
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: iterating initalizations

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 2:22 PM, Aaron Stepp  wrote:
> Hi all:
>
> I'm new to python and trying to save time and code by iterating through list
> initializations as well as the assignments.  I have the following code:
>
> import random
> from rtcmix import *
> from chimes_source import *
> from rhythmblock import *
> from pitchblock import *
>
> indexrand = random.Random()
> indexrand.seed(2)
>
> rhythm = rhythmBlock()
> pitch = pitchBlock()
>
> class pitchAndRhythm:
>
>def __init__self:
>
>self.__abet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>
>
> def listCreate(self, num):
>
>if num > 25:
>
>print "Oops.  This won't work"
>
>else:
>
>for a in range(num):
>
>b = indexrand.randint(0, 3)
>
>c = indexrand.randint(0, 7)
>

I don't quite understand what you're trying to do, but I can offer some advice.

>index = self.__abet[a]
The previous line is pointless currently. I don't understand what you
expect it to do, considering you completely overwrite 'index' in the
very next line.

>index = [ ]
>
>index = index.append(rhythm.rhythmTwist(b, c))
Important Note: .append() modifies the list *in-place*. It does *not*
return the modified list, it returns None. You probably want to
eliminate the 'index =' part of the previous line.

>
> This doesn't do what I expect (probably because I don't have a clue what I'm
> doing!): initalizing, then filling new arrays, each new one called A[ ],
> then B[ ], etc.

You probably want a dictionary of names to lists then, the names being
items of __abet and the lists being the corresponding 'index'.

It likely goes without saying, but you ought to read the fine tutorial as well.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread Christian Heimes
ajaksu schrieb:
> That said, a "decode to declared HTTP header encoding" version of
> urlopen could be useful to give some users the output they want (text
> from network io) or to make it clear why bytes is the safe way.

Yeah, your idea sounds both useful and feasible. A patch is welcome! :)

Christian

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


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 4:14 pm, je.s.t...@hehxduhmp.org wrote:
> r  wrote:
> > Would you trust my words more if i used a name like "Thurstan Howell
> > III" Come on, don't tell me you are that shallow. To attack my
> > credibility solely based on my user name is the sport of small minded
> > people. Surely you can bring more thought, and intelligence to this
> > thread than that?...
>
> I'm just saying that there's absolutely no more credibility attached
> to some random & anonymous account than there is to someone due to
> not having X-No-Archive.  You are no more accountable for your words than
> I am.  So you might be throwing stones at my use of X-No-Archive, but
> you are living in a glass house.
>
> And for the record, the obfuscation of my email address and the use of
> X-No-Archive has a lot more to do with random people being able to
> track me via the internet than it does with believing/not believing what
> I'm saying.  If one wanted to put in some small bit of effort, it isn't
> particularly difficult to track down usenet posts authored by me from
> 15ish years ago, but I raise the bar so that any random joker probably won't
> bother (and making the reverse mapping - knowing my real identity and then
> looking for recent net activity - is much more difficult to do).

An exercise in thought...
To go a bit further, what if we could post a picture of ourselves on
the Usenet?? What would stop me from posting a picture of someone else
besides myself? NOTHING!

Do not put your trust in such weak beliefs. My name and picture mean
squat on a this medium. If you want to validate my intelligence, use
my words, not shallow assumptions. Your logic is like that fruitcake
my auntie makes every Christmas. Please put more thought into you
post.

My words are here and they will stay here, sure some may disagree with
my thoughts, but i will not be ashamed of them! Thats called having
"brass Cohones" mi hijo.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread ajaksu
On Dec 22, 8:25 pm, Christian Heimes  wrote:
> It's not possible unless you know the encoding of the bytes. Network io
> only returns byte and you must encode it explicitly.
[...]
> There is no generic and simple way to detect the encoding of a remote
> site. Sometimes the encoding is mentioned in the HTTP header, sometimes
> it's embedded in the  section of the HTML document.

That said, a "decode to declared HTTP header encoding" version of
urlopen could be useful to give some users the output they want (text
from network io) or to make it clear why bytes is the safe way.

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


Re: New Python 3.0 string formatting - really necessary?

2008-12-22 Thread Arnaud Delobelle
Steven D'Aprano  writes:

> Instead of just whinging, how about making a suggestion to fix it? Go on, 
> sit down for an hour or ten and try to work out how a BINARY OPERATOR 
> like % (that means it can only take TWO arguments) can deal with an 
> arbitrary number of arguments, *without* having any special cases.
>
> Go on. Take your time. I'll be waiting.

Well that's easy.  I see 'r' didn't answer so I will: only accept tuples
on the right hand side of the %, so all arguments have to be put inside
a tuple.

>>> "%s" % 42
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for %: 'str' and 'int'
>>> "%s" % (42,)
'42'

Of course there would still be the possibility of uncaught bugs when
people forget to put the argument in a tuple if the argument itself is a
tuple of length 1.

>>> def foo(x):
... print "foo(%s)" % x
... # should be % (x,)
... 
>>> foo('a')
TypeError: unsupported operand type(s) for %: 'str' and 'str'
>>> # But if x is a tuple of length 1 the error is not reported
>>> foo((1,))
foo(1)

That's why .format() is a better option IMHO.

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


Re: 64-bit / 128-bit data element type for array?

2008-12-22 Thread akineko
Hello Robert,

> Is that actually a 2s-complement 128-bit unsigned integer, or is it just a
> 128-bit-long chunk of data?

That is a good question.
A 128-bit data can be anything.
A 128-bit data can be an instrution code (VLIW machines use such wide
instruction). A 128-bit can be a packed ascill (16 chrs).
A 128-bit can be a descriptor (a structure of various fields).
It is probably safe to say that only unsigned 128-bit is required.
(I cannot think of any situations where signed 128-bit is necessary)

Hope this answers your question.

Aki Niimura

On Dec 22, 1:22 pm, Robert Kern  wrote:
> akineko wrote:
> > Hello,
>
> > bearophile and  Robert, thank you for your prompt response.
> > I will try NumPy (this is a good execuse to learn and to use a new
> > package).
>
> >> I haven't seen uint128 in the wild, though.
>
> > Of course, not many applications require uinit128 as a scalar value.
> > I may need to deal with 128-bit data as it is now not uncommon to have
> > 128-bit data bus (or even 256-bit wide and beyond) in ASICs
> > (microchip) design. Unfortunately, some designs use big-endian and
> > others use little-endian ...
>
> Is that actually a 2s-complement 128-bit unsigned integer, or is it just a
> 128-bit-long chunk of data?
>
> --
> 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: I always wonder ...

2008-12-22 Thread ajaksu
On Dec 22, 3:53 pm, s...@pobox.com wrote:
> ... shouldn't people who spend all their time trolling be doing something
> else: studying, working, writing patches which solve the problems they
> perceive to exist in the troll subject?  

Sure. So should I.

Hmm.

Shutting-up-and-back-to-work-ly y'rs,
Daniel
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 4:16 pm, Joe Strout  wrote:
> Alvin ONeal wrote:
> > Also worthy of mention:
> > I've seen python pre-installed on consumer HP desktops (I think as
> > part of a backup/restore script, but I'm not sure)
>
> It's pre-installed on every Mac (both desktop and laptop), too.
>
> Cheers,
> - Joe

I am using a Vista HP right now that came pre-installed with Python.
Blew my mind when i found out :). This single reason just reinforced
my belief in Python. Now if we can get Python on every windows
platform...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-22 Thread James Mills
On Tue, Dec 23, 2008 at 4:42 AM, cm_gui  wrote:
> i am referring mainly to Python for web applications.
>
> Python is slow.

Please just go away. You are making
an embarrassment of yourself.

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


Re: Are Django/Turbogears too specific?

2008-12-22 Thread Daniel Fetchinson
> I'd like to rewrite a Web 2.0 PHP application in Python with AJAX, and
> it seems like Django and Turbogears are the frameworks that have the
> most momentum.
>
> I'd like to use this opportunity to lower the load on servers, as the
> PHP application wasn't built to fit the number of users hammering the
> servers now.
>
> I'm concerned, though, that these frameworks they may be too specific
> to the tasks they were originally developped for (news articles,
> AFAIK). Do you think I should just use eg. CherryPy and some basic
> AJAX?

The 1.x branch of tg is built on cherrypy, the 2.x branch is built on
pylons. Both branches depend on external packages for most of their
functionality which makes them very flexible. Django is monolithic and
was intended to be monolithic. Of course you can customize it and use
different components than the defaults, but after all *everything* is
customizable since the source code is there and you can modify it. The
point is that tg was designed with flexibility and customizability in
mind, while django was designed with a monolithic infrastructure in
mind.

The 1.x branch of tg is stable and has been for years while the 2.x
branch is in beta but will be released soon as a stable, production
version.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread Christian Heimes
Glenn G. Chappell schrieb:
> I just ran 2to3 on a py2.5 script that does pattern matching on the
> text of a web page. The resulting script crashed, because when I did
> 
> f = urllib.request.urlopen(url)
> text = f.read()
> 
> then "text" is a bytes object, not a string, and so I can't do a
> regexp on it.
> 
> Of course, this is easy to patch: just do "f.read().decode()".
> However, it strikes me as an obvious bug, which ought to be fixed.
> That is, read() should return a string, as it did in py2.5.

It's not possible unless you know the encoding of the bytes. Network io
only returns byte and you must encode it explicitly. You "patch" breaks
as soon as a remote sites returns the data in a different encoding. It
also breaks if the site returns an image/*, appliation/*, audio/* or any
other mimetype than text.
There is no generic and simple way to detect the encoding of a remote
site. Sometimes the encoding is mentioned in the HTTP header, sometimes
it's embedded in the  section of the HTML document.

> This change breaks pretty much every Python program that opens a
> webpage, doesn't it? 2to3 doesn't catch it, and, in any case, why
> should read() return bytes, not string? Am I missing something?

I hope I was able to explain the issue. By the way Python 2.x and 3.0
are both returning bytes (str in 2.x, bytes in 3.0).

Christian

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


Re: Python's popularity

2008-12-22 Thread walterbyrd
On Dec 22, 11:50 am, Bruno Desthuilliers
 wrote:

> > When it comes to web development, it seems to me that ruby
> > (because of rails) is far more popular
>
> s/popular/hyped/

I'm not so sure. Go to dice.com, enter "ruby rails" no quotes, search
all words, job titles only - I got 86 hits, and another five hits when
I searched for "RoR."

Do the same search, but substitue "python django" for "ruby rails" and
I get 3 hits.

Doing the search for just "ruby" and I get 121 hits. Doing the search
for just "python" and I get 61 hits. Just "rails" and get 94 hits,
just "django" and I get 4 hits.

Not scientific, but there is substantial  difference.


> Fooled by version numbers ?

No, but I am giving django the benefit of the doubt. The django
project told people all along that django was not to be considered
production ready before 1.0. I will accept that some people decided to
wait until 1.0 came out to do any production development. Maybe django
is only lagging because 1.0 just came out?

> My actual CTO is a big Ruby/Rails fan, yet he settled on Python/Django
> for our current 'big' project. Wonder why ?

Not knowing much about RoR: yes, I wonder why? Is it because python
has a cleaner syntax? Or what?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Event Driven programming - Doubts

2008-12-22 Thread James Mills
On Tue, Dec 23, 2008 at 12:57 AM, Kottiyath  wrote:
> Hi,
>I have been looking at Twisted and lately Circuits as examples for
> event driven programming in Python.

Wonderful! :) "circuits" that is :)

>Even though I understood how to implement the code in these and
> what is deferred etc, I have not yet understood the implementation of
> deferred. I went through a lot of tutorials, but I guess most places
> they expect that the user already understands how events are
> generated. The tutorials mention that there is no more threads once
> twisted is used.

deferred to me is nothing more than
scheduling "things" to happen "later".

ie: Timers, or Timed Events.

I clearly biased here as I'm the developer
of circuits, so I can't comment on Twisted's
design or architecture, but the way to
achieve Twisted's so-called deferred (events?)
is to use the Timer component, Timed Events.

>My question is as follows:
>I have not understood how the callbacks are hit without (a)
> blocking the code or (b) having new threads.

Again speaking in terms of circuits,
but also in the event-driven paradigm:

a) Event Handlers _can_ block - but ideally shouldn't (ihmo).
b) Forking new threads/processes per event is mostly not necessary.
(There are exceptions).

> The usual example given is that of a program waiting for data coming
> through a socket. In the tutorials, it is mentioned that -in an event
> driven program, we schedule the code to hit when the remote server
> gets back to us - .
> Now, my question is - somebody has to still wait on that socket and
> check whether the data is received, and once all the data is received,
> call the appropriate callbacks.

In the case of circuits' TCPServer component
you simply poll it in your main event-loop.
The pattern looks like this:

from circuits.lib.sockets import TCPServer

server = TCPServer(8000)
while True:
   server.poll()
   server.flush()

The TCPServer component has various builtin
event handlers that do all the work for you
and expose other more useful events to
the application, such as:
 * connect
 * disconnect
 * read
 * error

> Is twisted creating a micro-thread which just waits on the socket and
> once the data is received, calls callFromThread for it to run on the
> main loop?

I can't comment - I tend to avoid threads
where ever possible.

> If so, Even though data locking etc is not a problem, are we not still
> having threads? Will it not still cause scalability problems in high
> traffic?

Regarding scalability btw ... (in case you're interested)
circuits comes with circuits.lib.web and several
sets of Web Components. A lot of code was
borrowed from the BaseHTTPServer from the
python standard library and bits and pieces
from CherryPy and the cgi module In terms
of performance, it has a "raw" performance
~3k req/s on good hardware.

Do have fun in your endeavours :)

cheers
James

Circuits: http://trac.softcircuit.com.au/circuits/
--
http://mail.python.org/mailman/listinfo/python-list


iterating initalizations

2008-12-22 Thread Aaron Stepp

Hi all:

I'm new to python and trying to save time and code by iterating  
through list initializations as well as the assignments.  I have the  
following code:


import random
from rtcmix import *
from chimes_source import *
from rhythmblock import *
from pitchblock import *

indexrand = random.Random()
indexrand.seed(2)

rhythm = rhythmBlock()
pitch = pitchBlock()

class pitchAndRhythm:

def __init__self:

self.__abet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'


def listCreate(self, num):

if num > 25:

print "Oops.  This won't work"

else:

for a in range(num):

b = indexrand.randint(0, 3)

c = indexrand.randint(0, 7)

index = self.__abet[a]

index = [ ]

index = index.append(rhythm.rhythmTwist(b, c))


This doesn't do what I expect (probably because I don't have a clue  
what I'm doing!): initalizing, then filling new arrays, each new one  
called A[ ], then B[ ], etc.


This seems very un-pythonic, and I'm sure there is a right way to do  
it.  I'm just lost!


Thanks

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


Re: python3 urlopen(...).read() returns bytes

2008-12-22 Thread Carl Banks
On Dec 22, 3:41 pm, "Glenn G. Chappell" 
wrote:
> I just ran 2to3 on a py2.5 script that does pattern matching on the
> text of a web page. The resulting script crashed, because when I did
>
>     f = urllib.request.urlopen(url)
>     text = f.read()
>
> then "text" is a bytes object, not a string, and so I can't do a
> regexp on it.
>
> Of course, this is easy to patch: just do "f.read().decode()".
> However, it strikes me as an obvious bug, which ought to be fixed.
> That is, read() should return a string, as it did in py2.5.

Well, I can't agree that it's an obvious bug (in Python 3).  It might
be something worth raising a warning over in 2to3.  It would also be a
reasonable wishlist item for automatic encoding detection and
conversion to a string (see below).  But it's not a bug.


> But apparently others disagree? This was mentioned in issue 3930
> (http://bugs.python.org/issue3930) back in September '08, but that
> issue is now closed, apparently because consistent behavior was
> achieved. But I figure consistently bad behavior is still bad.
>
> This change breaks pretty much every Python program that opens a
> webpage, doesn't it?

No.  What if someone is using urllib retrieve (say) a JPEG image?  A
bytes object is what they'd want in Python 3.  Also, many people were
already explicitly dealing with encodings in Python 2.5; the change
wouldn't affect them.


> 2to3 doesn't catch it, and, in any case, why
> should read() return bytes, not string? Am I missing something?

It returns bytes because it doesn't know what encoding to use.  This
is the appropriate behavior.


HOWEVER... a web page request often does know what encoding to use,
since it ostensibly has to parse the header.  It's reasonable that IF
a url request's "Content-type" is text, and/or the "Content-encoding"
is given, for urllib to have an option to automatically decode and
return a string instead of bytes.  (For all I know, it already can do
that.)


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


Re: Python's popularity

2008-12-22 Thread Joe Strout

Alvin ONeal wrote:


Also worthy of mention:
I've seen python pre-installed on consumer HP desktops (I think as
part of a backup/restore script, but I'm not sure)


It's pre-installed on every Mac (both desktop and laptop), too.

Cheers,
- Joe

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


Re: Python's popularity

2008-12-22 Thread ajaksu
On Dec 22, 4:44 pm, r  wrote:
> Oh Steve... Listen, my words are ment as a wake-up-call to all who

r, can you do me a favor? Go read the archives of this newsgroup for a
month or two, then come back with some perspective. I hope that will
make your posts a little less nonsensical and annoying. My words are
'ment' as a shut-up-call, you make as much sense as jeff here:
http://www.python.org/doc/humor/#nolo-contendre

Daniel

P.S.: You think Steve 'one of those who love python'? Geez, he's the
one that made us weak in this war by sabotaging a major source of
revenue for Python! -> 
http://pyfound.blogspot.com/2006/04/python-25-licensing-change.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Are Django/Turbogears too specific?

2008-12-22 Thread James Mills
On Tue, Dec 23, 2008 at 12:35 AM, Philip Semanchuk  wrote:
>
> On Dec 22, 2008, at 1:52 AM, Tino Wildenhain wrote:
>
>> Philip Semanchuk wrote:
>> ...
>>>
>>> I prefer Mako over the other template languages I've seen.
>>
>> From what I can tell Mako is nearly identical to all other
>> template languages you might have seen (e.g. PHP style
>> tags). Thats why I personally would not consider it. Its just
>> much of a hassle to mix code and design this way.
>>
>> I prefer TAL (template attribute language, ZPT) [1]
>> much over the other attempts I've seen ( and I've seen a lot)
>
> That's an excellent example of how Python can accommodate different tastes.
> =) I can't stand TAL; I find it awkward and unPythonic. Your comment makes
> sense, though. Mako and TAL have very different design philosophies, and if
> you really like one, you're probably going to find the other strange at
> best.

I agree! :) And just for the record I prefer
Mako :) (Not that I really use it at all) :P

--JamesMills

PS: Web Services FTW
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 3:15 pm, je.s.t...@hehxduhmp.org wrote:
> r  wrote:
> > We see where you stand. And also see that by removing your comments
> > from the archive in 5 days, how small your acorns really are.
>
> Also, it is pretty hard to take such accusations seriously from someone
> who themselves is using a generic gmail address w/o their real name
> attached to it.  If I didn't care about using a proper NNTP client, I
> could quite easily create some dufus account on Gmail and post through
> that just like you did - I'm sure that'd really increase my credibility!

Would you trust my words more if i used a name like "Thurstan Howell
III" Come on, don't tell me you are that shallow. To attack my
credibility solely based on my user name is the sport of small minded
people. Surely you can bring more thought, and intelligence to this
thread than that?...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 3:13 pm, je.s.t...@hehxduhmp.org wrote:
> r  wrote:
> > We see where you stand. And also see that by removing your comments
> > from the archive in 5 days, how small your acorns really are.
>
> What is "the archive", Google Groups?  You do realize that's not the
> entirety of Usenet, correct?

Absolutely, but why do you wish to remove your post. Do you not stand
behind everything you say? I do, and if a make a mistake i will
apologize for it. I have no reason to hide my words from anybody. They
will be here from now to  eternity.

This just makes your thoughts look more "drive-by-ish" to me. Thats
all.
--
http://mail.python.org/mailman/listinfo/python-list


python3 urlopen(...).read() returns bytes

2008-12-22 Thread Glenn G. Chappell
I just ran 2to3 on a py2.5 script that does pattern matching on the
text of a web page. The resulting script crashed, because when I did

f = urllib.request.urlopen(url)
text = f.read()

then "text" is a bytes object, not a string, and so I can't do a
regexp on it.

Of course, this is easy to patch: just do "f.read().decode()".
However, it strikes me as an obvious bug, which ought to be fixed.
That is, read() should return a string, as it did in py2.5.

But apparently others disagree? This was mentioned in issue 3930
( http://bugs.python.org/issue3930 ) back in September '08, but that
issue is now closed, apparently because consistent behavior was
achieved. But I figure consistently bad behavior is still bad.

This change breaks pretty much every Python program that opens a
webpage, doesn't it? 2to3 doesn't catch it, and, in any case, why
should read() return bytes, not string? Am I missing something?

By the way, I'm running Ubuntu 8.10. Doing "python3 --version" prints
"Python 3.0rc1+".
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread Robert Kern

je.s.t...@hehxduhmp.org wrote:

r  wrote:

We see where you stand. And also see that by removing your comments
from the archive in 5 days, how small your acorns really are.


What is "the archive", Google Groups?  You do realize that's not the
entirety of Usenet, correct?


It's the predominant archive of USENET, but it's not the only one that respects 
your X-No-Archive header. GMane, for example, will respect it if the list admin 
has not requested otherwise.


--
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: 64-bit / 128-bit data element type for array?

2008-12-22 Thread Robert Kern

akineko wrote:

Hello,

bearophile and  Robert, thank you for your prompt response.
I will try NumPy (this is a good execuse to learn and to use a new
package).


I haven't seen uint128 in the wild, though.


Of course, not many applications require uinit128 as a scalar value.
I may need to deal with 128-bit data as it is now not uncommon to have
128-bit data bus (or even 256-bit wide and beyond) in ASICs
(microchip) design. Unfortunately, some designs use big-endian and
others use little-endian ...


Is that actually a 2s-complement 128-bit unsigned integer, or is it just a 
128-bit-long chunk of data?


--
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: 64-bit / 128-bit data element type for array?

2008-12-22 Thread akineko
Hello,

bearophile and  Robert, thank you for your prompt response.
I will try NumPy (this is a good execuse to learn and to use a new
package).

> I haven't seen uint128 in the wild, though.

Of course, not many applications require uinit128 as a scalar value.
I may need to deal with 128-bit data as it is now not uncommon to have
128-bit data bus (or even 256-bit wide and beyond) in ASICs
(microchip) design. Unfortunately, some designs use big-endian and
others use little-endian ...

Thank you and Happy Holidays!
Aki Niimura

On Dec 22, 11:26 am, Robert Kern  wrote:
> akineko wrote:
> > Hello everyone,
>
> > I need to handle binary files that contain 64-bit (or 128-bit in the
> > furture) unsigned int data.
> > Python's array seems not supporting unsigned int type beyond 32-bit
> > ('L').
> > I would like to use Python array as I need to make my program work on
> > both big-endian machines as well as on little-endian machines.
>
> > What is the best way to deal with 64-bit / 128-bit data elements in
> > Python (must support byteswap())?
> > (must be machine-independent)
>
> You might give numpy a try. We support uint64 data even on 32-bit machines
> provided that your C compiler does. I haven't seen uint128 in the wild, 
> though.
>
> http://numpy.scipy.org/
>
> --
> 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: I always wonder ...

2008-12-22 Thread r
On Dec 22, 2:31 pm, s...@pobox.com wrote:
>     Carl> ...shouldn't poeple who spend all their time following up to
>     Carl> trolls, or starting new threads about trolls, being doing
>     Carl> something else?
>
> Sure.  It was just a momentary break from work, as is this.  I thought an
> implied smiley was enough, but I guess not.
>
> Skip

Pythonic.explicit_smiley() -> :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to represent a sequence of raw bytes

2008-12-22 Thread John Machin
On Dec 23, 1:52 am, "Steven Woody"  wrote:
> On Mon, Dec 22, 2008 at 6:44 PM, Steven D'Aprano
>
>  wrote:
> > On Mon, 22 Dec 2008 14:56:45 +0800, Steven Woody wrote:
>
> >> The intension is to allocate 200 undefined bytes in memory.
>
> > You *want* undefined bytes? Out of curiosity, what do you intend to do
> > with them?
>
> to receive/send network packets, read raw files, etc.  After read
> replies of the thread, I think 'array' or 'struct' maybe what I
> wanted, may a plain list can do, but I am not sure.

[Rhetorical questions] How do you use "undefined bytes" to receive
network packets?? Do you really want to use "undefined bytes" to
*send* network packets

Suggestion: Stop trying to replicate C in Python; think about what you
are trying to accomplish at a higher level, then how to implement that
in Python.

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


Re: Check file is

2008-12-22 Thread Grant Edwards
On 2008-12-20, Harish  wrote:

> Is there any utility in python which will help me to read any
> pdf files?

There are two things I can think off the top of my head

 1) The Poppler library. I don't know if there's a Python
binding for it.  The poppler home page and Wikipedia page
would probably be a good place to start reading.

 2) Qoppa Software has some Java PDF libraries that you could
probably use with Jython.

-- 
Grant Edwards   grante Yow! Did I do an INCORRECT
  at   THING??
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Check file is

2008-12-22 Thread Colin J. Williams






Paul McNett wrote:
Colin
J. Williams wrote:
  
  The ReportLab toolkit appears to be concerned
with building Portable

Document Files.  I would be interested in any utility which will read

any pdf - for example, to convert pdf -> html

  
  
I don't know of any Python utility to do this, but pdftohtml,
pdftotext, pdftoppm, and pdftops exist on my Ubuntu Linux system.
  
  
Paul
  
  

Thanks, pdftohtml is an experimental version, last updated in 2006: pdftohtml.sourceforge.net

There is another converter, last updated in 2004:
http://www.intrapdf.com/

The Debian version appears to have been last updated in 2003:
http://freshmeat.net/projects/pdftohtml/

Aside from the Adobe service, the most recent could be:
http://www.abbyyusa.com/shop/PDFT.htm

I was hoping that there might be something in Python.

Colin W.



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


Re: New Python 3.0 string formatting - really necessary?

2008-12-22 Thread r
On Dec 22, 12:36 pm, Bruno Desthuilliers
 wrote:

> As far as I'm concerned, I don't think Python is "superior" (OMG), I
> think it's a good language that happens to fit my brain *and* solve more
> than 80% of my programmer's needs. If you're not happy with Python's
> perfs, please contribute, you are welcome.

He is contributing, by bringing up the subject for debate. Volunteers
exist on all levels, not just the people who write code for CPython.

Every OOS project needs diversity. There is base code, maintenance
code, tutorials, essays, promotion(even if you consider it
fanboyism),etc, etc. """Every spoke on a wheel is just as important as
all the rest""", Bruno.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 63, Issue 420

2008-12-22 Thread John Machin
On Dec 23, 5:31 am, wblu...@verizon.net wrote:
> Sent from my Verizon Wireless BlackBerry
[snip]
That was kind of your parents to let you open your Christmas presents
early.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Check file is

2008-12-22 Thread Paul McNett

Colin J. Williams wrote:

The ReportLab toolkit appears to be concerned with building Portable
Document Files.  I would be interested in any utility which will read
any pdf - for example, to convert pdf -> html


I don't know of any Python utility to do this, but pdftohtml, pdftotext, pdftoppm, 
and pdftops exist on my Ubuntu Linux system.


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


Re: I always wonder ...

2008-12-22 Thread skip

Carl> ...shouldn't poeple who spend all their time following up to
Carl> trolls, or starting new threads about trolls, being doing
Carl> something else?

Sure.  It was just a momentary break from work, as is this.  I thought an
implied smiley was enough, but I guess not.

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


Re: I always wonder ...

2008-12-22 Thread Alvin ONeal
>
> What really is a troll?
>
*troll* /v.,n./

[From the Usenet group *alt.folklore.urban *] To
utter a posting on
Usenetdesigned to
attract predictable responses or
flame s. Derives from the
phrase "trolling for
newbies"
which in turn comes from mainstream "trolling", a style of fishing in which
one trails bait through a likely spot hoping for a bite. The
well-constructed troll is a post that induces lots of newbies and flamers to
make themselves look even more clueless than they already do, while subtly
conveying to the more savvy and experienced that it is in fact a deliberate
troll. If you don't fall for the joke, you get to be in on it.

Some people claim that the troll is properly a narrower category than flame
bait , that a troll is
categorized by containing some assertion that is wrong but not overtly
controversial.
--
http://mail.python.org/mailman/listinfo/python-list


Re: I always wonder ...

2008-12-22 Thread Carl Banks
On Dec 22, 11:53 am, s...@pobox.com wrote:
> ... shouldn't people who spend all their time trolling be doing something
> else: studying, working, writing patches which solve the problems they
> perceive to exist in the troll subject?  Is there some online troll game
> running where the players earn points for generating responses to their
> posts?

...shouldn't poeple who spend all their time following up to trolls,
or starting new threads about trolls, being doing something else?

Seriously, I participated briefly in the that thread when r still had
benefit of the doubt over whether he had any credibility, but now
there is no doubt that he none at all, so he's not worth replying to,
so I don't.  I suggest everyone else does likewise and ignores the
fool.

If you have to followup, at least keep your reply to something short
and witty, like, "Go away, troll".


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


Re: Python is slow

2008-12-22 Thread Luis M . González
On Dec 22, 3:42 pm, cm_gui  wrote:
> Python is slow.

Haven't you said that already?
Well, you did it so many times that you convinced me...

I'll tell the Google folks that they are a bunch of ignorant fools for
choosing python.
That's why their business is doing that bad. They will surely go to
hell.
This Google search engine and that silly site "youtube"... they won't
work.
THEY ARE SLOW!

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


Re: I always wonder ...

2008-12-22 Thread r
On Dec 22, 1:54 pm, Christian Heimes  wrote:
> > you are truly an open minded, intelligent Human being. Thanks for
> > blessing use with your wisdom here. We need more like you. Every
> > thought, action, fact, must always be questioned, that is what makes
> > us human!
>
> *plonk*

so i was wrong about you ;)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 1:50 pm, Luis M. González  wrote:
> On Dec 22, 3:44 pm, r  wrote:
>
>
>
> > Steve Holden
>
> > > What makes you assume this is a zero-sum game, and that Python won't
> > > survive if any other language becomes popular. Every language borrows
> > > from those that came before it. Terms like "outright plagiarism" don't
> > > encourage rational debate, and make you seem like a troll who is more
> > > interested in stirring up controversy than actually doing things to help
> > > promote the language.
>
> > This is a war Steve, and i will explain why. Python does not need to
> > compete with perl, lisp, C, basic, etc, etc. WHY, well because python
> > is SO radically different than those languages. Ruby on the other
> > hand, took most from python, the only difference is Ruby's full OO
> > integration.(12.method()). Since Ruby is so similar to python we must
> > consider that some people who would have found only python in this
> > niche now could go to Ruby. I am for choices, but this is out and out
> > robbery!
> > Of course we must stand on the shoulders of greater minds than our own
> > to get ahead, but using someone's knowledge against them is wrong. If
> > Ruby want's to incorporate so many Pythonian ideas into their
> > language, at least put a note in the tutorial giving credit to Guido
> > for his wisdom. Don't use our ideas and then bash python in the next
> > breath!
>
> > > I have an article about the Zen coming up in "Python Magazine" so I
> > > won't steal its thunder. Suffice it to say that people take the Zen far
> > > too seriously. Anyone who does so undermines their own credibility as a
> > > Python commentator. This isn't a war. Stop being childish.
>
> > I was speaking to the loyalty of Pythonista's. Of course we are not
> > really going to slay mats, come on Steve, get real!
>
> > > If all you want from a language is speed, go use C. I would avoid
> > > assembly language though, since a modern optimizing C compiler will
> > > often beat an assembly language programmer for execution speed, and the
> > > programming time will definitely be shorter. But to make speed the
> > > be-all and end-all is a witless approach. Speed is definitely not why
> > > dynamic languages' popularity is increasing. Speed *is* still relevant
> > > in certain areas, and completely irrelevant in others.
>
> > Come on Steve, i am NOT saying speed is the only thing that matters
> > here! But it is very important. I never compared Python to C, that is
> > madness. But it must be better, faster, smarter than it's direct
> > competition(ruby)... you agree??
>
> > > Much more of this kind of tripe and nobody will read what you write
> > > anyway. You will hear the plonking of a hundred thousand newsreaders
> > > every time you post.
>
> > Oh Steve... Listen, my words are ment as a wake-up-call to all who
> > still love Python, and i believe you are one of them. Maybe old age
> > has slowed your hand, that's OK, Us "youngsters" will take the helm.
> > And be serious, do you really think this group is read by "hundreds-of-
> > thousands of news readers? I wish it were, but I highly doubt it.
>
> Dude, calm down... There is no war here.
> Please turn off your computer, go take a walk for awhile, experience
> some real life in the outer world, and then think about this again.
> Python is cool language, Ruby too. We are all happy and competition is
> good.
> Nobody will win this "war" and the loser won't be annihilated. I hope
> there will be some healthy cross-pollination.
> There is actually, for example python borrowed list-comprehensions
> from haskell and I've never heard any haskell fan calling for jihad.
>
> Did you know that people are looking forward to use pypy to create a
> fast ruby implementation?
> Pypy is being developed by python developers and they will be happy to
> see a ruby, perl, logo or whatever language implemented with pypy. We
> are talking about tools, not religions.
> Those who use them to create useful, real life applications know it.
>
> Soon, we will be able to use python libraries from ruby and the other
> way around. the differences will be just a matter of taste, different
> syntax to achieve the same tasks.
>
> Luis

Your right, Python needs Ruby, and do you know why??? The same reason
MS needs, Mac & Linux. So they do not fall asleep at the wheel! This
keeps MS on there toes(although still no explanation for their piss-
poor product).

Python needs Ruby so we don't fall asleep. Ruby may be the best thing
that happened to Python. Wake Up people! The writing is on the Wall!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread r
OK je.s.t... whatever,
We see where you stand. And also see that by removing your comments
from the archive in 5 days, how small your acorns really are.

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


Re: Python's popularity

2008-12-22 Thread Luis M . González
On Dec 22, 3:44 pm, r  wrote:
> Steve Holden
>
> > What makes you assume this is a zero-sum game, and that Python won't
> > survive if any other language becomes popular. Every language borrows
> > from those that came before it. Terms like "outright plagiarism" don't
> > encourage rational debate, and make you seem like a troll who is more
> > interested in stirring up controversy than actually doing things to help
> > promote the language.
>
> This is a war Steve, and i will explain why. Python does not need to
> compete with perl, lisp, C, basic, etc, etc. WHY, well because python
> is SO radically different than those languages. Ruby on the other
> hand, took most from python, the only difference is Ruby's full OO
> integration.(12.method()). Since Ruby is so similar to python we must
> consider that some people who would have found only python in this
> niche now could go to Ruby. I am for choices, but this is out and out
> robbery!
> Of course we must stand on the shoulders of greater minds than our own
> to get ahead, but using someone's knowledge against them is wrong. If
> Ruby want's to incorporate so many Pythonian ideas into their
> language, at least put a note in the tutorial giving credit to Guido
> for his wisdom. Don't use our ideas and then bash python in the next
> breath!
>
> > I have an article about the Zen coming up in "Python Magazine" so I
> > won't steal its thunder. Suffice it to say that people take the Zen far
> > too seriously. Anyone who does so undermines their own credibility as a
> > Python commentator. This isn't a war. Stop being childish.
>
> I was speaking to the loyalty of Pythonista's. Of course we are not
> really going to slay mats, come on Steve, get real!
>
> > If all you want from a language is speed, go use C. I would avoid
> > assembly language though, since a modern optimizing C compiler will
> > often beat an assembly language programmer for execution speed, and the
> > programming time will definitely be shorter. But to make speed the
> > be-all and end-all is a witless approach. Speed is definitely not why
> > dynamic languages' popularity is increasing. Speed *is* still relevant
> > in certain areas, and completely irrelevant in others.
>
> Come on Steve, i am NOT saying speed is the only thing that matters
> here! But it is very important. I never compared Python to C, that is
> madness. But it must be better, faster, smarter than it's direct
> competition(ruby)... you agree??
>
> > Much more of this kind of tripe and nobody will read what you write
> > anyway. You will hear the plonking of a hundred thousand newsreaders
> > every time you post.
>
> Oh Steve... Listen, my words are ment as a wake-up-call to all who
> still love Python, and i believe you are one of them. Maybe old age
> has slowed your hand, that's OK, Us "youngsters" will take the helm.
> And be serious, do you really think this group is read by "hundreds-of-
> thousands of news readers? I wish it were, but I highly doubt it.

Dude, calm down... There is no war here.
Please turn off your computer, go take a walk for awhile, experience
some real life in the outer world, and then think about this again.
Python is cool language, Ruby too. We are all happy and competition is
good.
Nobody will win this "war" and the loser won't be annihilated. I hope
there will be some healthy cross-pollination.
There is actually, for example python borrowed list-comprehensions
from haskell and I've never heard any haskell fan calling for jihad.

Did you know that people are looking forward to use pypy to create a
fast ruby implementation?
Pypy is being developed by python developers and they will be happy to
see a ruby, perl, logo or whatever language implemented with pypy. We
are talking about tools, not religions.
Those who use them to create useful, real life applications know it.

Soon, we will be able to use python libraries from ruby and the other
way around. the differences will be just a matter of taste, different
syntax to achieve the same tasks.

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


Re: I always wonder ...

2008-12-22 Thread Christian Heimes
> you are truly an open minded, intelligent Human being. Thanks for
> blessing use with your wisdom here. We need more like you. Every
> thought, action, fact, must always be questioned, that is what makes
> us human!

*plonk*

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


Re: Python's popularity

2008-12-22 Thread Bruno Desthuilliers

walterbyrd a écrit :

On Dec 22, 10:13 am, r  wrote:

Since the
advent of Ruby(Python closet competitor), Python's hold on this niche
is slipping.


About the only place I ever hear of ruby being used is web development
with RoR. When it comes to web development, it seems to me that ruby
(because of rails) is far more popular


s/popular/hyped/

But being (perhaps over ?) hyped too soon is not necessarily the best 
move...



than python. It seems to me
that ruby is the niche player, and python (with fairly new frameworks)
is trying to catch up to ruby in that niche. It seems to me that the
python web framework that best competes with rails, is Django, and
Django 1.0 just came out a few months back.


Fooled by version numbers ? Heck, Python 3.0 just came out a couple 
weeks ago, and PHP is already at 6.x !-)


FWIW, I wrote my first django app years ago (and it's still in production).



A lot of Ruby noobies don't even realize that most of
Ruby is an out-right plagiarism of Python.


I don't know who asserted such a stupid thing, but he manages to be 
equally clueless wrt/ both languages.



Maybe. But the rails framework seems to have a different philosophy
than the django, turbogears, or pylons, frameworks. RoR values
convention over configuration, and has a lot of "magic" whereas the
python frameworks seem to have the opposite philosophy - in those
regards. I see pros and cons to both approaches. I wonder what the
market with think?


My actual CTO is a big Ruby/Rails fan, yet he settled on Python/Django 
for our current 'big' project. Wonder why ?


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


Re: New Python 3.0 string formatting - really necessary?

2008-12-22 Thread Bruno Desthuilliers

walterbyrd a écrit :

On Dec 21, 12:28 pm, Bruno Desthuilliers
 wrote:

Strange enough,
no one seems to complain about PHP or Ruby's performances...


A few years back, there was a certain amount of chest thumping, when
python/django easily beat ror in a benchmark test.


I don't remember it, and honestly, I just don't give a damn.


Now that ruby is
faster,


"faster" than what ? Than Python ? or than it's previous version ?


I guess speed is no big issue.


Please use your google-fu (if you have any). As far as I'm concerned, my 
position didn't change these 7+ past years: Python is (and has always 
been) fast enough for most of what I use it for (and when it isn't, 
neither PHP nor Ruby are going to be solution anyway).


Now improvements are always welcomes, and if you compare 1.5.2 with 
2.5.1, you'll find out that the core developpers did improve Python's 
perfs.


Now do you have any serious argument, or are you just trolling ?


By the same reasoning, python advocates used to sneer at php because
php constantly broke backward compatibility. Now that python does it,
breaking backward compatibility is no big deal.


There's a lot 1.5.2 days code still running *unmodified* on 2.6.x. 
You'll have hard time finding (non-trivial, and even then) PHP3 code 
running unmodified on PHP5.



I guess unicode
support was not that important, until python caught up to perl.

I guess, the way it works is: you first assume that python is
superior, then you figure out why.


Whoever said Python was "superior" (except your good friend 'r') ?

As far as I'm concerned, I don't think Python is "superior" (OMG), I 
think it's a good language that happens to fit my brain *and* solve more 
than 80% of my programmer's needs. If you're not happy with Python's 
perfs, please contribute, you are welcome.

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


Re: Python's popularity

2008-12-22 Thread r
On Dec 22, 1:10 pm, MRAB  wrote:
> r wrote:
> > Steve Holden
> >> What makes you assume this is a zero-sum game, and that Python won't
> >> survive if any other language becomes popular. Every language borrows
> >> from those that came before it. Terms like "outright plagiarism" don't
> >> encourage rational debate, and make you seem like a troll who is more
> >> interested in stirring up controversy than actually doing things to help
> >> promote the language.
>
> > This is a war Steve, and i will explain why. Python does not need to
> > compete with perl, lisp, C, basic, etc, etc. WHY, well because python
> > is SO radically different than those languages. Ruby on the other
> > hand, took most from python, the only difference is Ruby's full OO
> > integration.(12.method()). Since Ruby is so similar to python we must
> > consider that some people who would have found only python in this
> > niche now could go to Ruby. I am for choices, but this is out and out
> > robbery!
> > Of course we must stand on the shoulders of greater minds than our own
> > to get ahead, but using someone's knowledge against them is wrong. If
> > Ruby want's to incorporate so many Pythonian ideas into their
> > language, at least put a note in the tutorial giving credit to Guido
> > for his wisdom. Don't use our ideas and then bash python in the next
> > breath!
>
> [snip]
> "Pythonian"? A real Pythonista would know it's "Pythonic"! A real
> Pythonista would be called "p", not "r", which sounds very Rubish(?) to
> me...

MRAB -> '%sMuchRubyAndBasic' %'Too'
MRAB -> Method.Ruby(AttractsBraindead)
MRAB -> MyRubyAintBad
MRAB -> MuchoRubyAndBasic

Pythonian is more acceptable in the context of my sentence...

""" If Ruby want's to incorporate so many Pythonian ideas into their
language, at least put a note in the tutorial giving credit to Guido
for his wisdom."""

Pythonian.translate() -> in the domain if Python... ownership
Pythonic.translate() -> in a python style... (way of)

two radically different meaning, of course if you vocabulary reaches
that far??


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


Re: Check file is

2008-12-22 Thread Colin J. Williams

gardsted wrote:

Harish wrote:

Hi Friends
Is there any utility in python which will help me to read any pdf
files?

Regards
Harish


Not sure, what you're after exactly, but I tried googling 'python read pdf'
and found this, so maybe 'reportlab' is what you're looking for:

Re: Reading PDF files
  #2
Dec 20th, 2006
To read and manage Portable Document Files you can use the open source 
ReportLab toolkit (written in Python) from:

http://www.reportlab.org/rl_toolkit.html

kind regards jorgen


The ReportLab toolkit appears to be 
concerned with building Portable
Document Files.  I would be interested 
in any utility which will read
any pdf - for example, to convert pdf -> 
html


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


Re: Python's popularity

2008-12-22 Thread walterbyrd
On Dec 22, 11:42 am, "Ellinghaus, Lance" 
wrote:

> Yes, Ruby has taken some of the popularity out of Python, but they are
> also hitting different markets.

Do you mean different markets within web development, or do you mean
ruby is used mostly for web-dev, while python is used for other stuff?
--
http://mail.python.org/mailman/listinfo/python-list


Re: 64-bit / 128-bit data element type for array?

2008-12-22 Thread Robert Kern

akineko wrote:

Hello everyone,

I need to handle binary files that contain 64-bit (or 128-bit in the
furture) unsigned int data.
Python's array seems not supporting unsigned int type beyond 32-bit
('L').
I would like to use Python array as I need to make my program work on
both big-endian machines as well as on little-endian machines.

What is the best way to deal with 64-bit / 128-bit data elements in
Python (must support byteswap())?
(must be machine-independent)


You might give numpy a try. We support uint64 data even on 32-bit machines 
provided that your C compiler does. I haven't seen uint128 in the wild, though.


http://numpy.scipy.org/

--
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: 64-bit / 128-bit data element type for array?

2008-12-22 Thread bearophileHUGS
akineko:
> I need to handle binary files that contain 64-bit (or 128-bit in the
> furture) unsigned int data.
> Python's array seems not supporting unsigned int type beyond 32-bit
> ('L').

I agree that it can be useful for the built-in array module to grow
signed/unsigned 64 bit numbers.

Numpy supports signed/unsigned 64 bit numbers too, so that may be
enough for you:
http://docs.scipy.org/doc/numpy/user/basics.types.html

Regarding 128-bit numbers you may have to support them manually, with
pairs of uint64, with numpy. They aren't much common yet.
(D language will have cent/ucent 128 bit integral numbers, but it's
not a common thing).

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's popularity

2008-12-22 Thread MRAB

r wrote:

Steve Holden

What makes you assume this is a zero-sum game, and that Python won't
survive if any other language becomes popular. Every language borrows
from those that came before it. Terms like "outright plagiarism" don't
encourage rational debate, and make you seem like a troll who is more
interested in stirring up controversy than actually doing things to help
promote the language.


This is a war Steve, and i will explain why. Python does not need to
compete with perl, lisp, C, basic, etc, etc. WHY, well because python
is SO radically different than those languages. Ruby on the other
hand, took most from python, the only difference is Ruby's full OO
integration.(12.method()). Since Ruby is so similar to python we must
consider that some people who would have found only python in this
niche now could go to Ruby. I am for choices, but this is out and out
robbery!
Of course we must stand on the shoulders of greater minds than our own
to get ahead, but using someone's knowledge against them is wrong. If
Ruby want's to incorporate so many Pythonian ideas into their
language, at least put a note in the tutorial giving credit to Guido
for his wisdom. Don't use our ideas and then bash python in the next
breath!


[snip]
"Pythonian"? A real Pythonista would know it's "Pythonic"! A real 
Pythonista would be called "p", not "r", which sounds very Rubish(?) to 
me...


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


Re: I always wonder ...

2008-12-22 Thread r
On Dec 22, 1:02 pm, Christian Heimes  wrote:
> Don't worry about the trolling, Skip. I'd be more worried if nobody
> trolls about Python. It would mean Python loses popularity and our work
> is all in vain.

Christain,
you are truly an open minded, intelligent Human being. Thanks for
blessing use with your wisdom here. We need more like you. Every
thought, action, fact, must always be questioned, that is what makes
us human!

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


Re: I always wonder ...

2008-12-22 Thread r
> You just got 10 points ;-)

Fighting trolls begets a troll. Skip not you, i have so much respect
for you :)

What really is a troll?
Someone who does not agree with you?
Someone you don't like?
Someone you do like?

All good questions. I think this whole troll calling business has
gotten out of hand. Some people may antagonize you, but who is
ultimately to blame for that? I guess we could have this set up were
certain people could be banned, would you like that. Or maybe you
should just ignore that which bothers you. If someone came to this
group and said

""" Ruby rules! Python sucks eggs!"""

I would not even bother to reply. But do not let yourself be closed
minded and think your ways are alway right. I have learned a lot from
people here and have disagreed with a lot of opinions here. Troll
calling is childish. be more open minded than that.
--
http://mail.python.org/mailman/listinfo/python-list


Re: I always wonder ...

2008-12-22 Thread Christian Heimes
s...@pobox.com schrieb:
>  shouldn't people who spend all their time trolling be doing something
> else: studying, working, writing patches which solve the problems they
> perceive to exist in the troll subject?  Is there some online troll game
> running where the players earn points for generating responses to their
> posts?

Don't worry about the trolling, Skip. I'd be more worried if nobody
trolls about Python. It would mean Python loses popularity and our work
is all in vain.

Prepare yourself for the worst, Christmas holidays are near! The fading
day light usually increased the amount of troll posts.

Christian

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


Re: Calling ImageMagick's convert

2008-12-22 Thread Андрей Парамонов
2008/12/22 Chris Rebert :
> I think this needs to be:
>
> subprocess.call(['convert', 'in.png', '-resize', '640x480', 'out.png'])
>
> Otherwise, it gets '-resize 640x480' as a single escaped option when
> it's really 2 options, which is the error message you're getting.
> You have to split the arguments up just like the shell would, which
> basically means at whitespace unless quoting is used, which is not the
> case here.
>
> Cheers,
> Chris

It worked, many thanks!

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


Re: I always wonder ...

2008-12-22 Thread Grant Edwards
On 2008-12-22, Martin P. Hellwig  wrote:
> s...@pobox.com wrote:

>> Is there some online troll game running where the players earn
>> points for generating responses to their posts?
>
> You just got 10 points ;-)

We'll have to ask for an instant replay for the judges on that
one.  If his question was genuine, then it doesn't officially
count as a troll.

-- 
Grant Edwards   grante Yow! Are we laid back yet?
  at   
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >