Re: Detect string has non-ASCII chars without checking each char?

2010-08-22 Thread Michel Claveau - MVP
Hi! Another way : # -*- coding: utf-8 -*- import unicodedata def test_ascii(struni): strasc=unicodedata.normalize('NFD', struni).encode('ascii','replace') if len(struni)==len(strasc): return True else: return False print test_ascii(u"abcde") prin

Re: Python "why" questions

2010-08-22 Thread Russ P.
On Aug 21, 1:33 am, Steven D'Aprano wrote: > On Fri, 20 Aug 2010 11:01:42 -0700, Russ P. wrote: > > Most programmers probably never use vectors and matrices, so they don't > > care about the inconsistency with standard mathematical notation. > > Perhaps you should ask the numpy programmers what th

Re: Problem checking an existing browser cookie

2010-08-22 Thread Νίκος
On 16 Αύγ, 14:31, Peter Otten <__pete...@web.de> wrote: > Νίκος wrote: > > # initializecookie > >cookie=Cookie.SimpleCookie() > >cookie.load( os.environ.get('HTTP_COOKIE', '') ) > > mycookie =cookie.get('visitor') > > > if ( mycookie and mycookie.value != 'nikos' ) or re.search( r'(cyta| > > yandex

Re: Python "why" questions

2010-08-22 Thread Chris Rebert
On Sun, Aug 22, 2010 at 12:23 AM, Russ P. wrote: > On Aug 21, 1:33 am, Steven D'Aprano cybersource.com.au> wrote: >> On Fri, 20 Aug 2010 11:01:42 -0700, Russ P. wrote: >> > Most programmers probably never use vectors and matrices, so they don't >> > care about the inconsistency with standard math

freq function

2010-08-22 Thread Dirk Nachbar
Here is a function which takes any list and creates a freq table, which can be printed unsorted, sorted by cases or items. It's supposed to mirror the proc freq in SAS. Dirk def freq(seq,order='unsorted',prin=True): #order can be unsorted, cases, items freq={} for s in seq: i

Re: freq function

2010-08-22 Thread Shashwat Anand
On Sun, Aug 22, 2010 at 1:31 PM, Dirk Nachbar wrote: > Here is a function which takes any list and creates a freq table, > which can be printed unsorted, sorted by cases or items. It's supposed > to mirror the proc freq in SAS. > > Dirk > > def freq(seq,order='unsorted',prin=True): >#order ca

Re: freq function

2010-08-22 Thread Chris Rebert
On Sun, Aug 22, 2010 at 1:16 AM, Shashwat Anand wrote: > On Sun, Aug 22, 2010 at 1:31 PM, Dirk Nachbar wrote: >> Here is a function which takes any list and creates a freq table, >> which can be printed unsorted, sorted by cases or items. It's supposed >> to mirror the proc freq in SAS. >> >> Dir

Running python script before user login

2010-08-22 Thread Mahmood Naderan
I have wrote a python script and want to run it before user login. To do that, I have added it to the ubuntu startup file (init.d). However it seems that the script doesn't work. I want to know does python modules work before user login? // Naderan *Mahmood; -- http://mail.python.o

Re: Running python script before user login

2010-08-22 Thread Chris Rebert
On Sun, Aug 22, 2010 at 1:52 AM, Mahmood Naderan wrote: > I have wrote a python script and want to run it before user login. To do > that, I have added it to the ubuntu startup file (init.d). However it seems > that the script doesn't work. Specify exactly how it's not working. Cheers, Chris --

how to use xdrlib

2010-08-22 Thread Alan Wilter Sousa da Silva
Hi there, I am trying to understand how xdrlib works as I want to read files in this format. The problem is I don't much about xdr (although I read http://docs.python.org/library/xdrlib.html and RFC 1832). Another problem is I don't know how the file I want to read was encoded. So when I do some

Re: Running python script before user login

2010-08-22 Thread Mahmood Naderan
>Specify exactly how it's not working. I have wrote a script to send my ip address to an email address. It does work when I am login (python sendip.py). I then followed the procedure in https://help.ubuntu.com/community/RcLocalHowto. However after restart, no email is sent. // Naderan *Mahmoo

Wrong unichr docstring in 2.7

2010-08-22 Thread jmfauth
I think there is a small point here. >>> sys.version 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] >>> print unichr.__doc__ unichr(i) -> Unicode character Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10. >>> # but >>> unichr(0x10fff) Traceback (mos

CodeSnipr Learning can be simple!!

