I wrote:
Kent Johnson wrote:
You can do the same thing using a PYTHONSTARTUP file - see
http://docs.python.org/tut/node4.html#SECTION00424
You can change the prompts with
import sys
sys.ps1 = ' >>> '
sys.ps2 = ' ... '
Very cool. I didn't know about this. Does anyone know how to
Bengt Richter wrote:
Not true on NT4 at least:
Alt-Spacebar gets you the system menu
paste into the dos window with Alt-spacebar e p
Thanks immensely for this -- I love it.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 17 Dec 2004 08:03:12 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote:
>Steven Bethard wrote:
>> Very cool. I didn't know about this. Does anyone know how to make it
>> work with Pythonwin[1]? (Obviously, I can type the above in manually
>> every time, but I'd much rather have Pythonwin
Keith Dart wrote:
> Fernando Perez wrote:
>
>>
>>
>> You might want to look at ipython:
>>
>> http://ipython.scipy.org,
>>
>>
>>
>>
>
> I did just recently install that. It looks very nice. Would make a great
> interactive prompt for an IDE, as well.
Glad you like it :) And yes, there are
Kent Johnson wrote:
You can copy and paste from a Windows command prompt. It's a bit
bizarre, but
- In the system menu for a command window, pick Properties
- On the Options tab, turn on Quick Edit mode
- Now you can copy and paste with right-click (!). If you have text
selected, right-click will
Steven Bethard wrote:
Very cool. I didn't know about this. Does anyone know how to make it
work with Pythonwin[1]? (Obviously, I can type the above in manually
every time, but I'd much rather have Pythonwin do this automatically for
me.)
Steve
[1] I'd do my example code at the command prompt
Thought you might enjoy my super-small flatten function: (though google
groups seems to be munging my whitespace today)
def flatten(d):
"flatten([[[1,[2,3],[4,5]],6],[7]])==[1,2,3,4,5,6,7]"
return reduce(lambda a,b:a+b,[(type(x) in (list, tuple) \
and flatten(x) or [x]) for x in d])
--
http://ma
Fernando Perez wrote:
You might want to look at ipython:
http://ipython.scipy.org,
I did just recently install that. It looks very nice. Would make a great
interactive prompt for an IDE, as well.
--
\/ \/
(O O)
-- oOOo~(
Kent Johnson wrote:
> Keith Dart wrote:
>> What I do is set Python's sys.ps1 variable to something else. I have a
>> module called "interactive" that I import implicitly by shell alias:
>>
>> py='python -i -c '\''import interactive'\'
>>
>> Which, among other things, sets the prompt to "Python>
Kent Johnson wrote:
You can do the same thing using a PYTHONSTARTUP file - see
http://docs.python.org/tut/node4.html#SECTION00424
You can change the prompts with
import sys
sys.ps1 = ' >>> '
sys.ps2 = ' ... '
Very cool. I didn't know about this. Does anyone know how to make it
Keith Dart wrote:
What I do is set Python's sys.ps1 variable to something else. I have a
module called "interactive" that I import implicitly by shell alias:
py='python -i -c '\''import interactive'\'
Which, among other things, sets the prompt to "Python> "
You can do the same thing using a PYTHO
Steve Holden wrote:
Nick Coghlan wrote:
$ python
Python 2.4 (#1, Dec 4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.ps1 = ".>>> "; sys.ps2 = " "
.>>> print """\
It isn't that hard"""
Steve Holden wrote:
Nick Coghlan wrote:
Roel Schroeven wrote:
Stefan Behnel wrote:
This is the first time I see that and I totally like the idea of
writing ".>>>" instead of ">>>" at the beginning of a line. Thank
you Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as
the default pr
Nick Coghlan wrote:
Roel Schroeven wrote:
Stefan Behnel wrote:
This is the first time I see that and I totally like the idea of
writing ".>>>" instead of ">>>" at the beginning of a line. Thank you
Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as the
default prompt as it messes up
Nick Coghlan wrote:
(FYI, I filed bug report #1085744 on SF about this)
And Raymond Hettinger was able to decipher my somewhat incoherent rambling (tip:
don't try to write bug reports in the wee hours of the morning) and produce a
potentially useful modification to PySequence_Tuple.
Anyway, I gu
Roel Schroeven wrote:
Stefan Behnel wrote:
This is the first time I see that and I totally like the idea of
writing ".>>>" instead of ">>>" at the beginning of a line. Thank you
Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as the
default prompt as it messes up the display on mail
Stefan Behnel wrote:
Nick Coghlan schrieb:
data = [['foo','bar','baz'],['my','your'],['holy','grail']]
result = []
for d in data:
.>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
.>>> from itertools import chain
.>>> result = "".join(chain(*data))
'foobarbazmyyourholygrail'
This i
Nick Coghlan schrieb:
data = [['foo','bar','baz'],['my','your'],['holy','grail']]
result = []
for d in data:
.>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
.>>> from itertools import chain
.>>> result = "".join(chain(*data))
'foobarbazmyyourholygrail'
This is the first time I see
Matthew Moss wrote:
>> >>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
>> >>> [e for l in data for e in l]
>> ['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
>
> Okay, I tried this in an interactive Python session and it works as
> stated. My question is, why? How is the inte
Diez B. Roggisch wrote:
> >>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
> >>> [e for l in data for e in l]
> ['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
Okay, I tried this in an interactive Python session and it works as
stated. My question is, why? How is the interpre
Will Stuyvesant wrote:
Here is a question about list comprehensions [lc]. The
question is dumb because I can do without [lc]; but I am
posing the question because I am curious.
This:
data = [['foo','bar','baz'],['my','your'],['holy','grail']]
result = []
for d in data:
... for w in d:
...
Timothy Babytch wrote:
Will Stuyvesant wrote:
data = [['foo','bar','baz'],['my','your'],['holy','grail']]
sum(data, [])
['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
The second parameter passed to sum is just to overrride default
initial value "zero".
It's worth keeping in mind that this so
Steven Bethard wrote:
> > python -m timeit -s "data = [range(10) for _ in range(1000)]"
> "sum(data, [])"
> 10 loops, best of 3: 54.2 msec per loop
>
> > python -m timeit -s "data = [range(10) for _ in range(1000)]" "[w for
> d in data for w in d]"
> 100 loops, best of 3: 1.75 msec per loop
>
> Th
Will Stuyvesant wrote:
data = [['foo','bar','baz'],['my','your'],['holy','grail']]
sum(data, [])
['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
The second parameter passed to sum is just to overrride default
initial value "zero".
--
Timothy Babytch
--
http://mail.python.org/mailman/listinfo/p
On Tue, 14 Dec 2004 00:41:36 +0100, Max M wrote:
> Fredrik Lundh wrote:
>> Max M wrote:
>>
>>
I tried funnies like [[w for w in L] for L in data],
>>>
>>>That is absolutely correct. It's not a funnie at all.
>>
>> well, syntactically correct or not, it doesn't do what he want...
>
> Doh! *
Okay that was fun. Enlightening as I hoped. unroll() in Python, for
arbitrary depth, _flatten in Tkinter (what else is in Tkinter!), sum()
abuse.
The sum(data,[]) was funniest, it works like ((['foo','bar'] + []) +
['my','your']) + ['holy','grail']. Before I think of such things I
have already
Max M wrote:
>> I tried funnies like [[w for w in L] for L in data],
>> that is correct syntax, but you'd never guess.
>
> That is absolutely correct. It's not a funnie at all. If you find it odd it's
> only because you are
> not used to list comprehensiones.
well, syntactically correct or not,
Fredrik Lundh wrote:
Max M wrote:
I tried funnies like [[w for w in L] for L in data],
That is absolutely correct. It's not a funnie at all.
well, syntactically correct or not, it doesn't do what he want...
Doh! *I* might not be used to list comprehensions then... You are right.
That example could
Will Stuyvesant wrote:
I tried funnies like [[w for w in L] for L in data],
that is correct syntax, but you'd never guess.
That is absolutely correct. It's not a funnie at all. If you find it odd
it's only because you are not used to list comprehensiones.
In that case you might be more comfortabl
Will Stuyvesant wrote:
data = [['foo','bar','baz'],['my','your'],['holy','grail']]
result = []
for d in data:
> ... for w in d:
> ...result.append(w)
print result
> ['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
>
> puts all the words in a list, like I want.
Here is a question about list comprehensions [lc]. The
question is dumb because I can do without [lc]; but I am
posing the question because I am curious.
This:
>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
>>> result = []
>>> for d in data:
... for w in d:
...result
>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
>>> [e for l in data for e in l]
['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
--
Regards,
Diez B. Roggisch
--
http://mail.python.org/mailman/listinfo/python-list
Will Stuyvesant wrote:
data = [['foo','bar','baz'],['my','your'],['holy','grail']]
result = []
for d in data:
... for w in d:
...result.append(w)
print result
['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
Take advantage of the fact that you can have more than one 'for' in a
list
I guess the simplest to do it is like this:
>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
>>> result=[w for d in data for w in d]
>>> result
['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
>>>
--
http://mail.python.org/mailman/listinfo/python-list
James Stroud wrote:
> Here is one for arbitrary depth:
>
> def unroll(ary):
> unrolled = []
> for item in ary:
># add test for your favorite sequence type
>if ( type(item) == types.ListType or \
> type(item) == types.TupleType \
> ):
> unrolled.extend(unroll(item
Here is one for arbitrary depth:
def unroll(ary):
unrolled = []
for item in ary:
# add test for your favorite sequence type
if ( type(item) == types.ListType or \
type(item) == types.TupleType \
):
unrolled.extend(unroll(item))
else:
unrolled.appen
I guess the simplest way to do it is like this:
>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
>>> result=[w for d in data for w in d]
>>> result
['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
>>>
--
http://mail.python.org/mailman/listinfo/python-list
37 matches
Mail list logo