473,545 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very, Very Green Python User

I have used Perl for a long time, but I am something of an experimental
person and mean to try something new. Most of my 'work' with Vector
Linux entails the use of Perl (a bit of a misnomer as it is not now a
paid position -- I am not yet even out of K-12), and there a lot of
things I love about it. I can look past a number of misfeatures in
Perl, but I am surprised to see that Python has very few (that I know
of). Most of them are documented here, it would seem:
http://www.c2.com/cgi/wiki?PythonProblems. Is the Python debugger
fairly stable? The one you get with Perl stinks on ice. More than
anything else, I would like to have a powerful OO environment where I
do not have to worry about the debugger sucking ass.

A couple blemishes I'm concerned about, though:

Python closures are apparently very poor, but from what I can surmise
of the PyGTK2 page, instances of objects are dynamic enough to add new
methods, so you get your callbacks, at least.

Double-underscore methods are rewritten with the class name? That's an
ugly hack, but remember I'm coming from Perl. If the language doesn't
pull many other hijinks, that's OK.

I have plenty of docs and stuff, now I'm just looking for wisdom. As a
seasoned Python user, what do you have to impart?

Mar 13 '06 #1
17 1620
ha********@gmai l.com wrote:
... Is the Python debugger fairly stable? Yes, but it is not massively featured. The "Pythonic" way is to
rarely use a debugger (test first and straightforward code should
lead to "shallow" bugs). Often for most of us judiciously placed
print statements suffice.
The one you get with Perl stinks on ice. More than
anything else, I would like to have a powerful OO environment where I
do not have to worry about the debugger sucking .... Do watch your language on this newsgroup. Lots of people read this
group and there is no good reason to offend them. In turn, you will be
cut some slack.
A couple blemishes I'm concerned about, though:

Python closures are apparently very poor, but from what I can surmise
of the PyGTK2 page, instances of objects are dynamic enough to add new
methods, so you get your callbacks, at least.
What do you mean by "very poor"? Python prefers you to use functions
defined with a suitable name in places other languages provide stronger
lambda expressions, if that's what you mean. Also, there is no easy way
to affect the variables of an encasing function, if that is what you
mean.
Double-underscore methods are rewritten with the class name? That's an
ugly hack, but remember I'm coming from Perl. If the language doesn't
pull many other hijinks, that's OK.
Double-underscore is a strong language convention and warning. Names
both beginning and ending with double-underscore may be "magic" in
that interacting with them affects more behavior than the same code
using a different name. Instance variables with double-underscore as
a leading convention get "mangled" just so that when you are designing
"mixin" classes you can easily choose names that should not collide
with the instance variable names of classes using your "mixin" classes.
I have plenty of docs and stuff, now I'm just looking for wisdom. As a
seasoned Python user, what do you have to impart?


I think if you spend the effort to learn to use Python you'll have a
wonderful experience. Welcome to the newsgroup.
--Scott David Daniels
sc***********@a cm.org
Mar 13 '06 #2
Scott David Daniels wrote:
... Is the Python debugger fairly stable?

Yes, but it is not massively featured. The "Pythonic" way is to
rarely use a debugger (test first and straightforward code should
lead to "shallow" bugs). Often for most of us judiciously placed
print statements suffice.


combined with a modular design, so you can make sure that individual
functions, classes, and modules work as expected before you use them
to build larger stuff...

</F>

Mar 13 '06 #3
> Python closures are apparently very poor, but from what I can surmise
of the PyGTK2 page, instances of objects are dynamic enough to add new
methods, so you get your callbacks, at least.
It's true that Python's "lambda" is somewhat limited, but this is
rarely a problem because you can define named functions on-the-fly.
Double-underscore methods are rewritten with the class name? That's an ugly hack


Yes, it is. But in practice, you will rarely need to pay attention to
this. I'd been using Python for two years before I noticed this odd
behavior.

I heartily applaud shopping around for new languages. Coming from
Perl, I think you'll find Python to be a figurative breath of fresh
air, but you might also want to look at languages like Ruby, Haskell,
etc.

Mar 13 '06 #4
On 12 Mar 2006 17:58:43 -0800
ha********@gmai l.com wrote:
Double-underscore methods are rewritten with the class
name? That's an ugly hack, but remember I'm coming from
Perl. If the language doesn't pull many other hijinks,
that's OK.


