Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > Why do you assume that everything you need for your list comprehension has > to go into a single line? Chances are your list comp already calls > functions, so just create one more for it to use. > > > py> def describe(cond): > ... if cond: > ... return "odd" >

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2005 21:05:50 -0800, [EMAIL PROTECTED] wrote: > Steven D'Aprano wrote: >> WHY WHY WHY the obsession with one-liners? What is wrong with the good old >> fashioned way? >> >> if cond: >> x = true_value >> else: >> x = false_value >> >> It is easy to read, easy to understand,

Weekly Python Patch/Bug Summary

2005-11-18 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 379 open (+14) / 2968 closed ( +7) / 3347 total (+21) Bugs: 910 open ( +6) / 5384 closed (+17) / 6294 total (+23) RFE : 200 open ( +0) / 191 closed ( +2) / 391 total ( +2) New / Reopened Patches __ PythonD D

Re: os.popen('alias')

2005-11-18 Thread Chris F.A. Johnson
On 2005-11-19, Chris F.A. Johnson wrote: > On 2005-11-18, Belebele wrote: >>>From an interactive python shell, I execute the following: >> >> import os >> for line in os.popen('alias').readlines(): >> print line >> >> >> No aliases are print

Re: Underscores in Python numbers

2005-11-18 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > On Fri, 18 Nov 2005 16:26:08 -0800, [EMAIL PROTECTED] wrote: > > > Personally, I would rather see the int() and float() function be > > smarter to take what is used for this, i.e. : > > > > a = int("1,234,567") > > But the problem isn't just with conversion of strings. It

Re: os.popen('alias')

2005-11-18 Thread Chris F.A. Johnson
On 2005-11-18, Belebele wrote: >>From an interactive python shell, I execute the following: > > import os > for line in os.popen('alias').readlines(): > print line > > > No aliases are printed. > > I started python from an bash environment t

Re: Underscores in Python numbers

2005-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2005 16:26:08 -0800, [EMAIL PROTECTED] wrote: > Personally, I would rather see the int() and float() function be > smarter to take what is used for this, i.e. : > > a = int("1,234,567") But the problem isn't just with conversion of strings. It is also with literals. n = 9

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread [EMAIL PROTECTED]
Roy Smith wrote: > I think the list comprehensions are going to be the death of readable > python programs. Could be, but seems that someone in charge of the language wants readable python programs to die then as if list comprehension is not enough, there comes generator expression and now the for

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > WHY WHY WHY the obsession with one-liners? What is wrong with the good old > > fashioned way? > > > > if cond: > > x = true_value > > else: > > x = false_value > > > > It is easy to

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > WHY WHY WHY the obsession with one-liners? What is wrong with the good old > fashioned way? > > if cond: > x = true_value > else: > x = false_value > > It is easy to read, easy to understand, only one of true_value and > false_value is evaluated. It isn't a one-lin

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2005 11:17:17 -0800, David Wahler wrote: > Daniel Crespo wrote: >> I would like to know how can I do the PHP ternary operator/statement >> (... ? ... : ...) in Python... >> >> I want to something like: >> >> a = {'Huge': (quantity>90) ? True : False} > > Well, in your example the

Re: Embedded Python interpreter and sockets

2005-11-18 Thread [EMAIL PROTECTED]
Hi Jan, I believe the problem lies with how Houdini uses dlopen() to open your plugin. It uses RTLD_LOCAL to load your plugin, which means that all your plugin's symbols (including the python symbols) are private to that library. Subsequent dlopen() calls, including those made by the python libr

Re: Behaviour of enumerated types

2005-11-18 Thread Bengt Richter
On Sat, 19 Nov 2005 11:10:42 +1100 (EST), Ben Finney <[EMAIL PROTECTED]> wrote: >Bengt Richter <[EMAIL PROTECTED]> wrote: >> Ben Finney <[EMAIL PROTECTED]> wrote: >> >Getting a numeric index might be useful in a language such as >> >Pascal, with no built-in dict or sequence types. In Python, where

Re: Python obfuscation

2005-11-18 Thread Steven D'Aprano
On Tue, 15 Nov 2005 03:06:31 -0800, Ben Sizer wrote: > My interest lies in being able to use encrypted data (where 'data' can > also include parts of the code) so that the data can only be read by my > Python program, and specifically by a single instance of that program. > You would be able to ma

Re: How to convert a "long in a string" to a "long"?

2005-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2005 17:49:50 +, Leif K-Brooks wrote: > Sion Arrowsmith wrote: >> Steven Bethard <[EMAIL PROTECTED]> wrote: >> >>>[EMAIL PROTECTED] wrote: >>> s = long("0xL") ValueError: invalid literal for long(): 0xL >>int("0x", 0) >>> >>>4294967295L

Re: need help about time.sleep, timer

2005-11-18 Thread Peter Hansen
Sinan Nalkaya wrote: > i need a function like that, > wait 5 seconds: >(during wait) do the function > but function waits for keyboard input so if you dont enter any it waits > forever. It's quite unclear whether the last part, above, is one of your *requirements*, or a description of a prob

Re: How to convert a "long in a string" to a "long"?

2005-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2005 11:10:06 -0500, Carsten Haese wrote: >> s = long("0xL") >> ValueError: invalid literal for long(): 0xL >> >> s = long("0x") >> ValueError: invalid literal for long(): 0xL >> >> What can I do? >> >> Thank you in advance. >> Stefan > > Leave o

Re: path module / class

2005-11-18 Thread Peter Hansen
Neil Hodgson wrote: > Chris: > >> What is the status of the path module/class PEP? Did somebody start >> writing one, or did it die? I would really like to see something like >> Jason Orendorff's path class make its way into the python standard >> library. > >There is no PEP yet but there i

Re: different binding behavior

2005-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2005 15:34:36 +0100, Gabriel Zachmann wrote: > i don't see why there should be only one instance of Int with the value 0. "Small" ints are cached, so there may be only one instance of the int with value 0. However, that's an implementation detail, which may change from version to v

Re: textwrap.dedent() drops tabs - bug or feature?

2005-11-18 Thread Peter Hansen
Steven Bethard wrote: > Note that even though the tabs are internal, they are still removed by > textwrap.dedent(). The documentation[1] says: ... > So it looks to me like even if this is a "feature" it is undocumented. > I'm planning on filing a bug report, but I wanted to check here first in

Re: examining python objects

2005-11-18 Thread rurpy
"Chris Mellon" <[EMAIL PROTECTED]> wrote: On 18 Nov 2005 14:05:05 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > -- snip -- > > Writing my own __repr__() is emphatically what I don't > > want to do! That is no better than debugging by inserting > > print statements, a technique from the 198

Re: Confused about namespaces

2005-11-18 Thread Alex Martelli
KvS <[EMAIL PROTECTED]> wrote: > > There's no reason not to just "import wx" if you want that. > > Yes, that's clear. But if you would make some huge application that has > a large number of nested modules, each importing the former one, then > avoiding the use of "from ... import *" would mean t

Re: Hot to split string literals that will across two or more lines ?

2005-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2005 15:59:30 +1100, Ben Finney wrote: > Tony Nelson <[EMAIL PROTECTED]> wrote: >> While we're at it, I use bracketing instead of line continuation: >> >> print ( "a long string, longer than this " >> "and some more of the string" ) > > To continue the pedantry: Th

Re: Confused about namespaces

2005-11-18 Thread Diez B. Roggisch
> Am I understanding correctly that if you have a module foo importing wx > and a module main importing both foo and wx there are actually two > instances of wx created, one referenced to by (at top level) foo.wx.* > and one wx.*? If this is indeed the case it isn't too good for the > performance

Embedded Python interpreter and sockets

2005-11-18 Thread wahn
Hi, Here is a problem I came across and need some help with. I developed a little Python script with some classes which runs standalone and communicates with a database via sockets. So far everything works fine. I also successfully embedded the Python interpreter into a plugin for a commercial 3D

Re: Reinvent no more forever

2005-11-18 Thread ismaelgfk
Ben Finney wrote: > Fine sentiments. What does this mean for PyPI though? How should those > of us who also want to "reinvent no more forever" proceed? How do we > deal with the rampant proliferation of a zillion implementations of > some standard idiom in PyPI? How about some kind of "mega util"

Re: Importing a class without knowing the module

2005-11-18 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > You did help me to better understand some of the roots of your many > mistaken assertions in this thread, from your first "How about adding > Foo.__file__" proposal onwards, yes -- thank you. I claim I haven't made a single mistaken assertion in this th

deleting registry keys and value

2005-11-18 Thread sdb1031
Hi, I am trying to learn how to write, change and delete registry keys and values of a remote computer via Python's _winreg module. So far, I've been able to programmatically create a value and read the value. However, I am unable to figure out how to delete the value. Using the following code,

Is there a way to create a button in either pygame or livewires?

2005-11-18 Thread Nathan Pinno
Hey all, Is there a way to create a button in either pygame or livewires, that is able to be clicked and when clicked sends a command to restart the program? Thanks, Nathan Pinno -- For great sites go to: http://www.the-web-surfers-store.com MSN Messenger: [EMAIL PROTECTED],com Yahoo! Messenge

Re: Confused about namespaces

2005-11-18 Thread KvS
> There's no reason not to just "import wx" if you want that. Yes, that's clear. But if you would make some huge application that has a large number of nested modules, each importing the former one, then avoiding the use of "from ... import *" would mean that you have to use long references like f

Re: Underscores in Python numbers

2005-11-18 Thread [EMAIL PROTECTED]
Personally, I would rather see the int() and float() function be smarter to take what is used for this, i.e. : a = int("1,234,567") Of course, also support the locale variant where the meaning of "," and "." is swapped in most European countries. Gustav HÃ¥llberg wrote: > I tried finding a discus

Re: Confused about namespaces

2005-11-18 Thread Chris Mellon
On 18 Nov 2005 16:09:44 -0800, KvS <[EMAIL PROTECTED]> wrote: > Hmm. But actually I was doing this import from GUIclasses with exactly > this in mind, namely that it would make wx also available at top level. There's no reason not to just "import wx" if you want that. > I (in my naive understandi

Re: Can anyone tell me if pygame and Tkinter can work together?

2005-11-18 Thread Nathan Pinno
Even its from one or two external libraries like Tkinter and pygame? I prefer to load what I need, not to constantly have to call it by its library dot its_name. It makes easier coding for me. I try to keep my code as simply as possible. Wonder if its possible to use a Tkinter question to make a

Re: Behaviour of enumerated types

2005-11-18 Thread Ben Finney
Bengt Richter <[EMAIL PROTECTED]> wrote: > Ben Finney <[EMAIL PROTECTED]> wrote: > >Getting a numeric index might be useful in a language such as > >Pascal, with no built-in dict or sequence types. In Python, where > >any immutable object can be a dict key, and any sequence can be > >iterated, it s

Re: Confused about namespaces

2005-11-18 Thread KvS
Hmm. But actually I was doing this import from GUIclasses with exactly this in mind, namely that it would make wx also available at top level. I (in my naive understanding) see this as "natural" and actually desirable, how could this cause confusing bugs? Do you mean multiple "from ... import *"'s

Re: Underscores in Python numbers

2005-11-18 Thread Dave Hansen
Sorry for the delayed response. I somehow missed this earlier. On Tue, 8 Nov 2005 15:39:09 + (UTC) in comp.lang.python, [EMAIL PROTECTED] (Roy Smith) wrote: >Dave Hansen <[EMAIL PROTECTED]> wrote: >> Of course, I write _far_ more code in C than Python. But I've seen >> enough bugs of the s

Re: How to do "new_variable = (variable) ? True : False; " (php) on python?

2005-11-18 Thread [EMAIL PROTECTED]
Peter Otten wrote: > Daniel Crespo wrote: > > > How can I do > > > > new_variable = (variable) ? True : False; > > > > in Python in one line? > > new_variable = variable > > :-) I would assume the OP is just lazy and don't want to type : new_variable = (variable_is_true_value) ? some_expression_

Re: Importing a class without knowing the module

