Re: How to detect what type a variable is?

2006-11-29 Thread Daniel Klein
On 29 Nov 2006 08:25:35 -0800, "Leandro Ardissone" <[EMAIL PROTECTED]> wrote: >great, thanks > >And how I can compare this "" output ? >I want to decide what to do if the var is an string and what to do if >not.. > >Tried with: >if type(artistList) == "": > >and >if type(artistList) == "list": > >

Re: How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
great, that is just what I need! Thank you all! -- Leandro Ardissone On Nov 29, 1:29 pm, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: > Leandro Ardissone wrote: > > And how I can compare this "" output ? > > I want to decide what to do if the var is an string and what to do if > > not.. > > > T

Using Python

2006-11-29 Thread beemer328i2004
Hi Guys, I am new to this language and i need some help... I am trying to create a script that will go into a log file and bring me back the xml from an order... For example: go into Log1.xml and extract order number 2 from top to bottom and extract it into a txt file... Does anyone know how

Re: trouble writing results to files

2006-11-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I can try that. Is using range(len(a)) a bad solution in the sense > that its likely to create an unexpected error? Or because there is a > more efficient way to accomplish the same thing? for-in uses an internal index counter to fetch items from the sequence, so

Re: Overloading "if object" unary operator

2006-11-29 Thread Sarcastic Zombie
On Nov 29, 11:26 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Sarcastic Zombie wrote: > > is there any way to overload the 'if' unary usage to detect if a > > variable has a value?Define a __nonzero__() or __len__() method. > > Peter Thanks to both of you, it worked perfectly. I must have missed

Re: How to detect what type a variable is?

2006-11-29 Thread Roberto Bonvallet
Leandro Ardissone wrote: > And how I can compare this "" output ? > I want to decide what to do if the var is an string and what to do if > not.. > > Tried with: > if type(artistList) == "": > > and > if type(artistList) == "list": > > but nothing.. type() doesn't return a string, it returns a

Re: Overloading "if object" unary operator

2006-11-29 Thread Peter Otten
Sarcastic Zombie wrote: > is there any way to overload the 'if' unary usage to detect if a > variable has a value? Define a __nonzero__() or __len__() method. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
Thanks, I don't store Python objects in xml, but I get an object from a library that parses xml and converts it to objects. On Nov 29, 12:43 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2006-11-29, Grant Edwards <[EMAIL PROTECTED]> wrote: > > > On 2006-11-29, Leandro Ardissone <[EMAIL PROTEC

Re: How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
great, thanks And how I can compare this "" output ? I want to decide what to do if the var is an string and what to do if not.. Tried with: if type(artistList) == "": and if type(artistList) == "list": but nothing.. On Nov 29, 12:41 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2006-11-29

Re: Overloading "if object" unary operator

2006-11-29 Thread Roberto Bonvallet
Sarcastic Zombie wrote: > For example, in the code: > > a = A(56) > if a: >print "Hoo hah!" > > how can I insure that the if will come back true and fire off the print > if and only if self.id is defined? I want to do this in an overloaded, > generic way, if possible; I know that I could test

Re: Reading GDSII layouts

2006-11-29 Thread Vincent Arnoux
Le mardi 28 novembre 2006 18:46, Jacob Rael a écrit : > Funny, I started writing one this past weekend as a learning exercise > (handling large files and start to use classes). If ipkiss does not > work out, let me know specifically what you need and maybe my hack will > work. > > jr Well, if you

Re: Reading GDSII layouts

2006-11-29 Thread Vincent Arnoux
Le mardi 28 novembre 2006 17:56, Paddy a écrit : >> The link you gave states this near the top: > IPKISS is a python-based library for the generation of GDSII layouts, > including hierarchy. > It has grown out of the GDS_KEY library, but it is more flexible and > object oriented. Contrary > t

Re: trouble writing results to files

2006-11-29 Thread lisa . engblom
Roberto Bonvallet wrote: > [EMAIL PROTECTED] wrote: > > import csv > > output = csv.writer(open('/Python25/working/output.csv', 'a')) > > a = ["apple", "cranberry", "tart"] > > for elem in range(len(a)): > >output.writerow(a[elem]) > > output.writerow expects a sequence as an argument. You ar

Overloading "if object" unary operator

2006-11-29 Thread Sarcastic Zombie
Good morning, If I have a class class A: __init__(id) self.id = id is there any way to overload the 'if' unary usage to detect if a variable has a value? For example, in the code: a = A(56) if a: print "Hoo hah!" how can I insure that the if will come back true and fire off th

Re: trouble writing results to files

2006-11-29 Thread Fredrik Lundh
Neil Cerutti wrote: >> BTW, iterating over range(len(a)) is an anti-pattern in Python. > > Unless you're modifying elements of a, surely? and needs to run on a Python version that doesn't support enumerate. -- http://mail.python.org/mailman/listinfo/python-list

Re: Asyncore Medusa Example

2006-11-29 Thread Fredrik Lundh
Graeme Matthew wrote: > does anyone know where you can find examples of how to write a native > python webserver, I have looked at medusa and asyncore but there are no > real examples and the doco is very light medusa *is* a web server based on asyncore, so you should be able to use it more or

Re: Detecting recursion loops

2006-11-29 Thread Carl Banks
robert wrote: > My code does recursion loops through a couple of functions. Due to > problematic I/O input this leads sometimes to "endless" recursions and after > expensive I/O to the Python recursion exception. > What would be a good method to detect recursion loops and stop it by > user-Excep

Re: trouble writing results to files

2006-11-29 Thread Neil Cerutti
On 2006-11-29, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-11-29, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: >>> BTW, iterating over range(len(a)) is an anti-pattern in Python. >> >> Unless you're modifying elements of a, surely? > > enumerate is your friend :)

Re: How to detect what type a variable is?

2006-11-29 Thread SeanDavis12
Leandro Ardissone wrote: > Hi, > > I want to know what type is a variable. > For example, I get the contents of an xml but some content is a list or > a string, and I need to know what type it is. type(variable) Sean -- http://mail.python.org/mailman/listinfo/python-list

Re: How to detect what type a variable is?

2006-11-29 Thread Neil Cerutti
On 2006-11-29, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2006-11-29, Leandro Ardissone <[EMAIL PROTECTED]> wrote: > >> I want to know what type is a variable. For example, I get the >> contents of an xml but some content is a list or a string, and >> I need to know what type it is. > x = '

Re: How to detect what type a variable is?

2006-11-29 Thread Grant Edwards
On 2006-11-29, Leandro Ardissone <[EMAIL PROTECTED]> wrote: > I want to know what type is a variable. For example, I get the > contents of an xml but some content is a list or a string, and > I need to know what type it is. >>> x = 'asdf' >>> type(x) >>> i = 0 >>> type(i) >>> -- Grant Edward

Re: trouble writing results to files

2006-11-29 Thread Roberto Bonvallet
Neil Cerutti wrote: > On 2006-11-29, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: >> BTW, iterating over range(len(a)) is an anti-pattern in Python. > > Unless you're modifying elements of a, surely? enumerate is your friend :) for n, item in enumerate(a): if f(item): a[n

How to detect what type a variable is?

2006-11-29 Thread Leandro Ardissone
Hi, I want to know what type is a variable. For example, I get the contents of an xml but some content is a list or a string, and I need to know what type it is. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble writing results to files

2006-11-29 Thread Neil Cerutti
On 2006-11-29, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: > BTW, iterating over range(len(a)) is an anti-pattern in Python. Unless you're modifying elements of a, surely? -- Neil Cerutti You can't give him that cutback lane. He's so fast, and he sees it so well. He can also run away from you i

Re: Calling functions with dynamic arguments

2006-11-29 Thread SeanDavis12
Roberto Bonvallet wrote: > SeanDavis12 wrote: > > I have a dictionary like: > > > > {"a":1, "b":2} > > > > and I want to call a function: > > > > def func1(a=3,b=4): > >print a,b > > > > so that I get a=1,b=2, how can I go about that? > > func1(**yourdict) Thanks, Roberto. Sean -- http:

Re: trouble writing results to files

2006-11-29 Thread Roberto Bonvallet
[EMAIL PROTECTED] wrote: > import csv > output = csv.writer(open('/Python25/working/output.csv', 'a')) > a = ["apple", "cranberry", "tart"] > for elem in range(len(a)): >output.writerow(a[elem]) output.writerow expects a sequence as an argument. You are passing a string, which is a sequence o

Re: Detecting recursion loops

2006-11-29 Thread Rob Wolfe
robert wrote: > My code does recursion loops through a couple of functions. Due to > problematic I/O input this leads sometimes to "endless" recursions and after > expensive I/O to the Python recursion exception. > What would be a good method to detect recursion loops and stop it by > user-Exce

Re: Calling functions with dynamic arguments

2006-11-29 Thread Roberto Bonvallet
SeanDavis12 wrote: > I have a dictionary like: > > {"a":1, "b":2} > > and I want to call a function: > > def func1(a=3,b=4): >print a,b > > so that I get a=1,b=2, how can I go about that? func1(**yourdict) -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list

Calling functions with dynamic arguments

2006-11-29 Thread SeanDavis12
I have a dictionary like: {"a":1, "b":2} and I want to call a function: def func1(a=3,b=4): print a,b so that I get a=1,b=2, how can I go about that? Thanks, Sean -- http://mail.python.org/mailman/listinfo/python-list

trouble writing results to files

2006-11-29 Thread lisa . engblom
I have two semi related questions... First, I am trying to output a list of strings to a csv file using the csv module. The output file separates each letter of the string with a comma and then puts each string on a separate line. So the code is: import csv output = csv.writer(open('/Python25/w

Stani's Python Editor is looking for a new webhost

2006-11-29 Thread SPE - Stani's Python Editor
SPE was hosted for a long while by Zettai. I'd like to thank them again for their wonderful service. Unfortunately they will go out of business. So SPE is looking for a new webhost. These are the requirements: - python framework (Zope/Plone, django, turbogears, ...) - I have the freedom to use thi

odict the Ordered Diction 0.2.2

2006-11-29 Thread Fuzzyman
After a break of almost a year there has been an update to `odict the Ordered Dictionary `_. The latest version is 0.2.2, with changes implemented by Nicola Larosa. Despite over 700 downloads since May (plus 1300 as part of `pythonutils

Re: pyxpcom

2006-11-29 Thread hg
Trent Mick wrote: >> My need is as follows: I have developed an activex component to access a >> smart card on the client side / do some web site logon. >> >> Are xpcom / pyxpcom advanced/stable enough for such an implementation >> under Linux / Windows ? > > You mean to provide the equivalent fun

Re: ANN: CherryPy 3.0 RC1

2006-11-29 Thread James Cunningham
On 2006-11-29 08:37:46 -0500, "Christian" <[EMAIL PROTECTED]> said: >> "Christian Wyglendowski" <[EMAIL PROTECTED]> writes: >> >>> I'm happy to announce the first release candidate for CherryPy 3.0. > > Ben Finney wrote: >> >> Congratulations, I'm glad to see an announcement for CherryPy. >> >

Re: ANN: CherryPy 3.0 RC1

2006-11-29 Thread Christian
> "Christian Wyglendowski" <[EMAIL PROTECTED]> writes: > > > I'm happy to announce the first release candidate for CherryPy 3.0. Ben Finney wrote: > > Congratulations, I'm glad to see an announcement for CherryPy. > > Please, in future, don't send HTML message bodies to public forums; > plain text

Re: Error handling. Python embedded into a C++ app.

2006-11-29 Thread Wolfram
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >You would use try: and then on the next line except: Thanks for the idea, but it did not help. I can not wrap every pythion line in python, so I wrote the following code on the C++ side: -- snip - try { i

Re: Processing Solid Edge objects

2006-11-29 Thread Maria R
olive skrev: > It would help if you could give an exemple of .par and .asm file. > > Is it human readable, XML ... ? > > Is there any other import/export file format provided ? > The .par files and friends are in binary format so the method I prefer is using the provided COM interfaces and acces

Re: screen output problem

2006-11-29 Thread Ritesh Raj Sarraf
I'm not sure if there is a definite solution to this problem. I've noticed that one of the applications, which I use on a daily basis (apt from Debian) does address the progress bar issue in another way. When apt tries to download multiple files, it displays the progress of all the downloads on a

Re: Problem with imaplib (weird result if mailbox contains a %)

2006-11-29 Thread Antoon Pardon
On 2006-11-29, Leo Kislov <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> On 2006-11-28, Leo Kislov <[EMAIL PROTECTED]> wrote: >> > >> Are there more docs than at http://www.python.org/doc/. I don't find >> those very helpfull in explaining this. >> >> I also took a look at rfc 2060 and to be

Re: Processing Solid Edge objects

2006-11-29 Thread olive
It would help if you could give an exemple of .par and .asm file. Is it human readable, XML ... ? Is there any other import/export file format provided ? Maria R a écrit : > I consider using Python to process Solid Edge .par .asm etc objects. > Solid Edge provides a pretty rich documentation an

Re: Problem with imaplib (weird result if mailbox contains a %)

2006-11-29 Thread Leo Kislov
Antoon Pardon wrote: > On 2006-11-28, Leo Kislov <[EMAIL PROTECTED]> wrote: > > > > Antoon Pardon wrote: > >> This little program gives IMO a strange result. > >> > >> import imaplib > >> > >> user = "cpapen" > >> > >> cyr = imaplib.IMAP4("imap.vub.ac.be") > >> cyr.login("cyrus", "cOn-A1r") > >> rc

Re: Wrapping A Shell

2006-11-29 Thread Nick Craig-Wood
Jeremy Moles <[EMAIL PROTECTED]> wrote: > I'm not sure if this is really the right place to ask this question, but > since the implementation is in Python, I figured I'd give it a shot. > > I want to "wrap" a shell process using popen inside of python program > rather than creating a new shell

Processing Solid Edge objects

2006-11-29 Thread Maria R
I consider using Python to process Solid Edge .par .asm etc objects. Solid Edge provides a pretty rich documentation and tutorials. Still, when trying it out, using PyWin32, I get somewhat frustrated. So, I hope for someone out there to be willing to share experiences. The objective is to automat

Re: shtoom or yate client source code

2006-11-29 Thread Paul Boddie
Croteam wrote: > > Can somebody give me (if is that possible) source code of shtoom or > yate client Take a look at the SourceForge downloads page for Shtoom: http://sourceforge.net/project/showfiles.php?group_id=94774 The project is actually hosted at divmod.com... http://www.divmod.org/trac/w

Re: Really closing stdout (was: "fork and exit" needed?)

2006-11-29 Thread Nick Craig-Wood
Mitja Trampus <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > I'm not sure how you do open stdout to /dev/null in python though! > > I suspect something like this... > > import posix > > posix.close(1) > > posix.open("/dev/null", posix.O_WRONLY) > > Yes, you're close enough... The

shtoom or yate client source code

2006-11-29 Thread Croteam
Hello, Can somebody give me (if is that possible) source code of shtoom or yate client ( e.g. yate.exe or shtoom.exe client source code) and, Do you know any python voip module except shtoom and yate,if you know please tell me. I will appreciate any help!!

Re: proof of concept python and tkinter gnugo interface

2006-11-29 Thread grindel
Anton Vredegoor wrote: > For the last few days I've been doodling with a script that provides a > graphical interface to gnugo by using its GTP protocol. At the moment > the script is *very* basic, in fact the only thing it does is to allow > one to click on a coordinate and place a move there O

Re: utf - string translation

2006-11-29 Thread Frederic Rentsch
Dan wrote: > On 22 nov, 22:59, "John Machin" <[EMAIL PROTECTED]> wrote: > > >>> processes (Vigenère) >>> >> So why do you want to strip off accents? The history of communication >> has several examples of significant difference in meaning caused by >> minute differences in punctuation or

Re: Asyncore Medusa Example

2006-11-29 Thread Gabriel Genellina
At Wednesday 29/11/2006 07:23, Graeme Matthew wrote: does anyone know where you can find examples of how to write a native python webserver, I have looked at medusa and asyncore but there are no real examples and the doco is very light The Python standard library already comes with a native HT

Re: Small prog question from a newbie: abt variables in a function definition

2006-11-29 Thread Gabriel Genellina
At Wednesday 29/11/2006 06:48, B Shyam Sundar wrote: I am a newbie as far as python is concerned ... I am trying to write a code for playing bridge in obj oriented manner .. Well ... i have this small problem: class hand: def __init__(self,set_of_cards=[]): self.set_of_cards=set_o

Asyncore Medusa Example

2006-11-29 Thread Graeme Matthew
Hi all does anyone know where you can find examples of how to write a native python webserver, I have looked at medusa and asyncore but there are no real examples and the doco is very light any help is appreciated regards graeme -- http://mail.python.org/mailman/listinfo/python-list

Re: Python program that validates an url against w3c markup validator

2006-11-29 Thread Gabriel Genellina
At Wednesday 29/11/2006 02:29, yaru22 wrote: I'd like to create a program that validates bunch of urls against the w3c markup validator (http://validator.w3.org/) and store the result in a file. Since I don't know network programming, I have no idea how to start coding this program. Why not u

Small prog question from a newbie: abt variables in a function definition

2006-11-29 Thread B Shyam Sundar
Hi all, I am a newbie as far as python is concerned ... I am trying to write a code for playing bridge in obj oriented manner .. Well ... i have this small problem: class hand: def __init__(self,set_of_cards=[]): self.set_of_cards=set_of_cards card_played_flag =0 def play(played_

Re: windows problem

2006-11-29 Thread hankpai
thanks :)! On Nov 29, 12:35 am, Phil Thompson <[EMAIL PROTECTED]> wrote: > On Wednesday 29 November 2006 8:12 am, [EMAIL PROTECTED] wrote: > > > Dumb question from extreme newbie. > > > Steps so far: > > 1. Installed Python 2.5 > > 2. Installed Qt 4.2.1 (with mingw) from executable > > 3. Installe

Re: splitting a long string into a list

2006-11-29 Thread Frederic Rentsch
ronrsr wrote: > still having a heckuva time with this. > > here's where it stand - the split function doesn't seem to work the way > i expect it to. > > > longkw1,type(longkw): Agricultural subsidies; Foreign > aid;Agriculture; Sustainable Agriculture - Support; Organic > Agriculture; Pesticides,

Re: [PyQt] windows problem

2006-11-29 Thread Phil Thompson
On Wednesday 29 November 2006 8:12 am, [EMAIL PROTECTED] wrote: > Dumb question from extreme newbie. > > Steps so far: > 1. Installed Python 2.5 > 2. Installed Qt 4.2.1 (with mingw) from executable > 3. Installed PyQt 4.1 from executable > > Been trying to run the first example (t1.pyw) in the tuto

[PyQt] windows problem

2006-11-29 Thread hankpai
Dumb question from extreme newbie. Steps so far: 1. Installed Python 2.5 2. Installed Qt 4.2.1 (with mingw) from executable 3. Installed PyQt 4.1 from executable Been trying to run the first example (t1.pyw) in the tutorials folder, but the following error pops up while running the from idle-pyth

Re: Problem with imaplib (weird result if mailbox contains a %)

2006-11-29 Thread Antoon Pardon
On 2006-11-28, Leo Kislov <[EMAIL PROTECTED]> wrote: > > Antoon Pardon wrote: >> This little program gives IMO a strange result. >> >> import imaplib >> >> user = "cpapen" >> >> cyr = imaplib.IMAP4("imap.vub.ac.be") >> cyr.login("cyrus", "cOn-A1r") >> rc, lst = cyr.list('""', "user/%s/*" % user) >>

Re: Using SimpleXMLRPCServer in a Windows Service

2006-11-29 Thread Gabriel Genellina
At Tuesday 28/11/2006 05:49, Rudy Schockaert wrote: I found the problem. Actually both pieces of code work now. The problem was that when I run the SimpleXMLRPCService in a Windows Service, the STDERR needs to be redirected to a real file. I guess some kind of buffer overflow occurs when you don

Re: Reading text labels from a Win32 window

2006-11-29 Thread Thomas Heller
[EMAIL PROTECTED] schrieb: > [EMAIL PROTECTED] schrieb: > >> Does anyone know of a way to read text labels from a Win32 application. >> I am familiar with using pywin32 and the SendMessage function to >> capture text from Buttons,text boxex, comboboxes, etc, however, the >> text I am would like to

Re: Question about import and sys.path

2006-11-29 Thread Rob Wolfe
Frank Millman wrote: > One small point. The docs have the following warning - > > "Important: the caller is responsible for closing the file argument, if > it was not None, even when an exception is raised. This is best done > using a try ... finally statement. " > > I have added this to my code.

PIL throws exception when reading bitmap/pnm data

2006-11-29 Thread Cameron Walsh
Hi all, I'm trying to extract the data from a bitmap or .pnm file using the following code: import Image img = Image.open("test.bmp","r") data=img.getdata() Unfortunately I get the following exception on Linux, but not on Windows: >>> data=img.getdata() Traceback (most recent call last): File

<    1   2