How to avoid "f.close" (no parens) bug?

2005-11-12 Thread o



plez send me
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Property Abuse

2011-12-14 Thread Felipe O
Hi All,
I was wondering what everyone's thought process was regarding properties.
Lately I find I've been binging on them and have classes with > 10
properties. While pylint doesn't complain (yet), it tends to be picky about
keeping instance attribute counts low, so I figure there's something
against that. How do you guys decide between using properties versus getter
methods, or how do you refactor them if neither?
Cheers!
-Felipe
-- 
http://mail.python.org/mailman/listinfo/python-list


Backslash Escapes

2011-12-25 Thread Felipe O
Hi all,
Whenever I take any input (raw_input, of course!) or I read from a
file, etc., any backslashes get escaped automatically. Is there any
elegant way of parsing the backslashes as though they were written in
a python string. The best I have so far right now goes like this:

def parse_backslash_escapes(input_string):
parts = input_string.split("'''")  # That's ' " " " ' without the spaces
'"""'.join(eval + p + '"""') for p in parts)

I'm not entirely convinced that it's safe on two accounts.
+ Is that eval statement safe? The input could be coming from an
unfriendly source.
+ Are there any obscure backslash escapes or other tricks I should be aware of?

I guess the alternative is to make a dictionary of all the escapes I
want to support, but that sounds tedious and error-prone.

Thanks,

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


Adding private tags to a tiff file.

2006-08-11 Thread O Evans
Hi there,

I'm manipualating tiff images captured by a program that insists on
using annoying private tags. I want to be able to import an image that
I have created into the program but I cannot get PIL to save the
private tag. Here is a simplified version of the code I am using:

import Image
original = Image.open(r"test.tif")
original.tag[34118] = "life"
print "Before saving" , original.tag[34118]
original.save("test2.tif")
altered = Image.open(r"test2.tif")
if altered.tag.tagdata.has_key(34118):
print "It worked!"

Is there a way of getting this to work? I have tried looking at
TiffTags and TiffImageFile, but I cannot understand why the tags are
not preserved. Or should I be looking at a different library?

Many thanks.

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


Change value of element in list

2006-06-18 Thread O Plameras
Hi,

I'm doing python tutorial,
> http://docs.python.org/tut/node5.html

and I have these,

lists = ['spam', 'eggs', 100, 1234]
lists[2] = lists[2] + 23

I expected this,
lists = ['spam', 'eggs', 123, 1234]

but got this,
lists = ['spam', 'eggs', 100, 1234]

What's my problem here ?

I have Fedora C5 with python2.4.

Thanks.

O Plameras

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


Re: Change value of element in list

2006-06-18 Thread O Plameras
O Plameras wrote:
> Hi,
> 
> I'm doing python tutorial,
>> http://docs.python.org/tut/node5.html
> 
> and I have these,
> 
> lists = ['spam', 'eggs', 100, 1234]
> lists[2] = lists[2] + 23
> 
> I expected this,
> lists = ['spam', 'eggs', 123, 1234]
> 
> but got this,
> lists = ['spam', 'eggs', 100, 1234]
> 
> What's my problem here ?
> 
> I have Fedora C5 with python2.4.
> 
> Thanks.
> 
> O Plameras
> 

I reply to my post to say it is my
mistake. Before printing 'lists' I did
not do this

lists[2] = lists[2] + 23

Sorry for the bother.

O Plameras

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


Re: urllib2 httplib.BadStatusLine exception while opening a page on an Oracle HTTP Server

2009-02-19 Thread O Peng
I'm running into a similar problem with the BadStatusLine.
The source code for httplib.py in the problem is as follows:

class HTTPResponse:
...
def _read_status(self):
line = self.fp.readline()
...
if not line:
# Presumably, the server closed the connection before
# sending a valid response.
raise BadStatusLine(line)

However, I found that right before the 'raise BadStatusLine(line)'
when I ran the following:

restOfResponse = self.fp.read()
print restOfResponse

restOfResponse is NOT empty.  In fact, when I run self.fp.read() at
the beginning of the begin() function, it is not empty at all.
This leads me to believe there is a bug with the self.fp.readline()
(socket._fileobject.readline()) function.  For me it only fails
sometimes.

This behavior is only observed on Windows, Python 2.5.  Running it on
Mac OS X, Python 2.5 yielded no problems.

On Jan 19, 3:48 pm, ak  wrote:
> On Jan 19, 10:00 pm, ak  wrote:
>
>
>
> > Hi everyone,
>
> > I have a problem with urllib2 on this particular url, hosted on an
> > Oracle HTTP Server
>
> >http://www.orange.sk/eshop/sk/portal/catalog.html?type=post&subtype=p...
>
> > which gets 302 redirected 
> > tohttps://www.orange.sk/eshop/sk/catalog/post/phones.html,
> > after setting a cookie through the Set-Cookie header field in the 302
> > reply. This works fin with firefox.
>
> > However, with urllib2 and the following code snippet, it doesn't work
>
> > 
> > import cookiejar
> > import urllib2
>
> > cookiejar = cookielib.LWPCookieJar()
> > opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
> > url = 'http://www.orange.sk/eshop/sk/portal/catalog.html?
> > type=post&subtype=phone&null'
> > req = urllib2.Request(url, None)
> > s=opener.open(req)
> > 
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/usr/lib/python2.5/urllib2.py", line 387, in open
> >     response = meth(req, response)
> >   File "/usr/lib/python2.5/urllib2.py", line 498, in http_response
> >     'http', request, response, code, msg, hdrs)
> >   File "/usr/lib/python2.5/urllib2.py", line 419, in error
> >     result = self._call_chain(*args)
> >   File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
> >     result = func(*args)
> >   File "/usr/lib/python2.5/urllib2.py", line 582, in http_error_302
> >     return self.parent.open(new)
> >   File "/usr/lib/python2.5/urllib2.py", line 381, in open
> >     response = self._open(req, data)
> >   File "/usr/lib/python2.5/urllib2.py", line 399, in _open
> >     '_open', req)
> >   File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
> >     result = func(*args)
> >   File "/usr/lib/python2.5/urllib2.py", line 1115, in https_open
> >     return self.do_open(httplib.HTTPSConnection, req)
> >   File "/usr/lib/python2.5/urllib2.py", line 1080, in do_open
> >     r = h.getresponse()
> >   File "/usr/lib/python2.5/httplib.py", line 928, in getresponse
> >     response.begin()
> >   File "/usr/lib/python2.5/httplib.py", line 385, in begin
> >     version, status, reason = self._read_status()
> >   File "/usr/lib/python2.5/httplib.py", line 349, in _read_status
> >     raise BadStatusLine(line)
> > httplib.BadStatusLine
>
> > Trying the redirected url directly doesn't work either (trying with
> > Firefox will give an HTML error page, as the cookie is not set yet,
> > but trying with urllib2 gives the same exception as previously,
> > whereas it should return the HTML error page)
> > This works correctly on other urls on this website 
> > (http(s)://www.orange.sk).
>
> > Am I doing anything wrong or is this a bug in urllib2 ?
>
> > -- ak
>
> Actually, I was wrong on the last point, this does *not* work 
> onhttps://www.orange.sk(but does onhttp://www.orange.sk). IMHO, this
> means either urllib2 or the server misimplemented HTTPS.
>
> Here's some output with debuglevel=1 :
>
> >>> opener.open(urllib2.Request('http://www.orange.sk/', None, headers))
>
> reply: 'HTTP/1.1 200 OK\r\n'
> header: Date: Mon, 19 Jan 2009 21:44:03 GMT
> header: Server: Oracle-Application-Server-10g/10.1.3.1.0 Oracle-HTTP-
> Server
> header: Set-Cookie:
> JSESSIONID=0a19055a30d630c427bda71d4e26a37ca604b9f590dc.e3eNaNiRah4Pe3aSch8 
> Sc3yOc40;
> path=/web
> header: Expires: Mon, 19 Jan 2009 21:44:13 GMT
> header: Surrogate-Control: max-age="10"
> header: Content-Type: text/html; charset=ISO-8859-2
> header: X-Cache: MISS fromwww.orange.sk
> header: Connection: close
> header: Transfer-Encoding: chunked
>  0x831348c>>
>
> >>> opener.open(urllib2.Request('https://www.orange.sk/', None, headers))
>
> reply: ''
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.5/urllib2.py", line 381, in open
>     response = self._open(req, data)
>   File "/usr/lib/python2.5/urllib2.py", line 399, in _open
>     '_open', req)
>   File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
>     result = func(*args)
>   File "/u

Announcement: Code generation from state diagrams

2016-10-16 Thread peter . o . mueller
>From (UML) state diagrams to Python code made easy.

State machines are without any doubt a very good way to model behavior. The new 
code generator from Sinelabore translates hierarchical state machines 
efficiently into different languages now including Python.

The generator accepts diagrams from many common UML tools. It automatically 
performs robustness tests  and allows interactive simulation of the model. The 
generated code is maintainable and readable. No special runtime libraries are 
required. 

More information and a demo version is available on www.sinelabore.com

Best regards,
Peter Mueller
-- 
https://mail.python.org/mailman/listinfo/python-list


Class methods

2005-10-05 Thread Hughes, Chad O
Title: Class methods






Is there any way to create a class method?  I can create a class variable like this:


class Foo:

  classVariable = None

  def __init__(self, classVariable):

    Foo.classVariable = classVariable 


A = Foo('a')

B = Foo('b')


Print 'The class variable for A is "%s" and the class variable for B is "%s"'%(a.classVariable,b.classVariable)


When you run this, you see the following:


The class variable for A is "b" and the class variable for B is "b"


This is what I expect.  However, I wand to write a function that can be called on a class directly.  Lets say the name of the function is bar.  This function needs to be callable without an instance.  The class will be maintaining a queue, as a class variable, that all instances of that class will use to place data in.  When bar is called - perhaps by Foo.bar() - bar will operate on the all of the data provided by its instances.

Any ideas?  

 



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

Re: Reinstall python 2.3 on OSX 10.3.5?

2005-02-03 Thread Dominique O. Martel
0) compile and install GNU readline 5.0 with the usual ./configure
method
ftp://ftp.cwru.edu/pub/bash/readline-5.0.tar.gz

1) as an administrator, remove the contents of
"/System/Library/Frameworks/Python.framework"

2) install Python from the standard distribution:
 ./configure --enable-framework=/System/Library/Frameworks
make
sudo make frameworkinstall

3) install the extras in /Applications if you want to:
sudo make frameworkinstallextras
Move them to /Developer/Applications/Utilities/MacPython-2.3

4) remove every python* from /usr/local/bin
Those in /usr/bin/ are OK for Python 2.3

5) replace
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages"
with a symbolic link to "/Library/Python/2.3". Name it "site-packages".

I have installed and used Python 2.3.x this way without any problem
whatsoever.

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


RE: Python choice of database

2005-06-20 Thread Hughes, Chad O
One db that is very much worth trying is Firebird.  This is an open
source Interbase 6.0 (Borland product) compatible db.  It is a
SourceForge project.  There are three versions: the super server which
is a client/server db, classic server (the one that I am very familiar
with) which is also a client/server db, and the embedded server which is
a standalone.  In order to access the database you need the open source
module KInterbasdb which is also a SourceForge project.  KInterbasdb is
a Python DB API 2.0 database driver.

Firebird has a lot of documentation.  Moreover it was made based on the
Interbase 6.0, which is was made open source by Borland, so all of
Borland's documentation and tools apply as well.


Firebird can be found at:
http://firebird.sourceforge.net/

KInterbasdb can be found at:
http://kinterbasdb.sourceforge.net/



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Philippe C. Martin
Sent: Monday, June 20, 2005 8:19 AM
To: [email protected]
Subject: Python choice of database


Hi,

I am looking for a stand-alone (not client/server) database solution for
Python.

1) speed is not an issue
2) I wish to store less than 5000 records
3) each record should not be larger than 16K


As I start with Python objects, I thought of using shelve, but looking
at the restrictions (record size + potential collisions) I feel I should
study my options a bit further before I get started.


Regards,

Philippe

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


RE: Database recommendations for Windows app

2005-06-22 Thread Hughes, Chad O
Firebird is cross platform (you would need the classic server version)
look at the following post:

http://mail.python.org/pipermail/python-list/2005-June/286366.html

Chad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Will McGugan
Sent: Wednesday, June 22, 2005 7:14 AM
To: [email protected]
Subject: Database recommendations for Windows app


Hi,

I'd like to write a windows app that accesses a locally stored database.

There are a number of tables, the largest of which has 455,905 records.

Can anyone recommend a database that runs on Windows, is fast / 
efficient and can be shipped without restrictions or extra downloads?

I have googled and found plenty of information on databases, its just 
that I dont have enough experience with databases to know which one is 
best for my task!


Thanks in advance,

Will McGugan
-- 
http://www.willmcgugan.com
"".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
"jvyy*jvyyzpthtna^pbz")
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Can't start new thread

2005-08-11 Thread Hughes, Chad O
Title: Can't start new thread






I am trying to understand what is causing python to raise this error when I create a number of threads:


thread.error: can't start new thread


I have been told that it is due to the default thread size (1 MB), but I have recompiled python defining an alternate threadsize, and I am not seeing any changes.  I defined the THREAD_STACK_SIZE in the thread_pthread.h file.

Any ideas?


Here is the code I am using to test the number of threads I can get running.  It maxis out at 1031.  I have tested it on two systems, one with 1GB of ram and another with 2GB of RAM.

import threading

import time


class Mythread(threading.Thread):

  def __init__(self):

    self.__live = True

    threading.Thread.__init__(self, target=self.runLoop)

  def runLoop(self):

    while self.__live:

  time.sleep(.1)

  def stop(self):

    self.__live = False

    