This is GvR's way of saying "do not use double-underscore
methods". ;-)

You shouldn't ever see the mangled _<classname>__< method>
form, unless you've been very, very naughty.

And if you have been, well, we promise not to tell anybody,
but it's Your Problem [TM].

Seriously, truly private methods are generally not something
you want to mess with in Python. Quite frequently, people
with a C++ or Java background come here and ask for them. A
Frequently Repeated Thread ensues:

0) I want private methods in Python

1) you don't need 'em

2) C++ and Java have 'em and the book says you have to
have 'em, or you aren't doin' OOP

3) total hogwash -- I can use compiler directives to
defeat C++/Java "private" variables anyday, so it
doesn't accomplish anything that isn't easier to
do by putting "__" in front of it to tell the client
programmer not to use it.

Then we all go back to coding.

Cheers and good luck with your project, ;-)
Terry

--
Terry Hancock (ha*****@Anansi Spaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com

Mar 14 '06 #5

Scott David Daniels wrote:
ha********@gmai l.com wrote:
> The one you get with Perl stinks on ice. More than
anything else, I would like to have a powerful OO environment where I
do not have to worry about the debugger sucking ....

Do watch your language on this newsgroup. Lots of people read this
group and there is no good reason to offend them. In turn, you will be
cut some slack.


What exactly is your problem with the language used here ?

"Suck" rhymes too closely ?

Are "luck", "ruck", and "puck" offensive too?
And who gets to decide how easily offended "lots of people" are ?

Why do you think *anyone* else is as offended by hanumizzle's language
as others are by your sanctimoniousne ss ?

--
Alan
http://aivipi.blogspot.com

Mar 14 '06 #6
Scott David Daniels wrote:
ha********@gmai l.com wrote:
... Is the Python debugger fairly stable?


Yes, but it is not massively featured. The "Pythonic" way is to
rarely use a debugger (test first and straightforward code should
lead to "shallow" bugs). Often for most of us judiciously placed
print statements suffice.


Well, the fact is that I haven't used pdb on more than two or three
occasions, and I'm using Python since the 1.5.x.
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Mar 14 '06 #7
ha********@gmai l.com wrote:
I have used Perl for a long time, but I am something of an experimental
person and mean to try something new. Most of my 'work' with Vector
Linux entails the use of Perl (a bit of a misnomer as it is not now a
paid position -- I am not yet even out of K-12), and there a lot of
things I love about it. I can look past a number of misfeatures in
Perl, but I am surprised to see that Python has very few (that I know
of). Most of them are documented here, it would seem:
http://www.c2.com/cgi/wiki?PythonProblems.
Seems that this page is sometimes just plain wrong and somewhat
outdated. Let's see some of them:

1/Memory Management The reference implementation uses reference
counting, the worst-performing memory management scheme there is

Actually, Python uses *both* reference-counting and a garbage collector.

2/ No Ternary If
Well... actually true, but not such a major annoyance.
NB : the "tuple_dispatch " option works well if you know how-to python.
IOW, you can avoid useless evaluation with a simple lambda :

result = (lambda: action_if_true, lambda : action_if_false )[test]()

3/ Dynamic Typing
Err... Actually, this is not a problem, Sir, it's a feature.

4/ Speed
Never been a problem for me so far.

5/ Ugly mechanism for privates
This is *not* a mechanism for "privates". This is a mechanism to protect
some crucial implementation attributes from being *accidentally*
overriden in a child class.

6/ SelfDotSyndrome
As for 3, this is definitively a feature. I've always used the implicit
'this' in Java and C++ anyway.

Is the Python debugger
fairly stable?
can't tell, almost never had a use for it.
More than
anything else, I would like to have a powerful OO environment where I
do not have to worry about the debugger sucking ass.
What makes you think you have such a need for a debugger ?
A couple blemishes I'm concerned about, though:

Python closures are apparently very poor,
In Python, encapsuling state is better done with objects. Once you'll
get a better understanding of Python's object model, you'll find out
that there's not such a need for more powerfull closures (well, that's
MHO at least). Amongst other things, functions and methods are objects,
and any other class can be made callable if you implement a method for
the call operator...
but from what I can surmise
of the PyGTK2 page, instances of objects are dynamic enough to add new
methods, so you get your callbacks, at least.
You don't even need this to use callbacks. Remember, functions and
methods are objects, and other objects can be callable too...
Double-underscore methods are rewritten with the class name? That's an
ugly hack,
Ever looked at what a C++ compiler do to symbols ?-)
but remember I'm coming from Perl.