2010-08-22 Thread bapi
Hi, All the group members right at here, we people recently lunched a website CodeSnipr based on Computer language like (PHP, RUBBY, HTML, CSS, MYSQL, JQURY, IPHONE DEVELOPMENT, JAVASCRIPT, C++,.NET,XML,C# etc.). CodeSnipr will provide you access to user generated tutorials. Here you can post

Re: Wrong unichr docstring in 2.7

2010-08-22 Thread Thomas Jollans
On Sunday 22 August 2010, it occurred to jmfauth to exclaim: > I think there is a small point here. > > >>> sys.version > > 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] > > >>> print unichr.__doc__ > > unichr(i) -> Unicode character > > Return a Unicode string of one char

Re: Wrong unichr docstring in 2.7

2010-08-22 Thread Dave Angel
jmfauth wrote: I think there is a small point here. sys.version 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] print unichr.__doc__ unichr(i) -> Unicode character Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10. # b

Re: how to use xdrlib

2010-08-22 Thread Thomas Jollans
On Sunday 22 August 2010, it occurred to Alan Wilter Sousa da Silva to exclaim: > Hi there, > > I am trying to understand how xdrlib works as I want to read files in this > format. The problem is I don't much about xdr (although I read > http://docs.python.org/library/xdrlib.html and RFC 1832). >

Re: Running python script before user login

2010-08-22 Thread Thomas Jollans
On Sunday 22 August 2010, it occurred to Mahmood Naderan to exclaim: > >Specify exactly how it's not working. > > I have wrote a script to send my ip address to an email address. It does > work when I am login (python sendip.py). I then followed the procedure in > https://help.ubuntu.com/community

ANN: warehouse Objects in SQLite : y_serial module

2010-08-22 Thread code43
Module download at SourceForge http://yserial.sourceforge.net Documentation has been revised and v0.60 released. Serialization + persistance :: in a few lines of code, compress and annotate Python objects into SQLite; then later retrieve them chronologically by keywords without any SQL. Most usefu

Re: Detect string has non-ASCII chars without checking each char?

2010-08-22 Thread John Machin
On Aug 22, 5:07 pm, "Michel Claveau - MVP" wrote: > Hi! > > Another way : > >   # -*- coding: utf-8 -*- > >   import unicodedata > >   def test_ascii(struni): >       strasc=unicodedata.normalize('NFD', struni).encode('ascii','replace') >       if len(struni)==len(strasc): >          return True >

trying to use sdl_pango with python

2010-08-22 Thread inhahe
i'm new to ctypes. can someone help me use sdl_pango with python? here's the documentation: http://sdlpango.sourceforge.net/ here's my code: - import pygame from ctypes import * import win32api MATRIX_TRANSPARENT_BACK_WHITE_LETTER = c_char_p("

Re: freq function

2010-08-22 Thread Peter Otten
Dirk Nachbar wrote: > Here is a function which takes any list and creates a freq table, > which can be printed unsorted, sorted by cases or items. It's supposed > to mirror the proc freq in SAS. > > Dirk > > def freq(seq,order='unsorted',prin=True): > #order can be unsorted, cases, items >

Re: Running python script before user login

2010-08-22 Thread Mahmood Naderan
I am trying to execute this script before login:   #!/bin/sh  date > /home/mahmood/dateatboot.txt echo "In local file" /usr/bin/python2.6 /home/mahmood/sendip.py echo "python script finished" after restart, dateatboot.txt was created shows that the script was executed. In the python file, I have th

Re: Running python script before user login

2010-08-22 Thread Thomas Jollans
On Sunday 22 August 2010, it occurred to Mahmood Naderan to exclaim: > I am trying to execute this script before login: > > #!/bin/sh > date > /home/mahmood/dateatboot.txt > echo "In local file" > /usr/bin/python2.6 /home/mahmood/sendip.py > echo "python script finished" > after restart, dateatb

Re: Running python script before user login

2010-08-22 Thread Mahmood Naderan
It seems that changing the directory before python command is mandatory: #!/bin/sh cd /home/mahmood/ python sendip.py    I am now able to receive the IP address right after boot and before login page. Thank you // Naderan *Mahmood; From: Thomas Jollans To: py

Re: Python "why" questions

2010-08-22 Thread Neil Cerutti
On 2010-08-21, Steven D'Aprano wrote: > There is room in the world for programming languages aimed at > non- programmers (although HC is an extreme case), but not all > languages should prefer the intuition of non-programmers over > other values. Extremer: Inform 7. -- Neil Cerutti -- http://m

Re: Wrong unichr docstring in 2.7

2010-08-22 Thread jmfauth
Short comments: 1) I'm aware Python can be built in "ucs2" or "ucs4" mode. It remains that the unichr doc string does not seem correct. 2) 0x0 versus 0 Do not take this too seriously. Sure the value of 0x0 and 0 are equal, but the "unit" sounds strange. Eg. If a is a length, I would not express a

