On 05/10/2017 14:13, Steve D'Aprano wrote:
On Thu, 5 Oct 2017 10:51 pm, bartc wrote:
Am I allowed to say that it all seems a bit of a mess?
You may or may not be pleased to learn that there's a push to create a "record
like" or "struct like" datatype for Python 3.7 or 3.8, tentatively called
On Thu, 5 Oct 2017 10:51 pm, bartc wrote:
> Am I allowed to say that it all seems a bit of a mess?
You may or may not be pleased to learn that there's a push to create a "record
like" or "struct like" datatype for Python 3.7 or 3.8, tentatively called
a "Data Class" for now.
The proposed syntax
On 05/10/2017 12:29, Gregory Ewing wrote:
bartc wrote:
Result? You can't just look at my 'any' class and see what fields it
uses. You can't even just look at the static source code. You have to
run the program to find out. And it might be different each time.
You can usually get a pretty good
bartc wrote:
Result? You can't just look at my 'any' class and see what fields it
uses. You can't even just look at the static source code. You have to
run the program to find out. And it might be different each time.
You can usually get a pretty good idea of what attributes a
class has by loo
On Wed, 4 Oct 2017 11:46 pm, Rhodri James wrote:
> On 04/10/17 12:07, bartc wrote:
>> I've seen that example brought up before. It still doesn't cut any ice.
>>
>> You might as well be condescending of someone who finds Joyce or Proust
>> unreadable, and prefers McBain, Simenon or Chandler. (Sorr
On Thu, 5 Oct 2017 04:00 am, Paul Moore wrote:
> I wonder - would the people who want "real constants" find the
> following confusing:
>
from demo import foo
foo = 14
foo
> 14
>
> It's fundamental to the way the import function works, and how names
> in Python behave, but I can s
On Thu, 5 Oct 2017 09:08 am, bartc wrote:
[...]
> And when I tried, it didn't really work in Python 2 (extra attributes
> could still be created, and .__slots__ wasn't readonly); only Py3.
Not quite, but I don't blame you for the mistake. Its an easy one to make.
__slots__ only works in "new sty
On 04/10/2017 17:02, Rhodri James wrote:
On 04/10/17 16:33, Paul Moore wrote:
It's not an advantage or a disadvantage, just an approach. Many people
like it, you may not. Specifically, yes you can't "just declare a
lightweight struct or record with exactly two fields".
Actually you can:
>>
On Wed, Oct 4, 2017 14:03 PM, bartc wrote >
"A property, in some object-oriented programming languages, is a special
>sort of class member, intermediate in functionality between a field (or
>data member) and a method."
>
>But Python has some problems just in using fields. If you wanted say a
On 4 October 2017 at 17:15, Ian Kelly wrote:
> On Wed, Oct 4, 2017 at 9:08 AM, Steve D'Aprano
> wrote:
>> But in large projects, especially those where you cannot trust every module
>> in
>> the project to obey the naming convention, I can see that this lack might
>> contribute to the perception
On 4 October 2017 at 17:02, Rhodri James wrote:
> Actually you can:
>
class Point:
> ... __slots__ = ("x", "y")
> ... def __init__(self, x, y):
> ... self.x = x
> ... self.y = y
> ... def __str__(self):
> ... return "({0},{1})".format(self.x, self.y)
> ...
p = Point(3,4
On Wed, Oct 4, 2017 at 9:08 AM, Steve D'Aprano
wrote:
> But in large projects, especially those where you cannot trust every module in
> the project to obey the naming convention, I can see that this lack might
> contribute to the perception, if not the fact, of Python being a bit too
> unsafe for
On 04/10/17 16:33, Paul Moore wrote:
On 4 October 2017 at 16:03, bartc wrote:
No error. Some would perceive all this as an advantage, but it means you
can't just declare a lightweight struct or record 'Point' with exactly two
fields x and y. You have to use other solutions ('namedtuples' or wha
On 4 October 2017 at 16:03, bartc wrote:
> No error. Some would perceive all this as an advantage, but it means you
> can't just declare a lightweight struct or record 'Point' with exactly two
> fields x and y. You have to use other solutions ('namedtuples' or whatever,
> which probably are immuta
On Thu, 5 Oct 2017 12:41 am, Ian Kelly wrote:
> Python has the simplest named constants of all:
>
> C = 12345
>
> As long as you don't subsequently change it, it's a constant. And it's
> very simple because it works just like any other variable.
I do feel that the lack of constants[1] is a (mi
On 04/10/2017 14:41, Ian Kelly wrote:
On Wed, Oct 4, 2017 at 5:07 AM, bartc wrote:
For that matter, I don't think Python has such a feature either. So that you
write for example:
const C = 123345
and then whenever C appears within the code, it's implemented as:
LOAD_CONST (123345)
On Wed, Oct 4, 2017 at 5:07 AM, bartc wrote:
> It is just being elitist. I have a preference for keeping things simple and
> avoiding unnecessary complexity. But with programming languages many do have
> a penchant for the latter.
>
> As an example, a recent discussion on comp.lang.c was about imp
On 04/10/17 12:07, bartc wrote:
I've seen that example brought up before. It still doesn't cut any ice.
You might as well be condescending of someone who finds Joyce or Proust
unreadable, and prefers McBain, Simenon or Chandler. (Sorry, can't think
of any modern pulp novelists).
I don't thin
On 04/10/2017 06:32, Steve D'Aprano wrote:
On Wed, 4 Oct 2017 02:00 am, bartc wrote:
Does all this advanced stuff (which I don't understand and which doesn't
look very appealing either; hopefully I will never come across such
code) still count as programming?
I could not have hoped to see a m
On Wed, 4 Oct 2017 02:00 am, bartc wrote:
> Does all this advanced stuff (which I don't understand and which doesn't
> look very appealing either; hopefully I will never come across such
> code) still count as programming?
I could not have hoped to see a more perfect example of the Blub effect in
On Tue, Oct 3, 2017 at 9:16 AM, Jorge Gimeno wrote:
> No, I see this as teaching the skills involved to drive a car. Practicing a
> turn, scanning gauges, and checking blind spots are all a part of driving.
> When one is learning, it's easier to learn these in isolation so when the
> problem must
Steve D'Aprano wrote:
On Tue, 3 Oct 2017 06:51 am, Bill wrote:
Can you inspire me with a good decorator problem (standard homework
exercise-level will be fine)?
Here is a nice even dozen problems for you. Please ask for clarification if any
are unclear.
Thank you for sharing the problems on
No, I see this as teaching the skills involved to drive a car. Practicing a
turn, scanning gauges, and checking blind spots are all a part of driving.
When one is learning, it's easier to learn these in isolation so when the
problem must be solved in real time, you know what to do. This is no
diffe
On 03/10/2017 15:39, Ian Kelly wrote:
On Tue, Oct 3, 2017 at 4:41 AM, Steve D'Aprano
wrote:
On Tue, 3 Oct 2017 06:51 am, Bill wrote:
Can you inspire me with a good decorator problem (standard homework
exercise-level will be fine)?
Here is a nice even dozen problems for you. Please ask for
On Tue, Oct 3, 2017 at 4:41 AM, Steve D'Aprano
wrote:
> On Tue, 3 Oct 2017 06:51 am, Bill wrote:
>
>> Can you inspire me with a good decorator problem (standard homework
>> exercise-level will be fine)?
>
>
> Here is a nice even dozen problems for you. Please ask for clarification if
> any
> are
On Tue, 3 Oct 2017 10:01 pm, Lele Gaifax wrote:
> Steve D'Aprano writes:
>
>> (9) [ADVANCED] Modify the decorator from (8) to take an argument specifying
>> the path to a file, and use the logging module to log the details to that
>> file instead of printing them.
>
> This may suffer of excessi
Steve D'Aprano writes:
> (9) [ADVANCED] Modify the decorator from (8) to take an argument specifying
> the
> path to a file, and use the logging module to log the details to that file
> instead of printing them.
This may suffer of excessive creativity, as usually the details of *where* a
logger
On Tue, 3 Oct 2017 06:51 am, Bill wrote:
> Can you inspire me with a good decorator problem (standard homework
> exercise-level will be fine)?
Here is a nice even dozen problems for you. Please ask for clarification if any
are unclear.
(1) Write a decorator which simply prints a descriptive m
Bill wrote:
Chris Angelico wrote:
Decorators are fairly straight-forward if you understand higher-order
functions.
ChrisA
I was just minding my own business, and thought to write my first
decorator for a simple *recursive* function f. The decorator WORKS if
f does not make a call to its
On Tue, Oct 3, 2017 at 2:39 PM, Bill wrote:
> Chris Angelico wrote:
>>
>> Decorators are fairly straight-forward if you understand higher-order
>> functions.
>>
>> ChrisA
>
>
>
> I was just minding my own business, and thought to write my first decorator
> for a simple *recursive* function f. T
Chris Angelico wrote:
Decorators are fairly straight-forward if you understand higher-order
functions.
ChrisA
I was just minding my own business, and thought to write my first
decorator for a simple *recursive* function f. The decorator WORKS if f
does not make a call to itself.Other
Steve D'Aprano wrote:
There's no need to set the radius and the diameter, as one is completely derived
from the other
Good point; I'm glad I submitted my code for grading. Sort of a "trick
question" to ask me to add diameter and then take off points because I
used it! ; )
Bill
On Tue, 3 Oct 2017 06:32 am, Bill wrote:
> Steve D'Aprano wrote:
>> Circle didn't use any setters, but I could have let you set the
>> diameter, which in
>> turn would set the radius:
>>
>> circle.radius = 2
>> assert circle.diameter == 4
>> circle.diameter == 2 # requires a setter
>> assert circ
On Mon, Oct 2, 2017 at 1:32 PM, Bill wrote:
> @property def circumference(self):
> return 2 * math.pi *self.radius
Of course the *proper* formula here is just math.tau * self.radius.
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, Oct 3, 2017 at 6:51 AM, Bill wrote:
> Can you inspire me with a good decorator problem (standard homework
> exercise-level will be fine)? Otherwise I will go create one which will
> prints a row of asterisks before and after the call to the original function
> (which I think I should do)
Chris Angelico wrote:
On Tue, Oct 3, 2017 at 6:23 AM, Larry Hudson via Python-list
wrote:
On 10/01/2017 03:52 PM, Bill wrote:
Steve D'Aprano wrote:
The definitive explanation of descriptors is here:
https://docs.python.org/3/howto/descriptor.html
Thank you! It is next on my list. Then I'
Steve D'Aprano wrote:
Circle didn't use any setters, but I could have let you set the
diameter, which in
turn would set the radius:
circle.radius = 2
assert circle.diameter == 4
circle.diameter == 2 # requires a setter
assert circle.radius == 1
Getting that to work is left as an exercise :-)
On Tue, Oct 3, 2017 at 6:23 AM, Larry Hudson via Python-list
wrote:
> On 10/01/2017 03:52 PM, Bill wrote:
>>
>> Steve D'Aprano wrote:
>>>
>>> The definitive explanation of descriptors is here:
>>> https://docs.python.org/3/howto/descriptor.html
>>
>>
>> Thank you! It is next on my list. Then I'
On 10/01/2017 03:52 PM, Bill wrote:
Steve D'Aprano wrote:
The definitive explanation of descriptors is here:
https://docs.python.org/3/howto/descriptor.html
Thank you! It is next on my list. Then I'll try that Circle problem you mentioned as an
exercise last night! I don't expect run into
On Mon, 2 Oct 2017 07:51 pm, Marko Rauhamaa wrote:
> Chris Angelico :
>
>> On Mon, Oct 2, 2017 at 5:34 PM, Marko Rauhamaa wrote:
>>> I have *seen* a semi-useful decorator in code once
>>> (@contextlib.contextmanager) but still would prefer explicit dunder
>>> methods.
>>
>> [...] I'm not sure wh
On 2017-10-02 10:51, Marko Rauhamaa wrote:
> Chris Angelico :
>
>> On Mon, Oct 2, 2017 at 5:34 PM, Marko Rauhamaa wrote:
>>> I have *seen* a semi-useful decorator in code once
>>> (@contextlib.contextmanager) but still would prefer explicit dunder
>>> methods.
>>
>> [...] I'm not sure where dunde
Chris Angelico :
> On Mon, Oct 2, 2017 at 5:34 PM, Marko Rauhamaa wrote:
>> I have *seen* a semi-useful decorator in code once
>> (@contextlib.contextmanager) but still would prefer explicit dunder
>> methods.
>
> [...] I'm not sure where dunder methods come into this, though, as
> they're comple
On Mon, 2 Oct 2017 05:34 pm, Marko Rauhamaa wrote:
> I must say, though, I have yet to run into a need for descriptors.
You've never called a method?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailm
On Mon, Oct 2, 2017 at 5:34 PM, Marko Rauhamaa wrote:
> Chris Angelico :
>
>> Yes, that's correct. The *descriptor* protocol is what allows
>> "foo.bar" to cause a function to be executed
>
> That mechanism allows you to expose data fields in the API. If the
> implementation later changes, you can
Chris Angelico :
> Yes, that's correct. The *descriptor* protocol is what allows
> "foo.bar" to cause a function to be executed
That mechanism allows you to expose data fields in the API. If the
implementation later changes, you can emulate the data fields.
I must say, though, I have yet to run
On Sunday, October 1, 2017 at 6:47:34 PM UTC+1, MRAB wrote:
> On 2017-10-01 02:52, Stefan Ram wrote:
> > MRAB writes:
> >>raise ValueError("Temperature below -273 is not possible")
> >
> >-273.15
> >
> I think you've trimmed a little too much. In my reply I was only copying
> what someone el
On Mon, Oct 2, 2017 at 9:47 AM, Bill wrote:
> Stephan Houben wrote:
>>
>> Op 2017-10-01, Bill schreef :
>>>
>>> I watched an example on YouTube where someone wrote a simple descriptor
>>> ("@Time_it) to output the amount of time that it took ordinary functions
>>> to complete.To be honest, I A
Steve D'Aprano wrote:
The definitive explanation of descriptors is here:
https://docs.python.org/3/howto/descriptor.html
Thank you! It is next on my list. Then I'll try that Circle problem
you mentioned as an exercise last night! I don't expect run into any
difficulties. : )
--
https:/
Stephan Houben wrote:
Op 2017-10-01, Bill schreef :
I watched an example on YouTube where someone wrote a simple descriptor
("@Time_it) to output the amount of time that it took ordinary functions
to complete.To be honest, I AM interested in descriptors.
Are you sure you are not confusing d
Steve D'Aprano wrote:
On Sun, 1 Oct 2017 05:46 pm, Bill wrote:
If you were going to show non-Python users, say science undergraduates
and faculty, that Python is an interesting tool (in 45 minutes), would
one delve into descriptors?
Hell no :-)
Oops, I see I used the word "descriptor", where I
Op 2017-10-01, Bill schreef :
> Steve D'Aprano wrote:
>>
>> [1] Technically, the interpreter knows nothing about properties. What
>> it cares about is *descriptors*. Properties are just one kind of
>> descriptor, as are methods. But I'm intentionally not talking about
>> the gory details of descrip
Op 2017-10-01, Bill schreef :
> I watched an example on YouTube where someone wrote a simple descriptor
> ("@Time_it) to output the amount of time that it took ordinary functions
> to complete.To be honest, I AM interested in descriptors.
Are you sure you are not confusing deSCRIPTtors and
On 2017-10-01 02:52, Stefan Ram wrote:
MRAB writes:
raise ValueError("Temperature below -273 is not possible")
-273.15
I think you've trimmed a little too much. In my reply I was only copying
what someone else had written.
--
https://mail.python.org/mailman/listinfo/python-list
On 01/10/17 03:52, Stefan Ram wrote:
> MRAB writes:
>> raise ValueError("Temperature below -273 is not possible")
> -273.15
>
Either way, that depends.
https://en.wikipedia.org/wiki/Negative_temperature#Examples
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, 1 Oct 2017 05:46 pm, Bill wrote:
> If you were going to show non-Python users, say science undergraduates
> and faculty, that Python is an interesting tool (in 45 minutes), would
> one delve into descriptors?
Hell no :-)
I think there's a hierarchy of difficulty/complexity/mind-boggling
Steve D'Aprano wrote:
[1] Technically, the interpreter knows nothing about properties. What it cares
about is *descriptors*. Properties are just one kind of descriptor, as are
methods. But I'm intentionally not talking about the gory details of
descriptors. Feel free to ask if you care, but hone
Steve D'Aprano wrote:
Circle
didn't use any setters, but I could have let you set the diameter, which in
turn would set the radius:
circle.radius = 2
assert circle.diameter == 4
circle.diameter == 2 # requires a setter
assert circle.radius == 1
Getting that to work is left as an exercise :-)
On Sun, 1 Oct 2017 11:07 am, Bill wrote:
> You and Ned are both right. Up until a few minutes ago, I wasn't
> thinking about a class having more than 1 attribute that I wanted to
> change. And now I realize that __get__ doesn't really make sense in
> that context (in the back of my mind was the
On 30Sep2017 20:07, Bill wrote:
think all of this would have made a bit more sense (to me), if instead of just
"@property", the syntax was "@property.getter".
Perhaps, but nobody wants to type this. Also many properties are ready only, so
that is the default.
Now I am forced to ask the ques
On 2017-10-01 01:07, Bill wrote:
Steve D'Aprano wrote:
On Sun, 1 Oct 2017 08:47 am, Bill wrote:
I spent a few hours experimenting with @property. To my mind it seems
like it would be preferable to just define (override) instance methods
__get__(), __set__(), and possibly __del__(), as desired,
Ned Batchelder wrote:
On 9/30/17 7:18 PM, Bill wrote:
Ned Batchelder wrote:
On 9/30/17 5:47 PM, Bill wrote:
I spent a few hours experimenting with @property. To my mind it
seems like it would be preferable to just define (override)
instance methods __get__(), __set__(), and possibly __del__()
Steve D'Aprano wrote:
On Sun, 1 Oct 2017 08:47 am, Bill wrote:
I spent a few hours experimenting with @property. To my mind it seems
like it would be preferable to just define (override) instance methods
__get__(), __set__(), and possibly __del__(), as desired, as I could
easily provide them wi
On 9/30/17 7:18 PM, Bill wrote:
Ned Batchelder wrote:
On 9/30/17 5:47 PM, Bill wrote:
I spent a few hours experimenting with @property. To my mind it
seems like it would be preferable to just define (override) instance
methods __get__(), __set__(), and possibly __del__(), as desired, as
I cou
Ned Batchelder wrote:
On 9/30/17 5:47 PM, Bill wrote:
I spent a few hours experimenting with @property. To my mind it seems
like it would be preferable to just define (override) instance
methods __get__(), __set__(), and possibly __del__(), as desired, as
I could easily provide them with "idea
On Sun, 1 Oct 2017 08:47 am, Bill wrote:
> I spent a few hours experimenting with @property. To my mind it seems
> like it would be preferable to just define (override) instance methods
> __get__(), __set__(), and possibly __del__(), as desired, as I could
> easily provide them with "ideal" custom
On 9/30/17 5:47 PM, Bill wrote:
I spent a few hours experimenting with @property. To my mind it seems
like it would be preferable to just define (override) instance methods
__get__(), __set__(), and possibly __del__(), as desired, as I could
easily provide them with "ideal" customization. Am I
On Thursday, March 8, 2012 5:25:06 PM UTC+2, hyperboogie wrote:
> Hello everyone.
>
> This is my first post in this group.
> I started learning python a week ago from the "dive into python" e-
> book and thus far all was clear.
> However today while reading chapter 5 about objects and object
> ori
Ian Kelly wrote:
> On Sun, Mar 11, 2012 at 5:40 AM, Ian Kelly wrote:
>>> 2. Is the mro function available only on python3?
>>
>> No, but it is available only on new-style classes. If you try it on a
>> classic class, you'll get an AttributeError.
>
> And by the way, you probably shouldn't call
On Sun, Mar 11, 2012 at 5:40 AM, Ian Kelly wrote:
>> 2. Is the mro function available only on python3?
>
> No, but it is available only on new-style classes. If you try it on a
> classic class, you'll get an AttributeError.
And by the way, you probably shouldn't call the mro method directly.
Tha
On Sun, Mar 11, 2012 at 4:56 AM, hyperboogie wrote:
> 1. What do you mean by "subclassing `object`"?
In Python 2 there are two different types of classes: classic classes,
which are retained for backward compatibility, and new-style classes,
which were introduced in Python 2.2. Classic classes a
On Sun, Mar 11, 2012 at 3:56 AM, hyperboogie wrote:
> On Sunday, March 11, 2012 12:38:27 PM UTC+2, Chris Rebert wrote:
>> On Sun, Mar 11, 2012 at 3:18 AM, hyperboogie wrote:
>>
>> > thank you everyone...
>> > Still things are not working as expected... what am I doing wrong?
>>
>> > # cat test.p
On Sunday, March 11, 2012 12:38:27 PM UTC+2, Chris Rebert wrote:
> On Sun, Mar 11, 2012 at 3:18 AM, hyperboogie wrote:
>
> > thank you everyone...
> > Still things are not working as expected... what am I doing wrong?
>
> > # cat test.py
> > #!/usr/bin/python
> >
> > class A():
>
> You should be
On Sun, Mar 11, 2012 at 3:18 AM, hyperboogie wrote:
> thank you everyone...
> Still things are not working as expected... what am I doing wrong?
> # cat test.py
> #!/usr/bin/python
>
> class A():
You should be subclassing `object`, but that's a minor point which
isn't the cause of your problem.
On Mar 11, 12:47 am, "Colin J. Williams" wrote:
> On 10/03/2012 12:58 PM, Colin J. Williams wrote:> On 08/03/2012 10:25 AM,
> hyperboogie wrote:
> >> Hello everyone.
>
> [snip]
> > main()
> > I'm not sure that the class initialization is required.
>
> > Good luck,
>
> > Colin W.
>
> When I wrote
On 10/03/2012 12:58 PM, Colin J. Williams wrote:
On 08/03/2012 10:25 AM, hyperboogie wrote:
Hello everyone.
[snip]
main()
I'm not sure that the class initialization is required.
Good luck,
Colin W.
When I wrote earlier, I wondered about the need for initialization.
With Version 2, both __
On 08/03/2012 10:25 AM, hyperboogie wrote:
Hello everyone.
This is my first post in this group.
I started learning python a week ago from the "dive into python" e-
book and thus far all was clear.
However today while reading chapter 5 about objects and object
orientation I ran into something tha
hyperboogie wrote:
Hello everyone.
This is my first post in this group.
I started learning python a week ago from the "dive into python" e-
book and thus far all was clear.
However today while reading chapter 5 about objects and object
orientation I ran into something that confused me.
it says h
Maarten wrote:
> Alternatively you can figure out the parent class with a call to super:
This is WRONG:
> super(self.__class__, self).__init__()
You have to name the current class explicitly. Consider:
>> class A(object):
... def __init__(self):
... print "in a"
...
>>
On Thursday, March 8, 2012 4:25:06 PM UTC+1, hyperboogie wrote:
> My question is if __init__ in the descendant class overrides __init__
> in the parent class how can I call the parent's __init__ from the
> descendant class - I just overrode it didn't I?
>
> Am I missing something more fundamental
I received 1 st http://bestfinance-blog.com/topics/mortgage-loans";>mortgage loans
when I was 25 and that supported my family very much. But, I need the bank loan
once more time.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jul 28, 2010 at 5:50 AM, whitey wrote:
> On Tue, 27 Jul 2010 19:19:59 -0700, Mithrandir wrote:
>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> On 07/27/2010 04:07 AM, whitey wrote:
>>> hi all. am totally new to python and was wondering if there are any
>>> newsgroups that are t
On Tue, 27 Jul 2010 19:19:59 -0700, Mithrandir wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 07/27/2010 04:07 AM, whitey wrote:
>> hi all. am totally new to python and was wondering if there are any
>> newsgroups that are there specifically for beginners. i have bought a
>> book
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 07/27/2010 04:07 AM, whitey wrote:
> hi all. am totally new to python and was wondering if there are any
> newsgroups that are there specifically for beginners. i have bought a
> book for $2 called "learn to program using python" by alan gauld.
>
On 7/27/10 4:07 AM, whitey wrote:
hi all. am totally new to python and was wondering if there are any
newsgroups that are there specifically for beginners. i have bought a
book for $2 called "learn to program using python" by alan gauld.
starting to read it but it was written in 2001. presuming t
On Tue, 27 Jul 2010 11:07:09 GMT, whitey wrote:
hi all. am totally new to python and was wondering if there are any
newsgroups that are there specifically for beginners.
Yes, Python Tutor list is specifically aimed for beginners. You can
access it by subscribing to either tu...@python.org or
whitey wrote:
hi all. am totally new to python and was wondering if there are any
newsgroups that are there specifically for beginners. i have bought a
book for $2 called "learn to program using python" by alan gauld.
starting to read it but it was written in 2001. presuming that the
commands
On Jul 27, 9:07 pm, whitey wrote:
> hi all. am totally new to python and was wondering if there are any
> newsgroups that are there specifically for beginners. i have bought a
> book for $2 called "learn to program using python" by alan gauld.
> starting to read it but it was written in 2001. pres
Thanks Simon!
You are right.. I also believe it is something with Eclipse.
I've been working since... the module below runs.. but Eclipse is
still showing an error when I reference urlopen with a little red X...
saying it is an undefined variable in the IDE.. but not giving me an
runtime errors.
On Mon, Nov 9, 2009 at 6:29 PM, Penn wrote:
> I just installed PyDev into Eclipse using the 'update' method and did
> the standard installation. I allowed it to Auto Configure itself and
> ran a "Hello World" module to make sure I was in the ballpark.
>
> I got an starting module up and have run
try any one 1)
>>>from __future__ import division
>>>2/3 -1/3
0.1
2)
>>>x = 2/3.0
>>>x - 1/3.0
0.1
On Mon, Mar 9, 2009 at 9:33 AM, Daniel Dalton wrote:
> Hi,
>
> On Mon, Mar 09, 2009 at 12:08:16AM +0100, Lo wrote:
> > I just tried python first time.
> >
> > 2/3
Hi,
On Mon, Mar 09, 2009 at 12:08:16AM +0100, Lo wrote:
> I just tried python first time.
>
> 2/3
>
> the result is zero
That's because your dividing an int by an int to an int. The definition
of an int is a "whole number". So just use floating point I think it's
called, this should work, and d
Lo wrote:
I just tried python first time.
2/3
the result is zero
I want the result to be .333...
How do I get this?
That's integer division (integer divided by integer is integer).
If you want the result to be floating point then make one of them
floating point:
2.0 / 3
or do this
Lo pisze:
I just tried python first time.
2/3
the result is zero
Float type must be specified explicitly:
2/3.0 or 2.0/3
In Python 3.x operators behave differently and '2/3' would give float
number as a result.
I want the result to be .333...
Than try: 1/3.0 because 2/3.0 will never
On Sun, Mar 8, 2009 at 3:08 PM, Lo wrote:
> I just tried python first time.
>
> 2/3
>
> the result is zero
>
> I want the result to be .333...
>
> How do I get this?
Add the following to the top of your program:
from __future__ import division
That tells Python to use the proper kind of divisio
On 2009-03-08, Lo wrote:
> I just tried python first time.
>
> 2/3
>
> the result is zero
>
> I want the result to be .333...
How odd.
> How do I get this?
1./3
--
Grant
--
http://mail.python.org/mailman/listinfo/python-list
Lo schrieb:
I just tried python first time.
2/3
the result is zero
I want the result to be .333...
Well, that's not going to happen - 2/3 is .666 if not done with integers...
How do I get this?
Use floating points.
>>> 2.0 / 3.0
0.3
Diez
--
http://mail.python.org/mailma
On Aug 13, 8:46 am, Sion Arrowsmith <[EMAIL PROTECTED]>
wrote:
> Dave <[EMAIL PROTECTED]> wrote:
> >hitNum = 0
> >stopCnt = 6 + hitNum
> >offSet = 5
>
> >for i in range(0,10,1):
>
> The step argument to range defaults to 1: it's tidier to omit it.
> Similarly, the start argument defaults to 0, so
Dave <[EMAIL PROTECTED]> wrote:
>hitNum = 0
>stopCnt = 6 + hitNum
>offSet = 5
>
>for i in range(0,10,1):
The step argument to range defaults to 1: it's tidier to omit it.
Similarly, the start argument defaults to 0, so you can drop that too.
for i in range(10):
> for x in range(hitNum,len
Dave wrote:
arrrggg, now I feel really dumb..
hitNum = 0
stopCnt = 6 + hitNum
offSet = 5
for i in range(0,10,1):
for x in range(hitNum,len(inLst), 1):
print hitNum, stopCnt
if x == stopCnt: break
hitLst.append(inLst[x])
hitNum +=o
Dave napisał(a):
> Hey there, having a bit of problem iterating through lists before i go
> on any further, here is
> a snip of the script.
> --
> d = "a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 a4 b4 c4 d4 e4 a5 b5
> c5 d5 e5"
> inLst = d.split()
> hitLst = []
>
> hitNum = 0
> stopCnt = 6 + hitN
1 - 100 of 270 matches
Mail list logo