On 26/07/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> Wow, it was actually quite a bit harder to Google than I thought :)
> well, some experimentation leads me to believe this is the syntax for
> list slicing:
[...]
It's in the docs, albeit rather tersely:
http://www.python.org/doc/current/l
when you use the 3rd element, it's called the extended slice syntax.
here are a few more examples:
>>> x = 'python programming'
>>> x[::-1]
'gnimmargorp nohtyp'
>>> x[2:12:2]
'to rg'
>>>
ironically, this feature has been available in the interpreter for
many years, but it wasn't until circa 2.3 t
Dick Moores wrote:
> At 08:38 PM 7/25/2007, Luke Paireepinart wrote:
>> > I would like to know what exactly the index notation of [::-1] is,
>> where
>> > it comes from and if there are other variants.
>> >
>> This is called list slicing. Look into it to figure out what all this
>> stuff means.
>
At 08:38 PM 7/25/2007, Luke Paireepinart wrote:
> > I would like to know what exactly the index notation of [::-1] is, where
> > it comes from and if there are other variants.
> >
>This is called list slicing. Look into it to figure out what all this
>stuff means.
>I could send you a link but I'd
As promised, here's some comments on your code.
from livewires import *
begin_graphics()
allow_moveables()
def place_player():
global player_x
global player_y
global player_shape
player_y = random_between(0,47)
player_x = random_between(0,63)
player_shape = circle(10*pla
cuell wrote:
> In order to reverse the order of an array, I discovered that I'm
> supposed to use [::-1].
>
I don't know if 'supposed to' is the correct term.
You could just as easily get away with using ['a','b','c'].reverse().
However, below you're using 'array' and I'm not sure exacly what
In order to reverse the order of an array, I discovered that I'm
supposed to use [::-1].
>>> a = array([1., 2., 3.])
>>> a
array([ 1., 2., 3.])
>>> a[::-1]
array([ 3., 2., 1.])
>>>
I would like to know what exactly the index notation of [::-1] is, where
it comes from and if there are o
Tonu Mikk wrote:
> Thanks for offering to help! I am following the Livewires exercise
> (attached file "5-robots.pdf"). I have gotten as far as page 7.
> Attached is also my code so far in robotsarecoming-teleport.py.
> Question 1. I was checking for collision of a robot and player first
> i
Alan Gauld wrote:
> "Terry Carroll" <[EMAIL PROTECTED]> wrote
>
>> if Y in X:
>
> FWIW I believe that 'in' did only work for single characters up until
> version 2.X so your ideas may have been based on experiences with
> an earlier Python version.
Yes, it changed in Python 2.3.
Kent
Kent Johnson wrote:
> Tonu Mikk wrote:
>
>> I also
>> began reading and coding the Livewires course exercises
>> (http://www.livewires.org.uk/python/). I have gotten through the first
>> 4 exercise, but got stuck with the last one where we build a robot
>> game. The Livewires coding exerci
"Terry Carroll" <[EMAIL PROTECTED]> wrote
> if Y in X:
>
> Which is much more elegant/pythonic; but I didn't know you could do
> that
> with one string over another. For some reason, I had thought Y
> would have
> to exactly match one iterable element in X (e.g., one element of a
> list,
>
On Tue, 24 Jul 2007, wesley chun wrote:
> i don't have any time myself either (getting ready for OSCON talk),
> but i'm not sure what terry's OP was about... looking for a
> well-written piece of code, a faster-performing snippet, or both? i
> think he was just unsatissfied with his 1st attempt.
> By the way, this is an important and fundamental subject about
> Python. When I teach classes on Python, I always need to explain
> Python's execution model, and I always struggle with it. So,
> anything you can tell me that would help me teach this will be much
> appreciated.
>
> Dave
The way
Tonu Mikk wrote:
> I also
> began reading and coding the Livewires course exercises
> (http://www.livewires.org.uk/python/). I have gotten through the first
> 4 exercise, but got stuck with the last one where we build a robot
> game. The Livewires coding exercise uses modules that can be down
Hello, I am at a very beginning on trying to learn Python. So far I
have read first few chapters of Alan Gauld tutorials, and completed all
the exercises of Guido van Robot (http://gvr.sourceforge.net/). I also
began reading and coding the Livewires course exercises
(http://www.livewires.org.
> I found the problem. It was rather simple actually. I didn't have remote
> logging enabled for syslog. Even though I was logging to localhost, for
> some reason, it wouldn't work until I gave syslogd a -r at startup.
> Thanks
localhost is still remote, in that sockets are used to reach it. Th
> Cheers for the critique I'll take you points on board .especially
> this schoolboy error
It's not an error, really. It will work. Just... not intuitive
Errors are things that do not work.
> One thing to note about the re expression is that the products are not
> these were just substitutes
Alan Gauld wrote:
> "Kent Johnson" <[EMAIL PROTECTED]> wrote
>
>
>>> Perl executes differently to Python in that it does a compilation
>>> stage before executing. Therefore Perl knows about all the function
>>> definitions prior to executing any code. Python compiles modules
>>> which it import
On Wed, Jul 25, 2007 at 06:21:08PM +0100, Alan Gauld wrote:
>
> I'm not sure if the undefined name errors come from the compilation
> or from the execution - does anyone else. I confess i've never looked
> deeply into how Python actually does its complile/execute cycle.
>
A couple of points that
Alan Gauld wrote:
> "Kent Johnson" <[EMAIL PROTECTED]> wrote
>> scripts. However this has no bearing on the current thread; for both
>> imported modules and executed scripts, a function must be defined
>> before
>> it can be called.
>
> Yes, the bearing is in the way that Perl compiles its code.
"Kent Johnson" <[EMAIL PROTECTED]> wrote
>> Perl executes differently to Python in that it does a compilation
>> stage before executing. Therefore Perl knows about all the function
>> definitions prior to executing any code. Python compiles modules
>> which it imports
>> but not scripts which it
Alan Gauld wrote:
> "nibudh" <[EMAIL PROTECTED]> wrote
>
>
>> in perl this works:
>>
>> #!/usr/bin/env perl
>> hello("World");
>>
>> sub hello {
>>print "Hello ". $_[0] . "\n";
>> }
>>
>
>
> Perl executes differently to Python in that it does a compilation
> stage
> before executing. T
Alan Gauld wrote:
> "nibudh" <[EMAIL PROTECTED]> wrote
>
>> in perl this works:
>>
>> #!/usr/bin/env perl
>> hello("World");
>>
>> sub hello {
>>print "Hello ". $_[0] . "\n";
>> }
>
>
> Perl executes differently to Python in that it does a compilation
> stage
> before executing. Therefore P
Thanks for the reply Kent.
I found the problem. It was rather simple actually. I didn't have remote
logging enabled for syslog. Even though I was logging to localhost, for
some reason, it wouldn't work until I gave syslogd a -r at startup. Thanks
jay
On 7/25/07, Kent Johnson <[EMAIL PROTECTE
"nibudh" <[EMAIL PROTECTED]> wrote
> in perl this works:
>
> #!/usr/bin/env perl
> hello("World");
>
> sub hello {
>print "Hello ". $_[0] . "\n";
> }
Perl executes differently to Python in that it does a compilation
stage
before executing. Therefore Perl knows about all the function
defini
Andrew Purdea wrote:
> Hello!
> I can see that lists have implemented these methods in jython..
> But i can not find any documentation on this. It looks like python
> compares each element, and and when it finds a difference, it returns.
> Where can i find documenation on this? Will this be
Andrew Purdea wrote:
> Hello!
> I can see that lists have implemented these methods in jython..
> But i can not find any documentation on this. It looks like python
> compares each element, and and when it finds a difference, it returns.
> Where can i find documenation on this?
In python 2.
Beanan O Loughlin wrote:
> Hi all, I'm a meteorology postgrad working with python for the first time.
>
> I have found the location minimum in a large covariance matrix. this
> value corresponds to the covariance of two points on a latitude,
> longitude grid.
>
> I need to find a method to locate
Hi Kent and Alan,
Thanks for the responses. It really got me thinking!
To test what i thought i knew, i wrote a "hello world" script in perl and
python.
in perl this works:
#!/usr/bin/env perl
hello("World");
sub hello {
print "Hello ". $_[0] . "\n";
}
but in python:
#!/usr/bin/env pytho
Cheers for the critique I'll take you points on board .especially
this schoolboy error
def findTestDirectories(path):
os.chdir(path)
directory_listing = os.listdir(os.getcwd())
--
Change this to
directory_listing = os.listdir(path)
Why look up the current directory
jay wrote:
> Hello,
>
> I'm trying to setup simple Syslog logging in python using the logging
> module. I would like to use a config file, but so far haven't been able
> to get the correct configuration. Actually, I don't get any warnings or
> errors, program runs fine, but nothing is logged
Alan Gauld wrote:
> "nibudh" <[EMAIL PROTECTED]> wrote
>
>> I looked over my code (all 41 lines!) and couldn't find anything,
>> then on a
>> hunch i moved the def statement _above_ the rest of my code and hey
>> presto
>> it worked.
>>
>> I vaguely understand why this is happening, but can some
Hello!
I can see that lists have implemented these methods in jython..
But i can not find any documentation on this. It looks like python
compares each element, and and when it finds a difference, it returns.
Where can i find documenation on this? Will this behaviour remain in
python for futur
"nibudh" <[EMAIL PROTECTED]> wrote
> I looked over my code (all 41 lines!) and couldn't find anything,
> then on a
> hunch i moved the def statement _above_ the rest of my code and hey
> presto
> it worked.
>
> I vaguely understand why this is happening, but can someone explain
> it to
> me.
Hi list,
I've just been writing a small script to parse some xml files and output tab
separated values into a separate file.
I was surprised to see that my function "processXML(fpart)" was failing with
an error along the lines of "processXML not defined"
I looked over my code (all 41 lines!) an
35 matches
Mail list logo