Re: how is python not the same as java?

2006-11-10 Thread Steve Holden
Ben Finney wrote:
> Steve Holden <[EMAIL PROTECTED]> writes:
> 
>> Java is horrible, Oython is not.
> 
> Is that the predecessor to Python, the one that could only be
> expressed in vowel noises?
> 
You're taking the oiss, right?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: How to choose the right GUI toolkit ?

2006-11-10 Thread Eric Brunel
On Thu, 09 Nov 2006 23:51:31 +0100, Dan Lenski <[EMAIL PROTECTED]> wrote:

> One other thing I'm wondering: how exactly does Tkinter work?  Is the
> whole Tk toolkit bound up as library of low-level C code, or does
> Tkinter sit on top of a Tcl interpreter?

The latter: there is a tiny C layer allowing Python to call an embedded  
tcl interpreter.

> If the latter, that might explain why it is frustratingly slow on
> Cygwin... since Cygwin is not very good at starting up new processes in
> a timely manner.

There is no other process involved: the interpreter is embedded, just as a  
Python interpreter can be embedded in a C application. If you want to work  
with Tkinter on Windows, you'd better avoid Cygwin. Python with Tkinter  
works just fine on Windows, just as it works on any other platform, and is  
fully portable, just as tcl/tk is.

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing to file, how do I do it efficiently?

2006-11-10 Thread Cameron Walsh
Robert Kern wrote:
> Cameron Walsh wrote:
>> Hi all,
>>
>> I have a numpy.array of 89x512x512 uint8's, set up with code like this:
> 
> numpy questions are best asked on the numpy list, not here.

At first I thought it was a generic python question, since it had more
to do with writing array data to file rather than the specific format of
the array data.

> 
>> data=numpy.array([],dtype="uint8")
>> data.resize((89,512,512))
> 
> You might want to look at using numpy.empty() here, instead.
> 

Thanks!

[...]
>> I'm guessing that the slow part is the fact that I am converting the
>> data to character format and writing it one character at a time.  What
>> is a better way of doing this, or where should I look to find a better way?
> 
> data.tostring()
> 

And here I see I was wrong, it was a numpy question.  I assumed the
tostring() method would produce the same output as printing the array to
the screen by just calling "data".  But of course, that would be the job
of the __repr__() method.

It is now ridiculously fast (<1second).  Thank you for your help.

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


Re: how is python not the same as java?

2006-11-10 Thread Michele Simionato

gavino wrote:
> both are interpreted oo langauges..

Notice that gavino has a long history of asking trollish questions in
Lisp and Scheme
newsgroups and  he displays the typical behavior of a troll.

Michele Simionato

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


Re: How to choose the right GUI toolkit ?

2006-11-10 Thread Eric Brunel
On Thu, 09 Nov 2006 22:01:51 +0100, Dan Lenski <[EMAIL PROTECTED]> wrote:
> Tk 8.4 appears to use native Win32 widgets under Cygwin and native
> WinXP.

It seems to depend on the widget type, and on what you call native... For  
example, tk menus are definitely the native ones; tk scrollbars are the  
native ones, but with the Win2k look (no XP look available yet); tk  
buttons do not seem to be the native ones, as they don't act like "normal"  
Windows buttons.

> But it definitely doesn't use GTK widgets under Ubuntu with
> Gnome desktop.

You seem to imply that GTK is "native" on Linux. It isn't, as can be seen  
with the echoes of the "holy war" between Gnome and KDE that we often see  
around here. As an aside, I personnally work on Linux and don't even use  
any of these environments (both are too much Windows-like to my taste...).

> Is there a way to get it to do so?

Not yet. But tcl/tk 8.5 will include the Tile extension including new  
themable widgets. See here:
http://tktable.sourceforge.net/tile/screenshots/unix.html

There is also a Tile/QT extension that allows the Tile widgets to use the  
QT library. See here:
http://www.ellogon.org/petasis/index.php?option=com_content&task=view&id=24&Itemid=40

AFAIK, nothing equivalent for GTK yet.

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how is python not the same as java?

2006-11-10 Thread Ben Finney
Steve Holden <[EMAIL PROTECTED]> writes:

> Ben Finney wrote:
> > Steve Holden <[EMAIL PROTECTED]> writes:
> >> Java is horrible, Oython is not.
> > Is that the predecessor to Python, the one that could only be
> > expressed in vowel noises?
> > 
> You're taking the oiss, right?

Oardon. I never meant to ooke fun at your tyoing imoediment.

-- 
 \  "For mad scientists who keeo brains in jars, here's a tio: why |
  `\not add a slice of lemon to each jar, for freshness?"  -- Jack |
_o__)   Handey |
Ben Finney

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


Re: Simple question to split

2006-11-10 Thread cppasm
a.split(',')

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

Localized (international) informations on WXP

2006-11-10 Thread durumdara
Hi !

WXP, Py2.4.3.

I want to get localized informations like month names, format 
parameters, etc.

But nl_langinfo is not exists.

Have the Python a way to get these informations in uniformed way (like 
php) to avoid multiplatform problems ?

Thanks for help:
dd

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


Re: to Doctest as SystemExit is to Python

2006-11-10 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> Can I somehow tell doctest that it's time to quit?

Hit Ctrl-C. Or raise a KeyboardInterrupt:

import sys

class ExitDoctest(KeyboardInterrupt):
pass

def f(what):
"""
>>> f("alpha")
'alpha'
>>> f("e")
'e'
>>> f("x")
'x'
>>> f("X")
'X'
>>> f("beta")
'beta'
"""
if what == "e":
raise Exception
elif what == "x":
sys.exit()
elif what == "X":
raise ExitDoctest("You're in trouble")
return what

if __name__ == "__main__":
import doctest
try:
doctest.testmod()
except ExitDoctest, e:
print >> sys.stderr, e

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


Re: Localized (international) informations on WXP

2006-11-10 Thread Martin v. Löwis
durumdara schrieb:
> I want to get localized informations like month names, format
> parameters, etc.

Month names are available through calendar.month_name. Format
parameters are available through locale.localeconv.

> Have the Python a way to get these informations in uniformed way (like
> php) to avoid multiplatform problems ?

It exposes all of the C locale API, yes. Whether that's like php,
I don't know.

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


Re: Tkinter check box behaviour - Windows / Linux discrepancy

2006-11-10 Thread peter
Thank you for those suggestions

I've tried it on Windows and it seems fine (with the minor change to
command=self.chkTest_click).  I'm currently at work, with no access to
Linux, so can't test it there until this evening.  

Muchas gracias!

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


Re: Tkinter check box behaviour - Windows / Linux discrepancy

2006-11-10 Thread peter
Thank you for those suggestions

I've tried it on Windows and it seems fine (with the minor change to
command=self.chkTest_click).  I'm currently at work, with no access to
Linux, so can't test it there until this evening.  

Muchas gracias!

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


Create shared folder in server

2006-11-10 Thread Enrique Palomo
Title: Create shared folder in server







Hi all,

I'm doing some test to create and share  folders in another pc.

I'm executing an example found googling and works fine in my own pc, but executing from another (ping is ok) raises an "access denied" error.

I've included the entry shinfo['user'], don't know if exist but is needed to operate in different servers.

Any idea?


Thanks a lot

Enrique


import win32net

import win32netcon


shinfo={}


shinfo['netname']='prueba pitonera'

shinfo['type']=win32netcon.STYPE_DISKTREE

shinfo['remark']='bedrock_rubbel'

shinfo['permissions']=0

shinfo['max_uses']=-1

shinfo['current_uses']=0

shinfo['path']='c:\\'

shinfo['user']='xx'

shinfo['passwd']=''

server=''


try:

  win32net.NetShareAdd(server,2,shinfo)

except win32net.error:

  print traceback.format_tb(sys.exc_info()[2]),'\n',sys.exc_type,'\n',sys.exc_value


**AVISO DE CONFIDENCIALIDAD** La informacion contenida en este mensaje y archivos es privada y confidencial estando dirigida solamente al destinatario. Si Ud. ha recibido esta informacion por error, por favor, proceda a su inmediata destruccion. Cualquier opinion o punto de vista contenido en este mensaje corresponde al remitente y necesariamente no representa la opinion del GRUPO XEROX.**CONFIDENTIAL HEADER**This email and any files are private and confidential and intended solely for the use of the addressee(s). If you have received this e-mail in error please delete it immediately. Any views or opinions presented in this e-mail are solely those of the sender and do not necessarily represent those of XEROX GROUP.
-- 
http://mail.python.org/mailman/listinfo/python-list

Localization - set to default on Windows

2006-11-10 Thread durumdara




Hi !

I want to set default locale on WXP.
I want to create a formatting tool that can set up format locale in the
init, and next the formatter functions are use these settings.
Example:

fmtunit:
---

SetLocaleToDefault()

def ToUnicode(text,  encoding = None):
    
    if encoding == None:
       encoding = defaultencoding
    ...

This is my test code that have been failed in more point.
import locale
# Get default
print locale.getdefaultlocale('LANG')
# Get actual
print locale.getlocale(locale.LC_ALL)
# Get default to "loc"
loc, enc = locale.getdefaultlocale('LANG')
try:
    # Try to set 
    locale.setlocale(locale.LC_ALL, loc)
except Exception, msg:
    # An error
    print msg
# Get actual
print locale.getlocale(locale.LC_ALL)
# Set manually
locale.setlocale(locale.LC_ALL, "HU")
# Get the actual locale
print locale.getlocale(locale.LC_ALL)
print locale.getdefaultlocale('LANG')
  

The result was:

> Executing: C:\Program Files\ConTEXT\ConExec.exe
"c:\python24\python" "c:\loc.py"
  
('hu_HU', 'cp1250')
(None, None)
unsupported locale setting
(None, None)
('Hungarian_Hungary', '1250')
('hu_HU', 'cp1250')
> Execution finished.
  

Two interesting thing I see:

  The default locale (hu_HU) is not correct parameter for
setlocale. Why ? I want to determine and set up the locale
automatically, with script !
  When I set locale with HU, then I cannot compare default locale
with locale, to check it's state. These values are uncomparable: "HU",
"hu_HU", "Hungarian_Hungary"...
  


Please help me: how to do this localization ?

Thanks for it:
    dd





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

python wiki question

2006-11-10 Thread ruud habets
Hi,

Does anybody know how to determine if a wiki page is a redirectpage 
using the wikipedia-scripts? It must be something like

if IsRedirectPage() == False:
text_file.write("\n")

But I cannot seem to get it working.

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


Re: how is python not the same as java?

2006-11-10 Thread Bruno Desthuilliers
gavino wrote:
> both are interpreted oo langauges..

Being "interpreted" or whatever is a feature of an *implementation*, not
of a language.

FWIW, CPython (the reference implementation) is compiled to byte-code,
that is then executed by a virtual machine. And Sun's Java
implementation works the same.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how is python not the same as java?

2006-11-10 Thread Bruno Desthuilliers
Jorge Vargas wrote:
> On 9 Nov 2006 16:44:40 -0800, gavino <[EMAIL PROTECTED]> wrote:
>> both are interpreted oo langauges..
>>
> that is not correct java is compiled and the VM interprets the code

So are CPython and IronPython.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python wiki question

2006-11-10 Thread ruud habets
ruud habets schreef:
> Hi,
> 
> Does anybody know how to determine if a wiki page is a redirectpage 
> using the wikipedia-scripts? It must be something like
> 
> if IsRedirectPage() == False:
>text_file.write("\n")
> 
> But I cannot seem to get it working.
> 
> thnx
> Ruud
problem solved:

def workon(page):
 try:
 text = page.get()
 except wikipedia.IsRedirectPage:
 return

 text_file.write(page.title().encode("utf-8"))
 text_file.write("\n")
 text_file.write(page.get().encode("utf-8"))
 text_file.write("\n")
 print page

thnx anyway
ruud
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-10 Thread Robin Becker
Robin Becker wrote:
> Andrew MacIntyre wrote:
>> Robin Becker wrote:
>>
>>> I think it uses sysv semaphores and although freeBSD 6 has them 
>>> perhaps there's something I need to do to allow them to work.
>> IIRC, you need to explicitly configure loading the kernel module, or
>> compile the kernel with the necessary option in the config file.
>>
> I tried loading the module, but it seems already to be in the kernel. 
> Probably some sysctl stuff to do.
> 
In fact the semaphore modules are built in now. I did some debugging and the 
error happens in the code at SemSet.c line 25


   for (i = 0; i < sets; i++) {
 int id = semget(IPC_PRIVATE, MAX_SYSV_SET_SIZE, IPC_CREAT
 | S_IREAD | S_IWRITE); //SEM_R | SEM_A);
 if (id == -1) {

the first semget(i=0) succeeds and the second fails with an errno ENOSPC which 
from the man page implies a resource issue of some kind.

 [ENOSPC]   Insufficiently many semaphores are available.
 [ENOSPC]   The kernel could not allocate a struct semid_ds.


I guess the freebsd limits  must be different to the original development 
environment.
-- 
Robin Becker

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


Re: Newb: installing Jython on Windows XP ...

2006-11-10 Thread Marcus Bajohr
donkeyboy wrote:
> All,
> 
> I'm having issues installing Jython on Windows XP. I've looked on the
> web and this newsgroup but to no avail. Any suggestions? The shell
> listing is below:
> 
> NB I've got Cygwin installed, hence the Unix 'ls' on a Windows box
> 
> C:\>cd Jython
> 
> C:\Jython>ls
> jython_21.class
> 
> C:\Jython>ls "c:\Program Files\Java\jdk1.5.0_09\bin\java.exe"
> c:\Program Files\Java\jdk1.5.0_09\bin\java.exe
> 
> C:\Jython>"c:\Program Files\Java\jdk1.5.0_09\bin\java.exe" jython_21
> Exception in thread "main" java.lang.NoClassDefFoundError: jython_21
> 
> C:\Jython>"c:\Program Files\Java\jdk1.5.0_09\bin\java.exe" jython-21
> Exception in thread "main" java.lang.NoClassDefFoundError: jython-21
> 
> Any help would be of great use!!!
> 
Try it from cmd, not from the cygwin shell.
The environments differ !

greets
Marcus

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


Re: substring search without using built in utils

2006-11-10 Thread [EMAIL PROTECTED]


My lecture Mustafa Başer give me the same homework.But u have to
check similar algorithm at c then you can manipulate the same functions
for python.Cause other languages (except C#, java etc.) does not have a
strong library as python.Or alternatively you can check the source
codes too see behind the function's code.

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


pythoncom and dialog

2006-11-10 Thread ChristianHahn
Hi,

I inherited a piece of code, that doesn't work anymore. It's a
COM-object.
One interface method opens a modal dialog ( OpenDialog() ), with the
other methods one can set the values for a ComboBox or query the input
of the user.

This COM-module is istantiated(?) via
st=win32com.client.Dispatch(..)
within a windows application (btw it's called Prime Front Arena). The
scripting language for this application is Python.

The COM module works fine, when I call it from Excel via VBA or from
python directly.
When I call it from the mentioned application, sometime (not always)
the python statement st.OpenDialog() never returns and the application
is not responding anymore.
In the previous release of this appication this piece of code worked.
In the new release the app now using two threads, one thread for a
log-windows and one thread for all other windows.

I don't know if this a problem with pythoncom or a windows problem (two
threads, modal dialog), but when I debug it seems to me that it get
stuck somewhere in the pythoncom.dll

So

1) Does anyone have any hints for. I'm completly in the dark.
2) How can I compile a debug version of the pythoncom.dll by myself? I
downloaded the Zip-File, but when I try to open an *.dsp file, i get
asked for password (SafeSource)? What's that.

You see my windows skill are limited (but increased dramatically the
last days).

Thanks in advance
Christian

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


Re: how is python not the same as java?

2006-11-10 Thread Paul Boddie
Ray wrote:
> [EMAIL PROTECTED] wrote:
>
> > Jython exists.
>
> And Pava (or Pyava) doesn't, you mean?

Proof of concept only: http://www.boddie.org.uk/python/javaclass.html

If there were any really compelling libraries for Java that really had
to be available for CPython programs, I'd probably have worked around
the "platform issues" mentioned in the above document by now. However,
most people should just use Jython if they want Python and Java
interoperability, and gcj if they want to write Java for use with
CPython (just as the PyLucene people have done).

Paul

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


Re: Newb: installing Jython on Windows XP ...

2006-11-10 Thread Ant


On 10 Nov, 10:29, Marcus Bajohr <[EMAIL PROTECTED]> wrote:
> donkeyboy wrote:
> > All,
>
> > I'm having issues installing Jython on Windows XP. I've looked on the
...
> > Any help would be of great use!!!
> Try it from cmd, not from the cygwin shell.
> The environments differ !

Looking at the command prompt, he's not in the cygwin shell. I think
that there's a bug in the latest jre from sun. I installed the 1.5.0_09
update a few days ago, and I can't get any apps to run with it
(including irritatingly the Java Control Panel application so I can't
change the default back easily...) The problems are
NoClassDefFoundError's as well, so I wonder if the class loading is
broken in that release...

Anyway the solution seems to be to use an earlier jre explicitly:

"c:\Program Files\Java\jdk1.5.0_06\bin\java.exe" jython-21

1.5.0_06 seems to work fine for me.

HTH

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


Re: win32com/python different behavour.

2006-11-10 Thread Roger Upole
bli wrote:
>I have been developing an application driving a device through COM. I
> used win32com (brilliant )
> and was at a fairly advanced stage being able to access the functions
> of the device and access/ retrieve its data.
> A week or two ago I did some overdue upgrading to all the components of
> the application.win32com, python to 2.4.4 and wxpy to latest.
> Then the problem began (I think!).
> My app still accesses the device and some functions still perform as
> expected. Howeve some important data retrieval functions now behave
> very differently.
> Initially a tuple was returned, which was made into a list. This tuple
> returned (true,'1234xyz'), the first element was the success or failure
> of the operation, the second the required data.
> Now all these functions return only the boolean, True or False.
> I cannot seem to produce the tuple that initially worked extremely
> well.
>
> eg. initially
>
> xx.GetMACAddr(param1,param2)  <-- params as per 'intellisense' would
> return
> (True,'123xyz')
>
> now
> xx.GetMACAddr(param1,param2)  returns
> True(type boolean)
>
> I have exhausted my relative inexperience on this one.
> Any Ideas  BTW VB extracts the data just fine , so I dont think that
> the Device or firmware is at fault here.
> Python has been great so far, I trust this problem is an oversight on
> my part.
>
> Thanks in keen anticipation for any ideas to get over this one!!
>
> I am in the middle of returning to Python 2.4.3 just to be sure that
> this is not the issue.

Try running makepy on the object's typelib.  It may have been done
for your previous version of python.  Occasionally this can cause a
change in the number of return values if the library is doing something
non-standard.

  Roger


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


service windows avec py2exe

2006-11-10 Thread DarkPearl
Bonjour à tous,

apres avoir créer un service windows avec py2exe,
j'ai ce probleme quand je lance le service :

voici ce que je trouve dans le journal d'evenement :

The instance's SvcRun() method failed
: (-2147221020, 'Syntaxe incorrecte',
None, None)



je n'arrive pas du tout à trouver le probleme.

Peut etre que quelqu'un d'entre vous sais...

Merci

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


Re: Searching for a module to generate GUI events

2006-11-10 Thread Paul Boddie
Stephan Kuhagen wrote:
> utabintarbo wrote:
>
> > http://pywinauto.pbwiki.com/ for Win32
>
> Thanks for the hint, looks usable. But it seems, there's nothing for X11 and
> MacOSX. I didn't thought, that the problem would be so unusual...

Searching for "Python GUI testing" on Google gave this as the first
result:

http://www.redhat.com/magazine/020jun06/features/dogtail/

Comments on similar techniques for OS X can be found here:

http://www.oluyede.org/blog/2006/07/04/europython-day-1/

Other X11 projects which might support low-level interactions with
applications include the following:

http://python-xlib.sourceforge.net/
http://plwm.sourceforge.net/

Paul

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


windows service with SNMP

2006-11-10 Thread DarkPearl
Sorry for language, i wanted post in FR.comp.lang.python.

But...

hello with all, after having to create a Windows service with py2exe, I
have this problem when I launch the service: here what I find in the
eventLog:

The instance's SvcRun() method failed
: (-2147221020, 'Syntaxe incorrecte',
None, None)

I don't find a the problem.

If you can help me, thank's

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


Re: how is python not the same as java?

2006-11-10 Thread robert
gavino wrote:
> both are interpreted oo langauges..
> 

Thinks the first FAQs and tutorials about Python answer this question in detail.

Theoreticalls you'd start off thinking this: 
* Java is a stiff typing language (as old C/C++/Pascal... and even Perl are 
also ). 
* Python is a dynamic typing language - regarding almost all aspects. 
>From that each language can try to achieve some benefits of the other basic 
>paradigm by becoming cramped.

Practically:
* you will type a Python programs >5x faster than the equivalent in Java. 
* This is true, at least when we assume that test code has to be done for a 
good program anyway 
  (and/otherwise "pychecker" will neutralize most first-glance disadvantages of 
Python)
* Jave (typed code) ist executed faster. Yet Python is even faster when using 
little C, Pyrex, ...

That is probably what counts.

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


Re: How to choose the right GUI toolkit ?

2006-11-10 Thread Jeremy Sanders
Dan Lenski wrote:

> My apologies!  I'm glad to be corrected on this.  There are Cygwin
> packages for Qt as well, but I have heard about enough bugs to think I
> should avoid Qt.  I have used enough Gtk apps that run flawlessly under
> Windows to have my hopes that it works well.

You normally use PyQt/Qt on Windows without Cygwin. There are very few bugs
and lots of professional companies base their products on Qt Windows.

-- 
Jeremy Sanders
http://www.jeremysanders.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: comparing Unicode and string

2006-11-10 Thread Neil Cerutti
On 2006-11-10, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Marc 'BlackJack' Rintsch wrote:
>> Why?  Python strings are *byte strings* and bytes have values in the range
>> 0..255.  Why would you restrict them to ASCII only?
>
> Because getting an exception when comparing a string with a unicode
> string is irritating.
>
> But I don't insist on my PEP. The example just shows just
> another pitfall with Unicode and why I'll advise to any
> beginner: Never write text constants that contain non-ascii
> chars as simple strings, always make them Unicode strings by
> prepending the "u".

That doesn't do any good if you aren't writing them in unicode
code points, though.

-- 
Neil Cerutti
To succeed in the world it is not enough to be stupid, you must also
be well-mannered. --Voltaire
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: comparing Unicode and string

2006-11-10 Thread Neil Cerutti
On 2006-11-10, John Machin <[EMAIL PROTECTED]> wrote:
>
> Neil Cerutti wrote:
>> On 2006-10-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> > Hello,
>> >
>> > here is something that surprises me.
>> >
>> >   #coding: iso-8859-1
>>
>> I think that's supposed to be:
>>
>> # -*- coding: iso-8859-1 -*-
>>
>
> Not quite. As PEP 263 says:
>
> """
> More precisely, the first or second line must match the regular
> expression "coding[:=]\s*([-\w.]+)". 
> """

Yep. I was erroneously going by the example in the Unicode Howto.
Thanks for the correction.

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


Re: how is python not the same as java?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, gavino <[EMAIL PROTECTED]> wrote:
> both are interpreted oo langauges..

"..."

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


PythonWin Editor Freezes System

2006-11-10 Thread brettjasoncohen
When stepping through a program in the PythonWin Editor, sometimes the
rest of my system becomes unresponsive, espescially the program menu
items (File, Edit, ..., Help).
Help!
Brett

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


Re: how is python not the same as java?

2006-11-10 Thread [EMAIL PROTECTED]

gavino wrote:
> both are interpreted oo langauges..

How are LANs (http://en.wikipedia.org/wiki/LAN) and porns stars
(http://en.wikipedia.org/wiki/Gauge_%28porn_star%29) related to Java,
Python, Programming paradigms and trolls? ask Gavino!

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


announce: FAQs suggested

2006-11-10 Thread p . lavarre
http://effbot.org/pyfaq/suggest.htm has new FAQ's:

FAQ: How do I ask to exit from a doctest
FAQ: How do I say unsigned char in ctypes?
FAQ: How do I say returns void in ctypes?
FAQ: How do I calculate what quoted strings and numbers mean?

Enjoy, Pat LaVarre

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


Back Slash not allowed at the end of raw string?

2006-11-10 Thread yuhao
Title: Mail


I'm using Python 2.5 on Windows XP Pro.
While testing for strings, I got the following result:
 
>>> r'c:\'SyntaxError: EOL while scanning single-quoted 
string
>>> r'c:\nwin''c:\\nwin'
>>> r"c:\"SyntaxError: EOL while scanning single-quoted 
string
>>> r'\n''\\n'
>>> r'\"''\\"'
It seemed that when a back slash is inside the raw string, 
it is correctly recognized as a normal character, not translated; 
but when put to the end, it raise an error.
 
And the message looks so strange:
 
>>> r"c:\"SyntaxError: EOL while scanning single-quoted 
string
 
what does this message mean? I'm not using any single quote in the 
statement.
It this a bug or by design?
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Thu, 09 Nov 2006 14:44:21 -0600, Tim Chase
><[EMAIL PROTECTED]> declaimed the following in
> comp.lang.python:
>
>> A few arbitrary warts per-dictum of BDFL are fine though...it 
>> still looks much cleaner compared to PHP & Perl ;-)
>>
>   Or line continuation in REXX... Where you get such oddities as:
>
>   call xyz(a, b, c, ,
>   d, e, f)
>
> That is NOT a NULL argument between c and d... The first comma
> is the argument separator, the second comma is the
> to-be-continued marker

Eyiyi! That's yugly.

The colon's main purpose seems to be to allow one-liners:

Easy to parse: if a < b: a += 1
Hard to parse if a < b a += 1

-- 
Neil Cerutti
When you're in the public eye, it's wrong to cheat on someone, unless
you're very careful. If you're normal and no one's going to know, then
do it. --Paris Hilton
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: announce: FAQs suggested

2006-11-10 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> http://effbot.org/pyfaq/suggest.htm has new FAQ's:
> 
> FAQ: How do I ask to exit from a doctest

I don't consider that question /frequently/ /asked/ or that feature
frequently requested. Also, the KeyboardInterrupt approach is a hack. 

> FAQ: How do I say unsigned char in ctypes?
> FAQ: How do I say returns void in ctypes?

That's in the ctypes documentation, where it belongs.

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread skip

Neil> The colon's main purpose seems to be to allow one-liners:

Neil> Easy to parse: if a < b: a += 1
Neil> Hard to parse if a < b a += 1

No, as the note from Tim Peters referenced by Robert Kern pointed out
earlier in this thread, the ABC language designers found that
indentation-based block structure by itself wasn't enough to clue new users
in about the code structure.  Adding the colon at the end of the
if/while/for clause helped.

Skip

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


Re: Back Slash not allowed at the end of raw string?

2006-11-10 Thread Peter Otten
yuhao wrote:

> I'm using Python 2.5 on Windows XP Pro.
> While testing for strings, I got the following result:
> 
 r'c:\'
> SyntaxError: EOL while scanning single-quoted string

> what does this message mean? I'm not using any single quote in the
> statement. It this a bug or by design?

http://effbot.org/pyfaq/why-can-t-raw-strings-r-strings-end-with-a-backslash.htm

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


Re: announce: FAQs suggested

2006-11-10 Thread p . lavarre
> > > http://effbot.org/pyfaq/suggest.htm
> > FAQ: How do I say returns void in ctypes?
> That's in the ctypes documentation, where it belongs.

Thank you, before I never had found "Use None for void a function not
returning anything" at:
http://starship.python.net/crew/theller/ctypes/reference.html

Now I see, that find corresponds to:
http://docs.python.org/dev/lib/ctypes-foreign-functions.html

I think this remains an FAQ, because I see void is missing from much
more prominent places:
http://docs.python.org/dev/lib/node452.html "Fundamental data types"
http://docs.python.org/dev/lib/ctypes-return-types.html

Finding a way to suggest improving those docs would help more than
suggesting an FAQ, I agree.

> > > > http://effbot.org/pyfaq/suggest.htm
> > FAQ: How do I say unsigned char in ctypes?
> That's in the ctypes documentation, where it belongs.

Yes and no.  The whole FAQ suggested was:

FAQ: How do I say unsigned char in ctypes?
A: ctypes.c_ubyte
ctypes doesn't define c_uchar. This actually is doc'ed, it's just
annoying.

Per your kind correction above re void, I see we could also say:

FAQ: How do I say returns void in ctypes?
A: restype = None
ctypes doesn't define c_void. This actually is doc'ed obscurely, it's
just irregular.

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


FAQ: How do I calculate what quoted strings and numbers mean?

2006-11-10 Thread p . lavarre
> Subject: announce: FAQs suggested ...
> http://effbot.org/pyfaq/suggest.htm has new FAQ's ...
> FAQ: How do I calculate what quoted strings and numbers mean?
>
> A: eval(source, {'builtins': {}}) works, without also accidentally
> accepting OS commands as input.
>
> Note: Eval might surprise you if you mistype this idiom as: eval(source, {}).
>
> Note: This idiom makes sense of ordinary Python literals (such as 010, 0x8,
> 8.125e+0, and "\x45ight"). This idiom also correctly interprets simple
> literal expressions, such as 64**0.5.

That suggested FAQ is misleadingly incorrect as stated - we need help
rewording it.

/F correctly commented:
"eval" is never a good choice if you cannot trust the source; it's
trivial to do various denial-of-service attacks. See
http://effbot.org/zone/librarybook-core-eval.htm

Correspondingly, newbie me, I actually did copy the eval(source,
{'builtins': {}}) idiom into some code from that page without noticing
the comments re the cost of evaluating literal expressions like 'a' *
(10**9) , abuses of __subclass__ and mro(), etc.

But those objections miss the point.  Having had those troubles
explained to me now, I'm still leaving my code unchanged - it still
does what I mean.  That is,

eval(source, {'builtins': {}}) works enough like an evaluator of
literals to let you duck the work of writing that evaluator until you
need it.  Yagni.

That's useful, and likely an FAQ.  Anybody out there able to say
concisely what we really mean to say here?

Thanks in advance, Pat LaVarre

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
On 2006-11-09, Bjoern Schliessmann
<[EMAIL PROTECTED]> wrote:
> What about
>
> if color == red or blue or green:
> return 'primary'
>
>:)

The Inform 6* programming language supports the serial 'or' (and
'and') and looks just like that. The disadvantage is that the
usual binary logical operators must exist and are spelled
differently. (It uses C's '||' and '&&'.)

  if (color == red or blue or green && color.type == additive) {
  return 'primary';
  }

It also supports a switch statement syntax and semantics that
would fit nicely with Python.

  switch (action) {
Eat:
  print "Gulp! Delicious, but poisonous.";
  deadflag = 1;
Taste:
  print "You nibble at one of the corners. Yum!";
Attack:
  print "What did that mushroom ever to to you?";
default: 
  print "You can't do that to a mushroom.";
  }

There's no fall-through, and there's no syntax to enable it,
either.

In Python it would hypothetically be:

  switch action:
Eat:
  print "Gulp! Delicious, but poisonous."
  deadflag = True
Taste:
  print "You nibble at one of the corners. Yum!"
Attack:
  print "What did the mushroom ever to to you?"
default: 
  print "You can't do that to a mushroom."

I've often wanted a "Pythonic" Inform to Inform translator, so I
can leave out all the unecessary (), {} and ;.

 * Inform 6 is a language for implementing text adventures, not
   to be confused with the unrelated language Inform 7.

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread skip

Neil> The colon's main purpose seems to be to allow one-liners:

Neil> Easy to parse: if a < b: a += 1
Neil> Hard to parse if a < b a += 1

Skip> ... the ABC language designers found that indentation-based block
Skip> structure by itself wasn't enough to clue new users in about the
Skip> code structure.  Adding the colon at the end of the if/while/for
Skip> clause helped.

One final note.  Just because the colon isn't technically required in many
situations doesn't mean it's superfluous.  If all language designers cared
about was ease of parsing we'd probably all be programming in assembler,
sendmail, brainfuck.  Or, as the Zen of Python says: "Readability counts".

Skip

P.S.  I felt I just had to tie this into the thread on profanity somehow.
But notice that I didn't mention nazis or Hitler. ;-)

S


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


Re: announce: FAQs suggested

2006-11-10 Thread p . lavarre
> > > > http://effbot.org/pyfaq/suggest.htm
> > > FAQ: How do I say returns void in ctypes?
> > That's in the ctypes documentation, where it belongs.
>
> Thank you, before I never had found "Use None for void a function not
> returning anything" at:
> http://starship.python.net/crew/theller/ctypes/reference.html
>
> Now I see, that find corresponds to:
> http://docs.python.org/dev/lib/ctypes-foreign-functions.html
>
> I think this remains an FAQ, because I see void is missing from much
> more prominent places:
> http://docs.python.org/dev/lib/node452.html "Fundamental data types"
> http://docs.python.org/dev/lib/ctypes-return-types.html
>
> Finding a way to suggest improving those docs would help more than
> suggesting an FAQ, I agree.

I might have hit this brick wall while working offline, with nothing
but the doc to hand.

http://www.google.com/search?q=site%3Adocs.python.org+ctypes+void
now, if not before, does fetch that key phrase:
"Use None for void a function not returning anything"

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


Re: announce: FAQs suggested

2006-11-10 Thread Thomas Heller
[EMAIL PROTECTED] schrieb:
>> > > http://effbot.org/pyfaq/suggest.htm
>> > FAQ: How do I say returns void in ctypes?
>> That's in the ctypes documentation, where it belongs.
> 
> Thank you, before I never had found "Use None for void a function not
> returning anything" at:
> http://starship.python.net/crew/theller/ctypes/reference.html
> 
> Now I see, that find corresponds to:
> http://docs.python.org/dev/lib/ctypes-foreign-functions.html
> 
> I think this remains an FAQ, because I see void is missing from much
> more prominent places:
> http://docs.python.org/dev/lib/node452.html "Fundamental data types"

I don't think it belongs in the above section because 'void' is not a type.

> http://docs.python.org/dev/lib/ctypes-return-types.html

A note could probably be added to this section.

> Finding a way to suggest improving those docs would help more than
> suggesting an FAQ, I agree.
> 
>> > > > http://effbot.org/pyfaq/suggest.htm
>> > FAQ: How do I say unsigned char in ctypes?
>> That's in the ctypes documentation, where it belongs.
> 
> Yes and no.  The whole FAQ suggested was:
> 
> FAQ: How do I say unsigned char in ctypes?
> A: ctypes.c_ubyte
> ctypes doesn't define c_uchar. This actually is doc'ed, it's just
> annoying.
> 
> Per your kind correction above re void, I see we could also say:
> 
> FAQ: How do I say returns void in ctypes?
> A: restype = None
> ctypes doesn't define c_void. This actually is doc'ed obscurely, it's
> just irregular.


I don't think that this is irregular, see comment about void not being a type.

Thomas

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


Re: How to choose the right GUI toolkit ?

2006-11-10 Thread Nick Craig-Wood
Christophe <[EMAIL PROTECTED]> wrote:
>  ( and I must admit one of the reasons I avoid wx if possible, is because 
>  I don't use Gnome under Linux and the look and feel of wx applications 
>  is really horrible under KDE )

If you install the QT theme for GTK it all starts to look a lot nicer

Eg debian

ii  gtk2-engines-gtk-qt 0.7-1 theme engine using Qt for GTK+ 2.x

You get a control panel for GTK apps in the KDE control center also.

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


manual eggs downloads?

2006-11-10 Thread Harry George
"eggs" are wonderful for no-hassle get-all-the-dependencies.  However,
they can trigger hands-off downloads from various sites.  This is Bad
News for corporate environments in which every download is carefully
pre-approved.

A tarball with a subdirectory of "third_party" packages is ok.  A web
page simple listing the third party sites and the recommended
downloads is ok.  Automatically downloading is not ok.

Is there some way in the eggs mechanism to just get a list of the
proposed downloads, and let the user take the actions manually?

-- 
Harry George
PLM Engineering Architecture
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how is python not the same as java?

2006-11-10 Thread Jorge Vargas
On 9 Nov 2006 18:09:37 -0800, John Machin <[EMAIL PROTECTED]> wrote:
>
> Jorge Vargas wrote:
> > On 9 Nov 2006 16:44:40 -0800, gavino <[EMAIL PROTECTED]> wrote:
> > > both are interpreted oo langauges..
> > >
> > that is not correct java is compiled and the VM interprets the code
>
> ... and what do you think is in those pesky little .pyc files you may
> have noticed lying around on your hard disk?
>
can you open a commandline and start writting java code? no

the division between java (runtime) and javac is very explicit, the
compiler catches a lot of things, in python this is threaded in a
totally different way.

the pyc files are just a "catching" system for the common python
developer, as for the java developer the .class files are executable
code. In python noone runs the pyc files, the interpreter takes care
of this for you.

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


range syntax

2006-11-10 Thread Colin J. Williams
One of the little irritants of Python is that the range syntax is rather 
long-winded:
[Dbg]>>> range(3, 20, 6)
[3, 9, 15]
[Dbg]>>>
It would be nice if one could have something like 3:20:6.

I've just come across the r_class in numpy which doesn't go that far
but does provide a generalization of the above:
[Dbg]>>> r_[1:6:2, 6:8, (10, 11, 13), [20,25]]
array([ 1,  3,  5,  6,  7, 10, 11, 13, 20, 25])
[Dbg]>>>

Colin W.

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


Re: manual eggs downloads?

2006-11-10 Thread Jorge Vargas
On 11/10/06, Harry George <[EMAIL PROTECTED]> wrote:
> "eggs" are wonderful for no-hassle get-all-the-dependencies.  However,
> they can trigger hands-off downloads from various sites.  This is Bad
> News for corporate environments in which every download is carefully
> pre-approved.
>
> A tarball with a subdirectory of "third_party" packages is ok.  A web
> page simple listing the third party sites and the recommended
> downloads is ok.  Automatically downloading is not ok.
>
> Is there some way in the eggs mechanism to just get a list of the
> proposed downloads, and let the user take the actions manually?
>
that is not implemented yet, also you may want to take this to the
distutils-sig list.

what you can do is read the egg's setup.py for it's dependencies, but
this can turn into something like red hat's dep hell.

> --
> Harry George
> PLM Engineering Architecture
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Neil> The colon's main purpose seems to be to allow one-liners:
>
> Neil> Easy to parse: if a < b: a += 1
> Neil> Hard to parse if a < b a += 1
>
> No, as the note from Tim Peters referenced by Robert Kern
> pointed out earlier in this thread, the ABC language designers
> found that indentation-based block structure by itself wasn't
> enough to clue new users in about the code structure.  Adding
> the colon at the end of the if/while/for clause helped.

Thanks. I worded that lousily.

-- 
Neil Cerutti
The Minutemen are not tall in terms of height. --Dan Bonner
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to choose the right GUI toolkit ?

2006-11-10 Thread Dan Lenski

Eric Brunel wrote:
> On Thu, 09 Nov 2006 22:01:51 +0100, Dan Lenski <[EMAIL PROTECTED]> wrote:
> > Tk 8.4 appears to use native Win32 widgets under Cygwin and native
> > WinXP.
>
> It seems to depend on the widget type, and on what you call native... For
> example, tk menus are definitely the native ones; tk scrollbars are the
> native ones, but with the Win2k look (no XP look available yet); tk
> buttons do not seem to be the native ones, as they don't act like "normal"
> Windows buttons.

So, basically, Tk is actually embedding the native Win2k menus, but it
isn't actually embedding the native Win2k scrollbars... it's just
emulating their look and feel?

> > But it definitely doesn't use GTK widgets under Ubuntu with
> > Gnome desktop.
>
> You seem to imply that GTK is "native" on Linux. It isn't, as can be seen
> with the echoes of the "holy war" between Gnome and KDE that we often see
> around here. As an aside, I personnally work on Linux and don't even use
> any of these environments (both are too much Windows-like to my taste...).

I didn't imply that GTK widgets are "native" on Linux.  I implied that
GTK widgets native under Gnome ;-)  I was basing my assumption on an
earlier poster who said that Tk 8.x can use native widgets on all
supported platforms... so I assumed that under Gnome it should use GTK
widgets.

> > Is there a way to get it to do so?
>
> Not yet. But tcl/tk 8.5 will include the Tile extension including new
> themable widgets. See here:
> http://tktable.sourceforge.net/tile/screenshots/unix.html

Good to know!  I'm looking forward to 8.5.

Dan

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


Need help with Subversion bindings

2006-11-10 Thread paul . keating
I'm trying to write a basic Subversion client because I need to
integrate Subversion with a product that keeps source code in a
database (so it has no notion of "working copy").

I have tried to translate the simple C examples in Garrett Rooney's
book into Python, but the very clever SWIG stuff has made the Python
access so different from the corresponding C that I can't do it.

Example: I can create an apr array but I have no idea how to insert
something into it. In C you use APR_ARRAY_PUSH. In Python that doesn't
exist. Another example: I can create an apr hash, but I can't work out
how to look inside it. In C it is a struct with members count and max
etc. In Python it is a class  that doesn't remotely resemble the
struct.

Has anyone got a bare-bones bit of working Python that shows how to do
(say) an add or a checkout? There is an example of status in the
Subversion book but it's a toy: it doesn't show how you create an
authentication callback so it will only work locally.

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


Re: announce: FAQs suggested

2006-11-10 Thread p . lavarre
Thanks again for making time to comment - insights into the perspective
of the author are invaluable.  But if by chance you have time to
continue:

> > > http://effbot.org/pyfaq/suggest.htm
> > http://docs.python.org/dev/lib/ctypes-return-types.html
> A note could probably be added to this section.

Good.  Next: Is there a place on the web where we can log that
conclusion to inspire its resolution?

> > void is missing from
> > http://docs.python.org/dev/lib/node452.html "Fundamental data types"
>
> 'void' is not a type.

Help, lost me?

1)

http://msdn.microsoft.com/library/en-us/winprog/winprog/windows_data_types.asp
thinks void is a type.  That's what I was reading in parallel with the
ctypes doc, as I tried to make ctypes and the Windows kernel32.dll talk
to each other.

2)

void foo(int ii) { ii = ii; }
is a C way of saying the return type of foo is the type void, in casual
conversation among programmers.

I mean, suppose I ask you what is the return type of foo?  That is,
suppose I ask you what its ctypes restype should be?

We can answer like a C lawyer, tell me that my question is malformed,
tell me that foo returns no result, tell me that foo has no return
type, and claim that thus obviously its restype should be None, despite
the widespread string Api convention of distinguishing None from
consciously empty and not using None to mean consciously empty.

Or informally we can say the return type of foo is the type void,
because void is a type, and ctypes uses Python None to express the idea
of the void type, without adding the name c_void to tell you this.

> I don't think that this is irregular,

Have I clearly explained why defining no c_void appears irregular to me
the C-literate Python-illiterate newbie?

Maybe also relevant is my Jvm/Jni background - I'm used to seeing void
expressed there as a type, not much different than int.

Was my newbie confusion here so very unique, or do these two FAQ's
exist:
FAQ: How do I say unsigned char in ctypes?
FAQ: How do I say returns void in ctypes?

Or can we hope to improve any of:
http://starship.python.net/crew/theller/ctypes/tutorial.html
http://docs.python.org/dev/lib/node452.html "Fundamental data types"
http://docs.python.org/dev/lib/ctypes-return-types.html
?

> > That's in the ctypes documentation, where it belongs.

Thanks again for that claim.

Now also I see that returns void is defined by:
http://starship.python.net/crew/theller/ctypes/reference.html
although not by:
http://starship.python.net/crew/theller/ctypes/tutorial.html

Once upon a time, I only knew the tutorial existed, not the reference.
The tutorial includes one well-buried mention of "see the reference
manual for details", but doesn't link to what reference manual is
meant.

I remember, as a newbie, I was slow to accept that Google
site:docs.python.org shouldn't be the only thing I read to understand
the ctypes of 2.5 Python.

> ...

Thanks all for the education.

I'm clear on this now, and delighted to remove the fixme: undoc'ed
comments from my source.

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


newbee I have an object how to check what's his class?

2006-11-10 Thread consternation
I can't find  neither in tutorial nor with google It's all about 
isinstance,  or  __class__.
How to test that an object is an instance of my X class??
Do I have this problems because I stre my objects in a dict?

I wrote a class X like this :
class X(object):

 def __init__(self,name):
   self.name=name
   self.val=[]
   self.description ="class X contains : "

def __repr__(self):
 for i in range(len(self.val)):
description+=i
 return self.description


In class Y I create my X objects and put them into a dict

  print "\nTEST"
.for (i,v) in self.mem.items():
  print v

The objects are printed out the way I specified in  __repr__, so I know it's 
an object of X class.
No I want to put in the dict some other objects of class Z,K
When I get the value fom dict I have to distinguish them somehow to handle 
them latr in programm.
I thouth about isinstanceof  - it doesn't work. I did some tests, but I 
don't understand the answers:
Why python claims it's a list, but still print's it like X class
#in Y class:
print isinstance(v,X)  False
print v.__class__.__name__ list


And adding print in  X class i see
 def __repr__(self):
print self.__class__-->[__main__.Complex

Could someone explain this to me?
thank you


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


Re: How to choose the right GUI toolkit ?

2006-11-10 Thread vdicarlo
> I highly recommend wxPython. It's very mature, full-featured, and
> portable, and fairly easy to learn as well.

I am also a Python beginner thinking about what GUI toolkit to use, and
the availability of a free video screencast series on installing and
using wxpython at showmedo.com is making me want to go that way. I
viewed their introduction to Python resources and wished I had found it
first.

The wxpython series is at http://tinyurl.com/yggean

Vincent

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


Re: newbee I have an object how to check what's his class?

2006-11-10 Thread paul . keating
This doesn't answer your whole post because it asked a lot of
questions. But as to finding out whether something is an instance of a
class:

class X(object):
  # ... defined as in your post

>>> x = X('Fred')
>>> x
class X contains:
>>> type(x) is X
True
>>> isinstance(x,X)
True
>>> x.__class__.__name__
'X'

Now for subclasses:

class Y(X):
extrastuffinY = 1

>>> y = Y('Joe')
>>> type(y) is X
False
>>> isinstance(y,X)
True


consternation:

> I can't find  neither in tutorial nor with google It's all about
> isinstance,  or  __class__.
> How to test that an object is an instance of my X class??

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


Re: to Doctest as SystemExit is to Python

2006-11-10 Thread p . lavarre
(((I thought I had sent this reply already, Google says No.)))

> > Can I somehow tell doctest that it's time to quit?
> > ... doctest redefines ... SystemExit ...
>
> Hit Ctrl-C. Or raise a KeyboardInterrupt:

Yes!  Thank you!!!  I see now,

Doctest exactly reverses the python -i experience:

doctest exits quietly if I raise KeyboardInterrupt.
doctest catches SystemExit and prints the traceback.

python -i exits quietly if I raise SystemExit.
python -i catches KeyboardInterrupt and prints the traceback.

Of course, to make the doctest work as sketched, I had to strip the
trailing blanks that my browser introduced and I had to expect
tracebacks for raise Exception and raise SystemExit, e.g.:

>>> import sys
>>> sys.exit()
Traceback (most recent call last):
  ...
SystemExit
>>>

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


Re: Newb: installing Jython on Windows XP ...

2006-11-10 Thread [EMAIL PROTECTED]

I haven't installed on cygwin or windows XP myself but you should be
using "java jython-21". Note that there are two class files
"jython-21.class" and "jython_21.class". Also make sure that the
CLASSPATH includes the directory that has these two class files.

Raghu.

donkeyboy wrote:
> All,
>
> I'm having issues installing Jython on Windows XP. I've looked on the
> web and this newsgroup but to no avail. Any suggestions? The shell
> listing is below:
>
> NB I've got Cygwin installed, hence the Unix 'ls' on a Windows box
>
> C:\>cd Jython
>
> C:\Jython>ls
> jython_21.class
>
> C:\Jython>ls "c:\Program Files\Java\jdk1.5.0_09\bin\java.exe"
> c:\Program Files\Java\jdk1.5.0_09\bin\java.exe
>
> C:\Jython>"c:\Program Files\Java\jdk1.5.0_09\bin\java.exe" jython_21
> Exception in thread "main" java.lang.NoClassDefFoundError: jython_21
>
> C:\Jython>"c:\Program Files\Java\jdk1.5.0_09\bin\java.exe" jython-21
> Exception in thread "main" java.lang.NoClassDefFoundError: jython-21
> 
> Any help would be of great use!!!

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Bjoern Schliessmann
Neil Cerutti wrote:
> On 2006-11-09, Bjoern Schliessmann

>> if color == red or blue or green:
>> return 'primary'
>>
>>:)
 
> The Inform 6* programming language supports the serial 'or' (and
> 'and') and looks just like that.

Python also supports it.

> The disadvantage is that the usual binary logical operators must
> exist and are spelled differently. (It uses C's '||' and '&&'.)

Do they have to be spelled differently? In Python, they don't have
to.

Regards,


Björn

-- 
BOFH excuse #115:

your keyboard's space bar is generating spurious keycodes.

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


path.py and directory naming: trailing slash automatic?

2006-11-10 Thread [EMAIL PROTECTED]
Hi,

I'm a big fan of path.py. One thing that I think is a good idea is for
directories to automatically have a slash appended to them if it is not
automatically added. Eg:

from path import path

dir = path('/some/dir')

x = dir + "file" # should yield /some/dir/file


I emailed the author of path.py but I think he must be extremely busy.
It took him 2-3 weeks to answer my first email and it's been longer
than that for the one I sent regarding this.

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> P.S.  I felt I just had to tie this into the thread on profanity somehow.
> But notice that I didn't mention nazis or Hitler. ;-)

You did it just now!

-- 
Robert Kern

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

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


Getting externally-facing IP address?

2006-11-10 Thread Michael B. Trausch




Hello,

Every programming example that I have seen thus far shows simple server code and how to bind to a socket--however, every example binds to the localhost address.  What I am wondering is this:  Is there a clean way to get the networked IP address of the machine the code is running on?  For example, my laptop's IP address is 192.168.0.101, and I want to bind a server to that address.  Is there a clean way of doing so that will work, for example, when I move the code to my server (which obviously doesn't have the same IP address)?

Thanks in advance.

    -- Mike




--



Michael B. Trausch


[EMAIL PROTECTED]




Phone: (404) 592-5746


Jabber IM: [EMAIL PROTECTED]




Demand Freedom!  Use open and free protocols, standards, and software!





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

Re: Getting externally-facing IP address?

2006-11-10 Thread Tim Williams
On 10/11/06, Michael B. Trausch <[EMAIL PROTECTED]> wrote:



  
  



Every programming example that I have seen thus far shows simple server code and how to bind to a socket--however, every example binds to the localhost address.  What I am wondering is this:  Is there a clean way to get the networked IP address of the machine the code is running on?  For example, my laptop's IP address is 
192.168.0.101, and I want to bind a server to that address.  Is there a clean way of doing so that will work, for example, when I move the code to my server (which obviously doesn't have the same IP address)?


Try  using 0.0.0.0  as the IP address,  or possibly giving IP address at all.   HTH :)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Getting externally-facing IP address?

2006-11-10 Thread Tim Williams
On 10/11/06, Tim Williams <[EMAIL PROTECTED]> wrote:
>
>
> On 10/11/06, Michael B. Trausch <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > Every programming example that I have seen thus far shows simple server
> code and how to bind to a socket--however, every example binds to the
> localhost address.  What I am wondering is this:  Is there a clean way to
> get the networked IP address of the machine the code is running on?  For
> example, my laptop's IP address is 192.168.0.101, and I want to bind a
> server to that address.  Is there a clean way of doing so that will work,
> for example, when I move the code to my server (which obviously doesn't have
> the same IP address)?
> >
> >
>
> Try  using 0.0.0.0  as the IP address,  or possibly giving IP address at
> all.
>
> HTH :)
>
>

Correction:

-> or possibly giving *no* IP address at
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Tony Nelson
In article <[EMAIL PROTECTED]>,
 Bjoern Schliessmann <[EMAIL PROTECTED]> 
 wrote:

> Michael Hobbs wrote:
> 
> > That is, assume that the expression ends at the colon, not at the
> > newline. That would make this type of statement possible:
> > if color == red or
> >   color == blue or
> >   color == green:
> > return 'primary'
> > Right now, such a statement would have to be spelled thus:
> > if color == red or \
> >   color == blue or \
> >   color == green:
> > return 'primary'
> > or
> > if (color == red or
> >   color == blue or
> >   color == green):
> > return 'primary'
> 
> What about
> 
> if color == red or blue or green:
> return 'primary'

What about

if color in [red, blue, green]:
return 'primary'

TonyN.:'[EMAIL PROTECTED]
  '  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: range syntax

2006-11-10 Thread Roberto Bonvallet
Colin J. Williams wrote:
> One of the little irritants of Python is that the range syntax is rather 
> long-winded:
> [Dbg]>>> range(3, 20, 6)
> [3, 9, 15]
> [Dbg]>>>
> It would be nice if one could have something like 3:20:6.

In that case, how would the parser know which colon terminates the
'for' in the following example:

for i in 2:3:4:
...

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


Re: how is python not the same as java?

2006-11-10 Thread Boris Borcic
Jorge Vargas wrote:
> can you open a commandline and start writting java code? 

beanshell, iirc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Michael Hobbs
Ben Finney wrote:
> Please don't hide your new thread as a reply to an existing, unrelated
> message. Start a new message if your message isn't actually a reply.
>
>   
My apologies. My email client was apparently hiding some important 
headers from me.

>> The colon that divides the statement therefore seems redundant. The
>> colon could continue to be used for single-line statements:
>> if self.hungry: self.eat()
>> 
>
> Why have two different syntaxes for the same statement?
>
>   
Why am I allowed separate statements with semi-colons in addition to 
newlines? Why have triple-quoted long strings in addition to 
single-quoted short strings? Why do I have to type backslash to continue 
a line, except when I'm currently inside parens, brackets, or braces?

The answer is that it's a matter of convenience for the most common 
case, with some exceptions allowed for the exceptional cases.

>> I think the colon could be omitted from every type of compound
>> statement: 'if', 'for', 'def', 'class', whatever. Am I missing
>> anything?
>> 
>
> A use case. What problem is being solved by introducing this
> inconsistency?
>   
The same problem that is solved by not having to type parens around the 
'if' conditional, a la C and its derivatives. That is, it's unnecessary 
typing to no good advantage, IMHO. I was coding in Ruby for several 
months and got very comfortable with just typing the if conditional and 
hitting return, without any extra syntax. When I came back to Python, I 
found that I felt annoyed every time I typed the colon, since it 
obviously isn't required. The FAQ says that the colon increases 
readability, but I'm skeptical. The indentation seems to provide more 
than enough of a visual clue as to where the if conditional ends.

As far as using the FAQ as gospel, the FAQ also provides arguments for 
why there isn't a with statement or a switch statement. The with 
statement has already been implemented in 2.5 and there's a PEP to 
implement switch (3103).

- Mike

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> On 2006-11-09, Bjoern Schliessmann
>
>>> if color == red or blue or green:
>>> return 'primary'
>>>
>>>:)
>  
>> The Inform 6* programming language supports the serial 'or' (and
>> 'and') and looks just like that.
>
> Python also supports it.
>
>> The disadvantage is that the usual binary logical operators
>> must exist and are spelled differently. (It uses C's '||' and
>> '&&'.)
>
> Do they have to be spelled differently? In Python, they don't
> have to.

That kind of answers your question. ;-)

That is cool. I was unaware of the feature; until just now I
thought Inform was had innovated the syntax!

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


Re: announce: FAQs suggested

2006-11-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

>>> http://docs.python.org/dev/lib/ctypes-return-types.html
 >>
>> A note could probably be added to this section.
> 
> Good.  Next: Is there a place on the web where we can log that
> conclusion to inspire its resolution?

ideally, you'd click "add a comment" on the relevant library reference 
page, just like you did for the FAQ, but we're not quite there yet.  in 
the meantime, see this page:

 http://docs.python.org/tut/about.html



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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, Robert Kern <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>> P.S.  I felt I just had to tie this into the thread on
>> profanity somehow. But notice that I didn't mention nazis or
>> Hitler. ;-)
>
> You did it just now!

I hate Godwin's Law Nazis.

;-)

-- 
Neil Cerutti
Scouts are saving aluminum cans, bottles, and other items to be
recycled. Proceeds will be used to cripple children. --Church Bulletin
Blooper
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbee I have an object how to check what's his class?

2006-11-10 Thread consternation
Thank You for reply but 
I found solution suggested by You in a tutorial yesterday. For some reason
it doesn't work in my case.

code:
#mem-dictionary in Y class for storing objects
#Y doesn't inherit from X
  for (i,v) in self.mem.items(): 
  print " isinstance(x,X)"
  print  isinstance(v,X)
  print "type(x) is X"
  print type(v) is X
  print v.__class__.__name__
  print v.__class__

result:
isinstance(x,X)
False
type(x) is X
False

list

Well I can handle my problem. I will give an extra field in class with it's
name. But I thought that when a language has tools to learn a class of an
object one should use it. 


[EMAIL PROTECTED] wrote:

> This doesn't answer your whole post because it asked a lot of
> questions. But as to finding out whether something is an instance of a
> class:
> 
> class X(object):
>   # ... defined as in your post
> 
 x = X('Fred')
 x
> class X contains:
 type(x) is X
> True
 isinstance(x,X)
> True
 x.__class__.__name__
> 'X'
> 
> Now for subclasses:
> 
> class Y(X):
> extrastuffinY = 1
> 
 y = Y('Joe')
 type(y) is X
> False
 isinstance(y,X)
> True
> 
> 
> consternation:
> 
>> I can't find  neither in tutorial nor with google It's all about
>> isinstance,  or  __class__.
>> How to test that an object is an instance of my X class??

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


newbie: minidom

2006-11-10 Thread Danny Scalenotti
I'm not able to get out of this ...


from  xml.dom.minidom import getDOMImplementation

impl = getDOMImplementation()  // default UTF-8
doc = impl.createDocument(None, "test",None)
root = doc.documentElement
root.setAttribute('myattrib', '5')

print root.toxml()


I obtain





why not this?





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


SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
no matter where I place this imported file,the statement after it in
the main program gets a syntax error, regardless of the syntax.

I think I may have changed something in this file, but I'm stuck.  Can
anyone help?

#!/usr/local/bin/python
# Copyright 2004 by Stephen Masterman

#Change the db connection details here.


import MySQLdb




def connect():


   return =  MySQLdb.connect (host = "db91x..com",
   user = "",
passwd = "x",
db = "homebase_zingers"
   );

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


Re: path.py and directory naming: trailing slash automatic?

2006-11-10 Thread Max Erickson
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I'm a big fan of path.py. One thing that I think is a good idea
> is for directories to automatically have a slash appended to them
> if it is not automatically added. Eg:
> 
> from path import path
> 
> dir = path('/some/dir')
> 
> x = dir + "file" # should yield /some/dir/file
> 
> 
> I emailed the author of path.py but I think he must be extremely
> busy. It took him 2-3 weeks to answer my first email and it's
> been longer than that for the one I sent regarding this.
> 

just use '/' if that is what you want:

>>> from path import path
>>> d=path('/some/dir')
>>> d / "file"
path(u'/some/dir\\file')
>>> 

If + also did that, it would be more difficult to change the extension 
when renaming a file or whatever.

max

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Roberto Bonvallet
ronrsr wrote:
>   return =  MySQLdb.connect (host = "db91x..com",
>   user = "",
>passwd = "x",
>db = "homebase_zingers"
>   );

return is a reserved keyword.  You cannot have a variable with that name.

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
here's some of the surrounding code from the main program:



querystring = querystring + " ORDER BY keywords ";
#SQL
import zsql





zc = zsql.connect()

print("return from open")



zq = zc.query(querystring).dictresult()

ronrsr wrote:
> no matter where I place this imported file,the statement after it in
> the main program gets a syntax error, regardless of the syntax.
>
> I think I may have changed something in this file, but I'm stuck.  Can
> anyone help?
>
> #!/usr/local/bin/python
> # Copyright 2004 by Stephen Masterman
>
> #Change the db connection details here.
>
>
> import MySQLdb
>
>
>
>
> def connect():
>
>
>return =  MySQLdb.connect (host = "db91x..com",
>user = "",
> passwd = "x",
>   db = "homebase_zingers"
>);

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, ronrsr wrote:

> def connect():
> 
> 
>return =  MySQLdb.connect (host = "db91x..com",
^

You can't assign to a keyword.  Just leave this ``=`` out.

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
thanks for the speedy answer.  what i meant was:

 return   MySQLdb.connect (host = "db91b.pair.com",
   user = "homebase",
passwd = "Newspaper2",
db = "homebase_zingers"
   );


but even when I have that, I still get the same error.

bests, 

-rsr-

ronrsr wrote:
> here's some of t

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


Re: range syntax

2006-11-10 Thread Fredrik Lundh
Colin J. Williams wrote:

> One of the little irritants of Python is that the range syntax is rather 
> long-winded:
> [Dbg]>>> range(3, 20, 6)
> [3, 9, 15]
> [Dbg]>>>
> It would be nice if one could have something like 3:20:6.

if you find yourself using range a lot, maybe you should check if you 
couldn't use custom iterators more often.

or use the R helper:

 >>> R[3:20:6]
[3, 9, 15]
 >>> R[:20]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
 >>> R[0:20:2]
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
 >>> R[1:20:2]
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

where R is defined as:

 >>> class R:
... def __getitem__(self, slice):
... return range(*slice.indices(slice.stop))
...
 >>> R = R()



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


handling many default values

2006-11-10 Thread Alan G Isaac
My class MyClass reuses many default parameters
with a small number of changes in each instance.
For various reasons I decided to put all the
parameters in a separate Params class, instances
of which reset the default values based on keyword
arguments, like this:

class Params:
 def __init__(self,**kwargs):
 #set lots of default values
 ...
 #set the deviations from defaults
 self.__dict__.update(kwargs)

Is this a reasonable approach overall?
(Including the last line.)

Thanks,
Alan Isaac
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbee I have an object how to check what's his class?

2006-11-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, consternation wrote:

> Thank You for reply but 
> I found solution suggested by You in a tutorial yesterday. For some reason
> it doesn't work in my case.
> 
> code:
> #mem-dictionary in Y class for storing objects
> #Y doesn't inherit from X
>   for (i,v) in self.mem.items(): 
>   print " isinstance(x,X)"
>   print  isinstance(v,X)
>   print "type(x) is X"
>   print type(v) is X
>   print v.__class__.__name__
>   print v.__class__
> 
> result:
> isinstance(x,X)
> False
> type(x) is X
> False
> 
> list

Define "doesn't work".  Obviously lists are not instances of your `X`
class.  So where's the problem?  What did you expect and why?

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Roberto Bonvallet
ronrsr wrote:
> thanks for the speedy answer.  what i meant was:
> 
> return   MySQLdb.connect (host = "db91b.pair.com",
>   user = "homebase",
>passwd = "Newspaper2",
>db = "homebase_zingers"
>   );
> 
> 
> but even when I have that, I still get the same error.

Could you please copy and paste the exact code that is triggering the
error, and the exact error message?

(BTW, in Python you don't need to end your statements with a semi-colon)
-- 
Roberto Bonvallet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
the exact code that is triggering the error message is:

zc = zsql.connect()


exact error message:  SyntaxError:  Invalid Syntax


but any statement that follows the import statement will trigger it.

bests,

r-sr-




Roberto Bonvallet wrote:
> ronrsr wrote:
> > thanks for the speedy answer.  what i meant was:
> >

> Could you please copy and paste the exact code that is triggering the
> error, and the exact error message?
>
> (BTW, in Python you don't need to end your statements with a semi-colon)
> -- 
> Roberto Bonvallet

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


Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread ronrsr
the syntax error comes in the main program, in any line that follows
the import statement.


ronrsr wrote:
> the exact code that is triggering the error message is:
>
> zc = zsql.connect()
>
>
> exact error message:  SyntaxError:  Invalid Syntax
>
>
> but any statement that follows the import statement will trigger it.
>
> bests,
>
> r-sr-
>
>
>
>
> Roberto Bonvallet wrote:
> > ronrsr wrote:
> > > thanks for the speedy answer.  what i meant was:
> > >
>
> > Could you please copy and paste the exact code that is triggering the
> > error, and the exact error message?
> >
> > (BTW, in Python you don't need to end your statements with a semi-colon)
> > -- 
> > Roberto Bonvallet

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Bjoern Schliessmann wrote:

> Neil Cerutti wrote:
>> On 2006-11-09, Bjoern Schliessmann
> 
>>> if color == red or blue or green:
>>> return 'primary'
>>>
>>>:)
>  
>> The Inform 6* programming language supports the serial 'or' (and
>> 'and') and looks just like that.
> 
> Python also supports it.

No it doesn't -- look again at the example given above.  It's legal syntax
in Python but doesn't have the semantics implied by the example.

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


Re: Need help with Subversion bindings

2006-11-10 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb:
> I'm trying to write a basic Subversion client because I need to
> integrate Subversion with a product that keeps source code in a
> database (so it has no notion of "working copy").
> 
> I have tried to translate the simple C examples in Garrett Rooney's
> book into Python, but the very clever SWIG stuff has made the Python
> access so different from the corresponding C that I can't do it.
> 
> Example: I can create an apr array but I have no idea how to insert
> something into it. In C you use APR_ARRAY_PUSH. In Python that doesn't
> exist. Another example: I can create an apr hash, but I can't work out
> how to look inside it. In C it is a struct with members count and max
> etc. In Python it is a class  that doesn't remotely resemble the
> struct.
> 
> Has anyone got a bare-bones bit of working Python that shows how to do
> (say) an add or a checkout? There is an example of status in the
> Subversion book but it's a toy: it doesn't show how you create an
> authentication callback so it will only work locally.

The nice python-ide eric3, written in python itself, features a 
subversion interface. Maybe you can take a look at that?

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread skip
Robert> [EMAIL PROTECTED] wrote:
>> P.S.  I felt I just had to tie this into the thread on profanity somehow.
>> But notice that I didn't mention nazis or Hitler. ;-)

Robert> You did it just now!

Hence the smiley. ;-)

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


Re: RAW network programming under Windows

2006-11-10 Thread billie
sturlamolden wrote:

> You can try to install "Windows Services for Unix 3.5" (aka SFU 3.5).
> It transforms your Windows into a certified UNIX (not just a Unix
> clone). SFU 3.5 has a full BSD socket API (derived from OpenBSD), not
> just Winsock. As the POSIX subsystem in SFU 3.5 is not layered on top
> of the Win32 subsystem, but talks directly to the NT kernel,
> restrictions in Winsock should not affect the BSD sockets in SFU 3.5.
> This behaviour is different from e.g. Cygwin, where the "Unix APIs" are
> layered on top of the Win32 subsystem.

It isn't exactly what I'm searching for but thanks anyway.

> In any case, I hope you are aware that spoofing IP packets gives you
> bad karma.

No problem about it. I'm just a lover of low-level network programming.
=)

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


Re: comparing Unicode and string

2006-11-10 Thread Steve Holden
Neil Cerutti wrote:
> On 2006-11-10, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Marc 'BlackJack' Rintsch wrote:
>>> Why?  Python strings are *byte strings* and bytes have values in the range
>>> 0..255.  Why would you restrict them to ASCII only?
>> Because getting an exception when comparing a string with a unicode
>> string is irritating.
>>
>> But I don't insist on my PEP. The example just shows just
>> another pitfall with Unicode and why I'll advise to any
>> beginner: Never write text constants that contain non-ascii
>> chars as simple strings, always make them Unicode strings by
>> prepending the "u".
> 
> That doesn't do any good if you aren't writing them in unicode
> code points, though.
> 
You tell the interpreter what encoding your source code is in. It then 
knows precisely how to decode your string literals into Unicode. How do 
you write things in "Unicode code points"?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: newbee I have an object how to check what's his class?

2006-11-10 Thread Jerry Hill
On 11/10/06, consternation <[EMAIL PROTECTED]> wrote:
result:isinstance(x,X)Falsetype(x) is XFalselistI think you need to show us more of your code.  Your variable, v, is not of type X in this example.  Instead, it is of type list.  What is 
self.mem.items()?  It isn't a dictionary like your comment seems to imply, or you would get a TypeError on that line because dictionaries aren't callable.Please give us enough sample code that we can actually run it and see what you're seeing.
-- Jerry
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Steve Holden
Michael Hobbs wrote:
> Ben Finney wrote:
[...]
>> A use case. What problem is being solved by introducing this
>> inconsistency?
>>   
> The same problem that is solved by not having to type parens around the 
> 'if' conditional, a la C and its derivatives. That is, it's unnecessary 
> typing to no good advantage, IMHO. I was coding in Ruby for several 
> months and got very comfortable with just typing the if conditional and 
> hitting return, without any extra syntax. When I came back to Python, I 
> found that I felt annoyed every time I typed the colon, since it 
> obviously isn't required. The FAQ says that the colon increases 
> readability, but I'm skeptical. The indentation seems to provide more 
> than enough of a visual clue as to where the if conditional ends.
> 
So you'd also like us to shorten the names of the builtins and the the 
keywords? Why bother with "def" when we could just use "d", "class" when 
we could just use "c"? Or *does* readability matter to some degree?

> As far as using the FAQ as gospel, the FAQ also provides arguments for 
> why there isn't a with statement or a switch statement. The with 
> statement has already been implemented in 2.5 and there's a PEP to 
> implement switch (3103).
> 
But the "with" statement isn't the one that "with" was reserved for in 
the FAQ, which is really talking about the same kind of "with" statement 
that Visual Basic uses: an implied left operand for unary "." operations.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Steve Holden
Bjoern Schliessmann wrote:
> Michael Hobbs wrote:
> 
>> That is, assume that the expression ends at the colon, not at the
>> newline. That would make this type of statement possible:
>> if color == red or
>>   color == blue or
>>   color == green:
>> return 'primary'
>> Right now, such a statement would have to be spelled thus:
>> if color == red or \
>>   color == blue or \
>>   color == green:
>> return 'primary'
>> or
>> if (color == red or
>>   color == blue or
>>   color == green):
>> return 'primary'
> 
> What about
> 
> if color == red or blue or green:
> return 'primary'
> 
> :)
> 
> Really, I think it'd be more mess to let the if statement's end only
> depend on ":". I think there could arise situations that are messy
> to debug. If I need multiple lines I prefer the parentheses.
> 
I still prefer

   if color in (red, blue, green):
 ...

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: newbie: minidom

2006-11-10 Thread Fredrik Lundh
Danny Scalenotti wrote:

> I'm not able to get out of this ...
> 
> from  xml.dom.minidom import getDOMImplementation
> 
> impl = getDOMImplementation()  // default UTF-8
> doc = impl.createDocument(None, "test",None)
> root = doc.documentElement
> root.setAttribute('myattrib', '5')
> 
> print root.toxml()
> 
> 
> I obtain
> 
> 
> 
> why not this?
> 
> 
> 

why?  the documents are equivalent, and any XML application that 
requires an explicit UTF-8 encoding declaration is broken.



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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Ron Adam
Michael Hobbs wrote:

> The same problem that is solved by not having to type parens around the 
> 'if' conditional, a la C and its derivatives. That is, it's unnecessary 
> typing to no good advantage, IMHO. I was coding in Ruby for several 
> months and got very comfortable with just typing the if conditional and 
> hitting return, without any extra syntax. When I came back to Python, I 
> found that I felt annoyed every time I typed the colon, since it 
> obviously isn't required. The FAQ says that the colon increases 
> readability, but I'm skeptical. The indentation seems to provide more 
> than enough of a visual clue as to where the if conditional ends.

I'm not sure why '\'s are required to do multi-line before the colon.  Possibly 
because if multi-line conditional expressions are the norm, dropping a colon 
could result in valid (but incorrect) code instead of an error?

The faq also pointed out a technical reason for requiring the colon.  It makes 
the underlying parser much easier to write and maintain.  This shouldn't be 
taken to lightly in my opinion, because a simpler easer to maintain and more 
reliable python parser means development time can be spent improving the 
language in other areas instead of fixing parsing problems every time a new 
feature is added that might be used in a conditional expression.

Cheers,
Ron










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


Re: range syntax

2006-11-10 Thread Antoon Pardon
On 2006-11-10, Roberto Bonvallet <[EMAIL PROTECTED]> wrote:
> Colin J. Williams wrote:
>> One of the little irritants of Python is that the range syntax is rather 
>> long-winded:
>> [Dbg]>>> range(3, 20, 6)
>> [3, 9, 15]
>> [Dbg]>>>
>> It would be nice if one could have something like 3:20:6.
>
> In that case, how would the parser know which colon terminates the
> 'for' in the following example:
>
> for i in 2:3:4:
>   ...

By the programmer using parenthesis. Like

  for i in (2:3):
 ...


Just as you are supposed to use parthesis if you
want a tuple as a function argument although normally
a comma is enough to form a tuple.

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


Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Michael Hobbs
Steve Holden wrote:
> Michael Hobbs wrote:
>   
>> Ben Finney wrote:
>> 
> [...]
>   
>>> A use case. What problem is being solved by introducing this
>>> inconsistency?
>>>   
>>>   
>> The same problem that is solved by not having to type parens around the 
>> 'if' conditional, a la C and its derivatives. That is, it's unnecessary 
>> typing to no good advantage, IMHO. I was coding in Ruby for several 
>> months and got very comfortable with just typing the if conditional and 
>> hitting return, without any extra syntax. When I came back to Python, I 
>> found that I felt annoyed every time I typed the colon, since it 
>> obviously isn't required. The FAQ says that the colon increases 
>> readability, but I'm skeptical. The indentation seems to provide more 
>> than enough of a visual clue as to where the if conditional ends.
>>
>> 
> So you'd also like us to shorten the names of the builtins and the the 
> keywords? Why bother with "def" when we could just use "d", "class" when 
> we could just use "c"? Or *does* readability matter to some degree?
>
>   
Like I said in that paragraph, removing the colon wouldn't seem to 
degrade readability *that much*, if at all. Personally, even though I 
find typing the colon to be a small annoyance, that annoyance exceeds 
any improvement to readability that it might provide; especially 
considering that indentation sticks out like a big red sign saying the 
code block starts "HERE, HERE, HERE".

>> As far as using the FAQ as gospel, the FAQ also provides arguments for 
>> why there isn't a with statement or a switch statement. The with 
>> statement has already been implemented in 2.5 and there's a PEP to 
>> implement switch (3103).
>>
>> 
> But the "with" statement isn't the one that "with" was reserved for in 
> the FAQ, which is really talking about the same kind of "with" statement 
> that Visual Basic uses: an implied left operand for unary "." operations.
>
>   
Yeah, okay, I didn't read through the details of the PEP. I picked a bad 
example to illustrate a point that is still true. The FAQ also tries to 
argue that it's a Good Thing that join() is a string method, not a list 
method. It also tries to argue that there's a good reason that lists are 
different than tuples. I don't think it would surprising that many 
Python developers don't really buy those arguments either.

- Mike


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


  1   2   >