Chris Angelico | 1 Dec 03:14 2011
Picon

Re: Need some IPC pointers

On Thu, Dec 1, 2011 at 8:03 AM, Andrew Berg <bahamutzero8825 <at> gmail.com> wrote:
> processes (that aren't necessarily written in Python) ...
> non-local processes would be nice ...
> The implementation needs to be cross-platform ...
> I don't think I'll ever need to transfer anything complicated or large -
> just strings or possibly tuples/lists.
> I'm thinking sockets, but perhaps there's something simpler/easier.

Definitely sockets, as other posters have said. The only question is,
what encapsulation format (since sockets give just a stream of bytes).
Since you want non-Python processes to be involved, I would be
inclined to avoid using Python's own pickling system; JSON may be
viable, and it's well known so you should be able to find support in
other languages. Alternatively, take a careful look at your dataset
and invent your own system. If your strings will never contain a pipe
character, you could define a tuple/list to be simply pipe-separated
strings; if they'll never contain newlines, you can specify your
protocol to be newline-terminated. For command/response protocols over
TCP/IP, I strongly recommend poking around with existing protocols
such as the email trio (SMTP, POP, and IMAP); there's many good ideas
to be gained from them.

If you can, try to keep your protocol to ASCII text. It makes
debugging far easier, as you can simply point a telnet/mud client at
your server and manually step through things.

Chris Angelico
Roy Smith | 1 Dec 04:15 2011
Picon

Clever hack or code abomination?

I need to try a bunch of names in sequence until I find one that works 
(definition of "works" is unimportant).  The algorithm is:

1) Given a base name, "foo", first see if just plain "foo" works.

2) If not, try "foo-1", "foo-2", and so on

3) If you reach "foo-20", give up.

What would you say if you saw this:

for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]:

It generates the right sequence of strings.  But, if you came upon that 
code, would it make sense to you, or would you spend half the afternoon 
trying to figure out what it did and the other half of the afternoon 
ranting about the deranged lunatic who wrote it?
Steven D'Aprano | 1 Dec 04:38 2011

Re: Clever hack or code abomination?

On Wed, 30 Nov 2011 22:15:27 -0500, Roy Smith wrote:

> I need to try a bunch of names in sequence until I find one that works
> (definition of "works" is unimportant).  The algorithm is:
> 
> 1) Given a base name, "foo", first see if just plain "foo" works.
> 
> 2) If not, try "foo-1", "foo-2", and so on
> 
> 3) If you reach "foo-20", give up.
> 
> What would you say if you saw this:
> 
> for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]:
> 
> It generates the right sequence of strings.  But, if you came upon that
> code, would it make sense to you, or would you spend half the afternoon
> trying to figure out what it did and the other half of the afternoon
> ranting about the deranged lunatic who wrote it?

Nah, it's fine. Not exactly the clearest piece of code in the world, but 
hardly worth a rant.

I'd be more likely to write that as:

for suffix in [''] + ["-%d" % i for i in range(1, 21)]:

or if I needed to do it more than once, as a generator:

def suffixes(max=20):
(Continue reading)

Steven D'Aprano | 1 Dec 04:42 2011

Re: How convert a list string to a real list

On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote:

> I think it would be better if safe_eval were available as an easily
> accessible builtin and dangerous_eval were tucked away in a module ;-).

+100000

--

-- 
Steven
Matt Joiner | 1 Dec 04:49 2011
Picon

Re: Clever hack or code abomination?

def possible_names():
    yield "foo"
    for i in range(20):
        yield "foo-" + str(i)

ಠ_ಠ