2005-11-18 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: ... > I suggested using the module, and mentioned that he might not have a > better choice than to use __file__ anyway. You overlooked the mention > of __module__ to complain that __file__ wasn't his best choice, > because he could use __module__. All I did

Re: running functions

2005-11-18 Thread Tom Anderson
On Thu, 17 Nov 2005, Scott David Daniels wrote: > Gorlon the Impossible wrote: > >> I have to agree with you there. Threading is working out great for me >> so far. The multiprocess thing has just baffled me, but then again I'm >> learning. Any tips or suggestions offered are appreciated... > > Th

Re: How to do "new_variable = (variable) ? True : False; " (php) on python?

2005-11-18 Thread Dave Hansen
On Fri, 18 Nov 2005 14:15:06 -0800 in comp.lang.python, Scott David Daniels <[EMAIL PROTECTED]> wrote: > > >Don't try to force everything to the type you expect, >use things as they are; embrace duck-typing. > Wrong, the grammar you have. Do not Everything to the type you expect force. Do or do n

Re: Confused about namespaces

2005-11-18 Thread Chris Mellon
On 18 Nov 2005 15:29:43 -0800, KvS <[EMAIL PROTECTED]> wrote: > Ok, makes sense but didn't seem "natural" to me, although it is an > obvious consequence of what you just pointed out, namely that modules > are evaluated in their own namespace, something to keep in mind... On > the other hand it does

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread [EMAIL PROTECTED]
The cleanest(IMO) is this : a = (predicate and [if_true_expr] or [if_false_expr])[0] This would give you the necessary "short circuit" behaviour no matter what. a = predicate and if_true_expr or if_false_expr works most of the time but should if_true_expr turns out to be 0 or something like tha

Re: Choose meaningful subjects for posts

2005-11-18 Thread Mike Meyer
Micah Elliott <[EMAIL PROTECTED]> writes: > On Nov 18, [EMAIL PROTECTED] wrote: >> Grant> Obligatory aside: I'm completely baffled why anybody would choose >> Grant> the mailing list format over Usenet. I don't even read mailing >> Grant> lists via mailing lists. I recommend gmane.org

Re: Confused about namespaces

2005-11-18 Thread KvS
Ok, makes sense but didn't seem "natural" to me, although it is an obvious consequence of what you just pointed out, namely that modules are evaluated in their own namespace, something to keep in mind... On the other hand it does apparently work recursively "the other way around" since I didn't exp

Re: Adding through recursion

2005-11-18 Thread [EMAIL PROTECTED]
Ben Finney wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > def add(x, y): > > if x == 0: > > print y > > return y > > else: > > x -= 1 > > y += 1 > > add(x, y) > > To add to the other good advice in this thread: > > This is just one of many

Re: Web-based client code execution

2005-11-18 Thread Chris Mellon
On 11/18/05, Paul Watson <[EMAIL PROTECTED]> wrote: > Steve wrote: > > AJAX works because browsers can execute javascript. I don't know of a > > browser that can execute python. Basically your stuck with java or > > javascript because everything else really isn't cross platform. > > Well, I guess

Re: Confused about namespaces

2005-11-18 Thread Chris Mellon
On 18 Nov 2005 15:04:23 -0800, KvS <[EMAIL PROTECTED]> wrote: > Hi all, > > to start with, excuse me, I'm still learning programming alltogether, > probably I'm making some fundamental mistake here... > > I have the files settings.py, GUIclasses.py and main.py in the same > directory. In the file m

Re: Importing a class without knowing the module

2005-11-18 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >... >> > How do you arrange a module so that its classes' __module__ attributes >> > don't tell you the name of the module "that would be useful", yet the >> > module's __file__ DOES give you information that you

Confused about namespaces

2005-11-18 Thread KvS
Hi all, to start with, excuse me, I'm still learning programming alltogether, probably I'm making some fundamental mistake here... I have the files settings.py, GUIclasses.py and main.py in the same directory. In the file main.py are the statements: import settings from GUIclasses import * clas

Re: Reading a file in same directory as code with relative path

2005-11-18 Thread [EMAIL PROTECTED]
Answer to a similar question: http://groups.google.com/group/comp.lang.python/msg/c01f292d7926f393?hl=en&; If you want a way that will work regardless if your module is run interactively, imported, or just run by itself, this is a solution that will always work: :: \wherever\wherever\ (the d

Re: Adding through recursion

2005-11-18 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Ben Finney <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > def add(x, y): > > if x == 0: > > print y > > return y > > else: > > x -= 1 > > y += 1 > > add(x, y) ... > def recursive_add

Re: examining python objects

2005-11-18 Thread Chris Mellon
On 18 Nov 2005 14:05:05 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > __repr__ almost always only prints a summary of it's > object, not the detailed internal structure that I want to > see. When it prints values, that are not pretty-printed, > nor are the objects that constitute the value

Re: Importing a class without knowing the module

2005-11-18 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: ... > > How do you arrange a module so that its classes' __module__ attributes > > don't tell you the name of the module "that would be useful", yet the > > module's __file__ DOES give you information that you can usefully > > process, heuristically I assume

Re: How to do "new_variable = (variable) ? True : False;" (php) on python?

2005-11-18 Thread Scott David Daniels
Peter Otten wrote: > Daniel Crespo wrote: >>new_variable = (variable) ? True : False; >>in Python in one line? > new_variable = variable Of course to answer your actual question: new_variable = variable and True or False But you should consider that Peter has given you a better answer than

Re: How to write an API for a Python application?

2005-11-18 Thread Duncan Grisby
In article <[EMAIL PROTECTED]>, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >A more lightweight solution might be Ice. >It is architecturally similar to Corba, but with less overhead. More lightweight and less overhead in what sense? The performance measurements

Re: examining python objects

2005-11-18 Thread rurpy
__repr__ almost always only prints a summary of it's object, not the detailed internal structure that I want to see. When it prints values, that are not pretty-printed, nor are the objects that constitute the value printed recursively. Writing my own __repr__() is emphatically what I don't want t

Re: Adding through recursion

2005-11-18 Thread Micah Elliott
On Nov 19, Ben Finney wrote: ... > This is just one of many reasons why I advocate always having a > *single* return statement, at the *end* of the function. Agreed that it's a good *general* practice, but sometimes early exit is useful and clear. This is somewhat of a religious topic. A goo

Re: Los Angeles Python Users' Group, anyone?

2005-11-18 Thread mortenbagai
Great, thanks! /M. -- http://mail.python.org/mailman/listinfo/python-list

Re: Choose meaningful subjects for posts [was: Re: newb ?]

2005-11-18 Thread skip
Grant> If I allowed news posts to interrupt me, I'd never get anything Grant> done. I limit e-mail to things that really do require fairly Grant> immediate attention. Well, I do try to limit the number of things I pay attention to. However, as the "Python guy" at work, participating

Re: Los Angeles Python Users' Group, anyone?

2005-11-18 Thread Grig Gheorghiu
[EMAIL PROTECTED] wrote: > Hi, > > I was rifling through python.org to see if there was an existing Python > user's group for the Los Angeles area. Doesn't seem like it, so maybe > we should start one? I'm interested in helping with the coordination of > activities etc. > > Since everybody living i

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Steve M
Another way to simulate the ternary operator is this: a = (quantity > 90 and "It is very huge") or "The value is correct" You have to be careful of semantics of 'and' and 'or'. But in this case I wonder why you don't just test whether quantity is greater than 90 and assign the corresponding value

Re: os.popen('alias')

2005-11-18 Thread Lars Kellogg-Stedman
> import os > for line in os.popen('alias').readlines(): > print line > > > No aliases are printed. > > I started python from an bash environment that had many aliases > defined. I expected to see the list of aliases from within the > intera

Re: func(*params)

2005-11-18 Thread David Duerrenmatt
Great, this is exactly what I was looking for. Thanks all of you for your immediate answer! Nick Smallbone schrieb: > David Duerrenmatt wrote: > >>Hi there >> >>For some reasons, I've to use Python 1.5.2 and am looking for a workaround: >> >>In newer Python versions, I can call a function thi

Re: func(*params)

2005-11-18 Thread Nick Smallbone
David Duerrenmatt wrote: > Hi there > > For some reasons, I've to use Python 1.5.2 and am looking for a workaround: > > In newer Python versions, I can call a function this way: > > func = some_function > func(*params) > I think the "apply" function is what you want: apply(object[, args[, kwargs]

Re: func(*params)

2005-11-18 Thread Peter Otten
David Duerrenmatt wrote: > For some reasons, I've to use Python 1.5.2 and am looking for a > workaround: > > In newer Python versions, I can call a function this way: > > func = some_function > func(*params) Use apply(func, params) Peter -- http://mail.python.org/mailman/listinfo/python-l

Re: check if com api is still available

2005-11-18 Thread Chris Mellon
On 11/18/05, Neil Hodgson <[EMAIL PROTECTED]> wrote: > Hermann Maier: > > > i am using the com api of a program and if this program is shut down and > > my program calls a method of the api, it crashs. that means, i need to > > check, if the com server is still available, before i can call for it.

func(*params)

2005-11-18 Thread David Duerrenmatt
Hi there For some reasons, I've to use Python 1.5.2 and am looking for a workaround: In newer Python versions, I can call a function this way: func = some_function func(*params) Then, the list/tuple named params will automatically be "expanded" and n=len(params) arguments will be submitted. P

Re: Adding through recursion

2005-11-18 Thread Ben Finney
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > def add(x, y): > if x == 0: > print y > return y > else: > x -= 1 > y += 1 > add(x, y) To add to the other good advice in this thread: This is just one of many reasons why I advocate always having a *si

Re: Los Angeles Python Users' Group, anyone?

2005-11-18 Thread Matt
[EMAIL PROTECTED] wrote: > Hi, > > I was rifling through python.org to see if there was an existing Python > user's group for the Los Angeles area. Doesn't seem like it, so maybe > we should start one? I'm interested in helping with the coordination of > activities etc. > > Since everybody living

Re: Behaviour of enumerated types (was: Re: Immutable instances, constant values)

2005-11-18 Thread Bengt Richter
On Fri, 18 Nov 2005 23:43:10 +1100 (EST), Ben Finney <[EMAIL PROTECTED]> wrote: >Bengt Richter <[EMAIL PROTECTED]> wrote: >> Ben Finney <[EMAIL PROTECTED]> wrote: >> >I've recently packaged 'enum' in PyPI. >> [...] >> My notion of enum comes from (what I remember of) Pascal > >You might want to in

Re: check if com api is still available

2005-11-18 Thread Neil Hodgson
Hermann Maier: > i am using the com api of a program and if this program is shut down and > my program calls a method of the api, it crashs. that means, i need to > check, if the com server is still available, before i can call for it. The server should not shut down while clients have outs

Re: examining python objects

2005-11-18 Thread Ben Finney
[EMAIL PROTECTED] wrote: > Is there a function/class/module/whatever I can use to look at > objects? The repr() function is what you want. > I want something that will print the object's value (if any) in > pretty-printed form, and list all it's attributes and their values. > And do all that recu

Re: Choose meaningful subjects for posts [was: Re: newb ?]

2005-11-18 Thread Micah Elliott
On Nov 18, Grant Edwards wrote: > There is an NNTP patch to allow you to use mutt to read Usenet > via an NNTP server. Yes, I'm aware of it; it's last (alpha) update was in 1999 and it probably has some fleas. :-) > Mutt users who don't do that seem to like slrn -- it has a very > similar look an

Re: Choose meaningful subjects for posts [was: Re: newb ?]

2005-11-18 Thread Grant Edwards
On 2005-11-18, Micah Elliott <[EMAIL PROTECTED]> wrote: > On Nov 18, [EMAIL PROTECTED] wrote: >> Grant> Obligatory aside: I'm completely baffled why anybody would choose >> Grant> the mailing list format over Usenet. I don't even read mailing >> Grant> lists via mailing lists. I recom

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Daniel Crespo
Hi Peter, Expand your mind. a = {'whatever': TernaryOperation(quantity>90,"It is very huge","The value is correct")} ;-) thanks for your advice anyway Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Web-based client code execution

2005-11-18 Thread Stephen Kellett
In message <[EMAIL PROTECTED]>, Steve <[EMAIL PROTECTED]> writes >AJAX works because browsers can execute javascript. I don't know of a >browser that can execute python. Basically your stuck with java or >javascript because everything else really isn't cross platform. ActiveState do a version o

Re: Choose meaningful subjects for posts [was: Re: newb ?]

2005-11-18 Thread Micah Elliott
On Nov 18, [EMAIL PROTECTED] wrote: > Grant> Obligatory aside: I'm completely baffled why anybody would choose > Grant> the mailing list format over Usenet. I don't even read mailing > Grant> lists via mailing lists. I recommend gmane.org's NNTP server for > Grant> all your mailin

Re: How to write an API for a Python application?

2005-11-18 Thread Piet van Oostrum
> Duncan Grisby <[EMAIL PROTECTED]> (DG) wrote: >DG> To me, the situation sounds complex enough, especially with the need >DG> for callbacks, that CORBA is an ideal solution. At the expense of a >DG> small amount of boilerplate code, all the communication issues are >DG> handled for you. In th

os.popen('alias')

2005-11-18 Thread Belebele
>From an interactive python shell, I execute the following: import os for line in os.popen('alias').readlines(): print line No aliases are printed. I started python from an bash environment that had many aliases defined. I expected to se

Re: Yield in a wrapper function

2005-11-18 Thread Bengt Richter
On 18 Nov 2005 05:08:39 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >This works exactly as you would expect:: > > from time import sleep > def foo(on='ABC'): >for e in list(on): >sleep(1) >yield e > >When I run this on the command line It takes about 3 seconds to >com

Type-checking unpickled objects

2005-11-18 Thread Gordon Airporte
I have this class, and I've been pickling it's objects as a file format for my program, which works great. The problems are a.) how to handle things when the user tries to load a non-pickled file, and b.) when they load a pickled file of the wrong class. a. I can handle with a general exception

Re: Choose meaningful subjects for posts [was: Re: newb ?]

2005-11-18 Thread skip
Grant> Obligatory aside: I'm completely baffled why anybody would choose Grant> the mailing list format over Usenet. I don't even read mailing Grant> lists via mailing lists. I recommend gmane.org's NNTP server for Grant> all your mailing list needs. For the same reason I don't

Re: Web-based client code execution

2005-11-18 Thread Steve
You universally won't be able to do that with javascript, only with and extension on firefox. ActiveX will limit you to windows only with ie. Which isn't bad you still get a 80% market share. -- http://mail.python.org/mailman/listinfo/python-list

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Grant Edwards
On 2005-11-18, Daniel Crespo <[EMAIL PROTECTED]> wrote: > I would like to know how can I do the PHP ternary operator/statement > (... ? ... : ...) in Python... The _PHP_ ternary operator (x?y:z)! Kids these days! -- Grant Edwards grante Yow! It's so OBVIOUS!!

Re: Web-based client code execution

2005-11-18 Thread Paul Watson
Steve wrote: > AJAX works because browsers can execute javascript. I don't know of a > browser that can execute python. Basically your stuck with java or > javascript because everything else really isn't cross platform. Well, I guess the Grail browser could run Python, but I do not think I can

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Peter Otten
Daniel Crespo wrote: > Oh... Well, thanks for that information. > > I'll do this then: > > def TernaryOperation(condition,true_part,false_part): > if condition: > return True-part > else: > return False-part > > a = {'Huge': TernaryOperation(quantity>90,True,False)} By

Re: Controlling windows gui applications from python

2005-11-18 Thread Paul Watson
tim wrote: > Hi all, I'm almost as new to this list as to python so I hope I don't > get a "this has been answered a 100 times before" or anything... > > Currently I am using a program named 'Macro Scheduler' for automating > programs that don't have a command line version. > Its a simple script

Re: Controlling windows gui applications from python

2005-11-18 Thread Simon Brunning
On 18/11/05, tim <[EMAIL PROTECTED]> wrote: > Hi all, I'm almost as new to this list as to python so I hope I don't > get a "this has been answered a 100 times before" or anything... > > Currently I am using a program named 'Macro Scheduler' for automating > programs that don't have a command line

Re: How to do "new_variable = (variable) ? True : False; " (php) on python?

2005-11-18 Thread Sam Pointon
Daniel Crespo wrote: > Hello to all, > > How can I do > > new_variable = (variable) ? True : False; > > in Python in one line? > > I want to do something like this: > > dic = {'item1': (variable) ? True-part : False-part} > > Any suggestions? > > Daniel There's a trick using the short-circuiting b

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Daniel Crespo
Oh... Well, thanks for that information. I'll do this then: def TernaryOperation(condition,true_part,false_part): if condition: return True-part else: return False-part a = {'Huge': TernaryOperation(quantity>90,True,False)} Thank you -- http://mail.python.org/mailman/l

Re: Web-based client code execution

2005-11-18 Thread Steve
AJAX works because browsers can execute javascript. I don't know of a browser that can execute python. Basically your stuck with java or javascript because everything else really isn't cross platform. -- http://mail.python.org/mailman/listinfo/python-list

Re: Choose meaningful subjects for posts [was: Re: newb ?]

2005-11-18 Thread Grant Edwards
On 2005-11-18, Mike Meyer <[EMAIL PROTECTED]> wrote: >>> http://www.catb.org/~esr/faqs/smart-questions.html#bespecific >>> before you post your next question. If I can't tell from the subject line what the thread is about, I almost never read it. >> Note also that the subject line on an exis

Controlling windows gui applications from python

2005-11-18 Thread tim
Hi all, I'm almost as new to this list as to python so I hope I don't get a "this has been answered a 100 times before" or anything... Currently I am using a program named 'Macro Scheduler' for automating programs that don't have a command line version. Its a simple scripting language that allow

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread gene tani
Mike Meyer wrote: > "Daniel Crespo" <[EMAIL PROTECTED]> writes: > > > Hi! > > > > I would like to know how can I do the PHP ternary operator/statement > > (... ? ... : ...) in Python... > > > > I want to something like: > > > > a = {'Huge': (quantity>90) ? True : False} > > > > Any suggestions? >

Re: Python on linux

2005-11-18 Thread Sybren Stuvel
John Abel enlightened us with: > Here's one I used a while back. Returns a dict containing details per > partition This only gives information about actually mounted partitions. It could be improved by checking /proc/partitions as well. Sybren -- The problem with the world is stupidity. Not sa

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Mike Meyer
"Daniel Crespo" <[EMAIL PROTECTED]> writes: > Hi! > > I would like to know how can I do the PHP ternary operator/statement > (... ? ... : ...) in Python... > > I want to something like: > > a = {'Huge': (quantity>90) ? True : False} > > Any suggestions? Lots of ways, depending on your exact needs

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread David Wahler
Daniel Crespo wrote: > I would like to know how can I do the PHP ternary operator/statement > (... ? ... : ...) in Python... > > I want to something like: > > a = {'Huge': (quantity>90) ? True : False} Well, in your example the '>' operator already returns a boolean value so you can just use it di

Web-based client code execution

2005-11-18 Thread Paul Watson
What are the options? The user to hits a web page, downloads code (Python I hope), execute it, and be able to return the results. It needs to be able to go through standard HTTP so that it could be run from behind a corporate firewall without any other ports being opened. Am I stuck doing an

Re: How to do "new_variable = (variable) ? True : False; " (php) on python?

2005-11-18 Thread Peter Otten
Daniel Crespo wrote: > How can I do > > new_variable = (variable) ? True : False; > > in Python in one line? new_variable = variable :-) Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: path module / class

2005-11-18 Thread [EMAIL PROTECTED]
Hi Neil, Neil Hodgson wrote: [snip] > There is no PEP yet but there is a wiki page. > http://wiki.python.org/moin/PathClass > Guido was unenthusiastic so a good step would be to produce some > compelling examples. I guess it depends on what is "compelling" :) I've been trying to come up

  1   2   >