On 11/28/2013 02:34 AM, Alan Gauld wrote:
Not so. If you are looking for a string and know the string ends with that
string you want the end point to exclude the known result at the end. And it is
a startswith because you are checking from the
start of the substring.
Ah, thank you, Alan!
Denis
On 11/29/2013 06:20 AM, eryksun wrote:
On Wed, Nov 27, 2013 at 10:04 AM, Arnaud Legout wrote:
[...]
For what it's worth, a personal point of view on Python class defs. I ended up
undertanding class definitions as code blocks the following way:
Imagine Python has kinds of free sections of co
On 11/29/2013 02:19 PM, uga...@talktalk.net wrote:
I have also looked at locale.py Line 494 of which is the last line of a def
(def function?) I include this below, hopefully this may save you searching for
locale.py (Pyhon 2.6) should you need it and wish to answer the above
questions, it may
On 12/01/2013 06:50 AM, Reuben wrote:
Hi,
How can we write a logic for detecting the number 2 in range from 1 to 100
Do you mean:
if 2 in numbers:
?
Also for a more general solution, think at the very nice function any(bools), in
combination with a generator comprehension:
On 12/01/2013 05:32 AM, Amit Saha wrote:
Hello,
I was told by someone (as a comment) that a code snippet such as this
"would make Pythonistas talk my ear off about how evil the append()"
function is:
mylist = []
mylist.append(1)
# a number of times over
I have some ideas that on an append()
On 12/01/2013 10:03 AM, Amit Saha wrote:
Hello,
Much to my disbelief, I realized I hadn't written a program in Python
as far as I can recall which required me to do something like this, in
psuedocode:
x = 0.1
for i = 0 to x step 0.01
# do something with i
end i
Simply stated, I want to start
On 12/01/2013 08:28 PM, richard kappler wrote:
I have a script that reads sensor values gathered by an Arduino board from
serial as a dictionary, said values to later be used in the AI for Nav &
Control. Here's the script:
#!/usr/bin/python
def sensorRead():
import serial
from time im
On 12/02/2013 03:25 AM, Byron Ruffin wrote:
The following program works and does what I want except for one last
problem I need to handle. The program reads a txt file of senators and
their associated states and when I input the last name it gives me their
state. The problem is "Udall". There
On 12/02/2013 04:53 PM, Steven D'Aprano wrote:
Also, the above function leaves LATIN CAPITAL LETTER O WITH STROKE as Ø
instead of stripping the stroke. I'm not sure whether that is an
oversight or by design. Likewise for the lowercase version. You might
want to do some post-processing:
There's
On 12/04/2013 10:35 AM, Ismar Sehic wrote:
[...]
Your presentation is a bit abscure (to me, at least): it is hard to help you.
Maybe you could explain better, and progressively:
* what is the purpose of your software, and its context
* what are your input data and what they mean, and whether
On 12/05/2013 11:52 AM, Steven D'Aprano wrote:
There is a name for this: it is called a RANK TABLE. In the example
given:
values = [3, 1, 2, 5, 4]
the rank table gives the rank of each element, that is, the position
they would get after sorting. In this case, the rank table is not
terribly exci
On 12/05/2013 12:02 PM, Alan Gauld wrote:
But the OP didn't ask for the final transform he asked for the list of
transforms that got from A to B. That means all of the intermediate steps. At
least that's how I read his statement "list-of-transforms
that got me from before to after"
I did not re
Hello,
How does slicing in Python really work? Apparently, there are slice objects
(start, past-end, step), generated using either the 'slice' builtin func or the
extended slicing syntax [i:k:s]. Is this correct? [1]
Does (only) the extended syntax (always) trigger slicing instead of contruct
On 12/07/2013 02:07 AM, Alan Gauld wrote:
On 06/12/13 15:39, spir wrote:
How does slicing in Python really work? Apparently, there are slice
objects (start, past-end, step), generated using either the 'slice'
builtin func or the extended slicing syntax [i:k:s]. Is this correct? [1]
On 12/07/2013 02:45 AM, Mark Lawrence wrote:
The good news is there is a memoryview in Python, see
http://docs.python.org/3/library/functions.html#func-memoryview. The bad news
is it doesn't work on strings. See here for the slice object
http://docs.python.org/3/library/functions.html#slice.
T
On 12/07/2013 02:49 AM, Joel Goldstick wrote:
>>Hum, we are not talking of the same topic, apparently. I mean this, from
>>the library ref, builtin funcs:
>>http://docs.python.org/3.3/library/functions.html#slice:
>>
>> slice(start, stop[, step])
>>
>
I'm totally confused by this. What is th
On 12/07/2013 11:42 AM, Steven D'Aprano wrote:
>Are slices and subsequences transparently usable one for the other?
Of course not. They are completely different things. A slice has to be
applied to a sequence before you get a subsequence:
Right, thank you, Staven, that's the bit I missed.
[I k
On 12/08/2013 11:22 AM, Rafael Knuth wrote:
Hey there,
I struggle to understand what unit testing specifically means in
practice and how to actually write unit tests for my code (my gut is
telling me that it's a fairly important concept to understand).
[...]
Hello Rafael,
This post is quite l
On 12/08/2013 07:59 AM, Shankar Donepudi wrote:
Hi All,
I am working as test engineer in Networking in storage domain. We have
decided to automate our testing and have chosen python for the same. We
have basic knowledge on python so can anyone suggest good tutorials for
writing automation script
On 12/08/2013 07:14 AM, Amit Saha wrote:
>If all of the bitN are strings:
> bit1 + bit2 + bit3 + bit4 + bit5
>actually constructs:
> bit1+bit2
> bit1+bit2+bit3
> bit1+bit2+bit3+bit4
> bit1+bit2+bit3+bit4+bit5
>A number of unneeded string object, and a very
On 12/09/2013 09:08 AM, Rafael Knuth wrote:
Hej there,
I wrote a program that converts an integer into a digit sum:
def DigitSum(YourNumber):
DigitList = []
YourNumber = str(YourNumber)
for i in YourNumber:
DigitList.append(int(i))
print(sum(DigitList))
DigitSum(55
On 12/09/2013 05:46 AM, Varuna Seneviratna wrote:
Let’s begin with some definitions.
A *namespace* is a mapping from names to objects. Most namespaces are
currently implemented as Python dictionaries, but that’s normally not
noticeable in any way (except for performance), and it may change in t
On 12/09/2013 02:42 PM, Rafael Knuth wrote:
Tu sum it up (aha!): you algorithm is the right and only one
No, it's not the only one. It's certainly the most obvious one, but there is
also the pure numbers approach pointed out by me and Alan.
So far I received 7 different alternative suggestion
On 12/09/2013 02:29 PM, Wolfgang Maier wrote:
spir gmail.com> writes:
Tu sum it up (aha!): you algorithm is the right and only one
No, it's not the only one. It's certainly the most obvious one, but there is
also the pure numbers approach pointed out by me and Alan.
You a
On 12/09/2013 03:49 PM, Alan Gauld wrote:
On 09/12/13 13:48, spir wrote:
On 12/09/2013 02:29 PM, Wolfgang Maier wrote:
spir gmail.com> writes:
Tu sum it up (aha!): you algorithm is the right and only one
No, it's not the only one. ...
also the pure numbers approach pointed out b
On 12/09/2013 09:27 PM, Alan Gauld wrote:
On 09/12/13 17:57, Roel Schroeven wrote:
You are right in a sense, but this is what int() does, isn't it?
No. int() can be done in several ways...
spir should have said "..., but this is what str() does, ..." I think.
Doh! Yes, tha
On 12/10/2013 11:56 AM, Steven D'Aprano wrote:
This is because the function does *two things*, when it should do one.
First it calculates the digit sum, and then it prints it.
print's inside functions are a sign of debug not completely cleaned ;-)
(and also a sign that test funcs do not provid
On 12/10/2013 12:46 AM, Steven D'Aprano wrote:
In Python 2.7, you can abbreviate that last one slightly:
'{} "{}"'.format(number, word)
Why 2.7? By me also works with 3.3.
Either should be preferred to building the string by hand with + signs.
The rule of thumb I use is to say that adding tw
[off-topic]
On 12/10/2013 01:39 PM, Wolfgang Maier wrote:
def digits(n):
"""Generator that breaks down an integer into digits from right to left."""
while n>0:
yield n % 10
n //= 10
Aha! one more sign that we write numbers backwards!
Denis
_
On 12/10/2013 02:31 PM, Rafael Knuth wrote:
Hej Steven,
thanks for the clarification.
I have two questions - one about map function and the other about return.
So, in mathematics we might have a mapping between (let's say) counting
numbers 1, 2, 3, 4, ... and the even numbers larger than fifty
On 12/10/2013 02:31 PM, Rafael Knuth wrote:
Hej Steven,
thanks for the clarification.
I have two questions - one about map function and the other about return.
So, in mathematics we might have a mapping between (let's say) counting
numbers 1, 2, 3, 4, ... and the even numbers larger than fifty
On 12/10/2013 03:48 PM, uga...@talktalk.net wrote:
[...]
Recursivity is hard to get really, meaning intuitively with your guts so-to-say.
Maybe using another example may help. Lets us say you want a function that sums
numbers from 1 up to n, the only input variable. (The result should thus be
On 12/11/2013 09:50 AM, Alan Gauld wrote:
Remember that each time mult() is called it creates
its own mini-world of variables independent of the
previous calls.
That, is a key point.
Denis
___
Tutor maillist - Tutor@python.org
To unsubscribe or cha
On 12/11/2013 03:56 PM, uga...@talktalk.net wrote:
Self-similar (fractal) recursion, sounds complex, I am guessing this is like
linear recursion but simultaneously in more than one dimension?
Curious business really. Wonders, if I may be a closet programmer, or something,
It is not complex,
On 12/11/2013 07:15 PM, Alan Gauld wrote:
Remember we are calling mul() several times, each with a new set of values.
So mul(3,2) calls mul(3,1)
and mul(3,1) calls mul(3,0)
mul(3.0) returns 0 to mul(3,1)
mul(3,1) then returns 3+0 => 3 to mul(3,2)
mul(3,2) returns 3+3 => 6.
This is a very cle
This is a pretty good clarification! (debug prints well designed and well
placed)
Congrats, Mark!
denis
On 12/11/2013 06:37 PM, Mark Lawrence wrote:
On 10/12/2013 14:48, uga...@talktalk.net wrote:
[snipped]
As you're clearly struggling here's my attempt at showing you what is happening.
c:
On 12/11/2013 02:55 PM, Jignesh Sutar wrote:
Thanks Mark,
print('%02d:%02d:%04d' % (now.hour, now.minute, now.year))
That works for;
now = datetime.now()
but not for;
exe_time = endTime-startTime
Yes, because exe-time is not a ate, a point in time, but a time delta (a
difference), thus doe
On 12/11/2013 06:40 PM, Jignesh Sutar wrote:
c = b-a
print "%s days, %.2dh: %.2dm: %.2ds" %
(c.days,c.seconds//3600,(c.seconds//60)%60, c.seconds%60)
This is a correct and general solution. Maybe worth being built-in, in fact, in
my view.
Denis
__
Hello,
I need to write out, both to stdout and stderr channels, which indeed in general
are the same one, and things written to be in order (lol!). For now, I flush on
stderr, and apparently there is no issue on stdout. Does someone know more about
that? I seem to remember stdout is flushed on
On 12/13/2013 05:10 AM, Sky blaze wrote:
Hi, I'm a newbie Python programmer. I was introduced to Python via the Hour
of Code, and after completing all three of Grok Learning's tutorials, I was
inspired to create a text-based RPG adventure. I composed this e-mail after
searching for a forum for Py
On 12/14/2013 12:24 AM, Mark Lawrence wrote:
I've just remembered that one distinct disadvantage of memoryviews is that you
can't use them anywhere if you want to do any sorting, as you can't compare
them :(
Not a blocker in my case (matching/parsing), thankfully.
Denis
__
On 12/14/2013 04:31 AM, Steven D'Aprano wrote:
To err is human, to forgive is humane.
Nicely said.
To the Original Poster, whoever you are... I hope you'll hang around
here and [...]
If it were me, he would probably not; too bad.
Denis
___
Tutor
On 12/14/2013 10:12 AM, Bo Morris wrote:
Thank you for your assistance. Based on your direction, I figured it out.
*This... *
def add(number):
print 1 + int(number)
x = ['2', '4', '6', '8', '10', '12']
[add(item) for item in x]
*Is the same as... *
def add(number):
print 1 +
On 12/14/2013 03:14 AM, Michael Crawford wrote:
I found this piece of code on github
mkdict = lambda row: dict((col, row[col]) for col in cols)
#<<
Apart form the "lambda" part, explained by others, one point I would note that
makes the whole expression weird and hard to
On 12/14/2013 03:28 PM, spir wrote:
This 'cols' is not even defined in the piece of code you posted (which is not
all reproduced above).
Oops! did not see it as param of the enclosing func. Sorry for the error,
Denis
___
Tutor maillist
On 12/14/2013 12:37 PM, Alan Gauld wrote:
I must admit I'd never even thought of checking the __name__ attribute
of a lambda, I'd kind of just assumed it would be empty (or maybe 'anonymous')!
You are right, Alan, in my view.
any_lambda_func.__name__ == ""
would be a better choice. (And
On 12/14/2013 03:29 PM, bruce wrote:
Hi.
Looking at a file -->>
http://www.marquette.edu/mucentral/registrar/snapshot/fall13/xml/BIOL_bysubject.xml
The file is generated via online/web url, and appears to be XML.
However, when I use elementtree:
document = ElementTree.parse( '/apps/parseapp
On 12/15/2013 05:54 PM, Rafael Knuth wrote:
Hej,
I stumbled upon this program here (Python 3.3.0) and I don't quite
understand how the for loop plays with the return True statement:
def is_prime(number):
for element in range(2, number):
if number % element == 0:
retur
On 12/16/2013 11:34 AM, spir wrote:
On 12/15/2013 05:54 PM, Rafael Knuth wrote:
PS: using "print" as Mark proposes is indeed you best friend to unsertand loops
(and also recursion).
Denis
___
Tutor maillist - Tutor@python.org
To unsu
On 12/16/2013 09:49 AM, Rafael Knuth wrote:
Hej there,
number = 9
for element in range(2,9):
3 % 2 != 0:
My assumption is that the program should end the loop after the first
iteration again and it then should return True.
No. If it did that, it wouldn't be a *loop* at all, would it? The whol
On 12/16/2013 03:12 PM, Alina Campana wrote:
Hello dear tutorlist,
I feel terribly ashamed for my bad english...
Yet I'll try to form my question:
It is about the continue statement in python.I wrote this code
i = 0while (i < 10): if i == 5: continueprint i i+=1
What i expect
On 12/16/2013 04:28 PM, Rafael Knuth wrote:
Hey there,
I am currently looking into all built in functions in Python 3.3.0,
one by one, in order to understand what each of them specifically does
(I am familiar with some of them already, but most built in functions
are still alien to me). I am wor
Hello,
is it at all possible to set new vars (or any symbol) into an existing scope
(typically locals())?
scope[name] = value
raises by me an error like:
TypeError: 'mappingproxy' object does not support item assignment
I guess 'mappingproxy' is the implementation name of a scope (her
On 12/18/2013 10:02 AM, Peter Otten wrote:
spir wrote:
[...]
Like Steven I have no idea how you produced the mappingproxy. Are you trying
to use a class as a namespace (in Python 3.3)?
class A: pass
...
A.__dict__["foo"] = "bar"
Traceback (most recent call last):
On 12/18/2013 03:28 AM, Keith Winston wrote:
On Tue, Dec 17, 2013 at 7:26 PM, wrote:
What else do I need to do to make this version of Python an actually
usable programming environment?
Chris Acreman
Chris, I'm also a noob, but I would recommend you install/use an IDE, such
as IDLE which c
On 12/17/2013 11:30 PM, Dave Angel wrote:
On Wed, 18 Dec 2013 02:39:43 +1100, Steven D'Aprano wrote:
if a > 0 and b > 0 and c > 0:
if all(x for x in (a, b, c):
Er, perhaps it should be:
if all (x> 0 for x in (a, b, c):
I saw the missing paren at once (maybe a few months progr lisp
On 12/18/2013 12:07 PM, eryksun wrote:
On Wed, Dec 18, 2013 at 5:40 AM, spir wrote:
C.__setattr__(C, "baz", "BAZ")
which fails, for any reason, with
TypeError: can't apply this __setattr__ to type object
You need __setattr__ from the metaclass
On 12/18/2013 11:51 AM, eryksun wrote:
On Tue, Dec 17, 2013 at 10:52 AM, spir wrote:
is it at all possible to set new vars (or any symbol) into an existing scope
(typically locals())?
scope[name] = value
raises by me an error like:
TypeError: 'mappingproxy' object does n
On 12/18/2013 06:35 PM, Reuben wrote:
Keep caution while using geany. It causes indentation problems
???
(funny assertion ;-) doesn't it raise an AssertionError, perhaps?)
Denis
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscri
On 12/18/2013 09:45 PM, Alan Gauld wrote:
On 18/12/13 17:45, Mark Lawrence wrote:
Can I be so bold as to ask how discussing metaclasses and __setattr__ on
a tutor mailing list is going to help the newbie who's having problems
with their "hello world" program?
It won't, but the tutor list is a
On 12/19/2013 12:56 AM, Steven D'Aprano wrote:
On Tue, Dec 17, 2013 at 09:28:14PM -0500, Keith Winston wrote:
On Tue, Dec 17, 2013 at 7:26 PM, wrote:
What else do I need to do to make this version of Python an actually
usable programming environment?
Chris Acreman
Chris, I'm also a noob,
On 12/29/2013 01:38 PM, Steven D'Aprano wrote:
>In the previous timer function that I was using, it defined a timer class,
>and then I had to instantiate it before I could use it, and then it saved a
>list of timing results. I think in yours, it adds attributes to each
>instance of a function/met
On 12/29/2013 12:33 PM, Steven D'Aprano wrote:
def adder_factory(n):
def plus(arg):
return arg + n
return plus # returns the function itself
If you call adder_factory(), it returns a function:
py> adder_factory(10)
.plus at 0xb7af6f5c>
What good is this? Watch carefully:
rint". It
is rarely a good idea to reuse such names, but maybe you did not know it. Here
is what it does (if you don't know yet about iterator objects, this will give
you a fore-taste, but don't bother with that topic before you actually need them):
spir@ospir:~$ python3
Python 3.
Hello,
I don't remember exactly how to do that. As an example:
class Source (str):
__slots__ = ['i', 'n']
def __init__ (self, string):
self.i = 0 # current matching index in source
self.n = len(string)# number of ucodes (Unicode code points)
On 12/31/2013 04:03 PM, Zachary Ware wrote:
On Tue, Dec 31, 2013 at 8:35 AM, spir wrote:
Hello,
I don't remember exactly how to do that. As an example:
class Source (str):
__slots__ = ['i', 'n']
def __init__ (self, string):
self.i = 0
On 12/31/2013 06:53 PM, eryksun wrote:
On Tue, Dec 31, 2013 at 11:21 AM, Mark Lawrence wrote:
The glossary entry for __slots__ states "A declaration inside a class that
saves memory by pre-declaring space for instance attributes and eliminating
instance dictionaries. Though popular, the techniq
On 12/31/2013 09:46 PM, Keith Winston wrote:
Thanks Denis, I found out about the iter builtin last night, a few hours
after I'd coded/posted that. Oops. Thanks for your other comments, I am
clearer now about the distinction of creating a new, empty list vs.
clearing the same list out, and the sub
On 01/01/2014 07:13 AM, eryksun wrote:
>I'm afraid I've lost the context, and don't understand why this is
>important. It's true that not all built-in objects are in builtins, and
>not all objects in builtins are built-in, but other than for pedantic
>correctness, why does this matter?
Denis sai
On 01/01/2014 01:26 AM, Steven D'Aprano wrote:
On Tue, Dec 31, 2013 at 03:35:55PM +0100, spir wrote:
Hello,
I don't remember exactly how to do that. As an example:
class Source (str):
__slots__ = ['i', 'n']
def __init__ (self, string):
self.i
On 01/02/2014 03:21 AM, Steven D'Aprano wrote:
On Wed, Jan 01, 2014 at 02:49:17PM +0100, spir wrote:
On 01/01/2014 01:26 AM, Steven D'Aprano wrote:
On Tue, Dec 31, 2013 at 03:35:55PM +0100, spir wrote:
[...]
I take the opportunity to add a few features, but would do
without Source
Hello tutorians,
Am I missing something or don't classes know how they're called (unlike funcs,
which have a __name__ attribute, very practicle)? Is there a way to get it
otherwise?
The point is to have a super-type define a general __repr__ like eg:
class SuperType:
# ...
def __repr
On 01/02/2014 11:18 AM, Dominik George wrote:
Hi,
Am I missing something or don't classes know how they're called
(unlike funcs, which have a __name__ attribute, very practicle)? Is
there a way to get it otherwise?
The class has it, the instance doesn't. That said, you are looking for
self._
On 01/02/2014 02:40 PM, Steven D'Aprano wrote:
On Thu, Jan 02, 2014 at 11:12:30AM +0100, spir wrote:
Hello tutorians,
Am I missing something or don't classes know how they're called (unlike
funcs, which have a __name__ attribute, very practicle)? Is there a way to
get it otherw
On 01/02/2014 04:48 PM, eryksun wrote:
On Thu, Jan 2, 2014 at 5:12 AM, spir wrote:
Am I missing something or don't classes know how they're called (unlike
funcs, which have a __name__ attribute, very practicle)? Is there a way to
get it otherwise?
What are you smoking, and where
On 01/03/2014 12:41 PM, Alan Gauld wrote:
return [step, self.move_count, self.num_chutes,
self.num_ladders, self.chutes_list, self.ladders_list]
In OOP you rarely have to return attributes. And since step
is passed in as an argument the caller already knows [it]. So I
don't think you
On 01/03/2014 09:30 AM, Christian Alexander wrote:
Hello Tutorians,
I've just recently acquired "Learning Python", and I must state that it is
a fairly thorough book. However it seems as if I am learning at a very
slow pace, so my question is, as far as setting a goal to master the
basics, wher
On 01/03/2014 10:53 PM, Keith Winston wrote:
My concern is with speed. This will have to keep up with (somewhat
arbitrarily) fast typing, while doing background processing, with a GUI of
course.
I wouldn't even bother. Try & see, you may be surprised. There are several
factors at play:
* The c
On 01/04/2014 05:47 AM, Keith Winston wrote:
Here is what I think will be about the final version of C and L. I
rearranged it quite a bit (into 2 classes), fixed a bug or two, and
generally cleaned it up a bit. I haven't really polished it, but hopefully
it will be less difficult to read... which
On 01/04/2014 05:45 AM, Steven D'Aprano wrote:
On Fri, Jan 03, 2014 at 09:56:25PM -0500, Keith Winston wrote:
gmail is driving me crazy. Anyway, every time I run it with:
if __name__ == "__main__":
tarray = CandL_Array
tarray.populate(100)
I get an error
Traceback (most recent call
On 01/04/2014 06:32 AM, Keith Winston wrote:
On Fri, Jan 3, 2014 at 11:59 PM, Steven D'Aprano wrote:
thelist = vars()[name]
I see: vars() certainly looks less dangerous than eval(), but I'm guessing
that's still smelly code? I hadn't known about vars() or I probably would
have used it.
It
On 01/04/2014 06:36 AM, Steven D'Aprano wrote:
Now, it's true that when *debugging code*, being able to see the name of
the variable and the contents of the variable is useful. But in ordinary
code, why would you care to print the name of the variable and its
contents. Who cares what the variable
On 01/04/2014 07:24 AM, Keith Winston wrote:
I had heard about deep/shallow copies, though in
this particular example (all int dicts), I don't think there's a
difference...?
There's none, you're right. It's only whenever inner items (fields, etc...)
themselves are complex elements and mutable.
On 01/04/2014 10:14 AM, Steven D'Aprano wrote:
While I agree with Devin, it is possible to write absurdly slow code in
*any* language. This is why is is better to write straightforward,
simple code in preference to complicated, intricate code -- it is easier
to understand simple code, which means
On 01/04/2014 02:38 AM, Keith Winston wrote:
The thing that put me on edge was noticing that my simple
Chutes & Ladders game doesn't go ANY faster on a machine that benchmarks
perhaps 1000 times faster than another...
You could say this about most programs in most langs. Actually, some even
re
On 01/04/2014 12:33 PM, Keith Winston wrote:
Thanks Alan & Denis: Alan, the improvement you suggested had already been
made, and adopted. Good catch.
Denis: alas, there are chutes and ladders dicts, but I guess your chutes &
ladders lists are local to the results class... Your suggestion is quit
On 01/04/2014 02:03 PM, Steven D'Aprano wrote:
>I understand that Python doesn't have composite objects, but neither does
>it dislallow my list of lists of ints and lists... which is, I imagine,
>very space efficient.
I'm afraid I have no idea what you mean by Python not having "composite
object
On 01/04/2014 02:03 PM, Steven D'Aprano wrote:
>I'm also a bit confused here: obviously tuples are immutable, but one can
>use lists in them... I think that makes those lists' contents immutable?
Nope. It makes the tuple immutable in the sense that it's *direct*
contents cannot be changed, but m
On 01/05/2014 08:52 AM, Mark Lawrence wrote:
On 05/01/2014 07:09, Keith Winston wrote:
Thanks all, interesting. I'll play more with tuples, I haven't knowingly
used them at all...
Keith
Homework for you :) Write a line of code that creates a list of say 3 or 4
integers, then write a line t
On 01/05/2014 12:52 AM, Steven D'Aprano wrote:
If you don't understand an exception, you
have no business covering it up and hiding that it took place. Never use
a bare try...except, always catch the *smallest* number of specific
exception types that make sense. Better is to avoid catching except
On 01/04/2014 08:26 PM, Alex Kleider wrote:
Any suggestions as to a better way to handle the problem of encoding in the
following context would be appreciated. The problem arose because 'Bogota' is
spelt with an acute accent on the 'a'.
$ cat IP_info.py3
#!/usr/bin/env python3
# -*- coding : ut
On 01/05/2014 03:31 AM, Alex Kleider wrote:
I've been maintaining both a Python3 and a Python2.7 version. The latter has
actually opened my eyes to more complexities. Specifically the need to use
unicode strings rather than Python2.7's default ascii.
So-called Unicode strings are not the solut
On 01/05/2014 08:57 AM, Alex Kleider wrote:
On 2014-01-04 21:20, Danny Yoo wrote:
Oh! That's unfortunate! That looks like a bug on the hostip.info
side. Check with them about it.
I can't get the source code to whatever is implementing the JSON
response, so I can not say why the city is not
On 01/05/2014 08:40 PM, Keith Winston wrote:
On Sun, Jan 5, 2014 at 2:52 AM, Mark Lawrence wrote:
Homework for you :) Write a line of code that creates a list of say 3 or
4 integers, then write a line that creates a tuple with the same integers.
Use the dis module to compare the byte code th
On 01/08/2014 10:30 AM, Keith Winston wrote:
well, fair enough. Generally, the issue involves instances when Python will
come back, but it might take several minutes or much longer. And weird
behaviour ensues: like timers I put on the program don't actually time the
amount of time it's busy (by a
rammer feedback. Guess it has to do with cycles, but
there are ways to do that; and python manages cycles in list expressions:
spir@ospir:~$ python3
Python 3.3.1 (default, Sep 25 2013, 19:29:01)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license&q
On 01/10/2014 01:11 AM, Amy Davidson wrote:
Hi,
I am a university student who is struggling with writing functions in Python.
I’ve been attempting to write a function in Python for over 2 hours with no
progress. The function must be called, printID and take a name and student
number as parame
's written like a list
comprehension, bit with () instead of []. The semantic difference is that items
are generated once at a time instead of all in one go and stored in a list.
Another difference is that one cannot reuse such a generator object (once end is
reached, it is like "e
On 01/12/2014 10:04 AM, Keith Winston wrote:
I've got this line:
for k in range(len(tcombo)):
tcombo_ep.append(list(combinations(tcombo, k+1)))
generating every possible length combination of tcombo. I then test
them, and throw most of them away. I need to do this differently, it
gets way
On 01/18/2014 09:51 AM, Keith Winston wrote:
I don't really get iterators. I saw an interesting example on
Stackoverflow, something like
with open('workfile', 'r') as f:
for a, b, c in zip(f, f, f):
And this iterated through a, b, c assigned to 3 consecutive lines of
the file as it it
401 - 500 of 627 matches
Mail list logo