Re: [Tutor] How to post: Was Re: The Charms of Gmail

2013-12-23 Thread Andy McKenzie
You know what?  I've been lurking here a long time.  I've asked a few
questions and gotten a few useful responses.

But overwhelmingly, when I think of this list, I find that my instinctive
response is Full of rude, arrogant people.

So screw this.  I don't need to keep reading insults to people who are
trying to ask reasonable questions.  I don't need to read long rants about
how GMail is ruining the world and all its users ought to be banned.  I
don't need to watch people be harassed for daring to top-post.  There's at
least one post in every thread I read here that makes me think This guy's
a jerk... why am I reading this?

I'm done.  With the list, and possibly with Python... it doesn't seem to do
much that other languages I like don't do, and the loudest portion of the
language's advocates -- not the majority, just the loudest -- are just
plain obnoxious.  I don't need that in my life.

Good luck to all of you, and I hope your lives are pleasant.  And I hope
those of you who don't currently know learn how to treat people politely.

Andy McKenzie


On Mon, Dec 23, 2013 at 10:11 AM, Steven D'Aprano st...@pearwood.infowrote:

 On Mon, Dec 23, 2013 at 12:59:15PM +, Mark Lawrence wrote:

  I entirely agree.  I'll offer to supply the cotton wool, baby oil, bibs
  and nappies that we can wrap the newbies up in

 Wrap the newbies up in? Who taught you to speak English? And what's
 with the two spaces after a full stop? It's not 1955 anymore, get with
 the program.

 (See how annoying it is to have the substance of your post completely
 ignored while trivial incidentals are picked on? Are you now even a
 *tiny* bit moved to use a single space after full stops?)


  as we don't want to offend them.

 It's not about *offending* them. It's about being a tedious, shrill
 nagger that makes the whole environment unpleasant for everybody, not
 just the newbies. If you can give advice without being unpleasant and a
 nag, please do so. Would you rather be right, and ignored, or
 effective?


  I mean if we do offend them, they might desert us for
  places such as stackoverflow, where they can read top voted answers that
  are completely wrong.

 I keep hearing people say this about StackOverflow, but whenever I
 google on a question I find plenty of good answers there. Yes, I see
 some pretty wrong or silly or ignorant answers, but not as the top-voted
 answer. Can you show me some of these top-voted but wrong answers?


 --
 Steven
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Beginner Question

2013-10-22 Thread Andy McKenzie
On Tue, Oct 22, 2013 at 10:25 AM, Sven Hennig shenni...@googlemail.comwrote:

 Hello, I would like to learn a programming language and have decided to
 use Python. I have some programming experience and doing well in Python.
 What really causes me problems is OOP.
 I'm just dont get it... I'm missing a really Practical example. In every
 book I've read are the examples of such Class Dog and the function is bark
 . Has anyone an OOP example for me as it is really used in real code, so
 I can better understand the concept? I do not know why this is so hard for
 me.

 Greetings
 Sven


The actual code I have is in PHP, so it's not exactly useful to post here,
but I can give you an outline of a class I used and found useful.  The
class was created to help me manipulate network subnets in an interface to
handle DHCP and DNS on a server.

class subnet:

   def __init__(cidr):
  # Do some stuff with the CIDR notation of the subnet (1.2.3.0/24syntax)

  def netmask:
 # Calculate the netmask and return it (ie, 255.255.255.0)

   def first_ip:
  # Calculate and return the first IP in the range.

   def last_ip:
  # Calculate and return the last IP in the range

   def number_of_addresses:
  # Calculate the number of usable addresses in the range and return
that value

The benefit to me was that I could create an instance of the subnet object
for a group (say, lab_1), and then pull out various information.  Calling
lab_1.first_ip() returns the first possible IP address.  That was a lot
more readable and a lot more concise than something like first_ip(
1.2.3.0/24).


I hope this helps!

Andy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] global variables