Talking about ugky hacks... !-)
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Mar 14 '06 #8

Scott David Daniels wrote:
ha********@gmai l.com wrote:
... Is the Python debugger fairly stable?

Yes, but it is not massively featured. The "Pythonic" way is to
rarely use a debugger (test first and straightforward code should
lead to "shallow" bugs). Often for most of us judiciously placed
print statements suffice.
> The one you get with Perl stinks on ice. More than
anything else, I would like to have a powerful OO environment where I
do not have to worry about the debugger sucking ....


Do watch your language on this newsgroup. Lots of people read this
group and there is no good reason to offend them. In turn, you will be
cut some slack.


As one who avidly studies language, I have observed that the meaning of
a word slip out of its original context through idiomatic usage. If I
had included the implicit object of 'sucks', then you would have more
grounds for complaint. However, 'sucks', used in the intransitive
sense, is no worse than 'bites the bag'.

Think about the word 'mogul'. Like 'oil mogul' or 'software mogul'.
Well, the **Mughals**, whence comes the word, were mass-murderers:

http://www.geocities.com/hindoo_humanist/mughal.html

If you were a Hindu in those times, saying 'oil mogul', would be
equivalent to saying 'oil Stalin' or 'oil Hitler' today. But this isn't
about human rights so much as it is about semantics. (Nobody likes
long-winded, abstract philosophical discussions on a technology NG.)
'Sucks' doesn't mean what it used to, at least how I used it there.

Unless one is willing to investigate the etymology of every word he
uses (like mogul, Christian, or juggernaut), there needs to be a more
lenient attitude towards use of language.

Mar 15 '06 #9
Exactly...this is how most of my Perl modules are written and tested,
actually.

Mar 15 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1898
by: Syver Enstad | last post by:
Here's the interactive session Python 2.2.2 (#37, Oct 14 2002, 17:02:34) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ord('\xe5') 229 >>> '\xe5'.find(u'') -1 >>> 'p\xe5'.find(u'') UnicodeError: ASCII decoding error: ordinal not in range(128)
16
1588
by: Eric | last post by:
I would want to obtain a list of factors (multiples of 2) given a prime number in python. For example 13=, 5=, 7=, 15= I would appreciate a fuction which would do this. Eric
2
1605
by: Peter Kleiweg | last post by:
This is weird... Running small Python scripts, now and again a window dump is created, and saved as the module name without the extension. This happens on Linux. The dumped file is a PostScript file with the image of one Window that was active at the moment (completely unrelated to the Python application), and has a header comment that...
8
2166
by: York | last post by:
Hi, R language has very high-level IO functions, its read.table can read a total .csv file and recogonize the types of each column. write.table can do the reverse. R's MySQL interface has high-level functions, too, e.g. dbWriteTable can automatically build a MySQL table and write a table of R data into it.
6
2638
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about splitting up the XML into several XML documents (perhaps 50,000 per document) to be more efficient but this will make things a lot more complex because...
17
2422
by: Steve R. Hastings | last post by:
I have been studying Python recently, and I read a comment on one web page that said something like "the people using Python for heavy math really wish they could define their own operators". The specific example was to define an "outer product" operator for matrices. (There was even a PEP, number 211, about this.) I gave it some thought,...
5
1548
by: Jon Guyer | last post by:
>>> This is a fake line to confuse the stupid top-posting filter at gmane We have a rather complicated class that, under certain circumstances, knows that it cannot perform various arithmetic operations, and so returns NotImplemented. As a trivial example: >>> class my: ... def __mul__(self, other): ... return...
50
5657
by: diffuser78 | last post by:
I have just started to learn python. Some said that its slow. Can somebody pin point the issue. Thans
16
2386
by: Durumdara | last post by:
Hi ! I have a problem. I have a little tool that can get data about filesystems and wrote it in python. The main user asked me a GUI for this software. This user is needed a portable program, so I create this kind of the software with Py2Exe.
0
7803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7411
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7749
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5965
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5322
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4942
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1871
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
695
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.