Re: pickle alternative

2005-07-08 Thread TZOTZIOY
On 4 Jul 2005 19:45:07 -0700, rumours say that [EMAIL PROTECTED]
might have written:

Time and space efficiency, and security do not have to be mutually
exclusive features of a serializer. Python does not provide, in the
standard library, a serializer which can work safely with untrusted
data which is time and space efficient. The proposed gherkin module
goes some way to achieving this. The format is simple enough to
easily write interoperable implementations across platforms.

I cannot readily check the source code because your web server listens
on port 82 (we're behind a strict firewall), so I don't know if my
following question has a reason to exist, but there we go:

Have you considered basing your module on xdrlib, which is more of a
cross-language standard?
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)

2005-07-04 Thread TZOTZIOY
On Sun, 03 Jul 2005 08:59:30 +1000, rumours say that John Machin
[EMAIL PROTECTED] might have written:

Neutral: no, they always seem to be active combatants.
Neuter: one would hope so, lest they procreate.

Thanks for the correction.  The first line of my sig is not completely
humourous, I believe you noticed :)
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which kid's beginners programming - Python or Forth?

2005-07-02 Thread TZOTZIOY
On Tue, 28 Jun 2005 12:58:21 -0700, rumours say that Dave Benjamin
[EMAIL PROTECTED] might have written:

BORT wrote:
 I am toying with the idea of teaching my ten year old a little about
 programming.  I started my search with something like best FREE
 programming language for kids.  After MUCH clicking and high-level
 scanning, I am looking at Python and Forth.  Both have advocates that
 say each is a great approach to learning computers.

Kids your backwards talking like if forth love will they then.

I have a nephew that would love Forth only for that.

The perfect language for many kids I know would be Python with boolean
operators reversed.  Oh, and 'print' should be 'do_NOT_print'.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-07-02 Thread TZOTZIOY
On Wed, 29 Jun 2005 07:11:43 -0500, rumours say that phil
[EMAIL PROTECTED] might have written:

I wonder what percentage of the tools you refer to are
Eclipse and not Java per se.  ?? I don't know.

The really big bucks of IBM sent Eclipse through the roof.

The project name is pretty offensive too, since it's related to the term
Sun and not the term Java.

If one has heard of the differences between Sun and IBM about Java, and
knowing that Eclipse started as an IBM project, then the reasoning for
choosing the name Eclipse becomes more obvious...
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MD5 problem

2005-07-02 Thread TZOTZIOY
On Mon, 13 Jun 2005 14:00:33 +0200, rumours say that fargo
[EMAIL PROTECTED] might have written:

If I use the md5 module with .txt files, it'ok.

The Problem comes from the .msg files. I get the same signature for 
every .msg file I try to hash with the md5 algorithm. I think some 
character are strange for python, and makes it stop before the end of 
the .msg file.

FYI: the character that was strange for Windows (not Python) was
chr(26), or Ctrl-Z, or end-of-file, which is special for files opened as
text instead of binary.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python choice of database

2005-07-02 Thread TZOTZIOY
On 20 Jun 2005 11:43:28 -0700, rumours say that Oren Tirosh
[EMAIL PROTECTED] might have written:

For very short keys and record (e.g. email addresses) you can use
symbolic links instead of files. The advantage is that you have a
single system call (readlink) to retrieve the contents of a link. No
need to open, read and close.

readlink also does open, read and close too.  And why go through
indirection?  Why not make indexes into subdirectories, say, and
hard-link the records under different filenames?

This works only on posix systems, of course.

There aren't any non-posix-conformant --or, at least, any
non-self-described-as-posix-conformant :-)-- operating systems in wide
use today.

Hint: win32file.CreateHardLink
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python choice of database

2005-07-02 Thread TZOTZIOY
On Tue, 21 Jun 2005 17:00:17 +0300, rumours say that Konstantin
Veretennicov [EMAIL PROTECTED] might have written:

On 6/21/05, Charles Krug [EMAIL PROTECTED] wrote:
 
 Related question:
 
 What if I need to create/modify MS-Access or SQL Server dbs?

You could use ADO + adodbapi for both.
http://adodbapi.sourceforge.net/

Or pywin32/ctypes and COM (btw, I prefer DAO to ADO, but that is a
personal choice).
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python choice of database

2005-07-02 Thread TZOTZIOY
On Mon, 20 Jun 2005 23:42:21 -0800, rumours say that EP
[EMAIL PROTECTED] might have written:

I tried this for one application under the Windows OS and it worked fine...

until my records (text - maybe 50KB average) unexpectedly blossomed into the 
10,000-1,000,000 ranges.  If I or someone else (who innocently doesn't know 
better) opens up one of the directories with ~150,000 files in it, the 
machine's personality gets a little ugly (it seems buggy but is just very 
busy; no crashing).  Under 10,000 files per directory seems to work just fine, 
though.

Although I am not a pro-Windows person, I have to say here directories
containing more than 1 files is not a problem for NTFS (at least
NTFS of Win2000 and WinXP based on my experience) since AFAIK
directories are stored in B-tree format; the problem is if one tries to
*view* the directory contents using Explorer.  Command-line dir had no
problem on a directory with 15000 files.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When someone from Britain speaks, Americans hear a British accent...

2005-07-02 Thread TZOTZIOY
On 28 Jun 2005 13:24:42 -0700, rumours say that muldoon
[EMAIL PROTECTED] might have written:

   Now, what forum would you recommend? Any help would be appreciated.

alt.usage.english?
alt.languages.english?
alt.english.usage?
uk.culture.language.english?
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When someone from Britain speaks, Americans hear a British accent...

2005-07-02 Thread TZOTZIOY
On Thu, 30 Jun 2005 18:29:56 +0100, rumours say that Tom Anderson
[EMAIL PROTECTED] might have written:

On Thu, 30 Jun 2005, Benji York wrote:

 python-needs-more-duct-tape'ly yours,

You're in luck: Python 3000 will replace duck typing with duct taping.

I would bet that somewhere in the Ingliy-spiking werld both terms
sound exactly the same.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for everything?

2005-07-02 Thread TZOTZIOY
On Thu, 30 Jun 2005 20:55:20 -0400, rumours say that Mike Meyer
[EMAIL PROTECTED] might have written:

Actually, I was thinking of pre-KR Unix compilers.

There must be something I am missing here, cause I don't understand what
you mean; what is the earliest KR C compiler (Unix compiler) you
consider as such?  Were there other Unix C compilers before KR wrote
one?  Or are you considering as KR Unix compilers those after the
publication of the white book and before C89?
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-07-01 Thread TZOTZIOY
On Fri, 24 Jun 2005 21:17:09 GMT, rumours say that Ron Adam
[EMAIL PROTECTED] might have written:

I think some sort of inline or deferred local statement would be useful 
also.  It would serve as a limited lambda (after it's removed), eval 
alternative, and as a inlined function in some situations as well I think.

Something like:

 name = defer expression

then used as:

 result = name()

The expression name() will never have arguments as it's meant to 
reference it's variables as locals and probably will be replaced 
directly with names's byte code contents at compile time.

Defer could be shortened to def I suppose, but I think defer would be 
clearer.  Anyway, it's only a wish list item for now.

This is similar:

http://groups-beta.google.com/group/comp.lang.python/msg/6fc884147852d23d
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Better console for Windows?

2005-07-01 Thread TZOTZIOY
On Tue, 28 Jun 2005 14:44:21 +0100, rumours say that Richie Hindle
[EMAIL PROTECTED] might have written:

Just to take this thread *completely* off-topic: does anyone know of a way
to scroll a Command Prompt window using the keyboard?

This comparison page suggests there is no keyboard shortcut to scroll:

http://www.xvsxp.com/power_user/terminal/
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling WinAMP (WM_COPYDATA problem)

2005-07-01 Thread TZOTZIOY
On 30 Jun 2005 11:48:31 -0700, rumours say that The Collector
[EMAIL PROTECTED] might have written:

Hi,

I've been looking for almost two full days now to get full control of
WinAMP using python. Simple play/stop functions are no problem. It's
the WM_COPYDATA that's used by IPC_PLAYFILE (=add a file to the
playlist) that's giving me troubles big time!

An alternative that could be easier to use is WinAmpCOM (a plugin for
winamp that makes it a COM server, so using pywin32 or ctypes you can
control it with much ease.)

It's available in the www.winamp.com site. (Search for plugin
winampcom)
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re:

2005-07-01 Thread TZOTZIOY
On Fri, 01 Jul 2005 10:54:03 +0200, rumours say that Adriaan Renting
[EMAIL PROTECTED] might have written:

Some thoughts interspersed:

I'm not a very experienced Python programmer yet, so I might be
mistaken, but there are a few things that would make me prefer C++ over
Python for large (over 500.000 LOC) projects.

- namespaces
Python: modules? classes?

- templates
Python: list.extend([a, 5, 3.14, 1+3j])

- strong type checking
Python: print 1+1

- data hiding
C++: #define private public

- more available libraries and more advanced developement tools.
More advanced development tools, yes.  More available libraries?
Perhaps.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-28 Thread TZOTZIOY
On Mon, 13 Jun 2005 20:27:46 -0400, rumours say that Roy Smith
[EMAIL PROTECTED] might have written:

Andrea Griffini [EMAIL PROTECTED] wrote:
 Hehehe... a large python string is a nice idea for modelling
 memory.

Actually, a Python string is only good for modelling ROM.  If you want to 
model read-write memory, you need a Python list.

This is a misquote, since Andrea paraphrased what Peter Maas said.  It
was Peter that suggested string usage to model memory (and obviously
forgot momentarily about string immutability in python).

If you included (even better, read :) the rest of Andrea's paragraph, it
would be obvious that you actually agree with Andrea.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-28 Thread TZOTZIOY
On Thu, 16 Jun 2005 14:29:49 +0100, rumours say that Tom Anderson
[EMAIL PROTECTED] might have written:

At one point, a friend and i founded a university to give our recreational 
random hackery a bit more credibility (well, we called ourself a 
university, anyway; it was mostly a joke). We called the programming 
department 'Executable Poetry'.

That's a good idea for a t-shirt:

Python: executable poetry

(kudos to Steve Holden for
[EMAIL PROTECTED] where the term PIPO
(Poetry In, Poetry Out) could be born)

and then, apart from t-shirts, the PSF could sell Python-branded
shampoos named poetry in lotion etc.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-28 Thread TZOTZIOY
On 27 Jun 2005 18:56:27 -0700, rumours say that Inkiniteo
[EMAIL PROTECTED] might have written:

I see. So... what about sending HTML email? If i send HTML tagged text,
the client will be able to read it as HTML?