On Thu, Dec 1, 2011 at 2:15 PM, Roy Smith <roy <at> panix.com> wrote:
> I need to try a bunch of names in sequence until I find one that works
> (definition of "works" is unimportant).  The algorithm is:
>
> 1) Given a base name, "foo", first see if just plain "foo" works.
>
> 2) If not, try "foo-1", "foo-2", and so on
>
> 3) If you reach "foo-20", give up.
>
> What would you say if you saw this:
>
> for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]:
>
> It generates the right sequence of strings.  But, if you came upon that
> code, would it make sense to you, or would you spend half the afternoon
> trying to figure out what it did and the other half of the afternoon
> ranting about the deranged lunatic who wrote it?
> --
> http://mail.python.org/mailman/listinfo/python-list
--

-- 
http://mail.python.org/mailman/listinfo/python-list
(Continue reading)

Steven D'Aprano | 1 Dec 05:17 2011

Disable readline

Is there a way to disable readline support in the interactive interpreter 
at runtime? Either from within an existing session, or when the session 
starts up will do.

I am trying to test the behaviour of some interactive scripts which rely 
on readline. I have work-arounds for missing readline (such as on Windows 
systems) but no way to test them properly on Linux.

If all else fails, are there any traps or pitfalls in installing a second 
Python installation with readline support disabled?

Any other suggestions?

--

-- 
Steven
Ben Finney | 1 Dec 05:25 2011
Picon

Re: How convert a list string to a real list

Steven D'Aprano <steve+comp.lang.python <at> pearwood.info> writes:

> On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote:
>
> > I think it would be better if safe_eval were available as an easily
> > accessible builtin and dangerous_eval were tucked away in a module ;-).
>
> +100000

You do realise that any vote outside the range −1 through +1 is invalid,
right? Every person gets a maximum of 1, positive or negative. Outside
that, the vote police come to kick you off the internet.

-- 
 \                             “Everything is futile.” —Marvin of Borg |
  `\                                                                   |
_o__)                                                                  |
Ben Finney
--

-- 
http://mail.python.org/mailman/listinfo/python-list
Alec Taylor | 1 Dec 05:33 2011
Picon

Re: How convert a list string to a real list

Dammit, been awake too long researching on the Internet, but I finally
reached the Last Page

On Thu, Dec 1, 2011 at 3:25 PM, Ben Finney <ben+python <at> benfinney.id.au> wrote:
> Steven D'Aprano <steve+comp.lang.python <at> pearwood.info> writes:
>
>> On Wed, 30 Nov 2011 17:12:10 -0500, Terry Reedy wrote:
>>
>> > I think it would be better if safe_eval were available as an easily
>> > accessible builtin and dangerous_eval were tucked away in a module ;-).
>>
>> +100000
>
> You do realise that any vote outside the range -1 through +1 is invalid,
> right? Every person gets a maximum of 1, positive or negative. Outside
> that, the vote police come to kick you off the internet.
>
> --
>  \                             "Everything is futile." --Marvin of Borg |
>  `\                                                                   |
> _o__)                                                                  |
> Ben Finney
> --
> http://mail.python.org/mailman/listinfo/python-list
Alec Taylor | 1 Dec 05:35 2011
Picon

Re: Need some IPC pointers

Sure, I'll give you some pointers:

0x3A28213A
0x6339392C
0x7363682E
Roy Smith | 1 Dec 06:00 2011
Picon

Re: Disable readline

In article <4ed6ffed$0$29986$c3e8da3$5496439d <at> news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python <at> pearwood.info> wrote:

> Is there a way to disable readline support in the interactive interpreter 
> at runtime? Either from within an existing session, or when the session 
> starts up will do.

I'm assuming Python uses the standard GNU readline().  If that's 
correct, then you can configure its behavior by editing your ~/.inputrc 
file.  Try "man readline".  I don't see any global "disable readline" 
flag, but you may be able to get that effect by deleting all the key 
mappings, or some such silliness.

Another possibility is setting your TERM environment variable to 
something that readline can't support:

~$ TERM=asr33
~$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Cannot read termcap database;
using dumb terminal settings.
Cannot read termcap database;
using dumb terminal settings.
Cannot read termcap database;
using dumb terminal settings.
>>> 

 
(Continue reading)


Gmane