threads = []

max = raw_input("max: ")

if max == 'None':

  max = None

else:

  max = int(max)


while True:

  print len(threads)

  t = Mythread()

  t.start()

  threads.append(t)

  if len(threads) == max:

    break


print 'all running'


while True:

  answer = raw_input("stop now? ")  

  if answer in ['Y','y']:

    break

  

print "stopping"

for t in threads:

  t.stop()

  

print "joining"

for t in T:

  t.join()


while True:

  answer = raw_input("Quit now? ")  

  if answer in ['Y','y']:

    break

  

print "done"



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

Re: The Nature of the “Unix Philosophy”

2006-06-08 Thread Nils O. Selåsdal
Xah Lee wrote:
> The Nature of the “Unix Philosophy”
> 
> Xah Lee, 2006-05
> 
> In the computing industry, especially among unix community, we often
> hear that there's a “Unix Philosophy”. In this essay, i dissect the
> nature and characterization of such “unix philosophy”, as have been
> described by Brian Kernighan, Rob Pike, Dennis Ritchie, Ken Thompson,
> and Richard P Gabriel et al, and in recent years by Eric Raymond.
> 
> There is no one definite set of priciples that is the so-called “unix
> philosophy”, but rather, it consistest of various slogans developed
> over the decades by unix programers that purport to describe the way
> unix is supposed to have been designed. The characteristics include:
> “keep it simple”, “make it fast”, “keep it small”, “make
> it work on 99% of cases, but generality and correctness are less
> important”, “diversity rules”, “User interface is not
> important, raw power is good”, “everything should be a file”,
> “architecture is less important than immediate workability”. Often,
> these are expressed by chantible slogans that exhibits juvenile humor,
> such as “small is beautiful”, “KISS (Keep It Simple, Stupid)”.

Perhaps you should take a peek at the ideas in Plan 9 from Bell Labs,
which is  a continuation of this philosophy, unlike the "modern" unix
clones.
-- 
http://mail.python.org/mailman/listinfo/python-list

Test tool - Design advise needed

2006-06-14 Thread P-O Bengtsson
Hello
 
I am new at this list, looking forward to be a part of it. 
 
I am trying to write a application with the functionality to record mouse and key events, and then another functionality to replay earlier recorded events.

 
It is meant to be used for testing of other applications/WebPages. I started of with tk to catch mouse and key event. So far no worries. But I decided that I would like to use wxpython instead. But I can not find a way to catch the necessary event while using wxpython.

For the playback function I have been thinking about using ctypes and access windll.user32
 to move the cursor. And it should be possible to send key and mousebutton event from windll as well I guess(?)
 
Is there any approach to catch user events from wxpyton? Am I on the right track here? Is it a good ide to access windll for my replay, or is there any better approach?

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

Thread Stack Size

2005-06-01 Thread Hughes, Chad O
Title: Thread Stack Size






I am using the threading module to create a great deal of threads. Is there any way to set the thread stack size?  It looks like each thread is being given a default stack size of 1MB.  I have looked all over and I cannot find a way to shrink the stack to a few KB.  When I try to create a large number of threads (say 1000 of them) I run into trouble, due to the fact that I have one Gig of memory.


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

RE: EnumKey vs EnumValue

2005-06-06 Thread Hughes, Chad O
EnumKey enumerates subkeys which are equivalent to the folders in
regedit.  EnumValue enumerates values only. The reason your script is
not printing anything must be due to the fact that you are passing in a
registry path that contains only subkeys and no values.  As I mentioned
before, the folders are the subkeys, but the values are the name, type,
data tuple in a given key.  Some loosely call the values keys, but
technically, the keys are the folders and the values are the names.  The
names can be set to a specific data item.  Hence the data column in
regedit.  The type is obviously the data type of the data that is
associated with a given value (name). 

So, to summarize,  keys are the folders that hold values that are set to
data of a specific type.  Keys are equivalent to the path, values are
equivalent to the name in regedit.  That value is assigned a date item
of a specific type.  This can get confusing because people commonly
referred to the values as keys when keys are actually the folders.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Pykid
Sent: Monday, June 06, 2005 1:07 PM
To: [email protected]
Subject: EnumKey vs EnumValue


I'm having trouble getting any responses back from the following
snippet, where I am just trying to read some data from the Windows
Registry.  I intend to do a little bit more with this but will work on
that later, but I think I can get more data back from EnumValue, I'd
like to see the differences between them.  I am running Python 2.3 on XP
and can get a response from EnumKey, but EnumValue returns nothing at
all; the key listing even returns 0 keys when it prints out the status.
But EnumKey returns the right number and even prints out the keys I
expect, I copied some of this from the Cookbook and can't tell what
might be the problem.

  Thanks for any help.

  - M
-

from _winreg import *

findkey = raw_input("What key do you want to look for?  ")

key = "SOFTWARE\\"+findkey
machine = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
regpath = OpenKey(machine,key)

print "Looking for",key

for i in range(25):
try:
regEndeca = EnumKey(regpath,i)
print regEndeca
except EnvironmentError:
print "There are", i,"keys under",key
break
print "That was using EnumKey."

for j in range(25):
try:
regstr,value,type = EnumValue(regpath,j)
print regstr,value,type
except EnvironmentError:
print "There are", j,"keys under",key
break
print "That was using EnumValue."

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


Posting a reply to a post in an existing thread

2005-06-09 Thread Hughes, Chad O
Title: Posting a reply to a post in an existing thread






This may be a dumb question.  I am new to using this list, and I cannot figure out how to send a reply to a message that has been posed in a thread without creating a new thread.  Let me rephrase my question.  The instructions for posting to the list is to send a message to [EMAIL PROTECTED]  There are no instructions for posting a reply.  What I need to know is, what do I put in either the TO field, the CC field, or the SUBJECT field for the list to see my message as a reply to an existing post in a thread and not a new thread.  When I use RE: in front of the reply and put [email protected] in the TO field, my reply ends up as the start of a new thread.  Is this supposed to be the procedure?

Thanks,

Chad



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

smtpd module

2005-06-09 Thread Hughes, Chad O
Title: smtpd module






Does anyone know of any documentation on how to use the smtpd module, either the SMTPServer or the DebuggingServer?  I cannot find any usage cases or examples anywhere.  I can find examples of using the smtplib module but not the smtpd module. 

Thanks,

Chad



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

RE: smtpd module

2005-06-09 Thread Hughes, Chad O
No, I know how to use the smtplib module and I can send email through
that.  However what I want is a the ability to set up a very simple mail
server with python, for some tests that I need to run that just prints
out the message to the standard out and disregards the message.  The
smtpd module seems to provide this ability via the DebuggingServer.
According to the documentation that is provided with python the:

class DebuggingServer( localaddr, remoteaddr) 
  Create a new debugging server. 
  Arguments are as per SMTPServer. 
  Messages will be discarded, and printed on stdout. 

Unfortunately, this does not tell me how to use it.  I cannot find any
examples on the web.  For that matter, I cannot find any other
documentation anywhere.  Has anyone ever used ether the SMTPServer
object or the DebuggingServer object?  If so, I would appreciate very
much an example use case.

Thanks,
Chad

-Original Message-
From: Ivan Shevanski [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 09, 2005 2:03 PM
To: [email protected]
Cc: Hughes, Chad O
Subject: RE: smtpd module


So youre wondering how to send mail in python? I have a lot of examples
if 
you want the smtp module. I don't have anything for anything other than
the 
smtp module.

-Ivan

_
Express yourself instantly with MSN Messenger! Download today - it's
FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

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


RE: how to operate the excel by python?

2005-06-10 Thread Hughes, Chad O
Here are two scripts that I have had to build for a class that I teach. You 
will either need to write the constants explicitly, or I can email neet the 
constans module that I have built, for the second one to work.  I will copy it 
to the very end.  If you have any questions, just let me know. Here is a simple 
one that allows me to interface with my grade book spreadsheet though the 
command line for taking attendance:

from win32com.client import Dispatch
import time
xl = Dispatch('Excel.Application')
wb = xl.Workbooks.Open('C:\\Documents and Settings\\My 
Documents\\discrete\\GradeBook.xls')
ws = wb.Worksheets.Item(1)
ws.Activate()
i = 1
while True:
  if ws.Cells(1,i).Text == '':
break
  i += 1
t = time.localtime()
d = '%s/%s/%s'%(t.tm_mon,t.tm_mday,t.tm_year)
ws.Cells(1,i).FormulaR1C1 = d
ws.Cells(2,i).Select()
j = 2
while True:
  name = ws.Cells(j,1).Text
  if name == '':
break
  name = name.split()[1]
  here = int(raw_input('%s here? '%name))
  ws.Cells(j,i).FormulaR1C1 = here
  j += 1
wb.Save() 

The next one is a kluge (spaghetti code), sorry but it is complete.  It builds 
a truth table for evalutating logic expressions:

from win32com.client import Dispatch
>From officecon.xlcon import *
xl = Dispatch('Excel.Application')
binary = False # set this to true to use 0 and 1 instead of False and True
vars = raw_input("Comma seperate the variables:")
headers = raw_input("What other headers do you want, comma seperated?")
headers = headers.split(',')
vars = vars.split(',')
numToAlpha = 'abcdefghijklmnopqrstuvwxyz'
if not xl.Visible:
  xl.Workbooks.Add()
  xl.Worksheets.Add()
  for i in range(3):
sheet = xl.Worksheets.Item(2)
sheet.Delete()
  xl.ActiveWindow.SelectedSheets.Delete
else:
  xl.Worksheets.Add()

sheet = xl.Worksheets.Item(1)
if len(headers[-1]) > 30:
  sheet.name = headers[-1][:27]+'...'
elif headers[-1] == '':
  sheet.name = 'Example'
else:
  sheet.name = headers[-1]

xl.Visible = True  
  
for i in range(len(vars)):
  sheet.Range(numToAlpha[i]+'1').FormulaR1C1 = vars[i]
sheet.Rows("1:1").Select()
xlBottom = -4107
xlCenter = -4108
xl.Selection.NumberFormat = "General"
xl.Selection.HorizontalAlignment = xlCenter
xl.Selection.VerticalAlignment = xlBottom
xl.Selection.Font.name = "Areial"
xl.Selection.Font.FontStyle = "Bold"
xl.Selection.Font.Size = 12

rows = []
number = 2**len(vars)
for i in range(number):
  row = []
  for j in range(len(vars)):
row.append((i%(2**(len(vars)-j)))/(2**(len(vars)-j-1)))
  rows.append(row)
  
for row in range(len(rows)):
  for column in range(len(rows[row])):
if not rows[row][column]:
  if binary:
value = 0
  else:
value = 'TRUE'
else:
  if binary:
value = 1
  else:
value = 'FALSE'
sheet.Range(numToAlpha[column]+`row+2`).FormulaR1C1 = value

for i in range(len(headers)):
  sheet.Range(numToAlpha[i+len(vars)]+'1').FormulaR1C1 = headers[i]
  sheet.Range(numToAlpha[i+len(vars)]+'1').Select()

sheet.Range("A1:"+numToAlpha[len(vars)+len(headers)-1]+`number+1`).Select()
xl.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
xl.Selection.Borders(xlDiagonalUp).LineStyle = xlNone

xl.Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
xl.Selection.Borders(xlEdgeLeft).Weight = xlThick
xl.Selection.Borders(xlEdgeLeft).ColorIndex = xlAutomatic


xl.Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
xl.Selection.Borders(xlEdgeTop).Weight = xlThick
xl.Selection.Borders(xlEdgeTop).ColorIndex = xlAutomatic


xl.Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous
xl.Selection.Borders(xlEdgeBottom).Weight = xlThick
xl.Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic


xl.Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
xl.Selection.Borders(xlEdgeRight).Weight = xlThick
xl.Selection.Borders(xlEdgeRight).ColorIndex = xlAutomatic


xl.Selection.Borders(xlInsideVertical).LineStyle = xlContinuous
xl.Selection.Borders(xlInsideVertical).Weight = xlThin
xl.Selection.Borders(xlInsideVertical).ColorIndex = xlAutomatic


xl.Selection.Borders(xlInsideHorizontal).LineStyle = xlContinuous
xl.Selection.Borders(xlInsideHorizontal).Weight = xlThin
xl.Selection.Borders(xlInsideHorizontal).ColorIndex = xlAutomatic

xl.Range("A1:"+numToAlpha[len(vars)+len(headers)-1]+'2').Select()
xl.Selection.Borders(xlInsideHorizontal).Weight = xlThick

xl.Range(numToAlpha[len(vars)-1]+'1:'+numToAlpha[len(vars)]+`number+1`).Select()
xl.Selection.Borders(xlInsideVertical).LineStyle = xlDouble


xl.Range(numToAlpha[len(vars)+len(headers)-1]+'1:'+numToAlpha[len(vars)+len(headers)-1]+`number+1`).Select()
xl.Selection.Borders(xlEdgeLeft).LineStyle = xlDashDotDot
xl.Selection.Interior.ColorIndex = 20
xl.Selection.Interior.Pattern = xlSolid
#xl.Selection.Borders(xlEdgeLeft).Weight = xlThick
#xl.Selection.Borders(xlEdgeTop).Weight = xlThick
#xl.Selection.Borders(xlEdgeBottom).Weight = xlThick
xl.Selection.Borders(xlEdgeRight).Weight = xlThick
#xl.Selection.Borders(xlInsideVertical).Weight = xlThin
#xl.Selec

RE: how to operate the excel by python?

2005-06-10 Thread Hughes, Chad O
Sorry, I meant to spell check but I did not somehow.

Chad

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hughes, Chad O
Sent: Friday, June 10, 2005 10:01 AM
To: [email protected]
Subject: RE: how to operate the excel by python?


Here are two scripts that I have had to build for a class that I teach. You 
will either need to write the constants explicitly, or I can email neet the 
constans module that I have built, for the second one to work.  I will copy it 
to the very end.  If you have any questions, just let me know. Here is a simple 
one that allows me to interface with my grade book spreadsheet though the 
command line for taking attendance:

from win32com.client import Dispatch
import time
xl = Dispatch('Excel.Application')
wb = xl.Workbooks.Open('C:\\Documents and Settings\\My 
Documents\\discrete\\GradeBook.xls')
ws = wb.Worksheets.Item(1)
ws.Activate()
i = 1
while True:
  if ws.Cells(1,i).Text == '':
break
  i += 1
t = time.localtime()
d = '%s/%s/%s'%(t.tm_mon,t.tm_mday,t.tm_year)
ws.Cells(1,i).FormulaR1C1 = d
ws.Cells(2,i).Select()
j = 2
while True:
  name = ws.Cells(j,1).Text
  if name == '':
break
  name = name.split()[1]
  here = int(raw_input('%s here? '%name))
  ws.Cells(j,i).FormulaR1C1 = here
  j += 1
wb.Save() 

The next one is a kluge (spaghetti code), sorry but it is complete.  It builds 
a truth table for evalutating logic expressions:

from win32com.client import Dispatch
>From officecon.xlcon import *
xl = Dispatch('Excel.Application')
binary = False # set this to true to use 0 and 1 instead of False and True vars 
= raw_input("Comma seperate the variables:") headers = raw_input("What other 
headers do you want, comma seperated?") headers = headers.split(',') vars = 
vars.split(',') numToAlpha = 'abcdefghijklmnopqrstuvwxyz' if not xl.Visible:
  xl.Workbooks.Add()
  xl.Worksheets.Add()
  for i in range(3):
sheet = xl.Worksheets.Item(2)
sheet.Delete()
  xl.ActiveWindow.SelectedSheets.Delete
else:
  xl.Worksheets.Add()

sheet = xl.Worksheets.Item(1)
if len(headers[-1]) > 30:
  sheet.name = headers[-1][:27]+'...'
elif headers[-1] == '':
  sheet.name = 'Example'
else:
  sheet.name = headers[-1]

xl.Visible = True  
  
for i in range(len(vars)):
  sheet.Range(numToAlpha[i]+'1').FormulaR1C1 = vars[i]
sheet.Rows("1:1").Select()
xlBottom = -4107
xlCenter = -4108
xl.Selection.NumberFormat = "General" xl.Selection.HorizontalAlignment = 
xlCenter xl.Selection.VerticalAlignment = xlBottom xl.Selection.Font.name = 
"Areial" xl.Selection.Font.FontStyle = "Bold" xl.Selection.Font.Size = 12

rows = []
number = 2**len(vars)
for i in range(number):
  row = []
  for j in range(len(vars)):
row.append((i%(2**(len(vars)-j)))/(2**(len(vars)-j-1)))
  rows.append(row)
  
for row in range(len(rows)):
  for column in range(len(rows[row])):
if not rows[row][column]:
  if binary:
value = 0
  else:
value = 'TRUE'
else:
  if binary:
value = 1
  else:
value = 'FALSE'
sheet.Range(numToAlpha[column]+`row+2`).FormulaR1C1 = value

for i in range(len(headers)):
  sheet.Range(numToAlpha[i+len(vars)]+'1').FormulaR1C1 = headers[i]
  sheet.Range(numToAlpha[i+len(vars)]+'1').Select()

sheet.Range("A1:"+numToAlpha[len(vars)+len(headers)-1]+`number+1`).Select()
xl.Selection.Borders(xlDiagonalDown).LineStyle = xlNone 
xl.Selection.Borders(xlDiagonalUp).LineStyle = xlNone

xl.Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous 
xl.Selection.Borders(xlEdgeLeft).Weight = xlThick 
xl.Selection.Borders(xlEdgeLeft).ColorIndex = xlAutomatic


xl.Selection.Borders(xlEdgeTop).LineStyle = xlContinuous 
xl.Selection.Borders(xlEdgeTop).Weight = xlThick 
xl.Selection.Borders(xlEdgeTop).ColorIndex = xlAutomatic


xl.Selection.Borders(xlEdgeBottom).LineStyle = xlContinuous 
xl.Selection.Borders(xlEdgeBottom).Weight = xlThick 
xl.Selection.Borders(xlEdgeBottom).ColorIndex = xlAutomatic


xl.Selection.Borders(xlEdgeRight).LineStyle = xlContinuous 
xl.Selection.Borders(xlEdgeRight).Weight = xlThick 
xl.Selection.Borders(xlEdgeRight).ColorIndex = xlAutomatic


xl.Selection.Borders(xlInsideVertical).LineStyle = xlContinuous 
xl.Selection.Borders(xlInsideVertical).Weight = xlThin 
xl.Selection.Borders(xlInsideVertical).ColorIndex = xlAutomatic


xl.Selection.Borders(xlInsideHorizontal).LineStyle = xlContinuous 
xl.Selection.Borders(xlInsideHorizontal).Weight = xlThin 
xl.Selection.Borders(xlInsideHorizontal).ColorIndex = xlAutomatic

xl.Range("A1:"+numToAlpha[len(vars)+len(headers)-1]+'2').Select()
xl.Selection.Borders(xlInsideHorizontal).Weight = xlThick

xl.Range(numToAlpha[len(vars)-1]+'1:'+numToAlpha[len(vars)]+`n

RE: SMTP Test Rig

2005-06-10 Thread Hughes, Chad O
Thanks very much it works great and does exactly what I need for a test
I have to perform.  I started teaching myself the SMTP protocol last
night and it does not look to hard.  But this saves me a great deal of
time an effort.  I hope you can find a good place to host it, as it is
the only example I have seen yet.
Chad

-Original Message-
From: Tim Williams [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 10, 2005 5:35 AM
To: Hughes, Chad O; Jesse Noller
Subject: SMTP Test Rig


Chad, Jesse.   The SMTP test rig receives SMTP emails and can be
configured
to write them to the screen,  save them to a file - or both.

Have fun


#
"""
SMTPRIG.py  (SMTP Test Rig)

Version 1.0

Copyright (C) Tim Williams ([EMAIL PROTECTED]) 10th June 2005
#
# This software is provided "AS IS" without any warranty
# explicit or implied.
#
# Redistribution of this code is allowed provided the
# above copyright information remains intact.
#
# This code was developed out of the need for a very basic
# test SMTP server, and later expanded to add logging to
# screen and/or the ability to save the email to a text file.
#
# This server has the bare minimum SMTP functionality required # to
impliment the above requirements. It has no error checking # or rfc822
compliance checks, it will receive anything from anyone # no matter how
bad their SMTP dialogue is. # # This server has only been tested in a
windows environment # # This server can receive multiple concurrent
emails (multithreaded inbound) # # This server CAN NOT RELAY email to
another server (unless you add that bit
yourself)
#
# Please feel free to send comments or questions to [EMAIL PROTECTED] # """

from socket import *
from SocketServer import *
from Queue import Queue
from random import randrange
from os import path, makedirs
import thread

server_port = 2525  # the port the server will run on
file_path = 'txtmails'  # path for saved files

write_to_screen = 1 # 1 to enable, 0 to disable
write_to_file = 1   # 1 to enable, 0 to disable

try:
makedirs(file_path)
except OSError, x:
#[Errno 17] File exists:
pass

q_print = Queue() #queue for printing to console.

class SMTPServer(ThreadingMixIn, TCPServer):

# other functions exist here in a live server

def some_function(self):
pass

#end of class SMTPServer

class SMTPRequestHandler(StreamRequestHandler):
global write_to_file, file_path

def handle(self):
qprint ('*-'*30)
self.ip, self.port = self.client_address
self.port = str(self.port)
self.ip = str(self.ip)
qprint ( "<=> Incoming connection from ", self.ip, ' Port:',
self.port)
self.terminated = 0
self.receiving_data = 0
self.SendResponse('220 ** Welcome **')
self.msg = []
self.msg_count = 1
empty_line = 0
self.msg_id()

commands={ 'HELO' : self.__OK,# supported commands
   'QUIT' : self.__QUIT,
   'MAIL' : self.__OK,
   'RCPT' : self.__OK,
   'NOOP' : self.__OK,
   'RSET' : self.__OK,
   'HELP' : self.__OK,
   'DATA' : self.__DATA,
   }

while not self.terminated:
try:
self.inputline = self.rfile.readline()
self.inputline = self.inputline.rstrip()
qprint (self.port + '<== ' + self.inputline )
except:
self.inputline = ' '

request = self.inputline.upper().split()
if self.receiving_data:
self.receive_body()
elif request and commands.has_key(request[0]):  # eg: if
has_key HELO
commands[request[0]](request)
else:
self.SendResponse("500 Unknown Command "+
self.inputline)
if self.inputline == '':# empty
commandline
empty_line += 1
if empty_line > 9:  # max empty
lines
self.SendResponse('550 Too many empty lines')
break   # end of
smtp
conversation

def receive_body(self):
if self.inputline == '.':
self.receiving_data = 0
self.msg_count += 1
self.msg_id()
if write_to_file:
self.write_file()
self.SendResponse('250 2.1.0 OK: Data received')
else:
self.msg.append(self.inputline)

def __OK(self,request):
self.SendResponse('250 2.1.0 OK')

def __DATA(self,request):
self.receiving_data = 1
self.SendResponse('35

RE: [python-win32] NTService detecting if the Windows System is Idle

2005-06-13 Thread Hughes, Chad O


-Original Message-
From: Hughes, Chad O 
Sent: Monday, June 13, 2005 9:09 AM
To: 'Fred Dixon'
Subject: RE: [python-win32] NTService detecting if the Windows System is
Idle


There may be important processes running in the background (headless
process with no user interaction) that need resources while the user may
or may not be "using" the computer, possible when the user is logged
out.  

I would use the system resource usage itself to define the idleness of
your system.  There are a great number of things that can be measured
and you can even have general system measurements as well as process
specific measurements.  For example: lets say that you have your
thresholds set to some logical value, and you have some process (call it
processA) that is important.  You can dynamically redefine your
thresholds for when processA is running and then dynamically readjust
them when it is not.  Moreover, you can make your thresholds be a
function of your general system usage combined with process specific
usage.  For example, you can dynamically adjust your thresholds based on
linear functions of the usage of a list of processes and your system.
This is a very flexible approach.  My example is just a starting point.
Do you fallow this? 

-Original Message-
From: Fred Dixon [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 12, 2005 12:30 PM
To: Hughes, Chad O
Subject: Re: [python-win32] NTService detecting if the Windows System is
Idle


why not just run it when the screen saver is active

On 6/10/05, Hughes, Chad O <[EMAIL PROTECTED]> wrote:
> I think this example is what you want to do. It is not a service, but
> you can turn it into one.
> 
> import win32pdh
> from time import sleep
> import threading
> 
> pdhQuery = win32pdh.OpenQuery(None, 0)
> 
> class PDH_COUNTER_PATH_ELEMENTS(list):
>   def __init__(self, l = None):
> if not l:
>   l = ['127.0.0.1',None,None,None,-1,None]
> list.__init__(self,l)
> self.__machineName = self[0]
> self.__objectName = self[1]
> self.__instanceName = self[2]
> self.__parantInstance = self[3]
> self.__instanceIndex = self[4]
> self.__counterName = self[5]
>   def __setMachineName(self,value):
> self.__machineName = value
> self[0] = value
>   def __setObjectName(self,value):
> self.__objectName = value
> self[1] = value
>   def __setInstanceName(self,value):
> self.__instanceName = value
> self[2] = value
>   def __setParentInstance(self,value):
> self.__parentInstance = value
> self[3] = value
>   def __setInstanceIndex(self,value):
> self.__instanceIndex = value
> self[4] = value
>   def __setCounterName(self,value):
> self.__counterName = value
> self[5] = value
>   def __getMachineName(self):
> return self.__machineName
>   def __getObjectName(self):
> return self.__objectName
>   def __getInstanceName(self):
> return self.__instanceName
>   def __getParentInstance(self):
> return self.__parentInstance
>   def __getInstanceIndex(self):
> return self.__instanceIndex
>   def __getCounterName(self):
> return self.__counterName
>   machineName = property(__getMachineName, __setMachineName)
>   objectName = property(__getObjectName, __setObjectName)
>   instanceName = property(__getInstanceName, __setInstanceName)
>   instanceIndex = property(__getInstanceIndex, __setInstanceIndex)
>   parentInstanceIndex = property(__getParentInstance,
> __setParentInstance)
>   counterName = property(__getCounterName, __setCounterName)
>   def makeCopy(self):
> return PDH_COUNTER_PATH_ELEMENTS(self)
>   def __repr__(self):
> return 'machineName = %s\nobjectName = %s\nInstanceName =
> %s\nparentInstance = %s\ninstanceIndex = %s\ncounterName =
> %s'%tuple(self)
> 
> class WorkerThread(threading.Thread):
>   def __init__(self):
> threading.Thread.__init__(self, target = self.__runLoop)
> self.__pauseEvent = threading.Event()
> #when wait is called after clear the thread will pause until set
> self.__pauseEvent.clear()
> self.__stayAlive = True
>   def stop(self):
> self.__stayAlive = False
> #loop until runLoop is exited
> while self.isAlive():
>   self.__pauseEvent.set()
>   def pause(self):
> self.__pauseEvent.clear()
>   def resume(self):
> self.__pauseEvent.set()
>   def __runLoop(self):
> while self.__stayAlive:
>   self.__pauseEvent.wait()
>   #do what ever you want to do while the CPU is idle
>   #example print that cpu is idle
>   print 'The CPU is idle'
> 
> 
> #make paths
> cpe = PDH_COUNTER_PATH_ELEMENTS((
>   '127.0.0.1',
>   "Processor",
>  

RE: Opening a drive folder from Python

2005-06-14 Thread Hughes, Chad O
I think you are talking about the following:

from win32com.client import Dispatch
path = raw_input('Type in a path: ')
s=Dispatch('WScript.Shell')
s.Run('Explorer %s'%path)


Chad
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
John Henry
Sent: Tuesday, June 14, 2005 4:02 PM
To: [email protected]
Subject: Opening a drive folder from Python


Can somebody please tell me how to pop open a drive folder from a Python
script? 

Thanks.

--
John

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


RE: Finding Word and switch focus to it

2005-06-15 Thread Hughes, Chad O
The first part is easy. I will have to think about the second part. To
find an opened copy of Word and switch focus to it do the following:

from win32com.client import Dispatch
word = Dispatch('Word.Application')
wdWindowStateNormal = 0
if len(word.Documents):
  word.Activate()
  if word.WindowState != wdWindowStateNormal:
word.WindowState = wdWindowStateNormal  
 
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
John Henry
Sent: Wednesday, June 15, 2005 3:21 PM
To: [email protected]
Subject: Finding Word and switch focus to it


Does anybody know how to find an opened copy of Word and switch focus to
it, wait until Word is closed, before continuing my Python script? I
tried to search for the answer from Google and nothing stands out.

Running under Windows XP.

Thanks,

--
John

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


RE: Finding Word and switch focus to it

2005-06-15 Thread Hughes, Chad O
Consider reading this post. It highlights how to do what you want:
http://mail.python.org/pipermail/python-win32/2002-April/000322.html

Chad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
John Henry
Sent: Wednesday, June 15, 2005 3:21 PM
To: [email protected]
Subject: Finding Word and switch focus to it


Does anybody know how to find an opened copy of Word and switch focus to
it, wait until Word is closed, before continuing my Python script? I
tried to search for the answer from Google and nothing stands out.

Running under Windows XP.

Thanks,

--
John

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


RE: Overcoming herpetophobia (or what's up w/ Python scopes)?

2005-06-17 Thread Hughes, Chad O
I am very familiar with Python, but I don't know Pearl. In order to
answer your question, you will have to tell me about your statement, "I
couldn't live without closures and without the fine control over scopes
that Pearl provides."  I don't know what these things are to Pearl.  If
you tell me what these features are in Pearl and what you use them for,
I can tell you if Python has them as well.

Chad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
kj
Sent: Friday, June 17, 2005 9:20 AM
To: [email protected]
Subject: Overcoming herpetophobia (or what's up w/ Python scopes)?





I'm a Perlhead (there, I said it).  Years ago I made a genuine attempt
to learn Python, but my intense disappointed with the way Python deals
with scopes ultimately sapped my enthusiasm.  I couldn't live without
closures and without the fine control over scopes that Perl provides.

I've been wanting to make another attempt to (re)learn Python for a
while, but this scopes business remained a major damper.  What's pushing
me over my reluctance is having to work with a large in-house package
developed in Python.

I am hoping that it may be better this time around.  For one thing, like
Perl, Python was then (and maybe still is) a "work in progress." So I
figure that Python scoping may have improved since then.  Even if not, I
think that Python is mature enough by now that adequate alternatives
must have been devised for the Perlish features that I missed during my
first attempt.

My question is: is there any tutorial on Python scoping aimed at diehard
Perlheads?

Thanks!

kj

-- 
NOTE: In my address everything before the first period is backwards; and
the last period, and everything after it, should be discarded.
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Overcoming herpetophobia (or what's up w/ Python scopes)?

2005-06-17 Thread Hughes, Chad O
Are you sure about the lower-case thing.  The original post states
"Perlhead" and there are many instances at www.Perl.com where O'REILLY
spells perl as Perl.

Chad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Steven D'Aprano
Sent: Friday, June 17, 2005 10:02 AM
To: [email protected]
Subject: RE: Overcoming herpetophobia (or what's up w/ Python scopes)?


On Fri, 17 Jun 2005 09:36:55 -0700, Hughes, Chad O wrote:

> I am very familiar with Python, but I don't know Pearl.

The language is *always* spelt without the "a", and usually all in
lower-case: perl.

Now that I've taught you everything I know about perl, you can be an
expert like me 

-- 
Steven

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


RE: Overcoming herpetophobia (or what's up w/ Python scopes)?

2005-06-17 Thread Hughes, Chad O
Thanks, I will keep that in mind.
Chad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Steven D'Aprano
Sent: Friday, June 17, 2005 11:06 AM
To: [email protected]
Subject: RE: Overcoming herpetophobia (or what's up w/ Python scopes)?


On Fri, 17 Jun 2005 10:22:05 -0700, Hughes, Chad O wrote:

> Are you sure about the lower-case thing.  The original post states 
> "Perlhead" and there are many instances at www.Perl.com where O'REILLY

> spells perl as Perl.

I did say "usually" :-)

But in fact it seems that the creator of Perl/perl, Larry Wall, now
distinguishes between the two spellings. From the FAQs:

Q: What's the difference between "perl" and "Perl"?
A: One bit. Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to
signify the language proper and "perl" the implementation of it, i.e.
the current interpreter. Hence Tom's quip that "Nothing but perl can
parse Perl." You may or may not choose to follow this usage. For
example, parallelism means "awk and perl" and "Python and Perl" look OK,
while "awk and Perl" and "Python and perl" do not. But never write
"PERL", because perl is not an acronym, apocryphal folklore and
post-facto expansions notwithstanding. 

http://faq.perl.org/perlfaq1.html




-- 
Steven

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


RE: how to operate the excel by python?

2005-06-17 Thread Hughes, Chad O
Title: Message



I have posed a more complete 
answer to your question, however, it is quite a large and It is awaiting 
approval.  For now, xlRight = -4152.  You can find this out by opening 
up Excel and typing the ALT-F11 combination.  From there use the 
ObjectBrowser.  For example if you type in the word "xlRight"  you 
will see that it is equal to -4152.

   
  Chad
  

-Original Message-From: Kevin P. 
Coffey [mailto:[EMAIL PROTECTED] Sent: Friday, June 17, 
2005 11:28 AMTo: [email protected]: how to 
operate the excel by python?
Question 
please:
 
In the post, 
"How to operate the excel by python," where did you find the codes for 
HorizontalAlignment and VerticalAlignment (Center = -4108 and Bottom = 
-4107)?  I need the code for HorizontalAlignment = xlRight.  Is 
there a table somewhere that shows these codes?
 
Thanks
 
kevin.coffey at 
ism-corp.us
-- 
http://mail.python.org/mailman/listinfo/python-list

Using swig to use an existing dll/library

2005-06-18 Thread peter . o . mueller
Hi together,

i have a Windows DLL in C that is internally multithreaded and provides
a callback function to signal specific events. As I understood one can
use "normal" C-code with swig. Is it also possible to use existing
DLLs? Does swig can also handel the callback method? If not - is there
another wrapper toolkit that can do that?

Thanks,
Peter

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


Re: List Comprehension Question: One to Many Mapping?

2007-08-24 Thread Eduardo O. Padoan
> For example, if I have x=[ [1,2], [3,4] ]
>
> What I want is a new list of list that has four sub-lists:
>
> [[1,2], [f(1), f(2)], [3,4], [f(3), f(4)]]

[[a, [f(b) for b in a]] for a in x]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will Python 3.0 remove the global interpreter lock (GIL)

2007-09-02 Thread Eduardo O. Padoan
On 9/2/07, llothar <[EMAIL PROTECTED]> wrote:
> I'm afraid that the GIL is killing the usefullness of python for some
> types of applications now where 4,8 oder 64 threads on a chip are here
> or comming soon.
>
> What is the status about that for the future of python?
>
> I know that at the moment allmost nobody in the scripting world has
> solved this problem, but it bites and it bites hard. Only groovy as a
> Java Plugin has support but i never tried it. Writing an interpreter
> that does MT this seems to be extremely difficult to do it right, with
> lots of advanced stuff like CAS and lock free programming.
>
> Even Smalltalk and Common Lisp didn't get it until know (with the
> exception of certain experiments).


No. http://www.artima.com/weblogs/viewpost.jsp?thread=211430

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will Python 3.0 remove the global interpreter lock (GIL)

2007-09-02 Thread Eduardo O. Padoan
> No. http://www.artima.com/weblogs/viewpost.jsp?thread=211430

Ops, I meant:
http://www.artima.com/forums/threaded.jsp?forum=106&thread=211200


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie: self.member syntax seems /really/ annoying

2007-09-13 Thread Eduardo O. Padoan
On 9/13/07, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote:
> because I'm trained to interpret the underscore as a synonym for one
> space. It's not particularly beautiful, but that is probably a matter of
> habituation. And that exact word is probably the reason why I'd still
> use self or s (explained by a comment, because I can get very dumb if I
> have to).

Have you worked with code using gettext functions imported as "_"?
When I see a single underscore as a name, i18n comes to mind.


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid overflow errors

2007-09-14 Thread Eduardo O. Padoan
On 9/14/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> I thought that overflow errors would be a thing of the past now that
> Python automatically converts ints to longs as needed. Unfortunately,
> that is not the case.
>
> >>> class MyInt(int):
> ... pass
> ...
> >>> MyInt(sys.maxint)
> 2147483647
> >>> MyInt(sys.maxint+1)
> Traceback (most recent call last):
>   File "", line 1, in 
> OverflowError: long int too large to convert to int


Not totally unrelated, but in Py3k, as it seems, overflows are really
things of the past:


Python 3.0a1 (py3k:58061, Sep  9 2007, 13:18:37)
[GCC 4.1.3 20070831 (prerelease) (Ubuntu 4.1.2-16ubuntu1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class MyInt(int):
... pass
...
>>> import sys
>>> MyInt(sys.maxint)
2147483647
>>> MyInt(sys.maxint+1)
2147483648


Thanks to your mail, only now I see how important this change
(int/liong unification) really is!


> How do I subclass int and/or long so that my class also auto-converts
> only when needed?

What about just subclassing long - is this not an option?


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


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid overflow errors

2007-09-14 Thread Eduardo O. Padoan
On 14 Sep 2007 18:08:00 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> "Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
> > Not totally unrelated, but in Py3k, as it seems, overflows are really
> > things of the past:
> >
> >
> > Python 3.0a1 (py3k:58061, Sep  9 2007, 13:18:37)
> > [GCC 4.1.3 20070831 (prerelease) (Ubuntu 4.1.2-16ubuntu1)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> class MyInt(int):
> > ... pass
> > ...
> > >>> import sys
> > >>> MyInt(sys.maxint)
> > 2147483647
> > >>> MyInt(sys.maxint+1)
> > 2147483648
>
> I'd be interested in knowing what happens in 3.0a1 with
>
>   a = itertools.count(sys.maxint)
>   print a.next()
>   print a.next()


>>> print(next(a))
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: cannot count beyond PY_SSIZE_T_MAX

Hum, you've got me there. it is the same as in 2.x. Maybe the message
should be less crypt, at least - nothing that googling for
PY_SSIZE_T_MAX cant help.

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid overflow errors

2007-09-15 Thread Eduardo O. Padoan
On 9/15/07, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Fri, 14 Sep 2007 22:59:13 -0300, Eduardo O. Padoan wrote:
>
> > On 14 Sep 2007 18:08:00 -0700, Paul Rubin
> > <"http://phr.cx"@nospam.invalid> wrote:
> >> "Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
> >> > Not totally unrelated, but in Py3k, as it seems, overflows are really
> >> > things of the past:
> >> >
> >> >
> >> > Python 3.0a1 (py3k:58061, Sep  9 2007, 13:18:37) [GCC 4.1.3 20070831
> >> > (prerelease) (Ubuntu 4.1.2-16ubuntu1)] on linux2 Type "help",
> >> > "copyright", "credits" or "license" for more information.
> >> > >>> class MyInt(int):
> >> > ... pass
> >> > ...
> >> > >>> import sys
> >> > >>> MyInt(sys.maxint)
> >> > 2147483647
> >> > >>> MyInt(sys.maxint+1)
> >> > 2147483648
> >>
> >> I'd be interested in knowing what happens in 3.0a1 with
> >>
> >>   a = itertools.count(sys.maxint)
> >>   print a.next()
> >>   print a.next()
> >
> >
> >>>> print(next(a))
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > OverflowError: cannot count beyond PY_SSIZE_T_MAX
> >
> > Hum, you've got me there. it is the same as in 2.x. Maybe the message
> > should be less crypt, at least - nothing that googling for
> > PY_SSIZE_T_MAX cant help.
>
> This should demonstrate that OverflowError will not disappear entirely
> even in Python 3.

No one is denying that by now :)

> Even if we were to get rid of all OverflowErrors resulting from integer
> operations in Python, there are going to be some C extensions--including
> some in the Python standard library--that will store 32-bit integers.
> Modules such as array and struct will still raise it, and probably other
> modules were a long integer sometimes doesn't make sense (socket, for
> instance).  itertools.count() should work for arbitrary integers, though.

Agreed. I was lookind at itertoolsmodule.c, and even for my very
limited C knowlegment, it does not seem to be too hard.
Anyway: http://bugs.python.org/issue1165


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


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to join array of integers?

2007-09-15 Thread Eduardo O. Padoan
> > It's nice people have invented so many ways to spell the
> > builting "map" ;)
> >
>  ",".join(map(str,[1,2,3]))
> > '1,2,3'
>
> IIRC, map's status as a builtin is going away.

Actually, py3k built-in map == itertools.imap

>>> map(str, [])


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python statements not forcing whitespace is messy?

2007-09-15 Thread Eduardo O. Padoan
On 9/15/07, J. Cliff Dyer <[EMAIL PROTECTED]> wrote:
> And I'd hate to have to remember all of the rules for what can go
> together and what can't, especially when it comes time to debug.  No.
> I don't think it should be forced, but maybe put it in PEP8 or PEP3008.

It is: see "Whitespace in Expressions and Statements" in PEP 8.


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 migration plans?

2007-09-27 Thread Eduardo O. Padoan
On 9/27/07, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> It seems that Python 3 is more significant for what it removes than
> what it adds.
>
> What are the additions that people find the most compelling?

 - dict.items(), .values() and .keys() returns "dict views", and the
.iter*() removal
   http://www.python.org/dev/peps/pep-3106/
 - the new super()
   http://www.python.org/dev/peps/pep-3135/

etc...

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unit testing

2007-10-05 Thread Eduardo O. Padoan
> What's the equivalent of unittest's "assertRaises"?
> In certain situations it is also useful to test wether an exception
> (along its type) is raised or not.
> Does py.test support such thing?

import py.test

py.test.raises(NameError, "blablabla")

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Duck Typing and **kwds

2007-10-11 Thread Eduardo O. Padoan
On 10/11/07, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote:
>
> Hi there.
>
> I just tried this test:
>
> 
> def f(**kwds):
> print kwds
>
> import UserDict
> d = UserDict.UserDict(hello="world")
> f(**d)
> 
>
> And it fails with a TypeError exception ("f() argument after ** must be a
> dictionary"). I find that weird, as UserDict should support all protocols that
> dict supports, yet it doesn't seem to support ** unpacking. If instead of
> UserDict I use a derivate class from dict (class mydict(dict):pass), the **
> operator works as expected. It also works if I execute f(**dict(d)) instead.
>
> Is that behavior expected? Is there any reason (performance, perhaps?) to 
> break
> duck-typing in this situation?

Reported, accepted and closed 5 months ago:
http://bugs.python.org/issue1686487

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Script to Download Ubuntu Gutsy ASAP

2007-10-18 Thread Eduardo O. Padoan
On 10/18/07, danfolkes <[EMAIL PROTECTED]> wrote:
> I thought I would post the source to a program that I made that will
> download the http://ubuntu.media.mit.edu/ubuntu-releases/gutsy/
> as soon as its posted.
>
> It checks the site every 10 min time.sleep(600)
>
> This is mostly untested so I would appreciate comments, and if you use
> it, post that too! :)
> 
>
> import time
> import urllib
>
> mysock = urllib.urlopen("http://ubuntu.media.mit.edu/ubuntu-releases/
> gutsy/ubunt
> u-7.10-desktop-i386.iso")
> #print mysock
> while 1:
> image = mysock.read()
> if image[0:1]!='<':
> oFile = open(r"image.iso",'wb')
> oFile.write(image)
> oFile.close
> break
> exit
> print "Wait ", time.localtime()
> time.sleep(600)
>
>
> 
>
> enjoy,

Please, don't do it. Use the torrent, Luke.
Also, use the HTTP error code - while the file is not at the server,
you will receive a 404, I think.

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Python 3000 Question

2007-10-30 Thread Eduardo O. Padoan
On 10/29/07, brad <[EMAIL PROTECTED]> wrote:
> Will len(a_string) become a_string.len()? I was just reading
>
> http://docs.python.org/dev/3.0/whatsnew/3.0.html
>
> One of the criticisms of Python compared to other OO languages is that
> it isn't OO enough or as OO as others or that it is inconsistent. And
> little things such as this seem to support those arguments. Not that it
> matters really... just seems that classes with methods used in a more
> consistent manner would be more appropriate in an OO langauage. Is there
> a reason that len cannot be a method?
>
> a_string.lower() makes sense, as does a_string.split(),
> a_string.strip()... why not a_string.len()?

This is a FAQ:
http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oh no, my code is being published ... help!

2007-11-30 Thread Eduardo O. Padoan
On Nov 30, 2007 11:36 AM, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> "Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
>
> > No, writing this way will confound the 2to3 tool.
>
> Why?  print("foo") is a perfectly valid Python 2 statement.  Maybe
> it's simply a matter of fixing the tool.
>

print("foo") -> print(("foo"))

If you have any idea of how the tool could understand what you meant,
please report it at bugs.python.org :)

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oh no, my code is being published ... help!

2007-11-30 Thread Eduardo O. Padoan
On Nov 30, 2007 11:18 AM, Peter Decker <[EMAIL PROTECTED]> wrote:
> On Nov 30, 2007 1:19 AM, Tim Roberts <[EMAIL PROTECTED]> wrote:
>
> > You also have a couple of instances of:
> > print("Error Squeezing %s...")
> >
> > The parentheses serve no purpose here, and are unidiomatic.
>
> I thought that with the eventual dropping of 'print' as a statement in
> Python 3, that writing it this way (as if it were a print function) is
> preferred, since that will be one fewer thing to convert.
>

No, writing this way will confound the 2to3 tool. Just try for
yourself. You would have to write print(something) all the time and
disable the fix_print convertion. It is easier and safer to write the
common 2.Xish way and let 2to3 do the work.

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in __init__?

2008-01-18 Thread Eduardo O. Padoan
On Jan 18, 2008 3:09 PM, Zbigniew Braniecki
<[EMAIL PROTECTED]> wrote:
> I found a bug in my code today, and spent an hour trying to locate it
> and then minimize the testcase.
>
> Once I did it, I'm still confused about the behavior and I could not
> find any reference to this behavior in docs.
>
> testcase:
>
> class A():
>
>def add (self, el):
>  self.lst.extend(el)
>
>def __init__ (self, val=[]):
>  print val
>  self.lst = val
>
>
> def test ():
>x = A()
>x.add(["foo1","foo2"])
>b = A()
>
>
> So, what I would expect here is that I will create two instances of
> class A with empty self.lst property. Right?
>
> In fact (at least with my Python 2.5)
>
> [EMAIL PROTECTED]:~/projects/pyl10n$ ./scripts/test.py
> []
> ['foo1', 'foo2']
>
> This bug does not happen when I switch to __init__ (self, *args) and
> assign self.lst= args[0].
>
> Any clue on what's going on here, and/if where I should report it?

It is a FAQ, not a bug:
http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects
http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Removing objects

2008-01-23 Thread Eduardo O. Padoan
On Jan 23, 2008 9:55 AM, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> For that to work, you need to give your class an __eq__ method, and have
> it match by name:
>
> # put this in MyClass
> def __eq__(self, other):
> return self.name == self.other

Do you mean:

# put this in MyClass
def __eq__(self, other):
return self.name == other.name

?

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PLEASE ACCEPT MY SINCERE APOLOGIES

2008-02-01 Thread Eduardo O. Padoan
On Feb 1, 2008 5:19 AM, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> On Feb 1, 5:08 am, Paddy <[EMAIL PROTECTED]> wrote:
> > On Feb 1, 1:26 am, "Blubaugh, David A." <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > To Everyone on the planet Earth,
> >
> > > Please accept my apologies for
> >
> > > Why the Hell has nobody answered my question.
> >
> > > I am just trying to finish a Masters thesis that is quite beyond
> > > anything in this world.
> >
> > > David Blubaugh
> >
> > > -Original Message-
> > > From: [EMAIL PROTECTED]
> >
> > > [mailto:[EMAIL PROTECTED] On Behalf
> > > Of [EMAIL PROTECTED]
> > > Sent: Thursday, January 31, 2008 7:30 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Python-list Digest, Vol 53, Issue 2
> >
> > > Send Python-list mailing list submissions to
> > > [EMAIL PROTECTED]
> >
> > > To subscribe or unsubscribe via the World Wide Web, visit
> > >http://mail.python.org/mailman/listinfo/python-list
> > > or, via email, send a message with subject or body 'help' to
> > > [EMAIL PROTECTED]
> >
> > > You can reach the person managing the list at
> > > [EMAIL PROTECTED]
> >
> > > When replying, please edit your Subject line so it is more specific than
> > > "Re: Contents of Python-list digest..."
> >
> > > This e-mail transmission contains information that is confidential and 
> > > may be privileged.   It is intended only for the addressee(s) named 
> > > above. If you receive this e-mail in error, please do not read, copy or 
> > > disseminate it in any manner. If you are not the intended recipient, any 
> > > disclosure, copying, distribution or use of the contents of this 
> > > information is prohibited. Please reply to the message immediately by 
> > > informing the sender that the message was misdirected. After replying, 
> > > please erase it from your computer system. Your assistance in correcting 
> > > this error is appreciated.
> >
> > Could you now specifically apologize for all those question
> > marks!!!
> >
> > :-)
> >
> > Peace, Paddy.
>
> And for top-posting :)

And for using ALL CAPS :)

> --
> Arnaud


-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Standardization: Wikipedia entry

2008-02-02 Thread Eduardo O. Padoan
On Jan 29, 2008 2:43 PM, John Nagle <[EMAIL PROTECTED]> wrote:
>Submitting Python 2.5 to ISO/ANSI might be a good idea.

>From GvR himself:
"""
- Does a specification (ISO, ECMA, ..) is planned for Python and when ?

No, never. I don't see the point.
"""
http://blogs.nuxeo.com/sections/blogs/tarek_ziade/2005_04_11_guido_van_rossum

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: type, object hierarchy?

2008-02-04 Thread Eduardo O. Padoan
On Feb 4, 2008 1:36 AM, 7stud <[EMAIL PROTECTED]> wrote:
> print dir(type)  #__mro__ attribute is in here
> print dir(object)   #no __mro__ attribute
>
>
> class Mammals(object):
> pass
> class Dog(Mammals):
> pass
>
> print issubclass(Dog, type)   #False
> print Dog.__mro__
>
> --output:--
> (, , )
>
>
> The output suggests that Dog actually is a subclass of type--despite
> the fact that issubclass(Dog, type) returns False.  In addition, the
> output of dir(type) and dir(object):
>
>
> ['__base__', '__bases__', '__basicsize__', '__call__', '__class__',
> '__cmp__', '__delattr__', '__dict__', '__dictoffset__', '__doc__',
> '__flags__', '__getattribute__', '__hash__', '__init__',
> '__itemsize__', '__module__', '__mro__', '__name__', '__new__',
> '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
> '__subclasses__', '__weakrefoffset__', 'mro']
>
> ['__class__', '__delattr__', '__doc__', '__getattribute__',
> '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__',
> '__repr__', '__setattr__', '__str__']
>
> suggests that type inherits from object since type has all the same
> attributes as object plus some additional ones.  That seems to
> indicate a hierarchy like this:
>
>
> object
>  |
>  V
> type
>  |
>  V
> Mammals
>  |
>  V
> Dog
>
>
> But then why does issubclass(Dog, type) return False?


Here you should find The Answer (tm):
http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html

(Beautifully ilustrated, BTW)

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anyone else use this little idiom?

2008-02-05 Thread Eduardo O. Padoan
On Feb 5, 2008 1:30 PM, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >  Ruby has a neat little convenience when writing loops where you don't
> >  care about the loop index: you just do n.times do { ... some
> >  code ... } where n is an integer representing how many times you want
> >  to execute "some code."
> >
> >  In Python, the direct translation of this is a for loop.  When the
> >  index doesn't matter to me, I tend to write it as:
> >
> >  for _ in xrange (1,n):
> > some code
> >
> >  An alternative way of indicating that you don't care about the loop
> >  index would be
> >
> >  for dummy in xrange (1,n):
> > some code
>
> I use pychecker a lot.  It views variables called [ '_', 'unused',
> 'empty', 'dummy' ] as names to ignore if they haven't been used.
>
> So according to pychecker '_' and 'dummy' would both be OK.
>
> As for me personally, I usually use '_' but sometimes use 'dummy'
> depending on the surrounding code.
>
> Note that this idiom is fairly common in python too
>
>  wanted, _, _, _, also_wanted = a_list
>
> which looks quite neat to my eyes.
>

BTW and FWIW, in Py3k you can do:

 wanted, *_, also_wanted = a_list

http://www.python.org/dev/peps/pep-3132/

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why must implementing Python be hard unlike Scheme?

2008-02-20 Thread Eduardo O. Padoan
On Feb 19, 2008 3:15 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Does this have to be true?  Beneath the more complex syntax are there
> a few core design principles/objects/relationships to help in grokking
> the whole thing? Got any related links?

Take a look at a simpler implementation, like "tinypy":
http://www.philhassey.com/blog/2008/02/19/tinypy-64k-nearing-10-and-it-really-does-fit-in-64k/

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A different kind of interface

2009-01-22 Thread Eduardo O. Padoan
On Thu, Jan 22, 2009 at 7:10 AM,   wrote:
> I use the Python shell daily, plus of course normal editors to edit
> python scripts. They both are very useful for different purposes. But
> the default interactive shell isn't much handy if you want to modify
> the past code to run it again, or you want to embed a bit of text in
> the code, or if you want to produce something a bit more clean that
> you can save, or just if you want to edit and debug 7-lines long
> programs.

You are almost *describing* reinteract:
http://blog.fishsoup.net/2007/11/10/reinteract-better-interactive-python/

It is a mix of a shell and an editor, that lets you go back and
rewirte history, and execute it again. It is GTK+, and you can write
plugins to plot graphics or display html, for example.

-- 
Eduardo de Oliveira Padoan
http://djangopeople.net/edcrypt/
"Distrust those in whom the desire to punish is strong." -- Goethe,
Nietzsche, Dostoevsky
--
http://mail.python.org/mailman/listinfo/python-list


Re: A different kind of interface

2009-01-23 Thread Eduardo O. Padoan
On Thu, Jan 22, 2009 at 5:01 PM,   wrote:
> Eduardo O. Padoan:
>> You are almost *describing* reinteract:
>
> - Thank you for the link and the software, I have not tried it yet,
> but from the screencast it looks quite nice.
> - I am glad that there are people that don't think that Emacs is
> (despite being good) the alpha and omega of editing. There's space for
> other ideas beside Emacs.

But it is! 

> - Maybe I was describing reinteract there, but that's only the first
> part of my post :-)
> - I can see that reinteract is based on a interaction style quite
> similar to the shell of Mathematica. I was talking about something
> different, and more similar to TextCalc, but in the end I think
> reinteract may be good enough for my purposes, so I'll try to run it.
> And I may be happy enough.

I dont known TextCalc, but I guess that reinteract is flexible enough
to the general purpose of "experimenting with Live code".

> - Eventually I may find the time and will to create my "interactive
> python text" :-) I think there's space for many different solutions.
> - Despite many years of experiments, development, shells, editors, and
> the like, I am sure there are other designs not yet tried or not
> common enough yet (beside the normal editors, shells, smart object-
> oriented graphical shells like hotwire shell, Resolver One, and few
> other weird things, like one where you can zoom text and images at
> different scales, other text-based systems, etc).


Sure, thats the spirit.


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



-- 
Eduardo de Oliveira Padoan
http://djangopeople.net/edcrypt/
"Distrust those in whom the desire to punish is strong." -- Goethe,
Nietzsche, Dostoevsky
--
http://mail.python.org/mailman/listinfo/python-list


Re: What about a decorator module version 3.0?

2008-12-01 Thread Eduardo O. Padoan
On Mon, Dec 1, 2008 at 9:16 AM, Michele Simionato
<[EMAIL PROTECTED]> wrote:
> I am thinking about releasing a new version of the decorator module,
> [...]

Just FYI, the module being discussed here is
http://www.phyast.pitt.edu/~micheles/python/documentation.html

I dont use it myself, but given how much I use decorators, I probably should.

-- 
Eduardo de Oliveira Padoan
http://djangopeople.net/edcrypt/
"Distrust those in whom the desire to punish is strong." -- Goethe,
Nietzsche, Dostoevsky
--
http://mail.python.org/mailman/listinfo/python-list


Re: "as" keyword woes

2008-12-04 Thread Eduardo O. Padoan
On Thu, Dec 4, 2008 at 7:44 AM, James Stroud <[EMAIL PROTECTED]> wrote:
> alex23 wrote:
>>
>> On Dec 4, 3:42 pm, "Warren DeLano" <[EMAIL PROTECTED]> wrote:
>>>
>>> So you prefer broken code to broken rules, eh?  Your customers must love
>>> that!  This is exactly the kind of ivory-tower thinking I feared might
>>> be behind the decision (form over function, damn the users to hell,
>>> etc.)
>>
>> Really? I find that believing something should remain static at the
>> expense of actual improvement to the language is far more 'ivory-tower
>> thinking' than embracing change.
>
> First, to quote Tim Peters, "practicality beats purity." Second, I might be
> biased here because I happen to know Warren, but, although he hails from the
> ivory tower, I imagine his concerns are purely practical. His contributions
> to software in structural biology are legendary.
>
>>> Am I the only one picking up on the irony here?  "as" exists largely to
>>> provide a mechanism for working around namespace conflicts -- except,
>>> apparently, conflicts involving "as".  The fact that "as" itself creates
>>> an insurmountable namespace collision is just killing me!  How absurd.
>>
>> Speaking of irony, you're complaining about namespace conflicts with a
>> -two character identifier- you've chosen. Here's a hint: choose better
>> names.
>
> The name fit his needs until changes in the language broke the name. If a
> name works and the code works, then the name is good enough. And speaking as
> a professional user of his software at the level of the application and at
> the level of the API, let me tell you his code works pretty damn good.
>
>>> But to be brutally honest...in this many-core world we must all accept
>>> and deal with today, it is hard to imagine how a non-multithreaded AND
>>> non-backwards compatible Python implementation can have much of a life
>>> ahead of it, with or without an "as" keyword.  I do sincerely hope I am
>>> wrong about this, but it is seems quite possible that C/Python's glory
>>> days are now behind us.
>>
>> To match your honesty, I'm somewhat tired with the trend of some
>> people to hit -one- issue with Python and suddenly lash out like
>> children over all the same old tired crap. Have you even looked at
>> multiprocessing? Have you contributed to any projects working on GIL-
>> less implementations? Or are you just regurgitating the same bullet
>> points we've heard time and time again?
>>
>> For chrissake, if you cannot do ANYTHING but BITCH about a change,
>> then you've no damn right to consider yourself a programmer. Real
>> programmers find solutions, not excuses.
>
> Correction: Real programmers write programs. And no, at this point he can't
> do anything but complain because, as others have noted, the change is not
> going away.
>
>>> And if so, then thank you all for so many wonderful years of effort and
>>> participation!
>>
>> You're welcome. Don't let the door hit you on the ass on your way out.
>
> You probably aren't a developer for the cPython implementation, but, if you
> were, I'd recommend taking rants like Warren's to heart because they are
> born of honest frustration and practical concern. Hopefully developers for
> python 2.7 are listening and won't break backward compatibility just because
> the "Zen of Python" suggests it might be a good idea.


Even I, who am not, by really far, legendary on anything, could give
my 2¢ one time or another on python-dev or python-ideas. If you really
care and think you have a good argument, I'm sure you are welcome to
post there! But they cant hold the release until everyone in the world
have voiced his concerns, its just not pratical.



-- 
Eduardo de Oliveira Padoan
http://djangopeople.net/edcrypt/
"Distrust those in whom the desire to punish is strong." -- Goethe,
Nietzsche, Dostoevsky
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python3 - it's awesome

2008-11-17 Thread Eduardo O. Padoan
On Mon, Nov 17, 2008 at 7:30 AM, Johannes Bauer <[EMAIL PROTECTED]> wrote:
> Hello list,
>
> since I've read so much about Python 3 and ran into some trouble which
> was supposed to be fixed with 3k, I yesterday came around to compile it
> and try it out.
>
> To sum it up: It's awesome. All the promised things like Unicode support
> "just work", all significant changes in the lanugage (try/except-Syntax,
> float division, file opening, print) I've encountered so far made
> absolute sense and it was quite easy to change over (I've been using 2.5
> so far). It was really easy to install it locally as my user (I want to
> try it out some more before I install it system-wide).

You can install it system-wide as "python3.0" or "python3" -- I think
that "make install" acts as "make altinstall" on Python 3.0, and dont
overide the default "python" binary. No, you probably dont want
python3.0 as the *default* python yet -- many Python programs for
Ubuntu or OS X, for example, depends on Python 2.X.

> So, why I am posting this here: First, thanks to the great work to
> anyone who has contributed. Secondly, I want to encourage anyone who
> hasn't tried Python3 out yet to do - it really is easier than you think
> and you won't be disappointed.

+1.

> Kind regards,
> Johannes
>
> --
> "Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
> verlästerung von Gott, Bibel und mir und bewusster Blasphemie."
> -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
> <[EMAIL PROTECTED]>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Eduardo de Oliveira Padoan
http://djangopeople.net/edcrypt/
"Distrust those in whom the desire to punish is strong." -- Goethe,
Nietzsche, Dostoevsky
--
http://mail.python.org/mailman/listinfo/python-list


Re: any(), all() and empty iterable

2009-04-12 Thread Eduardo O. Padoan
On Sun, Apr 12, 2009 at 8:53 AM, Tim Chase
 wrote:
>>> From the docs:
>>
>> all(iterable)
>>                Return True if all elements of the iterable are true.
>> Equivalent
>>        to:
>>                def all(iterable):
>>            for element in iterable:
>>                if not element:
>>                    return False
>>            return True
>
> Then I'd say the comment is misleading.  An empty list has no item that is
> true (or false), yet it returns true.  The comment in the docs should read
> "Return False if any element of the iterable is not true" or "Return True if
> all elements of the iterable are true or if the iterable is empty."

I didn't knew about "Vacuous True" (my fault, it seems Discrete Math
101) until reading about on this thread (thanks everyone!), and
reading on wikipedia it answered this exact question.


> To get the behavior the original comment describes, would seem to require an
> implementation something like this:
>
>  def all(iterable):
>    iterable = iter(iterable)
>    try:
>      element = iterable.next()
>    except StopIteration:
>      raise UnderdefinedBecauseNoElementsToCompareToTrue
>    while element:
>      try:
>        element = iterable.next()
>      except StopIteration:
>        return True
>    return False
>
>
> Tweaking the documentation seems like an easier and more backwards
> compatible solution to me :)
>
> -tkc
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Eduardo de Oliveira Padoan
http://importskynet.blogspot.com
http://djangopeople.net/edcrypt/

"Distrust those in whom the desire to punish is strong."
   -- Goethe, Nietzsche, Dostoevsky
--
http://mail.python.org/mailman/listinfo/python-list


Re: HASH TABLES IN PYTHON

2008-05-14 Thread Eduardo O. Padoan
On Wed, May 14, 2008 at 12:20 PM, Blubaugh, David A.
<[EMAIL PROTECTED]> wrote:
> To Whom It May Concern,
>
> I was wondering if anyone has ever worked with hash tables within the Python
> Programming language?  I will need to utilize this ability for quick
> numerical calculations.

http://docs.python.org/lib/typesmapping.html

> Thank You,
>
> David Blubaugh
-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list


Re: can't delete from a dictionary in a loop

2008-05-16 Thread Eduardo O. Padoan
On Fri, May 16, 2008 at 6:40 PM, Gary Herron <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>>
>> On 16 mai, 23:28, Hans Nowak <[EMAIL PROTECTED]> wrote:
>>
>>>
>>> Dan Upton wrote:
>>>

 for pid in procs_dict:
  if procs_dict[pid].poll() != None
   # do the counter updates
   del procs_dict[pid]
  The problem:
  RuntimeError: dictionary changed size during iteration

>>>
>>> I don't know if the setup with the pids in a dictionary is the best way
>>> to
>>> manage a pool of processes... I'll leave it others, presumably more
>>> knowledgable, to comment on that. :-)  But I can tell you how to solve
>>> the
>>> immediate problem:
>>>
>>>   for pid in procs_dict.keys():
>>>
>
> No, keys() produces a list (which is what is wanted here).
> It's iterkeys() that produces an iterator which would reproduce the OP's
> problem.
>
> And then, in Python3, keys() produces something else altogether (call a view
> of the dictionary) which would provoke the same problem, so yet another
> solution would have to be found then.

In Python 3.0, list(procs_dict.keys()) would have the same effect.



> Gary Herron
>
>>
>> I'm afraid this will do the same exact thing. A for loop on a dict
>> iterates over the dict keys, so both statements are strictly
>> equivalent from a practical POV.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is wrong with my Python threading?

2008-05-20 Thread Eduardo O. Padoan
On Tue, May 20, 2008 at 8:24 PM, Gabriel Genellina
<[EMAIL PROTECTED]> wrote:
> En Tue, 20 May 2008 10:28:51 -0300, castironpi <[EMAIL PROTECTED]>
> escribió:
>
>> You meant 'thd1.start( )' and 'thd2.start( )'.
>
> Wow! A message with a high S/N ratio coming from you!
> And it's not the first I've seen - whatever pills you're taking, they're
> good for you...

This is why I shouldn't be so eager adding people to the killfile.


-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list

Re: should I put old or new style classes in my book?

2008-05-30 Thread Eduardo O. Padoan
On Thu, May 29, 2008 at 3:06 PM, Jason <[EMAIL PROTECTED]> wrote:
> I've got Python 3.0 alpha 2.  In this version, it looks like you can
> define classes in either the old style or new style.  (I snipped the
> top line a bit in the following example):

Wrong. Py3k Classes are always new-style. They subclass object
implicitly when no superclass is given.

> Python 3.0a2 (r30a2:59405M, Dec  7 2007, 15:23:28
> Type "help", "copyright", "credits" or "license"
 class one(object): pass
> ...
 class two: pass
> ...
 two
> 
 one
> 
 type(one)
> 
 type(two)
> 


Both classes are new style.


-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Harry Potter?

2008-06-05 Thread Eduardo O. Padoan
On Thu, Jun 5, 2008 at 10:29 AM, Hans Nowak
<[EMAIL PROTECTED]> wrote:
> Helmut Jarausch wrote:
>>
>> Hi,
>> just to let you know ...
>>
>> Today I've got an email from Amazon recommending me
>> Harry Potter and the Deathly Hallows
>>
>> and they told me why they recommended this book,
>> because I've bought
>> Core PYTHON Programming
>>
>> Didn't know, Harry Potter is a Python fan.
>
> If you scan the alt.fan.harry-potter archives carefully, you will find at
> least one well-known Python core developer. :-)


Maybe Guido himself:
"The Harry Potter Theory of Programming Language Design"
http://www.artima.com/weblogs/viewpost.jsp?thread=123234




> --
> Hans Nowak (zephyrfalcon at gmail dot com)
> http://4.flowsnake.org/
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does the python library of Google Data API is truly free?

2008-06-11 Thread Eduardo O. Padoan
On Wed, Jun 11, 2008 at 10:28 AM, Kless <[EMAIL PROTECTED]> wrote:
> I understand very well that a service is a software which is accessed
> through a network.
>
> And the description given on Wikipedia [1] is "A 'Web service' (also
> Web Service) is defined by the W3C as "a software system designed to
> support interoperable Machine to Machine interaction over a network."
>
> Now, to ending with this. I understand that (almos) everybody is pro
> Google (and anti Microsoft), thinking that they have given a lot of
> services for free. And it's very hard that people understand my
> thinking.
>
> All that "free service" has a great price, that are the rights
> about those data, and when Google want can to disable the free access
> to that information.
>
> People don't realize that it's one more a company and like so it has
> only an end, that is to obtain the greater number of benefits which
> will be distributed between his shareholders. Within any years Google
> will be as hated as Microsoft.
>
> At least I try to use the less possible those services than limit my
> freedoms about data that has been contributed by me and another users.
>
>
> [1] http://en.wikipedia.org/wiki/Web_service
> --
> http://mail.python.org/mailman/listinfo/python-list
>

It is not a pro-GOOG/anti-MSFT child-thing. Google is a for-profit
company. They are in it for the money. There is nothing wrong with it
in a capitalist world, if you play by the rules.

Also, services like this are scarce resources, it demands storage
space, processing power, bandwidth, and etc to provide it, so it makes
absolute sense that one would want money to keep providing it.

Software per-se isn't scarce resources  - you can copy it infinite
times (but the work of writing it is, that is why there are
programmers payed to write Free Software).

Now you seem to be saying that if Google doesn't provide a scarce
resource to you for Free (as in "Free Beer"), they will be hated just
as you seem to hate Microsoft. I would hate Google if, after proving
so much good stuff as free software, they gonne bankrupt for providing
services without restrictions, completely for free.


http://en.wikipedia.org/wiki/Scarcity

-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple variable control in for loops. Doable in Python?

2008-07-18 Thread Eduardo O. Padoan
On Fri, Jul 18, 2008 at 4:21 PM, mark floyd <[EMAIL PROTECTED]> wrote:
> I'm new to Python and have been doing work converting a few apps from Perl
> to Python.  I can not figure out the comparable Python structures for
> multi-variable for loop control.
>
> Examples:
>
> # In Perl
> for($i = 0, j = 0; $i < I_MAX && $j < J_MAX; $i+=5, $j += 10)
> {
>. do something
> }
>
> // In Java
> class test {
>  public static void main(String[] args){
>   int i = 0;
>   int j = 1;
>   for(i=1, j = 0; i<11 && j < 10; i++, j++){
>System.out.println("I is: " + i);
>System.out.println("J is: " + j);
>   }
>  }
> }
>
>
> // In C
> #include 
> int main()
> {
>   int j = 0;
>   int k = 0;
>
>   for(j = 0, k = 0; j < 5 && k < 10; j++, k++) {
> printf("J = %d\n", j);
> printf("k = %d\n", k);
> }
>
>   return 0;
>   }
>
> I spent a good part of yesterday looking for a way to handle this style for
> loop in Python and haven't been able to find an appropriate way to handle
> this control style.  We have this style for loop all over the place and not
> being able to find a similar structure in Python could be a problem.  Any
> pointers to a Python equivalent structure would be much appreciated
>
> - Mark
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Ops, sorry, sent only to Mark.

Here is the asnwer again:

for i, j in zip(range(0, I_MAX, 5), range(0, J_MAX, 10)):
   do_stuff(...)

-- 
 Eduardo de Oliveira Padoan
http://www.petitiononline.com/veto2008/petition.html
http://djangopeople.net/edcrypt/
http://whoisi.com/p/514
http://pinax.hotcluboffrance.com/profiles/edcrypt/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this a good time to start learning python?

2008-04-01 Thread Eduardo O. Padoan
On Tue, Apr 1, 2008 at 3:57 PM,  <[EMAIL PROTECTED]> wrote:
> On Apr 1, 12:47 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
>  wrote:
>  > En Tue, 01 Apr 2008 13:57:55 -0300, <[EMAIL PROTECTED]> escribió:
>
> >
>  > > On Mar 31, 1:36 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
>  > > wrote:
>  >
>  > >> Don't be scared by the "backwards incompatible" tag - it's the way to
>  > >> get
>  > >> rid of nasty things that could not be dropped otherwise.
>  >
>  > > I would consider breaking production code to be "nasty" as well.
>  >
>
> > Please explain how the existence of Python 3.0 would break your production
>  > code.
>
>  The existence of battery acid won't hurt me either, unless I come into
>  contact with it.  If one eventually upgrades to 3.0 -- which is
>  ostensibly the desired path -- their code could break and require
>  fixing.

And how would this happen? I dont know of any good software
distribution that upgrades a component to another major revision
without asking first. The desired path is that, if somene wants to
port his software to Python 3.0, that he follow the migration plan.
Final users will install Python 3.0 as python3.0 anyway, with Python
2.x as default 'python' binary.


>  Backward compatibility is important.   C++ could break all ties with C
>  to "clean up" as well, but it would be a braindead move that would
>  break existing code bases upon upgrade.
>

C++ is not C. No one "upgrades" from C to C++.

-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Is this a good time to start learning python?

2008-04-01 Thread Eduardo O. Padoan
On Tue, Apr 1, 2008 at 4:20 PM,  <[EMAIL PROTECTED]> wrote:
>  > > > Please explain how the existence of Python 3.0 would break your 
> production
>  > >  > code.
>  >
>  > >  The existence of battery acid won't hurt me either, unless I come into
>  > >  contact with it.  If one eventually upgrades to 3.0 -- which is
>  > >  ostensibly the desired path -- their code could break and require
>  > >  fixing.
>  >
>
> > And how would this happen? I dont know of any good software
>  > distribution that upgrades a component to another major revision
>  > without asking first. The desired path is that, if somene wants to
>  > port his software to Python 3.0, that he follow the migration plan.
>
>  Of course, that's the point.  If you want to upgrade to the next
>  version of Python, you have to fix your code.   That stinks.  Your
>  other alternative is to remain stuck with Python 2.x, but eventually
>  the support for that will dry up.

"Eventually" it will take a decade to happen. 2.x support will not be
dropped untill gets (much) more users than Python 3.x.

>  > Final users will install Python 3.0 as python3.0 anyway, with Python
>  > 2.x as default 'python' binary.
>  >
>
> > >  Backward compatibility is important.   C++ could break all ties with C
>  > >  to "clean up" as well, but it would be a braindead move that would
>  > >  break existing code bases upon upgrade.
>  >
>
> > C++ is not C. No one "upgrades" from C to C++.
>
>  You misunderstand.  C++ has a lot of "warts" to maintain backwards
>  compatibility with C.  The standards committee could eliminate these
>  warts to make the language "cleaner", but it would break a lot of
>  systems.

It would not "break" anything that not move from C to C++, this is my point.
People not willing to take the migration path (porting to 2.6, using
the -3 flag, refactoring and re-running the tests untill the warning
are gone, using the 2to3 tool...) will not upgrade. No one will force
you to do it. 2.6 will not desappear from the python.org site anytime
soon.

-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie to python --- why should i learn !

2008-05-08 Thread Eduardo O. Padoan
On Thu, May 8, 2008 at 7:25 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi,
>
>  i was reading/learning some hello world program in python.
>  I think its very simillar to Java/C++/C#. What's different (except
>  syntax) ?
>
>  what can i do easily with python which is not easy in c++/java !?

Programming in a pure duck typing style
http://en.wikipedia.org/wiki/Duck_typing

>  Tnx,
>  Raxit
>  www.mykavita.com
>  --
>  http://mail.python.org/mailman/listinfo/python-list
>



-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list


Re: Not fully OO ?

2008-09-20 Thread Eduardo O. Padoan
On Sat, Sep 20, 2008 at 11:26 AM, Kay Schluehr <[EMAIL PROTECTED]> wrote:
> On 20 Sep., 12:14, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>> Kay Schluehr wrote:
>> > Answer: if you want to define an entity it has to be defined inside a
>> > class. If you want to access an entity you have to use the dot
>> > operator. Therefore Java is OO but Python is not.
>>
>> you're satirising the quoted author's cargo-cultish view of object
>> orientation, right?
>>
>> 
>
> I wonder if the OO fetish hasn't already lost much of its magic
> powers. What are the most powerful fetishes these days? A year ago I
> would have suspected "purely functional" but I'm not sure it has
> really caught on.

I think the current fetish is paralelism and  erlang's share-nothing
concurrency model. Or something like it.


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



-- 
Eduardo de Oliveira Padoan
http://djangopeople.net/edcrypt/
http://stopforwarding.us/etiq.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Joao S. O. Bueno
Today I also stumbled on this helpful "essay" from Brett Cannon about
the same subject

http://www.snarky.ca/how-the-heck-does-async-await-work-in-python-3-5

On 23 February 2016 at 18:05, Sven R. Kunze  wrote:
> On 20.02.2016 07:53, Christian Gollwitzer wrote:
>
> If you have difficulties wit hthe overall concept, and if you are open to
> discussions in another language, take a look at this video:
>
> https://channel9.msdn.com/Shows/C9-GoingNative/GoingNative-39-await-co-routines
>
> MS has added coroutine support with very similar syntax to VC++ recently,
> and the developer tries to explain it to the "stackful" programmers.
>
>
> Because of this thread, I finally finished an older post collecting valuable
> insights from last year discussions regarding concurrency modules available
> in Python: http://srkunze.blogspot.com/2016/02/concurrency-in-python.html It
> appears to me that it would fit here well.
>
> @python-ideas
> Back then, the old thread ("Concurrency Modules") was like basically meant
> to result in something useful. I hope the post covers the essence of the
> discussion.
> Some even suggested putting the table into the Python docs. I am unaware of
> the formal procedure here but I would be glad if somebody could point be at
> the right direction if that the survey table is wanted in the docs.
>
> Best,
> Sven
>
> ___
> Python-ideas mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to detect what type a variable is?

2006-11-29 Thread Eduardo \"EdCrypt\" O. Padoan
>
> One might prefer to check for string-ness, as strings can
> duck-type somewhat like lists:
>
> my_list = ['my', 'brain', 'hurts']
> my_string = 'Are you the brain specialist?'
>
> for test in [my_list, my_string]:
>  try:
>  for thing in test:
>  process_list_item(thing)
>  except Exception: #whatever flavor you want

The exception should be the one that process_list_item raises when it
receives a string instead of a list. if you want to treat strings and
list in different ways, maybe it means that you are doing different
operations on then, like appendind things to the list or whatever. If
not, than you maybe want to test the types.

>  process_string(thing) # not called because
>  #strings are iterable

What if you invert your code?


for test in [my_string, my_list]:
try:
process_string_item(thing)
#suppose process_string_item does some string operation on a
list and gets this
# exception - because if not, I see no meanning in distinguishing then
except ValueError:
for thing in test:
process_list_item(thing)

But maybe you have a reason to do things to a string that could be
done to a list without raising an exception, but you dont want to do
this to *that* list. My sugestion was to think if there is another
way, and maybe you are right.


-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
Blog: http://edcrypt.blogspot.com
Jabber: edcrypt at jabber dot org
ICQ: 161480283
GTalk: eduardo dot padoan at gmail dot com
MSN: eopadoan at altavix dot com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strange PyLint configuration (was: PEP 8 style enforcing program)

2007-05-31 Thread Eduardo \"EdCrypt\" O. Padoan
On 5/31/07, Bjoern Schliessmann
<[EMAIL PROTECTED]> wrote:
> Alexander Eisenhuth wrote:
>
> > Pylint is one of them (http://www.logilab.org/857)
>
> BTW: Why does pylint want all names with underscores? I tested it
> and it complains about malformed names in e.g. the following cases
> that are conformant to PEP 8:
>
> - single letter as parameter

This seems to be an Logilab internal restriction.

> - firstLowerCamelCase names for instances and instance methods in
>   class declarations ("should match [a-z_][a-z0-9_]{2,30}$")
> - all lowercase method names in class declarations
>

No. Quoting PEP 8:
Functions:
"""
mixedCase is allowed only in contexts where that's already the
  prevailing style (e.g. threading.py), to retain backwards compatibility.
"""
Methods and instances:
"""
Use the function naming rules: lowercase with words separated by
  underscores as necessary to improve readability.
"""


> Those policies are barely usable, IMHO, and neither practical.

I Desagree.

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should: "for k,v in **dictionary_instance" work?

2007-06-16 Thread Eduardo \"EdCrypt\" O. Padoan
> Actually since you asked, I had to try this out
>
> x = range(10)
> a, *b = x

PEP 3132: Extended Iterable Unpacking
http://www.python.org/dev/peps/pep-3132/



-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-22 Thread Eduardo \"EdCrypt\" O. Padoan
On 6/22/07, John Nagle <[EMAIL PROTECTED]> wrote:
> Paul Boddie wrote:
> > P.S. I agree with the sentiment that the annotations feature of Python
> > 3000 seems like a lot of baggage. Aside from some benefits around
> > writing C/C++/Java wrappers, it's the lowest common denominator type
> > annotation dialect that dare not be known as such, resulting from a
> > lack of consensus about what such a dialect should really do, haunted
> > by a justified fear of restrictive side-effects imposed by a more
> > ambitious dialect (eg. stuff you get in functional languages) on
> > dynamically-typed code. I don't think the language should be modified
> > in ways that only provide partial, speculative answers to certain
> > problems when there's plenty of related activity going on elsewhere
> > that's likely to provide more complete, proven answers to those
> > problems.
>
>  I agree.  It's a wierd addition to the language.  It looks like
> a compromise between the "no declarations" position and the "make
> the language strongly typed" position.  But it's so ill-defined that
> it's not helpful, and worse than either extreme.  The whole
> approach is antithetical to the "only one way to do it" concept.
> This could lead to misery when different libraries use
> incompatible type annotation systems, which is not going to be fun.
>
>  Python made it this far without declarations, and programmers
> seem to like that.  We need to get Python performance up, and
> the ShedSkin/Psyco restrictions seem to be enough to allow that.
> Type annotations don't seem to solve any problem that really needs
> to be solved.
>
>  The main advantage of strongly typed systems is that more errors
> are detected at compile time.  You pay for this in additional language
> baggage.  PEP 3107 adds the excess baggage without providing the benefit
> of compile time checks.

Remember that pure CPython has no different "compile time" and
runtiime. But Psyco and ShedSkin could use the annotations the way
they want.

Function annotations, as PEP 3107 says, just adds "arbitrary metadata
annotations to Python functions" - If you follow the py-dev discutions
about it, it was only accepted because it have more possible uses then
just type checking. Also, there are many approches and different needs
for type checking/restrictions ("safety", IDEs autocompletion hints,
performance... )
So the annotations will be more a "signature documentation", so
different libraries can do whatever it want of it - I problably will
use only as documentation, like in:

def compile(source: "something compilable",
   filename: "where the compilable thing comes from",
   mode: "is this a single statement or a suite?"):


-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Collections of non-arbitrary objects ?

2007-06-25 Thread Eduardo \"EdCrypt\" O. Padoan
> I don't think there is anything wrong with the data structures that
> exist in python. I was just wondering if there was a structure that
> would restrict a collection to only allow certain types. The
> "restrictedlist" class discussed in another thread may be the sort of
> thing I was looking for.


Just remenber that if you write a library using such a thing, your
(consenting adults) users will not be able to store objects in your
list that implement (part of) the interface of the type that you
restricted.


-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread Eduardo \"EdCrypt\" O. Padoan
On 6/27/07, Stephen R Laniel <[EMAIL PROTECTED]> wrote:
> On Thu, Jun 28, 2007 at 09:08:16AM +0200, Bruno Desthuilliers wrote:
> > You said ?
>
> I could link again to Mark-Jason Dominus, who writes that
> people often make the following inference:
>
> 1) C is strongly typed.
> 2) C's typing sucks.
> 3) Hence strong typing sucks.

AFAIK, Python type system is "stronger" than C. C is just *static* typed.

> But I won't.
>
> It doesn't need to be a religious war. Why can't people just
> say "When strong typing is done and used well, it's a
> useful tool; when it's not, it's not"?

True, why this need to be a religious war instead of everybody
agreeing with you? :P

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Voluntary Abstract Base Classes

2007-06-29 Thread Eduardo \"EdCrypt\" O. Padoan
On 6/29/07, Daniel Nogradi <[EMAIL PROTECTED]> wrote:
> Hi list,
>
> Well, the short question is: what are they? I've read Guido's python
> 3000 status report on
> http://www.artima.com/weblogs/viewpost.jsp?thread=208549 where he
> mentions ABC's but don't quite understand what the whole story is
> about.

The story is at PEP 3119:
http://www.python.org/dev/peps/pep-3119/

> Anyone has good use cases?

The Rationale in the PEP may help you to imagine one.



-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-30 Thread Eduardo \"EdCrypt\" O. Padoan
On 6/30/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> Eduardo "EdCrypt" O. Padoan a écrit :
> > Remember that pure CPython has no different "compile time" and
> > runtiime.
>
> Oh yes ? So what's the compiler doing, and what are those .pyc files ?
> (hint: read the doc)

Sorry, I surely know that Python has a compile time, I wanted to say
somthing like "compile time checks except from syntax". My intention
was to show that a *huge* change in the Python interpretation model
would be needed to allow what he wanted, but I finished my email too
early :P
And yes, I readed the docs :)

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-04 Thread Eduardo \"EdCrypt\" O. Padoan
On 7/4/07, BJörn Lindqvist <[EMAIL PROTECTED]> wrote:
> On 6/22/07, Eduardo EdCrypt O. Padoan <[EMAIL PROTECTED]> wrote:
> > Remember that pure CPython has no different "compile time" and
> > runtiime. But Psyco and ShedSkin could use the annotations the way
> > they want.
> .
> > def compile(source: "something compilable",
> >filename: "where the compilable thing comes from",
> >mode: "is this a single statement or a suite?"):
>
> I think the above would make an annotation-enhanced Psyco or ShedSkin
> very confused.

This example was to show that annotations are for documentation too,
not only type checking or optimization. It is from the PEP.



EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pickled objects over the network

2007-07-18 Thread Eduardo \"EdCrypt\" O. Padoan
On 7/18/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Tue, 17 Jul 2007 14:57:16 -0700, Walker Lindley <[EMAIL PROTECTED]> wrote:
[...]
> The obvious thing you're doing wrong is using pickle over a network. ;)
>
>   http://jcalderone.livejournal.com/15864.html

Ok, maybe not the best tools to the job, but there are some more
secure alternatives:
http://trustedpickle.sourceforge.net/
http://home.gna.org/oomadness/en/cerealizer/index.html

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Feature Request: Explicit variable declarations

2007-04-20 Thread Eduardo \"EdCrypt\" O. Padoan
> The thoughts of the inventor of Python on "Adding Optional Static
> Typing to Python" are at 
> http://www.artima.com/weblogs/viewpost.jsp?thread=86641
> . I wonder if the idea will be implemented in Python 3.0.

No. He says it in another newer post and in PEP 3099, AFAIK.


-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: Extending a For Statement.

2007-05-21 Thread Eduardo \"EdCrypt\" O. Padoan
> > Perhaps you meant that second one to be:
> > (key, mydict[key] for key in mydict if key in xrange(60, 69) or key ==
> > 3)
> >
> Clearly not! Its called *list*-comprehension, not tuple-comprehension. ;)
With () instead of [], it is a generator expression.
http://docs.python.org/ref/genexpr.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Eduardo \"EdCrypt\" O. Padoan
def flatten(listOfLists):
return list(chain(*listOfLists))

>From http://www.python.org/doc/2.4/lib/itertools-recipes.html
-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Inconsistent list/pointer problem

2007-02-02 Thread Eduardo \"EdCrypt\" O. Padoan
> def myFunc(listA):
> listB = listA
> work on & modify listB
> return(listB)

def my_func(listA):
   listB = listA[:]
   #work on & modify listB
   return listB

Attribution makes the name t the left 'point' to the result of the
expression at the right.
In your myFunc the expersion at the right is the name listA, at it
willl eval to the list that this  references. So you will end with to
references.
In my my_func, the expression at the right is a slicing of the list,
from begin to end (listA[:]). Slicing returns a new list, in this
example, with the same items of the original list. So you end with two
lists, as you wanted.


--
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
Blog: http://edcrypt.blogspot.com
Jabber: edcrypt at jabber dot org
ICQ: 161480283
GTalk: eduardo dot padoan at gmail dot com
MSN: eopadoan at altavix dot com


-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
Blog: http://edcrypt.blogspot.com
Jabber: edcrypt at jabber dot org
ICQ: 161480283
GTalk: eduardo dot padoan at gmail dot com
MSN: eopadoan at altavix dot com
-- 
http://mail.python.org/mailman/listinfo/python-list


re: Inconsistent list/pointer problem

2007-02-02 Thread Eduardo \"EdCrypt\" O. Padoan
> Won't do for the OP's needs - he wants to modify the objects contained
> in listB without impacting the ones in listA (or at least that's what I
> understand).


Sorry. That is true - the items referenced on the [:] copy are the same as
in the original. Rereading what the OP msg, I think we agree.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File system API

2007-02-02 Thread Eduardo \"EdCrypt\" O. Padoan
On 2/2/07, Tal Einat <[EMAIL PROTECTED]> wrote:
> > I think that there aready exists a proposal for an Abstract FS Layer
> > for Python somewere.
>
> I haven't been able to find any mention of it. Maybe you could point me in
> the right direction?
>
> - Tal
>
http://wiki.python.org/moin/CodingProjectIdeas/FileSystemVirtualization

Another related reference is the recently announced UniPath module:
http://sluggo.scrapping.cc/python/unipath/Unipath-current/README.html

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
Blog: http://edcrypt.blogspot.com
Jabber: edcrypt at jabber dot org
ICQ: 161480283
GTalk: eduardo dot padoan at gmail dot com
MSN: eopadoan at altavix dot com
-- 
http://mail.python.org/mailman/listinfo/python-list


re: compound statement from C "?:"

2007-02-02 Thread Eduardo \"EdCrypt\" O. Padoan
http://effbot.org/pyfaq/is-there-an-equivalent-of-c-s-ternary-operator.htm

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
Blog: http://edcrypt.blogspot.com
Jabber: edcrypt at jabber dot org
ICQ: 161480283
GTalk: eduardo dot padoan at gmail dot com
MSN: eopadoan at altavix dot com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda functions ?

2007-02-06 Thread Eduardo \"EdCrypt\" O. Padoan
> This means that "f" is not a pointer to make_incrementor but rather to
> the internal (copied?) function.
"returned" function isthe right here. As any returned object from a function.

>
> > This style is very common in Scheme programming so you might read a
> > Scheme book if you want to understand it.  The classic:
> >
> >   http://mitpress.mit.edu/sicp/
> >
>
> I might just well do that.

A nice read indeed, but understand this concept first:
http://en.wikipedia.org/wiki/First-class_function

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
Blog: http://edcrypt.blogspot.com
Jabber: edcrypt at jabber dot org
ICQ: 161480283
GTalk: eduardo dot padoan at gmail dot com
MSN: eopadoan at altavix dot com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Object type check

2007-02-07 Thread Eduardo \"EdCrypt\" O. Padoan
> Of cource i restrict them to particular types! In C# you cannot pass
> something bad
> this way because the compiler will just catch it!

And you cant pass something 'good' that immitates another object
interface (a file-like object for example)

> I see what you mean by "duck typing". So you suggest the "do nothing
> at all" direction,
> better document my code so other can see what is expected, right ?

I would add UnitTests to it.
-- 
EduardoOPadoan (eopadoan->altavix::com)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: idea for testing tools

2007-02-08 Thread Eduardo \"EdCrypt\" O. Padoan
>   #!/usr/bin/python
>
>   a = 1
>   b = 2
>
>   def test_some():
>   assert a == b
>
> didn't reveal the values for a and b, though some more complex cases
> showed something.

def test_some():
print 'a:', a, 'b:', b
assert a == b

http://codespeak.net/py/current/doc/test.html#debug-with-the-print-statement

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
Blog: http://edcrypt.blogspot.com
Jabber: edcrypt at jabber dot org
ICQ: 161480283
GTalk: eduardo dot padoan at gmail dot com
MSN: eopadoan at altavix dot com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: idea for testing tools

2007-02-08 Thread Eduardo \"EdCrypt\" O. Padoan
> That's hardly desirable. If one is writing a test library that goes as
> far as reparsing the assert statements, I can't see the point of
> requiring the user to clutter his test suite with such spurious print
> statements. After all, that's one of the main points of test suites in
> the first place (that's why there is assertEqual).

It will be only be printed when the test fails, along with the rest of
the info. The tests will not be "cluttered" by this litle print.

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Python interactive interpreter has no command history

2007-02-15 Thread Eduardo \"EdCrypt\" O. Padoan
> Hello,
>
> How to configure Python2.5's interactive interpreter to get command
> history ?
>
> I always got ^[[A and ^[[B .
>

Are you using Ubuntu? The last comes with 2.4.x and 2.5. This only
occurs on 2.5. This happens when you compile Python with libreadline
installed, AFAIK.
FIll a bug in the Ubuntu launchpad. You can install libreadline (and
build-essential), download the 2.5 source and compile yourself.

--
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pep 3105: the end of print?

2007-02-16 Thread Eduardo \"EdCrypt\" O. Padoan
On 2/15/07, Edward K Ream <[EMAIL PROTECTED]> wrote:
> > Isn't the very concept of major releases (1.x, 2.x, 3.x) that they *can*
> > be not backwards-compatible with previous releases?
>
> Not at all. [...]

It is the only intent of Python 3.0: be free of backward compatibity
constraints.
There are a tool called "2to3" that translates things like "print foo"
to print(foo).

-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why I don't like range/xrange

2007-02-16 Thread Eduardo \"EdCrypt\" O. Padoan
> But this long int => int issue should not exist in a future python
> version any more, IIRC int and long int is scheduled to be merged
> somehow. (Or isn't it?)

It is done.
http://mail.python.org/pipermail/python-3000-checkins/2007-January/000251.html


-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Calling a dos batch file from python

2007-09-04 Thread n o s p a m p l e a s e
Suppose I have a batch file called mybatch.bat  and I want to run it
from a python script. How can I call this batch file in python script?

Thanx/NSP

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


Re: Calling a dos batch file from python

2007-09-05 Thread n o s p a m p l e a s e
On Sep 4, 5:01 pm, [EMAIL PROTECTED] wrote:
> On Sep 4, 8:42 am, n o s p a m p l e a s e <[EMAIL PROTECTED]>
> wrote:
>
> > Suppose I have a batch file called mybatch.bat  and I want to run it
> > from a python script. How can I call this batch file in python script?
>
> > Thanx/NSP
>
> The subprocess module should work.
>
Thanx to all those who responded. It was quite simple.

import os
os.system("mybatch.bat")

NSP

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


Calling a matlab script from python

2007-09-05 Thread n o s p a m p l e a s e
Suppose I have a matlab script mymatlab.m. How can I call this script
from a python script?

Thanx/NSP

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


  1   2   >