I agree with the others that HTML is part of the web, not of the e-mail
system.

I suggest you send your info as an attached text file; no client will
mess with it.  The email package is your friend for MIME messages.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Better console for Windows?

2005-06-28 Thread TZOTZIOY
On 27 Jun 2005 20:13:41 -0700, rumours say that Brett Hoerner
[EMAIL PROTECTED] might have written:

Christ, thanks.  When you install Windows it should pop up first thing
and ask if you want to be annoyed, Y/N.

When you agree to the EULA of Windows, you implicitly say yes to do you
want to be annoyed?

Well, that solves my sound problem (thanks again), now if only I could
stretch the window horizontally.  Thats much less of a problem though,
this is at least usable now.

Hm... right-click the cmd.exe window's title bar (or click on the
top-left icon, or press Alt-Space), go to Properties, Layout tab, Window
Size, Width.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-28 Thread TZOTZIOY
On Tue, 28 Jun 2005 15:46:01 +0300, rumours say that Christos TZOTZIOY
Georgiou [EMAIL PROTECTED] might have written:

(kudos to Steve Holden for
[EMAIL PROTECTED] where the term PIPO
(Poetry In, Poetry Out) could be born)

oops! kudos to Michael Spencer (I never saw Michael's message on my
newsserver, so I archived Steve's).
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-27 Thread TZOTZIOY
On 27 Jun 2005 15:38:59 -0700, rumours say that Inkiniteo
[EMAIL PROTECTED] might have written:

Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail  and the receiver only get it in plain text.

Please tell us what you do more precisely:

* do you send the info as an attachment using the email package?
* do you create alternative text and HTML parts for the body?

I have never managed to send plain text email and receive it as HTML.
Perhaps you mean that some smart client does something stupid with
your text, eg. it removes line-breaks you have in your message?


Try this:

import smtplib

def send(server, from_whom, to_whom_list):
smtp = smtplib.SMTP(server)
smtp.sendmail(from_whom, to_whom_list,
From: %s
To: %s
Subject: test email

This is a test.
It has line breaks.
Does it come as three separate lines?)

I tried it as

send('localhost', '[EMAIL PROTECTED]', ['[EMAIL PROTECTED]'])

and I had no problem.  What happens for you (substitute other server and
email addresses, obviously :) ?
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-27 Thread TZOTZIOY
On 27 Jun 2005 15:38:59 -0700, rumours say that Inkiniteo
[EMAIL PROTECTED] might have written:

Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail  and the receiver only get it in plain text.

Please tell us what you do more precisely:

* do you send the info as an attachment using the email package?
* do you create alternative text and HTML parts for the body?

I have never managed to send plain text email and receive it as HTML.
Perhaps you mean that some smart client does something stupid with
your text, eg. it removes line-breaks you have in your message?


Try this:

import smtplib

def send(server, from_whom, to_whom_list):
smtp = smtplib.SMTP(server)
smtp.sendmail(from_whom, to_whom_list,
From: %s
To: %s
Subject: test email

This is a test.
It has line breaks.
Does it come as three separate lines? % (from_whom,
, .join(to_whom_list))

I tried it as

send('localhost', '[EMAIL PROTECTED]', ['[EMAIL PROTECTED]'])

and I had no problem.  What happens for you (substitute other server and
email addresses, obviously :) ?
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-27 Thread TZOTZIOY
On 27 Jun 2005 16:09:38 -0700, rumours say that Inkiniteo
[EMAIL PROTECTED] might have written:

Humm. I just create the message this way:

message = 'Serie:\t\t' + str(type) + str(series) + \
  '\t\t\tUbicación:\t\t\t' + place + '\n' + \
  'DateTime:\t' + date

and send it with:
message = header + message
server = smtplib.SMTP('localhost')
server.sendmail('[EMAIL PROTECTED]', email, message)
server.quit()

And what goes wrong when you see the message?  (BTW you don't have a
newline before Ubicación:; is it intentional?)

Tabs are infamous confusers of email clients, unfortunately.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting an object name

2005-06-22 Thread TZOTZIOY
On Wed, 22 Jun 2005 09:00:23 +0100, rumours say that Simon Brunning
[EMAIL PROTECTED] might have written:

 Let's say I have a list called, alist. If I pass alist to a function,
 how can I get the name of it?

The effbot put it beautifully:

And IMO it should be in the FAQ:
(http://www.python.org/doc/faq/general.html)

How do I get the name of an object?

The same way as you get the name of that cat you found on your porch:
the cat (object) itself cannot tell you its name, and it doesn't
really care -- so the only way to find out what it's called is to ask
all your neighbours (namespaces) if it's their cat (object) ... and
don't be surprised if you'll find that it's known by many names, or no
name at all!

Whom should we bug to add it?
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: the python way?

2005-06-16 Thread TZOTZIOY
On Mon, 06 Jun 2005 14:52:04 -0400, rumours say that Kent Johnson
[EMAIL PROTECTED] might have written:

def newZip(a1,a2):
 reassemble 
l1=len(a1)
l2=len(a2)
longest, shortest = [[a1,a2], [a2,a1]][l1l2]
snip

Other ways to write the last line:
--

/a/ execution in 22.5% of the original time taken

longest, shortest = l1  l2 and (a2,a1) or (a1,a2)


/b/ execution in 12.5% of the original time taken

if l1  l2: longest, shortest= a2, a1
else: longest, shortest= a1, a2


/c/ execution in 6.5% of the original time taken

if l1  l2: longest= a2; shortest= a1
else: longest= a1; shortest= a2


Another exotic way to write the last *three* lines, running in 228.7% of
the original time:-)

shortest, longest=sorted([a1,a2], key=len)


Numbers from 2.4c1 on a Pentium-M running at 600 MHz (battery powered).
Suggestion /a/ has the advantage of no repetion of the names like the
original line.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hopefully simple regular expression question

2005-06-14 Thread TZOTZIOY
On 14 Jun 2005 04:01:58 -0700, rumours say that [EMAIL PROTECTED]
[EMAIL PROTECTED] might have written:

I want to match a word against a string such that 'peter' is found in
peter bengtsson or  hey peter, or but in thepeter bengtsson or
hey peterbe, because the word has to stand on its own. The following
code works for a single word:

[snip]

use \b before and after the word you search, for example:

rePeter= re.compile(\bpeter\b, re.I)

In the documentation for the re module, Subsection 4.2.1 is Regular
Expression Syntax; it'll help a lot if you read it.

Cheers.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sudo open() ? (python newbee question)

2005-06-14 Thread TZOTZIOY
On 14 Jun 2005 08:12:17 -0400, rumours say that Dan Sommers
[EMAIL PROTECTED] might have written:

On Tue, 14 Jun 2005 11:52:13 +0200,
Denis WERNERT [EMAIL PROTECTED] wrote:

 The script could be SUID Root, and you could use os.setuid immediately
 after having performed the task to switch to a non-priviledged
 user. May be a big security risk, if someone can alter the script, he
 gains root access to the system...

I am *not* advocating suid scripts, and *ESPECIALLY NOT* suid Python
programs, but if a user can modify an unwriteable suid script owned by
root in a an unwriteable directory, then they already have root access
to the system (unless there's' a kernel or filesystem bug, in which case
all bets are off anyway).

I believe that the suid bit on scripts (either *sh or python) is
completely ignored on most *nix systems.

Try this in a shell (bash or ksh) as a sudo-capable user:

echo hello /tmp/tmp
sudo chown root /tmp/tmp
sudo chmod 600 /tmp/tmp
cat /tmp/ax.py @
#!/usr/bin/env python
x = open(/tmp/tmp, w)
x.write(there)
x.close()
@
sudo chown root /tmp/ax.py
sudo chmod a=rx,u+s /tmp/ax.py
ls -l /tmp/ax.py /tmp/tmp
/tmp/ax.py

I get:

-r-sr-xr-x  1 root users 75 2005-06-14 16:15 /tmp/ax.py
-rw---  1 root users  6 2005-06-14 16:15 /tmp/tmp
Traceback (most recent call last):
  File /tmp/ax.py, line 2, in ?
x = open(/tmp/tmp, w)
IOError: [Errno 13] Permission denied: '/tmp/tmp'

-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: also to balance else ?

2005-06-14 Thread TZOTZIOY
On Tue, 14 Jun 2005 07:20:06 GMT, rumours say that Andrew Dalke
[EMAIL PROTECTED] might have written:

Given the Python maxim of
  There should be one-- and preferably only one --obvious way to do it.

which of these is the preferred and obvious way?

while f():
  print Hello!
  if g():
break
else:
  print this is a test
also:
  print this is not a pipe

 -or-

while f():
  print Hello!
  if g():
print this is a test
break
else:
  print this is not a pipe

I prefer the second over the first.

I am not advocating for either side AFA python 2 is concerned (however I
would substitute then for also), however the second way does not
handle /elegantly/ multiple break points.

I'm +1 for making else the target for break in Py3K though, given an
elegant also/then keyword.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Destructive Windows Script

2005-06-06 Thread TZOTZIOY
On 05 Jun 2005 21:14:37 -0700, rumours say that Paul Rubin
http://[EMAIL PROTECTED] might have written:

The only way to be 100% sure the data is gone from a drive, is
basically to melt the drive.  However, if your data is that sensitive,
you shouldn't ever write it to a hard drive in the clear anyway.

A little healthy insanity never hurt anyone in the security field :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encryption with Python?

2005-05-26 Thread TZOTZIOY
On Tue, 24 May 2005 10:16:15 +0200, rumours say that Anthra Norell
[EMAIL PROTECTED] might have written:

Why whack someone over the head who tries to develop an idea of his own.
Such an approach isn't uncommon to earn extra credit in educational
settings.

I would never whack someone over the head (WSOTH) who tries to develop
an idea of his own, and never will (intentionally at least --I myself
like reinventing the wheel once in a while just to make sure my synapses
still work).  However I do WSOTH for 

I rolled my own for relatively short sequences, like passwords. The key is
an integer. To decrypt use the negative encryption key. I consider the
encryption unbreakable, as it is indistinguishable from a random sequence.

So, to be clear, my reason was your declaring that I consider the
encryption unbreakable, as it..., and that is why I actually challenged
you to either support the unbreakability of your algorithm by supplying
sensitive data for you, or back off and simply say ok guys, my words
were a *little* over the top.

That's all.  I see you took up the challenge and indirectly replied to
my last question, and in good spirit I say you earned a little respect
from me, at least for standing up to your words.  Now I hope no-one
gives a try to your data (for your own sake :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python on a public library computer

2005-05-17 Thread TZOTZIOY
On 14 May 2005 04:21:04 -0700, rumours say that
[EMAIL PROTECTED] [EMAIL PROTECTED] might have
written:

I'm typing this in a public library on a computer with OS windows 2000
server. I can run Internet explorer, word, excel and powerpoint, that's
it. Maybe java, but it seems to be flaky.

I want to run python scripts from this computer.

snip

I am not sure I will help you (uncertainty based on the part I snipped),
but the part so far can be easilly solved if you install Python for
single user inside the Documents and settings\username folder (or
whatever it is called).  I did in a similar case.


End of reply here; and now for some completely minor python success
story.


Some months ago, I happened to be for full workdays at a client's site,
with strict security rules enforced (no domain login == no access even
to web proxy) but I needed to access my company's internal mail server
from my laptop (which I do by ssh forwarding usually).  I could plug in
my laptop to their network, get an address, but that was all (local
network access only).

So I asked permission from an employee there (working on a computer
logged on to the domain) if I could run a putty session with forwarding
enabled.  He said he'd ask their BOFH; now, the BOFH was strictly a
windows person (I somehow connect strictly-industry-standard-OS/app
persons with lack of resourcefulness, as if these people have 7 bits
per byte :), and he thought that my case was hopeless, since the
employee's account had only access to a web proxy, and CONNECT requests
were only allowed to port 443, but he said ok anyway (in his place, I
wouldn't; but then again, what do I know? ;).

After a call to a colleague in order to redirect connections to port 443
(from the client's network) of an underused computer at my site to port
22, I set up putty to connect through their web proxy, but that didn't
work (since no authentication was given as requested).

Then it was that I downloaded python, installed it in the employee's
documents folder, and created a 'sniffer' between the web browser and
web proxy to find out the authentication headers.  After testing them by
hand, I wrote a script to pretend it's the web browser requesting a
CONNECT from the web proxy, and putty would connect to my script which
would just pass data back and forth.  It didn't work.

I quickly found out that their web proxy did NOT let anything come and
go, unless its client had sent at least 4 octets (and that was also a
security measure they had taken which I was not told about-- they wanted
only protocols where the client talks first, ie (pun intended) typically
HTTP).  So putty was waiting for the ssh server to announce its version
before announcing itself, but the announcement of the server would not
come through until putty sent something.

So I changed the middle-server [midsrv]: as soon as putty connected to
the listening port of midsrv, it opened the connection to the web proxy,
and instantly sent the putty announcement to the ssh server, consuming
it when putty sent it normally, and happily moving octets around for the
rest of the connection.  From my laptop, I could get my emails with
plain POP3.

That was in 34 minutes time (debugging time included).

When the network guy dropped by a couple of hours later to ask me if I
needed any help, I just thanked him for letting me connect.  He
scratched his head, tried to understand what happened (didn't realise
that the python app was important even though he absent-mindedly passed
over it checking running tasks), so I let him think over it for several
minutes before explaining to him what I did.  He was most impressed with
the python program when I showed it to him, gave a warning to the
employee: ok, run his program, but don't let him touch your computer
again!, and then came to the following conclusion (much similar to a
Python motto):

If Python can do this, it {Python} should be forbidden...


PS Unfortunately, I could not charge security consulting fees.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-dev Summary for 2005-04-16 through 2005-04-30

2005-05-16 Thread TZOTZIOY
On Mon, 16 May 2005 12:06:18 +1200, rumours say that Tony Meyer
[EMAIL PROTECTED] might have written:

A request for anonymous blocks by Shannon -jj Behrens launched a
massive discussion about a variety of related ideas. This discussion
is split into different sections for the sake of readability, but
as the sections are extracted from basically the same discussion,
it may be easiest to read them in the following order:

1. `Localized Namespaces`_

2. `The Control Flow Management Problem`_

3. `Block Decorators`_

4. `PEP 310 Updates Requested`_

5. `Sharing Namespaces`_

6. `PEP 340 Proposed`_

[SJB]

Great job, Steve...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encryption with Python?

2005-05-13 Thread TZOTZIOY
On Sat, 7 May 2005 13:51:40 +0200, rumours say that Anthra Norell
[EMAIL PROTECTED] might have written:

Here's the challenge. Prove this breakable

'\x10\x88d\x1d\xba\xa1\xdcK\x05w\x02/s\xa7Q0\xeb8\xb6Gx\xef\xcb\x1e=\xf5\x7f
\x9bI\xcb(\x87\xa5\x04\xc1soF\xfd\xc6\xc6\xd9|\x971\xdb\xcdT\tw#\x86a\xdc\x
b8P\xfb=n\xda\x80\x9f\x84m\x12\x98\x98\xca=o\x0b\x8e\x08O\xb7\x0b\x04SC\x96\
xc7\xab*\x0b\x996\x06\x86\x83(\x8dQ\x9eG\x8f$\xb2x)\xa9fv\x0c1B\x9b\r\xde\xf
fc\x08'

and given that

I rolled my own for relatively short sequences, like passwords. The key is
an integer. To decrypt use the negative encryption key. I consider the
encryption unbreakable, as it is indistinguishable from a random sequence.

can we suppose that the encrypted text above are the details of your
credit card (number, name as written on it, expiry date, billing address
and your first dog's name)?  Do you trust the 'unbreakability' of your
algorithm that much?
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: creating words of diff lengths

2005-05-13 Thread TZOTZIOY
Is there an echo in here?
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Solipsis: Python-powered Metaverse

2005-05-13 Thread TZOTZIOY
On Wed, 11 May 2005 22:48:31 -0400, rumours say that Terry Reedy
[EMAIL PROTECTED] might have written:

  and what if both computers
 wanted to participate on the port 6000 fun?

Recently, I had one family member use my purchased account to logon to and 
play an online action game, which sends a constant stream of update info. 
Then, curious what would happen, I logged on, from a different computer but 
through the same router, with a temporary guest account.  Somewhat to my 
surprise, it worked -- without touching the computer (XP) or router 
settings.  And kept working the whole weekend.  So there is a way to tag 
update packets so they can be reliably separated into two streams (and vice 
versa).  Solipsis should be able to do the same.

In your case, it's the internal address that originated the connection--
so the router can distinguish the streams:

(int1, port1)-(ext_host, port0)
maps to (router_ext, port2)-(ext_host, port0)

(int2, port3)-(ext_host, port0)
maps to (router_ext, port4)-(ext_host, port0)

Every TCP/UDP packet includes srcip, srcport, dstip, dstport, so an
internal dictionary makes the translations to and fro (the router
changes the srcip, srcport whenever a packet passes through).  The
internal computer knows not that the router mangled the packets, and the
external computer knows nothing about the internal computer address.

However, if both of your internal computers listen to port 6000 for
example, there is no easy way for the router to know to which one it
should forward an *incoming* request for connection to port 6000-- all
it knows is that some external computer connected to its external
interface ip address at some specific port.  In this case, *typically*
you would map port (router_ext, 6000) to (int1, 6000) and (router_ext,
6001) to (int2, 6000).  The internal computers would both think that
some computer is doing a connect at their port 6000.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Supercomputer and encryption and compression @ rate of 96%

2005-05-11 Thread TZOTZIOY
On Mon, 2 May 2005 23:11:54 +0530, rumours say that km
[EMAIL PROTECTED] might have written:

Hi all,

This was posted long ago.
I tried to compress a  mp3 file but i couldnt get the keycode+.out file 
which is of size 1 bit. instead it is printed to STDOUT. i am usng python 2.4 
. i understand that the keycode is embedded in the filename itself. Is it a 
problem with python not able to create a file with such a big filename ? 
any workarounds ? 

Ah...

Perhaps your humour is too subtle for me, in which case my reply is
totally off.  In any case:

Python does not restrict filename lengths; it happily creates filenames
of length less than or equal to the limit imposed by the underlying
operating system.

Now, in our universe there cannot be a compression algorithm that
reduces entropy and file size at the same time.  The code was a joke (I
even suggested a correction, which was a mistake because I hadn't
understood the full joke[1] :)

[snip effbot's code]


[1] I thought that Fredrik just made up something that looked like
working, and he explained that his code *was* working.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python or PHP?

2005-05-11 Thread TZOTZIOY
On Tue, 26 Apr 2005 00:35:59 GMT, rumours say that Jorey Bump
[EMAIL PROTECTED] might have written:

Lad [EMAIL PROTECTED] wrote in news:1114254894.512656.297040
@l41g2000cwc.googlegroups.com:

 Is anyone capable of providing Python advantages over PHP if there are
 any?


As you learn Python, you will find that your PHP code will improve, 
possibly becoming more and more concise until it disappears completely.

+1 QOTW
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-06 Thread TZOTZIOY
On Fri, 29 Apr 2005 23:38:53 +0300, rumours say that pythonchallenge
[EMAIL PROTECTED] might have written:

For the riddles' lovers among you, you are most invited to take part
in the Python Challenge, the first python programming riddle on the net.

You are invited to take part in it at:
http://www.pythonchallenge.com

This is not only about riddle lovers, but a great way to advocate python
to other programmers...  I already had a session with a friend (he did
the thinking, I did the programming next to him) and he was enchanted :)

I'm already investing a little time to think some new riddles to suggest
(extending stdlib coverage).
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delete will assure file is deleted?

2005-04-28 Thread TZOTZIOY
On Wed, 27 Apr 2005 17:28:04 +0200, rumours say that Fredrik Lundh
[EMAIL PROTECTED] might have written:

 import errno
 
 try:
   ...
 except OSError, exc:
 if exc.errno == errno.ENOENT: # file inexistant
  ...
 elif exc.errno == errno.EPERM: # no permissions
  ...

make that

elif exc.errno in (errno.EACCES, errno.EPERM): # no permissions

Yep, you're right (you wouldn't be a bot otherwise, right?-)

BTW I remember a post last summer about subclassing OSError (found it:
http://groups.google.com.gr/groups?selm=87llgxuyf5.fsf%40pobox.com --not
exactly what I remembered, but close.)

I think throwing subclasses of OSError based on errno would make life
easier --always assuming that Python requires POSIX conformance on all
platforms.  I will give it a try RSN...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delete will assure file is deleted?

2005-04-27 Thread TZOTZIOY
On Tue, 26 Apr 2005 21:33:52 -0500, rumours say that Mike Meyer
[EMAIL PROTECTED] might have written:

This is just a little bit tricky. os.remove (on FreeBSD 5-STABLE,
anyway) throws an OSError exception if it doesn't have permission to
remove the file, *or* if the file doesn't exist. You have to examine
the exception for it's value, which is the result of a strerror
call. I believe that the result of strerror is platform dependent.

Although I don't have experience with FreeBSD, so far checking the
exception's errno args does the job.  Example:

import errno

try:
   ...
except OSError, exc:
if exc.errno == errno.ENOENT: # file inexistant
  ...
elif exc.errno == errno.EPERM: # no permissions
  ...
   else:
  raise
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Perl PDF files

2005-04-26 Thread TZOTZIOY
On Mon, 25 Apr 2005 13:00:51 -0400, rumours say that Peter Hansen
[EMAIL PROTECTED] might have written:

Peter Hansen wrote:
 Dennis Lee Bieber wrote:
 On Mon, 25 Apr 2005 17:24:36 +0300, Christos TZOTZIOY Georgiou:
 I don't know any related myth of anglo-saxon origin to quote.

 The most commonly known phrasing would likely be God only helps
 those who help themselves.
 
 Google suggests that removing the word only produces a
 phrase many times more commonly known...

And very interesting reading (to spawn another diversion
typical to c.l.p), such as the third link in Google
titled Vessel of Honour: ... (content available only
via the Cached link), which points out that this
biblical-sounding phrase was never in the bible,
but actually comes *from Greek mythology*, and specifically
(it claims) from the same story as Christos has
quoted, except that the god in question was Hercules
and other details differ somewhat...

It seems that I mixed two myths (I should pay more attention probably to
mythology lessons at primary school :).  The fable with Hercules is the
correct one, as far as a cart and mud is concerned.  The one about
Athena and arm-motion, is that Aesop's fable:

http://www.mythfolklore.net/aesopica/oxford/480.htm

Now there's another phrase, the smart bird gets caught by the beak,
and I don't know if I'm a smart bird, but my nose is big...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Perl PDF files

2005-04-25 Thread TZOTZIOY
On Mon, 25 Apr 2005 09:23:43 -0400, rumours say that rbt
[EMAIL PROTECTED] might have written:

Are there any plans in the near future to support PDF files in Python as 
thoroughly and completely as Perl does?

Before we let you know about our plans, what are *your* plans on this
subject? :) [0]

http://cpan.uwinnipeg.ca/search?query=pdfmode=dist

I love Python's clean syntax and ease of use, etc. But on some things 
(PDF for example) as barbaric as Perl's syntax is, it does outshine 
Python... I hate having to use Perl just to deal with PDF files.

There are two issues here: a) a language, b) its library.  You imply
that the Perl syntax outshines Python's because it has _more thorough
and complete support for PDF_, as you say.  I don't see a connection,
but rather I see a lure to provoke answers, which doesn't always work
for you.  For example, my reply would be more helpful and to the point
if that reasoning was missing from your post.

What do others do???

Search google perhaps?  Why do you feel that the first result of the
query python pdf does not help you?


[0] there's an ancient myth about a peasant's cart getting stuck in the
mud, so the peasant starts calling out for help from goddess Athena.
Another peasant passing by tells him: Syn Athena kai kheira kinei,
which means, more or less, keep on calling Athena, but start also using
your hands.
I don't know any related myth of anglo-saxon origin to quote.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Perl PDF files

2005-04-25 Thread TZOTZIOY
On Mon, 25 Apr 2005 10:32:11 -0400, rumours say that rbt
[EMAIL PROTECTED] might have written:

I do not seek to provoke. Sorry if my question comes across that way to you.

Thanks for giving attention to my post, no need for apologies.

By the way, you didn't say in which way ReportLab and pdflib are not
helpful to you (packages suggested directly by Mike Meyer and indirectly
by me).
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto statement

2005-04-20 Thread TZOTZIOY
On Wed, 20 Apr 2005 14:58:35 +0300, rumours say that Maxim Kasimov
[EMAIL PROTECTED] might have written:

 if you need to comment a couple of code (and then uncomment ), what 
 are you doing then?
 
 Use comments?
 
WOW, just greate! ... but i'd like to relax at some more interesting way than 
to comment each of rows

What editor exactly are you using that can't un/indent and un/comment a
block of lines?  Obviously, neither vi, nor emacs, nor idle.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto statement

2005-04-20 Thread TZOTZIOY
On Wed, 20 Apr 2005 16:13:32 +0300, rumours say that Maxim Kasimov
[EMAIL PROTECTED] might have written:

but what if i just can't to do this becouse i'm working thrue ssh, and have to 
use only installed editors (such as vi)

If you use plain vi (not vim) and you want to comment e.g. 5 lines of
code, go to the first of these five and:

- if autoindent type:

5O^Dif 0:{ESC}

^D above is Ctrl-D, {ESC} is your Escape key

- if noautoindent type:

YP^Cif 0:{ESC}j5

^C above is literal ^, literal C, *NOT* Ctrl-C; {ESC} is your Escape key

To control autoindent, you can type:

:se ai

or

:se noai

If you need more help, I would gladly send you the output of `man vi'
from a non-GNU Unix.  I can also send you the output of `man vim' from a
GNU system.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: random number between 0 and 20

2005-04-20 Thread TZOTZIOY
On 20 Apr 2005 08:15:02 -0700, rumours say that
[EMAIL PROTECTED] might have written:

How can I generate a random number between 0 - 20 and store the number
in nrrandom?

Just choose a random number yourself, eg. nrrandom=17 (just kidding :)


import random

nrrandom = random.randint(0,20)

See also the random.randrange function.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: random number between 0 and 20

2005-04-20 Thread TZOTZIOY
On Wed, 20 Apr 2005 11:10:21 -0400, rumours say that Peter Hansen
[EMAIL PROTECTED] might have written:

NNTP-Posting-Date: Wed, 20 Apr 2005 10:20:45 -0500
Date: Wed, 20 Apr 2005 11:10:21 -0400

Based on these headers from your message, plus the fact that you
answered five minutes before aleksander asked his question, you might
want to either check your computer clock for accuracy or return the time
machine to Guido...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto statement

2005-04-20 Thread TZOTZIOY
On Wed, 20 Apr 2005 18:38:40 +0300, rumours say that Maxim Kasimov
[EMAIL PROTECTED] might have written:

 If you need more help, I would gladly send you the output of `man vi'
 from a non-GNU Unix.  I can also send you the output of `man vim' from a
 GNU system.

is it wrong to debug python script using python, but not some magic commands 
found somewhere in man ?

If you really believe you should use python to debug (and edit perhaps?)
python, use idle and X11 forwarding through your ssh connection instead
of vi.  Then you have menu-driven block un/commenting and un/indenting.

Otherwise, I believe your reply above is slightly adrift (you wondered
what one can do to comment a block of code when using vi, and I replied
to that; I don't quite understand what your exact point is.)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto statement

2005-04-20 Thread TZOTZIOY
On Wed, 20 Apr 2005 18:47:37 +0300, rumours say that Maxim Kasimov
[EMAIL PROTECTED] might have written:

by the way, goto statement will be useful for writing more powerful 
obfuscators

At this point in time you might want to reconsider what are the true
reasons you like python (if you really do :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto statement

2005-04-20 Thread TZOTZIOY
On Wed, 20 Apr 2005 16:24:19 +0100, rumours say that Simon Brunning
[EMAIL PROTECTED] might have written:

On 4/20/05, Christos TZOTZIOY Georgiou [EMAIL PROTECTED] wrote:
 If you need more help, I would gladly send you the output of `man vi'
 from a non-GNU Unix.  I can also send you the output of `man vim' from a
 GNU system.

[Simon]
It'll probably be easier to convince Guido to introduce a 'goto'
statement than it would be to learn vi.

I just happened to learn vi first before emacs, and this precedence set
my preference.  The only needed skill is to remember if you're in
'insert' or 'command' mode (or so I believe)...

I'm really not sure if I'm joking or not.

Have you ever heard of anyone *joking* about their preferred or hated
text editor?-)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to name Exceptions that aren't Errors

2005-04-15 Thread TZOTZIOY
On 7 Apr 2005 21:20:19 GMT, rumours say that Leo Breebaart
[EMAIL PROTECTED] might have written:

[Max about Leo]
 This guys famous in the alternative universe of
 alt.fan.pratchett.

The little imp stopped moving the memory blocks around as soon as it
heard the distinct click of the name Breebart[1] falling into place.


[1] Breeb*aa*rt you say.  Ok then, double click.


I doubt anybody here cares!

I WAS EXPECTING TO MEET THEE IN ALT.FAN.PRATCHETT.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: curses for different terminals

2005-04-15 Thread TZOTZIOY
On Thu, 14 Apr 2005 19:38:26 +0200, rumours say that harold fellermann
[EMAIL PROTECTED] might have written:

 1. Are you doing an single process application that produces output on
 many terminals?  ie the program is kind of like a service?

gotcha. I want to write a TCP server that handles incoming requests in
threads (one thread per request using SocketServer.ThreadingTCPServer).
Now, I want the server to use curses for client-server communication
(client will be telnet). Thus, my programm runs in a single process
(although several threads) and provides several curses screens (one for
each client.)

I see.  At first, here is some relevant source from
Modules/_cursesmodule.c :


A number of SysV or ncurses functions don't have wrappers yet; if you
need
a given function, add it and send a patch.  Here's a list of currently
unsupported functions:

addchnstr addchstr chgat color_set define_key
del_curterm delscreen dupwin inchnstr inchstr innstr keyok
mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr
mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat
mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm
resizeterm restartterm ripoffline scr_dump
scr_init scr_restore scr_set scrl set_curterm set_term setterm
tgetent tgetflag tgetnum tgetstr tgoto timeout tputs
vidattr vidputs waddchnstr waddchstr wchgat
wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl


So the answer is that, no, you can't use newterm currently.

But even if you did, it's not certain that you could use multiterminal
ncurses in a multithreaded environment; AFAIK in ncurses you just change
the current term and then go on with normal curses calls; is there a
current term per thread, or is there one per process?  I couldn't find
an answer in the short search I did.

I am afraid you will have to make it into a 3-tier arch; that is, your
server has the data model and absolutely no curses knowledge, and the
clients run a middle application, interfacing ncurses I/O and server
protocol.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Supercomputer and encryption and compression @ rate of 96%

2005-04-14 Thread TZOTZIOY
On 14 Apr 2005 02:27:26 -0700, rumours say that [EMAIL PROTECTED]
might have written:

Supercomputer and encryption and compression @ rate of 96%

[snip]

In other words, the story of your life can be expressed as a single
binary zero.  Get one.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Supercomputer and encryption and compression @ rate of 96%

2005-04-14 Thread TZOTZIOY
On Thu, 14 Apr 2005 13:49:22 +0200, rumours say that Fredrik Lundh
[EMAIL PROTECTED] might have written:

Will McGugan wrote:

 Please implement this as a Python module. I would like to compress my mp3 
 collection to single 
 bits.

here's the magic algorithm (somewhat simplified):

[snip algo [0]]

Well, I take advantage of this folding idea for years now.  Do you
remember DoubleSpace?  I was getting to the limits [1] of my 100 MiB
hard disk, so I was considering upgrading my hardware.  A female friend
of mine, knowing a little but not a lot about MS-DOS asked the
eye-opening question: why don't you reapply double space to the
compressed drive?

I was enlightened.

Of course, a couple of weeks ago I had a bad sector which destroyed 800
KiB right in the middle of _Echoes_, but I had my whole Pink Floyd
collection on a 5.25 floppy (zip of zip of zip of...)


[0] -- btw, in your code, Fredrik:
file = open(keycode + .out, wb).replace(keycode, filename)

[1] disk space -- the final frontier
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Supercomputer and encryption and compression @ rate of 96%

2005-04-14 Thread TZOTZIOY
On Thu, 14 Apr 2005 16:35:59 +0200, rumours say that Fredrik Lundh
[EMAIL PROTECTED] might have written:

 [0] -- btw, in your code, Fredrik:
 file = open(keycode + .out, wb).replace(keycode, filename)

if you do that, decompression won't work.

How obvious, now that you mention it... :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: curses for different terminals

2005-04-14 Thread TZOTZIOY
On Thu, 14 Apr 2005 18:39:14 +0200, rumours say that harold fellermann
[EMAIL PROTECTED] might have written:

Hi all,

I want to use curses in a server application that provides a GUI for 
telnet clients. Therefore, I need the functionality to open and handle 
several
screens.

Just to make sure we understand what you want to do:

1. Are you doing an single process application that produces output on
many terminals?  ie the program is kind of like a service?

2. Are you doing an application with one session per terminal?  ie a
user starts your app in every terminal, no multi-term output from a
single process.

3. Are you doing an application that runs on one terminal but with many
virtual sessions (or screens), kind of like the `screen(1)` program or
the behaviour of the linux or Novell console?

Concerning 
http://dickey.his.com/ncurses/ncurses-intro.html#init
this can be done using the function newterm(type,ofp,ifp). However, this
function seems not to be defined in the python library. Does anyone know
how this can be done in python?

Select one of the above, or describe more the desired situation if I
didn't cover your case, and we will try to help you more.

-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: LD_LIBRARY_PATH - how to set?

2005-04-04 Thread TZOTZIOY
On Fri, 01 Apr 2005 01:13:03 GMT, rumours say that Joal Heagney
[EMAIL PROTECTED] might have written:

wrapped program $*
---
 
 
 And you should change that last line to:
 
   wrapped program $@
 

Ah yes, because we want the arguments passed in as seperate words, not 
as a whole string.

No, this would happen if your last line was

wrapped program $*


To summarize, suppose your script is called with the following
arguments:

wrapper_script File with space.txt arg2 arg3

Here follow last lines and the corresponding sys.argv[1:]:

LAST LINE: wrapped_program $*
SYS.ARGV : [File, with, space.txt, arg2, arg3]

LAST LINE: wrapped_program $*
SYS.ARGV : [File with space.txt arg2 arg3]

LAST LINE: wrapped_program $@
SYS.ARGV : [File with space.txt, arg2, arg3]

For more information, see man 1 bash or man 1 ksh or man 1 sh.  Don't
know if this applies to *csh family.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Want to meet any of these people? They are registered for PyCon

2005-03-30 Thread TZOTZIOY
On Wed, 30 Mar 2005 14:42:52 GMT, rumours say that Garry Hodgson
[EMAIL PROTECTED] might have written:

Steve Holden [EMAIL PROTECTED] wrote:

 Sorry you can't make it to Python. My even-naiver way of approaching the 
 problem was to use the sort utility built into Cygwin, thereby avoiding 
 writing any code at all.

an easier way is to publish it unsorted, but claim it is sorted.
someone is sure to correct it with the proper sorted list.

For parents, the other way is to forbid their children sorting the list.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: return the last item in a list

2005-03-30 Thread TZOTZIOY
On 30 Mar 2005 10:48:17 -0700, rumours say that David Bear
[EMAIL PROTECTED] might have written:

I've googled for the above and get way too many hits.. 

I'm looking for an 'easy' way to have the last item in a list returned.

I've thought about

list[len(list)-1]

but thought there would be a more gracefull way.

There is.

alist[-1]

Did you read the tutorial?  This is referenced in 3. An Informal
Introduction to Python.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread TZOTZIOY
On 28 Mar 2005 22:06:44 -0800, rumours say that
[EMAIL PROTECTED] [EMAIL PROTECTED] might have
written:

snip complete article-- subject is enough

Read about locals() and globals() in the Python documentation.  These
provide the information you request (ie what names are bound to what
objects).
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for a 10-14 years old?

2005-03-28 Thread TZOTZIOY
On 24 Mar 2005 13:33:58 GMT, rumours say that Fred Pacquier
[EMAIL PROTECTED] might have written:

Christos TZOTZIOY Georgiou [EMAIL PROTECTED] said :

 At the age of nine at school, two guys from a French computer-making
 company named as Loup (in french) or Lupo (in Italian), can't
 remember which --if either is correct--, came and gave us a demo of one
 of their models.

OT/trivia : if it was between mid-eighties and early nineties, the company 
could be Goupil (ancien french for Fox).

Exactly! That was it... it was October or November 1981, though (early
eighties).
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: static variables in functions (was: Version Number Comparison Function)

2005-03-28 Thread TZOTZIOY
On Fri, 25 Mar 2005 19:23:37 GMT, rumours say that [EMAIL PROTECTED] (Bengt
Richter) might have written:

On Fri, 25 Mar 2005 17:02:31 +0100, Fredrik Lundh [EMAIL PROTECTED] wrote:

Keith wrote:

 Is there a function for comparing version numbers?

 E.g.

 0.1.0  0.1.2
 1.876b  1.876c
 3.2.2  3.4

the following works for many common cases:

import re

def cmpver(a, b):
def fixup(i):
try:
return int(i)
except ValueError:
return i
a = map(fixup, re.findall(\d+|\w+, a))
b = map(fixup, re.findall(\d+|\w+, b))
return cmp(a, b) # -1 if ab, 0 if a=b, 1 if ab

[OT] Visually, I like the nested def fixup, and I realize
that for cmpver execution overhead is not likely to be an issue,
but in general, what do you think of not being able
to write it that way if MAKE_FUNCTION overhead is unacceptable?

What if we had something like

@sticky('fixup') # evaluate binding only first time
def cmpver(a , b):
   def fixup ... ?

One of the previous related threads is this (long URL):

http://groups-beta.google.com/group/comp.lang.python/messages/f7dea61a92f5e792,5ce65b041ee6e45a,dbf695317a6faa26,19284769722775d2,7599103bb19c7332,abc53bd83cf8f636,4e87b44745a69832,330c5eb638963459,e4c8d45fe5147867,5a184dac6131a61e?thread_id=84da7d3109e1ee14mode=threadnoheader=1#doc_7599103bb19c7332
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Module function can't see globals after import.

2005-03-28 Thread TZOTZIOY
On Mon, 28 Mar 2005 17:19:42 GMT, rumours say that Ron_Adam
[EMAIL PROTECTED] might have written:

Is there a way to tell the imported function printx to use mymain's
globals instead of it's own copy without passing it as an argument?

No, but if you insist on working with globals for some reason of your
own, in the module you can:

import __main__

and access the main modules globals (eg 'x') as:

__main__.x
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Version Number Comparison Function

2005-03-25 Thread TZOTZIOY
On 25 Mar 2005 07:34:38 -0800, rumours say that Keith
[EMAIL PROTECTED] might have written:

Is there a function for comparing version numbers?

E.g.

0.1.0  0.1.2
1.876b  1.876c
3.2.2  3.4

Keith

Convert your version numbers into tuples:

(0, 1, 0)  (0, 1, 2)
(1, 876, 'b')  (1, 876, 'c')
(3, 2, 2)  (3, 4)

All of the above are True.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestions for a Java programmer

2005-03-24 Thread TZOTZIOY
On 24 Mar 2005 00:22:09 -0800, rumours say that Ray
[EMAIL PROTECTED] might have written:

Can you point me to Python for Java Programmers resources? I found
one blog, but that only touched the tip of the iceberg, I feel. I know
that as I use Python more and read more books and read how experienced
Python programmers code, eventually I'll find it out. But I'd like to
expedite that process if possible. What are your suggestions?

Searching google for python for java programmers (without the quotes)
produces:

Python for Java programmers - Irmen's Python wiki
Python  Java: Side by Side Comparison
Jython Home Page (which you might like a lot)
dirtSimple.org: Python Is Not Java (some useful pointers)

among others.  You didn't specify which blog you found, so HTH.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for a 10-14 years old?

2005-03-24 Thread TZOTZIOY
On 24 Mar 2005 02:35:34 -0800, rumours say that Michele Simionato
[EMAIL PROTECTED] might have written:

snip

I am pretty much convinced I could have mastered Python at the age
of nine. Of course, I cannot prove it, since when I was nine
I had no computer, I did not know English, and Python was not
yet invented. But apart for this minor circumstances, I don't
thing I was dumber as a child than as an adult.

At the age of nine at school, two guys from a French computer-making
company named as Loup (in french) or Lupo (in Italian), can't
remember which --if either is correct--, came and gave us a demo of one
of their models.  They wrote a simple BASIC program on the blackboard
and proceeded in explaining what the program did, and then asked for a
kid to type it.  I was chosen randomly, and I managed to do that, but I
*didn't* understand a thing.  See, I didn't either know English (we had
French at school), and I had no contact with computers earlier.  I had a
good knowledge of how things work in the surrounding world, even knew a
lot about electricity and how it works (I had played a lot with
batteries, buttons, wires and lights in order to make some amazing
devices to use with my friends when we were playing Galactica or
Space 1999 or Star Trek...), but *this* I couldn't grok.

This was the challenge that marked my life, I can say.  Next year I
managed to get my parents into buying me a ZX Spectrum 16K, the year
after that I managed to get them into buying me the 32K RAM upgrade
(first hw upgrade I ever did!), and one year and a half later, I managed
to get the Sinclair QL, with better BASIC, multitasking capabilities,
and something more like an OS than any other home computer till then.
And man, wasn't 68k assembly a joy :)

snip

The problem teachers face when explaining computers to kids, is
to keep them interested, so they prepare courses about graphics,
videogames, etc. But if you get the right kid, he/she will be
interested even on IBM Fortran IV with WATFOR and WATFIV ;)

The second book on computers I *bought* was Artificial Intelligence on
the Sinclair QL (age 12 --I bought the book *before* I got the QL :).
The first was 1001 Games for the ZX Spectrum (age 11).  We had lots of
computer magazines though, with lots of source code in them to keep a
kid interested then (the age of home computers)...

Personally, at that age I knew everything about the solar system
planets, distances from the Sun, masses, diameters, albedos, etc.
Fortunately, now I have forgot nearly everything ;)

Unless you play trivial pursuit with friends, in which case such
knowledge is very useful (and doesn't get forgotten :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for a 10-14 years old?

2005-03-24 Thread TZOTZIOY
On 24 Mar 2005 14:50:39 +0200, rumours say that Ville Vainio
[EMAIL PROTECTED] might have written:

 Christos == TZOTZIOY  Christos writes:

Christos (first hw upgrade I ever did!), and one year and a half
Christos later, I managed to get the Sinclair QL, with better
Christos BASIC, multitasking capabilities, and something more
Christos like an OS than any other home computer till then.  And
Christos man, wasn't 68k assembly a joy :)

Linus Torvalds also bought Sinclair Ql back in the day - I was
quite surprised to find out that it had a 32bit CPU (according to his
autobiography).

68008 at 8 MHz with 32bit architecture, 16bit ALU (long operations took
2 cycles), 8bit external bus (to communicate with cheap memory and other
ICs), 20bit max address space, but with complete compatibility with
68000 machine code.  For example, one could issue the following *single*
instruction:

MOVE.L ($18000), ($18004)

to copy the long from address 98304 to address 98308.  Intel provided
such functionality much later; I am not sure if even the 386 could use
memory indirect on both operands...

If only IBM had chosen Motorola for its new PC, 64KiB memory segments
would be something to laugh at, not something to remember and cry
about...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simultaneous copy to multiple media

2005-03-23 Thread TZOTZIOY
On Mon, 21 Mar 2005 00:17:05 +0100, rumours say that Heiko Wundram
[EMAIL PROTECTED] might have written:

Well, 430 MB/s is only for USB 2.0. 

It's 480 Mb/s (megabit or mebibit, I am not sure... :), so it maxes at
about 60 MB/s (or MiB/s) for all devices on the same controller.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] sorting matrixes

2005-03-22 Thread TZOTZIOY
On 22 Mar 2005 09:02:51 -0800, rumours say that Xah Lee [EMAIL PROTECTED] 
might
have written:

Today we'll write a program that can sort a matrix in all possible
ways.

Here's the Perl documentation. I'll post a Perl and Python version in 2
days.

Don't bother writing a Python version... list.sort and its arguments are fine
and send their greetings.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pre-PEP: Dictionary accumulator methods

2005-03-22 Thread TZOTZIOY
On Sat, 19 Mar 2005 01:24:57 GMT, rumours say that Raymond Hettinger
[EMAIL PROTECTED] might have written:

I would like to get everyone's thoughts on two new dictionary methods:

def count(self, value, qty=1):
try:
self[key] += qty
except KeyError:
self[key] = qty

def appendlist(self, key, *values):
try:
self[key].extend(values)
except KeyError:
self[key] = list(values)

Both are useful and often needed, so I am +1 on adding such
functionality.  However, I am -0 on adding methods to dict.

I believe BJörn Lindqvist suggested a subtype of dict instead, which
feels more right.  I believe this is a type of 'bag' collection, and it
could go to the collections module.

The default argument 99% of the time is the same for all calls to
setdefault of a specific instance.  So I would suggest that the default
argument should be an attribute of the bag instance, given at instance
creation.  And since unbound methods are going to stay, we can use the
accumulator method as a default argument (ie int.__add__ or list.append)

Based on the above, I would suggest something like the following
implementation, waiting criticism on names, algorithm or applicability:)

.class bag(dict):
.def __init__(self, accumulator=int.__add__):
.self.accumulator = accumulator
.
.# refinement needed for the following
.self.accu_class = accumulator.__objclass__
.
.# if there was an exception, probably the accumulator
.# provided was not appropriate
.
.def accumulate(self, key, value):
.try:
.old_value = self[key]
.except KeyError:
.self[key] = old_value = self.accu_class()
.new_value = self.accumulator(old_value, item)
.
.# and this needs refinement
.if new_value is not None: # method of immutable object
.self[key] = new_value

This works ok for int.__add__ and list.append.

PS I wrote these more than 36 hours ago, and before having read the
so-far downloaded messages of the thread.  I kept on reading and
obviously others thought the same too (default argument at
initialisation).

What the heck, Bengt at least could like the class method idea :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why tuple with one item is no tuple

2005-03-22 Thread TZOTZIOY
On 15 Mar 2005 11:25:15 -0500, rumours say that [EMAIL PROTECTED] (Roy
Smith) might have written:

The big question is, is it the parens that make it a tuple, or is it
the comma?  If you go along with the parens school of thought, then
(1,) is the special case.  If you believe in commas, then the () is
the special case.  In either case, it's a bit ugly, but we learn to
overlook the occasional cosmetic blemishes of those we love :-)

