Python Newbie

M

Michael Torrie

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

You should get together with ranging rick so that his python fork can
have unicode done properly then.
 
M

Michael Torrie

Thanks to everyone for all the posts, some friendly some not. I read
all of them with genuine interest.

I just finished reading this entire thread and I don't see any posts
that are unfriendly. Perhaps some of them are calling you on your
inflexibility and lack of experience in languages other than C#. All in
all things seem to be very positive and helpful.
 
J

jmfauth

On 02/23/2013 10:44 AM, jmfauth wrote:

[snip various stupidities]

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

Sorry, what can say?
More memory and slow down!
If you see a progress, I'm seeing a regression.

Did you test Devanagari canonical decomposition? Probably
not. I did it.
I wrote probably more tests than any core developper
and tests doing precisely what this flexible representation
does (not like the tests I saw).

That's the good point of all this story.
It is not every day that, one has two implementations
of the same product, if one wishes to explain, to teach,
to illustrate unicode or the coding of the characters in
general.
Unicode is not different from the other coding schemes and
it behaves exactly in the same way. The solely and basic
difference lies in the set of the *characters* which is broader.
Unicode, the Consortium, uses the term, "Abstract Character
Repertoire".

jmf
 
C

Chris Angelico

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)).

Sounds like IBM DB2 and sqlca.sqlcode - 0 for success, <0 for error,
0 for warning (or in some cases "status" - an SQLCODE of 100 means
"end of result set", which isn't exactly an error but you can't fetch
any more from it; it's akin to Python raising StopIteration to
terminate a for loop).

ChrisA
 
C

Chris Angelico

Pardon, but was that deliberate -> FAIL

:) Yep. It ended up feeling a little contrived, and I should have
changed the word "awesome" before it once "Awesome" got into the
acronym, but yeah, that was deliberate.

ChrisA
 
C

Chris Angelico

On 02/23/2013 10:44 AM, jmfauth wrote:

[snip various stupidities]

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

Sorry, what can say?
More memory and slow down!
If you see a progress, I'm seeing a regression.

Potted summary for those who aren't familiar with jmf's trolling:
Python 3.2 had a major bug in its Unicode handling, meaning that
non-BMP characters were mis-handled. Python 3.3 fixes these AND
improves performance on the whole. The complaints are about *very*
specific use-cases, and the overall string-handling benchmarks have
dramatically improved; but more importantly, the bug is fixed.

There, now you too can killfile him without loss.

ChrisA
 
G

Gene Heskett

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 ;-)

Humm, but what if you are worrying about having enough time just to finish
a bucket list? However, there so much in my bucket, I doubt if I'll ever
see the bottom of it. And of course, looking at it from my side of these
trifocals, the real question is should I put a smiley, or a frowny after
it, so I'll not confuse the issue by doing either.

Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
My views
<http://www.armchairpatriot.com/What Has America Become.shtml>
Our missions are peaceful -- not for conquest. When we do battle, it
is only because we have no choice.
-- Kirk, "The Squire of Gothos", stardate 2124.5
I was taught to respect my elders, but its getting
harder and harder to find any...
 
M

Michael Torrie

Sounds like IBM DB2 and sqlca.sqlcode - 0 for success, <0 for error,
"end of result set", which isn't exactly an error but you can't fetch
any more from it; it's akin to Python raising StopIteration to
terminate a for loop).

All apps that return an error code to the operating system return 0 for
success, any other value for error. All command-line utilities work
this way, all shells, etc. Even Windows command-line apps work this way
(errorlevel is what they call it).
 
M

Matej Cepl

When you learn your first language, you think you're learning to
program, but that's not really accurate. Once you've learned half a
dozen, you begin to understand something of the art of coding as
distinct from any particular language; after that, you can learn any
language fairly easily.

And then you find out that to be REALLY good in one language, you
have to focus on one language, because otherwise you are writing
in some kind of mishmash. The point is that you don’t need to
know any language but to at home in the whole universe of
libraries, idioms, patterns, etc. and if you can manage to be
REALLY at home in more than one (or let’s say two) universes, you
are better than most (professional programmers) I know.

Shakespeare wasn’t good in writing German poetry, as far as
I know.

Matěj
 
M

Michael Torrie

Chris, you are (almost) spot on with the if blocks indentation. This
is what I do, and it has served me well for 15 years.

Most companies, development teams have unified coding style standards
that all programmers must adhere to in the company. They do vary across
different companies of course. Some may require K&R syntax for braces,
others might settle on GNU-like rules. One nice thing about requiring
braces in C-like languages is that it's trivial to run a utility on the
source code to reformat it to the required specification.

The point, though, is that even though you prefer to do if blocks that
way, if you were to change jobs and join the development team in another
company they may require you to format them differently. So we have to
adapt our styles to the needs of the team, the project, and the language.

I have never had a problem fighting indentation for blocks, and it
always seemed natural (just like how I program on paper or the back of
napkins). I am equally at home with C braces too. Seems about the same
to me, except I can simply leave off the braces on python.
 
C

Chris Angelico

All apps that return an error code to the operating system return 0 for
success, any other value for error. All command-line utilities work
this way, all shells, etc. Even Windows command-line apps work this way
(errorlevel is what they call it).

Yep, the 0 = success part is pretty much universal (it's been said
that the cause of the downfall of the Roman empire was that, lacking
zero, they were unable to succeed at anything), but the notion of
negative for errors and positive for warnings isn't as clear;
errorlevels and Unix return codes are positive-only.

ChrisA
 
P

piterrr.dolinski

Hi all,

(Ethan, I like your "resident troll" statement. Highly exit-aining!)

Thanks for all the input. I did not expect to get so much constructive feedback, the more so that my initial attitude towards Python has been less than positive, diplomatically speaking.

Yes, it's true that I am trying to write C# code in Python. It is not goingto change any time soon, if at all - I have done too much C#ing, C++ing before that and C-ing earlier still. What surprises me a bit is that no one has said one word against C#, as a form of retaliation against me not being in love with Python. And C# does have its share of concerns, like any language. So far I like the community a lot better than Python.

I am trying to learn some Python on my own (besides faffing with it on the job, to use a britishizm). I have discovered today there is no do...while type loop. [Sigh]

Peter
 
M

Mark Lawrence

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.

Sorry, what can say?
More memory and slow down!
If you see a progress, I'm seeing a regression.

Potted summary for those who aren't familiar with jmf's trolling:
Python 3.2 had a major bug in its Unicode handling, meaning that
non-BMP characters were mis-handled. Python 3.3 fixes these AND
improves performance on the whole. The complaints are about *very*
specific use-cases, and the overall string-handling benchmarks have
dramatically improved; but more importantly, the bug is fixed.

There, now you too can killfile him without loss.

ChrisA

See also http://bugs.python.org/issue16061 for work being done to handle
edge cases.
 
M

MRAB

Yep, the 0 = success part is pretty much universal (it's been said
that the cause of the downfall of the Roman empire was that, lacking
zero, they were unable to succeed at anything), but the notion of
negative for errors and positive for warnings isn't as clear;
errorlevels and Unix return codes are positive-only.
....although some C functions return a negative error code because a
non-negative value is the number of characters written.
 
M

Michael Torrie

Yes, it's true that I am trying to write C# code in Python. It is not
going to change any time soon, if at all - I have done too much
C#ing, C++ing before that and C-ing earlier still.

Unfortunately as long as do, you'll find Python a less-than-satisfying
experience.

And I'm a bit surprised too because if you tried to program C# as you
would C++, you'd likely also be frustrated. C, C++, and C# all demand
different programming paradigms and even styles (despite the similarity
in the braces). Yet you got used to that.
 
V

Vito De Tullio

You see, Javascript, for one, behaves the same way as Python (no variable
declaration) but JS has curly braces and you know the variable you have
just used is limited in scope to the code within the { }. With Python, you
have to search the whole file.

I don't know if you know javascript, but I think your experience with it is
limited, as you listed two of of the many common pitfalls of javascript:

javascript has optional variable declaration, but if you don't declare a
variable (such as a local variable in a function) it binds itself in the
global scope;

in c/c++/c#/java... curly braces define a new scope, in javascript no.

if you do in javascript

function foo() {
if (some condition) {
a = 'something';
}

alert(a);
}

the moment you call the foo() function (and some condition is true), a
global variable "a" is created. (this time you *really* need to search not
the whole .js file, but the whole project, as there is no "file-level"
globals in javascript)

if you instead use the 'var' keyword to define explicitly a local variable

function foo() {
if (some condition) {
var a = 'something';
}

alert(a);
}

while you don't create a global variable, the "a" variable is still
accessible outside the "if" braces.

this is the reason most javascript linters (most notably jslint) force the
first statement of every function to be the definition of all function
variables.



by this point of view, python and javascript have the same philosophy, but
at least python doesn't allow implicit global variable definition
 
M

Mark Lawrence

... I have discovered today there is no do...while type loop. [Sigh]
No biggie. This is easily simulated with:

while True:
...
if <exit condition>:
break

Less easily simulated is the lack of a switch/case structure. This has
to be done with a less convenient extended if/elif/.../else structure.

Or a dict, there are umpteen recipes showing how to do this.
 
P

piterrr.dolinski

Hi guys,

Question. Have this code

intX = 32 # decl + init int var
intX_asString = None # decl + init with NULL string var

intX_asString = intX.__str__ () # convert int to string

What are these ugly underscores for? _________________str___________________

Peter
 
P

piterrr.dolinski

Hi guys,

Question. Have this code

intX = 32 # decl + init int var
intX_asString = None # decl + init with NULL string var

intX_asString = intX.__str__ () # convert int to string

What are these ugly underscores for? _________________str___________________

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top