> x = (list(l), list(r))
BTW: I prefer this syntax, because it makes the copy explicit, while
l[:] seems to me more "implicit" ...
Best regards,
Gabriel.
--
__
Life is so constructed that the event does not, cannot,
will not matc
Thanks a lot for your response, too.
Best regards,
Gabriel.
--
__
Life is so constructed that the event does not, cannot,
will not match the expectation. (Charlotte Bronte)
> If you're familiar with C or C++, think of s as holding a pointer to x
> which in turn holds a pointer to l and r, so when you change l or r, x
> (and s indirectly) is still pointing to the same lists which by the
AH - thanks a million -- that makes it crystal clear!
[Python's apparent simplici
> I'm using list(l) to copy the list, Tero uses l[:], but the idea is
> the same.
>
Thanks a lot for your response and the hint.
> But do you just want all proper partitions of lst? Then this is much
> simpler:
> lst = [0, 1, 2]
> s = [(lst[:i], lst[i:]) for i in range(1, len(lst))]
Ah, thanks
Well,
could some kind soul please explain to me why the following trivial code is
misbehaving?
#!/usr/bin/python
lst = [ 0, 1, 2 ]
s = []
l = [ lst[0] ]
r = lst[1:]
while r:
x = (l,r)
print x
s.append( x )
l.append( r.pop(0) )
print s
The output I get is:
([0], [1, 2])
([
Well,
could some kind soul please explain to me why the following trivial code
is misbehaving?
#!/usr/bin/python
s = []
l = [ 0 ]
r = [0, 0]
while r:
x = (l,r)
print x
s.append( x )
l.append( r.pop(0) )
print s
The output I get is:
([0], [0, 0])
([0, 0], [0])
> headers = {}
> headers['User-Agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB;
> rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4'
>
> request = urllib2.Request(url, headers)
> file = urllib2.urlopen(request)
ah, thanks a lot, that works !
Best regards,
Gabriel.
--
/
> On the other hand something which is simply retrieving one or two fixed
> pages doesn't fit that definition of a bot so is probably alright. They
i think so, too.
even provide a link to some frameworks for writing bots e.g.
>
> http://sourceforge.net/projects/pywikipediabot/
ah, that looks
Here is a very simple Python script utilizing urllib:
import urllib
url =
"http://commons.wikimedia.org/wiki/Commons:Featured_pictures/chronological";
print url
print
file = urllib.urlopen( url )
mime = file.info()
print mime
print file.read()
print fi
I understand the Wikipedia article on Polymorphism
( http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29 )
that it doesn't make sense to talk about polymorphism in a fully dynamically
typed language -- does the Python community agree?
cheers,
gabriel.
--
/--
I was wondering why python doesn't contain a way to make things "const"?
If it were possible to "declare" variables at the time they are bound to
objects that they should not allow modification of the object, then we would
have a concept _orthogonal_ to data types themselves and, as a by-produc
> the problem isn't determining who owns it, the problem is determining
> who's supposed to release it. that's not a very common problem in a
that's about what i meant.
i think, in c++, the "ownership problem" means the problem to determine who
and when is to delete an object, or to keep track t
Is it correct to say that the typical ownership problem, which frequently
arises in C++, does not occur normally in Python?
Best regards,
Gabriel.
--
/---\
| Any intelligent fool can make things bigger, more complex,
> We've just had a HUGE thread arguing about this behaviour, just three or
> five days ago. Let's not start it again.
ok, could you please point me to it?
> In a nutshell, the behaviour is because ints are immutable and can't be
> changed in place, and lists are mutable and can be changed in plac
Is there a way to combine doxygen comments, like this one
## Documentation for a function.
# @var a - variable
# More details.
def func( a ):
pass
with the doc strings, like this one
def func( a ):
""" Documentation for a function.
More details.
"""
pass
?
Ob
It seems to me that the following behavior of python (2.4.1) is inconsistent:
>>> a=1
>>> b=a
>>> a+=1
>>> b
1
>>> a
2
>>> a=[1,2]
>>> b=a
>>> b+=[3]
>>> a
[1, 2, 3]
>>> b
[1, 2, 3]
Why was it implemented like this??
Best regards,
Gabriel.
--
/
16 matches
Mail list logo