My take on this is that comma defines tuples, and () is the exception.

. tpl = 1, 2, 3 * 4; print tpl
(1, 2, 12)
. tpl = (1, 2, 3) * 4; print tpl
(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)

So parentheses just change precedence (comma has lower precedence than
star).
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sound processing - avarage amplitude?

2005-03-20 Thread TZOTZIOY
On Sat, 19 Mar 2005 17:18:42 +0200, rumours say that Niklas Paro [EMAIL 
PROTECTED]
might have written:

Hello

I would need way to check the amplitude (over time) for a sound file in
python. I'm sure this can be done, for example the audioop.rms function
seems to be able return amplitude values. However, it would be really
great to get the results in dB, which does not seem to be the case.
Anyone who has more information about this, or a way to convert the
results? I've searched google but info about audioop seem to be quite
scarce. Also, does audioop function perfectly also for wave files? Also,
cross-platform solutions are of course preferred, but I'm running linux
(with oss).

audioop is platform independent.  You just might need to import wave also.

I've also looked somewhat into tkSnack (http://www.speech.kth.se/snack/)
which has a dBPowerSpectrum function which might be doing at least
partially what i want it to, however, the returned values are approx.
-100 ... which I find odd. The real, recorded sound was somewhere in
the 50-60dB range.

Where is your 0dB mark?  If it's at maximum amplitude (1), then any value
(except zero) can be expressed as (negative) dB by the following function:

def amp2dB(amplitude):
return 20*math.log(amplitude, 10)

If you're converting from the 0...32767 range of 16bit PCM files, first divide
the amplitude by 32767.0 and pass the result to amp2dB.

thanks in advance

Hope this helps.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How two modules call functions defined in each other?

2005-03-20 Thread TZOTZIOY
On 19 Mar 2005 18:07:31 -0800, rumours say that Tian [EMAIL PROTECTED]
might have written:

I am python beginner, I have a question about the interdependence of
modules.

For example, when I have two modules:

module1.py
-
def plus(x):
  return add(x,1)


module2.py
-
def add(x,y):
  return x+y

def plus2(x):
  return plus(x)+1

How should I write import in both files?

In module1, import module2 and vice versa.  From moduleX, you access any
attribute (function or variable) of moduleY by using moduleY.attribute .

What about the global varibals? is there anything like extern keyword
in C?

There are no global variables in Python, only module-level attributes.  If by
global you mean the main program's (which is also a module) attributes, in your
other modules do a:

import __main__

and then access its attributes as __main__.attribute .  It's not generally a
good idea in Python, though, so you might like to explain what you need to do so
that we suggest alternate approaches.

or python has some other solutions?

Cheers!
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how can I put a 1Gb file in a zipfile??

2005-03-20 Thread TZOTZIOY
On Sun, 20 Mar 2005 10:44:06 +0100, rumours say that Bennie [EMAIL PROTECTED]
might have written:

Hi,

I have a problem with ZipFile.
It works okay untily I come across a file that is greater then 1Gb.
Then it exit with the error:
   OverflowError: long int too large to convert to int

How can I fix this?

AFAIR there is a 4GiB (or 2GiB) size limit applying both to files added to zip
and to the total size of the zip file.  This limit comes from the zip file
specification (32 bit offsets).

souce:
   zip = zipfile.ZipFile(file, 'w')
   
   for all in os.walk(os.getcwd()):
   path = all[0]
   for document in all[2]:
   zipaccview.write(path + os.sep + document)

   zip.close()

Can it be that you are creating a zip file that its total size exceeds the
limit?
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python scope is too complicated

2005-03-20 Thread TZOTZIOY
On Sun, 20 Mar 2005 13:53:34 +0200, rumours say that Max
[EMAIL PROTECTED] might have written:

Yeah, I know. It's the price we pay for forsaking variable declarations. 
But for java programmers like me, Py's scoping is too complicated. 
Please explain what constitutes a block/namespace, and how to refer to 
variables outside of it.

I presume you read 4.1 Naming and binding from Python reference manual.

What constitutes a block is answered in paragraph 2, for example.  Please come
back with confusing / missing information in that chapter giving us a chance to
improve the documentation.

Cheers!
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: raise takes a long time

2005-03-20 Thread TZOTZIOY
On Fri, 18 Mar 2005 12:04:02 +, rumours say that Robin Becker
[EMAIL PROTECTED] might have written:

I'm trying to get a handle on a real world problem related to raising an 
exception. This is in the reportlab SimpleDoctemplate class.

The following code takes a very long time (60 seconds) in Python 2.2, 2.3, 
2.4, 
but not in 2.1 (at least on windows).

raise LayoutError(Flowable %s too large on page %d % (f.identity(30), 
self.page))

Maybe this is dumb, but how long does the following take?

raise LayoutError, Flowable %s too large on page %d % (f.identity(30),
self.page)

However, the supposedly functionally identical code

ident = f.identity(30)
raise LayoutError(Flowable %s too large on page %d % (ident, self.page))

Let's not assume that f.identity(30) runs equally fast in the two cases (for any
obscure reasons).  Did you time it (ie get the time at the start and end of the
function)?

does not take a long time ( 1 second). The exception LayoutError is trivial
class LayoutError(Exception):
 pass

-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Listbox fill=BOTH expand=YES (Tkinter)

2005-03-17 Thread TZOTZIOY
On Thu, 17 Mar 2005 00:54:46 +0300, rumours say that Raseliarison nirinA
[EMAIL PROTECTED] might have written:

i'll recite 42 times precedence rules before going to bed.
but now i'm a bit confused by the -in- operator. as:

 set(['TRUE','YES']).issubset(set(dir(Tkconstants)))
True

i expected this to be true, but it's not:

 set(['TRUE','YES']) in set(dir(Tkconstants))
False

the 'in' operator searches for existance of *elements* in a set, not of
*subsets*.  BTW, only a frozenset can be included in a set.

To check for subsets, either use the issubset function, or the '' operator (I
believe they both call the same code):

. set(['TRUE','YES']).issubset(set(dir(Tkconstants)))
True

can be expressed as

. set(['TRUE','YES'])  set(dir(Tkconstants))
True
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Itertools wishlists

2005-03-17 Thread TZOTZIOY
On Thu, 17 Mar 2005 06:09:44 GMT, rumours say that Raymond Hettinger
[EMAIL PROTECTED] might have written:

[snip]

 Did I make you believe I cared about the fate of any function judged unworthy
 even for the documentation?

No.  My note was mainly for the benefit of those who had an interest in what
type of ideas had been discussed and the reasoning behind their
inclusion/exclusion.  It needed to be documented somewhere and the newsgroup
discussion on a couple of proposals provided an opportunity to put those notes
on record.

In that case, I thank you too (like Terry) for the trouble writing down those
notes.

 I'm just whining that putting recipes in the docs as an 'extended
 toolset' instead of in a module is a joking compromise...

Not really.  The recipes have several uses and none of them are compromises.

Of course they aren't compromises.  Who said they were?  The subsentence is a
joking compromise, to which your Not really applies, has putting as
subject, not uses of recipes.  It's possible that my lack of fluency in the
English language confused you.

[snip]

By way of comparision, consider the evolution of set()/frozenset() which went
through stages as recipes, as a PEP, then as Python module, and finally as C
coded built-ins.  That multi-stage process was deliberate and resulted in the
final version being excellent.  Similarly, many new decorators are going to
start their lives as wiki entries or recipes.  Ultimately, some will make it
into the standard library.  It would be a mistake to make that transition too
quickly.

That (long cycle/excellent results) is surely true.  And sets are *very* useful
as the majority would agree.  Thanks about sets, too.

The other purpose of the itertool recipes is to serve as a teaching tool 
showing
how to combine the tools and how to integrate them with other Python code.  
IMO,
most of the recipes are more useful in this capacity than as immediate 
solutions
to particular problems.

Well, I have to respect your opinion and so I drop the subject... but with my
dying breath, re:

to serve as a teaching tool showing
how to combine the tools and how to integrate them with other Python code.

, I cry that's why we hint at people to /read/ the /source/ of the standard
library... :)

Cheers.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: computing a weighted sum

2005-03-17 Thread TZOTZIOY
On Thu, 17 Mar 2005 08:11:11 GMT, rumours say that Raymond Hettinger
[EMAIL PROTECTED] might have written:

[Christos TZOTZIOY Georgiou]
 Anyway, a functional equivalent:

 . from itertools import starmap, izip
 . import operator
 . x= [1,2,3,4]
 . w=[3.0, 6.0, 9.0, 12.0]
 . sum(starmap(operator.mul, izip(x,w)))
 90.0

Gack!  starmap() is only for situations where the data is already in tuple 
form.
If it inputs are already distinct, imap() is the preferred form.

FWIW, the answer was already in the docs (itertools recipes):

def dotproduct(vec1, vec2):
return sum(imap(operator.mul, vec1, vec2))

What, you're some kind of expert on itertools now? :-)

You are of course absolutely correct.  Let my post stand as an example of
itertools misuse.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I can do it in sed...

2005-03-17 Thread TZOTZIOY
On Wed, 16 Mar 2005 19:06:40 -0600, rumours say that Terry Hancock
[EMAIL PROTECTED] might have written:

snip

You mean you have a text file and you want to find all the lines between
a line starting with  start and one starting with end.

snip

lines = open('myfile', 'r').readlines()
printing = 0
for line in lines:
if line[:5]=='start': printing=1
if line[:3]=='end':  printing=0
if printing: print line

suggested order to mimic sed functionality:

if line[:5]=='start': printing=1
if printing: print line
if line[:3]=='end':  printing=0

and perhaps it's better to use startswith than slicing.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Itertools wishlists

2005-03-16 Thread TZOTZIOY
On Sun, 13 Mar 2005 06:52:40 GMT, rumours say that Raymond Hettinger
[EMAIL PROTECTED] might have written:

[snip of lots of stuff]

itertools.window() with n=2 got rejected.  Almost all proposed uses had better
solutions (such as an accumulator variable or fibonacci sequence style logic:
a, b = b, a+b).  Writing it in C afforded only small speed advantage over a
solution using izip() and tee().

Speed or C implementation was not my objection.  I don't care if C itertools
gets renamed to _itertools and some Python itertools imports _itertools first
thing a la heapq, and then the most probably useful doc recipes get defined in
Python; in fact, I would like that.  Do you think that window is rarely used?
You didn't say that in your post, you just argued against implementing it in C.
I agree.  Don't implement it in C.  Implement it as in the recipe.  Just make it
readily available.  I volunteer for a patch if we agree on it[1].

For example, if speed is our main concern, why is there PEP 309 for partial
function application as a class?  The tools are already there, and
new.instancemethod is our friend.  In the case of binding only the first
argument, which is the most common, calling the resulting object is 2% faster
than calling the function itself (at least on my laptop).  Of course, PEP 309 is
not about speed; it's about availability of /correct/ and /useful/
functionality.  Kind of like recipes in the itertools documentation.

'nuff said, mister whatever happened to batteries included ;-)

Cool extensive summarising reply --however, how relevant is it?  None of the
itertools.(queue|roundrobin|accumulate|multi_gen|remove_value|eq|consume|ilines)
that you reference exists as a recipe in the docs.

Did I make you believe I cared about the fate of any function judged unworthy
even for the documentation?  Because, if it is my fault, let me correct that: I
am talking about the recipes in the documentation (those found worthy enough to
be included in the docs, but not found worthy enough to be included in the lib),
and specifically for window and flatten: why aren't they considered as
batteries?  About flatten, you say things are still warm.  About window, you say
it's not really efficient, use izip and tee, or use a deque for n2.  Ok.  I
never spoke about speed.  I spoke about tool availability.

IIRC you were cooled down in Python-Dev from adding more functions into
itertools; it was kind of a surprise for me now to see /you/ of all people
defending this choice.  FWIW, I like speed (who doesn't if nothing else is
affected?); I have an unpolished CPython pcode decompiler / compiler that offers
a decorator for function-level optimising and a function that modifies *.py[co]
files replacing patterns like the one you yourself lately worried about [2],
which module I leave as-is partly waiting the AST branch to be finished and
partly because now and then you implement some part of it in the peephole
optimiser.  So no objections about speed, just note that I didn't mention it in
my previous post.

AFAIAC, in my own stdlib-supporting modules what I need is readily available;
possibly I'm just whining that putting recipes in the docs as an 'extended
toolset' instead of in a module is a joking compromise...

P.S.  It's not an accident that the recipes in the itertools docs are in a form
that is directly cut and pastable into a working application.

[1] Like I said, I volunteer to copy-paste from the docs into a Python module
for the stdlib.  Thanks for the eye-opening hint!-)

[2] STORE_sth x/LOAD_sth x into DUP/STORE_sth x, local binding of multiple
LOAD_sth x/LOAD_ATTR/LOAD_ATTR where x is an imported module into a LOAD_FAST or
a LOAD_CONST based on whether it's the modifier or the decorator,
LOAD_CONST*/BUILD_LIST into LOAD_CONST a_tuple/UNPACK_SEQUENCE/BUILD_TUPLE,
a,b,c=d,e,f reordering and dropping of the tuple building/unpacking (which is
a case already improved in C) etc.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode converting

2005-03-16 Thread TZOTZIOY
On 16 Mar 2005 02:53:12 -0800, rumours say that Serge Orlov
[EMAIL PROTECTED] might have written:

3) There is a note in README: To compile
Python2.3 with Tkinter, you will need to pass --enable-unicode=ucs4
flag to ./configure

I thought this applied to Tkinter as pre-built on recent RedHat systems.  Does
it also apply to FreeBSD?  On Windoze, Mandrake and SuSE python has UCS-2
unicode and Tkinter is working just fine.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Listbox fill=BOTH expand=YES (Tkinter)

2005-03-16 Thread TZOTZIOY
On Tue, 15 Mar 2005 16:48:17 +0300, rumours say that Raseliarison nirinA
[EMAIL PROTECTED] might have written:

yes, indeed. 
 import Tkconstants
 'True' and 'YES' in dir(Tkconstants)
True

thanks Harlin,

I hope you also know that

. 'inexistent keyword' and 'YES' in dir(Tkconstants)

is also True...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode converting

2005-03-16 Thread TZOTZIOY
On 16 Mar 2005 04:21:16 -0800, rumours say that Serge Orlov
[EMAIL PROTECTED] might have written:

 On Windoze, Mandrake and SuSE python has UCS-2
 unicode and Tkinter is working just fine.

Did you build python on Mandrake and SuSE yourself? I had an impression
that ucs-4 builds are prefered on Linux. At least python on RedHat EL3
and SUSE ES9 is built with --enable-unicode=ucs4.