2013-08-22 Thread Andy McKenzie
On Thu, Aug 22, 2013 at 10:12 AM, Matthew Ngaha chigga...@gmail.com wrote:

 On Thu, Aug 22, 2013 at 2:52 PM, Chris Down ch...@chrisdown.name wrote:
 I would doubt that anyone has told you don't ever use classes, because
  that's nonsense; you've probably misread a dissuasion from that path in a
  single instance as applying more broadly than was intended.

 I am being totally honest here. I was very confused at the time and i
 said i didn't agree because it's what i had put so much effort into
 learning. They went on to say at some well known Python talks speakers
 have stated why using OOP (especially inheritance, but not excluding
 any others) is very bad design and the same thing can always be
 achieved without it. To be clear they said every use case OOP is the
 worst option. I asked what about GUIs which their design is strongly
 based around OOP? and they sad GUIs are badly designed to begin with
 so it proves the point about OOP.


OK, I'm not a fantastic programmer in any language, but this strikes me as
someone with an axe to grind giving bad advice to new programmers.  Here
are a few of the things that I see wrong with their statements:

1) For almost every option in programming, there's at least one case where
it's a good idea, design-wise.  Saying in every use case OOP is the worst
option is absurd.  Of course there are cases where it's not the worst
option.  There are also cases where it is.  That goes for just about
everything.

2) If they think OOP is always a bad idea, WHY are they using Python?
Isn't object orientation kind of the whole POINT of Python?  From python.org:
Python is an interpreted, object-oriented, high-level programming language
with dynamic semantics.  If they honestly believe that object oriented
programming is always a bad idea, they really need to pick a different
language.  Perl, maybe, although even in Perl people are doing object
oriented work.  I have trouble believing that someone who believes OOP is
inherently bad is a current high-level programmer in Python, unless they're
trapped in a job they don't want to be doing.

3) Bad design in a product does not mean bad design in the tool used to
build it.  I've built some really terrible things out of wood with really
nice tools.  I've watched people use really nice drafting tools to design
houses that would have been unusable for living in.  Saying badly designed
GUIs prove that OOP is bad is, frankly, illogical at best and stupid at
worst.

I strongly suspect that either the speaker they were listening to wasn't
clear, or they weren't clear.  Either that, or the speaker or whoever you
were talking to mis-represented their ability level.

Andy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-20 Thread Andy McKenzie
On Mon, Aug 19, 2013 at 8:18 PM, Leam Hall leamh...@gmail.com wrote:

 All,

 Am I more confused than normal or if I click Reply should it go just to
 the sender instead of the list?


Yep.  Someone decided it didn't make sense for reply to go to the list
that sent the message and should be receiving the reply.  I've never
understood it, even after reading the arguments in favor.

Andy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-20 Thread Andy McKenzie
On Tue, Aug 20, 2013 at 2:53 PM, Alan Gauld alan.ga...@btinternet.comwrote:

 On 20/08/13 13:15, Andy McKenzie wrote:

  Yep.  Someone decided it didn't make sense for reply to go to the list
 that sent the message


 Lists never send messages. People do.

 So reply goes to the *person* who sent the message.
 Which is what mail always does, to modify it for mail
 forwarded by a list server makes no sense whatsoever.
 And it breaks the ability to send to the originator.

 IMHO of course :-)
 http://mail.python.org/mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor


The problem is, as far as I'm concerned the message came from the list.
Needing to go to the dropdown and select Reply to all is just one extra
movement, and it's one I have to make every single time I reply.  In all
honesty, I can't think of a single time that I've wanted to reply to just
the original sender:  that's the point of a mailing list, to have
conversations on it.  I've occasionally been prompted to remember that I
wanted to ask an individual something specific off-list, but it's never
been a direct response to what was posted ON the list.

As to the ability to send to the originator:  I've been on a lot of lists
where the address was munged.  They all included the original sender's
email address in the body, so if I really wanted to send to them, I could.
And the rest of the time (basically always) I didn't have to think about it.

It's basically a practicality thing for me.  On a list where the vast
majority of replies went to the original sender, I'd agree with you.  For
something like this, it's just making me do extra work without providing me
with an extra benefit.

Andy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-20 Thread Andy McKenzie
leam hall wrote:


  The only question I have is what is compelling about being different than
  other lists? Far as I can tell, most reply to the list if you click
 reply.
 
  It's not something to get religious over; if I reply and don't have time
 to
  make sure it goes to those who might be interested, at least it will go
 to
  the person I'm responding to. They can forward it on if it's important
  enough.  :)
 

 Yeah, and top-posting with html mail is similarly taking the easy way
 out.  After all, who cares if everyone else has to put up with your bad
 habits.


Well, since someone else brought it up... I really prefer top posting.  In
general, I don't WANT to reread every message:  I want to quickly get to
whatever is new.  Top posting, much like the return-address munging
question, is a personal preference.  For me, it runs opposite to what this
list requires.  Clearly whoever set up this list agreed with you.

What REALLY gets to me is the people who try to insist that their way is
objectively RIGHT, and everyone else is practicing bad habits, or polluting
the net, or some other nonsense like that.  The fact is, we just have
different work flow preferences.  You like one thing, I like another.  If
you want to present your view rationally and objectively, or talk about
your preferred layouts, that's fine.  But let's not start saying someone
has bad habits because they disagree with you.

Andy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Multiple search and replace?

2013-05-02 Thread Andy McKenzie
Hey folks,

  I'm trying to figure out how to do something, and it feels like it should
be possible, but I can't figure out how.  What I want is to define four
expressions, like so:

(\sNorth\s|\sN\s)(\sSouth\s|\sS\s)(\sEast\s|\sE\s)(\sWest\s|\sW\s)

And then run a replace such that the groups are replaced, in order, with N
, S , E , or W  (capital letters, no spaces before).

It's easy enough to use re.sub to replace ONE of those, and I could just do
that four times, but is there a way to do all at once?  It looks from some
things I've seen like it should be, but I can't figure out how.

Thanks,
  Andy McKenzie
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] multiple versions of python on windows?

2013-04-22 Thread Andy McKenzie
I have no idea on Wing, but I'm using Eclipse with the PyDev plugin, and
I'm able to associate projects with either Python 2.7 or 3.2 in Windows.
 It checks for correct grammar in each, and if I tell it to run as a Python
script, it uses the correct executable.

So if you're not tied to Wing, you might give Eclipse/PyDev a try.

-Andy


On Mon, Apr 22, 2013 at 2:42 AM, Jim Mooney cybervigila...@gmail.comwrote:

 On 21 April 2013 22:47, School northri...@s.dcsdk12.org wrote:
  You can install multiple versions. The programs use the version they
 were assigned to, so there shouldn't be any conflict.

 This brings up the question of installing multiple versions of Wing
 101 IDE. I forget the install but even if I can install in a different
 directory for Py 2.7, Windows awful Registry might trip me up. I've
 grown to love portables since they bypass Windows Worst Idea, but Wing
 isn't one of them.

 If anyone knows, does the paid version of wing allow to switch between
 multipe installs? I know, this is probably a Wing discuss question,
 but I'm burned out on joining discussion groups to ask one question,
 since otherwise Wing is very easy to grasp.

 --
 Jim Mooney

 Today is the day that would have been tomorrow if yesterday was today
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
Hey folks.

I'm just starting to pick up Python, and I'd like to avoid some of the
mistakes I made in the past.  To elaborate on that, my primary
programming/scripting experience is PHP, with a little bit of Perl thrown
in.  Like so many people who write in PHP, I was entirely self-taught, and
would be the first to admit that a lot of what I've written is, well...
wrong.  It works, but it's sloppy and inefficient, because there were
standard constructions and solutions I just didn't know about.  I'd like to
avoid that with Python.