windows hook to catch WM_CREATE

2010-08-22 Thread Jacques HULLU
Hello all, I'm looking for a method, lib, ... to create a windows hook to catch WM_CREATE message in python 2.6? For keyboard and mouse I use pyHook. any idea ? -- Jacques -- http://mail.python.org/mailman/listinfo/python-list

Re: Detect string has non-ASCII chars without checking each char?

2010-08-22 Thread Michel Claveau - MVP
Re ! > Try your code with u"abcd\xa1" ... it says it's ASCII. Ah? in my computer, it say "False" @-salutations -- MCi -- http://mail.python.org/mailman/listinfo/python-list

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-22 Thread David Kastrup
John Bokma writes: > David Kastrup writes: > >> John Passaniti writes: >> >>> Amen! All this academic talk is useless. Who cares about things like >>> the big-O notation for program complexity. Can't people just *look* >>> at code and see how complex it is?! And take things like the years o

Organizing unit test?

2010-08-22 Thread Roy Smith
Over the years, I've tried different styles of organizing unit tests. I used to create a test directory and put all my tests there. I would maintain a one-to-one correspondence between production source and test source, i.e. the test code for foo.py would be in test/foo.py. More recently, I've

Re: Get authentication error while using 'smtplib'

2010-08-22 Thread Mahmood Naderan
Well, login plain did the job:   session = smtplib.SMTP(smtpserver) session.ehlo() session.esmtp_features["auth"] = "LOGIN PLAIN"if AUTHREQUIRED:    session.login(smtpuser, smtppass)   // Naderan *Mahmood; From: Mahmood Naderan To: python mailing list Sent: F

comparing tuples

2010-08-22 Thread Baba
level: beginners I was trying to write simple code that compares 2 tuples and returns any element in the second tuple that is not in the first tuple. def tuples(t1, t2): result = [] for b in t2: for a in t1: if b == a: break else: re

Re: Iterative vs. Recursive coding

2010-08-22 Thread Hrvoje Niksic
Steven D'Aprano writes: > * It throws away information from tracebacks if the recursive function > fails; and [...] > If you're like me, you're probably thinking that the traceback from an > exception in a recursive function isn't terribly useful. Agreed. On the other hand, a full-fledged tai

Re: comparing tuples

2010-08-22 Thread Tim Chase
On 08/22/10 12:50, Baba wrote: level: beginners I was trying to write simple code that compares 2 tuples and returns any element in the second tuple that is not in the first tuple. def tuples(t1, t2): result = [] for b in t2: for a in t1: if b == a:

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-22 Thread John Bokma
David Kastrup writes: > John Bokma writes: > >> David Kastrup writes: >> >>> John Passaniti writes: >>> Amen! All this academic talk is useless. Who cares about things like the big-O notation for program complexity. Can't people just *look* at code and see how complex it is?!

[ANN]VTD-XML 2.9

2010-08-22 Thread Jimmy
VTD-XML 2.9, the next generation XML Processing API for SOA and Cloud computing, has been released. Please visit https://sourceforge.net/projects/vtd-xml/files/ to download the latest version. * Strict Conformance # VTD-XML now fully conforms to XML namespace 1.0 spec * Performance Improv

Re: Iterative vs. Recursive coding

2010-08-22 Thread John Bokma
Steven D'Aprano writes: > On Sat, 21 Aug 2010 19:09:52 -0500, John Bokma wrote: > >> this means that Python should eliminate / optimize tail >> recursion. > > There have been various suggestions to add tail recursion optimization to > the language. Two problems: [snip] > But this is not the on

Sphinx cross reference question

2010-08-22 Thread Laszlo Nagy
In my shopzeus.db.pivot.convert.py file, in the run() method of my Data2Facts class, I can write this into the docstring: class Data2Facts(threading.Thread): # code here... def prepare(self,*args): # code here... # more code here def run(self): """ Star

Re: Python "why" questions

2010-08-22 Thread Russ P.
On Aug 22, 12:47 am, Chris Rebert wrote: > On Sun, Aug 22, 2010 at 12:23 AM, Russ P. wrote: > > On Aug 21, 1:33 am, Steven D'Aprano > cybersource.com.au> wrote: > >> On Fri, 20 Aug 2010 11:01:42 -0700, Russ P. wrote: > >> > Most programmers probably never use vectors and matrices, so they don't

Re: comparing tuples

2010-08-22 Thread Baba
On Aug 22, 7:12 pm, Tim Chase wrote: > On 08/22/10 12:50, Baba wrote: > > > > > level: beginners > > > I was trying to write simple code that compares 2 tuples and returns > > any element in the second tuple that is not in the first tuple. > > > def tuples(t1, t2): > >      result = [] > >      fo