[EMAIL PROTECTED]/home/tzot/tmp
$ py
Python 2.4 (#8, Mar  2 2005, 11:12:44)
[GCC 3.3.3 (SuSE Linux)] on linux2
Type help, copyright, credits or license for more information.
. import sys
. sys.maxunicode
65535
. import Tkinter
.
You have new mail in /var/mail/tzot
[EMAIL PROTECTED]/home/tzot/tmp
$ python
Python 2.3.3 (#1, Aug 31 2004, 13:51:39)
[GCC 3.3.3 (SuSE Linux)] on linux2
Type help, copyright, credits or license for more information.
. import sys, Tkinter
. sys.maxunicode
1114111
.

2.4 built by me, 2.3.3 by SuSE.

I see.  So on SuSE 9.1 professional too, Python and Tcl/Tk are pre-built with
ucs-4.  My Mandrake installation is at home and I can't check now.  Sorry for
the misinformation about SuSE.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: computing a weighted sum

2005-03-16 Thread TZOTZIOY
On 16 Mar 2005 06:49:09 -0800, rumours say that [EMAIL PROTECTED] might have
written:

Suppose I have a list of n floats x and a list of n floats w and I want
to compute x[0]*w[0] + .. + x[n-1]*w[n-1].

Is there some elegant expression (perhaps using lambda) to have it done
in one statement ? As in :
 y = lambda x,w : ...

I ask because the way I am doing it now :
  y = 0
  for i in range(0,n): y += x[i]*w[i]

doesn't seem very pythonic :)

Your method seems to be the one closest to what's generally considered as
pythonic.

Anyway, a functional equivalent:

. from itertools import starmap, izip
. import operator
. x= [1,2,3,4]
. w=[3.0, 6.0, 9.0, 12.0]
. sum(starmap(operator.mul, izip(x,w)))
90.0
.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Downloading all files older than 3 hours from a ftp-server.

2005-03-15 Thread TZOTZIOY
On 15 Mar 2005 00:38:20 -0800, rumours say that Thomas W
[EMAIL PROTECTED] might have written:

I need to download all files older than 3 hours from a ftp-server.
What's the easiest way to this? I've looked into the standard ftplib,
but it seems like the only way to go is to parse the
ftp.retrlines('LIST') command and that seems to be very easy to mess
up. 

any hints? 

google brings this up:

http://www.sschwarzer.net/python/ftputil.html

ISTR seeing a parsedate (or similar) for ftp sites by the effbot, but I am not
sure.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simulated samba server

2005-03-15 Thread TZOTZIOY
On 15 Mar 2005 02:08:55 -0800, rumours say that tc [EMAIL PROTECTED]
might have written:

Does anyone know of a module for python which simulates a samba server
(windows fileshare). Instead of sharing a Phisical Device I'd like to
share a database based filesystem which is spread over various numbers
of drives and servers.

I haven't seen one so far; however, is it possible that you could serve your
users through HTTP?  I have done so in a similar situation like yours.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python version anachronism

2005-03-15 Thread TZOTZIOY
On Tue, 15 Mar 2005 10:23:02 +, rumours say that Simon Brunning
[EMAIL PROTECTED] might have written:

3.2.5 is a bugfix release of the 2.3 branch

Damn, we're on Python 3 already?  Where are all the PEPs I missed?-)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode study with unicodedata module

2005-03-15 Thread TZOTZIOY
On 15 Mar 2005 04:55:17 -0800, rumours say that Xah Lee [EMAIL PROTECTED] 
might
have written:

how do i get a unicode's number?

e.g. 03ba for greek lowercase kappa? (or in decimal form)

you get the character with:

. uc = u\N{GREEK SMALL LETTER KAPPA}

or with

. uc = unicodedata.lookup(GREEK SMALL LETTER KAPPA)

and you get the ordinal with:

. ord(uc)

ord works for strings and unicode.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode converting

2005-03-15 Thread TZOTZIOY
On Tue, 15 Mar 2005 18:54:20 +0200, rumours say that Maxim Kasimov
[EMAIL PROTECTED] might have written:

 It shouldn't be your concern - but you can specify it using  ./configure
 --enable-unicode=ucs2 or --enable-unicode=ucs4. You can't set it to utf-8
 or utf-16.

is that means that python internal unicode format is ucs2 or ucs4?
i'm concerning with the qustion because i need to send data to external
application in ucs2 encoding

If unicode_data references your unicode data, all you have to send is:

unicode_data.encode('utf-16') # maybe utf-16be for network order

You should not care about internal encoding of unicode objects.

-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wishlist item: itertools.flatten

2005-03-11 Thread TZOTZIOY
On 11 Mar 2005 13:32:45 +0200, rumours say that Ville Vainio
[EMAIL PROTECTED] might have written:

For quick-and-dirty stuff, it's often convenient to flatten a sequence
(which perl does, surprise surprise, by default):

[1,2,[3,hello,[[4  -

[1, 2, 3, 'hello', 4]

One such implementation is at

http://aspn.activestate.com/ASPN/Mail/Message/python-tutor/2302348

but something like this would be handy in itertools as well.

It seems trivial, but I managed to screw up several times when trying
to produce my own implementation (infinite recursion).

See Python Library Reference, 5.16.3 Recipes.  Now that all and any (also
presented as recipes there) are considered to be included, perhaps flatten gets
a chance too.

This is just a personal opinion, but I detest restraints on library (itertools
module in this case) expansion when talking about such useful *building blocks*.
What happened to batteries included?
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] a program to delete duplicate files

2005-03-11 Thread TZOTZIOY
On Fri, 11 Mar 2005 01:24:59 +0100, rumours say that Patrick Useldinger
[EMAIL PROTECTED] might have written:

 Have you found any way to test if two files on NTFS are hard linked without
 opening them first to get a file handle?

No. And even then, I wouldn't know how to find out.

MSDN is our friend for Windows stuff.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createhardlink.asp

and then

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/getfileinformationbyhandle.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/by_handle_file_information_str.asp

The relevant parts from this last page:

st_dev - dwVolumeSerialNumber

st_ino - (nFileIndexHigh, nFileIndexLow)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] a program to delete duplicate files

2005-03-11 Thread TZOTZIOY
On Fri, 11 Mar 2005 01:12:14 +0100, rumours say that Patrick Useldinger
[EMAIL PROTECTED] might have written:

 On POSIX filesystems, one has also to avoid comparing files having same 
 (st_dev,
 st_inum), because you know that they are the same file.

I then have a bug here - I consider all files with the same inode equal, 
  but according to what you say I need to consider the tuple 
(st_dev,ST_ium). I'll have to fix that for 0.13.

I have a bug here too-- I wrote st_inum meaning st_ino, but that would be quick
to find!

 Thanks ;-)

You are very welcome.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] a program to delete duplicate files

2005-03-11 Thread TZOTZIOY
On Fri, 11 Mar 2005 11:07:02 -0800, rumours say that David Eppstein
[EMAIL PROTECTED] might have written:

More seriously, the best I can think of that doesn't use a strong slow 
hash would be to group files by (file size, cheap hash) then compare 
each file in a group with a representative of each distinct file found 
among earlier files in the same group -- that leads to an average of 
about three reads per duplicated file copy: one to hash it, and two for 
the comparison between it and its representative (almost all of the 
comparisons will turn out equal but you still need to check unless you 
use a strong hash).

The code I posted in another thread (and provided a link in this one) does
exactly that (a quick hash of the first few K before calculating the whole
file's md5 sum).  However, Patrick's code is faster, reading only what's
necessary (he does what I intended to do, but I was too lazy-- I actually
rewrote from scratch one of the first programs I wrote in Python, which
obviously was too amateurish code for me to publish :)

It seems your objections are related to Xah Lee's specifications; I have no
objections to your objections (-:) other than that we are just trying to produce
something of practical value out of an otherwise doomed thread...
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wishlist item: itertools.flatten

2005-03-11 Thread TZOTZIOY
On 12 Mar 2005 00:44:39 +0200, rumours say that Ville Vainio
[EMAIL PROTECTED] might have written:

Christos This is just a personal opinion, but I detest restraints
Christos on library (itertools module in this case) expansion
Christos when talking about such useful *building blocks*.

Yeah - esp. in the case of flattening. If it was deemed useful enough
to be the default behavior in perl (which is admittedly braindamaged),
it should surely warrant being included as a single function in the
stdlib.

Or a window function, which I have needed enough times in *separate* occasions
to add it in one of my personal stdlib modules (hinting it could be part of
itertools):

window('hello', 2) = 'he', 'el', 'll', 'lo'
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Test

2005-03-11 Thread TZOTZIOY
On Fri, 11 Mar 2005 17:33:14 -0500, rumours say that JMG [EMAIL PROTECTED]
might have written:

hello world

Test failed: wrong case of 'h', missing ',' and '!'.  Sorry.  Try again.

NB by posting to alt.test instead, you have better chances of avoiding smart-ass
replies like mine :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] a program to delete duplicate files

2005-03-10 Thread TZOTZIOY
On Wed, 9 Mar 2005 16:13:20 -0600, rumours say that Terry Hancock
[EMAIL PROTECTED] might have written:

For anyone interested in responding to the above, a starting
place might be this maintenance script I wrote for my own use.  I don't
think it exactly matches the spec, but it addresses the problem.  I wrote
this to clean up a large tree of image files once.  The exact behavior
described requires the '--exec=ls %s' option as mentioned in the help.

The drawback of this method is that you have to read everything.  For example,
if you have ten files less than 100KiB each and one file more than 2 GiB in
size, there is no need to read the 2 GiB file, is there?

If it's a one-shot attempt, I guess it won't mind a lot.

On POSIX filesystems, one has also to avoid comparing files having same (st_dev,
st_inum), because you know that they are the same file.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] a program to delete duplicate files

2005-03-10 Thread TZOTZIOY
On Thu, 10 Mar 2005 10:54:05 +0100, rumours say that Patrick Useldinger
[EMAIL PROTECTED] might have written:

I wrote something similar, have a look at 
http://www.homepages.lu/pu/fdups.html.

That's fast and good.

A minor nit-pick: `fdups.py -r .` does nothing (at least on Linux).

Have you found any way to test if two files on NTFS are hard linked without
opening them first to get a file handle?
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I Read/Write multiple sequential Binary/Text data files

2005-03-10 Thread TZOTZIOY
On 10 Mar 2005 09:41:05 -0800, rumours say that Albert Tu
[EMAIL PROTECTED] might have written:

Dear there,

We have an x-ray CT system. The acquisition computer acquires x-ray
projections and outputs multiple data files in binary format (2-byte
unsigned integer) such as projection0.raw, projection1.raw,
projection2.raw ... up to projection500.raw. Each file is
2*1024*768-byte big.

I would like to read those files and convert to ascii files in %5.0f/n
format as projection0.data ... projection500.data so that our
visualization software can undersatnd the projection images. I was
trying to do this conversion using Python. However, I had troubles
declaring the file names using the do-loop index. Anyone had previous
experience?   

Regular expressions could help, but if you *know* that these are the filenames,
you can (untested code):

PREFIX= projection
SUFFIX_I= .raw
SUFFIX_O= .data

import glob, struct

for filename in glob.glob(%s*%s % (PREFIX, SUFFIX_I)):
number= filename[len(PREFIX):-len(SUFFIX_I)]
fpi= open(filename, rb)
fpo= open(%s%s%s % (PREFIX, number, SUFFIX_O), w)
while 1:
datum= fpi.read(2)
if not datum: break
fpo.write(%5d\n % struct.unpack(H, datum)) # check endianness!!!
fpi.close()
fpo.close()
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recognizing the Arrival of a New File

2005-03-08 Thread TZOTZIOY
On Tue, 08 Mar 2005 08:43:04 -0600, rumours say that Greg Lindstrom
[EMAIL PROTECTED] might have written:

I am writing an application where I need to recognize when a file 
arrives in a given directory.  Files may arrive at any time during the 
course of the day.  Do I set up a cron job to poll the directory every 
few minutes?  Write a daemon to monitor the directory?  Or is there some 
other more common/accepted way to perform this task?  I'm using Python 
2.3 on Linux.

The most common way to watch for a file or a directory change (in my experience)
is to use the SGI fam (file alteration monitor); I think it has been ported to
Linux.  Otherwise, either way you describe is common use.  Suggestion: first
check for changes in the st_mtime of the directory, then search for the file
existence.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >