Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python Newbie

Reply
Thread Tools

Python Newbie

 
 
Steve Simmons
Guest
Posts: n/a
 
      02-23-2013

On 23/02/2013 16:51, Chris Angelico wrote:
> Steve, why do you say you're not a developer? A score of languages
> under your belt, choosing to write code in your spare time, and
> speaking competently on the comparative merits of different languages
> and why you made the decision you made - sounds like you're every bit
> a coder. Don't run yourself down so! ChrisA


I guess I was a developer back in 1972 when I did 15 months worth of
COBOL and for a while in the late 70's when I was coding in assembler
for ICL machines (24 bit words!) but since then, I've never done enough
with any one language to be able to code without 'the book' open in
front of me, so I'd feel a bit of a fraud if I called myself a
developer. However, what I have done has taught me every computer works
in the same way, from the Raspberry Pi all the way back to those 32Kb
'mainframes' of the 70's and that a compiler/linker or interpreter goes
through a very similar process for any language on any architecture,
although I'm sure someone will reply to this post to tell me that the
Gargleflup 3000 model 6.78.009B was COMPLETELY different or to ask why I
hadn't mentioned the Zurp language if I was so damn knowledgeable.
I suppose that if I had to label myself, it would be 'IT Generalist' but
I've been doing that for over 40 years so I suppose I'm a Specialist
Generalist
 
Reply With Quote
 
 
 
 
Steve Simmons
Guest
Posts: n/a
 
      02-23-2013

On 23/02/2013 18:32, Gene Heskett wrote:
> I am here because I was hoping some knowledge leakage would help me to
> understand python, but at my age I am beginning to have to admit the
> level of abstraction is something I may never fully grok. If I ever
> find a python book that literally starts at square one, it _will_ come
> home with me though. But I have too many hobbies too, I have a BP
> rifle that needs a trip to the range this afternoon for some exercise.
> Cheers, Gene

I'm using Rapid GUI Programming with Python & Qt (Mark Summerfield ISBN
978-0-13-235418-9) - it fits for me because I needed something that
covered GUI development but also had an intro to the language. The
first 3 chapters are a Python intro at a sensible level for experienced
coders (none of this 'here is the keyboard, there is the screen'
nonsense) so it is enough to get you going with Python. The rest is
about Qt/PyQt, taught via manageable examples and giving a fairly well
thought out dialogue (monologue?) of what each line/function does. It
was useful enough for me to want to carry the hardback version with me
on my 'commute' from the UK to Nigeria where I am currently working.
I've also got two books by Wesley Chun, (Core Python Programming & Core
Python Applications Programming) on my Kindle . I can't give you a
sensible verdict on those two because, while I've finally settled to
reading fiction on the Kindle, I still like to have a real book when it
comes to reference works (on any subject) so they haven't had the usage
that Summerfield has.

Oh, and you're never too old for anything but most things take longer -
gives you more time to enjoy them

 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      02-23-2013
On Fri, 22 Feb 2013 15:38:53 -0800 (PST), http://www.velocityreviews.com/forums/(E-Mail Removed)
declaimed the following in gmane.comp.python.general:


> if (some statement): # short form
>
> in the example I gave, but you figured exactly what I mean. Of course if the condition (some statement) is boolean there is no point adding "== true" or similar. But if (some statement) represents a value this is where I have trouble and again the origins of this date back to when Python had no boolean type. So now at least I understand it.
>


Python isn't the only language that will treat non-Boolean as
Boolean, though applying it to strings, floats, other objects may be an
extension (and one which does simplify a lot of code, in my view).

Error codes under DEC VAX/VMS used odd integers for
"success/information" and even integers for "warning/error" (been too
many years, I think positive integers were success/warning, negative
integers were information/error; I could also be wrong on which set were
even... if 0 were no-info/success then odd were errors and even were
success)).

The VAX instruction set only used the least significant bit for
Boolean checks, so one could do a fast check by

if (retCode) then
#assume odd are errors
#examine for "correctible" error codes
#or dump an exception
else
#assume we don't care for specific info messages
#a la: tape already at beginning, if the operation was a rewind
#do normal processing
end if


> Btw, there are still languages with no boolean type today, MySQL for one. This creates big efficiency problems when fetching data from the database into a C# program - what should be a bool is fetched as an 8-byte integer! But that's a different story. I shut up now.
>


SQL itself did not define a Boolean type until the 1999 standard --
and in that standard, Boolean is an optional feature.
http://en.wikipedia.org/wiki/Boolean_data_type#SQL

Apparently few database engines implement a true Boolean.
--
Wulfraed Dennis Lee Bieber AF6VN
(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      02-23-2013
On Sat, 23 Feb 2013 13:18:56 +1100, Chris Angelico <(E-Mail Removed)>
declaimed the following in gmane.comp.python.general:

> awesome Fred's Awesome Internet Language is, it's not going to be as


Pardon, but was that deliberate -> FAIL
--
Wulfraed Dennis Lee Bieber AF6VN
(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
Michael Torrie
Guest
Posts: n/a
 
      02-23-2013
On 02/21/2013 02:26 PM, Piterrr wrote:
> Hi folks. I am a long time C sharp dev, just learning Python now due
> to job requirements. My initial impression is that Python has got to
> be the most ambiguous and vague language I have seen to date. I have
> major issues with the fact that white space matters. How do you deal
> with this?


Well I never use tabs in python files and I don't expect any python
source code file to either. Any that do I consider to be a bug.

But as for whitespace syntax formatting in general, I love it.
Executable pseudo-code makes for more rapid development (and fewer
errors) than in any language I have used to date.
 
Reply With Quote
 
jmfauth
Guest
Posts: n/a
 
      02-23-2013
On 23 fv, 16:43, Steve Simmons <(E-Mail Removed)> wrote:
> On 22/02/2013 22:37, (E-Mail Removed) wrote:> So far I am getting the impression

....
>
> My main message to you would be : *don't approach Python with a negative
> attitude, give it a chance and I'm sure you'll come to enjoy it.
>


----

Until you realize this:

Py32:

>>> timeit.timeit("'abc需'")

0.032749386495456466
>>> sys.getsizeof('abc需')

42

Py33:

>>> timeit.timeit("'abc需'")

0.04104208536801017
>>> sys.getsizeof('abc需')

50

Very easy to explain: wrong, incorrect, naive unicode
handling.

jmf


 
Reply With Quote
 
Michael Torrie
Guest
Posts: n/a
 
      02-23-2013
On 02/21/2013 04:34 PM, (E-Mail Removed) wrote:
> Thanks for this. Regarding ambiguity, you will never find me write
> ambiguous code. I don't sabotage my own work. But the reality is
> that in addition to writing my own code, I have to maintain existing.
> I find it incredibly confusing then I see a statement along the
> lines of "if not something" - have to study the code in detail to see
> what it is testing.


As others have said, I don't see why this should be confusing. It's a
common idiom that happens in C# or C all the time:

if (!some_state)
{
//blah
}

There is absolutely no ambiguity here. Every C# and C programmer knows
exactly what this means. As others have said, it's the equivalent of
saying, ((bool)(expression) != True). Just in a cleaner way and in a
way that echos how most programmers actually think. And in python,
dropping the unnecessary comparisons actually gives you a speed up too.

In python there is some ambiguity as to what constitutes a boolean truth
or falsehood value for some types. For example, an empty list ([]) is
false, as is an empty dictionary ({}), and a number is 0. And in some
cases (default arguments, for example), using a "is None" comparison is
required. For example:

def some_function( a = None):
# None is used above as the default because lists are
# mutable, and if a list were placed up there it would
# affect all subsequent calls to some_function()

if a is None:
a = [ 'default', 'values', 'here']

for x in a:
print x

some_func()
some_func(1,2,3)

> I could show more examples of what I find confusing in existing
> code, but I don't intent to troll. I'm just trying to understand the
> language as it is. I will see how it goes.


As long as you are trying to write C# code in Python, you'll be very
frustrated. Takes some time to learn about what it means to write
"pythonic" code. You'll be well-served and you will start to enjoy the
language more. Ditch the excess parenthesis. They don't make things
clearer necessary and they really confuse what is a statement with what
is an expression (a pet peeve of mine with C).

Finally take some time to learn about how Python works from a language
theory point of view. One interesting thing you'll learn is that python
actually has no variables. This is a powerful concept, but can get you
in trouble sometimes when you're not aware of this fact.
 
Reply With Quote
 
Ethan Furman
Guest
Posts: n/a
 
      02-23-2013
On 02/23/2013 10:44 AM, jmfauth wrote:

[snip various stupidities]

> jmf


Peter, jmfauth is one of our resident trolls. Feel free to ignore him.

--
~Ethan~
 
Reply With Quote
 
Ian Kelly
Guest
Posts: n/a
 
      02-23-2013
On Sat, Feb 23, 2013 at 11:44 AM, jmfauth <(E-Mail Removed)> wrote:
> Until you realize this:
>
> Py32:
>
>>>> timeit.timeit("'abc需'")

> 0.032749386495456466
>>>> sys.getsizeof('abc需')

> 42
>
> Py33:
>
>>>> timeit.timeit("'abc需'")

> 0.04104208536801017
>>>> sys.getsizeof('abc需')

> 50
>
> Very easy to explain: wrong, incorrect, naive unicode
> handling.


You've previously been asked not to hijack unrelated threads with your
misguided Unicode FUD. Since you persist in doing so, consider your
posts now relegated to my trash folder.
 
Reply With Quote
 
Michael Torrie
Guest
Posts: n/a
 
      02-23-2013
On 02/23/2013 11:10 AM, Steve Simmons wrote:
> I'm using Rapid GUI Programming with Python & Qt (Mark Summerfield ISBN
> 978-0-13-235418-9) - it fits for me because I needed something that
> covered GUI development but also had an intro to the language.


Sounds fun. One thing about PyQt is that it's really just C++ thinly
wrapped in python calls. It's not really that pythonic. PySide looks
to be a bit better, with more pythonic ways of interacting with things
(iteration, etc).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib, winzip barfs on Python-2.4.1.tar, cannot download bzip2 Bill Davy Python 12 04-22-2005 12:19 PM
Re: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib,winzip barfs on Python-2.4.1.tar, cannot download bzip2 Jaime Wyant Python 0 04-21-2005 12:49 PM
RE: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib,winzip barfs on Python-2.4.1.tar, cannot download bzip2 Bill Davy Python 0 04-19-2005 09:27 AM
Python Newbie. Python on PPC, please assist. pythonnewbie Python 5 10-12-2004 05:51 PM
Creating an OLE server document in Python (MFC/OLE/COM/Python newbie) Drew Pihera Python 0 02-04-2004 07:48 PM



Advertisments