Re: Iterative vs. Recursive coding

2010-08-22 Thread John Nagle
On 8/21/2010 8:32 PM, Steven D'Aprano wrote: On Sat, 21 Aug 2010 19:09:52 -0500, John Bokma wrote: this means that Python should eliminate / optimize tail recursion. There have been various suggestions to add tail recursion optimization to the language. Two problems: * It throws away inform

Re: psycopg2 for insertion of binary data to PostgreSQL database

2010-08-22 Thread Julia Jacobson
Thanks a lot, this was the solution. It would be greate, if you could also show me a way to extract the inserted binary object from the table on the server to a file on a client. > Peter Otten wrote: Julia Jacobson wrote: Hello everybody out there using python, For the insertion of pictures

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-22 Thread 1001nuits
Le Sun, 22 Aug 2010 20:12:36 +0200, John Bokma a écrit: David Kastrup writes: John Bokma writes: David Kastrup writes: John Passaniti writes: Amen! All this academic talk is useless. Who cares about things like the big-O notation for program complexity. Can't people just *l

Re: psycopg2 for insertion of binary data to PostgreSQL database

2010-08-22 Thread Thomas Jollans
On Sunday 22 August 2010, it occurred to Julia Jacobson to exclaim: > Thanks a lot, this was the solution. > It would be greate, if you could also show me a way to extract the > inserted binary object from the table on the server to a file on a client. Probably something along the lines of: * exe

Re: Detect string has non-ASCII chars without checking each char?

2010-08-22 Thread John Machin
On Aug 23, 1:10 am, "Michel Claveau - MVP" wrote: > Re ! > > > Try your code with u"abcd\xa1" ... it says it's ASCII. > > Ah?  in my computer, it say "False" Perhaps your computer has a problem. Mine does this with both Python 2.7 and Python 2.3 (which introduced the unicodedata.normalize function

Re: expression in an if statement

2010-08-22 Thread Gregory Ewing
Thomas Jollans wrote: What if "set" has side effects? A compiler could only exclude this possibility if it knew exactly what "set" will be at run time, And also that 'a' remains bound to the same object, and that object or anything reachable from it is not mutated in any way that could affect

What is a class method?

2010-08-22 Thread Paulo da Silva
I understand the concept of a static method. However I don't know what is a class method. Would anybody pls. explain me? class C: @classmethod def ... ... Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: What is a class method?

2010-08-22 Thread James Mills
On Mon, Aug 23, 2010 at 12:49 PM, Paulo da Silva wrote: > I understand the concept of a static method. > However I don't know what is a class method. > Would anybody pls. explain me? Please read this first: http://docs.python.org/library/functions.html#classmethod Then ask us questions :) cheer

Re: What is a class method?

2010-08-22 Thread Paulo da Silva
Em 23-08-2010 04:30, James Mills escreveu: > On Mon, Aug 23, 2010 at 12:49 PM, Paulo da Silva > wrote: >> I understand the concept of a static method. >> However I don't know what is a class method. >> Would anybody pls. explain me? > > Please read this first: > http://docs.python.org/library/fun

Re: What is a class method?

2010-08-22 Thread James Mills
On Mon, Aug 23, 2010 at 1:53 PM, Paulo da Silva wrote: > I did it before posting ... > The "explanation" is not very clear. It is more like "how to use it". Without going into the semantics of languages basically the differences are quite clear: @classmethod is a decorator that warps a function

Re: What is a class method?

2010-08-22 Thread Ian Kelly
On Sun, Aug 22, 2010 at 9:53 PM, Paulo da Silva wrote: > Em 23-08-2010 04:30, James Mills escreveu: >> On Mon, Aug 23, 2010 at 12:49 PM, Paulo da Silva >> wrote: >>> I understand the concept of a static method. >>> However I don't know what is a class method. >>> Would anybody pls. explain me? >>

Re: What is a class method?

2010-08-22 Thread Terry Reedy
On 8/22/2010 11:53 PM, Paulo da Silva wrote: Please read this first: http://docs.python.org/library/functions.html#classmethod Then ask us questions :) I did it before posting ... When you ask a question, it help people answer if they know what you have already tried and failed with ;-)

Re: What is a class method?

2010-08-22 Thread John Nagle
On 8/22/2010 9:16 PM, James Mills wrote: On Mon, Aug 23, 2010 at 1:53 PM, Paulo da Silva wrote: I did it before posting ... The "explanation" is not very clear. It is more like "how to use it". Without going into the semantics of languages basically the differences are quite clear: @classme