So:  my first two questions to the list.

1) Python 2.7 or 3.x?  I know I'm going to want to do some work with NLTK
(which appears to only have an alpha version out for Python 3), but I've
just gone through the hassle of dealing with an upgrade from PHP 4 to 5.3,
and I'd rather not start learning something that's already obsolete.  Any
words of advice?

2) Best practices.  I have the WROX Press Beginning Python book, which
targets Python 2.  Clearly that's of only limited value if I'm going to go
with Python 3, but it looks like it's at least going to be a good overview.
 But some of the stuff they do seems to be fairly personalized, rather than
trying to follow standards.  Should I just start out with the tutorial from
docs.python.org?  I would assume that that would start putting me in the
right habits from the beginning... is that accurate, or is there a better
way to go?

Thanks in advance,
  Andy McKenzie
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
On Tue, Apr 16, 2013 at 4:18 PM, Dave Angel da...@davea.name wrote:

 On 04/16/2013 11:58 AM, Andy McKenzie wrote:

 Hey folks.

 I'm just starting to pick up Python, and I'd like to avoid some of the
 mistakes I made in the past.  To elaborate on that, my primary
 programming/scripting experience is PHP, with a little bit of Perl thrown
 in.  Like so many people who write in PHP, I was entirely self-taught, and
 would be the first to admit that a lot of what I've written is, well...
 wrong.  It works, but it's sloppy and inefficient, because there were
 standard constructions and solutions I just didn't know about.  I'd like
 to
 avoid that with Python.


 Welcome to the mailing list.  I expect you'll find Python a much cleaner
 language than the other two, though php has some definite convenience for
 its particular niche.




  So:  my first two questions to the list.

 1) Python 2.7 or 3.x?  I know I'm going to want to do some work with NLTK
 (which appears to only have an alpha version out for Python 3), but I've
 just gone through the hassle of dealing with an upgrade from PHP 4 to 5.3,
 and I'd rather not start learning something that's already obsolete.  Any
 words of advice?


 If you have to use a library that's not available yet for 3.x, then you
 need to use 2.x  on the other hand, if you're learning now, maybe that
 library will be available by the time you actually need it.

 For most people, I'd advise against trying to use a tutorial that targets
 a different version than you're running.  If you get frustrated quickly,
 you can get bogged down by the differences when you're just copying an
 exact program out of some book.

 Python 3 in particular has spent some substantial effort cleaning up the
 warts, the biggest one being Unicode.  For beginning programmers using only
 ASCII, probably the main thing that'll bog you down is that print() is now
 a function, rather than a statement, so you need parentheses. But once you
 get used to seeing syntax error, you quickly get the hang of it.  And once
 you do, the function is much nicer.



  2) Best practices.  I have the WROX Press Beginning Python book, which
 targets Python 2.  Clearly that's of only limited value if I'm going to go
 with Python 3, but it looks like it's at least going to be a good
 overview.
   But some of the stuff they do seems to be fairly personalized, rather
 than
 trying to follow standards.  Should I just start out with the tutorial
 from
 docs.python.org?  I would assume that that would start putting me in the
 right habits from the beginning... is that accurate, or is there a better
 way to go?

 Thanks in advance,
Andy McKenzie


 I'd start with the python.org tutorial for the version you're trying to
 learn.  Get serious about trying everything, and don't try to absorb it all
 in one sitting, even though it can be done.

 And use a text editor that helps you indent, or even that colorizes your
 code.  And when you just want to try things, use the interpreter directly.
  It's amazing what you can learn directly from it.  You can ask the
 interpreter lots of questions about an object:

help(obj)
dir(obj)
print( type(obj) )
print( repr(obj) )

 And don't forget to post here when you seem to be stuck.  Sometimes a well
 placed comment beats days of struggling.  When you do get an exception you
 don't understand, paste the whole thing, as well as the code you were
 trying.

 Best of luck.




Thanks for the advice, folks.  Given that it looks like the biggest changes
are unicode handling (which I'm not going to need any time soon) and the
way the print function works, I decided to stick with 2.7.  I'm an IT guy,
though unemployed at the moment, and it occurred to me that I'm familiar
with Python, but not the version your entire established codebase is in
wasn't a great thing to have on a resume.

Since it looks like the new formatting for print -- that is, print(Print
this stuff!) -- works fine in 2.7, I'm just getting myself used to doing
that from the beginning.

I went through the first four or five sections of the tutorial this
afternoon, with a few side trips into things that got me interested, and I
figure I'll do at least one more section after dinner.  I did find it
interesting that one of the first things I wanted to know turned out to be
an extremely common question:  What's the Python equivalent to print_r()
from PHP?  If any of you are familiar with PHP (I know at least a couple
of you seemed to be), you'll know that pprint() (which seems to be the most
common answer) isn't actually very close.  Its output isn't nearly as
readable.

For instance:  output of running print_r on a very short dictionary from
PHP:

Array
(
[key3] = thing3
[key2] = thing2
[key1] = thing1
)

And running pprint on the same dict in Python:

{'key1': 'thing1', 'key2': 'thing2', 'key3': 'thing3'}


I finally decided that a good project would be building a quick function
that recreates the print_r

Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
On Tue, Apr 16, 2013 at 5:31 PM, Dave Angel da...@davea.name wrote:

 On 04/16/2013 05:20 PM, Andy McKenzie wrote:



  SNIP



  Thanks for the advice, folks.  Given that it looks like the biggest
 changes
 are unicode handling (which I'm not going to need any time soon) and the
 way the print function works, I decided to stick with 2.7.  I'm an IT guy,
 though unemployed at the moment, and it occurred to me that I'm familiar
 with Python, but not the version your entire established codebase is in
 wasn't a great thing to have on a resume.

 Since it looks like the new formatting for print -- that is, print(Print
 this stuff!) -- works fine in 2.7, I'm just getting myself used to doing
 that from the beginning.


 The degenerate print, where you're printing exactly one thing, works the
 same.  But if you have two things to print, putting parens around them in
 Python 2.x will cause a tuple to be printed, rather than printing the two
 with a space between.

  print(3,5)  -- version 2.x
 (3, 5)

  print(3,5)  -- version 3.x
 3 5

 To get 3.x functionality, you'd want to use
 from __future__ import print_function

 and I do not think that works in 2.6 or older versions.  It also can be
 awkward even in 2.7 if you're mixing existing code with new print functions.


That's good to know, since I hadn't run into it yet.

So am I correct in understanding that I can just put the from __future__
import print_function in each new 2.7 script, and get identical
functionality to what happens in 3.x?  Or do I need to do that system-wide
somehow?

-Andy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Hello, and a newbie question

2013-04-16 Thread Andy McKenzie
On Tue, Apr 16, 2013 at 7:39 PM, Alan Gauld alan.ga...@btinternet.comwrote:

 On 16/04/13 22:20, Andy McKenzie wrote:

  For instance:  output of running print_r on a very short dictionary from
 PHP:

 Array
 (
  [key3] = thing3
  [key2] = thing2
  [key1] = thing1
 )

 And running pprint on the same dict in Python:

 {'key1': 'thing1', 'key2': 'thing2', 'key3': 'thing3'}


 I finally decided that a good project would be building a quick function
 that recreates the print_r function, and I got that working.  New
 function output, in Python:

 (
  [key3] = thing3
  [key2] = thing2
  [key1] = thing1
 )



 You should probably use {} instead of () as the delimiter to indicate that
 the thing is a dictionary and not a tuple. but otherwise that's a good
 starter project.


Good idea.  I went with () because I was just trying to duplicate the
output in PHP.  Now that I've got that, I can start thinking about
improvements.  Varying the punctuation to match the type would probably be
a good idea.

Thanks,
  Andy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor